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:
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 
97  std::pair<double, double> getBoundingR() const {return m_boundingbox.range_r();};
98 
100  std::pair<double, double> getBoundingZ() const {return m_boundingbox.range_z();};
101 
104  {
106  }
107 
109  double averageLength(void) const
110  {
111  return m_tracks ? m_accounting.length() / m_tracks : 0.;
112  }
113 
115  double averageRadiationLengths(void) const
116  {
118  }
119 
121  double averageEnergyLoss(void) const
122  {
123  return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.;
124  }
125 
127  double sigmaLength(void) const
128  {
130  }
131 
133  double sigmaRadiationLengths(void) const
134  {
136  }
137 
139  double sigmaEnergyLoss(void) const
140  {
142  }
143 
145  unsigned int tracks(void) const
146  {
147  return m_tracks;
148  }
149 
151  const std::string & name(void) const
152  {
153  return m_name;
154  }
155 
157  std::string info(void) const;
158 
160  void savePlots(void);
161 
162  // get directly the internal vector of global points that
163  // correspond, roughly, to the center of each subcomponent of this
164  // group.
165 
166  const std::vector<GlobalPoint> & elements(void) const {
167  return m_elements;
168  }
169 
170 private:
171  void savePlot(TH1F * plot, const std::string & name);
172  void savePlot(TProfile * plot, float average, const std::string & name);
173 
175  std::vector<GlobalPoint> m_elements;
179  unsigned int m_tracks;
180  bool m_counted;
182 
183  // plots of material effects distribution
186  // plots of material effects vs. η / Z / R
187  TProfile * m_dedx_vs_eta;
188  TProfile * m_dedx_vs_z;
189  TProfile * m_dedx_vs_r;
190  TProfile * m_radlen_vs_eta;
191  TProfile * m_radlen_vs_z;
192  TProfile * m_radlen_vs_r;
193 
194  // file to store plots into
195  mutable TFile * m_file;
196 
197  // 100um should be small enough that no elements from different layers/groups are so close
198  static double const s_tolerance;
199 };
200 
201 #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 &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:76
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:48
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
MaterialAccountingGroup & operator=(const MaterialAccountingGroup &layer)
stop default assignment operator
std::pair< double, double > getBoundingR() const
Return the bouding limit in R for the hosted Group.
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