CMS 3D CMS Logo

MaterialAccountingTrack.h
Go to the documentation of this file.
1 #ifndef MaterialAccountingTrack_h
2 #define MaterialAccountingTrack_h
3 
4 #include <vector>
6 #include "G4VPhysicalVolume.hh"
9 
10 // keep material accounting informations on a per-track basis
12 private:
13  // this values are optimized to avoid resizing
14  enum { kSteps = 600, kDetectors = 30 };
15 
16 public:
18  m_total(),
20  m_detector(),
21  m_steps(),
22  m_detectors()
23  {
24  m_steps.reserve(kSteps);
25  m_detectors.reserve(kDetectors);
26  }
27 
28  void reset(void) {
29  m_total.clear();
30  m_current_volume = nullptr;
31  m_steps.clear();
32  m_steps.reserve(kSteps);
33  m_steps.push_back( m_total );
34  m_detector.clear();
35  m_detectors.clear();
36  m_detectors.reserve(kDetectors);
37  }
38 
39  void step( const MaterialAccountingStep & step ) {
40  m_total += step;
41  m_steps.push_back( step );
42  }
43 
44  void enterDetector( const G4VPhysicalVolume* volume, const GlobalPoint& position, double cosTheta );
45  void leaveDetector( const G4VPhysicalVolume* volume, double cosTheta );
46 
48  return m_total;
49  }
50 
51  const std::vector<MaterialAccountingDetector> & detectors() const {
52  return m_detectors;
53  }
54 
55  std::vector<MaterialAccountingDetector> & detectors() {
56  return m_detectors;
57  }
58 
59  const std::vector<MaterialAccountingStep> & steps() const {
60  return m_steps;
61  }
62 
63  std::vector<MaterialAccountingStep> & steps() {
64  return m_steps;
65  }
66 
67 private:
68  MaterialAccountingStep m_total; // cache position along track (length and material)
69  const G4VPhysicalVolume * m_current_volume; // keep track of current G4 volume
70  MaterialAccountingDetector m_detector; // keep track of current detector
71  std::vector<MaterialAccountingStep> m_steps;
72  std::vector<MaterialAccountingDetector> m_detectors;
73 };
74 
75 #endif // MaterialAccountingTrack_h
const std::vector< MaterialAccountingDetector > & detectors() const
const G4VPhysicalVolume * m_current_volume
const std::vector< MaterialAccountingStep > & steps() const
std::vector< MaterialAccountingDetector > m_detectors
std::vector< MaterialAccountingStep > m_steps
MaterialAccountingStep m_total
#define nullptr
void step(const MaterialAccountingStep &step)
std::vector< MaterialAccountingDetector > & detectors()
MaterialAccountingDetector m_detector
std::vector< MaterialAccountingStep > & steps()
void enterDetector(const G4VPhysicalVolume *volume, const GlobalPoint &position, double cosTheta)
static int position[264][3]
Definition: ReadPGInfo.cc:509
step
const MaterialAccountingStep & summary() const
void leaveDetector(const G4VPhysicalVolume *volume, double cosTheta)