9 #include "G4VProcess.hh"
10 #include "G4EmProcessSubType.hh"
11 #include "G4LogicalVolumeStore.hh"
12 #include "G4RegionStore.hh"
34 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction initiated with"
35 <<
" flag for saving decay products in "
36 <<
" Tracker: " << savePDandCinTracker
37 <<
" in Calo: " << savePDandCinCalo
38 <<
" in Muon: " << savePDandCinMuon
39 <<
"\n saveFirstSecondary"
40 <<
": " << saveFirstSecondary
41 <<
" Flag for tracking neutrino: "
43 << killHeavy <<
" protons below "
44 << kmaxProton <<
" MeV, neutrons below "
45 << kmaxNeutron <<
" MeV and ions"
46 <<
" below " << kmaxIon <<
" MeV\n"
47 <<
" kill tracks with "
48 <<
"time larger than " << maxTrackTime
49 <<
" ns and kill Delta Ray flag set to "
51 for (
unsigned int i=0;
i<maxTrackTimes.size();
i++) {
52 maxTrackTimes[
i] *= ns;
53 edm::LogInfo(
"SimG4CoreApplication") <<
"StackingAction::MaxTrackTime for "
54 << maxTimeNames[
i] <<
" is "
65 G4ClassificationOfNewTrack classification = fUrgent;
69 if (aTrack->GetCreatorProcess()==0 || aTrack->GetParentID()==0) {
71 }
else if (aTrack->GetTouchable() == 0) {
73 <<
"StackingAction: no touchable for track " << aTrack->GetTrackID()
74 <<
" from " << aTrack->GetParentID()
75 <<
" with PDG code " << aTrack->GetDefinition()->GetParticleName();
76 classification = fKill;
86 if (aTrack->GetTrackStatus() == fStopAndKill) classification = fKill;
88 int pdg = aTrack->GetDefinition()->GetPDGEncoding();
89 double ke = aTrack->GetKineticEnergy()/MeV;
90 if (((pdg/1000000000 == 1) && (((pdg/10000)%100) > 0) &&
91 (((pdg/10)%100) > 0) && (ke<
kmaxIon)) ||
93 ((pdg == 2112) && (ke <
kmaxNeutron))) classification = fKill;
96 int pdg =
std::abs(aTrack->GetDefinition()->GetPDGEncoding());
97 if (pdg == 12 || pdg == 14 || pdg == 16 || pdg == 18)
98 classification = fKill;
102 if (aTrack->GetCreatorProcess()->GetProcessType() == fElectromagnetic &&
103 aTrack->GetCreatorProcess()->GetProcessSubType() == fIonisation)
104 classification = fKill;
107 LogDebug(
"SimG4CoreApplication") <<
"StackingAction:Classify Track "
108 << aTrack->GetTrackID() <<
" Parent "
109 << aTrack->GetParentID() <<
" Type "
110 << aTrack->GetDefinition()->GetParticleName()
111 <<
" K.E. " << aTrack->GetKineticEnergy()/MeV
112 <<
" MeV from process/subprocess "
113 << aTrack->GetCreatorProcess()->GetProcessType() <<
"|"
114 << aTrack->GetCreatorProcess()->GetProcessSubType()
115 <<
" as " << classification <<
" Flag " <<
flag;
118 return classification;
127 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
129 std::vector<G4LogicalVolume*>::const_iterator lvcite;
130 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
132 if (strcmp(
"Tracker",(*lvcite)->GetName().c_str()) == 0)
tracker.push_back(*lvcite);
133 if (strcmp(
"BEAM",(*lvcite)->GetName().substr(0,4).c_str()) == 0)
tracker.push_back(*lvcite);
136 if (strcmp(
"CALO",(*lvcite)->GetName().c_str()) == 0)
calo.push_back(*lvcite);
137 if (strcmp(
"VCAL",(*lvcite)->GetName().c_str()) == 0)
calo.push_back(*lvcite);
140 if (strcmp(
"MUON",(*lvcite)->GetName().c_str()) == 0)
muon.push_back(*lvcite);
143 edm::LogInfo(
"SimG4CoreApplication") <<
"# of LV for Tracker "
144 <<
tracker.size() <<
" for Calo "
145 <<
calo.size() <<
" for Muon "
148 edm::LogInfo(
"SimG4CoreApplication") <<
"Tracker vol " <<
i <<
" name "
150 for (
unsigned int i=0;
i<
calo.size(); ++
i)
151 edm::LogInfo(
"SimG4CoreApplication") <<
"Calorimeter vol " <<
i <<
" name "
152 <<
calo[
i]->GetName();
153 for (
unsigned int i=0;
i<
muon.size(); ++
i)
154 edm::LogInfo(
"SimG4CoreApplication") <<
"Muon vol " <<
i <<
" name "
155 <<
muon[
i]->GetName();
158 const G4RegionStore * rs = G4RegionStore::GetInstance();
161 std::vector<double> tofs;
163 std::vector<G4Region*>::const_iterator rcite;
164 for (rcite = rs->begin(); rcite != rs->end(); rcite++) {
165 for (
unsigned int i=0;
i<
num;
i++) {
172 if (tofs.size() ==
num)
break;
175 for (
unsigned int i=0;
i<tofs.size();
i++) {
177 G4String
name =
"Unknown";
179 edm::LogInfo(
"SimG4CoreApplication") << name <<
" with pointer "
188 std::vector<G4LogicalVolume*> & lvs)
const {
191 if (lvs.size() > 0 && touch !=0) {
192 int level = ((touch->GetHistoryDepth())+1);
194 unsigned int ii = (
unsigned int)(level - 3);
195 flag = (
std::count(lvs.begin(),lvs.end(),(touch->GetVolume(ii)->GetLogicalVolume())) != 0);
202 const G4Track & mother)
const {
209 if (aTrack->GetCreatorProcess()->GetProcessType() == fDecay) flag = 1;
210 else if (aTrack->GetCreatorProcess()->GetProcessType() == fElectromagnetic &&
211 aTrack->GetCreatorProcess()->GetProcessSubType() == fGammaConversion) flag = 2;
230 double time = (aTrack->GetGlobalTime())/nanosecond;
233 G4Region* reg = aTrack->GetTouchable()->GetVolume(0)->GetLogicalVolume()->GetRegion();
241 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
std::vector< double > maxTrackTimes
int isItPrimaryDecayProductOrConversion(const G4Track *, const G4Track &) const
virtual ~StackingAction()
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack)
StackingAction(const edm::ParameterSet &ps)
std::vector< std::string > maxTimeNames
virtual void PrepareNewEvent()
void secondary(const G4Track *aSecondary, const G4Track &mother, int) const
std::vector< G4LogicalVolume * > calo
std::vector< G4LogicalVolume * > muon
bool isThisVolume(const G4VTouchable *, std::vector< G4LogicalVolume * > &) const
int isItFromPrimary(const G4Track &, int) const
bool isItLongLived(const G4Track *) const
static const G4Track * track()