CMS 3D CMS Logo

ElectronLimiter.cc
Go to the documentation of this file.
1 //
2 // V.Ivanchenko 2013/10/19
3 // step limiter and killer for e+,e-
4 //
6 
7 #include "G4ParticleDefinition.hh"
8 #include "G4VEnergyLossProcess.hh"
9 #include "G4LossTableManager.hh"
10 #include "G4Step.hh"
11 #include "G4Track.hh"
12 #include "G4SystemOfUnits.hh"
13 #include "G4TransportationProcessType.hh"
14 
16  : G4VDiscreteProcess("eLimiter", fGeneral)
17 {
18  // set Process Sub Type
19  SetProcessSubType(static_cast<int>(STEP_LIMITER));
20 
21  minStepLimit = p.getParameter<double>("MinStepLimit")*mm;
22  rangeCheckFlag = false;
23  fieldCheckFlag = false;
24  killTrack = false;
25 
26  fIonisation = 0;
27  particle = 0;
28 }
29 
31 {}
32 
33 void ElectronLimiter::BuildPhysicsTable(const G4ParticleDefinition& part)
34 {
35  particle = &part;
36  fIonisation = G4LossTableManager::Instance()->GetEnergyLossProcess(particle);
37  /*
38  std::cout << "ElectronLimiter::BuildPhysicsTable for "
39  << particle->GetParticleName()
40  << " ioni: " << fIonisation << " rangeCheckFlag: " << rangeCheckFlag
41  << " fieldCheckFlag: " << fieldCheckFlag << std::endl;
42  */
43 }
44 
45 G4double
47  G4double,
48  G4ForceCondition* condition)
49 {
50  *condition = NotForced;
51 
52  G4double limit = DBL_MAX;
53  killTrack = false;
54 
55  if(rangeCheckFlag) {
56  G4double safety = aTrack.GetStep()->GetPreStepPoint()->GetSafety();
57  if(safety > minStepLimit) {
58  G4double kinEnergy = aTrack.GetKineticEnergy();
59  G4double range = fIonisation->GetRangeForLoss(kinEnergy,
60  aTrack.GetMaterialCutsCouple());
61  if(safety >= range) {
62  killTrack = true;
63  limit = 0.0;
64  }
65  }
66  }
67  if(!killTrack && fieldCheckFlag) {
68  limit = minStepLimit;
69  }
70 
71  return limit;
72 }
73 
74 inline G4VParticleChange* ElectronLimiter::PostStepDoIt(const G4Track& aTrack,
75  const G4Step&)
76 {
77  fParticleChange.Initialize(aTrack);
78  if(killTrack) {
79  fParticleChange.ProposeTrackStatus(fStopAndKill);
80  fParticleChange.ProposeLocalEnergyDeposit(aTrack.GetKineticEnergy());
81  fParticleChange.SetProposedKineticEnergy(0.0);
82  }
83  return &fParticleChange;
84 }
85 
86 inline G4double ElectronLimiter::GetMeanFreePath(const G4Track&,G4double,
87  G4ForceCondition*)
88 {
89  return DBL_MAX;
90 }
T getParameter(std::string const &) const
G4VEnergyLossProcess * fIonisation
ElectronLimiter(const edm::ParameterSet &p)
G4double minStepLimit
part
Definition: HCALResponse.h:20
virtual G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *)
const G4ParticleDefinition * particle
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4ParticleChangeForGamma fParticleChange
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
virtual ~ElectronLimiter()
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)