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 
69 
72 
73 public:
76 
78  void endOfTrack(void);
79 
81  bool inside(const MaterialAccountingDetector& detector) const;
82 
84  std::pair<double, double> getBoundingR() const { return m_boundingbox.range_r(); };
85 
87  std::pair<double, double> getBoundingZ() const { return m_boundingbox.range_z(); };
88 
91 
93  double averageLength(void) const { return m_tracks ? m_accounting.length() / m_tracks : 0.; }
94 
96  double averageRadiationLengths(void) const { return m_tracks ? m_accounting.radiationLengths() / m_tracks : 0.; }
97 
99  double averageEnergyLoss(void) const { return m_tracks ? m_accounting.energyLoss() / m_tracks : 0.; }
100 
102  double sigmaLength(void) const {
104  }
105 
107  double sigmaRadiationLengths(void) const {
110  : 0.;
111  }
112 
114  double sigmaEnergyLoss(void) const {
116  }
117 
119  unsigned int tracks(void) const { return m_tracks; }
120 
122  const std::string& name(void) const { return m_name; }
123 
125  std::string info(void) const;
126 
128  void savePlots(void);
129 
130  // get directly the internal vector of global points that
131  // correspond, roughly, to the center of each subcomponent of this
132  // group.
133 
134  const std::vector<GlobalPoint>& elements(void) const { return m_elements; }
135 
136 private:
137  void savePlot(TH1F* plot, const std::string& name);
138  void savePlot(TProfile* plot, float average, const std::string& name);
139 
141  std::vector<GlobalPoint> m_elements;
145  unsigned int m_tracks;
146  bool m_counted;
148 
149  // plots of material effects distribution
152  // plots of material effects vs. η / Z / R
153  TProfile* m_dedx_vs_eta;
154  TProfile* m_dedx_vs_z;
155  TProfile* m_dedx_vs_r;
156  TProfile* m_radlen_vs_eta;
157  TProfile* m_radlen_vs_z;
158  TProfile* m_radlen_vs_r;
159 
160  // file to store plots into
161  mutable TFile* m_file;
162 
163  // 100um should be small enough that no elements from different layers/groups are so close
164  static double const s_tolerance;
165 };
166 
167 #endif // MaterialAccountingGroup_h
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
bool inside(const MaterialAccountingDetector &detector) const
check if detector is inside any part of this layer
BoundingBox(double min_r, double max_r, double min_z, double max_z)
MaterialAccountingGroup(const std::string &name, const DDCompactView &geometry)
explicit constructors
void endOfTrack(void)
commit the buffer and reset the "already hit by this track" flag
double averageLength(void) const
return the average normalized layer thickness
MaterialAccountingStep m_errors
MaterialAccountingStep m_buffer
std::vector< GlobalPoint > m_elements
const std::vector< GlobalPoint > & elements(void) const
std::pair< double, double > getBoundingR() const
Return the bouding limit in R for the hosted Group.
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
double sigmaRadiationLengths(void) const
return the sigma of the normalized number of radiation lengths
double sigmaEnergyLoss(void) const
return the sigma of the normalized energy loss density factor for Bethe-Bloch
std::pair< double, double > range_r() const
unsigned int tracks(void) const
return the number of tracks that hit this layer
void savePlot(TH1F *plot, const std::string &name)
T sqrt(T t)
Definition: SSEVec.h:19
std::string info(void) const
get some infos
bool inside(double r, double z) const
MaterialAccountingGroup & operator=(const MaterialAccountingGroup &layer)=delete
stop default assignment operator
std::pair< double, double > range_z() const
double sigmaLength(void) const
return the sigma of the normalized layer thickness
void savePlots(void)
save the plots
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
std::pair< double, double > getBoundingZ() const
Return the bouding limit in Z for the hosted Group.
bool addDetector(const MaterialAccountingDetector &detector)
buffer material from a detector, if the detector is inside the DetLayer bounds
~MaterialAccountingGroup(void)
destructor
double radiationLengths(void) const
MaterialAccountingStep m_accounting
const std::string & name(void) const
get the layer name
double energyLoss(void) const
MaterialAccountingStep average(void) const
return the average normalized material accounting informations