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- and other charged particles
4 //
8 
9 #include "G4ParticleDefinition.hh"
10 #include "G4VEnergyLossProcess.hh"
11 #include "G4LossTableManager.hh"
12 #include "G4DummyModel.hh"
13 #include "G4Step.hh"
14 #include "G4Track.hh"
15 #include "G4Region.hh"
16 #include "G4SystemOfUnits.hh"
17 #include "G4TransportationProcessType.hh"
18 
19 ElectronLimiter::ElectronLimiter(const edm::ParameterSet &p, const G4ParticleDefinition *part)
20  : G4VEmProcess("eLimiter", fGeneral),
21  ionisation_(nullptr),
22  particle_(part),
23  nRegions_(0),
24  rangeCheckFlag_(false),
25  fieldCheckFlag_(false),
26  killTrack_(false) {
27  // set Process Sub Type
28  SetProcessSubType(static_cast<int>(STEP_LIMITER));
29  minStepLimit_ = p.getParameter<double>("MinStepLimit") * CLHEP::mm;
31 }
32 
34 
35 void ElectronLimiter::InitialiseProcess(const G4ParticleDefinition *) {
36  G4LossTableManager *lManager = G4LossTableManager::Instance();
37  if (rangeCheckFlag_) {
38  ionisation_ = lManager->GetEnergyLossProcess(particle_);
39  if (!ionisation_) {
40  rangeCheckFlag_ = false;
41  }
42  }
43  AddEmModel(0, new G4DummyModel());
44 
45  if (lManager->IsMaster()) {
46  edm::LogVerbatim("SimG4CoreApplication")
47  << "ElectronLimiter::BuildPhysicsTable for " << particle_->GetParticleName() << " ioni: " << ionisation_
48  << " rangeCheckFlag: " << rangeCheckFlag_ << " fieldCheckFlag: " << fieldCheckFlag_ << " " << nRegions_
49  << " regions for tracking cuts\n";
50  }
51 }
52 
54  G4double previousLimit,
55  G4ForceCondition *condition) {
56  *condition = NotForced;
57  G4double limit = DBL_MAX;
58  killTrack_ = false;
59 
60  G4double kinEnergy = aTrack.GetKineticEnergy();
61  if (0 < nRegions_) {
62  if (regions_[0] == nullptr) {
63  if (kinEnergy < energyLimits_[0]) {
64  killTrack_ = true;
66  limit = 0.0;
67  }
68  } else {
69  const G4Region *reg = aTrack.GetVolume()->GetLogicalVolume()->GetRegion();
70  for (G4int i = 0; i < nRegions_; ++i) {
71  if (reg == regions_[i] && kinEnergy < energyLimits_[i]) {
72  killTrack_ = true;
74  limit = 0.0;
75  break;
76  }
77  }
78  }
79  }
80  if (!killTrack_ && rangeCheckFlag_) {
81  G4double safety = aTrack.GetStep()->GetPreStepPoint()->GetSafety();
82  if (safety > std::min(minStepLimit_, previousLimit)) {
83  G4double range = ionisation_->GetRange(kinEnergy, aTrack.GetMaterialCutsCouple());
84  if (safety >= range) {
85  killTrack_ = true;
86  limit = 0.0;
87  }
88  }
89  }
90  if (!killTrack_ && fieldCheckFlag_) {
92  }
93  return limit;
94 }
95 
96 G4VParticleChange *ElectronLimiter::PostStepDoIt(const G4Track &aTrack, const G4Step &) {
97  fParticleChange.Initialize(aTrack);
98  if (killTrack_) {
99  fParticleChange.ProposeTrackStatus(fStopAndKill);
100  G4double edep = trcut_->SampleEnergyDepositEcal(aTrack.GetKineticEnergy());
101  fParticleChange.ProposeLocalEnergyDeposit(edep);
102  fParticleChange.SetProposedKineticEnergy(0.0);
103  }
104  return &fParticleChange;
105 }
106 
107 G4bool ElectronLimiter::IsApplicable(const G4ParticleDefinition &) { return true; }
108 
110 
111 void ElectronLimiter::SetTrackingCutPerRegion(std::vector<const G4Region *> &reg,
112  std::vector<G4double> &cut,
113  std::vector<G4double> &fac,
114  std::vector<G4double> &rms) {
115  nRegions_ = reg.size();
116  if (nRegions_ > 0) {
117  regions_ = reg;
118  energyLimits_ = cut;
119  factors_ = fac;
120  rms_ = rms;
121  }
122 }
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
CMSTrackingCutModel
Definition: CMSTrackingCutModel.h:14
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
ElectronLimiter::SetTrackingCutPerRegion
void SetTrackingCutPerRegion(std::vector< const G4Region * > &, std::vector< G4double > &, std::vector< G4double > &, std::vector< G4double > &)
Definition: ElectronLimiter.cc:111
min
T min(T a, T b)
Definition: MathUtil.h:58
CMSTrackingCutModel::SampleEnergyDepositEcal
virtual G4double SampleEnergyDepositEcal(G4double kinEnergy)
Definition: CMSTrackingCutModel.cc:18
ElectronLimiter::IsApplicable
G4bool IsApplicable(const G4ParticleDefinition &) override
Definition: ElectronLimiter.cc:107
ElectronLimiter::rms_
std::vector< G4double > rms_
Definition: ElectronLimiter.h:58
ElectronLimiter::regions_
std::vector< const G4Region * > regions_
Definition: ElectronLimiter.h:55
CMSTrackingCutModel.h
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
ElectronLimiter::~ElectronLimiter
~ElectronLimiter() override
Definition: ElectronLimiter.cc:33
ElectronLimiter::rangeCheckFlag_
G4bool rangeCheckFlag_
Definition: ElectronLimiter.h:63
ElectronLimiter::minStepLimit_
G4double minStepLimit_
Definition: ElectronLimiter.h:60
ElectronLimiter::energyLimits_
std::vector< G4double > energyLimits_
Definition: ElectronLimiter.h:56
part
part
Definition: HCALResponse.h:20
ElectronLimiter::trcut_
CMSTrackingCutModel * trcut_
Definition: ElectronLimiter.h:52
ElectronLimiter.h
ElectronLimiter::factors_
std::vector< G4double > factors_
Definition: ElectronLimiter.h:57
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ElectronLimiter::StartTracking
void StartTracking(G4Track *) override
Definition: ElectronLimiter.cc:109
ElectronLimiter::PostStepGetPhysicalInteractionLength
G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override
Definition: ElectronLimiter.cc:53
ElectronLimiter::PostStepDoIt
G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &) override
Definition: ElectronLimiter.cc:96
ElectronLimiter::ElectronLimiter
ElectronLimiter(const edm::ParameterSet &, const G4ParticleDefinition *)
Definition: ElectronLimiter.cc:19
CMSTrackingCutModel::InitialiseForStep
void InitialiseForStep(G4double fac, G4double rms)
Definition: CMSTrackingCutModel.h:31
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
PA_MinBiasSkim_cff.cut
cut
Definition: PA_MinBiasSkim_cff.py:13
ElectronLimiter::ionisation_
G4VEnergyLossProcess * ionisation_
Definition: ElectronLimiter.h:51
ElectronLimiter::particle_
const G4ParticleDefinition * particle_
Definition: ElectronLimiter.h:53
ElectronLimiter::killTrack_
G4bool killTrack_
Definition: ElectronLimiter.h:65
ElectronLimiter::nRegions_
G4int nRegions_
Definition: ElectronLimiter.h:62
ElectronLimiter::InitialiseProcess
void InitialiseProcess(const G4ParticleDefinition *) override
Definition: ElectronLimiter.cc:35
ElectronLimiter::fieldCheckFlag_
G4bool fieldCheckFlag_
Definition: ElectronLimiter.h:64