1 #ifndef HelpfulWatchers_G4StepStatistics_h 2 #define HelpfulWatchers_G4StepStatistics_h 26 #include "G4ParticleDefinition.hh" 28 #include "G4VProcess.hh" 35 #include <TClonesArray.h> 68 : theG4RegionName(
"UNDEFINED"),
69 theG4ProcessName(
"UNDEFINED"),
70 theParticlePDGID(theG4Step->GetTrack()->GetDefinition()->GetPDGEncoding()) {
72 if (theG4Step->GetPreStepPoint()->GetPhysicalVolume()) {
73 theG4RegionName = theG4Step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()->GetName();
75 std::cout <<
"Physical Volume" << std::endl;
76 if (theG4Step->GetPreStepPoint()->GetProcessDefinedStep()) {
77 theG4ProcessName = theG4Step->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
98 }
else if (strcmp(theG4RegionName,
id.
GetRegionName()) != 0) {
99 return strcmp(theG4RegionName,
id.
GetRegionName()) > 0 ?
true :
false;
101 return strcmp(theG4ProcessName,
id.
GetProcessName()) > 0 ?
true :
false;
110 }
else if (strcmp(theG4RegionName,
id.
GetRegionName()) != 0) {
111 return strcmp(theG4RegionName,
id.
GetRegionName()) < 0 ?
true :
false;
113 return strcmp(theG4ProcessName,
id.
GetProcessName()) < 0 ?
true :
false;
120 #define OBSERVES(type) \ 122 Observer<const type *> 123 #define UPDATE(type) \ 124 void update(const type *) override { std::cout << "++ signal " #type << std::endl; } 137 : m_verbose(pSet.getUntrackedParameter<
bool>(
"verbose",
false)),
Event(0) {
139 G4StepTree = fs->make<TTree>(
"G4StepTree",
"G4Step Tree ");
140 G4StepTree->Branch(
"Event", &
Event,
"Event/I");
141 G4StepTree->Branch(
"PDGID", &PDGID,
"PDGID[100000]/I");
142 Region =
new TClonesArray(
"TObjString", 100000);
143 G4StepTree->Branch(
"Region", &
Region);
144 Process =
new TClonesArray(
"TObjString", 100000);
145 G4StepTree->Branch(
"Process", &Process);
146 G4StepTree->Branch(
"G4StepFreq", &G4StepFreq,
"G4StepFreq[100000]/I");
156 void update(const G4Step *iStep)
override {
161 if (G4StatsMap.find(mysteptest) == G4StatsMap.end()) {
165 unsigned int *MyValue =
new unsigned int(1);
167 G4StatsMap.insert(std::make_pair(mysteptest, MyValue));
170 *G4StatsMap[mysteptest] = *G4StatsMap[mysteptest] + 1;
189 std::cout <<
"++ signal EndOfEvent " << std::endl;
194 std::cout <<
" G4StatsMap size is: " << G4StatsMap.size() << std::endl;
197 for (std::map<const StepID, unsigned int *>::const_iterator
step = G4StatsMap.begin();
step != G4StatsMap.end();
200 std::cout <<
" G4StatsMap step is: " <<
step->first.GetRegionName() <<
" " <<
step->first.GetProcessName()
201 <<
" " <<
step->first.GetParticlePDGID();
202 std::cout <<
" Number of such steps: " << *
step->second << std::endl;
206 PDGID[
index] =
step->first.GetParticlePDGID();
207 new ((*Region)[
index]) TObjString(
step->first.GetRegionName());
208 new ((*Process)[
index]) TObjString(
step->first.GetProcessName());
227 TClonesArray *Process;
228 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