Belle II Software  release-05-01-25
UncertainHelix.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/geometry/Helix.h>
13 
14 #include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
15 #include <tracking/trackFindingCDC/geometry/UncertainSZLine.h>
16 #include <tracking/trackFindingCDC/geometry/SZLine.h>
17 
18 #include <tracking/trackFindingCDC/geometry/HelixParameters.h>
19 #include <tracking/trackFindingCDC/geometry/PerigeeParameters.h>
20 #include <tracking/trackFindingCDC/geometry/SZParameters.h>
21 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
22 
23 #include <cstddef>
24 #include <iosfwd>
25 
26 namespace Belle2 {
32  namespace TrackFindingCDC {
33  class Vector3D;
34 
36  class UncertainHelix {
37 
38  public:
41  {
42  }
43 
46  UncertainHelix(const double curvature,
47  const double phi0,
48  const double impact,
49  const double tanLambda,
50  const double z0,
52  const double chi2 = 0.0,
53  std::size_t ndf = 0)
54  : m_helix(curvature, phi0, impact, tanLambda, z0)
56  , m_chi2(chi2)
57  , m_ndf(ndf)
58  {
59  }
60 
62  explicit UncertainHelix(const HelixParameters& parameters,
64  const double chi2 = 0.0,
65  std::size_t ndf = 0)
66  : m_helix(parameters)
68  , m_chi2(chi2)
69  , m_ndf(ndf)
70  {
71  }
72 
75  UncertainHelix(const double curvature,
76  const Vector2D& phi0Vec,
77  const double impact,
78  const double tanLambda,
79  const double z0,
81  const double chi2 = 0.0,
82  std::size_t ndf = 0)
83  : m_helix(curvature, phi0Vec, impact, tanLambda, z0)
85  , m_chi2(chi2)
86  , m_ndf(ndf)
87  {
88  }
89 
91  explicit UncertainHelix(const Helix& helix,
93  const double chi2 = 0.0,
94  std::size_t ndf = 0)
95  : m_helix(helix)
97  , m_chi2(chi2)
98  , m_ndf(ndf)
99  {
100  }
101 
103  UncertainHelix(const UncertainPerigeeCircle& uncertainPerigeeCircle,
105  : m_helix(uncertainPerigeeCircle, uncertainSZLine)
106  , m_helixCovariance(HelixUtil::stackBlocks(uncertainPerigeeCircle.perigeeCovariance(),
107  uncertainSZLine.szCovariance()))
108  , m_chi2(uncertainPerigeeCircle.chi2() + uncertainSZLine.chi2())
109  , m_ndf(uncertainPerigeeCircle.ndf() + uncertainSZLine.ndf())
110  {
111  }
112 
115  static UncertainHelix average(const UncertainHelix& fromHelix, const UncertainHelix& toHelix);
116 
140  static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
141  const PerigeeHelixAmbiguity& fromAmbiguity,
142  const UncertainPerigeeCircle& toPerigeeCircle,
143  const PerigeeHelixAmbiguity& toAmbiguity,
144  const SZParameters& szParameters);
145 
164  const UncertainPerigeeCircle& perigeeCircle,
165  const PerigeeHelixAmbiguity& ambiguityMatrix)
166  {
167  return average(perigeeCircle, ambiguityMatrix, helix);
168  }
169 
187  static UncertainHelix average(const UncertainPerigeeCircle& fromPerigeeCircle,
188  const PerigeeHelixAmbiguity& fromAmbiguity,
189  const UncertainHelix& toHelix);
190 
191  public:
201  const Helix* operator->() const
202  {
203  return &m_helix;
204  }
205 
207  operator const Helix& () const
208  {
209  return m_helix;
210  }
211 
213  const Helix& helix() const
214  {
215  return m_helix;
216  }
217 
220  {
222  }
223 
224  public:
228  {
229  return UncertainPerigeeCircle(helix().circleXY(),
231  }
232 
236  {
238  }
239 
242  {
244  }
245 
247  const HelixCovariance& helixCovariance() const
248  {
250  }
251 
253  double covariance(const EHelixParameter& iRow, const EHelixParameter& iCol) const
254  {
255  return helixCovariance()(iRow, iCol);
256  }
257 
259  double variance(const EHelixParameter& i) const
260  {
261  return helixCovariance()(i, i);
262  }
263 
265  double chi2() const
266  {
267  return m_chi2;
268  }
269 
271  void setChi2(const double chi2)
272  {
274  }
275 
277  std::size_t ndf() const
278  {
279  return m_ndf;
280  }
281 
283  void setNDF(std::size_t ndf)
284  {
286  }
287 
289  void invalidate()
290  {
293  m_chi2 = 0.0;
294  m_ndf = 0;
295  }
296 
297  public:
299  void reverse()
300  {
301  m_helix.reverse();
303  }
304 
306  UncertainHelix reversed() const
307  {
310  chi2(),
311  ndf());
312  }
313 
314  public:
317  void passiveMoveBy(const Vector3D& by)
318  {
319  // Move the covariance matrix first to have access to the original parameters
323  }
324 
329  double shiftPeriod(int nPeriods)
330  {
331  double arcLength2D = m_helix.shiftPeriod(nPeriods);
332  SZJacobian szJacobian = m_helix.szLine().passiveMoveByJacobian(Vector2D(arcLength2D, 0));
333  PerigeeJacobian perigeeJacobian = PerigeeUtil::identity();
334  HelixJacobian jacobian = HelixUtil::stackBlocks(perigeeJacobian, szJacobian);
336  return arcLength2D;
337  }
338 
339  private:
341  Helix m_helix;
342 
345 
347  double m_chi2 = 0.0;
348 
350  size_t m_ndf = 0.0;
351 
352  };
353 
355  std::ostream& operator<<(std::ostream& output, const UncertainHelix& uncertainHelix);
356  }
358 }
Belle2::TrackFindingCDC::UncertainHelix::setHelixCovariance
void setHelixCovariance(const HelixCovariance &helixCovariance)
Setter for the whole covariance matrix of the perigee parameters.
Definition: UncertainHelix.h:249
Belle2::TrackFindingCDC::UncertainHelix::shiftPeriod
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
Definition: UncertainHelix.h:337
Belle2::TrackFindingCDC::UncertainHelix::average
static UncertainHelix average(const UncertainHelix &fromHelix, const UncertainHelix &toHelix)
Construct the averages of the two given helices by properly considering their covariance matrix.
Definition: UncertainHelix.cc:25
Belle2::TrackFindingCDC::Helix::invalidate
void invalidate()
Sets all circle parameters to zero.
Definition: Helix.h:77
Belle2::TrackFindingCDC::UncertainHelix::operator->
const Helix * operator->() const
Access to the constant interface of the underlying parameter line Allows the user of this "super" cla...
Definition: UncertainHelix.h:209
Belle2::TrackFindingCDC::UncertainHelix::helixParameters
HelixParameters helixParameters() const
Getter for the perigee parameters in the order defined by EPerigeeParameter.h.
Definition: UncertainHelix.h:227
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::UncertainHelix
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
Definition: UncertainHelix.h:40
Belle2::operator<<
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Definition: IntervalOfValidity.cc:196
Belle2::TrackFindingCDC::UncertainHelix::uncertainCircleXY
UncertainPerigeeCircle uncertainCircleXY() const
Projects the helix into the xy plain carrying over the relevant parts of the convariance matrix.
Definition: UncertainHelix.h:235
Belle2::TrackFindingCDC::UncertainHelix::chi2
double chi2() const
Getter for the chi square value of the helix fit.
Definition: UncertainHelix.h:273
Belle2::TrackFindingCDC::Helix::passiveMoveBy
double passiveMoveBy(const Vector3D &by)
Moves the coordinates system by the given vector.
Definition: Helix.h:157
Belle2::TrackFindingCDC::HelixUtil
Utility struct for functions and types related to the helix parameters.
Definition: HelixParameters.h:66
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::Helix::helixParameters
HelixParameters helixParameters() const
Getter for the five helix parameters in the order defined by EHelixParameter.h.
Definition: Helix.h:317
Belle2::TrackFindingCDC::UncertainParametersUtil< HelixUtil, EHelixParameter >::transport
static void transport(const JacobianMatrix &jacobian, CovarianceMatrix &cov)
Transport the covariance matrix inplace with the given jacobian matrix.
Definition: UncertainParameters.icc.h:34
Belle2::TrackFindingCDC::UncertainSZLine
A line in sz where s is the transverse travel distance as seen in the xy projection with uncertaintie...
Definition: UncertainSZLine.h:38
Belle2::TrackFindingCDC::UncertainHelix::setChi2
void setChi2(const double chi2)
Setter for the chi square value of the helix fit.
Definition: UncertainHelix.h:279
Belle2::TrackFindingCDC::UncertainHelix::reverse
void reverse()
Flips the orientation of the circle in place.
Definition: UncertainHelix.h:307
Belle2::TrackFindingCDC::UncertainHelix::ndf
std::size_t ndf() const
Getter for the number of degrees of freediom used in the helix fit.
Definition: UncertainHelix.h:285
Belle2::TrackFindingCDC::UncertainHelix::m_helix
Helix m_helix
Memory for the underlying helix.
Definition: UncertainHelix.h:349
Belle2::TrackFindingCDC::UncertainHelix::helix
const Helix & helix() const
Getter for the underlying helix.
Definition: UncertainHelix.h:221
Belle2::TrackFindingCDC::Helix
Extension of the generalized circle also caching the perigee coordinates.
Definition: Helix.h:38
Belle2::TrackFindingCDC::Helix::reversed
Helix reversed() const
Returns a copy of the helix with flips the travel direction, pivot point is the same.
Definition: Helix.h:97
Belle2::TrackFindingCDC::Helix::shiftPeriod
double shiftPeriod(int nPeriods)
Adjust the arclength measure to start n periods later.
Definition: Helix.h:175
Belle2::TrackFindingCDC::UncertainHelix::helixCovariance
const HelixCovariance & helixCovariance() const
Getter for the whole covariance matrix of the perigee parameters.
Definition: UncertainHelix.h:255
Belle2::TrackFindingCDC::UncertainParametersUtil< HelixUtil, EHelixParameter >::identity
static CovarianceMatrix identity()
Returns an identity matrix.
Definition: UncertainParameters.icc.h:65
Belle2::TrackFindingCDC::Helix::szLine
const SZLine & szLine() const
Getter for the projection into xy space.
Definition: Helix.h:336
Belle2::TrackFindingCDC::Helix::passiveMoveByJacobian
HelixJacobian passiveMoveByJacobian(const Vector3D &by) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition: Helix.cc:92
Belle2::TrackFindingCDC::UncertainHelix::m_helixCovariance
HelixCovariance m_helixCovariance
Memory for the 5x5 covariance matrix of the helix parameters.
Definition: UncertainHelix.h:352
Belle2::TrackFindingCDC::UncertainPerigeeCircle
Adds an uncertainty matrix to the circle in perigee parameterisation.
Definition: UncertainPerigeeCircle.h:39
Belle2::TrackFindingCDC::UncertainHelix::covariance
double covariance(const EHelixParameter &iRow, const EHelixParameter &iCol) const
Getter for individual elements of the covariance matrix.
Definition: UncertainHelix.h:261
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::SZLine::passiveMoveByJacobian
SZJacobian passiveMoveByJacobian(const Vector2D &bySZ) const
Computes the Jacobi matrix for a move of the coordinate system by the given vector.
Definition: SZLine.h:218
Belle2::TrackFindingCDC::UncertainHelix::invalidate
void invalidate()
Sets all circle parameters to zero and the covariance matrix to something noninformative.
Definition: UncertainHelix.h:297
Belle2::TrackFindingCDC::UncertainHelix::UncertainHelix
UncertainHelix()
Default constructor for ROOT compatibility.
Definition: UncertainHelix.h:48
Belle2::TrackFindingCDC::HelixUtil::getPerigeeCovariance
static PerigeeUtil::CovarianceMatrix getPerigeeCovariance(const CovarianceMatrix &helixCov)
Get perigee covariance matrix related to the xy space.
Definition: HelixParameters.cc:48
Belle2::TrackFindingCDC::UncertainHelix::variance
double variance(const EHelixParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
Definition: UncertainHelix.h:267
Belle2::TrackFindingCDC::UncertainHelix::reversed
UncertainHelix reversed() const
Returns a copy of the circle with opposite orientation.
Definition: UncertainHelix.h:314
Belle2::CDC::Helix
Helix parameter class.
Definition: Helix.h:51
Belle2::TrackFindingCDC::UncertainHelix::setNDF
void setNDF(std::size_t ndf)
Setter for the number of degrees of freediom used in the helix fit.
Definition: UncertainHelix.h:291
Belle2::TrackFindingCDC::HelixUtil::getSZCovariance
static SZUtil::CovarianceMatrix getSZCovariance(const CovarianceMatrix &helixCov)
Get sz covariance matrix.
Definition: HelixParameters.cc:54
Belle2::TrackFindingCDC::PlainMatrix
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:50
Belle2::TrackFindingCDC::UncertainHelix::passiveMoveBy
void passiveMoveBy(const Vector3D &by)
Moves the coordinate system by the vector by and calculates the new perigee and its covariance matrix...
Definition: UncertainHelix.h:325
Belle2::TrackFindingCDC::UncertainHelix
A general helix class including a covariance matrix.
Definition: UncertainHelix.h:44
Belle2::TrackFindingCDC::UncertainParametersUtil< HelixUtil, EHelixParameter >::reversed
static CovarianceMatrix reversed(const CovarianceMatrix &cov)
Return a copy of the reversed covariance matrix.
Definition: UncertainParameters.icc.h:59
Belle2::TrackFindingCDC::UncertainHelix::m_chi2
double m_chi2
Memory for the chi square value of the fit of this helix.
Definition: UncertainHelix.h:355
Belle2::TrackFindingCDC::UncertainHelix::uncertainSZLine
UncertainSZLine uncertainSZLine() const
Reduces the helix to an sz line carrying over the relevant parts of the convariance matrix.
Definition: UncertainHelix.h:243
Belle2::TrackFindingCDC::NHelixParameterIndices::EHelixParameter
EHelixParameter
Enumeration to address the individual helix parameters in a vector or matrix.
Definition: HelixParameters.h:37
Belle2::TrackFindingCDC::Helix::reverse
void reverse()
Flips the travel direction of the helix in place, pivot point is unchanged.
Definition: Helix.h:90
Belle2::TrackFindingCDC::UncertainParametersUtil< HelixUtil, EHelixParameter >::reverse
static void reverse(CovarianceMatrix &cov)
Reverse the covariance matrix inplace.
Definition: UncertainParameters.icc.h:53
Belle2::TrackFindingCDC::HelixUtil::stackBlocks
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.
Definition: HelixParameters.cc:60
Belle2::TrackFindingCDC::UncertainHelix::m_ndf
size_t m_ndf
Memory for the number of degrees of freedom of the fit of this helix.
Definition: UncertainHelix.h:358