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),
30  theWeight(AlgebraicSymMatrix44()),
31  theWeightTimesPos(AlgebraicVector4()),
32  theWeightInMix(weightInMix),
33  thePosAvailable(true),
34  theTimeAvailable(false),
35  theErrAvailable(true),
36  theWeightAvailable(false),
37  theWeightTimesPosAvailable(false),
38  valid(true),
39  vertexIs4D(false) {}
40 
42  const GlobalWeight& posWeight,
43  const double& weightInMix)
44  : thePos(pos),
45  theTime(dNaN),
46  theErr(AlgebraicSymMatrix44()),
47  theWeight(posWeight),
48  theWeightTimesPos(AlgebraicVector4()),
49  theWeightInMix(weightInMix),
50  thePosAvailable(true),
51  theTimeAvailable(false),
52  theErrAvailable(false),
53  theWeightAvailable(true),
54  theWeightTimesPosAvailable(false),
55  valid(true),
56  vertexIs4D(false) {}
57 
59  const GlobalWeight& posWeight,
60  const double& weightInMix)
61  : thePos(GlobalPoint(0, 0, 0)),
62  theTime(dNaN),
63  theErr(AlgebraicSymMatrix44()),
64  theWeight(posWeight),
65  theWeightTimesPos(weightTimesPosition[0], weightTimesPosition[1], weightTimesPosition[2], 0),
66  theWeightInMix(weightInMix),
67  thePosAvailable(false),
68  theTimeAvailable(false),
69  theErrAvailable(false),
70  theWeightAvailable(true),
71  theWeightTimesPosAvailable(true),
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),
84  theWeight(AlgebraicSymMatrix44()),
85  theWeightTimesPos(AlgebraicVector4()),
86  theWeightInMix(weightInMix),
87  thePosAvailable(true),
88  theTimeAvailable(true),
89  theErrAvailable(true),
90  theWeightAvailable(false),
91  theWeightTimesPosAvailable(false),
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),
106  theErr(AlgebraicSymMatrix44()),
107  theWeight(posWeight),
108  theWeightTimesPos(AlgebraicVector4()),
109  theWeightInMix(weightInMix),
110  thePosAvailable(true),
111  theTimeAvailable(true),
112  theErrAvailable(false),
113  theWeightAvailable(true),
114  theWeightTimesPosAvailable(false),
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),
128  theErr(AlgebraicSymMatrix44()),
129  theWeight(posWeight),
130  theWeightTimesPos(weightTimesPosition[0], weightTimesPosition[1], weightTimesPosition[2], weightTimesTime),
131  theWeightInMix(weightInMix),
132  thePosAvailable(false),
133  theTimeAvailable(false),
134  theErrAvailable(false),
135  theWeightAvailable(true),
136  theWeightTimesPosAvailable(true),
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),
151  theWeight(AlgebraicSymMatrix44()),
152  theWeightTimesPos(AlgebraicVector4()),
153  theWeightInMix(weightInMix),
154  thePosAvailable(true),
155  theTimeAvailable(true),
156  theErrAvailable(true),
157  theWeightAvailable(false),
158  theWeightTimesPosAvailable(false),
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),
168  theErr(AlgebraicSymMatrix44()),
169  theWeight(posTimeWeight),
170  theWeightTimesPos(AlgebraicVector4()),
171  theWeightInMix(weightInMix),
172  thePosAvailable(true),
173  theTimeAvailable(true),
174  theErrAvailable(false),
175  theWeightAvailable(true),
176  theWeightTimesPosAvailable(false),
177  valid(true),
178  vertexIs4D(true) {}
179 
181  const GlobalWeight& posWeight,
182  const double& weightInMix)
183  : thePos(GlobalPoint(0, 0, 0)),
184  theTime(dNaN),
185  theErr(AlgebraicSymMatrix44()),
186  theWeight(posWeight),
187  theWeightTimesPos(weightTimesPosition),
188  theWeightInMix(weightInMix),
189  thePosAvailable(false),
190  theTimeAvailable(false),
191  theErrAvailable(false),
192  theWeightAvailable(true),
193  theWeightTimesPosAvailable(true),
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  }
336 }
T z() const
Definition: PV3DBase.h:61
Common base class.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
double time() const override
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
const AlgebraicSymMatrix44 & matrix4D() const
GlobalError error() const override
T sqrt(T t)
Definition: SSEVec.h:23
GlobalPoint position() const override
double timeError() const override
const AlgebraicSymMatrix33 matrix() const
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
ROOT::Math::SVector< double, 4 > AlgebraicVector4
AlgebraicVector4 weightTimesPosition4D() const override
AlgebraicVector3 weightTimesPosition() const override
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
GlobalError error4D() const override
double weightInMixture() const override
ROOT::Math::SVector< double, 3 > AlgebraicVector3
GlobalWeight weight() const override
GlobalWeight weight4D() const override
AlgebraicVector4 theWeightTimesPos