Belle II Software development
UncertainHelix.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackingUtilities/geometry/Helix.h>
11
12#include <tracking/trackingUtilities/geometry/UncertainPerigeeCircle.h>
13#include <tracking/trackingUtilities/geometry/UncertainSZLine.h>
14#include <tracking/trackingUtilities/geometry/SZLine.h>
15
16#include <tracking/trackingUtilities/geometry/HelixParameters.h>
17#include <tracking/trackingUtilities/geometry/PerigeeParameters.h>
18#include <tracking/trackingUtilities/geometry/SZParameters.h>
19
20#include <Math/Vector3D.h>
21#include <Math/Vector2D.h>
22
23#include <cstddef>
24#include <iosfwd>
25
26namespace Belle2 {
31
32 namespace TrackingUtilities {
33
36
37 public:
40 {
41 }
42
45 UncertainHelix(const double curvature,
46 const double phi0,
47 const double impact,
48 const double tanLambda,
49 const double z0,
50 const HelixCovariance& helixCovariance = HelixUtil::identity(),
51 const double chi2 = 0.0,
52 std::size_t ndf = 0)
53 : m_helix(curvature, phi0, impact, tanLambda, z0)
55 , m_chi2(chi2)
56 , m_ndf(ndf)
57 {
58 }
59
61 explicit UncertainHelix(const HelixParameters& parameters,
62 const HelixCovariance& helixCovariance = HelixUtil::identity(),
63 const double chi2 = 0.0,
64 std::size_t ndf = 0)
65 : m_helix(parameters)
67 , m_chi2(chi2)
68 , m_ndf(ndf)
69 {
70 }
71
74 UncertainHelix(const double curvature,
75 const ROOT::Math::XYVector& phi0Vec,
76 const double impact,
77 const double tanLambda,
78 const double z0,
79 const HelixCovariance& helixCovariance = HelixUtil::identity(),
80 const double chi2 = 0.0,
81 std::size_t ndf = 0)
82 : m_helix(curvature, phi0Vec, impact, tanLambda, z0)
84 , m_chi2(chi2)
85 , m_ndf(ndf)
86 {
87 }
88
90 explicit UncertainHelix(const Helix& helix,
91 const HelixCovariance& helixCovariance = HelixUtil::identity(),
92 const double chi2 = 0.0,
93 std::size_t ndf = 0)
94 : m_helix(helix)
96 , m_chi2(chi2)
97 , m_ndf(ndf)
98 {
99 }
100
102 UncertainHelix(const UncertainPerigeeCircle& uncertainPerigeeCircle,
104 : m_helix(uncertainPerigeeCircle, uncertainSZLine)
105 , m_helixCovariance(HelixUtil::stackBlocks(uncertainPerigeeCircle.perigeeCovariance(),
106 uncertainSZLine.szCovariance()))
107 , m_chi2(uncertainPerigeeCircle.chi2() + uncertainSZLine.chi2())
108 , m_ndf(uncertainPerigeeCircle.ndf() + uncertainSZLine.ndf())
109 {
110 }
111
114 static UncertainHelix average(const UncertainHelix& fromHelix, const UncertainHelix& toHelix);
115
139 static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
140 const PerigeeHelixAmbiguity& fromAmbiguity,
141 const UncertainPerigeeCircle& toPerigeeCircle,
142 const PerigeeHelixAmbiguity& toAmbiguity,
143 const SZParameters& szParameters);
144
163 const UncertainPerigeeCircle& perigeeCircle,
164 const PerigeeHelixAmbiguity& ambiguityMatrix)
165 {
166 return average(perigeeCircle, ambiguityMatrix, helix);
167 }
168
186 static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
187 const PerigeeHelixAmbiguity& fromAmbiguity,
188 const UncertainHelix& toHelix);
189
190 public:
200 const Helix* operator->() const
201 {
202 return &m_helix;
203 }
204
206 operator const Helix& () const
207 {
208 return m_helix;
209 }
210
212 const Helix& helix() const
213 {
214 return m_helix;
215 }
216
218 HelixParameters helixParameters() const
219 {
220 return m_helix.helixParameters();
221 }
222
223 public:
231
238
240 void setHelixCovariance(const HelixCovariance& helixCovariance)
241 {
243 }
244
246 const HelixCovariance& helixCovariance() const
247 {
248 return m_helixCovariance;
249 }
250
252 double covariance(const EHelixParameter& iRow, const EHelixParameter& iCol) const
253 {
254 return helixCovariance()(iRow, iCol);
255 }
256
258 double variance(const EHelixParameter& i) const
259 {
260 return helixCovariance()(i, i);
261 }
262
264 double chi2() const
265 {
266 return m_chi2;
267 }
268
270 void setChi2(const double chi2)
271 {
272 m_chi2 = chi2;
273 }
274
276 std::size_t ndf() const
277 {
278 return m_ndf;
279 }
280
282 void setNDF(std::size_t ndf)
283 {
284 m_ndf = ndf;
285 }
286
289 {
290 m_helix.invalidate();
292 m_chi2 = 0.0;
293 m_ndf = 0;
294 }
295
296 public:
298 void reverse()
299 {
300 m_helix.reverse();
302 }
303
306 {
307 return UncertainHelix(m_helix.reversed(),
309 chi2(),
310 ndf());
311 }
312
313 public:
316 void passiveMoveBy(const ROOT::Math::XYZVector& by)
317 {
318 // Move the covariance matrix first to have access to the original parameters
319 HelixJacobian jacobian = m_helix.passiveMoveByJacobian(by);
321 m_helix.passiveMoveBy(by);
322 }
323
328 double shiftPeriod(int nPeriods)
329 {
330 double arcLength2D = m_helix.shiftPeriod(nPeriods);
331 SZJacobian szJacobian = m_helix.szLine().passiveMoveByJacobian(ROOT::Math::XYVector(arcLength2D, 0));
332 PerigeeJacobian perigeeJacobian = PerigeeUtil::identity();
333 HelixJacobian jacobian = HelixUtil::stackBlocks(perigeeJacobian, szJacobian);
335 return arcLength2D;
336 }
337
338 private:
341
344
346 double m_chi2 = 0.0;
347
349 size_t m_ndf = 0.0;
350
351 };
352
354 std::ostream& operator<<(std::ostream& output, const UncertainHelix& uncertainHelix);
355 }
357}
Extension of the generalized circle also caching the perigee coordinates.
Definition Helix.h:30
A general helix class including a covariance matrix.
UncertainHelix(const double curvature, const ROOT::Math::XYVector &phi0Vec, const double impact, const double tanLambda, const double z0, const HelixCovariance &helixCovariance=HelixUtil::identity(), const double chi2=0.0, std::size_t ndf=0)
Composes an uncertain perigee circle from the perigee parameters and a 3x3 covariance matrix.
double variance(const EHelixParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
UncertainHelix(const double curvature, const double phi0, const double impact, const double tanLambda, const double z0, const HelixCovariance &helixCovariance=HelixUtil::identity(), const double chi2=0.0, std::size_t ndf=0)
Composes an uncertain perigee circle from the perigee parameters and a 3x3 covariance matrix.
const HelixCovariance & helixCovariance() const
Getter for the whole covariance matrix of the perigee parameters.
UncertainHelix()
Default constructor for ROOT compatibility.
void passiveMoveBy(const ROOT::Math::XYZVector &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
void reverse()
Flips the orientation of the circle in place.
UncertainHelix reversed() const
Returns a copy of the circle with opposite orientation.
UncertainSZLine uncertainSZLine() const
Reduces the helix to an sz line carrying over the relevant parts of the convariance matrix.
UncertainHelix(const UncertainPerigeeCircle &uncertainPerigeeCircle, const UncertainSZLine &uncertainSZLine)
Augments a plain helix with a covariance matrix. Covariance defaults to zero.
UncertainHelix(const HelixParameters &parameters, const HelixCovariance &helixCovariance=HelixUtil::identity(), const double chi2=0.0, std::size_t ndf=0)
Constructor taking all stored parameters.
double covariance(const EHelixParameter &iRow, const EHelixParameter &iCol) const
Getter for individual elements of the covariance matrix.
static UncertainHelix average(const UncertainHelix &fromHelix, const UncertainHelix &toHelix)
Construct the averages of the two given helices by properly considering their covariance matrix.
void setHelixCovariance(const HelixCovariance &helixCovariance)
Setter for the whole covariance matrix of the perigee parameters.
HelixCovariance m_helixCovariance
Memory for the 5x5 covariance matrix of the helix parameters.
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
double m_chi2
Memory for the chi square value of the fit of this helix.
HelixParameters helixParameters() const
Getter for the perigee parameters in the order defined by EPerigeeParameter.h.
void invalidate()
Sets all circle parameters to zero and the covariance matrix to something noninformative.
double chi2() const
Getter for the chi square value of the helix fit.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freediom used in the helix fit.
size_t m_ndf
Memory for the number of degrees of freedom of the fit of this helix.
UncertainHelix(const Helix &helix, const HelixCovariance &helixCovariance=HelixUtil::identity(), const double chi2=0.0, std::size_t ndf=0)
Augments a plain helix with a covariance matrix. Covariance defaults to zero.
Helix m_helix
Memory for the underlying helix.
void setChi2(const double chi2)
Setter for the chi square value of the helix fit.
static UncertainHelix average(const UncertainHelix &helix, const UncertainPerigeeCircle &perigeeCircle, const PerigeeHelixAmbiguity &ambiguityMatrix)
Construct the average helix including its covariance matrix incoorporating additional information fro...
std::size_t ndf() const
Getter for the number of degrees of freediom used in the helix fit.
const Helix & helix() const
Getter for the underlying helix.
UncertainPerigeeCircle uncertainCircleXY() const
Projects the helix into the xy plain carrying over the relevant parts of the convariance matrix.
const Helix * operator->() const
Access to the constant interface of the underlying parameter line Allows the user of this "super" cla...
Adds an uncertainty matrix to the circle in perigee parameterisation.
A line in sz where s is the transverse travel distance as seen in the xy projection with uncertaintie...
Abstract base class for different kinds of events.
Utility struct for functions and types related to the helix parameters.
static SZUtil::CovarianceMatrix getSZCovariance(const CovarianceMatrix &helixCov)
Get sz covariance matrix.
static HelixUtil::CovarianceMatrix stackBlocks(const PerigeeUtil::CovarianceMatrix &perigeeCov, const SZUtil::CovarianceMatrix &szCov)
Combine covariance matrices from the xy space and the sz space in their respective blocks.
static PerigeeUtil::CovarianceMatrix getPerigeeCovariance(const CovarianceMatrix &helixCov)
Get perigee covariance matrix related to the xy space.
static void transport(const JacobianMatrix &jacobian, CovarianceMatrix &cov)