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()), theWeightInMix(0.) ,
15  thePosAvailable(false), theTimeAvailable(false), theErrAvailable(false),theWeightAvailable(false), theWeightTimesPosAvailable(false),
16  valid(false), vertexIs4D(false)
17 {}
18 
20  const GlobalError & posErr,
21  const double & weightInMix)
22  : thePos(pos),
23  theTime(dNaN),
24  theErr(posErr),
27  theWeightInMix(weightInMix),
30 {}
31 
32 
34  const GlobalWeight & posWeight,
35  const double & weightInMix)
36  : thePos(pos),
37  theTime(dNaN),
39  theWeight(posWeight),
41  theWeightInMix(weightInMix),
44 {}
45 
46 
48  const GlobalWeight & posWeight,
49  const double & weightInMix)
50  : thePos(GlobalPoint(0, 0, 0)),
51  theTime(dNaN),
53  theWeight(posWeight),
54  theWeightTimesPos(weightTimesPosition[0], weightTimesPosition[1], weightTimesPosition[2], 0),
55  theWeightInMix(weightInMix),
58 {}
59 
60 // no-offdiags for time
62  const GlobalError & posErr,
63  const double time,
64  const double timeErr,
65  const double & weightInMix)
66  : thePos(pos),
67  theTime(time),
68  theErr(posErr),
71  theWeightInMix(weightInMix),
74 {
75  // You dumb bastard. It's not a schooner, its a sailboat.
76  GlobalError timeErrMat(0.,
77  0.,0.,
78  0.,0.,0.,
79  0.,0.,0.,timeErr*timeErr);
80  theErr = theErr + timeErrMat;
81 }
82 
83 
85  const GlobalWeight & posWeight,
86  const double time,
87  const double timeWeight,
88  const double & weightInMix)
89  : thePos(pos),
90  theTime(time),
92  theWeight(posWeight),
94  theWeightInMix(weightInMix),
97 {
98  GlobalWeight timeWeightMat(0.,
99  0.,0.,
100  0.,0.,0.,
101  0.,0.,0.,timeWeight);
102  theWeight = theWeight + timeWeightMat;
103 }
104 
105 
107  const GlobalWeight & posWeight,
108  const double weightTimesTime,
109  const double timeWeight,
110  const double & weightInMix)
111  : thePos(GlobalPoint(0, 0, 0)),
112  theTime(dNaN),
114  theWeight(posWeight),
115  theWeightTimesPos(weightTimesPosition[0],weightTimesPosition[1],weightTimesPosition[2],weightTimesTime),
116  theWeightInMix(weightInMix),
119 {
120  GlobalWeight timeWeightMat(0.,
121  0.,0.,
122  0.,0.,0.,
123  0.,0.,0.,timeWeight);
124  theWeight = theWeight + timeWeightMat;
125 }
126 
127 // off-diags for time
129  const double time,
130  const GlobalError & posTimeErr, // fully filled 4x4 matrix
131  const double & weightInMix)
132  : thePos(pos),
133  theTime(time),
134  theErr(posTimeErr),
137  theWeightInMix(weightInMix),
140 {}
141 
142 
144  const double time,
145  const GlobalWeight & posTimeWeight,
146  const double & weightInMix)
147  : thePos(pos),
148  theTime(time),
150  theWeight(posTimeWeight),
152  theWeightInMix(weightInMix),
155 {}
156 
157 
159  const GlobalWeight & posWeight,
160  const double & weightInMix)
161  : thePos(GlobalPoint(0, 0, 0)),
162  theTime(dNaN),
164  theWeight(posWeight),
165  theWeightTimesPos(weightTimesPosition),
166  theWeightInMix(weightInMix),
169 {}
170 
172 {
173  if (!valid) throw VertexException("BasicSingleVertexState::position::invalid");
175  return thePos;
176 }
177 
179 {
180  if (!valid) throw VertexException("BasicSingleVertexState::error::invalid");
182  return GlobalError(theErr.matrix());
183 }
184 
186 {
187  if (!valid) throw VertexException("BasicSingleVertexState::error4D::invalid");
189  return theErr;
190 }
191 
193  if (!valid) throw VertexException("BasicSingleVertexState::time::invalid");
194  if (!theTimeAvailable) computePosition(); // time computed with position (4-vector)
195  return theTime;
196 }
197 
199  if (!valid) throw VertexException("BasicSingleVertexState::timeError::invalid");
201  return std::sqrt(theErr.matrix4D()(3,3));
202 }
203 
205 {
206  if (!valid) throw VertexException("BasicSingleVertexState::weight::invalid");
208  return GlobalWeight(theWeight.matrix());
209 }
210 
212 {
213  if (!valid) throw VertexException("BasicSingleVertexState::weight4D::invalid");
215  return theWeight;
216 }
217 
219 {
220  if (!valid) throw VertexException("BasicSingleVertexState::weightTimesPosition::invalid");
223 }
224 
226 {
227  if (!valid) throw VertexException("BasicSingleVertexState::weightTimesPosition4D::invalid");
229  return theWeightTimesPos;
230 }
231 
232 
234 {
235  if (!valid) throw VertexException("BasicSingleVertexState::weightInMixture::invalid");
236  return theWeightInMix;
237 }
238 // RefCountedVertexSeed BasicSingleVertexState::seedWithoutTracks() const
239 // {
240 // RefCountedVertexSeed v = new VertexSeed(position(), error());
241 // return v;
242 // }
243 
244 
245 
247 {
248  if (!valid) throw VertexException("BasicSingleVertexState::computePosition::invalid");
250  thePos = GlobalPoint(pos[0], pos[1], pos[2]);
251  theTime = pos[3];
252  thePosAvailable = true;
253  theTimeAvailable = true;
254 }
255 
257 {
258  if (!valid) throw VertexException("BasicSingleVertexState::computeError::invalid");
259  int ifail;
260  if( vertexIs4D ) {
261  theErr = weight4D().matrix4D().Inverse(ifail);
262  if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert weight matrix");
263  } else {
264  theErr = weight4D().matrix().Inverse(ifail);
265  if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert weight matrix");
266  }
267  theErrAvailable = true;
268 }
269 
270 
272 {
273  if (!valid) throw VertexException("BasicSingleVertexState::computeWeight::invalid");
274  int ifail;
275  if( vertexIs4D ) {
276  theWeight = error4D().matrix4D().Inverse(ifail);
277  if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert error matrix");
278  } else {
279  theWeight = error4D().matrix().Inverse(ifail);
280  if (ifail != 0) throw VertexException("BasicSingleVertexState::could not invert error matrix");
281  }
282  theWeightAvailable = true;
283 }
284 
285 
287 {
288  if (!valid) throw VertexException("BasicSingleVertexState::computeWeightTimesPos::invalid");
289  AlgebraicVector4 pos; pos(0) = position().x();
290  pos(1) = position().y(); pos(2) = position().z();
291  if ( vertexIs4D ) {
292  pos(3) = theTime;
293  } else {
294  pos(3) = 0.;
295  }
298 }
299 
300 
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:63
double timeError() const override
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
const AlgebraicSymMatrix44 & matrix4D() const
GlobalWeight weight4D() const override
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > AlgebraicSymMatrix44
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
ROOT::Math::SVector< double, 3 > AlgebraicVector3
GlobalWeight weight() const override
GlobalErrorBase< double, WeightMatrixTag > GlobalWeight
Definition: GlobalWeight.h:12
double time() const override
double weightInMixture() const override
GlobalPoint position() const override
AlgebraicVector3 weightTimesPosition() const override
ROOT::Math::SVector< double, 4 > AlgebraicVector4
T x() const
Definition: PV3DBase.h:62
#define constexpr
AlgebraicVector4 theWeightTimesPos