9 #include "G4VProcess.hh"
10 #include "G4EmProcessSubType.hh"
11 #include "G4LogicalVolumeStore.hh"
12 #include "G4RegionStore.hh"
13 #include "Randomize.hh"
14 #include "G4SystemOfUnits.hh"
90 (gRusRoEcal < 1.0 || gRusRoHcal < 1.0 ||
91 gRusRoMuonIron < 1.0 || gRusRoPreShower < 1.0 || gRusRoCastor < 1.0 ||
92 gRusRoWorld < 1.0)) { gRRactive =
true; }
93 if(nRusRoEnerLim > 0.0 &&
94 (nRusRoEcal < 1.0 || nRusRoHcal < 1.0 ||
95 nRusRoMuonIron < 1.0 || nRusRoPreShower < 1.0 || nRusRoCastor < 1.0 ||
97 if(pRusRoEnerLim > 0.0 &&
98 (pRusRoEcal < 1.0 || pRusRoHcal < 1.0 ||
99 pRusRoMuonIron < 1.0 || pRusRoPreShower < 1.0 || pRusRoCastor < 1.0 ||
100 pRusRoWorld < 1.0)) {
pRRactive =
true; }
102 if ( p.
exists(
"TestKillingOptions") ) {
104 .getParameter<
bool>(
"KillInCalo");
106 .getParameter<
bool>(
"KillInCaloEfH");
108 <<
" *** Activating special test killing options in StackingAction \n"
109 <<
" *** Kill secondaries in Calorimetetrs volume = " << killInCalo <<
"\n"
110 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= "
118 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction initiated with"
119 <<
" flag for saving decay products in "
120 <<
" Tracker: " << savePDandCinTracker
121 <<
" in Calo: " << savePDandCinCalo
122 <<
" in Muon: " << savePDandCinMuon
123 <<
" everywhere: " << savePDandCinAll
124 <<
"\n saveFirstSecondary"
125 <<
": " << saveFirstSecondary
126 <<
" Tracking neutrino flag: "
128 <<
" Kill Delta Ray flag: "
130 <<
" Kill hadrons/ions flag: "
135 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction kill protons below "
136 << kmaxProton/
MeV <<
" MeV, neutrons below "
137 << kmaxNeutron/
MeV <<
" MeV and ions"
138 <<
" below " << kmaxIon/
MeV <<
" MeV";
141 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction kill tracks with "
142 <<
"time larger than " << maxTrackTime/ns
147 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction MaxTrackTime for "
148 << maxTimeNames[
i] <<
" is "
149 << maxTrackTimes[
i] <<
" ns ";
150 maxTrackTimes[
i] *= ns;
153 if(limitEnergyForVacuum > 0.0) {
155 <<
"StackingAction LowDensity regions - kill if E < "
156 << limitEnergyForVacuum/
MeV <<
" MeV";
161 <<
"StackingAction Dead regions - kill all secondaries ";
166 <<
"StackingAction: "
167 <<
"Russian Roulette for gamma Elimit(MeV)= "
169 <<
" ECAL Prob= " << gRusRoEcal <<
"\n"
170 <<
" HCAL Prob= " << gRusRoHcal <<
"\n"
171 <<
" MuonIron Prob= " << gRusRoMuonIron <<
"\n"
172 <<
" PreShower Prob= " << gRusRoPreShower <<
"\n"
173 <<
" CASTOR Prob= " << gRusRoCastor <<
"\n"
178 <<
"StackingAction: "
179 <<
"Russian Roulette for neutron Elimit(MeV)= "
180 << nRusRoEnerLim/
MeV <<
"\n"
181 <<
" ECAL Prob= " << nRusRoEcal <<
"\n"
182 <<
" HCAL Prob= " << nRusRoHcal <<
"\n"
183 <<
" MuonIron Prob= " << nRusRoMuonIron <<
"\n"
184 <<
" PreShower Prob= " << nRusRoPreShower <<
"\n"
185 <<
" CASTOR Prob= " << nRusRoCastor <<
"\n"
190 <<
"StackingAction: "
191 <<
"Russian Roulette for proton Elimit(MeV)= "
192 << pRusRoEnerLim/
MeV <<
"\n"
193 <<
" ECAL Prob= " << pRusRoEcal <<
"\n"
194 <<
" HCAL Prob= " << pRusRoHcal <<
"\n"
195 <<
" MuonIron Prob= " << pRusRoMuonIron <<
"\n"
196 <<
" PreShower Prob= " << pRusRoPreShower <<
"\n"
197 <<
" CASTOR Prob= " << pRusRoCastor <<
"\n"
201 if(savePDandCinTracker) {
202 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Tracker regions: ";
205 if(savePDandCinCalo) {
206 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Calo regions: ";
209 if(savePDandCinMuon) {
210 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Muon regions: ";
223 G4ClassificationOfNewTrack classification = fUrgent;
224 if (aTrack->GetCreatorProcess()==0 || aTrack->GetParentID()==0) {
243 }
else if (aTrack->GetTouchable() == 0) {
245 <<
"StackingAction: no touchable for track " << aTrack->GetTrackID()
246 <<
" from " << aTrack->GetParentID()
247 <<
" with PDG code " << aTrack->GetDefinition()->GetParticleName();
248 classification = fKill;
250 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
251 double ke = aTrack->GetKineticEnergy();
253 if (aTrack->GetTrackStatus() == fStopAndKill) { classification = fKill; }
254 if (
killHeavy && classification != fKill) {
255 if (((pdg/1000000000 == 1) && (((pdg/10000)%100) > 0) &&
256 (((pdg/10)%100) > 0) && (ke<
kmaxIon)) ||
258 ((pdg == 2112) && (ke <
kmaxNeutron))) { classification = fKill; }
261 if (pdg == 12 || pdg == 14 || pdg == 16 || pdg == 18)
262 classification = fKill;
265 { classification = fKill; }
269 classification = fKill;
277 && aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
278 classification = fKill;
281 const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
284 classification = fKill;
288 classification = fKill;
291 classification = fKill;
295 if(classification != fKill) {
312 if(2112 == pdg || 22 == pdg || 2212 == pdg) {
313 double currentWeight = aTrack->GetWeight();
315 if(1.0 >= currentWeight) {
354 if(prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
355 if(G4UniformRand() < prob) {
356 const_cast<G4Track*
>(aTrack)->SetWeight(currentWeight/prob);
358 classification = fKill;
365 int pdgMother = mother->GetDefinition()->GetPDGEncoding();
366 if ( (pdg == 22 ||
std::abs(pdg) == 11) &&
370 classification = fKill;
375 if (classification != fKill) {
397 LogDebug(
"SimG4CoreApplication") <<
"StackingAction:Classify Track "
398 << aTrack->GetTrackID() <<
" Parent "
399 << aTrack->GetParentID() <<
" Type "
400 << aTrack->GetDefinition()->GetParticleName()
401 <<
" K.E. " << aTrack->GetKineticEnergy()/
MeV
402 <<
" MeV from process/subprocess "
403 << aTrack->GetCreatorProcess()->GetProcessType()
405 <<aTrack->GetCreatorProcess()->GetProcessSubType()
406 <<
" as " << classification <<
" Flag " <<
flag;
409 return classification;
419 const G4RegionStore * rs = G4RegionStore::GetInstance();
420 std::vector<G4Region*>::const_iterator rcite;
421 std::vector<std::string>::const_iterator rd;
423 for (rcite = rs->begin(); rcite != rs->end(); ++rcite) {
424 const G4Region* reg = (*rcite);
425 G4String rname = reg->GetName();
427 rname ==
"EcalRegion") {
431 rname ==
"HcalRegion") {
435 rname ==
"MuonIron") {
439 && rname ==
"PreshowerRegion") {
443 rname ==
"CastorRegion") {
447 rname ==
"DefaultRegionForTheWorld") {
455 for (
unsigned int i=0;
i<
num;
i++) {
464 (rname ==
"BeamPipe" || rname ==
"BeamPipeVacuum"
465 || rname ==
"TrackerPixelSensRegion"
466 || rname ==
"TrackerPixelDeadRegion"
467 || rname ==
"TrackerDeadRegion" || rname ==
"TrackerSensRegion")) {
471 (rname ==
"HcalRegion" || rname ==
"EcalRegion"
472 || rname ==
"PreshowerSensRegion" || rname ==
"PreshowerRegion")) {
476 (rname ==
"MuonChamber" || rname ==
"MuonSensitive_RPC"
477 || rname ==
"MuonIron" || rname ==
"Muon"
478 || rname ==
"MuonSensitive_DT-CSC") ) {
481 if(rname ==
"BeamPipeOutside" || rname ==
"BeamPipeVacuum") {
485 if(rname == (G4String)(*rd)) {
493 std::vector<const G4Region*>& regions)
const
496 unsigned int nRegions = regions.size();
497 for(
unsigned int i=0;
i<nRegions; ++
i) {
498 if(reg == regions[
i]) {
507 const G4Track & mother)
const
514 if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) {
516 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType()==fGammaConversion) {
524 const G4Track & mother)
const
533 if(22 == genID || 11 == genID || -11 == genID) { flag =
false; }
557 if (motherInfo.
isPrimary()) { flag = 3; }
568 aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
576 if (aTrack->GetGlobalTime() > tofM) { flag =
true; }
583 for (
unsigned int i=0;
i<reg.size(); ++
i) {
584 edm::LogInfo(
"SimG4CoreApplication") <<
" StackingAction: " << word
586 <<
". " << reg[
i]->GetName();
void primary(const G4Track *aSecondary) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< const G4Region * > lowdensRegions
std::vector< double > maxTrackTimes
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
virtual ~StackingAction()
std::vector< const G4Region * > deadRegions
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
std::vector< const G4Region * > muonRegions
std::vector< std::string > maxTimeNames
const G4Region * regionEcal
void printRegions(const std::vector< const G4Region * > ®, const std::string &word) const
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
StackingAction(const TrackingAction *, const edm::ParameterSet &ps)
Abs< T >::type abs(const T &t)
bool isThisRegion(const G4Region *, std::vector< const G4Region * > &) const
std::vector< std::string > deadRegionNames
const G4Region * regionHcal
std::vector< const G4Region * > maxTimeRegions
const G4Region * regionPreShower
const TrackingAction * trackAction
int isItFromPrimary(const G4Track &, int) const
std::vector< const G4Region * > trackerRegions
bool isItLongLived(const G4Track *) const
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum
const G4Region * regionWorld
const G4Track * geant4Track() const