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  m_in = step.m_in;
63  m_out = step.m_out;
64  return *this;
65  }
66 
69  m_length += step.m_length;
70  m_radiationLengths += step.m_radiationLengths;
71  m_energyLoss += step.m_energyLoss;
72 
73  // assume that perp2 is 0 only for uninitialized steps
74  if ((m_in.perp2() == 0.0) or (step.m_in.perp2() < m_in.perp2()))
75  m_in = step.m_in;
76 
77  if ((m_out.perp2() == 0.0) or (step.m_out.perp2() > m_out.perp2()))
78  m_out = step.m_out;
79 
80  return *this;
81  }
82 
85  m_length -= step.m_length;
86  m_radiationLengths -= step.m_radiationLengths;
87  m_energyLoss -= step.m_energyLoss;
88 
89  // can anything more sensible be done for m_in and/or m_out ?
90  if ((step.m_in.perp2() <= m_in.perp2()) and (step.m_out.perp2() >= m_in.perp2()))
91  m_in = step.m_out;
92 
93  if ((step.m_out.perp2() >= m_out.perp2()) and (step.m_in.perp2() <= m_out.perp2()))
94  m_out = step.m_in;
95 
96  return *this;
97  }
98 
101  m_length *= step.m_length;
102  m_radiationLengths *= step.m_radiationLengths;
103  m_energyLoss *= step.m_energyLoss;
104  return *this;
105  }
106 
109  m_length *= x;
111  m_energyLoss *= x;
112  return *this;
113  }
114 
117  m_length /= x;
119  m_energyLoss /= x;
120  return *this;
121  }
122 };
123 
126  step += y;
127  return step;
128 }
129 
132  step -= y;
133  return step;
134 }
135 
138  step *= y;
139  return step;
140 }
141 
144  step *= y;
145  return step;
146 }
147 
150  step *= y;
151  return step;
152 }
153 
156  step /= y;
157  return step;
158 }
159 
160 #endif // MaterialAccountingStep_h
MaterialAccountingStep::MaterialAccountingStep
MaterialAccountingStep(void)
Definition: MaterialAccountingStep.h:11
MaterialAccountingStep::m_out
GlobalPoint m_out
Definition: MaterialAccountingStep.h:29
step
step
Definition: StallMonitor.cc:94
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
MaterialAccountingStep::operator*=
MaterialAccountingStep & operator*=(const MaterialAccountingStep &step)
multiply two steps, usefull to implement (co)variance
Definition: MaterialAccountingStep.h:100
DDAxes::x
MaterialAccountingStep::in
const GlobalPoint & in(void) const
Definition: MaterialAccountingStep.h:38
operator/
MaterialAccountingStep operator/(const MaterialAccountingStep &x, double y)
Definition: MaterialAccountingStep.h:154
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
MaterialAccountingStep::m_energyLoss
double m_energyLoss
Definition: MaterialAccountingStep.h:27
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52861
operator*
MaterialAccountingStep operator*(const MaterialAccountingStep &x, const MaterialAccountingStep &y)
Definition: MaterialAccountingStep.h:136
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
MaterialAccountingStep::m_radiationLengths
double m_radiationLengths
Definition: MaterialAccountingStep.h:26
MaterialAccountingStep::out
const GlobalPoint & out(void) const
Definition: MaterialAccountingStep.h:40
MaterialAccountingStep::operator-=
MaterialAccountingStep & operator-=(const MaterialAccountingStep &step)
subtract a step
Definition: MaterialAccountingStep.h:84
MaterialAccountingStep::operator*=
MaterialAccountingStep & operator*=(double x)
multiply by a scalar
Definition: MaterialAccountingStep.h:108
operator+
MaterialAccountingStep operator+(const MaterialAccountingStep &x, const MaterialAccountingStep &y)
Definition: MaterialAccountingStep.h:124
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
MaterialAccountingStep::split
std::pair< MaterialAccountingStep, MaterialAccountingStep > split(double fraction) const
split the step (0..1) in (0..f) + (f..1) using linear interpolation
Definition: MaterialAccountingStep.h:43
MaterialAccountingStep::operator+=
MaterialAccountingStep & operator+=(const MaterialAccountingStep &step)
add a step
Definition: MaterialAccountingStep.h:68
MaterialAccountingStep::m_in
GlobalPoint m_in
Definition: MaterialAccountingStep.h:28
MaterialAccountingStep::m_length
double m_length
Definition: MaterialAccountingStep.h:25
MaterialAccountingStep::operator/=
MaterialAccountingStep & operator/=(double x)
divide by a scalar
Definition: MaterialAccountingStep.h:116
MaterialAccountingStep
Definition: MaterialAccountingStep.h:9
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
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
genVertex_cff.x
x
Definition: genVertex_cff.py:12
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
operator-
MaterialAccountingStep operator-(const MaterialAccountingStep &x, const MaterialAccountingStep &y)
Definition: MaterialAccountingStep.h:130
or
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::MaterialAccountingStep
MaterialAccountingStep(double position, double radlen, double loss, const GlobalPoint &in, const GlobalPoint &out)
Definition: MaterialAccountingStep.h:13
GlobalPoint.h
MaterialAccountingStep::clear
void clear(void)
Definition: MaterialAccountingStep.h:16
PV3DBase::perp2
T perp2() const
Definition: PV3DBase.h:68
MaterialAccountingStep::operator=
MaterialAccountingStep & operator=(const MaterialAccountingStep &step)
assignement operator
Definition: MaterialAccountingStep.h:58