00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "BDSUserSpecialCuts.hh"
00024
00025 #include "G4Step.hh"
00026 #include "G4UserLimits.hh"
00027 #include "G4VParticleChange.hh"
00028 #include "G4EnergyLossTables.hh"
00029
00030
00031
00032 BDSUserSpecialCuts::BDSUserSpecialCuts(const G4String& aName)
00033 : G4VProcess(aName)
00034 {
00035 if (verboseLevel>0) {
00036 G4cout << GetProcessName() << " is created "<< G4endl;
00037 }
00038 }
00039
00040
00041
00042 BDSUserSpecialCuts::~BDSUserSpecialCuts()
00043 {}
00044
00045
00046
00047 BDSUserSpecialCuts::BDSUserSpecialCuts(BDSUserSpecialCuts& right)
00048 : G4VProcess(right)
00049 {}
00050
00051
00052
00053 G4double BDSUserSpecialCuts::PostStepGetPhysicalInteractionLength(
00054 const G4Track& aTrack,
00055 G4double previousStepSize,
00056 G4ForceCondition* condition
00057 )
00058 {
00059
00060 *condition = NotForced;
00061
00062 G4double ProposedStep = DBL_MAX;
00063 G4UserLimits* pUserLimits = aTrack.GetVolume()->GetLogicalVolume()->GetUserLimits();
00064 if (pUserLimits)
00065 {
00066 ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack) - aTrack.GetTrackLength());
00067 if (ProposedStep < 0.) return 0.;
00068
00069 G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())/(aTrack.GetTotalEnergy());
00070 G4double dTime= (pUserLimits->GetUserMaxTime(aTrack) - aTrack.GetGlobalTime());
00071 G4double temp = beta*c_light*dTime;
00072 if (temp < 0.) return 0.;
00073 if (ProposedStep > temp) ProposedStep = temp;
00074
00075 G4ParticleDefinition* Particle = aTrack.GetDefinition();
00076 if (Particle->GetPDGCharge() != 0.)
00077 {
00078 G4double Ekine = aTrack.GetKineticEnergy();
00079 G4Material* Material = aTrack.GetMaterial();
00080 G4double RangeNow = G4EnergyLossTables::GetRange(Particle,Ekine,Material);
00081 temp = (RangeNow - pUserLimits->GetUserMinRange(aTrack));
00082 if (temp < 0.) return 0.;
00083 if (ProposedStep > temp) ProposedStep = temp;
00084
00085 G4double Emin = pUserLimits->GetUserMinEkine(aTrack);
00086
00087
00088
00089
00090
00091 G4double Rmin = G4EnergyLossTables::GetRange(Particle,Emin,Material);
00092 temp = RangeNow - Rmin;
00093 if (temp < 0.) return 0.;
00094 if (ProposedStep > temp) ProposedStep = temp;
00095 }
00096 }
00097 return ProposedStep;
00098 }
00099
00100
00101
00102 G4VParticleChange* BDSUserSpecialCuts::PostStepDoIt(
00103 const G4Track& aTrack,
00104 const G4Step&
00105 )
00106
00107
00108
00109 {
00110 aParticleChange.Initialize(aTrack);
00111
00112 #if G4VERSION > 6
00113 aParticleChange.ProposeEnergy(0.) ;
00114 aParticleChange.ProposeLocalEnergyDeposit (aTrack.GetKineticEnergy()) ;
00115 #else
00116 aParticleChange.SetEnergyChange(0.) ;
00117 aParticleChange.SetLocalEnergyDeposit (aTrack.GetKineticEnergy()) ;
00118 #endif
00119
00120
00121
00122 return &aParticleChange;
00123 }
00124
00125