CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/SimDataFormats/ValidationFormats/interface/MaterialAccountingTrack.h

Go to the documentation of this file.
00001 #ifndef MaterialAccountingTrack_h
00002 #define MaterialAccountingTrack_h
00003 
00004 #include <vector>
00005 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00006 #include "G4VPhysicalVolume.hh"
00007 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
00008 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingDetector.h"
00009 
00010 // keep material accounting informations on a per-track basis
00011 class MaterialAccountingTrack {
00012 private:
00013   // this values are optimized to avoid resizing
00014   enum { kSteps = 600, kDetectors = 30 };
00015   
00016 public:
00017   MaterialAccountingTrack(void) : 
00018     m_total(),
00019     m_current_volume(0),
00020     m_detector(),
00021     m_steps(), 
00022     m_detectors()
00023   {
00024     m_steps.reserve(kSteps);
00025     m_detectors.reserve(kDetectors);
00026   }
00027 
00028   void reset(void) {
00029     m_total.clear();
00030     m_current_volume = 0;
00031     m_steps.clear();
00032     m_steps.reserve(kSteps);
00033     m_steps.push_back( m_total );
00034     m_detector.clear();
00035     m_detectors.clear();
00036     m_detectors.reserve(kDetectors);
00037   }
00038  
00039   void step( const MaterialAccountingStep & step ) {
00040     m_total += step;
00041     m_steps.push_back( step );
00042   }
00043 
00044   void enterDetector( const G4VPhysicalVolume* volume, const GlobalPoint& position, double cosTheta );
00045   void leaveDetector( const G4VPhysicalVolume* volume, double cosTheta );
00046 
00047   const MaterialAccountingStep& summary( void ) {
00048     return m_total;
00049   }
00050 
00051   const std::vector<MaterialAccountingDetector> & detectors() {
00052     return m_detectors;
00053   }
00054 
00055   const std::vector<MaterialAccountingStep> & steps() {
00056     return m_steps;
00057   }
00058   
00059 public:
00060   MaterialAccountingStep                    m_total;            // cache position along track (length and material)
00061   mutable const G4VPhysicalVolume *         m_current_volume;   // keep track of current G4 volume
00062   mutable MaterialAccountingDetector        m_detector;         // keep track of current detector
00063   std::vector<MaterialAccountingStep>       m_steps;
00064   std::vector<MaterialAccountingDetector>   m_detectors;
00065 };
00066 
00067 #endif // MaterialAccountingTrack_h