CMS 3D CMS Logo

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 class DDCompactView;
18 
20 private:
21 
22  // quick implementation of a bounding cilinder
23  class BoundingBox {
24  public:
25 
26  BoundingBox(double min_r, double max_r, double min_z, double max_z) :
27  r_min(min_r),
28  r_max(max_r),
29  z_min(min_z),
30  z_max(max_z)
31  { }
32 
34  r_min(0.),
35  r_max(0.),
36  z_min(0.),
37  z_max(0.)
38  { }
39 
40  void grow(double r, double z) {
41  if (r < r_min) r_min = r;
42  if (r > r_max) r_max = r;
43  if (z < z_min) z_min = z;
44  if (z > z_max) z_max = z;
45  }
46 
47  void grow(double skin) {
48  r_min -= skin; // yes, we allow r_min to go negative
49  r_max += skin;
50  z_min -= skin;
51  z_max += skin;
52  }
53 
54  bool inside(double r, double z) const {
55  return (r >= r_min and r <= r_max and z >= z_min and z <= z_max);
56  }
57 
58  std::pair<double, double> range_r() const {
59  return std::make_pair(r_min, r_max);
60  }
61 
62  std::pair<double, double> range_z() const {
63  return std::make_pair(z_min, z_max);
64  }
65 
66  private:
67  double r_min;
68  double r_max;
69  double z_min;
70  double z_max;
71  };
72 
73 public:
76 
79 
80 private:
82  MaterialAccountingGroup(const MaterialAccountingGroup & layer) = delete;
83 
86 
87 public:
90 
92  void endOfTrack( void );
93 
95  bool inside( const MaterialAccountingDetector& detector ) const;
96 
98  std::pair<double, double> getBoundingR() const {return m_boundingbox.range_r();};
99 
101  std::pair<double, double> getBoundingZ() const {return m_boundingbox.range_z();};
102 
105  {
107  }
108 
110  double averageLength(void) const
111  {
112  return m_tracks ? m_accounting.length() / m_tracks : 0.;
113  }
114 
116  double averageRadiationLengths(void) const
117  {
119  }
120 
122  double averageEnergyLoss(void) const
123  {
124  return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.;
125  }
126 
128  double sigmaLength(void) const
129  {
131  }
132 
134  double sigmaRadiationLengths(void) const
135  {
137  }
138 
140  double sigmaEnergyLoss(void) const
141  {
143  }
144 
146  unsigned int tracks(void) const
147  {
148  return m_tracks;
149  }
150 
152  const std::string & name(void) const
153  {
154  return m_name;
155  }
156 
158  std::string info(void) const;
159 
161  void savePlots(void);
162 
163  // get directly the internal vector of global points that
164  // correspond, roughly, to the center of each subcomponent of this
165  // group.
166 
167  const std::vector<GlobalPoint> & elements(void) const {
168  return m_elements;
169  }
170 
171 private:
172  void savePlot(TH1F * plot, const std::string & name);
173  void savePlot(TProfile * plot, float average, const std::string & name);
174 
176  std::vector<GlobalPoint> m_elements;
180  unsigned int m_tracks;
181  bool m_counted;
183 
184  // plots of material effects distribution
187  // plots of material effects vs. η / Z / R
188  TProfile * m_dedx_vs_eta;
189  TProfile * m_dedx_vs_z;
190  TProfile * m_dedx_vs_r;
191  TProfile * m_radlen_vs_eta;
192  TProfile * m_radlen_vs_z;
193  TProfile * m_radlen_vs_r;
194 
195  // file to store plots into
196  mutable TFile * m_file;
197 
198  // 100um should be small enough that no elements from different layers/groups are so close
199  static double const s_tolerance;
200 };
201 
202 #endif // MaterialAccountingGroup_h
std::pair< double, double > getBoundingZ() const
Return the bouding limit in Z for the hosted Group.
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 "already hit by this track" 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
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
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:18
MaterialAccountingGroup & operator=(const MaterialAccountingGroup &layer)=delete
stop default assignment operator
const std::vector< GlobalPoint > & elements(void) const
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
std::pair< double, double > getBoundingR() const
Return the bouding limit in R for the hosted Group.
void savePlots(void)
save the plots
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