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) {
24 kmaxIon =
p.getParameter<
double>(
"IonThreshold") *
MeV;
30 maxTrackTimes =
p.getParameter<std::vector<double> >(
"MaxTrackTimes");
31 maxTimeNames =
p.getParameter<std::vector<std::string> >(
"MaxTimeNames");
33 savePDandCinAll =
p.getUntrackedParameter<
bool>(
"SaveAllPrimaryDecayProductsAndConversions",
true);
34 savePDandCinTracker =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInTracker",
false);
35 savePDandCinCalo =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInCalo",
false);
36 savePDandCinMuon =
p.getUntrackedParameter<
bool>(
"SavePrimaryDecayProductsAndConversionsInMuon",
false);
52 gRusRoEcal =
p.getParameter<
double>(
"RusRoEcalGamma");
53 gRusRoHcal =
p.getParameter<
double>(
"RusRoHcalGamma");
59 nRusRoEcal =
p.getParameter<
double>(
"RusRoEcalNeutron");
60 nRusRoHcal =
p.getParameter<
double>(
"RusRoHcalNeutron");
64 nRusRoWorld =
p.getParameter<
double>(
"RusRoWorldNeutron");
77 if (
p.exists(
"TestKillingOptions")) {
81 <<
" *** Activating special test killing options in StackingAction \n"
82 <<
" *** Kill secondaries in Calorimetetrs volume = " <<
killInCalo <<
"\n"
83 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= " <<
killInCaloEfH;
90 <<
"StackingAction initiated with"
91 <<
" flag for saving decay products in "
104 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction kill tracks with "
120 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Dead regions - kill all secondaries ";
125 <<
"StackingAction: "
126 <<
"Russian Roulette for gamma Elimit(MeV)= " <<
gRusRoEnerLim /
MeV <<
"\n"
136 <<
"StackingAction: "
137 <<
"Russian Roulette for neutron Elimit(MeV)= " <<
nRusRoEnerLim /
MeV <<
"\n"
147 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Tracker regions: ";
151 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Calo regions: ";
155 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Muon regions: ";
158 worldSolid = G4TransportationManager::GetTransportationManager()
159 ->GetNavigatorForTracking()
169 G4ClassificationOfNewTrack classification = fUrgent;
170 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
174 if (aTrack->GetCreatorProcess() ==
nullptr || aTrack->GetParentID() == 0) {
175 if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
176 classification = fKill;
177 }
else if (
worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
178 classification = fKill;
184 const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
186 if (aTrack->GetTrackStatus() == fStopAndKill) {
187 classification = fKill;
188 }
else if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
189 classification = fKill;
191 classification = fKill;
196 double ke = aTrack->GetKineticEnergy();
200 classification = fKill;
203 classification = fKill;
208 classification = fKill;
212 if (
killExtra && classification != fKill) {
213 if (
killHeavy && classification != fKill) {
214 if (((
pdg / 1000000000 == 1) && (((
pdg / 10000) % 100) > 0) && (((
pdg / 10) % 100) > 0) &&
217 classification = fKill;
222 aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
223 classification = fKill;
226 classification = fKill;
231 classification = fKill;
237 if (classification != fKill) {
254 if (2112 ==
pdg || 22 ==
pdg) {
255 double currentWeight = aTrack->GetWeight();
257 if (1.0 >= currentWeight) {
301 if (prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
302 if (G4UniformRand() <
prob) {
303 const_cast<G4Track*>(aTrack)->SetWeight(currentWeight /
prob);
305 classification = fKill;
310 if (classification != fKill) {
314 <<
"StackingAction:Classify Track " << aTrack->GetTrackID() <<
" Parent " << aTrack->GetParentID()
315 <<
" Type " << aTrack->GetDefinition()->GetParticleName() <<
" K.E. " << aTrack->GetKineticEnergy() /
MeV
316 <<
" MeV from process/subprocess " << aTrack->GetCreatorProcess()->GetProcessType() <<
"|"
317 << aTrack->GetCreatorProcess()->GetProcessSubType() <<
" as " << classification <<
" Flag " <<
flag;
325 return classification;
338 std::vector<G4Region*>* rs = G4RegionStore::GetInstance();
340 for (
auto& reg : *rs) {
341 G4String
rname = reg->GetName();
362 for (
unsigned int i = 0;
i <
num; ++
i) {
370 (
rname ==
"BeamPipe" ||
rname ==
"BeamPipeVacuum" ||
rname ==
"TrackerPixelSensRegion" ||
371 rname ==
"TrackerPixelDeadRegion" ||
rname ==
"TrackerDeadRegion" ||
rname ==
"TrackerSensRegion")) {
375 rname ==
"PreshowerRegion")) {
379 rname ==
"Muon" ||
rname ==
"MuonSensitive_DT-CSC")) {
382 if (
rname ==
"BeamPipeOutside" ||
rname ==
"BeamPipeVacuum") {
386 if (
rname == (G4String)(dead)) {
409 if (aTrack->GetCreatorProcess()->GetProcessType() ==
fDecay) {
411 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) {
423 return (22 == genID || 11 == genID || -11 == genID) ?
false :
true;
445 return (aTrack->GetGlobalTime() > tofM) ?
true :
false;
449 for (
unsigned int i = 0;
i < reg.size(); ++
i) {
451 <<
" StackingAction: " <<
word <<
"Region " <<
i <<
". " << reg[
i]->GetName();