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 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();
191 if (aTrack->GetTrackStatus() == fStopAndKill) {
192 classification = fKill;
193 }
else if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
194 classification = fKill;
199 classification = fKill;
207 classification = fKill;
211 double ke = aTrack->GetKineticEnergy();
215 classification = fKill;
218 classification = fKill;
223 classification = fKill;
227 if (
killExtra && classification != fKill) {
228 if (
killHeavy && classification != fKill) {
229 if (((
pdg / 1000000000 == 1) && (((
pdg / 10000) % 100) > 0) && (((
pdg / 10) % 100) > 0) &&
232 classification = fKill;
237 aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
238 classification = fKill;
241 classification = fKill;
246 classification = fKill;
252 if (classification != fKill) {
269 if (2112 ==
pdg || 22 ==
pdg) {
270 double currentWeight = aTrack->GetWeight();
272 if (1.0 >= currentWeight) {
316 if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
317 if (G4UniformRand() <
prob) {
318 const_cast<G4Track*>(aTrack)->SetWeight(currentWeight /
prob);
320 classification = fKill;
325 if (classification != fKill) {
329 <<
"StackingAction:Classify Track " << aTrack->GetTrackID() <<
" Parent " << aTrack->GetParentID()
330 <<
" Type " << aTrack->GetDefinition()->GetParticleName() <<
" K.E. " << aTrack->GetKineticEnergy() /
MeV
331 <<
" MeV from process/subprocess " << aTrack->GetCreatorProcess()->GetProcessType() <<
"|"
332 << aTrack->GetCreatorProcess()->GetProcessSubType() <<
" as " << classification <<
" Flag " <<
flag;
340 return classification;
353 std::vector<G4Region*>* rs = G4RegionStore::GetInstance();
355 for (
auto& reg : *rs) {
356 G4String
rname = reg->GetName();
377 for (
unsigned int i = 0;
i <
num; ++
i) {
385 (
rname ==
"BeamPipe" ||
rname ==
"BeamPipeVacuum" ||
rname ==
"TrackerPixelSensRegion" ||
386 rname ==
"TrackerPixelDeadRegion" ||
rname ==
"TrackerDeadRegion" ||
rname ==
"TrackerSensRegion")) {
390 rname ==
"PreshowerRegion")) {
394 rname ==
"Muon" ||
rname ==
"MuonSensitive_DT-CSC")) {
397 if (
rname ==
"BeamPipeOutside" ||
rname ==
"BeamPipeVacuum") {
401 if (
rname == (G4String)(dead)) {
424 if (aTrack->GetCreatorProcess()->GetProcessType() ==
fDecay) {
426 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) {
438 return (22 == genID || 11 == genID || -11 == genID) ?
false :
true;
460 return (aTrack->GetGlobalTime() > tofM) ?
true :
false;
464 for (
unsigned int i = 0;
i < reg.size(); ++
i) {
466 <<
" StackingAction: " <<
word <<
"Region " <<
i <<
". " << reg[
i]->GetName();