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
MaterialAccountingTrack::enterDetector
void enterDetector(const G4VPhysicalVolume *volume, const GlobalPoint &position, double cosTheta)
Definition: MaterialAccountingTrack.cc:7
MaterialAccountingTrack::m_steps
std::vector< MaterialAccountingStep > m_steps
Definition: MaterialAccountingTrack.h:55
MaterialAccountingStep.h
step
step
Definition: StallMonitor.cc:94
MaterialAccountingTrack::kSteps
Definition: MaterialAccountingTrack.h:14
MaterialAccountingTrack::m_detectors
std::vector< MaterialAccountingDetector > m_detectors
Definition: MaterialAccountingTrack.h:56
MaterialAccountingTrack::step
void step(const MaterialAccountingStep &step)
Definition: MaterialAccountingTrack.h:33
MaterialAccountingTrack::leaveDetector
void leaveDetector(const G4VPhysicalVolume *volume, double cosTheta)
Definition: MaterialAccountingTrack.cc:28
MaterialAccountingDetector
Definition: MaterialAccountingDetector.h:15
MaterialAccountingTrack::MaterialAccountingTrack
MaterialAccountingTrack(void)
Definition: MaterialAccountingTrack.h:17
MaterialAccountingTrack::detectors
const std::vector< MaterialAccountingDetector > & detectors() const
Definition: MaterialAccountingTrack.h:43
MaterialAccountingTrack::summary
const MaterialAccountingStep & summary() const
Definition: MaterialAccountingTrack.h:41
Point3DBase< float, GlobalTag >
MaterialAccountingTrack::m_detector
MaterialAccountingDetector m_detector
Definition: MaterialAccountingTrack.h:54
MaterialAccountingTrack::detectors
std::vector< MaterialAccountingDetector > & detectors()
Definition: MaterialAccountingTrack.h:45
MaterialAccountingTrack::m_total
MaterialAccountingStep m_total
Definition: MaterialAccountingTrack.h:52
MaterialAccountingTrack::steps
std::vector< MaterialAccountingStep > & steps()
Definition: MaterialAccountingTrack.h:49
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
MaterialAccountingTrack
Definition: MaterialAccountingTrack.h:11
MaterialAccountingDetector::clear
void clear(void)
Definition: MaterialAccountingDetector.h:24
MaterialAccountingStep
Definition: MaterialAccountingStep.h:9
MaterialAccountingDetector.h
MaterialAccountingTrack::kDetectors
Definition: MaterialAccountingTrack.h:14
MaterialAccountingTrack::m_current_volume
const G4VPhysicalVolume * m_current_volume
Definition: MaterialAccountingTrack.h:53
GlobalPoint.h
MaterialAccountingStep::clear
void clear(void)
Definition: MaterialAccountingStep.h:16
MaterialAccountingTrack::reset
void reset(void)
Definition: MaterialAccountingTrack.h:22
MaterialAccountingTrack::steps
const std::vector< MaterialAccountingStep > & steps() const
Definition: MaterialAccountingTrack.h:47