CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  m_length(0.),
14  m_energyLoss(0.),
15  m_in(),
16  m_out()
17  { }
18 
19  MaterialAccountingStep( double position, double radlen, double loss, const GlobalPoint & in, const GlobalPoint & out ) :
20  m_length( position ),
21  m_radiationLengths( radlen ),
22  m_energyLoss( loss ),
23  m_in( in ),
24  m_out( out )
25  { }
26 
27  void clear( void ) {
28  m_length = 0.;
29  m_radiationLengths = 0.;
30  m_energyLoss = 0.;
31  m_in = GlobalPoint();
32  m_out = GlobalPoint();
33  }
34 
35 private:
36  double m_length;
38  double m_energyLoss;
41 
42 public:
43  double length(void) const {
44  return m_length;
45  }
46 
47  double radiationLengths(void) const {
48  return m_radiationLengths;
49  }
50 
51  double energyLoss(void) const {
52  return m_energyLoss;
53  }
54 
55  const GlobalPoint & in(void) const {
56  return m_in;
57  }
58 
59  const GlobalPoint & out(void) const {
60  return m_out;
61  }
62 
64  std::pair<MaterialAccountingStep, MaterialAccountingStep> split( double fraction ) const {
65  // no check is done to ensure that 0 <= f <= 1 !
67  m_in.x() * fraction + m_out.x() * (1. - fraction),
68  m_in.y() * fraction + m_out.y() * (1. - fraction),
69  m_in.z() * fraction + m_out.z() * (1. - fraction)
70  );
71 
72  MaterialAccountingStep part1( fraction * m_length,
73  fraction * m_radiationLengths,
74  fraction * m_energyLoss,
75  m_in,
76  limit );
77 
78  MaterialAccountingStep part2( (1 - fraction) * m_length,
79  (1 - fraction) * m_radiationLengths,
80  (1 - fraction) * m_energyLoss,
81  limit,
82  m_out );
83  return std::make_pair( part1, part2 );
84  }
85 
88  m_length = step.m_length;
91  m_in = step.m_in;
92  m_out = step.m_out;
93  return *this;
94  }
95 
98  m_length += step.m_length;
100  m_energyLoss += step.m_energyLoss;
101 
102  // assume that perp2 is 0 only for uninitialized steps
103  if ((m_in.perp2() == 0.0) or (step.m_in.perp2() < m_in.perp2()))
104  m_in = step.m_in;
105 
106  if ((m_out.perp2() == 0.0) or (step.m_out.perp2() > m_out.perp2()))
107  m_out = step.m_out;
108 
109  return *this;
110  }
111 
114  m_length -= step.m_length;
116  m_energyLoss -= step.m_energyLoss;
117 
118  // can anything more sensible be done for m_in and/or m_out ?
119  if ((step.m_in.perp2() <= m_in.perp2()) and (step.m_out.perp2() >= m_in.perp2()))
120  m_in = step.m_out;
121 
122  if ((step.m_out.perp2() >= m_out.perp2()) and (step.m_in.perp2() <= m_out.perp2()))
123  m_out = step.m_in;
124 
125  return *this;
126  }
127 
130  m_length *= step.m_length;
132  m_energyLoss *= step.m_energyLoss;
133  return *this;
134  }
135 
138  m_length *= x;
140  m_energyLoss *= x;
141  return *this;
142  }
143 
146  m_length /= x;
148  m_energyLoss /= x;
149  return *this;
150  }
151 };
152 
153 inline
156  step += y;
157  return step;
158 }
159 
160 inline
163  step -= y;
164  return step;
165 }
166 
167 inline
170  step *= y;
171  return step;
172 }
173 
174 inline
177  step *= y;
178  return step;
179 }
180 
181 inline
184  step *= y;
185  return step;
186 }
187 
188 inline
191  step /= y;
192  return step;
193 }
194 
195 #endif // MaterialAccountingStep_h
MaterialAccountingStep & operator=(const MaterialAccountingStep &step)
assignement operator
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
list step
Definition: launcher.py:15
MatrixMeschach operator+(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
MatrixMeschach operator-(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
double length(void) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
double radiationLengths(void) const
MaterialAccountingStep & operator*=(const MaterialAccountingStep &step)
multiply two steps, usefull to implement (co)variance
T perp2() const
Definition: PV3DBase.h:70
MaterialAccountingStep & operator*=(double x)
multiply by a scalar
double energyLoss(void) const
Basic3DVector< long double > operator/(const Basic3DVector< long double > &v, S s)
T z() const
Definition: PV3DBase.h:63
MaterialAccountingStep & operator+=(const MaterialAccountingStep &step)
add a step
MaterialAccountingStep & operator/=(double x)
divide by a scalar
std::pair< MaterialAccountingStep, MaterialAccountingStep > split(double fraction) const
split the step (0..1) in (0..f) + (f..1) using linear interpolation
const GlobalPoint & out(void) const
MaterialAccountingStep & operator-=(const MaterialAccountingStep &step)
subtract a step
static int position[264][3]
Definition: ReadPGInfo.cc:509
MaterialAccountingStep(double position, double radlen, double loss, const GlobalPoint &in, const GlobalPoint &out)
const GlobalPoint & in(void) const
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
x
Definition: VDTMath.h:216
T x() const
Definition: PV3DBase.h:61