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:
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
MaterialAccountingGroup::m_buffer
MaterialAccountingStep m_buffer
Definition: MaterialAccountingGroup.h:148
MaterialAccountingGroup::name
const std::string & name(void) const
get the layer name
Definition: MaterialAccountingGroup.h:123
MaterialAccountingGroup::BoundingBox::z_max
double z_max
Definition: MaterialAccountingGroup.h:57
MaterialAccountingGroup::m_dedx_vs_z
TProfile * m_dedx_vs_z
Definition: MaterialAccountingGroup.h:155
MaterialAccountingGroup::sigmaEnergyLoss
double sigmaEnergyLoss(void) const
return the sigma of the normalized energy loss density factor for Bethe-Bloch
Definition: MaterialAccountingGroup.h:115
MaterialAccountingStep.h
MaterialAccountingGroup::m_tracks
unsigned int m_tracks
Definition: MaterialAccountingGroup.h:146
MaterialAccountingGroup::m_radlen_vs_r
TProfile * m_radlen_vs_r
Definition: MaterialAccountingGroup.h:159
MaterialAccountingGroup::m_accounting
MaterialAccountingStep m_accounting
Definition: MaterialAccountingGroup.h:144
geometry
Definition: geometry.py:1
MaterialAccountingGroup::averageRadiationLengths
double averageRadiationLengths(void) const
return the average normalized number of radiation lengths
Definition: MaterialAccountingGroup.h:97
MaterialAccountingGroup::s_tolerance
static const double s_tolerance
Definition: MaterialAccountingGroup.h:165
MaterialAccountingGroup::BoundingBox::grow
void grow(double skin)
Definition: MaterialAccountingGroup.h:40
MaterialAccountingGroup::sigmaRadiationLengths
double sigmaRadiationLengths(void) const
return the sigma of the normalized number of radiation lengths
Definition: MaterialAccountingGroup.h:108
MaterialAccountingGroup::operator=
MaterialAccountingGroup & operator=(const MaterialAccountingGroup &layer)=delete
stop default assignment operator
MaterialAccountingGroup::BoundingBox::r_max
double r_max
Definition: MaterialAccountingGroup.h:55
MaterialAccountingGroup::m_errors
MaterialAccountingStep m_errors
Definition: MaterialAccountingGroup.h:145
plotFactory.plot
plot
Definition: plotFactory.py:109
MaterialAccountingGroup::elements
const std::vector< GlobalPoint > & elements(void) const
Definition: MaterialAccountingGroup.h:135
MaterialAccountingGroup::average
MaterialAccountingStep average(void) const
return the average normalized material accounting informations
Definition: MaterialAccountingGroup.h:91
MaterialAccountingGroup::BoundingBox::BoundingBox
BoundingBox()
Definition: MaterialAccountingGroup.h:27
MaterialAccountingGroup::m_file
TFile * m_file
Definition: MaterialAccountingGroup.h:162
MaterialAccountingGroup::inside
bool inside(const MaterialAccountingDetector &detector) const
check if detector is inside any part of this layer
Definition: MaterialAccountingGroup.cc:103
MaterialAccountingGroup::BoundingBox::r_min
double r_min
Definition: MaterialAccountingGroup.h:54
MaterialAccountingDetector
Definition: MaterialAccountingDetector.h:15
MaterialAccountingGroup::m_boundingbox
BoundingBox m_boundingbox
Definition: MaterialAccountingGroup.h:143
MaterialAccountingGroup::savePlot
void savePlot(TH1F *plot, const std::string &name)
Definition: MaterialAccountingGroup.cc:167
MaterialAccountingGroup::endOfTrack
void endOfTrack(void)
commit the buffer and reset the "already hit by this track" flag
Definition: MaterialAccountingGroup.cc:144
MaterialAccountingGroup::BoundingBox::BoundingBox
BoundingBox(double min_r, double max_r, double min_z, double max_z)
Definition: MaterialAccountingGroup.h:24
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
MaterialAccountingGroup::BoundingBox::range_z
std::pair< double, double > range_z() const
Definition: MaterialAccountingGroup.h:51
DDAxes::z
MaterialAccountingGroup::BoundingBox::range_r
std::pair< double, double > range_r() const
Definition: MaterialAccountingGroup.h:49
MaterialAccountingGroup::BoundingBox::grow
void grow(double r, double z)
Definition: MaterialAccountingGroup.h:29
MaterialAccountingGroup::BoundingBox::z_min
double z_min
Definition: MaterialAccountingGroup.h:56
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MaterialAccountingGroup::m_radlen_vs_z
TProfile * m_radlen_vs_z
Definition: MaterialAccountingGroup.h:158
MaterialAccountingGroup::getBoundingR
std::pair< double, double > getBoundingR() const
Return the bouding limit in R for the hosted Group.
Definition: MaterialAccountingGroup.h:85
MaterialAccountingGroup::m_elements
std::vector< GlobalPoint > m_elements
Definition: MaterialAccountingGroup.h:142
MaterialAccountingGroup::addDetector
bool addDetector(const MaterialAccountingDetector &detector)
buffer material from a detector, if the detector is inside the DetLayer bounds
Definition: MaterialAccountingGroup.cc:132
MaterialAccountingGroup::m_radlen_vs_eta
TProfile * m_radlen_vs_eta
Definition: MaterialAccountingGroup.h:157
MaterialAccountingGroup::~MaterialAccountingGroup
~MaterialAccountingGroup(void)
destructor
Definition: MaterialAccountingGroup.cc:88
MaterialAccountingGroup
Definition: MaterialAccountingGroup.h:19
MaterialAccountingGroup::averageEnergyLoss
double averageEnergyLoss(void) const
return the average normalized energy loss density factor for Bethe-Bloch
Definition: MaterialAccountingGroup.h:100
MaterialAccountingGroup::info
std::string info(void) const
get some infos
Definition: MaterialAccountingGroup.cc:208
average
Definition: average.py:1
MaterialAccountingGroup::sigmaLength
double sigmaLength(void) const
return the sigma of the normalized layer thickness
Definition: MaterialAccountingGroup.h:103
MaterialAccountingGroup::tracks
unsigned int tracks(void) const
return the number of tracks that hit this layer
Definition: MaterialAccountingGroup.h:120
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MaterialAccountingStep
Definition: MaterialAccountingStep.h:9
MaterialAccountingStep::energyLoss
double energyLoss(void) const
Definition: MaterialAccountingStep.h:36
MaterialAccountingStep::radiationLengths
double radiationLengths(void) const
Definition: MaterialAccountingStep.h:34
MaterialAccountingStep::length
double length(void) const
Definition: MaterialAccountingStep.h:32
MaterialAccountingGroup::MaterialAccountingGroup
MaterialAccountingGroup(const std::string &name, const DDCompactView &geometry)
explicit constructors
Definition: MaterialAccountingGroup.cc:23
MaterialAccountingGroup::BoundingBox
Definition: MaterialAccountingGroup.h:22
MaterialAccountingGroup::savePlots
void savePlots(void)
save the plots
Definition: MaterialAccountingGroup.cc:220
MaterialAccountingGroup::m_dedx_vs_r
TProfile * m_dedx_vs_r
Definition: MaterialAccountingGroup.h:156
MaterialAccountingGroup::m_dedx_vs_eta
TProfile * m_dedx_vs_eta
Definition: MaterialAccountingGroup.h:154
GeomDetEnumerators.h
MaterialAccountingGroup::averageLength
double averageLength(void) const
return the average normalized layer thickness
Definition: MaterialAccountingGroup.h:94
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
MaterialAccountingDetector.h
MaterialAccountingGroup::getBoundingZ
std::pair< double, double > getBoundingZ() const
Return the bouding limit in Z for the hosted Group.
Definition: MaterialAccountingGroup.h:88
MaterialAccountingGroup::m_dedx_spectrum
TH1F * m_dedx_spectrum
Definition: MaterialAccountingGroup.h:151
MaterialAccountingGroup::m_radlen_spectrum
TH1F * m_radlen_spectrum
Definition: MaterialAccountingGroup.h:152
MaterialAccountingGroup::m_name
std::string m_name
Definition: MaterialAccountingGroup.h:141
MaterialAccountingGroup::m_counted
bool m_counted
Definition: MaterialAccountingGroup.h:147
MaterialAccountingGroup::BoundingBox::inside
bool inside(double r, double z) const
Definition: MaterialAccountingGroup.h:47