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" 20 : trackAction(trka),steppingVerbose(sv)
80 (gRusRoEcal < 1.0 || gRusRoHcal < 1.0 ||
81 gRusRoMuonIron < 1.0 || gRusRoPreShower < 1.0 || gRusRoCastor < 1.0 ||
82 gRusRoWorld < 1.0)) { gRRactive =
true; }
83 if(nRusRoEnerLim > 0.0 &&
84 (nRusRoEcal < 1.0 || nRusRoHcal < 1.0 ||
85 nRusRoMuonIron < 1.0 || nRusRoPreShower < 1.0 || nRusRoCastor < 1.0 ||
88 if ( p.
exists(
"TestKillingOptions") ) {
90 .getParameter<
bool>(
"KillInCalo");
92 .getParameter<
bool>(
"KillInCaloEfH");
94 <<
" *** Activating special test killing options in StackingAction \n" 95 <<
" *** Kill secondaries in Calorimetetrs volume = " << killInCalo <<
"\n" 96 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= " 104 <<
"StackingAction initiated with" <<
" flag for saving decay products in " 105 <<
" Tracker: " << savePDandCinTracker
106 <<
" in Calo: " << savePDandCinCalo
107 <<
" in Muon: " << savePDandCinMuon
108 <<
" everywhere: " << savePDandCinAll <<
"\n saveFirstSecondary" 109 <<
": " << saveFirstSecondary
111 <<
" Kill Delta Ray flag: " << killDeltaRay
112 <<
" Kill hadrons/ions flag: " <<
killHeavy;
116 <<
"StackingAction kill protons below " 117 << kmaxProton/
MeV <<
" MeV, neutrons below " 118 << kmaxNeutron/
MeV <<
" MeV and ions" 119 <<
" below " << kmaxIon/
MeV <<
" MeV";
123 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction kill tracks with " 124 <<
"time larger than " << maxTrackTime/ns
129 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction MaxTrackTime for " 130 << maxTimeNames[
i] <<
" is " 131 << maxTrackTimes[
i] <<
" ns ";
132 maxTrackTimes[
i] *= ns;
135 if(limitEnergyForVacuum > 0.0) {
137 <<
"StackingAction LowDensity regions - kill if E < " 138 << limitEnergyForVacuum/
MeV <<
" MeV";
143 <<
"StackingAction Dead regions - kill all secondaries ";
148 <<
"StackingAction: " 149 <<
"Russian Roulette for gamma Elimit(MeV)= " 151 <<
" ECAL Prob= " << gRusRoEcal <<
"\n" 152 <<
" HCAL Prob= " << gRusRoHcal <<
"\n" 153 <<
" MuonIron Prob= " << gRusRoMuonIron <<
"\n" 154 <<
" PreShower Prob= " << gRusRoPreShower <<
"\n" 155 <<
" CASTOR Prob= " << gRusRoCastor <<
"\n" 160 <<
"StackingAction: " 161 <<
"Russian Roulette for neutron Elimit(MeV)= " 162 << nRusRoEnerLim/
MeV <<
"\n" 163 <<
" ECAL Prob= " << nRusRoEcal <<
"\n" 164 <<
" HCAL Prob= " << nRusRoHcal <<
"\n" 165 <<
" MuonIron Prob= " << nRusRoMuonIron <<
"\n" 166 <<
" PreShower Prob= " << nRusRoPreShower <<
"\n" 167 <<
" CASTOR Prob= " << nRusRoCastor <<
"\n" 171 if(savePDandCinTracker) {
172 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Tracker regions: ";
175 if(savePDandCinCalo) {
176 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Calo regions: ";
179 if(savePDandCinMuon) {
180 edm::LogVerbatim(
"SimG4CoreApplication") <<
"StackingAction Muon regions: ";
183 worldSolid = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume()->GetSolid();
194 G4ClassificationOfNewTrack classification = fUrgent;
195 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
199 if (aTrack->GetCreatorProcess()==
nullptr || aTrack->GetParentID()==0) {
200 if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18)) {
201 classification = fKill;
202 }
else if (
worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
203 classification = fKill;
210 const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
212 if (aTrack->GetTrackStatus() == fStopAndKill) { classification = fKill; }
213 else if (!
trackNeutrino && (abspdg == 12 || abspdg == 14 || abspdg == 16 || abspdg == 18))
214 { classification = fKill; }
219 double ke = aTrack->GetKineticEnergy();
223 classification = fKill;
226 classification = fKill;
233 if(
killExtra && classification != fKill) {
234 if (
killHeavy && classification != fKill) {
235 if (((pdg/1000000000 == 1) && (((pdg/10000)%100) > 0) &&
236 (((pdg/10)%100) > 0) && (ke<
kmaxIon)) ||
238 ((pdg == 2112) && (ke <
kmaxNeutron))) { classification = fKill; }
242 && aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
243 classification = fKill;
247 classification = fKill;
252 if ((pdg == 22 || abspdg == 11) && pdgMother != 11 && pdgMother != 22 &&
254 classification = fKill;
260 if(classification != fKill) {
277 if(2112 == pdg || 22 == pdg) {
278 double currentWeight = aTrack->GetWeight();
280 if(1.0 >= currentWeight) {
309 if(prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
310 if(G4UniformRand() < prob) {
311 const_cast<G4Track*
>(aTrack)->SetWeight(currentWeight/prob);
313 classification = fKill;
318 if (classification != fKill) {
321 LogDebug(
"SimG4CoreApplication") <<
"StackingAction:Classify Track " 322 << aTrack->GetTrackID() <<
" Parent " 323 << aTrack->GetParentID() <<
" Type " 324 << aTrack->GetDefinition()->GetParticleName()
325 <<
" K.E. " << aTrack->GetKineticEnergy()/
MeV 326 <<
" MeV from process/subprocess " 327 << aTrack->GetCreatorProcess()->GetProcessType()
329 <<aTrack->GetCreatorProcess()->GetProcessSubType()
330 <<
" as " << classification <<
" Flag " <<
flag;
338 return classification;
352 std::vector<G4Region*> *rs = G4RegionStore::GetInstance();
354 for (
auto & reg : *rs) {
355 G4String rname = reg->GetName();
376 for (
unsigned int i=0;
i<
num; ++
i) {
384 (rname ==
"BeamPipe" || rname ==
"BeamPipeVacuum" 385 || rname ==
"TrackerPixelSensRegion" 386 || rname ==
"TrackerPixelDeadRegion" 387 || rname ==
"TrackerDeadRegion" || rname ==
"TrackerSensRegion")) {
391 (rname ==
"HcalRegion" || rname ==
"EcalRegion" 392 || rname ==
"PreshowerSensRegion" || rname ==
"PreshowerRegion")) {
396 (rname ==
"MuonChamber" || rname ==
"MuonSensitive_RPC" 397 || rname ==
"MuonIron" || rname ==
"Muon" 398 || rname ==
"MuonSensitive_DT-CSC") ) {
401 if(rname ==
"BeamPipeOutside" || rname ==
"BeamPipeVacuum") {
405 if(rname == (G4String)(dead)) {
413 std::vector<const G4Region*>&
regions)
const 416 for(
auto & region : regions) {
426 const G4Track & mother)
const 432 if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) {
434 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType()==fGammaConversion) {
442 const G4Track & mother)
const 448 return (22 == genID || 11 == genID || -11 == genID) ?
false :
true;
456 if (motherInfo.
isPrimary()) { flag = 3; }
470 return (aTrack->GetGlobalTime() > tofM) ?
true :
false;
476 for (
unsigned int i=0;
i<reg.size(); ++
i) {
478 <<
" StackingAction: " << word <<
"Region " <<
i 479 <<
". " << reg[
i]->GetName();
void primary(const G4Track *aSecondary) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack) final
StackingAction(const TrackingAction *, const edm::ParameterSet &ps, const CMSSteppingVerbose *)
std::vector< const G4Region * > lowdensRegions
void PrepareNewEvent() override
void StackFilled(const G4Track *, bool isKilled) const
std::vector< double > maxTrackTimes
TrackInformationExtractor extractor
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const G4Region * regionCastor
const G4Region * regionMuonIron
bool rrApplicable(const G4Track *, const G4Track &) const
int isItPrimaryDecayProductOrConversion(const G4Track *, const G4Track &) const
std::vector< const G4Region * > deadRegions
const CMSSteppingVerbose * steppingVerbose
std::vector< const G4Region * > muonRegions
std::vector< std::string > maxTimeNames
const G4Region * regionEcal
~StackingAction() override
void printRegions(const std::vector< const G4Region * > ®, const std::string &word) const
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
Abs< T >::type abs(const T &t)
bool isThisRegion(const G4Region *, std::vector< const G4Region * > &) const
std::vector< std::string > deadRegionNames
const G4Region * regionHcal
bool isItOutOfTimeWindow(const G4Region *, const G4Track *) const
std::vector< const G4Region * > maxTimeRegions
const G4Region * regionPreShower
const TrackingAction * trackAction
int isItFromPrimary(const G4Track &, int) const
std::vector< const G4Region * > trackerRegions
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum
const G4Region * regionWorld
const G4Track * geant4Track() const