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_steps.reserve(kSteps);
19  m_detectors.reserve(kDetectors);
20  }
21 
22  void reset(void) {
23  m_total.clear();
24  m_current_volume = nullptr;
25  m_steps.clear();
26  m_steps.reserve(kSteps);
27  m_steps.push_back(m_total);
28  m_detector.clear();
29  m_detectors.clear();
30  m_detectors.reserve(kDetectors);
31  }
32 
34  m_total += step;
35  m_steps.push_back(step);
36  }
37 
38  void enterDetector(const G4VPhysicalVolume* volume, const GlobalPoint& position, double cosTheta);
39  void leaveDetector(const G4VPhysicalVolume* volume, double cosTheta);
40 
41  const MaterialAccountingStep& summary() const { return m_total; }
42 
43  const std::vector<MaterialAccountingDetector>& detectors() const { return m_detectors; }
44 
45  std::vector<MaterialAccountingDetector>& detectors() { return m_detectors; }
46 
47  const std::vector<MaterialAccountingStep>& steps() const { return m_steps; }
48 
49  std::vector<MaterialAccountingStep>& steps() { return m_steps; }
50 
51 private:
52  MaterialAccountingStep m_total; // cache position along track (length and material)
53  const G4VPhysicalVolume* m_current_volume; // keep track of current G4 volume
54  MaterialAccountingDetector m_detector; // keep track of current detector
55  std::vector<MaterialAccountingStep> m_steps;
56  std::vector<MaterialAccountingDetector> m_detectors;
57 };
58 
59 #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
#define nullptr
MaterialAccountingStep m_total
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
Definition: StallMonitor.cc:94
const MaterialAccountingStep & summary() const
void leaveDetector(const G4VPhysicalVolume *volume, double cosTheta)