CMS 3D CMS Logo

MaterialAccountingStep.h
Go to the documentation of this file.
1 #ifndef MaterialAccountingStep_h
2 #define MaterialAccountingStep_h
3 
4 #include <utility>
6 
7 // struct to keep material accounting informations on a per-step basis
8 // TODO split segment info (in, out) into separate child class
10 public:
12 
13  MaterialAccountingStep(double position, double radlen, double loss, const GlobalPoint& in, const GlobalPoint& out)
15 
16  void clear(void) {
17  m_length = 0.;
18  m_radiationLengths = 0.;
19  m_energyLoss = 0.;
20  m_in = GlobalPoint();
21  m_out = GlobalPoint();
22  }
23 
24 private:
25  double m_length;
27  double m_energyLoss;
30 
31 public:
32  double length(void) const { return m_length; }
33 
34  double radiationLengths(void) const { return m_radiationLengths; }
35 
36  double energyLoss(void) const { return m_energyLoss; }
37 
38  const GlobalPoint& in(void) const { return m_in; }
39 
40  const GlobalPoint& out(void) const { return m_out; }
41 
43  std::pair<MaterialAccountingStep, MaterialAccountingStep> split(double fraction) const {
44  // no check is done to ensure that 0 <= f <= 1 !
45  GlobalPoint limit(m_in.x() * fraction + m_out.x() * (1. - fraction),
46  m_in.y() * fraction + m_out.y() * (1. - fraction),
47  m_in.z() * fraction + m_out.z() * (1. - fraction));
48 
51 
54  return std::make_pair(part1, part2);
55  }
56 
59  m_length += step.m_length;
60  m_radiationLengths += step.m_radiationLengths;
61  m_energyLoss += step.m_energyLoss;
62 
63  // assume that perp2 is 0 only for uninitialized steps
64  if ((m_in.perp2() == 0.0) or (step.m_in.perp2() < m_in.perp2()))
65  m_in = step.m_in;
66 
67  if ((m_out.perp2() == 0.0) or (step.m_out.perp2() > m_out.perp2()))
68  m_out = step.m_out;
69 
70  return *this;
71  }
72 
75  m_length -= step.m_length;
76  m_radiationLengths -= step.m_radiationLengths;
77  m_energyLoss -= step.m_energyLoss;
78 
79  // can anything more sensible be done for m_in and/or m_out ?
80  if ((step.m_in.perp2() <= m_in.perp2()) and (step.m_out.perp2() >= m_in.perp2()))
81  m_in = step.m_out;
82 
83  if ((step.m_out.perp2() >= m_out.perp2()) and (step.m_in.perp2() <= m_out.perp2()))
84  m_out = step.m_in;
85 
86  return *this;
87  }
88 
91  m_length *= step.m_length;
92  m_radiationLengths *= step.m_radiationLengths;
93  m_energyLoss *= step.m_energyLoss;
94  return *this;
95  }
96 
99  m_length *= x;
101  m_energyLoss *= x;
102  return *this;
103  }
104 
107  m_length /= x;
109  m_energyLoss /= x;
110  return *this;
111  }
112 };
113 
116  step += y;
117  return step;
118 }
119 
122  step -= y;
123  return step;
124 }
125 
128  step *= y;
129  return step;
130 }
131 
134  step *= y;
135  return step;
136 }
137 
140  step *= y;
141  return step;
142 }
143 
146  step /= y;
147  return step;
148 }
149 
150 #endif // MaterialAccountingStep_h
MaterialAccountingStep operator*(const MaterialAccountingStep &x, const MaterialAccountingStep &y)
T z() const
Definition: PV3DBase.h:61
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
MaterialAccountingStep & operator*=(const MaterialAccountingStep &step)
multiply two steps, usefull to implement (co)variance
MaterialAccountingStep & operator*=(double x)
multiply by a scalar
const GlobalPoint & in(void) const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
MaterialAccountingStep & operator+=(const MaterialAccountingStep &step)
add a step
std::pair< MaterialAccountingStep, MaterialAccountingStep > split(double fraction) const
split the step (0..1) in (0..f) + (f..1) using linear interpolation
MaterialAccountingStep & operator/=(double x)
divide by a scalar
MaterialAccountingStep operator/(const MaterialAccountingStep &x, double y)
T perp2() const
Definition: PV3DBase.h:68
MaterialAccountingStep operator-(const MaterialAccountingStep &x, const MaterialAccountingStep &y)
const GlobalPoint & out(void) const
MaterialAccountingStep & operator-=(const MaterialAccountingStep &step)
subtract a step
static int position[264][3]
Definition: ReadPGInfo.cc:289
MaterialAccountingStep(double position, double radlen, double loss, const GlobalPoint &in, const GlobalPoint &out)
float x
double radiationLengths(void) const
step
Definition: StallMonitor.cc:83
double energyLoss(void) const
MaterialAccountingStep operator+(const MaterialAccountingStep &x, const MaterialAccountingStep &y)