Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:44

0001 #ifndef MaterialAccountingDetector_h
0002 #define MaterialAccountingDetector_h
0003 
0004 #include <iostream>
0005 #include <sstream>
0006 #include <string>
0007 #include <vector>
0008 #include <cmath>
0009 
0010 // CMSSW
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
0013 
0014 // struct to keep material accounting and geometrical informations on a per-detector basis, along a track
0015 class MaterialAccountingDetector {
0016   friend class MaterialAccountingTrack;
0017   friend class TrackingMaterialAnalyser;
0018   friend class DD4hep_TrackingMaterialAnalyser;
0019 
0020 public:
0021   MaterialAccountingDetector(void)
0022       : m_position(), m_curvilinearIn(0.), m_curvilinearOut(0.), m_cosThetaIn(0.), m_cosThetaOut(0.), m_accounting() {}
0023 
0024   void clear(void) {
0025     m_position = GlobalPoint(), m_curvilinearIn = 0.;
0026     m_curvilinearOut = 0.;
0027     m_cosThetaIn = 0.;
0028     m_cosThetaOut = 0.;
0029     m_accounting.clear();
0030   }
0031 
0032   const GlobalPoint& position() const { return m_position; }
0033 
0034   const MaterialAccountingStep& material() const { return m_accounting; }
0035 
0036   // step holds the length and material infos for a step
0037   // begin and end are the curviliniear coordinates
0038   void account(const MaterialAccountingStep& step, double begin, double end) {
0039     if (end <= m_curvilinearIn)
0040       // step before detector
0041       m_accounting += m_cosThetaIn * step;
0042     else if (begin >= m_curvilinearOut)
0043       // step after detector
0044       m_accounting += m_cosThetaOut * step;
0045     else
0046       // step inside detector
0047       m_accounting += (m_cosThetaIn + m_cosThetaOut) / 2. * step;
0048   }
0049 
0050 private:
0051   GlobalPoint m_position;   // roughly the center of the detector
0052   double m_curvilinearIn;   // beginning of detector coordinate along the track
0053   double m_curvilinearOut;  // end of detector coordinate along the track
0054   double m_cosThetaIn;
0055   double m_cosThetaOut;
0056   MaterialAccountingStep m_accounting;
0057 };
0058 
0059 #endif  // MaterialAccountingDetector_h