CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MaterialAccountingGroup.h
Go to the documentation of this file.
1 #ifndef MaterialAccountingGroup_h
2 #define MaterialAccountingGroup_h
3 
4 #include <string>
5 #include <stdexcept>
6 #include <utility>
7 
9 
12 
13 class TH1;
14 class TH1F;
15 class TProfile;
16 class TFile;
17 
19 private:
20 
21  // quick implementation of a bounding cilinder
22  class BoundingBox {
23  public:
24 
25  BoundingBox(double min_r, double max_r, double min_z, double max_z) :
26  r_min(min_r),
27  r_max(max_r),
28  z_min(min_z),
29  z_max(max_z)
30  { }
31 
33  r_min(0.),
34  r_max(0.),
35  z_min(0.),
36  z_max(0.)
37  { }
38 
39  void grow(double r, double z) {
40  if (r < r_min) r_min = r;
41  if (r > r_max) r_max = r;
42  if (z < z_min) z_min = z;
43  if (z > z_max) z_max = z;
44  }
45 
46  void grow(double skin) {
47  r_min -= skin; // yes, we allow r_min to go negative
48  r_max += skin;
49  z_min -= skin;
50  z_max += skin;
51  }
52 
53  bool inside(double r, double z) const {
54  return (r >= r_min and r <= r_max and z >= z_min and z <= z_max);
55  }
56 
57  std::pair<double, double> range_r() const {
58  return std::make_pair(r_min, r_max);
59  }
60 
61  std::pair<double, double> range_z() const {
62  return std::make_pair(z_min, z_max);
63  }
64 
65  private:
66  double r_min;
67  double r_max;
68  double z_min;
69  double z_max;
70  };
71 
72 public:
74  MaterialAccountingGroup( const std::string & name, const DDCompactView & geometry );
75 
78 
79 private:
82 
85 
86 public:
88  bool addDetector( const MaterialAccountingDetector& detector );
89 
91  void endOfTrack( void );
92 
94  bool inside( const MaterialAccountingDetector& detector ) const;
95 
98  {
100  }
101 
103  double averageLength(void) const
104  {
105  return m_tracks ? m_accounting.length() / m_tracks : 0.;
106  }
107 
109  double averageRadiationLengths(void) const
110  {
112  }
113 
115  double averageEnergyLoss(void) const
116  {
117  return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.;
118  }
119 
121  double sigmaLength(void) const
122  {
124  }
125 
127  double sigmaRadiationLengths(void) const
128  {
130  }
131 
133  double sigmaEnergyLoss(void) const
134  {
136  }
137 
139  unsigned int tracks(void) const
140  {
141  return m_tracks;
142  }
143 
145  const std::string & name(void) const
146  {
147  return m_name;
148  }
149 
151  std::string info(void) const;
152 
154  void savePlots(void);
155 
156 private:
157  void savePlot(TH1F * plot, const std::string & name);
158  void savePlot(TProfile * plot, float average, const std::string & name);
159 
160  std::string m_name;
161  std::vector<GlobalPoint> m_elements;
165  unsigned int m_tracks;
166  bool m_counted;
168 
169  // plots of material effects distribution
172  // plots of material effects vs. η / Z / R
173  TProfile * m_dedx_vs_eta;
174  TProfile * m_dedx_vs_z;
175  TProfile * m_dedx_vs_r;
176  TProfile * m_radlen_vs_eta;
177  TProfile * m_radlen_vs_z;
178  TProfile * m_radlen_vs_r;
179 
180  // file to store plots into
181  mutable TFile * m_file;
182 
183  // 100um should be small enough that no elements from different layers/groups are so close
184  static double s_tolerance;
185 };
186 
187 #endif // MaterialAccountingGroup_h
BoundingBox(double min_r, double max_r, double min_z, double max_z)
MaterialAccountingGroup(const std::string &name, const DDCompactView &geometry)
explicit constructors
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
void endOfTrack(void)
commit the buffer and reset the &quot;already hit by this track&quot; flag
MaterialAccountingStep m_errors
MaterialAccountingStep m_buffer
double sigmaLength(void) const
return the sigma of the normalized layer thickness
double sigmaRadiationLengths(void) const
return the sigma of the normalized number of radiation lengths
std::vector< GlobalPoint > m_elements
double length(void) const
double sigmaEnergyLoss(void) const
return the sigma of the normalized energy loss density factor for Bethe-Bloch
double radiationLengths(void) const
std::pair< double, double > range_r() const
std::string info(void) const
get some infos
double energyLoss(void) const
type of data representation of DDCompactView
Definition: DDCompactView.h:77
double double double z
unsigned int tracks(void) const
return the number of tracks that hit this layer
double averageLength(void) const
return the average normalized layer thickness
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
void savePlot(TH1F *plot, const std::string &name)
T sqrt(T t)
Definition: SSEVec.h:46
MaterialAccountingStep average(void) const
return the average normalized material accounting informations
std::pair< double, double > range_z() const
const std::string & name(void) const
get the layer name
MaterialAccountingGroup & operator=(const MaterialAccountingGroup &layer)
stop default assignment operator
void savePlots(void)
save the plots
ESHandle< TrackerGeometry > geometry
bool inside(double r, double z) const
bool addDetector(const MaterialAccountingDetector &detector)
buffer material from a detector, if the detector is inside the DetLayer bounds
~MaterialAccountingGroup(void)
destructor
MaterialAccountingStep m_accounting
bool inside(const MaterialAccountingDetector &detector) const
check if detector is inside any part of this layer