CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
G4StepStatistics Class Reference

#include <G4StepStatistics.h>

Inheritance diagram for G4StepStatistics:
Observer< const EndOfTrack * > Observer< const EndOfEvent * > Observer< const EndOfRun * > Observer< const G4Step * > Observer< const BeginOfTrack * > Observer< const BeginOfEvent * > Observer< const BeginOfRun * > Observer< const BeginOfJob * > Observer< const DDDWorld * > SimWatcher

Public Member Functions

 G4StepStatistics (const edm::ParameterSet &pSet)
 
void update (const DDDWorld *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfJob *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *iStep) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *iRun) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
- Public Member Functions inherited from SimWatcher
virtual void beginRun (edm::EventSetup const &)
 
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
virtual void registerConsumes (edm::ConsumesCollector)
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const DDDWorld * >
 Observer ()
 
void slotForUpdate (const DDDWorld *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfRun * >
 Observer ()
 
void slotForUpdate (const EndOfRun *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent *iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack *iT)
 
virtual ~Observer ()
 

Private Attributes

unsigned int Event
 
edm::Service< TFileServicefs
 
std::map< const StepID,
unsigned int * > 
G4StatsMap
 
Int_t G4StepFreq [100000]
 
TTree * G4StepTree
 
bool m_verbose
 
Int_t PDGID [100000]
 
TClonesArray * Process
 
TClonesArray * Region
 

Additional Inherited Members

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 125 of file G4StepStatistics.h.

Constructor & Destructor Documentation

G4StepStatistics::G4StepStatistics ( const edm::ParameterSet pSet)
inline

Definition at line 136 of file G4StepStatistics.h.

References fs, G4StepFreq, G4StepTree, TFileService::make(), PDGID, Process, and Region.

137  : m_verbose(pSet.getUntrackedParameter<bool>("verbose", false)), Event(0) {
138  // Adding TFile Service output
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");
147  }
T getUntrackedParameter(std::string const &, T const &) const
Int_t G4StepFreq[100000]
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
unsigned int Event
Int_t PDGID[100000]
TClonesArray * Process
TClonesArray * Region
edm::Service< TFileService > fs

Member Function Documentation

void G4StepStatistics::update ( const DDDWorld )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const DDDWorld * >.

Definition at line 148 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156 {
void G4StepStatistics::update ( const BeginOfJob )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 149 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156 {
void G4StepStatistics::update ( const BeginOfRun )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 150 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156 {
void G4StepStatistics::update ( const BeginOfEvent )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 154 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156 {
void G4StepStatistics::update ( const BeginOfTrack )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 155 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156 {
void G4StepStatistics::update ( const G4Step *  )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 156 of file G4StepStatistics.h.

References gather_cfg::cout, G4StatsMap, StepID::GetParticlePDGID(), StepID::GetProcessName(), StepID::GetRegionName(), and m_verbose.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

156  {
157  std::cout << "++ signal G4Step ";
158  // Dump the relevant information from the G4 step in the object mysteptest
159  StepID mysteptest(iStep);
160  // Add the StepID to the map, or increment if it already exists:
161  if (G4StatsMap.find(mysteptest) == G4StatsMap.end()) {
162  // Allocating new memory for a pointer to associate with the key
163  // mysteptest in our map. Initializing it to 1,will be incremented working
164  // on the value of the pointer.
165  unsigned int *MyValue = new unsigned int(1);
166  // Inserting the new key,value pair
167  G4StatsMap.insert(std::make_pair(mysteptest, MyValue));
168  } else {
169  // Incrementing the value of the pointer by 1
170  *G4StatsMap[mysteptest] = *G4StatsMap[mysteptest] + 1;
171  }
172 
173  // If the verbose flag is set, then dump the information
174  if (m_verbose) {
175  std::cout << " StepID RegionName: " << mysteptest.GetRegionName();
176  std::cout << " StepID ProcessName: " << mysteptest.GetProcessName();
177  std::cout << " StepID ParticlePDGID: " << mysteptest.GetParticlePDGID();
178  }
179  std::cout << std::endl;
180  }
std::map< const StepID, unsigned int * > G4StatsMap
tuple cout
Definition: gather_cfg.py:144
void G4StepStatistics::update ( const EndOfRun )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfRun * >.

Definition at line 182 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

188 {
void G4StepStatistics::update ( const EndOfEvent )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 188 of file G4StepStatistics.h.

References gather_cfg::cout, G4StatsMap, G4StepFreq, G4StepTree, m_verbose, and PDGID.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

188  {
189  std::cout << "++ signal EndOfEvent " << std::endl;
190  Event++;
191 
192  // Dumping the map in the log if verbose is chosen:
193  if (m_verbose) {
194  std::cout << " G4StatsMap size is: " << G4StatsMap.size() << std::endl;
195  }
196  int index(0);
197  for (std::map<const StepID, unsigned int *>::const_iterator step = G4StatsMap.begin(); step != G4StatsMap.end();
198  ++step, ++index) {
199  if (m_verbose) {
200  std::cout << " G4StatsMap step is: " << step->first.GetRegionName() << " " << step->first.GetProcessName()
201  << " " << step->first.GetParticlePDGID(); //<<" "<<step->first.GetTrackID() ;
202  std::cout << " Number of such steps: " << *step->second << std::endl;
203  }
204  // Rolling the map into 5 "arrays", containing the StepID information and
205  // the G4Step statistics
206  PDGID[index] = step->first.GetParticlePDGID();
207  new ((*Region)[index]) TObjString(step->first.GetRegionName());
208  new ((*Process)[index]) TObjString(step->first.GetProcessName());
209  G4StepFreq[index] = *step->second;
210  }
211 
212  G4StepTree->Fill();
213  }
Int_t G4StepFreq[100000]
Int_t PDGID[100000]
std::map< const StepID, unsigned int * > G4StatsMap
tuple cout
Definition: gather_cfg.py:144
step
Definition: StallMonitor.cc:94
void G4StepStatistics::update ( const EndOfTrack )
inlineoverridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 214 of file G4StepStatistics.h.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

216 :
217  bool m_verbose;

Member Data Documentation

unsigned int G4StepStatistics::Event
private

Definition at line 224 of file G4StepStatistics.h.

edm::Service<TFileService> G4StepStatistics::fs
private

Definition at line 222 of file G4StepStatistics.h.

Referenced by G4StepStatistics().

std::map<const StepID, unsigned int *> G4StepStatistics::G4StatsMap
private

Definition at line 221 of file G4StepStatistics.h.

Referenced by update().

Int_t G4StepStatistics::G4StepFreq[100000]
private

Definition at line 228 of file G4StepStatistics.h.

Referenced by G4StepStatistics(), and update().

TTree* G4StepStatistics::G4StepTree
private

Definition at line 223 of file G4StepStatistics.h.

Referenced by G4StepStatistics(), and update().

bool G4StepStatistics::m_verbose
private

Definition at line 217 of file G4StepStatistics.h.

Referenced by update().

Int_t G4StepStatistics::PDGID[100000]
private

Definition at line 225 of file G4StepStatistics.h.

Referenced by G4StepStatistics(), and update().

TClonesArray* G4StepStatistics::Process
private

Definition at line 227 of file G4StepStatistics.h.

Referenced by G4StepStatistics().

TClonesArray* G4StepStatistics::Region
private

Definition at line 226 of file G4StepStatistics.h.

Referenced by G4StepStatistics().