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  // quick implementation of a bounding cilinder
22  class BoundingBox {
23  public:
24  BoundingBox(double min_r, double max_r, double min_z, double max_z)
25  : r_min(min_r), r_max(max_r), z_min(min_z), z_max(max_z) {}
26 
27  BoundingBox() : r_min(0.), r_max(0.), z_min(0.), z_max(0.) {}
28 
29  void grow(double r, double z) {
30  if (r < r_min)
31  r_min = r;
32  if (r > r_max)
33  r_max = r;
34  if (z < z_min)
35  z_min = z;
36  if (z > z_max)
37  z_max = z;
38  }
39 
40  void grow(double skin) {
41  r_min -= skin; // yes, we allow r_min to go negative
42  r_max += skin;
43  z_min -= skin;
44  z_max += skin;
45  }
46 
47  bool inside(double r, double z) const { return (r >= r_min and r <= r_max and z >= z_min and z <= z_max); }
48 
49  std::pair<double, double> range_r() const { return std::make_pair(r_min, r_max); }
50 
51  std::pair<double, double> range_z() const { return std::make_pair(z_min, z_max); }
52 
53  private:
54  double r_min;
55  double r_max;
56  double z_min;
57  double z_max;
58  };
59 
60 public:
63 
66 
67 private:
69  MaterialAccountingGroup(const MaterialAccountingGroup& layer) = delete;
70 
73 
74 public:
77 
79  void endOfTrack(void);
80 
82  bool inside(const MaterialAccountingDetector& detector) const;
83 
85  std::pair<double, double> getBoundingR() const { return m_boundingbox.range_r(); };
86 
88  std::pair<double, double> getBoundingZ() const { return m_boundingbox.range_z(); };
89 
92 
94  double averageLength(void) const { return m_tracks ? m_accounting.length() / m_tracks : 0.; }
95 
97  double averageRadiationLengths(void) const { return m_tracks ? m_accounting.radiationLengths() / m_tracks : 0.; }
98 
100  double averageEnergyLoss(void) const { return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.; }
101 
103  double sigmaLength(void) const {
105  }
106 
108  double sigmaRadiationLengths(void) const {
111  : 0.;
112  }
113 
115  double sigmaEnergyLoss(void) const {
117  }
118 
120  unsigned int tracks(void) const { return m_tracks; }
121 
123  const std::string& name(void) const { return m_name; }
124 
126  std::string info(void) const;
127 
129  void savePlots(void);
130 
131  // get directly the internal vector of global points that
132  // correspond, roughly, to the center of each subcomponent of this
133  // group.
134 
135  const std::vector<GlobalPoint>& elements(void) const { return m_elements; }
136 
137 private:
138  void savePlot(TH1F* plot, const std::string& name);
139  void savePlot(TProfile* plot, float average, const std::string& name);
140 
142  std::vector<GlobalPoint> m_elements;
146  unsigned int m_tracks;
147  bool m_counted;
149 
150  // plots of material effects distribution
153  // plots of material effects vs. η / Z / R
154  TProfile* m_dedx_vs_eta;
155  TProfile* m_dedx_vs_z;
156  TProfile* m_dedx_vs_r;
157  TProfile* m_radlen_vs_eta;
158  TProfile* m_radlen_vs_z;
159  TProfile* m_radlen_vs_r;
160 
161  // file to store plots into
162  mutable TFile* m_file;
163 
164  // 100um should be small enough that no elements from different layers/groups are so close
165  static double const s_tolerance;
166 };
167 
168 #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