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 G4Track *, 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
 
double gRusRoCastor
 
double gRusRoEcal
 
double gRusRoEnerLim
 
double gRusRoHcal
 
double gRusRoMuonIron
 
double gRusRoPreShower
 
double gRusRoWorld
 
bool killDeltaRay
 
bool killExtra
 
bool killGamma
 
bool killHeavy
 
bool killInCalo
 
bool killInCaloEfH
 
double kmaxGamma
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
double limitEnergyForVacuum
 
std::vector< const G4Region * > lowdensRegions
 
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
 
double nRusRoCastor
 
double nRusRoEcal
 
double nRusRoEnerLim
 
double nRusRoHcal
 
double nRusRoMuonIron
 
double nRusRoPreShower
 
double nRusRoWorld
 
unsigned int numberTimes
 
const G4Region * regionCastor
 
const G4Region * regionEcal
 
const G4Region * regionHcal
 
const G4Region * regionMuonIron
 
const G4Region * regionPreShower
 
const G4Region * regionWorld
 
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 19 of file StackingAction.h.

Constructor & Destructor Documentation

◆ StackingAction()

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

Definition at line 19 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(), regionCastor, regionEcal, regionHcal, regionMuonIron, regionPreShower, regionWorld, saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, trackerRegions, trackNeutrino, and worldSolid.

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

◆ ~StackingAction()

StackingAction::~StackingAction ( )
override

Definition at line 170 of file StackingAction.cc.

References newTA.

170 { delete newTA; }
NewTrackAction * newTA

Member Function Documentation

◆ ClassifyNewTrack()

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

Definition at line 172 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, maxTrackTimeForward, maxZCentralCMS, muonRegions, newTA, nRRactive, nRusRoCastor, nRusRoEcal, nRusRoEnerLim, nRusRoHcal, nRusRoMuonIron, nRusRoPreShower, nRusRoWorld, NewTrackAction::primary(), TtFullHadEvtBuilder_cfi::prob, ValidateTausOnZEEFastSim_cff::proc, regionCastor, regionEcal, regionHcal, regionMuonIron, regionPreShower, regionWorld, rrApplicable(), saveFirstSecondary, savePDandCinAll, savePDandCinCalo, savePDandCinMuon, savePDandCinTracker, NewTrackAction::secondary(), CMSSteppingVerbose::StackFilled(), steppingVerbose, protons_cff::time, HLT_2022v15_cff::track, trackAction, trackerRegions, trackNeutrino, and worldSolid.

172  {
173  // G4 interface part
174  G4ClassificationOfNewTrack classification = fUrgent;
175  const int pdg = aTrack->GetDefinition()->GetPDGEncoding();
176  const int abspdg = std::abs(pdg);
177  auto track = const_cast<G4Track*>(aTrack);
178 
179  // primary
180  if (aTrack->GetCreatorProcess() == nullptr || aTrack->GetParentID() == 0) {
181  if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
182  classification = fKill;
183  } else if (worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
184  classification = fKill;
185  } else {
186  newTA->primary(track);
187  }
188  } else {
189  // secondary
190  const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
191  const double time = aTrack->GetGlobalTime();
192 
193  // definetly killed tracks
194  if (aTrack->GetTrackStatus() == fStopAndKill) {
195  classification = fKill;
196  } else if (!trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
197  classification = fKill;
198 
199  } else if (std::abs(aTrack->GetPosition().z()) >= maxZCentralCMS) {
200  // very forward secondary
201  if (time > maxTrackTimeForward) {
202  classification = fKill;
203  } else {
204  const G4Track* mother = trackAction->geant4Track();
205  newTA->secondary(track, *mother, 0);
206  }
207 
208  } else if (isItOutOfTimeWindow(reg, time)) {
209  // time window check
210  classification = fKill;
211 
212  } else {
213  // potentially good for tracking
214  const double ke = aTrack->GetKineticEnergy();
215  const G4VProcess* proc = aTrack->GetCreatorProcess();
216  G4int subType = (nullptr != proc) ? proc->GetProcessSubType() : 0;
217  if (subType == 16) {
218  auto ptr = dynamic_cast<const G4GammaGeneralProcess*>(proc);
219  if (nullptr != proc) {
220  proc = ptr->GetSelectedProcess();
221  subType = proc->GetProcessSubType();
222  track->SetCreatorProcess(proc);
223  }
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  << proc->GetProcessName();
229 
230  // kill tracks in specific regions
231  if (isThisRegion(reg, deadRegions)) {
232  classification = fKill;
233  }
234  if (classification != fKill && ke <= limitEnergyForVacuum && isThisRegion(reg, lowdensRegions)) {
235  classification = fKill;
236 
237  } else if (classification != fKill) {
238  // very low-energy gamma
239  if (pdg == 22 && killGamma && ke < kmaxGamma) {
240  classification = fKill;
241  }
242 
243  // specific track killing - not for production
244  if (killExtra && classification != fKill) {
245  if (killHeavy && classification != fKill) {
246  if (((pdg / 1000000000 == 1) && (((pdg / 10000) % 100) > 0) && (((pdg / 10) % 100) > 0) &&
247  (ke < kmaxIon)) ||
248  ((pdg == 2212) && (ke < kmaxProton)) || ((pdg == 2112) && (ke < kmaxNeutron))) {
249  classification = fKill;
250  }
251  }
252 
253  if (killDeltaRay && classification != fKill &&
254  aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
255  classification = fKill;
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(aTrack, *mother);
274  } else {
278  flag = isItPrimaryDecayProductOrConversion(aTrack, *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.0;
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 == regionCastor) {
305  prob = nRusRoCastor;
306  } else if (reg == regionWorld) {
307  prob = nRusRoWorld;
308  }
309 
310  // gamma
311  } else if (gRRactive && pdg == 22) {
312  elim = gRusRoEnerLim;
313  if (reg == regionEcal || reg == regionPreShower) {
314  if (rrApplicable(aTrack, *mother)) {
315  if (reg == regionEcal) {
316  prob = gRusRoEcal;
317  } else {
319  }
320  }
321  } else {
322  if (reg == regionHcal) {
323  prob = gRusRoHcal;
324  } else if (reg == regionMuonIron) {
326  } else if (reg == regionCastor) {
327  prob = gRusRoCastor;
328  } else if (reg == regionWorld) {
329  prob = gRusRoWorld;
330  }
331  }
332  }
333  if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
334  if (G4UniformRand() < prob) {
335  track->SetWeight(currentWeight / prob);
336  } else {
337  classification = fKill;
338  }
339  }
340  }
341  }
342  if (classification != fKill) {
343  newTA->secondary(track, *mother, flag);
344  }
345  LogDebug("SimG4CoreApplication")
346  << "StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent " << aTrack->GetParentID()
347  << " Type " << aTrack->GetDefinition()->GetParticleName() << " Ekin=" << ke / CLHEP::MeV
348  << " MeV from process " << proc->GetProcessName() << " subType=" << subType << " as " << classification
349  << " Flag: " << flag;
350  }
351  }
352  }
353  }
354  if (nullptr != steppingVerbose) {
355  steppingVerbose->StackFilled(aTrack, (classification == fKill));
356  }
357  return classification;
358 }
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 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
int isItPrimaryDecayProductOrConversion(const G4Track *, const G4Track &) 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
double gRusRoMuonIron
std::vector< const G4Region * > trackerRegions
#define LogDebug(id)
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum
const G4Region * regionWorld

◆ initPointer()

void StackingAction::initPointer ( )
private

Definition at line 364 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().

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

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

Referenced by ClassifyNewTrack().

459  {
460  int flag = flagIn;
461  if (flag != 1) {
462  const TrackInformation* ptr = static_cast<TrackInformation*>(mother.GetUserInformation());
463  if (ptr->isPrimary()) {
464  flag = 3;
465  }
466  }
467  return flag;
468 }
bool isPrimary() const

◆ isItOutOfTimeWindow()

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

Definition at line 470 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

470  {
471  double tofM = maxTrackTime;
472  for (unsigned int i = 0; i < numberTimes; ++i) {
473  if (reg == maxTimeRegions[i]) {
474  tofM = maxTrackTimes[i];
475  break;
476  }
477  }
478  return (t > tofM);
479 }
std::vector< double > maxTrackTimes
unsigned int numberTimes
std::vector< const G4Region * > maxTimeRegions

◆ isItPrimaryDecayProductOrConversion()

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

Definition at line 437 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

437  {
438  int flag = 0;
439  const TrackInformation& motherInfo(extractor(mother));
440  // Check whether mother is a primary
441  if (motherInfo.isPrimary()) {
442  if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) {
443  flag = 1;
444  } else if (aTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) {
445  flag = 2;
446  }
447  }
448  return flag;
449 }
TrackInformationExtractor extractor

◆ isThisRegion()

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

Definition at line 426 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

426  {
427  bool flag = false;
428  for (auto& region : regions) {
429  if (reg == region) {
430  flag = true;
431  break;
432  }
433  }
434  return flag;
435 }

◆ NewStage()

void StackingAction::NewStage ( )
override

Definition at line 360 of file StackingAction.cc.

360 {}

◆ PrepareNewEvent()

void StackingAction::PrepareNewEvent ( )
override

Definition at line 362 of file StackingAction.cc.

362 {}

◆ printRegions()

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

Definition at line 481 of file StackingAction.cc.

References mps_fire::i.

Referenced by StackingAction().

481  {
482  for (unsigned int i = 0; i < reg.size(); ++i) {
483  edm::LogVerbatim("SimG4CoreApplication")
484  << " StackingAction: " << word << "Region " << i << ". " << reg[i]->GetName();
485  }
486 }
Log< level::Info, true > LogVerbatim
uint64_t word

◆ rrApplicable()

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

Definition at line 451 of file StackingAction.cc.

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

Referenced by ClassifyNewTrack().

451  {
452  const TrackInformation& motherInfo(extractor(mother));
453 
454  // Check whether mother is gamma, e+, e-
455  const int genID = motherInfo.genParticlePID();
456  return (22 != genID && 11 != std::abs(genID));
457 }
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 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().

◆ extractor

TrackInformationExtractor StackingAction::extractor
private

Definition at line 75 of file StackingAction.h.

Referenced by isItPrimaryDecayProductOrConversion(), and rrApplicable().

◆ gRRactive

bool StackingAction::gRRactive
private

Definition at line 103 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoCastor

double StackingAction::gRusRoCastor
private

Definition at line 98 of file StackingAction.h.

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

◆ gRusRoEcal

double StackingAction::gRusRoEcal
private

Definition at line 90 of file StackingAction.h.

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

◆ gRusRoEnerLim

double StackingAction::gRusRoEnerLim
private

Definition at line 86 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ gRusRoHcal

double StackingAction::gRusRoHcal
private

Definition at line 92 of file StackingAction.h.

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

◆ gRusRoMuonIron

double StackingAction::gRusRoMuonIron
private

Definition at line 94 of file StackingAction.h.

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

◆ gRusRoPreShower

double StackingAction::gRusRoPreShower
private

Definition at line 96 of file StackingAction.h.

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

◆ gRusRoWorld

double StackingAction::gRusRoWorld
private

Definition at line 100 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
private

Definition at line 49 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ killInCaloEfH

bool StackingAction::killInCaloEfH
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().

◆ 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().

◆ newTA

NewTrackAction* StackingAction::newTA
private

Definition at line 74 of file StackingAction.h.

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

◆ nRRactive

bool StackingAction::nRRactive
private

Definition at line 104 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoCastor

double StackingAction::nRusRoCastor
private

Definition at line 99 of file StackingAction.h.

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

◆ nRusRoEcal

double StackingAction::nRusRoEcal
private

Definition at line 91 of file StackingAction.h.

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

◆ nRusRoEnerLim

double StackingAction::nRusRoEnerLim
private

Definition at line 87 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ nRusRoHcal

double StackingAction::nRusRoHcal
private

Definition at line 93 of file StackingAction.h.

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

◆ nRusRoMuonIron

double StackingAction::nRusRoMuonIron
private

Definition at line 95 of file StackingAction.h.

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

◆ nRusRoPreShower

double StackingAction::nRusRoPreShower
private

Definition at line 97 of file StackingAction.h.

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

◆ nRusRoWorld

double StackingAction::nRusRoWorld
private

Definition at line 101 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
private

Definition at line 82 of file StackingAction.h.

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

◆ regionEcal

const G4Region* StackingAction::regionEcal
private

Definition at line 78 of file StackingAction.h.

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

◆ regionHcal

const G4Region* StackingAction::regionHcal
private

Definition at line 79 of file StackingAction.h.

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

◆ regionMuonIron

const G4Region* StackingAction::regionMuonIron
private

Definition at line 80 of file StackingAction.h.

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

◆ regionPreShower

const G4Region* StackingAction::regionPreShower
private

Definition at line 81 of file StackingAction.h.

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

◆ regionWorld

const G4Region* StackingAction::regionWorld
private

Definition at line 83 of file StackingAction.h.

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

◆ saveFirstSecondary

bool StackingAction::saveFirstSecondary
private

Definition at line 47 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinAll

bool StackingAction::savePDandCinAll
private

Definition at line 48 of file StackingAction.h.

Referenced by ClassifyNewTrack(), and StackingAction().

◆ savePDandCinCalo

bool StackingAction::savePDandCinCalo
private

Definition at line 46 of file StackingAction.h.

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

◆ savePDandCinMuon

bool StackingAction::savePDandCinMuon
private

Definition at line 47 of file StackingAction.h.

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

◆ savePDandCinTracker

bool StackingAction::savePDandCinTracker
private

Definition at line 46 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().