9 #include "G4VProcess.hh"
10 #include "G4EmProcessSubType.hh"
11 #include "G4LogicalVolumeStore.hh"
12 #include "G4RegionStore.hh"
13 #include "Randomize.hh"
14 #include "G4SystemOfUnits.hh"
15 #include "G4VSolid.hh"
16 #include "G4TransportationManager.hh"
19 : trackAction(trka), steppingVerbose(
sv) {
32 maxTrackTimes =
p.getParameter<std::vector<double> >(
"MaxTrackTimes");
33 maxTimeNames =
p.getParameter<std::vector<std::string> >(
"MaxTimeNames");
35 savePDandCinAll =
p.getUntrackedParameter<
bool>(
"SaveAllPrimaryDecayProductsAndConversions",
true);
36 savePDandCinTracker =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInTracker",
false);
37 savePDandCinCalo =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInCalo",
false);
38 savePDandCinMuon =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInMuon",
false);
54 gRusRoEcal =
p.getParameter<
double>(
"RusRoEcalGamma");
55 gRusRoHcal =
p.getParameter<
double>(
"RusRoHcalGamma");
61 nRusRoEcal =
p.getParameter<
double>(
"RusRoEcalNeutron");
62 nRusRoHcal =
p.getParameter<
double>(
"RusRoHcalNeutron");
66 nRusRoWorld =
p.getParameter<
double>(
"RusRoWorldNeutron");
79 if (
p.exists(
"TestKillingOptions")) {
83 <<
" *** Activating special test killing options in StackingAction \n"
84 <<
" *** Kill secondaries in Calorimetetrs volume = " <<
killInCalo <<
"\n"
85 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= " <<
killInCaloEfH;
92 <<
"StackingAction initiated with"
93 <<
" flag for saving decay products in "
108 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction kill tracks with "
109 <<
"time larger than " <<
maxTrackTime / CLHEP::ns <<
" ns ";
124 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Dead regions - kill all secondaries ";
129 <<
"StackingAction: "
140 <<
"StackingAction: "
151 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Tracker regions: ";
155 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Calo regions: ";
159 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Muon regions: ";
162 worldSolid = G4TransportationManager::GetTransportationManager()
163 ->GetNavigatorForTracking()
173 G4ClassificationOfNewTrack classification = fUrgent;
174 const int pdg = aTrack->GetDefinition()->GetPDGEncoding();
178 if (aTrack->GetCreatorProcess() ==
nullptr || aTrack->GetParentID() == 0) {
179 if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
180 classification = fKill;
181 }
else if (
worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
182 classification = fKill;
188 const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
189 const double time = aTrack->GetGlobalTime();
192 if (aTrack->GetTrackStatus() == fStopAndKill) {
193 classification = fKill;
194 }
else if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
195 classification = fKill;
200 classification = fKill;
208 classification = fKill;
212 const double ke = aTrack->GetKineticEnergy();
216 classification = fKill;
219 classification = fKill;
221 }
else if (classification != fKill) {
224 classification = fKill;
228 if (
killExtra && classification != fKill) {
229 if (
killHeavy && classification != fKill) {
230 if (((
pdg / 1000000000 == 1) && (((
pdg / 10000) % 100) > 0) && (((
pdg / 10) % 100) > 0) &&
233 classification = fKill;
238 aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
239 classification = fKill;
242 classification = fKill;
247 classification = fKill;
253 if (classification != fKill) {
270 if (2112 ==
pdg || 22 ==
pdg) {
271 double currentWeight = aTrack->GetWeight();
273 if (1.0 >= currentWeight) {
317 if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
318 if (G4UniformRand() <
prob) {
319 const_cast<G4Track*>(aTrack)->SetWeight(currentWeight /
prob);
321 classification = fKill;
326 if (classification != fKill) {
330 <<
"StackingAction:Classify Track " << aTrack->GetTrackID() <<
" Parent " << aTrack->GetParentID()
331 <<
" Type " << aTrack->GetDefinition()->GetParticleName() <<
" K.E. " << aTrack->GetKineticEnergy() /
MeV
332 <<
" MeV from process/subprocess " << aTrack->GetCreatorProcess()->GetProcessType() <<
"|"
333 << aTrack->GetCreatorProcess()->GetProcessSubType() <<
" as " << classification <<
" Flag " <<
flag;
341 return classification;
354 const std::vector<G4Region*>* rs = G4RegionStore::GetInstance();
356 for (
auto& reg : *rs) {
357 const G4String&
rname = reg->GetName();
378 for (
unsigned int i = 0;
i <
num; ++
i) {
386 (
rname ==
"BeamPipe" ||
rname ==
"BeamPipeVacuum" ||
rname ==
"TrackerPixelSensRegion" ||
387 rname ==
"TrackerPixelDeadRegion" ||
rname ==
"TrackerDeadRegion" ||
rname ==
"TrackerSensRegion" ||
388 rname ==
"FastTimerRegion" ||
rname ==
"FastTimerRegionSensBTL" ||
rname ==
"FastTimerRegionSensETL")) {
392 rname ==
"PreshowerRegion" ||
rname ==
"APDRegion" ||
rname ==
"HGCalRegion")) {
396 rname ==
"Muon" ||
rname ==
"MuonSensitive_DT-CSC")) {
399 if (
rname ==
"BeamPipeOutside" ||
rname ==
"BeamPipeVacuum") {
403 if (
rname == (G4String)(dead)) {
426 if (aTrack->GetCreatorProcess()->GetProcessType() ==
fDecay) {
428 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) {
440 return (22 != genID && 11 !=
std::abs(genID));
466 for (
unsigned int i = 0;
i < reg.size(); ++
i) {
468 <<
" StackingAction: " <<
word <<
"Region " <<
i <<
". " << reg[
i]->GetName();