CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
StackingAction Class Reference

#include <StackingAction.h>

Inheritance diagram for StackingAction:

Public Member Functions

G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack) final
 
void NewStage () override
 
void PrepareNewEvent () override
 
 StackingAction (const TrackingAction *, const edm::ParameterSet &ps, const CMSSteppingVerbose *)
 
 ~StackingAction () override
 

Private Member Functions

void initPointer ()
 
int isItFromPrimary (const G4Track &, int) const
 
bool isItOutOfTimeWindow (const G4Region *, const double &) const
 
int isItPrimaryDecayProductOrConversion (const int subtype, const G4Track &) const
 
bool isThisRegion (const G4Region *, std::vector< const G4Region *> &) const
 
void printRegions (const std::vector< const G4Region *> &reg, const std::string &word) const
 
bool rrApplicable (const G4Track *, const G4Track &) const
 

Private Attributes

std::vector< const G4Region * > caloRegions
 
std::vector< std::string > deadRegionNames
 
std::vector< const G4Region * > deadRegions
 
TrackInformationExtractor extractor
 
bool gRRactive {false}
 
double gRusRoCastor
 
double gRusRoEcal
 
double gRusRoEnerLim
 
double gRusRoHcal
 
double gRusRoMuonIron
 
double gRusRoPreShower
 
double gRusRoWorld
 
bool killDeltaRay
 
bool killExtra
 
bool killGamma
 
bool killHeavy
 
bool killInCalo {false}
 
bool killInCaloEfH {false}
 
double kmaxGamma
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
double limitEnergyForVacuum
 
std::vector< const G4Region * > lowdensRegions
 
const G4VProcess * m_Compton {nullptr}
 
std::vector< std::string > maxTimeNames
 
std::vector< const G4Region * > maxTimeRegions
 
double maxTrackTime
 
double maxTrackTimeForward
 
std::vector< double > maxTrackTimes
 
double maxZCentralCMS
 
std::vector< const G4Region * > muonRegions
 
NewTrackActionnewTA
 
bool nRRactive {false}
 
double nRusRoCastor
 
double nRusRoEcal
 
double nRusRoEnerLim
 
double nRusRoHcal
 
double nRusRoMuonIron
 
double nRusRoPreShower
 
double nRusRoWorld
 
unsigned int numberTimes
 
const G4Region * regionCastor {nullptr}
 
const G4Region * regionEcal {nullptr}
 
const G4Region * regionHcal {nullptr}
 
const G4Region * regionMuonIron {nullptr}
 
const G4Region * regionPreShower {nullptr}
 
const G4Region * regionWorld {nullptr}
 
bool saveFirstSecondary
 
bool savePDandCinAll
 
bool savePDandCinCalo
 
bool savePDandCinMuon
 
bool savePDandCinTracker
 
const CMSSteppingVerbosesteppingVerbose
 
const TrackingActiontrackAction
 
std::vector< const G4Region * > trackerRegions
 
bool trackNeutrino
 
G4VSolid * worldSolid
 

Detailed Description

Definition at line 20 of file StackingAction.h.

Constructor & Destructor Documentation

◆ StackingAction()

StackingAction::StackingAction ( const TrackingAction trka,
const edm::ParameterSet ps,
const CMSSteppingVerbose sv 
)
explicit

Definition at line 20 of file StackingAction.cc.

References caloRegions, deadRegionNames, deadRegions, gRRactive, gRusRoCastor, gRusRoEcal, gRusRoEnerLim, gRusRoHcal, gRusRoMuonIron, gRusRoPreShower, gRusRoWorld, mps_fire::i, initPointer(), killDeltaRay, killExtra, killGamma, killHeavy, killInCalo, killInCaloEfH, kmaxGamma, kmaxIon, kmaxNeutron, kmaxProton, limitEnergyForVacuum, lowdensRegions, visualization-live-secondInstance_cfg::m, maxTimeNames, maxTrackTime, maxTrackTimeForward, maxTrackTimes, maxZCentralCMS, muonRegions, newTA, nRRactive, nRusRoCastor, nRusRoEcal, nRusRoEnerLim, nRusRoHcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, numberTimes, AlCaHLTBitMon_ParallelJobs::p, printRegions(), saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, trackerRegions, trackNeutrino, and worldSolid.

21  : trackAction(trka), steppingVerbose(sv) {
22  trackNeutrino = p.getParameter<bool>("TrackNeutrino");
23  killHeavy = p.getParameter<bool>("KillHeavy");
24  killGamma = p.getParameter<bool>("KillGamma");
25  kmaxGamma = p.getParameter<double>("GammaThreshold") * CLHEP::MeV;
26  kmaxIon = p.getParameter<double>("IonThreshold") * CLHEP::MeV;
27  kmaxProton = p.getParameter<double>("ProtonThreshold") * CLHEP::MeV;
28  kmaxNeutron = p.getParameter<double>("NeutronThreshold") * CLHEP::MeV;
29  killDeltaRay = p.getParameter<bool>("KillDeltaRay");
30  limitEnergyForVacuum = p.getParameter<double>("CriticalEnergyForVacuum") * CLHEP::MeV;
31  maxTrackTime = p.getParameter<double>("MaxTrackTime") * ns;
32  maxTrackTimeForward = p.getParameter<double>("MaxTrackTimeForward") * ns;
33  maxZCentralCMS = p.getParameter<double>("MaxZCentralCMS") * CLHEP::m;
34  maxTrackTimes = p.getParameter<std::vector<double> >("MaxTrackTimes");
35  maxTimeNames = p.getParameter<std::vector<std::string> >("MaxTimeNames");
36  deadRegionNames = p.getParameter<std::vector<std::string> >("DeadRegions");
37  savePDandCinAll = p.getUntrackedParameter<bool>("SaveAllPrimaryDecayProductsAndConversions", true);
38  savePDandCinTracker = p.getUntrackedParameter<bool>("SavePrimaryDecayProductsAndConversionsInTracker", false);
39  savePDandCinCalo = p.getUntrackedParameter<bool>("SavePrimaryDecayProductsAndConversionsInCalo", false);
40  savePDandCinMuon = p.getUntrackedParameter<bool>("SavePrimaryDecayProductsAndConversionsInMuon", false);
41  saveFirstSecondary = p.getUntrackedParameter<bool>("SaveFirstLevelSecondary", false);
42 
43  gRusRoEnerLim = p.getParameter<double>("RusRoGammaEnergyLimit") * CLHEP::MeV;
44  nRusRoEnerLim = p.getParameter<double>("RusRoNeutronEnergyLimit") * CLHEP::MeV;
45 
46  gRusRoEcal = p.getParameter<double>("RusRoEcalGamma");
47  gRusRoHcal = p.getParameter<double>("RusRoHcalGamma");
48  gRusRoMuonIron = p.getParameter<double>("RusRoMuonIronGamma");
49  gRusRoPreShower = p.getParameter<double>("RusRoPreShowerGamma");
50  gRusRoCastor = p.getParameter<double>("RusRoCastorGamma");
51  gRusRoWorld = p.getParameter<double>("RusRoWorldGamma");
52 
53  nRusRoEcal = p.getParameter<double>("RusRoEcalNeutron");
54  nRusRoHcal = p.getParameter<double>("RusRoHcalNeutron");
55  nRusRoMuonIron = p.getParameter<double>("RusRoMuonIronNeutron");
56  nRusRoPreShower = p.getParameter<double>("RusRoPreShowerNeutron");
57  nRusRoCastor = p.getParameter<double>("RusRoCastorNeutron");
58  nRusRoWorld = p.getParameter<double>("RusRoWorldNeutron");
59 
60  if (gRusRoEnerLim > 0.0 && (gRusRoEcal < 1.0 || gRusRoHcal < 1.0 || gRusRoMuonIron < 1.0 || gRusRoPreShower < 1.0 ||
61  gRusRoCastor < 1.0 || gRusRoWorld < 1.0)) {
62  gRRactive = true;
63  }
64  if (nRusRoEnerLim > 0.0 && (nRusRoEcal < 1.0 || nRusRoHcal < 1.0 || nRusRoMuonIron < 1.0 || nRusRoPreShower < 1.0 ||
65  nRusRoCastor < 1.0 || nRusRoWorld < 1.0)) {
66  nRRactive = true;
67  }
68 
69  if (p.exists("TestKillingOptions")) {
70  killInCalo = (p.getParameter<edm::ParameterSet>("TestKillingOptions")).getParameter<bool>("KillInCalo");
71  killInCaloEfH = (p.getParameter<edm::ParameterSet>("TestKillingOptions")).getParameter<bool>("KillInCaloEfH");
72  edm::LogWarning("SimG4CoreApplication")
73  << " *** Activating special test killing options in StackingAction \n"
74  << " *** Kill secondaries in Calorimetetrs volume = " << killInCalo << "\n"
75  << " *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= " << killInCaloEfH;
76  }
77 
78  initPointer();
79  newTA = new NewTrackAction();
80 
81  edm::LogVerbatim("SimG4CoreApplication")
82  << "StackingAction initiated with"
83  << " flag for saving decay products in "
84  << " Tracker: " << savePDandCinTracker << " in Calo: " << savePDandCinCalo << " in Muon: " << savePDandCinMuon
85  << " everywhere: " << savePDandCinAll << "\n saveFirstSecondary"
86  << ": " << saveFirstSecondary << " Tracking neutrino flag: " << trackNeutrino
87  << " Kill Delta Ray flag: " << killDeltaRay << " Kill hadrons/ions flag: " << killHeavy
88  << " MaxZCentralCMS = " << maxZCentralCMS / CLHEP::m << " m"
89  << " MaxTrackTimeForward = " << maxTrackTimeForward / CLHEP::ns << " ns";
90 
91  if (killHeavy) {
92  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction kill protons below " << kmaxProton / CLHEP::MeV
93  << " MeV, neutrons below " << kmaxNeutron / CLHEP::MeV << " MeV and ions"
94  << " below " << kmaxIon / CLHEP::MeV << " MeV";
95  }
97 
98  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction kill tracks with "
99  << "time larger than " << maxTrackTime / CLHEP::ns << " ns ";
100  numberTimes = maxTimeNames.size();
101  if (0 < numberTimes) {
102  for (unsigned int i = 0; i < numberTimes; ++i) {
103  edm::LogVerbatim("SimG4CoreApplication")
104  << " MaxTrackTime for " << maxTimeNames[i] << " is " << maxTrackTimes[i] << " ns ";
105  maxTrackTimes[i] *= CLHEP::ns;
106  }
107  }
108  if (limitEnergyForVacuum > 0.0) {
109  edm::LogVerbatim("SimG4CoreApplication")
110  << "StackingAction LowDensity regions - kill if E < " << limitEnergyForVacuum / CLHEP::MeV << " MeV";
111  printRegions(lowdensRegions, "LowDensity");
112  }
113  if (deadRegions.size() > 0.0) {
114  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Dead regions - kill all secondaries ";
115  printRegions(deadRegions, "Dead");
116  }
117  if (gRRactive) {
118  edm::LogVerbatim("SimG4CoreApplication")
119  << "StackingAction: "
120  << "Russian Roulette for gamma Elimit(MeV)= " << gRusRoEnerLim / CLHEP::MeV << "\n"
121  << " ECAL Prob= " << gRusRoEcal << "\n"
122  << " HCAL Prob= " << gRusRoHcal << "\n"
123  << " MuonIron Prob= " << gRusRoMuonIron << "\n"
124  << " PreShower Prob= " << gRusRoPreShower << "\n"
125  << " CASTOR Prob= " << gRusRoCastor << "\n"
126  << " World Prob= " << gRusRoWorld;
127  }
128  if (nRRactive) {
129  edm::LogVerbatim("SimG4CoreApplication")
130  << "StackingAction: "
131  << "Russian Roulette for neutron Elimit(MeV)= " << nRusRoEnerLim / CLHEP::MeV << "\n"
132  << " ECAL Prob= " << nRusRoEcal << "\n"
133  << " HCAL Prob= " << nRusRoHcal << "\n"
134  << " MuonIron Prob= " << nRusRoMuonIron << "\n"
135  << " PreShower Prob= " << nRusRoPreShower << "\n"
136  << " CASTOR Prob= " << nRusRoCastor << "\n"
137  << " World Prob= " << nRusRoWorld;
138  }
139 
140  if (savePDandCinTracker) {
141  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Tracker regions: ";
142  printRegions(trackerRegions, "Tracker");
143  }
144  if (savePDandCinCalo) {
145  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Calo regions: ";
146  printRegions(caloRegions, "Calo");
147  }
148  if (savePDandCinMuon) {
149  edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Muon regions: ";
150  printRegions(muonRegions, "Muon");
151  }
152  worldSolid = G4TransportationManager::GetTransportationManager()
153  ->GetNavigatorForTracking()
154  ->GetWorldVolume()
155  ->GetLogicalVolume()
156  ->GetSolid();
157 }
double nRusRoPreShower
Log< level::Info, true > LogVerbatim
NewTrackAction * newTA
std::vector< const G4Region * > lowdensRegions
double maxZCentralCMS
std::vector< double > maxTrackTimes
double gRusRoPreShower
double nRusRoEnerLim
std::vector< const G4Region * > deadRegions
const CMSSteppingVerbose * steppingVerbose
std::vector< const G4Region * > muonRegions
std::vector< std::string > maxTimeNames
unsigned int numberTimes
void printRegions(const std::vector< const G4Region *> &reg, const std::string &word) const
double nRusRoMuonIron
G4VSolid * worldSolid
bool savePDandCinTracker
std::vector< std::string > deadRegionNames
double gRusRoEnerLim
double maxTrackTimeForward
const TrackingAction * trackAction
Log< level::Warning, false > LogWarning
double gRusRoMuonIron
std::vector< const G4Region * > trackerRegions
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum

◆ ~StackingAction()

StackingAction::~StackingAction ( )
override

Definition at line 159 of file StackingAction.cc.

References newTA.

159 { delete newTA; }
NewTrackAction * newTA

Member Function Documentation

◆ ClassifyNewTrack()

G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack ( const G4Track *  aTrack)
final

Definition at line 161 of file StackingAction.cc.

References funct::abs(), caloRegions, deadRegions, RemoveAddSevLevel::flag, g4SimHits_cfi::G4GammaGeneralProcess, TrackingAction::geant4Track(), gRRactive, gRusRoCastor, gRusRoEcal, gRusRoEnerLim, gRusRoHcal, gRusRoMuonIron, gRusRoPreShower, gRusRoWorld, isItFromPrimary(), isItOutOfTimeWindow(), isItPrimaryDecayProductOrConversion(), isThisRegion(), killDeltaRay, killExtra, killGamma, killHeavy, killInCalo, killInCaloEfH, kmaxGamma, kmaxIon, kmaxNeutron, kmaxProton, limitEnergyForVacuum, LogDebug, lowdensRegions, m_Compton, maxTrackTimeForward, maxZCentralCMS, muonRegions, newTA, nRRactive, nRusRoCastor, nRusRoEcal, nRusRoEnerLim, nRusRoHcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, AlCaHLTBitMon_ParallelJobs::p, NewTrackAction::primary(), TtFullHadEvtBuilder_cfi::prob, regionCastor, regionEcal, regionHcal, regionMuonIron, regionPreShower, regionWorld, rrApplicable(), saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, NewTrackAction::secondary(), CMSSteppingVerbose::StackFilled(), steppingVerbose, protons_cff::time, HLT_2023v12_cff::track, trackAction, trackerRegions, trackNeutrino, and worldSolid.

161  {
162  // G4 interface part
163  G4ClassificationOfNewTrack classification = fUrgent;
164  const int pdg = aTrack->GetDefinition()->GetPDGEncoding();
165  const int abspdg = std::abs(pdg);
166  auto track = const_cast<G4Track*>(aTrack);
167  const G4VProcess* creatorProc = aTrack->GetCreatorProcess();
168 
169  if (creatorProc == nullptr && aTrack->GetParentID() != 0) {
170  edm::LogWarning("StackingAction::ClassifyNewTrack")
171  << " TrackID=" << aTrack->GetTrackID() << " ParentID=" << aTrack->GetParentID() << " "
172  << aTrack->GetDefinition()->GetParticleName() << " Ekin(MeV)=" << aTrack->GetKineticEnergy();
173  }
174  if (aTrack->GetKineticEnergy() < 0.0) {
175  edm::LogWarning("StackingAction::ClassifyNewTrack")
176  << " TrackID=" << aTrack->GetTrackID() << " ParentID=" << aTrack->GetParentID() << " "
177  << aTrack->GetDefinition()->GetParticleName() << " Ekin(MeV)=" << aTrack->GetKineticEnergy() << " creator "
178  << creatorProc->GetProcessName();
179  }
180  // primary
181  if (creatorProc == nullptr || aTrack->GetParentID() == 0) {
182  if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
183  classification = fKill;
184  } else if (worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
185  classification = fKill;
186  } else {
187  newTA->primary(track);
188  }
189  } else {
190  // secondary
191  const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
192  const double time = aTrack->GetGlobalTime();
193 
194  // definetly killed tracks
195  if (aTrack->GetTrackStatus() == fStopAndKill) {
196  classification = fKill;
197  } else if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
198  classification = fKill;
199 
200  } else if (std::abs(aTrack->GetPosition().z()) >= maxZCentralCMS) {
201  // very forward secondary
202  if (time > maxTrackTimeForward) {
203  classification = fKill;
204  } else {
205  const G4Track* mother = trackAction->geant4Track();
206  newTA->secondary(track, *mother, 0);
207  }
208 
209  } else if (isItOutOfTimeWindow(reg, time)) {
210  // time window check
211  classification = fKill;
212 
213  } else {
214  // potentially good for tracking
215  const double ke = aTrack->GetKineticEnergy();
216  G4int subType = (nullptr != creatorProc) ? creatorProc->GetProcessSubType() : 0;
217  // VI: this part of code is needed for Geant4 10.7 only
218  if (subType == 16) {
219  auto ptr = dynamic_cast<const G4GammaGeneralProcess*>(creatorProc);
220  if (nullptr != ptr) {
221  creatorProc = ptr->GetSelectedProcess();
222  if (nullptr == creatorProc) {
223  if (nullptr == m_Compton) {
224  auto vp = G4LossTableManager::Instance()->GetEmProcessVector();
225  for (auto& p : vp) {
226  if (fComptonScattering == p->GetProcessSubType()) {
227  m_Compton = p;
228  break;
229  }
230  }
231  }
232  creatorProc = m_Compton;
233  }
234  subType = creatorProc->GetProcessSubType();
235  track->SetCreatorProcess(creatorProc);
236  }
237  if (creatorProc == nullptr) {
238  edm::LogWarning("StackingAction::ClassifyNewTrack")
239  << " SubType=16 and no creatorProc; TrackID=" << aTrack->GetTrackID()
240  << " ParentID=" << aTrack->GetParentID() << " " << aTrack->GetDefinition()->GetParticleName()
241  << " Ekin(MeV)=" << ke << " SubType=" << subType;
242  }
243  }
244  // VI - end
245  LogDebug("SimG4CoreApplication") << "##StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent "
246  << aTrack->GetParentID() << " " << aTrack->GetDefinition()->GetParticleName()
247  << " Ekin(MeV)=" << ke / CLHEP::MeV << " subType=" << subType << " ";
248 
249  // kill tracks in specific regions
250  if (isThisRegion(reg, deadRegions)) {
251  classification = fKill;
252  }
253  if (classification != fKill && ke <= limitEnergyForVacuum && isThisRegion(reg, lowdensRegions)) {
254  classification = fKill;
255 
256  } else if (classification != fKill) {
257  // very low-energy gamma
258  if (pdg == 22 && killGamma && ke < kmaxGamma) {
259  classification = fKill;
260  }
261 
262  // specific track killing - not for production
263  if (killExtra && classification != fKill) {
264  if (killHeavy && classification != fKill) {
265  if (((pdg / 1000000000 == 1) && (((pdg / 10000) % 100) > 0) && (((pdg / 10) % 100) > 0) &&
266  (ke < kmaxIon)) ||
267  ((pdg == 2212) && (ke < kmaxProton)) || ((pdg == 2112) && (ke < kmaxNeutron))) {
268  classification = fKill;
269  }
270  }
271 
272  if (killDeltaRay && classification != fKill && subType == fIonisation) {
273  classification = fKill;
274  }
275  if (killInCalo && classification != fKill && isThisRegion(reg, caloRegions)) {
276  classification = fKill;
277  }
278  if (killInCaloEfH && classification != fKill) {
279  int pdgMother = std::abs(trackAction->geant4Track()->GetDefinition()->GetPDGEncoding());
280  if ((pdg == 22 || abspdg == 11) && pdgMother != 11 && pdgMother != 22 && isThisRegion(reg, caloRegions)) {
281  classification = fKill;
282  }
283  }
284  }
285 
286  // Russian roulette && MC truth
287  if (classification != fKill) {
288  const G4Track* mother = trackAction->geant4Track();
289  int flag = 0;
290  if (savePDandCinAll) {
291  flag = isItPrimaryDecayProductOrConversion(subType, *mother);
292  } else {
296  flag = isItPrimaryDecayProductOrConversion(subType, *mother);
297  }
298  }
299  if (saveFirstSecondary && 0 == flag) {
300  flag = isItFromPrimary(*mother, flag);
301  }
302 
303  // Russian roulette
304  if (2112 == pdg || 22 == pdg) {
305  double currentWeight = aTrack->GetWeight();
306 
307  if (1.0 >= currentWeight) {
308  double prob = 1.0;
309  double elim = 0.0;
310 
311  // neutron
312  if (nRRactive && pdg == 2112) {
313  elim = nRusRoEnerLim;
314  if (reg == regionEcal) {
315  prob = nRusRoEcal;
316  } else if (reg == regionHcal) {
317  prob = nRusRoHcal;
318  } else if (reg == regionMuonIron) {
320  } else if (reg == regionPreShower) {
322  } else if (reg == regionCastor) {
323  prob = nRusRoCastor;
324  } else if (reg == regionWorld) {
325  prob = nRusRoWorld;
326  }
327 
328  // gamma
329  } else if (gRRactive && pdg == 22) {
330  elim = gRusRoEnerLim;
331  if (reg == regionEcal || reg == regionPreShower) {
332  if (rrApplicable(aTrack, *mother)) {
333  if (reg == regionEcal) {
334  prob = gRusRoEcal;
335  } else {
337  }
338  }
339  } else {
340  if (reg == regionHcal) {
341  prob = gRusRoHcal;
342  } else if (reg == regionMuonIron) {
344  } else if (reg == regionCastor) {
345  prob = gRusRoCastor;
346  } else if (reg == regionWorld) {
347  prob = gRusRoWorld;
348  }
349  }
350  }
351  if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
352  if (G4UniformRand() < prob) {
353  track->SetWeight(currentWeight / prob);
354  } else {
355  classification = fKill;
356  }
357  }
358  }
359  }
360  if (classification != fKill) {
361  newTA->secondary(track, *mother, flag);
362  }
363  LogDebug("SimG4CoreApplication")
364  << "StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent " << aTrack->GetParentID()
365  << " Type " << aTrack->GetDefinition()->GetParticleName() << " Ekin=" << ke / CLHEP::MeV
366  << " MeV from process subType=" << subType << " as " << classification << " Flag: " << flag;
367  }
368  }
369  }
370  }
371  if (nullptr != steppingVerbose) {
372  steppingVerbose->StackFilled(aTrack, (classification == fKill));
373  }
374  return classification;
375 }
double nRusRoPreShower
NewTrackAction * newTA
std::vector< const G4Region * > lowdensRegions
double maxZCentralCMS
bool rrApplicable(const G4Track *, const G4Track &) const
double gRusRoPreShower
double nRusRoEnerLim
const G4Region * regionCastor
const G4Region * regionMuonIron
const G4Track * geant4Track() const
int isItFromPrimary(const G4Track &, int) const
std::vector< const G4Region * > deadRegions
const G4VProcess * m_Compton
const CMSSteppingVerbose * steppingVerbose
std::vector< const G4Region * > muonRegions
const G4Region * regionEcal
double nRusRoMuonIron
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
G4VSolid * worldSolid
bool isItOutOfTimeWindow(const G4Region *, const double &) const
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
bool isThisRegion(const G4Region *, std::vector< const G4Region *> &) const
void primary(const G4Track *aSecondary) const
bool savePDandCinTracker
double gRusRoEnerLim
const G4Region * regionHcal
double maxTrackTimeForward
void StackFilled(const G4Track *, bool isKilled) const
const G4Region * regionPreShower
const TrackingAction * trackAction
Log< level::Warning, false > LogWarning
double gRusRoMuonIron
std::vector< const G4Region * > trackerRegions
int isItPrimaryDecayProductOrConversion(const int subtype, const G4Track &) const
#define LogDebug(id)
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum
const G4Region * regionWorld

◆ initPointer()

void StackingAction::initPointer ( )
private

Definition at line 381 of file StackingAction.cc.

References caloRegions, deadRegionNames, deadRegions, gRusRoCastor, gRusRoEcal, gRusRoHcal, gRusRoMuonIron, gRusRoPreShower, gRusRoWorld, mps_fire::i, lowdensRegions, maxTimeNames, maxTimeRegions, muonRegions, nRusRoCastor, nRusRoEcal, nRusRoHcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, EgammaValidation_cff::num, regionCastor, regionEcal, regionHcal, regionMuonIron, regionPreShower, regionWorld, rname, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, and trackerRegions.

Referenced by StackingAction().

381  {
382  // prepare region vector
383  const unsigned int num = maxTimeNames.size();
384  maxTimeRegions.resize(num, nullptr);
385 
386  // Russian roulette
387  const std::vector<G4Region*>* rs = G4RegionStore::GetInstance();
388 
389  for (auto& reg : *rs) {
390  const G4String& rname = reg->GetName();
391  if ((gRusRoEcal < 1.0 || nRusRoEcal < 1.0) && rname == "EcalRegion") {
392  regionEcal = reg;
393  }
394  if ((gRusRoHcal < 1.0 || nRusRoHcal < 1.0) && rname == "HcalRegion") {
395  regionHcal = reg;
396  }
397  if ((gRusRoMuonIron < 1.0 || nRusRoMuonIron < 1.0) && rname == "MuonIron") {
398  regionMuonIron = reg;
399  }
400  if ((gRusRoPreShower < 1.0 || nRusRoPreShower < 1.0) && rname == "PreshowerRegion") {
401  regionPreShower = reg;
402  }
403  if ((gRusRoCastor < 1.0 || nRusRoCastor < 1.0) && rname == "CastorRegion") {
404  regionCastor = reg;
405  }
406  if ((gRusRoWorld < 1.0 || nRusRoWorld < 1.0) && rname == "DefaultRegionForTheWorld") {
407  regionWorld = reg;
408  }
409 
410  // time limits
411  for (unsigned int i = 0; i < num; ++i) {
412  if (rname == (G4String)(maxTimeNames[i])) {
413  maxTimeRegions[i] = reg;
414  break;
415  }
416  }
417  //
418  if (savePDandCinTracker &&
419  (rname == "BeamPipe" || rname == "BeamPipeVacuum" || rname == "TrackerPixelSensRegion" ||
420  rname == "TrackerPixelDeadRegion" || rname == "TrackerDeadRegion" || rname == "TrackerSensRegion" ||
421  rname == "FastTimerRegion" || rname == "FastTimerRegionSensBTL" || rname == "FastTimerRegionSensETL")) {
422  trackerRegions.push_back(reg);
423  }
424  if (savePDandCinCalo && (rname == "HcalRegion" || rname == "EcalRegion" || rname == "PreshowerSensRegion" ||
425  rname == "PreshowerRegion" || rname == "APDRegion" || rname == "HGCalRegion")) {
426  caloRegions.push_back(reg);
427  }
428  if (savePDandCinMuon && (rname == "MuonChamber" || rname == "MuonSensitive_RPC" || rname == "MuonIron" ||
429  rname == "Muon" || rname == "MuonSensitive_DT-CSC")) {
430  muonRegions.push_back(reg);
431  }
432  if (rname == "BeamPipeOutside" || rname == "BeamPipeVacuum") {
433  lowdensRegions.push_back(reg);
434  }
435  for (auto& dead : deadRegionNames) {
436  if (rname == (G4String)(dead)) {
437  deadRegions.push_back(reg);
438  }
439  }
440  }
441 }
double nRusRoPreShower
std::vector< const G4Region * > lowdensRegions
double gRusRoPreShower
const G4Region * regionCastor
const G4Region * regionMuonIron
std::vector< const G4Region * > deadRegions
std::vector< const G4Region * > muonRegions
std::vector< std::string > maxTimeNames
const G4Region * regionEcal
double nRusRoMuonIron
bool savePDandCinTracker
std::vector< std::string > deadRegionNames
const G4Region * regionHcal
std::vector< const G4Region * > maxTimeRegions
const G4String rname[NREG]
const G4Region * regionPreShower
double gRusRoMuonIron
std::vector< const G4Region * > trackerRegions
std::vector< const G4Region * > caloRegions
const G4Region * regionWorld

◆ isItFromPrimary()

int StackingAction::isItFromPrimary ( const G4Track &  mother,
int  flagIn 
) const
private

Definition at line 476 of file StackingAction.cc.

References RemoveAddSevLevel::flag, and TrackInformation::isPrimary().

Referenced by ClassifyNewTrack().

476  {
477  int flag = flagIn;
478  if (flag != 1) {
479  const TrackInformation* ptr = static_cast<TrackInformation*>(mother.GetUserInformation());
480  if (ptr->isPrimary()) {
481  flag = 3;
482  }
483  }
484  return flag;
485 }
bool isPrimary() const

◆ isItOutOfTimeWindow()

bool StackingAction::isItOutOfTimeWindow ( const G4Region *  reg,
const double &  t 
) const
private

Definition at line 487 of file StackingAction.cc.

References mps_fire::i, maxTimeRegions, maxTrackTime, maxTrackTimes, numberTimes, and submitPVValidationJobs::t.

Referenced by ClassifyNewTrack().

487  {
488  double tofM = maxTrackTime;
489  for (unsigned int i = 0; i < numberTimes; ++i) {
490  if (reg == maxTimeRegions[i]) {
491  tofM = maxTrackTimes[i];
492  break;
493  }
494  }
495  return (t > tofM);
496 }
std::vector< double > maxTrackTimes
unsigned int numberTimes
std::vector< const G4Region * > maxTimeRegions

◆ isItPrimaryDecayProductOrConversion()

int StackingAction::isItPrimaryDecayProductOrConversion ( const int  subtype,
const G4Track &  mother 
) const
private

Definition at line 454 of file StackingAction.cc.

References extractor, hydjet2DefaultParameters_cff::fDecay, RemoveAddSevLevel::flag, and TrackInformation::isPrimary().

Referenced by ClassifyNewTrack().

454  {
455  int flag = 0;
456  const TrackInformation& motherInfo(extractor(mother));
457  // Check whether mother is a primary
458  if (motherInfo.isPrimary()) {
459  if (stype == fDecay) {
460  flag = 1;
461  } else if (stype == fGammaConversion) {
462  flag = 2;
463  }
464  }
465  return flag;
466 }
TrackInformationExtractor extractor

◆ isThisRegion()

bool StackingAction::isThisRegion ( const G4Region *  reg,
std::vector< const G4Region *> &  regions 
) const
private

Definition at line 443 of file StackingAction.cc.

References RemoveAddSevLevel::flag, and HLT_2023v12_cff::region.

Referenced by ClassifyNewTrack().

443  {
444  bool flag = false;
445  for (auto& region : regions) {
446  if (reg == region) {
447  flag = true;
448  break;
449  }
450  }
451  return flag;
452 }

◆ NewStage()

void StackingAction::NewStage ( )
override

Definition at line 377 of file StackingAction.cc.

377 {}

◆ PrepareNewEvent()

void StackingAction::PrepareNewEvent ( )
override

Definition at line 379 of file StackingAction.cc.

379 {}

◆ printRegions()

void StackingAction::printRegions ( const std::vector< const G4Region *> &  reg,
const std::string &  word 
) const
private

Definition at line 498 of file StackingAction.cc.

References mps_fire::i.

Referenced by StackingAction().

498  {
499  for (unsigned int i = 0; i < reg.size(); ++i) {
500  edm::LogVerbatim("SimG4CoreApplication")
501  << " StackingAction: " << word << "Region " << i << ". " << reg[i]->GetName();
502  }
503 }
Log< level::Info, true > LogVerbatim
uint64_t word

◆ rrApplicable()

bool StackingAction::rrApplicable ( const G4Track *  aTrack,
const G4Track &  mother 
) const
private

Definition at line 468 of file StackingAction.cc.

References funct::abs(), extractor, and TrackInformation::genParticlePID().

Referenced by ClassifyNewTrack().

468  {
469  const TrackInformation& motherInfo(extractor(mother));
470 
471  // Check whether mother is gamma, e+, e-
472  const int genID = motherInfo.genParticlePID();
473  return (22 != genID && 11 != std::abs(genID));
474 }
TrackInformationExtractor extractor
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Member Data Documentation

◆ caloRegions

std::vector<const G4Region*> StackingAction::caloRegions
private

Definition at line 69 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ deadRegionNames

std::vector<std::string> StackingAction::deadRegionNames
private

Definition at line 64 of file StackingAction.h.

Referenced by initPointer(), and StackingAction().

◆ deadRegions

std::vector<const G4Region*> StackingAction::deadRegions
private

Definition at line 71 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ extractor

TrackInformationExtractor StackingAction::extractor
private

Definition at line 78 of file StackingAction.h.

Referenced by isItPrimaryDecayProductOrConversion(), and rrApplicable().

◆ gRRactive

bool StackingAction::gRRactive {false}
private

Definition at line 106 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoCastor

double StackingAction::gRusRoCastor
private

Definition at line 101 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ gRusRoEcal

double StackingAction::gRusRoEcal
private

Definition at line 93 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ gRusRoEnerLim

double StackingAction::gRusRoEnerLim
private

Definition at line 89 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoHcal

double StackingAction::gRusRoHcal
private

Definition at line 95 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ gRusRoMuonIron

double StackingAction::gRusRoMuonIron
private

Definition at line 97 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ gRusRoPreShower

double StackingAction::gRusRoPreShower
private

Definition at line 99 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ gRusRoWorld

double StackingAction::gRusRoWorld
private

Definition at line 103 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ killDeltaRay

bool StackingAction::killDeltaRay
private

Definition at line 52 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killExtra

bool StackingAction::killExtra
private

Definition at line 53 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killGamma

bool StackingAction::killGamma
private

Definition at line 54 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killHeavy

bool StackingAction::killHeavy
private

Definition at line 52 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killInCalo

bool StackingAction::killInCalo {false}
private

Definition at line 50 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killInCaloEfH

bool StackingAction::killInCaloEfH {false}
private

Definition at line 51 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxGamma

double StackingAction::kmaxGamma
private

Definition at line 57 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxIon

double StackingAction::kmaxIon
private

Definition at line 56 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxNeutron

double StackingAction::kmaxNeutron
private

Definition at line 56 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxProton

double StackingAction::kmaxProton
private

Definition at line 56 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ limitEnergyForVacuum

double StackingAction::limitEnergyForVacuum
private

Definition at line 55 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ lowdensRegions

std::vector<const G4Region*> StackingAction::lowdensRegions
private

Definition at line 70 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ m_Compton

const G4VProcess* StackingAction::m_Compton {nullptr}
private

Definition at line 76 of file StackingAction.h.

Referenced by ClassifyNewTrack().

◆ maxTimeNames

std::vector<std::string> StackingAction::maxTimeNames
private

Definition at line 63 of file StackingAction.h.

Referenced by initPointer(), and StackingAction().

◆ maxTimeRegions

std::vector<const G4Region*> StackingAction::maxTimeRegions
private

Definition at line 66 of file StackingAction.h.

Referenced by initPointer(), and isItOutOfTimeWindow().

◆ maxTrackTime

double StackingAction::maxTrackTime
private

Definition at line 58 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ maxTrackTimeForward

double StackingAction::maxTrackTimeForward
private

Definition at line 59 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ maxTrackTimes

std::vector<double> StackingAction::maxTrackTimes
private

Definition at line 62 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ maxZCentralCMS

double StackingAction::maxZCentralCMS
private

Definition at line 60 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ muonRegions

std::vector<const G4Region*> StackingAction::muonRegions
private

Definition at line 68 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ newTA

NewTrackAction* StackingAction::newTA
private

Definition at line 77 of file StackingAction.h.

Referenced by ClassifyNewTrack(), StackingAction(), and ~StackingAction().

◆ nRRactive

bool StackingAction::nRRactive {false}
private

Definition at line 107 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoCastor

double StackingAction::nRusRoCastor
private

Definition at line 102 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ nRusRoEcal

double StackingAction::nRusRoEcal
private

Definition at line 94 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ nRusRoEnerLim

double StackingAction::nRusRoEnerLim
private

Definition at line 90 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoHcal

double StackingAction::nRusRoHcal
private

Definition at line 96 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ nRusRoMuonIron

double StackingAction::nRusRoMuonIron
private

Definition at line 98 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ nRusRoPreShower

double StackingAction::nRusRoPreShower
private

Definition at line 100 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ nRusRoWorld

double StackingAction::nRusRoWorld
private

Definition at line 104 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ numberTimes

unsigned int StackingAction::numberTimes
private

Definition at line 61 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ regionCastor

const G4Region* StackingAction::regionCastor {nullptr}
private

Definition at line 85 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionEcal

const G4Region* StackingAction::regionEcal {nullptr}
private

Definition at line 81 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionHcal

const G4Region* StackingAction::regionHcal {nullptr}
private

Definition at line 82 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionMuonIron

const G4Region* StackingAction::regionMuonIron {nullptr}
private

Definition at line 83 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionPreShower

const G4Region* StackingAction::regionPreShower {nullptr}
private

Definition at line 84 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionWorld

const G4Region* StackingAction::regionWorld {nullptr}
private

Definition at line 86 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ saveFirstSecondary

bool StackingAction::saveFirstSecondary
private

Definition at line 48 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinAll

bool StackingAction::savePDandCinAll
private

Definition at line 49 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinCalo

bool StackingAction::savePDandCinCalo
private

Definition at line 47 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ savePDandCinMuon

bool StackingAction::savePDandCinMuon
private

Definition at line 48 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ savePDandCinTracker

bool StackingAction::savePDandCinTracker
private

Definition at line 47 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ steppingVerbose

const CMSSteppingVerbose* StackingAction::steppingVerbose
private

Definition at line 75 of file StackingAction.h.

Referenced by ClassifyNewTrack().

◆ trackAction

const TrackingAction* StackingAction::trackAction
private

Definition at line 74 of file StackingAction.h.

Referenced by ClassifyNewTrack().

◆ trackerRegions

std::vector<const G4Region*> StackingAction::trackerRegions
private

Definition at line 67 of file StackingAction.h.

Referenced by ClassifyNewTrack(), initPointer(), and StackingAction().

◆ trackNeutrino

bool StackingAction::trackNeutrino
private

Definition at line 52 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ worldSolid

G4VSolid* StackingAction::worldSolid
private

Definition at line 73 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().