Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:03:51

0001 #ifndef MaterialAccountingTrack_h
0002 #define MaterialAccountingTrack_h
0003 
0004 #include <vector>
0005 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0006 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
0007 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingDetector.h"
0008 
0009 // keep material accounting informations on a per-track basis
0010 class MaterialAccountingTrack {
0011 private:
0012   // this values are optimized to avoid resizing
0013   enum { kSteps = 600, kDetectors = 30 };
0014 
0015 public:
0016   MaterialAccountingTrack(void) : m_total(), m_detector(), m_steps(), m_detectors() {
0017     m_steps.reserve(kSteps);
0018     m_detectors.reserve(kDetectors);
0019   }
0020 
0021   void reset(void) {
0022     m_total.clear();
0023     m_steps.clear();
0024     m_steps.reserve(kSteps);
0025     m_steps.push_back(m_total);
0026     m_detector.clear();
0027     m_detectors.clear();
0028     m_detectors.reserve(kDetectors);
0029   }
0030 
0031   void step(const MaterialAccountingStep& step) {
0032     m_total += step;
0033     m_steps.push_back(step);
0034   }
0035 
0036   void enterDetector(const GlobalPoint& position, double cosTheta);
0037   void leaveDetector(double cosTheta);
0038 
0039   const MaterialAccountingStep& summary() const { return m_total; }
0040 
0041   const std::vector<MaterialAccountingDetector>& detectors() const { return m_detectors; }
0042 
0043   std::vector<MaterialAccountingDetector>& detectors() { return m_detectors; }
0044 
0045   const std::vector<MaterialAccountingStep>& steps() const { return m_steps; }
0046 
0047   std::vector<MaterialAccountingStep>& steps() { return m_steps; }
0048 
0049 private:
0050   MaterialAccountingStep m_total;         // cache position along track (length and material)
0051   MaterialAccountingDetector m_detector;  // keep track of current detector
0052   std::vector<MaterialAccountingStep> m_steps;
0053   std::vector<MaterialAccountingDetector> m_detectors;
0054 };
0055 
0056 #endif  // MaterialAccountingTrack_h