CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/SimDataFormats/ValidationFormats/interface/MaterialAccountingDetector.h

Go to the documentation of this file.
00001 #ifndef MaterialAccountingDetector_h
00002 #define MaterialAccountingDetector_h
00003 
00004 #include <iostream>
00005 #include <sstream>
00006 #include <string>
00007 #include <vector>
00008 #include <cmath>
00009 
00010 // CMSSW
00011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00012 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
00013 
00014 // struct to keep material accounting and geometrical informations on a per-detector basis, along a track
00015 class MaterialAccountingDetector {
00016   friend class MaterialAccountingTrack;
00017   friend class TrackingMaterialAnalyser;
00018 
00019 public:
00020   MaterialAccountingDetector( void ) :
00021     m_position         (),
00022     m_curvilinearIn    ( 0. ),
00023     m_curvilinearOut   ( 0. ),
00024     m_cosThetaIn       ( 0. ),
00025     m_cosThetaOut      ( 0. ),
00026     m_accounting       ()
00027   { }
00028   
00029   void clear( void ) {
00030     m_position         = GlobalPoint(),
00031     m_curvilinearIn    = 0.;
00032     m_curvilinearOut   = 0.;
00033     m_cosThetaIn       = 0.;
00034     m_cosThetaOut      = 0.;
00035     m_accounting.clear();
00036   }
00037 
00038   const GlobalPoint & position() const {
00039     return m_position;
00040   }
00041 
00042   const MaterialAccountingStep & material() const {
00043     return m_accounting;
00044   }
00045 
00046   // step holds the length and material infos for a step
00047   // begin and end are the curviliniear coordinates
00048   void account( const MaterialAccountingStep & step, double begin, double end )
00049   {
00050     if (end <= m_curvilinearIn)
00051       // step before detector
00052       m_accounting += m_cosThetaIn * step;
00053     else if (begin >= m_curvilinearOut)
00054       // step after detector
00055        m_accounting += m_cosThetaOut * step;
00056     else
00057       // step inside detector
00058       m_accounting += (m_cosThetaIn + m_cosThetaOut ) / 2. * step;
00059   }
00060   
00061 private:  
00062   GlobalPoint m_position;                       // roughly the center of the detector
00063   double m_curvilinearIn;                       // beginning of detector coordinate along the track 
00064   double m_curvilinearOut;                      // end of detector coordinate along the track 
00065   double m_cosThetaIn;
00066   double m_cosThetaOut;
00067   MaterialAccountingStep m_accounting;
00068 };
00069 
00070 #endif // MaterialAccountingDetector_h