9 #include "G4VProcess.hh"
10 #include "G4EmProcessSubType.hh"
11 #include "G4LogicalVolumeStore.hh"
12 #include "G4RegionStore.hh"
13 #include "Randomize.hh"
14 #include "G4SystemOfUnits.hh"
89 (gRusRoEcal < 1.0 || gRusRoHcal < 1.0 ||
90 gRusRoMuonIron < 1.0 || gRusRoPreShower < 1.0 || gRusRoCastor < 1.0 ||
91 gRusRoWorld < 1.0)) { gRRactive =
true; }
92 if(nRusRoEnerLim > 0.0 &&
93 (nRusRoEcal < 1.0 || nRusRoHcal < 1.0 ||
94 nRusRoMuonIron < 1.0 || nRusRoPreShower < 1.0 || nRusRoCastor < 1.0 ||
96 if(pRusRoEnerLim > 0.0 &&
97 (pRusRoEcal < 1.0 || pRusRoHcal < 1.0 ||
98 pRusRoMuonIron < 1.0 || pRusRoPreShower < 1.0 || pRusRoCastor < 1.0 ||
101 if ( p.
exists(
"TestKillingOptions") ) {
103 .getParameter<
bool>(
"KillInCalo");
105 .getParameter<
bool>(
"KillInCaloEfH");
107 <<
" *** Activating special test killing options in StackingAction \n"
108 <<
" *** Kill secondaries in Calorimetetrs volume = " << killInCalo <<
"\n"
109 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= "
116 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction initiated with"
117 <<
" flag for saving decay products in "
118 <<
" Tracker: " << savePDandCinTracker
119 <<
" in Calo: " << savePDandCinCalo
120 <<
" in Muon: " << savePDandCinMuon
121 <<
" everywhere: " << savePDandCinAll
122 <<
"\n saveFirstSecondary"
123 <<
": " << saveFirstSecondary
124 <<
" Tracking neutrino flag: "
126 <<
" Kill Delta Ray flag: "
128 <<
" Kill hadrons/ions flag: "
133 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction kill protons below "
134 << kmaxProton/MeV <<
" MeV, neutrons below "
135 << kmaxNeutron/MeV <<
" MeV and ions"
136 <<
" below " << kmaxIon/MeV <<
" MeV";
139 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction kill tracks with "
140 <<
"time larger than " << maxTrackTime/ns
145 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction MaxTrackTime for "
146 << maxTimeNames[
i] <<
" is "
147 << maxTrackTimes[
i] <<
" ns ";
148 maxTrackTimes[
i] *= ns;
151 if(limitEnergyForVacuum > 0.0) {
153 <<
"StackingAction LowDensity regions - kill if E < "
154 << limitEnergyForVacuum/MeV <<
" MeV";
159 <<
"StackingAction Dead regions - kill all secondaries ";
164 <<
"StackingAction: "
165 <<
"Russian Roulette for gamma Elimit(MeV)= "
167 <<
" ECAL Prob= " << gRusRoEcal <<
"\n"
168 <<
" HCAL Prob= " << gRusRoHcal <<
"\n"
169 <<
" MuonIron Prob= " << gRusRoMuonIron <<
"\n"
170 <<
" PreShower Prob= " << gRusRoPreShower <<
"\n"
171 <<
" CASTOR Prob= " << gRusRoCastor <<
"\n"
176 <<
"StackingAction: "
177 <<
"Russian Roulette for neutron Elimit(MeV)= "
178 << nRusRoEnerLim/MeV <<
"\n"
179 <<
" ECAL Prob= " << nRusRoEcal <<
"\n"
180 <<
" HCAL Prob= " << nRusRoHcal <<
"\n"
181 <<
" MuonIron Prob= " << nRusRoMuonIron <<
"\n"
182 <<
" PreShower Prob= " << nRusRoPreShower <<
"\n"
183 <<
" CASTOR Prob= " << nRusRoCastor <<
"\n"
188 <<
"StackingAction: "
189 <<
"Russian Roulette for proton Elimit(MeV)= "
190 << pRusRoEnerLim/MeV <<
"\n"
191 <<
" ECAL Prob= " << pRusRoEcal <<
"\n"
192 <<
" HCAL Prob= " << pRusRoHcal <<
"\n"
193 <<
" MuonIron Prob= " << pRusRoMuonIron <<
"\n"
194 <<
" PreShower Prob= " << pRusRoPreShower <<
"\n"
195 <<
" CASTOR Prob= " << pRusRoCastor <<
"\n"
199 if(savePDandCinTracker) {
200 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Tracker regions: ";
203 if(savePDandCinCalo) {
204 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Calo regions: ";
207 if(savePDandCinMuon) {
208 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction Muon regions: ";
221 G4ClassificationOfNewTrack classification = fUrgent;
222 if (aTrack->GetCreatorProcess()==0 || aTrack->GetParentID()==0) {
241 }
else if (aTrack->GetTouchable() == 0) {
243 <<
"StackingAction: no touchable for track " << aTrack->GetTrackID()
244 <<
" from " << aTrack->GetParentID()
245 <<
" with PDG code " << aTrack->GetDefinition()->GetParticleName();
246 classification = fKill;
248 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
249 double ke = aTrack->GetKineticEnergy();
251 if (aTrack->GetTrackStatus() == fStopAndKill) { classification = fKill; }
252 if (
killHeavy && classification != fKill) {
253 if (((pdg/1000000000 == 1) && (((pdg/10000)%100) > 0) &&
254 (((pdg/10)%100) > 0) && (ke<
kmaxIon)) ||
256 ((pdg == 2112) && (ke <
kmaxNeutron))) { classification = fKill; }
259 if (pdg == 12 || pdg == 14 || pdg == 16 || pdg == 18)
260 classification = fKill;
263 { classification = fKill; }
267 classification = fKill;
275 && aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation) {
276 classification = fKill;
279 const G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
282 classification = fKill;
286 classification = fKill;
289 classification = fKill;
293 if(classification != fKill) {
310 if(2112 == pdg || 22 == pdg || 2212 == pdg) {
311 double currentWeight = aTrack->GetWeight();
313 if(1.0 >= currentWeight) {
352 if(prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
353 if(G4UniformRand() < prob) {
354 const_cast<G4Track*
>(aTrack)->SetWeight(currentWeight/prob);
356 classification = fKill;
363 int pdgMother = mother->GetDefinition()->GetPDGEncoding();
364 if ( (pdg == 22 ||
std::abs(pdg) == 11) &&
368 classification = fKill;
373 if (classification != fKill) {
395 LogDebug(
"SimG4CoreApplication") <<
"StackingAction:Classify Track "
396 << aTrack->GetTrackID() <<
" Parent "
397 << aTrack->GetParentID() <<
" Type "
398 << aTrack->GetDefinition()->GetParticleName()
399 <<
" K.E. " << aTrack->GetKineticEnergy()/MeV
400 <<
" MeV from process/subprocess "
401 << aTrack->GetCreatorProcess()->GetProcessType()
403 <<aTrack->GetCreatorProcess()->GetProcessSubType()
404 <<
" as " << classification <<
" Flag " <<
flag;
407 return classification;
417 const G4RegionStore * rs = G4RegionStore::GetInstance();
418 std::vector<G4Region*>::const_iterator rcite;
419 std::vector<std::string>::const_iterator rd;
421 for (rcite = rs->begin(); rcite != rs->end(); ++rcite) {
422 const G4Region* reg = (*rcite);
423 G4String rname = reg->GetName();
425 rname ==
"EcalRegion") {
429 rname ==
"HcalRegion") {
433 rname ==
"MuonIron") {
437 && rname ==
"PreshowerRegion") {
441 rname ==
"CastorRegion") {
445 rname ==
"DefaultRegionForTheWorld") {
453 for (
unsigned int i=0;
i<
num;
i++) {
462 (rname ==
"BeamPipe" || rname ==
"BeamPipeVacuum"
463 || rname ==
"TrackerPixelSensRegion"
464 || rname ==
"TrackerPixelDeadRegion"
465 || rname ==
"TrackerDeadRegion" || rname ==
"TrackerSensRegion")) {
469 (rname ==
"HcalRegion" || rname ==
"EcalRegion"
470 || rname ==
"PreshowerSensRegion" || rname ==
"PreshowerRegion")) {
474 (rname ==
"MuonChamber" || rname ==
"MuonSensitive_RPC"
475 || rname ==
"MuonIron" || rname ==
"Muon"
476 || rname ==
"MuonSensitive_DT-CSC") ) {
479 if(rname ==
"BeamPipeOutside" || rname ==
"BeamPipeVacuum") {
483 if(rname == (G4String)(*rd)) {
491 std::vector<const G4Region*>& regions)
const
494 unsigned int nRegions = regions.size();
495 for(
unsigned int i=0;
i<nRegions; ++
i) {
496 if(reg == regions[
i]) {
505 const G4Track & mother)
const
512 if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) {
514 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType()==fGammaConversion) {
522 const G4Track & mother)
const
531 if(22 == genID || 11 == genID || -11 == genID) { flag =
false; }
555 if (motherInfo.
isPrimary()) { flag = 3; }
566 aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
574 if (aTrack->GetGlobalTime() > tofM) { flag =
true; }
581 for (
unsigned int i=0;
i<reg.size(); ++
i) {
582 edm::LogInfo(
"SimG4CoreApplication") <<
" StackingAction: " << word
584 <<
". " << 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)
StackingAction(const edm::ParameterSet &ps)
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
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
int isItFromPrimary(const G4Track &, int) const
std::vector< const G4Region * > trackerRegions
bool isItLongLived(const G4Track *) const
std::vector< const G4Region * > caloRegions
double limitEnergyForVacuum
static const G4Track * track()
const G4Region * regionWorld