Belle II Software development
UncertainSZLine.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/SZLine.h>
11
12#include <tracking/trackingUtilities/geometry/SZParameters.h>
13
14#include <Math/Vector2D.h>
15
16#include <cstddef>
17#include <iosfwd>
18
19namespace Belle2 {
24
25 namespace TrackingUtilities {
26
30
31 public:
34 {
35 }
36
39 UncertainSZLine(const double tanLambda,
40 const double z0,
41 const SZCovariance& szCovariance = SZUtil::identity(),
42 const double chi2 = 0.0,
43 const size_t ndf = 0)
44 : m_szLine(tanLambda, z0)
46 , m_chi2(chi2)
47 , m_ndf(ndf)
48 {
49 }
50
53 explicit UncertainSZLine(const SZParameters szParameters,
54 const SZCovariance& szCovariance = SZUtil::identity(),
55 const double chi2 = 0.0,
56 const size_t ndf = 0)
59 , m_chi2(chi2)
60 , m_ndf(ndf)
61 {
62 }
63
66 explicit UncertainSZLine(const SZLine& szLine,
67 const SZCovariance& szCovariance = SZUtil::identity(),
68 const double chi2 = 0.0,
69 const size_t ndf = 0)
72 , m_chi2(chi2)
73 , m_ndf(ndf)
74 {
75 }
76
86 const SZLine* operator->() const
87 {
88 return &m_szLine;
89 }
90
92 operator const SZLine& () const
93 {
94 return m_szLine;
95 }
96
98 const SZLine& szLine() const
99 {
100 return m_szLine;
101 }
102
104 SZParameters szParameters() const
105 {
106 return m_szLine.szParameters();
107 }
108
109 public:
111 void setSZCovariance(const SZCovariance& szCovariance)
112 {
114 }
115
117 const SZCovariance& szCovariance() const
118 {
119 return m_szCovariance;
120 }
121
123 double covariance(const ESZParameter& iRow, const ESZParameter& iCol) const
124 {
125 return szCovariance()(iRow, iCol);
126 }
127
129 double variance(const ESZParameter& i) const
130 {
131 return szCovariance()(i, i);
132 }
133
135 double chi2() const
136 {
137 return m_chi2;
138 }
139
141 void setChi2(const double chi2)
142 {
143 m_chi2 = chi2;
144 }
145
147 std::size_t ndf() const
148 {
149 return m_ndf;
150 }
151
153 void setNDF(std::size_t ndf)
154 {
155 m_ndf = ndf;
156 }
157
160 {
161 m_szLine.invalidate();
163 m_chi2 = 0.0;
164 m_ndf = 0;
165 }
166
167 public:
169 void reverse()
170 {
171 m_szLine.reverse();
173 }
174
177 {
178 return UncertainSZLine(m_szLine.reversed(), SZUtil::reversed(szCovariance()), chi2(), ndf());
179 }
180
181 public:
184 void passiveMoveBy(const ROOT::Math::XYVector& bySZ)
185 {
186 // Move the covariance matrix first to have access to the original parameters
187 SZJacobian jacobian = m_szLine.passiveMoveByJacobian(bySZ);
189 m_szLine.passiveMoveBy(bySZ);
190 }
191
197 SZCovariance passiveMovedCovarianceBy(const ROOT::Math::XYVector& bySZ) const
198 {
199 SZJacobian jacobian = m_szLine.passiveMoveByJacobian(bySZ);
200 return SZUtil::transported(jacobian, szCovariance());
201 }
202
203 private:
206
209
211 double m_chi2 = 0.0;
212
214 size_t m_ndf = 0;
215 };
216
218 std::ostream& operator<<(std::ostream& output, const UncertainSZLine& uncertainSZLine);
219 }
221}
A line in the sz space.
Definition SZLine.h:28
A line in sz where s is the transverse travel distance as seen in the xy projection with uncertaintie...
void setSZCovariance(const SZCovariance &szCovariance)
Setter for the whole covariance matrix of the sz line parameters.
SZCovariance m_szCovariance
Memory for the 2x2 covariance matrix of sz slope (aka tan lambda) and z0.
UncertainSZLine(const SZLine &szLine, const SZCovariance &szCovariance=SZUtil::identity(), const double chi2=0.0, const size_t ndf=0)
Augments a plain two dimensional line with a covariance matrix.
void passiveMoveBy(const ROOT::Math::XYVector &bySZ)
Moves the coordinate system by the vector by and calculates the new sz line and its covariance matrix...
const SZLine * operator->() const
Access to the constant interface of the underlying parameter line Allows the user of this "super" cla...
double variance(const ESZParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
SZParameters szParameters() const
Getter for the sz parameters in the order defined by ESZParameter.h.
void reverse()
Reverses the direction of flight represented by this sz line.
UncertainSZLine(const double tanLambda, const double z0, const SZCovariance &szCovariance=SZUtil::identity(), const double chi2=0.0, const size_t ndf=0)
Composes an uncertain sz line from the perigee parameters and a 2x2 covariance matrix.
double m_chi2
Memory for the chi square value of the fit of this line.
void invalidate()
Sets all line parameters to zero including the covariance matrix.
const SZCovariance & szCovariance() const
Getter for the whole covariance matrix of the sz line parameters.
double chi2() const
Getter for the chi square value of the line fit.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freediom used in the line fit.
size_t m_ndf
Memory for the number of degrees of freedim of the fit of this line.
UncertainSZLine(const SZParameters szParameters, const SZCovariance &szCovariance=SZUtil::identity(), const double chi2=0.0, const size_t ndf=0)
Composes an uncertain sz line from the perigee parameters and a 2x2 covariance matrix.
SZLine m_szLine
Memory for the underlying line.
SZCovariance passiveMovedCovarianceBy(const ROOT::Math::XYVector &bySZ) const
Calculates the jacobian matrix that is needed for the translation of the parameter covariance for a p...
void setChi2(const double chi2)
Setter for the chi square value of the line fit.
UncertainSZLine reversed() const
Returns a copy of the line corresponding to the reverse direction of travel.
double covariance(const ESZParameter &iRow, const ESZParameter &iCol) const
Getter for individual elements of the covariance matrix.
std::size_t ndf() const
Getter for the number of degrees of freediom used in the line fit.
UncertainSZLine()
Default constructor for ROOT compatibility.
const SZLine & szLine() const
Getter for the underlying sz line.
Abstract base class for different kinds of events.
static CovarianceMatrix transported(const JacobianMatrix &jacobian, const CovarianceMatrix &cov)
static void transport(const JacobianMatrix &jacobian, CovarianceMatrix &cov)