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 }
BasicSingleVertexState.h
BasicSingleVertexState::vertexIs4D
bool vertexIs4D
Definition: BasicSingleVertexState.h:96
AlgebraicVector3
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: AlgebraicROOTObjects.h:12
BasicSingleVertexState::theErr
GlobalError theErr
Definition: BasicSingleVertexState.h:83
BasicSingleVertexState::weightTimesPosition4D
AlgebraicVector4 weightTimesPosition4D() const override
Definition: BasicSingleVertexState.cc:261
funct::false
false
Definition: Factorize.h:34
BasicSingleVertexState::timeError
double timeError() const override
Definition: BasicSingleVertexState.cc:229
BasicSingleVertexState::theWeightAvailable
bool theWeightAvailable
Definition: BasicSingleVertexState.h:92
VertexException
Common base class.
Definition: VertexException.h:12
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
pos
Definition: PixelAliasList.h:18
BasicSingleVertexState::error4D
GlobalError error4D() const override
Definition: BasicSingleVertexState.cc:213
BasicSingleVertexState::weightTimesPosition
AlgebraicVector3 weightTimesPosition() const override
Definition: BasicSingleVertexState.cc:253
GlobalErrorBase::matrix
const AlgebraicSymMatrix33 matrix() const
Definition: GlobalErrorBase.h:121
BasicSingleVertexState::theWeightTimesPosAvailable
bool theWeightTimesPosAvailable
Definition: BasicSingleVertexState.h:93
BasicSingleVertexState::BasicSingleVertexState
BasicSingleVertexState()
Definition: BasicSingleVertexState.cc:9
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
BasicSingleVertexState::weightInMixture
double weightInMixture() const override
Definition: BasicSingleVertexState.cc:269
GlobalError
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
BasicSingleVertexState::weight
GlobalWeight weight() const override
Definition: BasicSingleVertexState.cc:237
BasicSingleVertexState::theErrAvailable
bool theErrAvailable
Definition: BasicSingleVertexState.h:91
GlobalWeight
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
BasicSingleVertexState::theWeightTimesPos
AlgebraicVector4 theWeightTimesPos
Definition: BasicSingleVertexState.h:86
BasicSingleVertexState::theWeightInMix
double theWeightInMix
Definition: BasicSingleVertexState.h:87
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
BasicSingleVertexState::computeWeightTimesPos
void computeWeightTimesPos() const
Definition: BasicSingleVertexState.cc:322
BasicSingleVertexState::weight4D
GlobalWeight weight4D() const override
Definition: BasicSingleVertexState.cc:245
BasicSingleVertexState::computeError
void computeError() const
Definition: BasicSingleVertexState.cc:290
Point3DBase< float, GlobalTag >
BasicSingleVertexState::theTimeAvailable
bool theTimeAvailable
Definition: BasicSingleVertexState.h:90
BasicSingleVertexState::computePosition
void computePosition() const
Definition: BasicSingleVertexState.cc:280
GlobalErrorBase::matrix4D
const AlgebraicSymMatrix44 & matrix4D() const
Definition: GlobalErrorBase.h:136
BasicSingleVertexState::theTime
double theTime
Definition: BasicSingleVertexState.h:81
funct::true
true
Definition: Factorize.h:173
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GlobalErrorBase< double, ErrorMatrixTag >
BasicSingleVertexState::valid
bool valid
Definition: BasicSingleVertexState.h:95
AlgebraicSymMatrix44
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
Definition: AlgebraicROOTObjects.h:22
BasicSingleVertexState::time
double time() const override
Definition: BasicSingleVertexState.cc:221
AlgebraicVector4
ROOT::Math::SVector< double, 4 > AlgebraicVector4
Definition: AlgebraicROOTObjects.h:13
BasicSingleVertexState::computeWeight
void computeWeight() const
Definition: BasicSingleVertexState.cc:306
BasicSingleVertexState::theWeight
GlobalWeight theWeight
Definition: BasicSingleVertexState.h:84
BasicSingleVertexState::thePosAvailable
bool thePosAvailable
Definition: BasicSingleVertexState.h:89
VertexException.h
BasicSingleVertexState::thePos
GlobalPoint thePos
Definition: BasicSingleVertexState.h:80
ntuplemaker.time
time
Definition: ntuplemaker.py:310
BasicSingleVertexState::position
GlobalPoint position() const override
Definition: BasicSingleVertexState.cc:197
BasicSingleVertexState::error
GlobalError error() const override
Definition: BasicSingleVertexState.cc:205