1 #ifndef HelpfulWatchers_G4StepStatistics_h 2 #define HelpfulWatchers_G4StepStatistics_h 29 #include "G4VProcess.hh" 30 #include "G4ParticleDefinition.hh" 40 #include <TClonesArray.h> 70 theG4RegionName(
"UNDEFINED"),
71 theG4ProcessName(
"UNDEFINED"),
72 theParticlePDGID(theG4Step->GetTrack()->GetDefinition()->GetPDGEncoding())
75 if (theG4Step->GetPreStepPoint()->GetPhysicalVolume()) {
76 theG4RegionName = theG4Step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()->GetName();
79 if (theG4Step->GetPreStepPoint()->GetProcessDefinedStep()){
80 theG4ProcessName = theG4Step->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
101 return strcmp(theG4RegionName,
id.
GetRegionName())>0 ?
true :
false;
104 return strcmp(theG4ProcessName,
id.
GetProcessName())>0 ?
true :
false;
117 return strcmp(theG4RegionName,
id.
GetRegionName())<0 ?
true :
false;
120 return strcmp(theG4ProcessName,
id.
GetProcessName())<0 ?
true :
false;
128 #define OBSERVES(type) public Observer<const type*> 129 #define UPDATE(type) void update(const type*) { std::cout <<"++ signal " #type<<std::endl; } 143 m_verbose(pSet.getUntrackedParameter<
bool>(
"verbose",
false)),
147 G4StepTree = fs->make<TTree>(
"G4StepTree",
"G4Step Tree ");
148 G4StepTree->Branch(
"Event",&
Event,
"Event/I");
149 G4StepTree->Branch(
"PDGID",&PDGID,
"PDGID[100000]/I");
150 Region =
new TClonesArray(
"TObjString",100000);
151 G4StepTree->Branch(
"Region",&
Region);
152 Process =
new TClonesArray(
"TObjString",100000);
153 G4StepTree->Branch(
"Process",&Process);
154 G4StepTree->Branch(
"G4StepFreq",&G4StepFreq,
"G4StepFreq[100000]/I");
164 void update(const G4Step* iStep)
override {
169 if ( G4StatsMap.find(mysteptest) == G4StatsMap.end() )
173 unsigned int* MyValue =
new unsigned int(1);
175 G4StatsMap.insert(std::make_pair(mysteptest, MyValue));
180 *G4StatsMap[mysteptest] = *G4StatsMap[mysteptest] + 1;
199 std::cout <<
"++ signal EndOfEvent " <<std::endl;
204 std::cout <<
" G4StatsMap size is: "<<G4StatsMap.size()<<std::endl;
207 for (std::map<const StepID,unsigned int*>::const_iterator
step = G4StatsMap.begin();
step != G4StatsMap.end(); ++
step, ++
index){
209 std::cout <<
" G4StatsMap step is: "<<
step->first.GetRegionName()<<
" "<<
step->first.GetProcessName()<<
" "<<
step->first.GetParticlePDGID();
210 std::cout <<
" Number of such steps: "<< *
step->second <<std::endl;
213 PDGID[
index]=
step->first.GetParticlePDGID();
214 new ((*Region)[
index]) TObjString (
step->first.GetRegionName());
215 new ((*Process)[
index]) TObjString (
step->first.GetProcessName());
234 TClonesArray* Process;
235 Int_t G4StepFreq[100000];
bool operator==(const StepID &id) const
G4StepStatistics(const edm::ParameterSet &pSet)
bool operator<(const StepID &id) const
StepID(const G4Step *theG4Step)
G4String theG4ProcessName
G4String GetProcessName() const
bool operator>(const StepID &id) const
G4int GetParticlePDGID() const
G4String GetRegionName() const