CMS 3D CMS Logo

BasicSingleVertexState.cc
Go to the documentation of this file.
3 #include <limits>
4 
5 namespace {
6  constexpr double dNaN = std::numeric_limits<double>::quiet_NaN();
7 }
8 
10  : thePos(GlobalPoint(0, 0, 0)),
11  theTime(dNaN),
12  theErr(AlgebraicSymMatrix44()),
13  theWeight(AlgebraicSymMatrix44()),
14  theWeightTimesPos(AlgebraicVector4()),
15  theWeightInMix(0.),
16  thePosAvailable(false),
17  theTimeAvailable(false),
18  theErrAvailable(false),
19  theWeightAvailable(false),
20  theWeightTimesPosAvailable(false),
21  valid(false),
22  vertexIs4D(false) {}
23 
25  const GlobalError& posErr,
26  const double& weightInMix)
27  : thePos(pos),
28  theTime(dNaN),
29  theErr(posErr),
32  theWeightInMix(weightInMix),
38  valid(true),
39  vertexIs4D(false) {}
40 
42  const GlobalWeight& posWeight,
43  const double& weightInMix)
44  : thePos(pos),
45  theTime(dNaN),
47  theWeight(posWeight),
49  theWeightInMix(weightInMix),
55  valid(true),
56  vertexIs4D(false) {}
57 
59  const GlobalWeight& posWeight,
60  const double& weightInMix)
61  : thePos(GlobalPoint(0, 0, 0)),
62  theTime(dNaN),
64  theWeight(posWeight),
65  theWeightTimesPos(weightTimesPosition[0], weightTimesPosition[1], weightTimesPosition[2], 0),
66  theWeightInMix(weightInMix),
72  valid(true),
73  vertexIs4D(false) {}
74 
75 // no-offdiags for time
77  const GlobalError& posErr,
78  const double time,
79  const double timeErr,
80  const double& weightInMix)
81  : thePos(pos),
82  theTime(time),
83  theErr(posErr),
86  theWeightInMix(weightInMix),
92  valid(true),
93  vertexIs4D(true) {
94  // You dumb bastard. It's not a schooner, its a sailboat.
95  GlobalError timeErrMat(0., 0., 0., 0., 0., 0., 0., 0., 0., timeErr * timeErr);
96  theErr = theErr + timeErrMat;
97 }
98 
100  const GlobalWeight& posWeight,
101  const double time,
102  const double timeWeight,
103  const double& weightInMix)
104  : thePos(pos),
105  theTime(time),
107  theWeight(posWeight),
109  theWeightInMix(weightInMix),
115  valid(true),
116  vertexIs4D(true) {
117  GlobalWeight timeWeightMat(0., 0., 0., 0., 0., 0., 0., 0., 0., timeWeight);
118  theWeight = theWeight + timeWeightMat;
119 }
120 
122  const GlobalWeight& posWeight,
123  const double weightTimesTime,
124  const double timeWeight,
125  const double& weightInMix)
126  : thePos(GlobalPoint(0, 0, 0)),
127  theTime(dNaN),
129  theWeight(posWeight),
130  theWeightTimesPos(weightTimesPosition[0], weightTimesPosition[1], weightTimesPosition[2], weightTimesTime),
131  theWeightInMix(weightInMix),
137  valid(true),
138  vertexIs4D(true) {
139  GlobalWeight timeWeightMat(0., 0., 0., 0., 0., 0., 0., 0., 0., timeWeight);
140  theWeight = theWeight + timeWeightMat;
141 }
142 
143 // off-diags for time
145  const double time,
146  const GlobalError& posTimeErr, // fully filled 4x4 matrix
147  const double& weightInMix)
148  : thePos(pos),
149  theTime(time),
150  theErr(posTimeErr),
153  theWeightInMix(weightInMix),
159  valid(true),
160  vertexIs4D(true) {}
161 
163  const double time,
164  const GlobalWeight& posTimeWeight,
165  const double& weightInMix)
166  : thePos(pos),
167  theTime(time),
169  theWeight(posTimeWeight),
171  theWeightInMix(weightInMix),
177  valid(true),
178  vertexIs4D(true) {}
179 
181  const GlobalWeight& posWeight,
182  const double& weightInMix)
183  : thePos(GlobalPoint(0, 0, 0)),
184  theTime(dNaN),
186  theWeight(posWeight),
187  theWeightTimesPos(weightTimesPosition),
188  theWeightInMix(weightInMix),
194  valid(true),
195  vertexIs4D(true) {}
196 
198  if (!valid)
199  throw VertexException("BasicSingleVertexState::position::invalid");
200  if (!thePosAvailable)
201  computePosition();
202  return thePos;
203 }
204 
206  if (!valid)
207  throw VertexException("BasicSingleVertexState::error::invalid");
208  if (!theErrAvailable)
209  computeError();
210  return GlobalError(theErr.matrix());
211 }
212 
214  if (!valid)
215  throw VertexException("BasicSingleVertexState::error4D::invalid");
216  if (!theErrAvailable)
217  computeError();
218  return theErr;
219 }
220 
222  if (!valid)
223  throw VertexException("BasicSingleVertexState::time::invalid");
224  if (!theTimeAvailable)
225  computePosition(); // time computed with position (4-vector)
226  return theTime;
227 }
228 
230  if (!valid)
231  throw VertexException("BasicSingleVertexState::timeError::invalid");
232  if (!theTimeAvailable)
233  computeError();
234  return std::sqrt(theErr.matrix4D()(3, 3));
235 }
236 
238  if (!valid)
239  throw VertexException("BasicSingleVertexState::weight::invalid");
240  if (!theWeightAvailable)
241  computeWeight();
242  return GlobalWeight(theWeight.matrix());
243 }
244 
246  if (!valid)
247  throw VertexException("BasicSingleVertexState::weight4D::invalid");
248  if (!theWeightAvailable)
249  computeWeight();
250  return theWeight;
251 }
252 
254  if (!valid)
255  throw VertexException("BasicSingleVertexState::weightTimesPosition::invalid");
259 }
260 
262  if (!valid)
263  throw VertexException("BasicSingleVertexState::weightTimesPosition4D::invalid");
266  return theWeightTimesPos;
267 }
268 
270  if (!valid)
271  throw VertexException("BasicSingleVertexState::weightInMixture::invalid");
272  return theWeightInMix;
273 }
274 // RefCountedVertexSeed BasicSingleVertexState::seedWithoutTracks() const
275 // {
276 // RefCountedVertexSeed v = new VertexSeed(position(), error());
277 // return v;
278 // }
279 
281  if (!valid)
282  throw VertexException("BasicSingleVertexState::computePosition::invalid");
284  thePos = GlobalPoint(pos[0], pos[1], pos[2]);
285  theTime = pos[3];
286  thePosAvailable = true;
287  theTimeAvailable = true;
288 }
289 
291  if (!valid)
292  throw VertexException("BasicSingleVertexState::computeError::invalid");
293  int ifail;
294  if (vertexIs4D) {
295  theErr = weight4D().matrix4D().Inverse(ifail);
296  if (ifail != 0)
297  throw VertexException("BasicSingleVertexState::could not invert weight matrix");
298  } else {
299  theErr = weight4D().matrix().Inverse(ifail);
300  if (ifail != 0)
301  throw VertexException("BasicSingleVertexState::could not invert weight matrix");
302  }
303  theErrAvailable = true;
304 }
305 
307  if (!valid)
308  throw VertexException("BasicSingleVertexState::computeWeight::invalid");
309  int ifail;
310  if (vertexIs4D) {
311  theWeight = error4D().matrix4D().Inverse(ifail);
312  if (ifail != 0)
313  throw VertexException("BasicSingleVertexState::could not invert error matrix");
314  } else {
315  theWeight = error4D().matrix().Inverse(ifail);
316  if (ifail != 0)
317  throw VertexException("BasicSingleVertexState::could not invert error matrix");
318  }
319  theWeightAvailable = true;
320 }
321 
323  if (!valid)
324  throw VertexException("BasicSingleVertexState::computeWeightTimesPos::invalid");
326  pos(0) = position().x();
327  pos(1) = position().y();
328  pos(2) = position().z();
329  if (vertexIs4D) {
330  pos(3) = theTime;
331  } else {
332  pos(3) = 0.;
333  }
334  theWeightTimesPos = weight4D().matrix4D() * pos;
336 }
GlobalError error4D() const override
AlgebraicVector4 weightTimesPosition4D() const override
Common base class.
const AlgebraicSymMatrix33 matrix() const
GlobalError error() const override
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:60
double timeError() const override
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
const AlgebraicSymMatrix44 & matrix4D() const
GlobalWeight weight4D() const override
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
ROOT::Math::SVector< double, 4 > AlgebraicVector4
GlobalWeight weight() const override
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
double time() const override
double weightInMixture() const override
GlobalPoint position() const override
ROOT::Math::SVector< double, 3 > AlgebraicVector3
AlgebraicVector3 weightTimesPosition() const override
T x() const
Definition: PV3DBase.h:59
#define constexpr
AlgebraicVector4 theWeightTimesPos