Belle II Software  release-08-01-10
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/trackFindingCDC/geometry/Helix.h>
11 
12 #include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
13 #include <tracking/trackFindingCDC/geometry/UncertainSZLine.h>
14 #include <tracking/trackFindingCDC/geometry/SZLine.h>
15 
16 #include <tracking/trackFindingCDC/geometry/HelixParameters.h>
17 #include <tracking/trackFindingCDC/geometry/PerigeeParameters.h>
18 #include <tracking/trackFindingCDC/geometry/SZParameters.h>
19 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
20 
21 #include <cstddef>
22 #include <iosfwd>
23 
24 namespace Belle2 {
30  namespace TrackFindingCDC {
31  class Vector3D;
32 
35 
36  public:
39  {
40  }
41 
44  UncertainHelix(const double curvature,
45  const double phi0,
46  const double impact,
47  const double tanLambda,
48  const double z0,
50  const double chi2 = 0.0,
51  std::size_t ndf = 0)
52  : m_helix(curvature, phi0, impact, tanLambda, z0)
54  , m_chi2(chi2)
55  , m_ndf(ndf)
56  {
57  }
58 
60  explicit UncertainHelix(const HelixParameters& parameters,
62  const double chi2 = 0.0,
63  std::size_t ndf = 0)
64  : m_helix(parameters)
66  , m_chi2(chi2)
67  , m_ndf(ndf)
68  {
69  }
70 
73  UncertainHelix(const double curvature,
74  const Vector2D& phi0Vec,
75  const double impact,
76  const double tanLambda,
77  const double z0,
79  const double chi2 = 0.0,
80  std::size_t ndf = 0)
81  : m_helix(curvature, phi0Vec, impact, tanLambda, z0)
83  , m_chi2(chi2)
84  , m_ndf(ndf)
85  {
86  }
87 
89  explicit UncertainHelix(const Helix& helix,
91  const double chi2 = 0.0,
92  std::size_t ndf = 0)
93  : m_helix(helix)
95  , m_chi2(chi2)
96  , m_ndf(ndf)
97  {
98  }
99 
101  UncertainHelix(const UncertainPerigeeCircle& uncertainPerigeeCircle,
103  : m_helix(uncertainPerigeeCircle, uncertainSZLine)
104  , m_helixCovariance(HelixUtil::stackBlocks(uncertainPerigeeCircle.perigeeCovariance(),
105  uncertainSZLine.szCovariance()))
106  , m_chi2(uncertainPerigeeCircle.chi2() + uncertainSZLine.chi2())
107  , m_ndf(uncertainPerigeeCircle.ndf() + uncertainSZLine.ndf())
108  {
109  }
110 
113  static UncertainHelix average(const UncertainHelix& fromHelix, const UncertainHelix& toHelix);
114 
138  static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
139  const PerigeeHelixAmbiguity& fromAmbiguity,
140  const UncertainPerigeeCircle& toPerigeeCircle,
141  const PerigeeHelixAmbiguity& toAmbiguity,
142  const SZParameters& szParameters);
143 
162  const UncertainPerigeeCircle& perigeeCircle,
163  const PerigeeHelixAmbiguity& ambiguityMatrix)
164  {
165  return average(perigeeCircle, ambiguityMatrix, helix);
166  }
167 
185  static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
186  const PerigeeHelixAmbiguity& fromAmbiguity,
187  const UncertainHelix& toHelix);
188 
189  public:
199  const Helix* operator->() const
200  {
201  return &m_helix;
202  }
203 
205  operator const Helix& () const
206  {
207  return m_helix;
208  }
209 
211  const Helix& helix() const
212  {
213  return m_helix;
214  }
215 
218  {
219  return m_helix.helixParameters();
220  }
221 
222  public:
226  {
227  return UncertainPerigeeCircle(helix().circleXY(),
229  }
230 
234  {
236  }
237 
240  {
242  }
243 
246  {
247  return m_helixCovariance;
248  }
249 
251  double covariance(const EHelixParameter& iRow, const EHelixParameter& iCol) const
252  {
253  return helixCovariance()(iRow, iCol);
254  }
255 
257  double variance(const EHelixParameter& i) const
258  {
259  return helixCovariance()(i, i);
260  }
261 
263  double chi2() const
264  {
265  return m_chi2;
266  }
267 
269  void setChi2(const double chi2)
270  {
271  m_chi2 = chi2;
272  }
273 
275  std::size_t ndf() const
276  {
277  return m_ndf;
278  }
279 
281  void setNDF(std::size_t ndf)
282  {
283  m_ndf = ndf;
284  }
285 
287  void invalidate()
288  {
291  m_chi2 = 0.0;
292  m_ndf = 0;
293  }
294 
295  public:
297  void reverse()
298  {
299  m_helix.reverse();
301  }
302 
305  {
308  chi2(),
309  ndf());
310  }
311 
312  public:
315  void passiveMoveBy(const Vector3D& by)
316  {
317  // Move the covariance matrix first to have access to the original parameters
321  }
322 
327  double shiftPeriod(int nPeriods)
328  {
329  double arcLength2D = m_helix.shiftPeriod(nPeriods);
330  SZJacobian szJacobian = m_helix.szLine().passiveMoveByJacobian(Vector2D(arcLength2D, 0));
331  PerigeeJacobian perigeeJacobian = PerigeeUtil::identity();
332  HelixJacobian jacobian = HelixUtil::stackBlocks(perigeeJacobian, szJacobian);
334  return arcLength2D;
335  }
336 
337  private:
340 
343 
345  double m_chi2 = 0.0;
346 
348  size_t m_ndf = 0.0;
349 
350  };
351 
353  std::ostream& operator<<(std::ostream& output, const UncertainHelix& uncertainHelix);
354  }
356 }
Extension of the generalized circle also caching the perigee coordinates.
Definition: Helix.h:28
void reverse()
Flips the travel direction of the helix in place, pivot point is unchanged.
Definition: Helix.h:80
const SZLine & szLine() const
Getter for the projection into xy space.
Definition: Helix.h:326
Helix reversed() const
Returns a copy of the helix with flips the travel direction, pivot point is the same.
Definition: Helix.h:87
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
Definition: Helix.h:165
HelixParameters helixParameters() const
Getter for the five helix parameters in the order defined by EHelixParameter.h.
Definition: Helix.h:307
void invalidate()
Sets all circle parameters to zero.
Definition: Helix.h:67
double passiveMoveBy(const Vector3D &by)
Moves the coordinates system by the given vector.
Definition: Helix.h:147
HelixJacobian passiveMoveByJacobian(const Vector3D &by) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition: Helix.cc:90
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:40
SZJacobian passiveMoveByJacobian(const Vector2D &bySZ) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition: SZLine.h:208
A general helix class including a 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.
UncertainHelix()
Default constructor for ROOT compatibility.
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.
const Helix & helix() const
Getter for the underlying helix.
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.
void passiveMoveBy(const Vector3D &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
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.
UncertainHelix(const double curvature, const Vector2D &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.
const Helix * operator->() const
Access to the constant interface of the underlying parameter line Allows the user of this "super" cla...
Helix m_helix
Memory for the underlying helix.
const HelixCovariance & helixCovariance() const
Getter for the whole covariance matrix of the perigee parameters.
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.
UncertainPerigeeCircle uncertainCircleXY() const
Projects the helix into the xy plain carrying over the relevant parts of the convariance matrix.
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...
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
A three dimensional vector.
Definition: Vector3D.h:33
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
EHelixParameter
Enumeration to address the individual helix parameters in a vector or matrix.
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)
Transport the covariance matrix inplace with the given jacobian matrix.
static void reverse(CovarianceMatrix &cov)
Reverse the covariance matrix inplace.
static CovarianceMatrix reversed(const CovarianceMatrix &cov)
Return a copy of the reversed covariance matrix.