Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:03

0001 #ifndef DD4hep_MaterialAccountingGroup_h
0002 #define DD4hep_MaterialAccountingGroup_h
0003 
0004 #include <string>
0005 #include <stdexcept>
0006 #include <utility>
0007 #include <memory>
0008 
0009 #include "Geometry/CommonDetUnit/interface/GeomDetEnumerators.h"
0010 
0011 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
0012 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingDetector.h"
0013 
0014 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0015 
0016 #include "BoundingBox.h"
0017 
0018 class TH1;
0019 class TH1F;
0020 class TProfile;
0021 class TFile;
0022 
0023 class DD4hep_MaterialAccountingGroup {
0024 public:
0025   DD4hep_MaterialAccountingGroup(const DD4hep_MaterialAccountingGroup& layer) = delete;
0026   DD4hep_MaterialAccountingGroup& operator=(const DD4hep_MaterialAccountingGroup& layer) = delete;
0027 
0028 private:
0029   void savePlot(std::shared_ptr<TH1F>& plot, const std::string& name);
0030   void savePlot(std::shared_ptr<TProfile>& plot, float average, const std::string& name);
0031 
0032   std::string m_name;
0033   std::vector<GlobalPoint> m_elements;
0034   BoundingBox m_boundingbox;
0035   MaterialAccountingStep m_accounting;
0036   MaterialAccountingStep m_errors;
0037   unsigned int m_tracks;
0038   bool m_counted;
0039   MaterialAccountingStep m_buffer;
0040 
0041   std::shared_ptr<TH1F> m_dedx_spectrum;
0042   std::shared_ptr<TH1F> m_radlen_spectrum;
0043   std::shared_ptr<TProfile> m_dedx_vs_eta;
0044   std::shared_ptr<TProfile> m_dedx_vs_z;
0045   std::shared_ptr<TProfile> m_dedx_vs_r;
0046   std::shared_ptr<TProfile> m_radlen_vs_eta;
0047   std::shared_ptr<TProfile> m_radlen_vs_z;
0048   std::shared_ptr<TProfile> m_radlen_vs_r;
0049 
0050   std::unique_ptr<TFile> m_file;
0051 
0052   static constexpr double s_tolerance = 0.01;
0053 
0054 public:
0055   DD4hep_MaterialAccountingGroup(const std::string& name, const cms::DDCompactView& geometry);
0056   ~DD4hep_MaterialAccountingGroup(void);
0057 
0058   bool addDetector(const MaterialAccountingDetector& detector);
0059   void endOfTrack(void);
0060   bool isInside(const MaterialAccountingDetector& detector) const;
0061   std::pair<double, double> getBoundingR() const { return m_boundingbox.range_r(); };
0062   std::pair<double, double> getBoundingZ() const { return m_boundingbox.range_z(); };
0063   MaterialAccountingStep average(void) const;
0064   double averageLength(void) const;
0065   double averageRadiationLengths(void) const;
0066   double averageEnergyLoss(void) const;
0067   double sigmaLength(void) const;
0068   double sigmaRadiationLengths(void) const;
0069   double sigmaEnergyLoss(void) const;
0070   unsigned int tracks(void) const { return m_tracks; }
0071   const std::string& name(void) const { return m_name; }
0072   std::string info(void) const;
0073   void savePlots(void);
0074 
0075   const std::vector<GlobalPoint>& elements(void) const { return m_elements; }
0076 };
0077 
0078 #endif