Belle II Software development
HelixParameters.cc
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#include <tracking/trackFindingCDC/geometry/UncertainParameters.icc.h>
9
10#include <tracking/trackFindingCDC/geometry/HelixParameters.h>
11
12#include <tracking/trackFindingCDC/numerics/CovarianceMatrixUtil.h>
13#include <tracking/trackFindingCDC/numerics/ParameterVectorUtil.h>
14
15#include <tracking/trackFindingCDC/numerics/Angle.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19
21
23{
25}
26
28{
29 using namespace NHelixParameterIndices;
30 return getSubParameterVector<PerigeeUtil::ParameterVector, c_Curv>(helixPar);
31}
32
34{
35 using namespace NHelixParameterIndices;
36 return getSubParameterVector<SZUtil::ParameterVector, c_TanL>(helixPar);
37}
38
40 const SZUtil::ParameterVector& szPar)
41{
42 ParameterVector result = ParameterVectorUtil::stack(perigeePar, szPar);
43 return result;
44}
45
47{
48 using namespace NHelixParameterIndices;
49 return getSubCovarianceMatrix<PerigeeUtil::CovarianceMatrix, c_Curv>(helixCov);
50}
51
53{
54 using namespace NHelixParameterIndices;
55 return getSubCovarianceMatrix<SZUtil::CovarianceMatrix, c_TanL>(helixCov);
56}
57
59 const SZUtil::CovarianceMatrix& szCov)
60{
61 CovarianceMatrix result = CovarianceMatrixUtil::stackBlocks(perigeeCov, szCov);
62 return result;
63}
64
66{
68}
69
70double HelixUtil::average(const HelixParameters& fromPar,
71 const HelixCovariance& fromCov,
72 const HelixParameters& toPar,
73 const HelixCovariance& toCov,
74 HelixParameters& avgPar,
75 HelixCovariance& avgCov)
76{
77 using namespace NHelixParameterIndices;
78 HelixParameters refPar = (fromPar + toPar) / 2.0;
79 refPar[c_Phi0] = AngleUtil::average(fromPar[c_Phi0], toPar[c_Phi0]);
80
81 HelixParameters relFromPar = fromPar - refPar;
82 AngleUtil::normalise(relFromPar[c_Phi0]);
83
84 HelixParameters relToPar = toPar - refPar;
85 AngleUtil::normalise(relToPar[c_Phi0]);
86
87 HelixParameters relAvgPar;
88 double chi2 =
89 CovarianceMatrixUtil::average(relFromPar, fromCov, relToPar, toCov, relAvgPar, avgCov);
90
91 avgPar = relAvgPar + refPar;
92 AngleUtil::normalise(avgPar[c_Phi0]);
93
94 return chi2;
95}
96
98 const PerigeeCovariance& fromCov,
99 const PerigeeHelixAmbiguity& fromAmbiguity,
100 const HelixParameters& toPar,
101 const HelixCovariance& toCov,
102 HelixParameters& avgPar,
103 HelixCovariance& avgCov)
104{
105 auto toAmbiguity = JacobianMatrixUtil::identity<5>();
106
107 using namespace NPerigeeParameterIndices;
108 PerigeeParameters refPar = (fromPar + toPar.head<3>()) / 2.0;
109 refPar[c_Phi0] = AngleUtil::average(fromPar[c_Phi0], toPar[c_Phi0]);
110
111 HelixParameters refHelixPar = stack(refPar, toPar.tail<2>());
112
113 PerigeeParameters relFromPar = fromPar - refPar;
114 AngleUtil::normalise(relFromPar[c_Phi0]);
115
116 HelixParameters relToPar = toPar - refHelixPar;
117 AngleUtil::normalise(relToPar[c_Phi0]);
118
119 HelixParameters relAvgPar;
120
121 // Chi2 value
122 double chi2 = CovarianceMatrixUtil::average(relFromPar,
123 fromCov,
124 fromAmbiguity,
125 relToPar,
126 toCov,
127 toAmbiguity,
128 relAvgPar,
129 avgCov);
130
131 avgPar = relAvgPar + refHelixPar;
132 AngleUtil::normalise(avgPar[c_Phi0]);
133
134 return chi2;
135}
136
138 const PerigeeCovariance& fromCov,
139 const PerigeeHelixAmbiguity& fromAmbiguity,
140 const PerigeeParameters& toPar,
141 const PerigeeCovariance& toCov,
142 const PerigeeHelixAmbiguity& toAmbiguity,
143 const SZParameters& szParameters,
144 HelixParameters& avgPar,
145 HelixCovariance& avgCov)
146{
147 using namespace NPerigeeParameterIndices;
148 PerigeeParameters refPar = (fromPar + toPar) / 2.0;
149 refPar[c_Phi0] = AngleUtil::average(fromPar[c_Phi0], toPar[c_Phi0]);
150
151 HelixParameters refHelixPar = stack(refPar, szParameters);
152
153 PerigeeParameters relFromPar = fromPar - refPar;
154 AngleUtil::normalise(relFromPar[c_Phi0]);
155
156 PerigeeParameters relToPar = toPar - refPar;
157 AngleUtil::normalise(relToPar[c_Phi0]);
158
159 HelixParameters relAvgPar;
160
161 // Chi2 value
162 double chi2 = CovarianceMatrixUtil::average(relFromPar,
163 fromCov,
164 fromAmbiguity,
165 relToPar,
166 toCov,
167 toAmbiguity,
168 relAvgPar,
169 avgCov);
170
171 avgPar = relAvgPar + refHelixPar;
172 AngleUtil::normalise(avgPar[c_Phi0]);
173
174 return chi2;
175}
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:40
PlainMatrix< T, K, N > tail() const
Get the K bottom rows of the matrix.
Definition: PlainMatrix.h:215
static PlainMatrix< T, M, N > Zero()
Construct a matrix initialized with zeros.
Definition: PlainMatrix.h:67
PlainMatrix< T, K, N > head() const
Get the K top rows of the matrix.
Definition: PlainMatrix.h:208
Abstract base class for different kinds of events.
static void normalise(double &angle)
Normalise an angle inplace to lie in the range from [-pi, pi].
Definition: Angle.h:41
static double average(const double angle1, double angle2)
Combines two angluar values to the one that lies half way between them on the short arc.
Definition: Angle.h:27
static CovarianceMatrix< N1+N2 > stackBlocks(const CovarianceMatrix< N1 > &block1, const CovarianceMatrix< N2 > &block2)
Combines two covariance matrices by putting them in two blocks on the diagonal of a larger matrix.
static double average(const ParameterVector< N > &par1, const CovarianceMatrix< N > &cov1, const ParameterVector< N > &par2, const CovarianceMatrix< N > &cov2, ParameterVector< N > &par, CovarianceMatrix< N > &cov)
Averages two parameter vectors taking into account their respective covariances.
static double average(const HelixUtil::ParameterVector &fromPar, const HelixUtil::CovarianceMatrix &fromCov, const HelixUtil::ParameterVector &toPar, const HelixUtil::CovarianceMatrix &toCov, HelixUtil::ParameterVector &avgPar, HelixUtil::CovarianceMatrix &avgCov)
Calculates the weighted average between two helix parameter sets with their respective covariance mat...
static SZUtil::CovarianceMatrix getSZCovariance(const CovarianceMatrix &helixCov)
Get sz covariance matrix.
static SZUtil::ParameterVector getSZParameters(const ParameterVector &helixPar)
Get sz parameters.
static PerigeeUtil::ParameterVector getPerigeeParameters(const ParameterVector &helixPar)
Get helix parameters related to the xy space.
static PerigeeAmbiguity defaultPerigeeAmbiguity()
Initialse a default covariance matrix to zero.
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 HelixUtil::ParameterVector stack(const PerigeeUtil::ParameterVector &perigeePar, const SZUtil::ParameterVector &szPar)
Combine parameters from the xy space and the sz space.
static HelixUtil::ParameterVector reversalSigns()
Getter for the signs which have to be applied to reverse the parameters.
static ParameterVector< N1+N2 > stack(const ParameterVector< N1 > &upperPar, const ParameterVector< N2 > &lowerPar)
Combines two parameter vectors by stacking them over each other.
static ParameterVector reversalSigns()
Getter for the signs which have to be applied to reverse the traversal direction.
static ParameterVector reversalSigns()
Getter for the signs which have to be applied to reverse the parameters.
Definition: SZParameters.h:47
Utility struct to instantiate a couple of helper function related to a set of uncertain parameters.