Go to the documentation of this file.00001 #ifndef MaterialAccountingGroup_h
00002 #define MaterialAccountingGroup_h
00003
00004 #include <string>
00005 #include <stdexcept>
00006 #include <utility>
00007
00008 #include "Geometry/CommonDetUnit/interface/GeomDetEnumerators.h"
00009
00010 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingStep.h"
00011 #include "SimDataFormats/ValidationFormats/interface/MaterialAccountingDetector.h"
00012
00013 class TH1;
00014 class TH1F;
00015 class TProfile;
00016 class TFile;
00017
00018 class MaterialAccountingGroup {
00019 private:
00020
00021
00022 class BoundingBox {
00023 public:
00024
00025 BoundingBox(double min_r, double max_r, double min_z, double max_z) :
00026 r_min(min_r),
00027 r_max(max_r),
00028 z_min(min_z),
00029 z_max(max_z)
00030 { }
00031
00032 BoundingBox() :
00033 r_min(0.),
00034 r_max(0.),
00035 z_min(0.),
00036 z_max(0.)
00037 { }
00038
00039 void grow(double r, double z) {
00040 if (r < r_min) r_min = r;
00041 if (r > r_max) r_max = r;
00042 if (z < z_min) z_min = z;
00043 if (z > z_max) z_max = z;
00044 }
00045
00046 void grow(double skin) {
00047 r_min -= skin;
00048 r_max += skin;
00049 z_min -= skin;
00050 z_max += skin;
00051 }
00052
00053 bool inside(double r, double z) const {
00054 return (r >= r_min and r <= r_max and z >= z_min and z <= z_max);
00055 }
00056
00057 std::pair<double, double> range_r() const {
00058 return std::make_pair(r_min, r_max);
00059 }
00060
00061 std::pair<double, double> range_z() const {
00062 return std::make_pair(z_min, z_max);
00063 }
00064
00065 private:
00066 double r_min;
00067 double r_max;
00068 double z_min;
00069 double z_max;
00070 };
00071
00072 public:
00074 MaterialAccountingGroup( const std::string & name, const DDCompactView & geometry );
00075
00077 ~MaterialAccountingGroup( void );
00078
00079 private:
00081 MaterialAccountingGroup(const MaterialAccountingGroup & layer);
00082
00084 MaterialAccountingGroup& operator=( const MaterialAccountingGroup & layer);
00085
00086 public:
00088 bool addDetector( const MaterialAccountingDetector& detector );
00089
00091 void endOfTrack( void );
00092
00094 bool inside( const MaterialAccountingDetector& detector ) const;
00095
00097 MaterialAccountingStep average(void) const
00098 {
00099 return m_tracks ? m_accounting / m_tracks : MaterialAccountingStep();
00100 }
00101
00103 double averageLength(void) const
00104 {
00105 return m_tracks ? m_accounting.length() / m_tracks : 0.;
00106 }
00107
00109 double averageRadiationLengths(void) const
00110 {
00111 return m_tracks ? m_accounting.radiationLengths() / m_tracks : 0.;
00112 }
00113
00115 double averageEnergyLoss(void) const
00116 {
00117 return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.;
00118 }
00119
00121 double sigmaLength(void) const
00122 {
00123 return m_tracks ? std::sqrt(m_errors.length() / m_tracks - averageLength()*averageLength()) : 0.;
00124 }
00125
00127 double sigmaRadiationLengths(void) const
00128 {
00129 return m_tracks ? std::sqrt(m_errors.radiationLengths() / m_tracks - averageRadiationLengths()*averageRadiationLengths()) : 0.;
00130 }
00131
00133 double sigmaEnergyLoss(void) const
00134 {
00135 return m_tracks ? std::sqrt(m_errors.energyLoss() / m_tracks - averageEnergyLoss()*averageEnergyLoss()) : 0.;
00136 }
00137
00139 unsigned int tracks(void) const
00140 {
00141 return m_tracks;
00142 }
00143
00145 const std::string & name(void) const
00146 {
00147 return m_name;
00148 }
00149
00151 std::string info(void) const;
00152
00154 void savePlots(void);
00155
00156 private:
00157 void savePlot(TH1F * plot, const std::string & name);
00158 void savePlot(TProfile * plot, float average, const std::string & name);
00159
00160 std::string m_name;
00161 std::vector<GlobalPoint> m_elements;
00162 BoundingBox m_boundingbox;
00163 MaterialAccountingStep m_accounting;
00164 MaterialAccountingStep m_errors;
00165 unsigned int m_tracks;
00166 bool m_counted;
00167 MaterialAccountingStep m_buffer;
00168
00169
00170 TH1F * m_dedx_spectrum;
00171 TH1F * m_radlen_spectrum;
00172
00173 TProfile * m_dedx_vs_eta;
00174 TProfile * m_dedx_vs_z;
00175 TProfile * m_dedx_vs_r;
00176 TProfile * m_radlen_vs_eta;
00177 TProfile * m_radlen_vs_z;
00178 TProfile * m_radlen_vs_r;
00179
00180
00181 mutable TFile * m_file;
00182
00183
00184 static double s_tolerance;
00185 };
00186
00187 #endif // MaterialAccountingGroup_h