10 #include "G4VProcess.hh"
11 #include "G4EmProcessSubType.hh"
12 #include "G4LogicalVolumeStore.hh"
13 #include "G4RegionStore.hh"
14 #include "Randomize.hh"
15 #include "G4SystemOfUnits.hh"
32 for(
unsigned int i=0;
i<maxTrackTimes.size(); ++
i) { maxTrackTimes[
i] *= ns; }
84 if(gRusRoEcal < 1.0 || gRusRoHcal < 1.0 ||
85 gRusRoMuonIron < 1.0 || gRusRoPreShower < 1.0 || gRusRoCastor < 1.0 ||
86 gRusRoWorld < 1.0) { gRRactive =
true; }
87 if(nRusRoEcal < 1.0 || nRusRoHcal < 1.0 ||
88 nRusRoMuonIron < 1.0 || nRusRoPreShower < 1.0 || nRusRoCastor < 1.0 ||
90 if(pRusRoEcal < 1.0 || pRusRoHcal < 1.0 ||
91 pRusRoMuonIron < 1.0 || pRusRoPreShower < 1.0 || pRusRoCastor < 1.0 ||
94 if ( p.
exists(
"TestKillingOptions") ) {
99 <<
" *** Activating special test killing options in StackingAction \n"
100 <<
" *** Kill secondaries in Calorimetetrs volume = " << killInCalo <<
"\n"
101 <<
" *** Kill electromagnetic secondaries from hadrons in Calorimeters volume = " <<
killInCaloEfH;
105 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction initiated with"
106 <<
" flag for saving decay products in "
107 <<
" Tracker: " << savePDandCinTracker
108 <<
" in Calo: " << savePDandCinCalo
109 <<
" in Muon: " << savePDandCinMuon
110 <<
"\n saveFirstSecondary"
111 <<
": " << saveFirstSecondary
112 <<
" Flag for tracking neutrino: "
114 << killHeavy <<
" protons below "
115 << kmaxProton <<
" MeV, neutrons below "
116 << kmaxNeutron <<
" MeV and ions"
117 <<
" below " << kmaxIon <<
" MeV\n"
118 <<
" kill tracks with "
119 <<
"time larger than " << maxTrackTime
120 <<
" ns and kill Delta Ray flag set to "
122 for (
unsigned int i=0;
i<maxTrackTimes.size();
i++) {
123 maxTrackTimes[
i] *= ns;
124 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction::MaxTrackTime for "
130 <<
"StackingAction: "
131 <<
"Russian Roulette for gamma Elimit(MeV)= "
132 << nRusRoEnerLim/MeV <<
"\n"
133 <<
" ECAL Prob= " << gRusRoEcal <<
"\n"
134 <<
" HCAL Prob= " << gRusRoHcal <<
"\n"
135 <<
" MuonIron Prob= " << gRusRoMuonIron <<
"\n"
136 <<
" PreShower Prob= " << gRusRoPreShower <<
"\n"
137 <<
" CASTOR Prob= " << gRusRoCastor <<
"\n"
142 <<
"StackingAction: "
143 <<
"Russian Roulette for neutron Elimit(MeV)= "
144 << nRusRoEnerLim/MeV <<
"\n"
145 <<
" ECAL Prob= " << nRusRoEcal <<
"\n"
146 <<
" HCAL Prob= " << nRusRoHcal <<
"\n"
147 <<
" MuonIron Prob= " << nRusRoMuonIron <<
"\n"
148 <<
" PreShower Prob= " << nRusRoPreShower <<
"\n"
149 <<
" CASTOR Prob= " << nRusRoCastor <<
"\n"
154 <<
"StackingAction: "
155 <<
"Russian Roulette for proton Elimit(MeV)= "
156 << pRusRoEnerLim/MeV <<
"\n"
157 <<
" ECAL Prob= " << pRusRoEcal <<
"\n"
158 <<
" HCAL Prob= " << pRusRoHcal <<
"\n"
159 <<
" MuonIron Prob= " << pRusRoMuonIron <<
"\n"
160 <<
" PreShower Prob= " << pRusRoPreShower <<
"\n"
161 <<
" CASTOR Prob= " << pRusRoCastor <<
"\n"
176 G4ClassificationOfNewTrack classification = fUrgent;
177 if (aTrack->GetCreatorProcess()==0 || aTrack->GetParentID()==0) {
196 }
else if (aTrack->GetTouchable() == 0) {
198 <<
"StackingAction: no touchable for track " << aTrack->GetTrackID()
199 <<
" from " << aTrack->GetParentID()
200 <<
" with PDG code " << aTrack->GetDefinition()->GetParticleName();
201 classification = fKill;
203 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
205 if (aTrack->GetTrackStatus() == fStopAndKill) { classification = fKill; }
206 if (
killHeavy && classification != fKill) {
207 double ke = aTrack->GetKineticEnergy()/MeV;
208 if (((pdg/1000000000 == 1) && (((pdg/10000)%100) > 0) &&
209 (((pdg/10)%100) > 0) && (ke<
kmaxIon)) ||
211 ((pdg == 2112) && (ke <
kmaxNeutron))) { classification = fKill; }
214 if (pdg == 12 || pdg == 14 || pdg == 16 || pdg == 18)
215 classification = fKill;
218 { classification = fKill; }
220 if (aTrack->GetCreatorProcess()->GetProcessType() == fElectromagnetic &&
221 aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation)
222 classification = fKill;
226 classification = fKill;
230 if(classification != fKill) {
246 if(2112 == pdg || 22 == pdg || 2212 == pdg) {
247 double currentWeight = aTrack->GetWeight();
249 if(1.0 >= currentWeight) {
256 G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
268 G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
284 G4Region* reg = aTrack->GetVolume()->GetLogicalVolume()->GetRegion();
292 if(prob < 1.0 && aTrack->GetKineticEnergy() < elim) {
293 if(G4UniformRand() < prob) {
294 const_cast<G4Track*
>(aTrack)->SetWeight(currentWeight/prob);
296 classification = fKill;
303 int pdgMother = mother->GetDefinition()->GetPDGEncoding();
304 if ( (pdg == 22 ||
std::abs(pdg) == 11) &&
308 classification = fKill;
313 if (classification != fKill) {
335 LogDebug(
"SimG4CoreApplication") <<
"StackingAction:Classify Track "
336 << aTrack->GetTrackID() <<
" Parent "
337 << aTrack->GetParentID() <<
" Type "
338 << aTrack->GetDefinition()->GetParticleName()
339 <<
" K.E. " << aTrack->GetKineticEnergy()/MeV
340 <<
" MeV from process/subprocess "
341 << aTrack->GetCreatorProcess()->GetProcessType()
343 <<aTrack->GetCreatorProcess()->GetProcessSubType()
344 <<
" as " << classification <<
" Flag " << flag;
347 return classification;
356 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
358 std::vector<G4LogicalVolume*>::const_iterator lvcite;
359 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
361 if (strcmp(
"Tracker",(*lvcite)->GetName().c_str()) == 0) {
364 if (strcmp(
"BEAM",(*lvcite)->GetName().substr(0,4).c_str()) == 0) {
369 if (strcmp(
"CALO",(*lvcite)->GetName().c_str()) == 0) {
370 calo.push_back(*lvcite);
372 if (strcmp(
"VCAL",(*lvcite)->GetName().c_str()) == 0) {
373 calo.push_back(*lvcite);
377 if (strcmp(
"MUON",(*lvcite)->GetName().c_str()) == 0) {
378 muon.push_back(*lvcite);
382 edm::LogInfo(
"SimG4CoreApplication") <<
"# of LV for Tracker "
383 <<
tracker.size() <<
" for Calo "
384 <<
calo.size() <<
" for Muon "
387 edm::LogInfo(
"SimG4CoreApplication") <<
"Tracker vol " <<
i <<
" name "
389 for (
unsigned int i=0;
i<
calo.size(); ++
i)
390 edm::LogInfo(
"SimG4CoreApplication") <<
"Calorimeter vol " <<
i <<
" name "
391 <<
calo[
i]->GetName();
392 for (
unsigned int i=0;
i<
muon.size(); ++
i)
393 edm::LogInfo(
"SimG4CoreApplication") <<
"Muon vol " <<
i <<
" name "
394 <<
muon[
i]->GetName();
397 std::vector<double> tofs;
400 const G4RegionStore * rs = G4RegionStore::GetInstance();
401 std::vector<G4Region*>::const_iterator rcite;
402 for (rcite = rs->begin(); rcite != rs->end(); rcite++) {
404 (*rcite)->GetName() ==
"EcalRegion") {
408 (*rcite)->GetName() ==
"HcalRegion") {
412 (*rcite)->GetName() ==
"MuonIron") {
416 && (*rcite)->GetName() ==
"PreshowerRegion") {
420 (*rcite)->GetName() ==
"CastorRegion") {
424 (*rcite)->GetName() ==
"DefaultRegionForTheWorld") {
431 for (
unsigned int i=0;
i<
num;
i++) {
440 if(0 < tofs.size()) {
441 for (
unsigned int i=0;
i<tofs.size();
i++) {
443 G4String
name =
"Unknown";
445 edm::LogInfo(
"SimG4CoreApplication") << name <<
" with pointer "
453 std::vector<G4LogicalVolume*> & lvs)
const
456 if (lvs.size() > 0 && touch !=0) {
457 int level = ((touch->GetHistoryDepth())+1);
459 unsigned int ii = (
unsigned int)(level - 3);
461 (touch->GetVolume(ii)->GetLogicalVolume())) != 0);
468 const G4Track & mother)
const
475 if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) {
477 }
else if (aTrack->GetCreatorProcess()->GetProcessSubType()==fGammaConversion) {
487 const G4Track & mother)
const
496 if(22 == genID || 11 == genID || -11 == genID) { flag =
false; }
517 double time = (aTrack->GetGlobalTime())/nanosecond;
521 aTrack->GetTouchable()->GetVolume(0)->GetLogicalVolume()->GetRegion();
529 if (time > tofM) { flag =
true; }
void primary(const G4Track *aSecondary) const
std::vector< G4LogicalVolume * > tracker
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< G4Region * > maxTimeRegions
StackingAction(EventAction *e, const edm::ParameterSet &ps)
std::vector< double > maxTrackTimes
G4Region * regionPreShower
bool exists(std::string const ¶meterName) const
checks if a parameter exists
G4Region * regionMuonIron
bool rrApplicable(const G4Track *, const G4Track &) const
int isItPrimaryDecayProductOrConversion(const G4Track *, const G4Track &) const
virtual ~StackingAction()
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
std::vector< std::string > maxTimeNames
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
Abs< T >::type abs(const T &t)
std::vector< G4LogicalVolume * > calo
std::vector< G4LogicalVolume * > muon
bool isThisVolume(const G4VTouchable *, std::vector< G4LogicalVolume * > &) const
bool isItLongLived(const G4Track *) const
static const G4Track * track()