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=default
 

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
 
bool gRRactive {false}
 
double gRusRoCastor
 
double gRusRoEcal
 
double gRusRoEnerLim
 
double gRusRoHcal
 
double gRusRoHGcal
 
double gRusRoMuonIron
 
double gRusRoPreShower
 
double gRusRoWorld
 
double gRusRoZDC
 
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
 
bool nRRactive {false}
 
double nRusRoCastor
 
double nRusRoEcal
 
double nRusRoEnerLim
 
double nRusRoHcal
 
double nRusRoHGcal
 
double nRusRoMuonIron
 
double nRusRoPreShower
 
double nRusRoWorld
 
double nRusRoZDC
 
unsigned int numberTimes
 
const G4Region * regionCastor {nullptr}
 
const G4Region * regionEcal {nullptr}
 
const G4Region * regionHcal {nullptr}
 
const G4Region * regionHGcal {nullptr}
 
const G4Region * regionMuonIron {nullptr}
 
const G4Region * regionPreShower {nullptr}
 
const G4Region * regionWorld {nullptr}
 
const G4Region * regionZDC {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 18 of file StackingAction.h.

Constructor & Destructor Documentation

◆ StackingAction()

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

Definition at line 21 of file StackingAction.cc.

References caloRegions, deadRegionNames, deadRegions, gRRactive, gRusRoCastor, gRusRoEcal, gRusRoEnerLim, gRusRoHcal, gRusRoHGcal, gRusRoMuonIron, gRusRoPreShower, gRusRoWorld, gRusRoZDC, 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, nRRactive, nRusRoCastor, nRusRoEcal, nRusRoEnerLim, nRusRoHcal, nRusRoHGcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, nRusRoZDC, numberTimes, AlCaHLTBitMon_ParallelJobs::p, printRegions(), saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, trackerRegions, trackNeutrino, and worldSolid.

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

Member Function Documentation

◆ ClassifyNewTrack()

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

Definition at line 168 of file StackingAction.cc.

References funct::abs(), caloRegions, deadRegions, RemoveAddSevLevel::flag, TrackingAction::geant4Track(), gRRactive, gRusRoCastor, gRusRoEcal, gRusRoEnerLim, gRusRoHcal, gRusRoHGcal, gRusRoMuonIron, gRusRoPreShower, gRusRoWorld, gRusRoZDC, G4TrackToParticleID::isGammaElectronPositron(), isItFromPrimary(), isItOutOfTimeWindow(), isItPrimaryDecayProductOrConversion(), isThisRegion(), killDeltaRay, killExtra, killGamma, killHeavy, killInCalo, killInCaloEfH, kmaxGamma, kmaxIon, kmaxNeutron, kmaxProton, limitEnergyForVacuum, LogDebug, lowdensRegions, maxTrackTimeForward, maxZCentralCMS, muonRegions, nRRactive, nRusRoCastor, nRusRoEcal, nRusRoEnerLim, nRusRoHcal, nRusRoHGcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, nRusRoZDC, MCTruthUtil::primary(), TtFullHadEvtBuilder_cfi::prob, regionCastor, regionEcal, regionHcal, regionHGcal, regionMuonIron, regionPreShower, regionWorld, regionZDC, rrApplicable(), saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, MCTruthUtil::secondary(), CMSSteppingVerbose::stackFilled(), steppingVerbose, hcalRecHitTable_cff::time, HLT_2024v10_cff::track, trackAction, trackerRegions, trackNeutrino, and worldSolid.

Referenced by CMSSimEventManager::StackTracks().

168  {
169  // G4 interface part
170  G4ClassificationOfNewTrack classification = fUrgent;
171  const int pdg = aTrack->GetDefinition()->GetPDGEncoding();
172  const int abspdg = std::abs(pdg);
173  auto track = const_cast<G4Track*>(aTrack);
174  const G4VProcess* creatorProc = aTrack->GetCreatorProcess();
175 
176  if (creatorProc == nullptr && aTrack->GetParentID() != 0) {
177  edm::LogWarning("StackingAction::ClassifyNewTrack")
178  << " TrackID=" << aTrack->GetTrackID() << " ParentID=" << aTrack->GetParentID() << " "
179  << aTrack->GetDefinition()->GetParticleName() << " Ekin(MeV)=" << aTrack->GetKineticEnergy();
180  }
181  if (aTrack->GetKineticEnergy() < 0.0) {
182  edm::LogWarning("StackingAction::ClassifyNewTrack")
183  << " TrackID=" << aTrack->GetTrackID() << " ParentID=" << aTrack->GetParentID() << " "
184  << aTrack->GetDefinition()->GetParticleName() << " Ekin(MeV)=" << aTrack->GetKineticEnergy() << " creator "
185  << creatorProc->GetProcessName();
186  }
187  // primary
188  if (creatorProc == nullptr || aTrack->GetParentID() == 0) {
189  if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
190  classification = fKill;
191  } else if (worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
192  classification = fKill;
193  } else {
195  }
196  } else {
197  // secondary
198  const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
199  const double time = aTrack->GetGlobalTime();
200 
201  // definetly killed tracks
202  if (aTrack->GetTrackStatus() == fStopAndKill) {
203  classification = fKill;
204  } else if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
205  classification = fKill;
206 
207  } else if (std::abs(aTrack->GetPosition().z()) >= maxZCentralCMS) {
208  // very forward secondary
209  if (time > maxTrackTimeForward) {
210  classification = fKill;
211  } else {
212  const G4Track* mother = trackAction->geant4Track();
213  MCTruthUtil::secondary(track, *mother, 0);
214  }
215 
216  } else if (isItOutOfTimeWindow(reg, time)) {
217  // time window check
218  classification = fKill;
219 
220  } else {
221  // potentially good for tracking
222  const double ke = aTrack->GetKineticEnergy();
223  G4int subType = (nullptr != creatorProc) ? creatorProc->GetProcessSubType() : 0;
224 
225  LogDebug("SimG4CoreApplication") << "##StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent "
226  << aTrack->GetParentID() << " " << aTrack->GetDefinition()->GetParticleName()
227  << " Ekin(MeV)=" << ke / CLHEP::MeV << " subType=" << subType << " ";
228 
229  // kill tracks in specific regions
230  if (isThisRegion(reg, deadRegions)) {
231  classification = fKill;
232  }
233  if (classification != fKill && ke <= limitEnergyForVacuum && isThisRegion(reg, lowdensRegions)) {
234  classification = fKill;
235 
236  } else if (classification != fKill) {
237  // very low-energy gamma
238  if (pdg == 22 && killGamma && ke < kmaxGamma) {
239  classification = fKill;
240  }
241 
242  // specific track killing - not for production
243  if (killExtra && classification != fKill) {
244  if (killHeavy && classification != fKill) {
245  if (((pdg / 1000000000 == 1) && (((pdg / 10000) % 100) > 0) && (((pdg / 10) % 100) > 0) &&
246  (ke < kmaxIon)) ||
247  ((pdg == 2212) && (ke < kmaxProton)) || ((pdg == 2112) && (ke < kmaxNeutron))) {
248  classification = fKill;
249  }
250  }
251 
252  if (killDeltaRay && classification != fKill && aTrack->GetParentID() > 0 &&
254  classification = fKill;
255  }
256 
257  if (killInCalo && classification != fKill && isThisRegion(reg, caloRegions)) {
258  classification = fKill;
259  }
260  if (killInCaloEfH && classification != fKill) {
261  int pdgMother = std::abs(trackAction->geant4Track()->GetDefinition()->GetPDGEncoding());
262  if ((pdg == 22 || abspdg == 11) && pdgMother != 11 && pdgMother != 22 && isThisRegion(reg, caloRegions)) {
263  classification = fKill;
264  }
265  }
266  }
267 
268  // Russian roulette && MC truth
269  if (classification != fKill) {
270  const G4Track* mother = trackAction->geant4Track();
271  int flag = 0;
272  if (savePDandCinAll) {
273  flag = isItPrimaryDecayProductOrConversion(subType, *mother);
274  } else {
278  flag = isItPrimaryDecayProductOrConversion(subType, *mother);
279  }
280  }
281  if (saveFirstSecondary && 0 == flag) {
282  flag = isItFromPrimary(*mother, flag);
283  }
284 
285  // Russian roulette
286  if (2112 == pdg || 22 == pdg) {
287  double currentWeight = aTrack->GetWeight();
288 
289  if (1.0 >= currentWeight) {
290  double prob = 1.001;
291  double elim = 0.0;
292 
293  // neutron
294  if (nRRactive && pdg == 2112) {
295  elim = nRusRoEnerLim;
296  if (reg == regionEcal) {
297  prob = nRusRoEcal;
298  } else if (reg == regionHcal) {
299  prob = nRusRoHcal;
300  } else if (reg == regionMuonIron) {
302  } else if (reg == regionPreShower) {
304  } else if (reg == regionHGcal) {
305  prob = nRusRoHGcal;
306  } else if (reg == regionZDC) {
307  prob = nRusRoZDC;
308  } else if (reg == regionCastor) {
309  prob = nRusRoCastor;
310  } else if (reg == regionWorld) {
311  prob = nRusRoWorld;
312  }
313 
314  // gamma
315  } else if (gRRactive && pdg == 22) {
316  elim = gRusRoEnerLim;
317  if (reg == regionEcal || reg == regionPreShower) {
318  if (rrApplicable(aTrack, *mother)) {
319  if (reg == regionEcal) {
320  prob = gRusRoEcal;
321  } else {
323  }
324  }
325  } else {
326  if (reg == regionHcal) {
327  prob = gRusRoHcal;
328  } else if (reg == regionMuonIron) {
330  } else if (reg == regionHGcal) {
331  prob = gRusRoHGcal;
332  } else if (reg == regionZDC) {
333  prob = gRusRoZDC;
334  } else if (reg == regionCastor) {
335  prob = gRusRoCastor;
336  } else if (reg == regionWorld) {
337  prob = gRusRoWorld;
338  }
339  }
340  }
341  if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
342  if (G4UniformRand() < prob) {
343  track->SetWeight(currentWeight / prob);
344  } else {
345  classification = fKill;
346  }
347  }
348  }
349  }
350  if (classification != fKill) {
351  MCTruthUtil::secondary(track, *mother, flag);
352  }
353  LogDebug("SimG4CoreApplication")
354  << "StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent " << aTrack->GetParentID()
355  << " Type " << aTrack->GetDefinition()->GetParticleName() << " Ekin=" << ke / CLHEP::MeV
356  << " MeV from process subType=" << subType << " as " << classification << " Flag: " << flag;
357  }
358  }
359  }
360  }
361  if (nullptr != steppingVerbose) {
362  steppingVerbose->stackFilled(aTrack, (classification == fKill));
363  }
364  return classification;
365 }
double nRusRoPreShower
std::vector< const G4Region * > lowdensRegions
double maxZCentralCMS
const G4Region * regionZDC
bool rrApplicable(const G4Track *, const G4Track &) const
static void secondary(G4Track *aSecondary, const G4Track &mother, int)
Definition: MCTruthUtil.cc:17
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 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
const G4Region * regionHGcal
void stackFilled(const G4Track *, bool isKilled) const
bool isThisRegion(const G4Region *, std::vector< const G4Region *> &) const
bool savePDandCinTracker
static void primary(G4Track *aPrimary)
Definition: MCTruthUtil.cc:7
double gRusRoEnerLim
const G4Region * regionHcal
double maxTrackTimeForward
static bool isGammaElectronPositron(int pdgCode)
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 371 of file StackingAction.cc.

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

Referenced by StackingAction().

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

References RemoveAddSevLevel::flag.

Referenced by ClassifyNewTrack().

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

◆ isItOutOfTimeWindow()

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

Definition at line 484 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

484  {
485  double tofM = maxTrackTime;
486  for (unsigned int i = 0; i < numberTimes; ++i) {
487  if (reg == maxTimeRegions[i]) {
488  tofM = maxTrackTimes[i];
489  break;
490  }
491  }
492  return (t > tofM);
493 }
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 451 of file StackingAction.cc.

References hydjet2DefaultParameters_cff::fDecay, and RemoveAddSevLevel::flag.

Referenced by ClassifyNewTrack().

451  {
452  int flag = 0;
453  auto motherInfo = static_cast<const TrackInformation*>(mother.GetUserInformation());
454  // Check whether mother is a primary
455  if (motherInfo->isPrimary()) {
456  if (stype == fDecay) {
457  flag = 1;
458  } else if (stype == fGammaConversion) {
459  flag = 2;
460  }
461  }
462  return flag;
463 }

◆ isThisRegion()

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

Definition at line 440 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

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

◆ NewStage()

void StackingAction::NewStage ( )
override

Definition at line 367 of file StackingAction.cc.

367 {}

◆ PrepareNewEvent()

void StackingAction::PrepareNewEvent ( )
override

Definition at line 369 of file StackingAction.cc.

369 {}

◆ printRegions()

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

Definition at line 495 of file StackingAction.cc.

References mps_fire::i.

Referenced by StackingAction().

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

◆ rrApplicable()

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

Definition at line 465 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

465  {
466  auto motherInfo = static_cast<const TrackInformation*>(mother.GetUserInformation());
467 
468  // Check whether mother is gamma, e+, e-
469  const int genID = motherInfo->genParticlePID();
470  return (22 != genID && 11 != std::abs(genID));
471 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int genParticlePID() const

Member Data Documentation

◆ caloRegions

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

Definition at line 67 of file StackingAction.h.

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

◆ deadRegionNames

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

Definition at line 62 of file StackingAction.h.

Referenced by initPointer(), and StackingAction().

◆ deadRegions

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

Definition at line 69 of file StackingAction.h.

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

◆ gRRactive

bool StackingAction::gRRactive {false}
private

Definition at line 108 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoCastor

double StackingAction::gRusRoCastor
private

Definition at line 99 of file StackingAction.h.

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

◆ gRusRoEcal

double StackingAction::gRusRoEcal
private

Definition at line 91 of file StackingAction.h.

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

◆ gRusRoEnerLim

double StackingAction::gRusRoEnerLim
private

Definition at line 87 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoHcal

double StackingAction::gRusRoHcal
private

Definition at line 93 of file StackingAction.h.

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

◆ gRusRoHGcal

double StackingAction::gRusRoHGcal
private

Definition at line 103 of file StackingAction.h.

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

◆ gRusRoMuonIron

double StackingAction::gRusRoMuonIron
private

Definition at line 95 of file StackingAction.h.

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

◆ gRusRoPreShower

double StackingAction::gRusRoPreShower
private

Definition at line 97 of file StackingAction.h.

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

◆ gRusRoWorld

double StackingAction::gRusRoWorld
private

Definition at line 105 of file StackingAction.h.

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

◆ gRusRoZDC

double StackingAction::gRusRoZDC
private

Definition at line 101 of file StackingAction.h.

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

◆ killDeltaRay

bool StackingAction::killDeltaRay
private

Definition at line 50 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killExtra

bool StackingAction::killExtra
private

Definition at line 51 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killGamma

bool StackingAction::killGamma
private

Definition at line 52 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killHeavy

bool StackingAction::killHeavy
private

Definition at line 50 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killInCalo

bool StackingAction::killInCalo {false}
private

Definition at line 48 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killInCaloEfH

bool StackingAction::killInCaloEfH {false}
private

Definition at line 49 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxGamma

double StackingAction::kmaxGamma
private

Definition at line 55 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxIon

double StackingAction::kmaxIon
private

Definition at line 54 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxNeutron

double StackingAction::kmaxNeutron
private

Definition at line 54 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ kmaxProton

double StackingAction::kmaxProton
private

Definition at line 54 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ limitEnergyForVacuum

double StackingAction::limitEnergyForVacuum
private

Definition at line 53 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ lowdensRegions

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

Definition at line 68 of file StackingAction.h.

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

◆ m_Compton

const G4VProcess* StackingAction::m_Compton {nullptr}
private

Definition at line 74 of file StackingAction.h.

◆ maxTimeNames

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

Definition at line 61 of file StackingAction.h.

Referenced by initPointer(), and StackingAction().

◆ maxTimeRegions

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

Definition at line 64 of file StackingAction.h.

Referenced by initPointer(), and isItOutOfTimeWindow().

◆ maxTrackTime

double StackingAction::maxTrackTime
private

Definition at line 56 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ maxTrackTimeForward

double StackingAction::maxTrackTimeForward
private

Definition at line 57 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ maxTrackTimes

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

Definition at line 60 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ maxZCentralCMS

double StackingAction::maxZCentralCMS
private

Definition at line 58 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ muonRegions

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

Definition at line 66 of file StackingAction.h.

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

◆ nRRactive

bool StackingAction::nRRactive {false}
private

Definition at line 109 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoCastor

double StackingAction::nRusRoCastor
private

Definition at line 100 of file StackingAction.h.

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

◆ nRusRoEcal

double StackingAction::nRusRoEcal
private

Definition at line 92 of file StackingAction.h.

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

◆ nRusRoEnerLim

double StackingAction::nRusRoEnerLim
private

Definition at line 88 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoHcal

double StackingAction::nRusRoHcal
private

Definition at line 94 of file StackingAction.h.

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

◆ nRusRoHGcal

double StackingAction::nRusRoHGcal
private

Definition at line 104 of file StackingAction.h.

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

◆ nRusRoMuonIron

double StackingAction::nRusRoMuonIron
private

Definition at line 96 of file StackingAction.h.

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

◆ nRusRoPreShower

double StackingAction::nRusRoPreShower
private

Definition at line 98 of file StackingAction.h.

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

◆ nRusRoWorld

double StackingAction::nRusRoWorld
private

Definition at line 106 of file StackingAction.h.

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

◆ nRusRoZDC

double StackingAction::nRusRoZDC
private

Definition at line 102 of file StackingAction.h.

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

◆ numberTimes

unsigned int StackingAction::numberTimes
private

Definition at line 59 of file StackingAction.h.

Referenced by isItOutOfTimeWindow(), and StackingAction().

◆ regionCastor

const G4Region* StackingAction::regionCastor {nullptr}
private

Definition at line 81 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionEcal

const G4Region* StackingAction::regionEcal {nullptr}
private

Definition at line 77 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionHcal

const G4Region* StackingAction::regionHcal {nullptr}
private

Definition at line 78 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionHGcal

const G4Region* StackingAction::regionHGcal {nullptr}
private

Definition at line 83 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionMuonIron

const G4Region* StackingAction::regionMuonIron {nullptr}
private

Definition at line 79 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionPreShower

const G4Region* StackingAction::regionPreShower {nullptr}
private

Definition at line 80 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionWorld

const G4Region* StackingAction::regionWorld {nullptr}
private

Definition at line 84 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ regionZDC

const G4Region* StackingAction::regionZDC {nullptr}
private

Definition at line 82 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and initPointer().

◆ saveFirstSecondary

bool StackingAction::saveFirstSecondary
private

Definition at line 46 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinAll

bool StackingAction::savePDandCinAll
private

Definition at line 47 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinCalo

bool StackingAction::savePDandCinCalo
private

Definition at line 45 of file StackingAction.h.

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

◆ savePDandCinMuon

bool StackingAction::savePDandCinMuon
private

Definition at line 46 of file StackingAction.h.

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

◆ savePDandCinTracker

bool StackingAction::savePDandCinTracker
private

Definition at line 45 of file StackingAction.h.

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

◆ steppingVerbose

const CMSSteppingVerbose* StackingAction::steppingVerbose
private

Definition at line 73 of file StackingAction.h.

Referenced by ClassifyNewTrack().

◆ trackAction

const TrackingAction* StackingAction::trackAction
private

Definition at line 72 of file StackingAction.h.

Referenced by ClassifyNewTrack().

◆ trackerRegions

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

Definition at line 65 of file StackingAction.h.

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

◆ trackNeutrino

bool StackingAction::trackNeutrino
private

Definition at line 50 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ worldSolid

G4VSolid* StackingAction::worldSolid
private

Definition at line 71 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().