Belle II Software development
CDCRiemannFitter Class Reference

Class implementing the Riemann fit for two dimensional trajectory circle. More...

#include <CDCRiemannFitter.h>

Inheritance diagram for CDCRiemannFitter:
CDCFitter2D< Belle2::TrackFindingCDC::ExtendedRiemannsMethod > ExtendedRiemannsMethod

Public Member Functions

 CDCRiemannFitter ()
 Default constructor.
 
 ~CDCRiemannFitter ()
 Default destructor.
 
CDCTrajectory2D fit (const CDCObservations2D &observations2D) const
 Fits a collection of observation drift circles.
 
CDCTrajectory2D fit (CDCObservations2D &&observations2D) const
 Fits a collection of observation drift circles.
 
CDCTrajectory2D fit (const CDCTrack &track) const
 Fits the track.
 
CDCTrajectory2D fit (const CDCSegment3D &segment) const
 Fits the segment.
 
CDCTrajectory2D fit (const CDCSegment2D &fromSegment, const CDCSegment2D &toSegment) const
 Fits to the two segments.
 
CDCTrajectory2D fit (const CDCSegment2D &segment) const
 Fits the segment.
 
CDCTrajectory2D fit (const std::vector< const CDCWireHit * > &wireHit) const
 Fits to the wire hit observations.
 
CDCTrajectory2D fit (const std::vector< const CDCWire * > &wires) const
 Fits to the wire positions. Explicit specialisation to be used from python.
 
CDCTrajectory2D fit (const CDCWireHitSegment &wireHits) const
 Fits to the wire positions. Explicit specialisation to be used from python.
 
void update (CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
 Update the trajectory with a fit to the observations.
 
void update (CDCTrajectory2D &trajectory2D, CDCObservations2D &&observations2D) const
 Update the trajectory with a fit to the observations.
 
void update (CDCTrajectory2D &trajectory2D, const CDCSegment2D &segment) const
 Updates the given trajectory inplace from the given segment.
 
void update (CDCTrajectory2D &trajectory2D, const CDCAxialSegmentPair &axialSegmentPair) const
 Updates the given trajectory inplace from the given segment pair.
 
void update (CDCTrajectory2D &trajectory2D, CDCObservations2D &observations2D) const
 Executes the fit and updates the trajectory parameters This may render the information in the observation object.
 
void useOnlyPosition ()
 Setup the fitter to use only the reconstructed positions of the hits.
 
void useOnlyOrientation ()
 Setup the fitter to use only reference position and the drift length with right left orientation.
 
void usePositionAndOrientation ()
 Setup the fitter to use both the reconstructed position and the reference position and the drift length with right left orientation.
 
void setFitVariance (EFitVariance fitVariance)
 Setup the fitter to use the given variance measure by default.
 
bool isLineConstrained () const
 Getter for the indicator that lines should be fitted by this fitter.
 
bool isOriginConstrained () const
 Getter for the indicator that curves through the origin should be fitted by this fitter.
 
void setLineConstrained (bool constrained=true)
 Indicator if this fitter is setup to fit lines.
 
void setOriginConstrained (bool constrained=true)
 Indicator if this fitter is setup to fit curves through the origin.
 

Static Public Member Functions

static const CDCRiemannFittergetFitter ()
 Static getter for a general Riemann fitter.
 
static const CDCRiemannFittergetFitter (bool fromOrigin, bool line)
 Static getter for a given Riemann fitter.
 
static const CDCRiemannFittergetLineFitter ()
 Static getter for a line fitter.
 
static const CDCRiemannFittergetOriginCircleFitter ()
 Static getter for an origin circle fitter.
 

Private Member Functions

CDCTrajectory2D fitGeneric (const AHits &hits) const
 Fits a collection of hit typs which are convertible to observation circles.
 
CDCTrajectory2D fitGeneric (const AStartHits &startHits, const AEndHits &endHits) const
 Fits together two collections of hit types which are convertible to observation circles.
 
void updateGeneric (CDCTrajectory2D &trajectory2D, const AHits &hits) const
 Updates a given trajectory with a fit to a collection of hits types, which are convertible to observation circles.
 
void updateGeneric (CDCTrajectory2D &trajectory2D, const AStartHits &startHits, const AEndHits &endHits) const
 Updates a given trajectory with a fit to two collection of hit types, which are convertible to observation circles.
 
UncertainPerigeeCircle fitInternal (CDCObservations2D &observations2D) const
 Internal method doing the heavy work.
 

Private Attributes

bool m_usePosition
 Flag indicating the reconstructed position shall be used in the fit.
 
bool m_useOrientation
 Flag indicating the reference position and drift length with right left orientation shall be used in the fit.
 
EFitVariance m_fitVariance
 Default variance to be used in the fit.
 
bool m_lineConstrained
 Memory for the flag indicating that lines should be fitted.
 
bool m_originConstrained
 Memory for the flag indicating that curves through the origin shall be fitter.
 

Detailed Description

Class implementing the Riemann fit for two dimensional trajectory circle.

Definition at line 24 of file CDCRiemannFitter.h.

Member Function Documentation

◆ fit() [1/9]

CDCTrajectory2D fit ( CDCObservations2D &&  observations2D) const
inherited

Fits a collection of observation drift circles.

Definition at line 46 of file CDCFitter2D.icc.h.

45 {
46 CDCTrajectory2D result;
47 update(result, observations2D);
48 return result;
49 }
void update(CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
Update the trajectory with a fit to the observations.

◆ fit() [2/9]

CDCTrajectory2D fit ( const CDCObservations2D observations2D) const
inherited

Fits a collection of observation drift circles.

Definition at line 43 of file CDCFitter2D.icc.h.

39 {
40 return fit(CDCObservations2D(observations2D));
41 }
CDCTrajectory2D fit(const CDCObservations2D &observations2D) const
Fits a collection of observation drift circles.

◆ fit() [3/9]

CDCTrajectory2D fit ( const CDCSegment2D fromSegment,
const CDCSegment2D toSegment 
) const
inherited

Fits to the two segments.

Definition at line 61 of file CDCFitter2D.icc.h.

103 {
104 return fitGeneric(fromSegment, toSegment);
105 }
CDCTrajectory2D fitGeneric(const AHits &hits) const
Fits a collection of hit typs which are convertible to observation circles.

◆ fit() [4/9]

CDCTrajectory2D fit ( const CDCSegment2D segment) const
inherited

Fits the segment.

Definition at line 64 of file CDCFitter2D.icc.h.

78 {
79 return fitGeneric(segment);
80 }

◆ fit() [5/9]

CDCTrajectory2D fit ( const CDCSegment3D segment) const
inherited

Fits the segment.

Definition at line 58 of file CDCFitter2D.icc.h.

72 {
73 return fitGeneric(segment);
74 }

◆ fit() [6/9]

CDCTrajectory2D fit ( const CDCTrack track) const
inherited

Fits the track.

Definition at line 55 of file CDCFitter2D.icc.h.

66 {
67 return fitGeneric(track);
68 }

◆ fit() [7/9]

CDCTrajectory2D fit ( const CDCWireHitSegment wireHits) const
inherited

Fits to the wire positions. Explicit specialisation to be used from python.

Definition at line 73 of file CDCFitter2D.icc.h.

96 {
97 return fitGeneric(wireHits);
98 }

◆ fit() [8/9]

CDCTrajectory2D fit ( const std::vector< const CDCWire * > &  wires) const
inherited

Fits to the wire positions. Explicit specialisation to be used from python.

Definition at line 70 of file CDCFitter2D.icc.h.

90 {
91 return fitGeneric(wires);
92 }

◆ fit() [9/9]

CDCTrajectory2D fit ( const std::vector< const CDCWireHit * > &  wireHit) const
inherited

Fits to the wire hit observations.

Definition at line 67 of file CDCFitter2D.icc.h.

84 {
85 return fitGeneric(wireHits);
86 }

◆ fitGeneric() [1/2]

CDCTrajectory2D fitGeneric ( const AHits &  hits) const
privateinherited

Fits a collection of hit typs which are convertible to observation circles.

Definition at line 84 of file CDCFitter2D.icc.h.

124 {
125 CDCTrajectory2D result;
126 updateGeneric(result, hits);
127 return result;
128 }
void updateGeneric(CDCTrajectory2D &trajectory2D, const AHits &hits) const
Updates a given trajectory with a fit to a collection of hits types, which are convertible to observa...

◆ fitGeneric() [2/2]

CDCTrajectory2D fitGeneric ( const AStartHits &  startHits,
const AEndHits &  endHits 
) const
privateinherited

Fits together two collections of hit types which are convertible to observation circles.

Definition at line 88 of file CDCFitter2D.icc.h.

134 {
135 CDCTrajectory2D result;
136 updateGeneric(result, startHits, endHits);
137 return result;
138 }

◆ fitInternal()

UncertainPerigeeCircle fitInternal ( CDCObservations2D observations2D) const
privateinherited

Internal method doing the heavy work.

Definition at line 294 of file ExtendedRiemannsMethod.cc.

295{
296 using namespace NParabolicParameterIndices;
297
298 // Matrix of weighted sums
299 Eigen::Matrix< double, 5, 5 > s = getWXYRLSumMatrix(observations2D);
300
301 // The same as above without drift lengths
302 Eigen::Matrix<double, 4, 4> sNoL = s.block<4, 4>(0, 0);
303
304 // Determine NDF : Circle fit eats up to 3 degrees of freedom depending on the constraints
305 size_t ndf = observations2D.size() - 1;
306
307 if (not isOriginConstrained()) {
308 --ndf;
309 }
310
311 if (not isLineConstrained()) {
312 --ndf;
313 }
314
315 // Parameters to be fitted
316 UncertainPerigeeCircle resultCircle;
317 double chi2 = 0;
318
319 size_t nObservationsWithDriftRadius = observations2D.getNObservationsWithDriftRadius();
320 if (nObservationsWithDriftRadius > 0) {
321 resultCircle = UncertainPerigeeCircle(::fit(s, isLineConstrained(), isOriginConstrained()));
322 chi2 = calcChi2(resultCircle, s);
323 } else {
324 if (not isOriginConstrained()) {
325 // Alternative implementation for comparison
326
327 // Matrix of averages
328 Eigen::Matrix< double, 4, 4> aNoL = sNoL / sNoL(iW);
329
330 // Measurement means
331 Eigen::Matrix< double, 4, 1> meansNoL = aNoL.row(iW);
332
333 // Covariance matrix
334 Eigen::Matrix< double, 4, 4> cNoL = aNoL - meansNoL * meansNoL.transpose();
335
336 resultCircle = UncertainPerigeeCircle(fitSeperateOffset(meansNoL, cNoL, isLineConstrained()));
337
338 } else {
339 resultCircle = UncertainPerigeeCircle(::fit(sNoL, isLineConstrained(), isOriginConstrained()));
340 }
341
342 chi2 = calcChi2(resultCircle, sNoL);
343 }
344
345 // Covariance calculation does not need the drift lengths, which is why we do not forward them.
346 PerigeePrecision perigeePrecision =
347 calcPrecision(resultCircle, sNoL, isLineConstrained(), isOriginConstrained());
348
349 // Use in pivoting in case the matrix is not full rank as it is for the constrained cases
350 PerigeeCovariance perigeeCovariance = PerigeeUtil::covarianceFromPrecision(perigeePrecision);
351
352 resultCircle.setNDF(ndf);
353 resultCircle.setChi2(chi2);
354 resultCircle.setPerigeeCovariance(perigeeCovariance);
355 return resultCircle;
356}
std::size_t size() const
Returns the number of observations stored.
std::size_t getNObservationsWithDriftRadius() const
Returns the number of observations having a drift radius radius.
bool isLineConstrained() const
Getter for the indicator that lines should be fitted by this fitter.
bool isOriginConstrained() const
Getter for the indicator that curves through the origin should be fitted by this fitter.
A matrix implementation to be used as an interface typ through out the track finder.
Definition: PlainMatrix.h:40
Adds an uncertainty matrix to the circle in perigee parameterisation.
void setPerigeeCovariance(const PerigeeCovariance &perigeeCovariance)
Setter for the whole covariance matrix of the perigee parameters.
void setNDF(std::size_t ndf)
Setter for the number of degrees of freediom used in the circle fit.
void setChi2(const double chi2)
Setter for the chi square value of the circle fit.
Namespace to hide the contained enum constants.
static CovarianceMatrix covarianceFromPrecision(const PrecisionMatrix &prec)
Convert the precision matrix to the corresponding covariance matrix.

◆ getFitter() [1/2]

const CDCRiemannFitter & getFitter ( )
static

Static getter for a general Riemann fitter.

Definition at line 20 of file CDCRiemannFitter.cc.

21{
22 static CDCRiemannFitter fitter;
23 return fitter;
24}
Class implementing the Riemann fit for two dimensional trajectory circle.

◆ getFitter() [2/2]

const CDCRiemannFitter & getFitter ( bool  fromOrigin,
bool  line 
)
static

Static getter for a given Riemann fitter.

Definition at line 26 of file CDCRiemannFitter.cc.

27{
28 static CDCRiemannFitter fitter;
29 if (fromOrigin) fitter.setOriginConstrained();
30 if (line) fitter.setLineConstrained();
31 return fitter;
32}

◆ getLineFitter()

const CDCRiemannFitter & getLineFitter ( )
static

Static getter for a line fitter.

Definition at line 34 of file CDCRiemannFitter.cc.

35{
36 static CDCRiemannFitter lineFitter;
37 lineFitter.setLineConstrained();
38 return lineFitter;
39}
void setLineConstrained(bool constrained=true)
Indicator if this fitter is setup to fit lines.

◆ getOriginCircleFitter()

const CDCRiemannFitter & getOriginCircleFitter ( )
static

Static getter for an origin circle fitter.

Definition at line 41 of file CDCRiemannFitter.cc.

42{
43 static CDCRiemannFitter originCircleFitter;
44 originCircleFitter.setOriginConstrained();
45 return originCircleFitter;
46}
void setOriginConstrained(bool constrained=true)
Indicator if this fitter is setup to fit curves through the origin.

◆ isLineConstrained()

bool isLineConstrained ( ) const
inlineinherited

Getter for the indicator that lines should be fitted by this fitter.

Definition at line 39 of file ExtendedRiemannsMethod.h.

40 {
41 return m_lineConstrained;
42 }
bool m_lineConstrained
Memory for the flag indicating that lines should be fitted.

◆ isOriginConstrained()

bool isOriginConstrained ( ) const
inlineinherited

Getter for the indicator that curves through the origin should be fitted by this fitter.

Definition at line 45 of file ExtendedRiemannsMethod.h.

46 {
48 }
bool m_originConstrained
Memory for the flag indicating that curves through the origin shall be fitter.

◆ setFitVariance()

void setFitVariance ( EFitVariance  fitVariance)
inherited

Setup the fitter to use the given variance measure by default.

Definition at line 120 of file CDCFitter2D.icc.h.

221 {
222 m_fitVariance = fitVariance;
223 }

◆ setLineConstrained()

void setLineConstrained ( bool  constrained = true)
inlineinherited

Indicator if this fitter is setup to fit lines.

Definition at line 51 of file ExtendedRiemannsMethod.h.

52 {
53 m_lineConstrained = constrained;
54 }

◆ setOriginConstrained()

void setOriginConstrained ( bool  constrained = true)
inlineinherited

Indicator if this fitter is setup to fit curves through the origin.

Definition at line 57 of file ExtendedRiemannsMethod.h.

58 {
59 m_originConstrained = constrained;
60 }

◆ update() [1/5]

void update ( CDCTrajectory2D trajectory2D,
CDCObservations2D &&  observations2D 
) const
inherited

Update the trajectory with a fit to the observations.

Definition at line 52 of file CDCFitter2D.icc.h.

60 {
61 AFitMethod::update(trajectory2D, observations2D);
62 }

◆ update() [2/5]

void update ( CDCTrajectory2D trajectory2D,
CDCObservations2D observations2D 
) const
inherited

Executes the fit and updates the trajectory parameters This may render the information in the observation object.

Definition at line 34 of file ExtendedRiemannsMethod.cc.

36{
37 size_t nObservations = observations2D.size();
38 trajectory2D.clear();
39 if (not nObservations) return;
40
41 Vector2D origin = Vector2D(0.0, 0.0);
42 Vector2D centralPoint = observations2D.getCentralPoint();
43
44 const Vector2D& ref = isOriginConstrained() ? origin : centralPoint;
45 observations2D.passiveMoveBy(ref);
46
47 UncertainPerigeeCircle perigeeCircle = fitInternal(observations2D);
48
49 double frontX = observations2D.getX(0);
50 double frontY = observations2D.getY(0);
51 Vector2D frontPos(frontX, frontY);
52
53 double backX = observations2D.getX(nObservations - 1);
54 double backY = observations2D.getY(nObservations - 1);
55 Vector2D backPos(backX, backY);
56
57 Vector2D overPos(0, 0);
58 double totalPerps = (perigeeCircle->arcLengthBetween(frontPos, overPos) +
59 perigeeCircle->arcLengthBetween(overPos, backPos));
60
61 if (totalPerps < 0) {
62 perigeeCircle.reverse();
63 }
64
65 trajectory2D = CDCTrajectory2D(ref, perigeeCircle);
66}
double getX(int iObservation) const
Getter for the x value of the observation at the given index.
double getY(int iObservation) const
Getter for the y value of the observation at the given index.
Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
void passiveMoveBy(const Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
Particle trajectory as it is seen in xy projection represented as a circle.
void clear()
Clears all information from this trajectory.
UncertainPerigeeCircle fitInternal(CDCObservations2D &observations2D) const
Internal method doing the heavy work.
double arcLengthBetween(const Vector2D &from, const Vector2D &to) const
Calculates the arc length between two points of closest approach on the circle.
void reverse()
Flips the orientation of the circle in place.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32

◆ update() [3/5]

void update ( CDCTrajectory2D trajectory2D,
const CDCAxialSegmentPair axialSegmentPair 
) const
inherited

Updates the given trajectory inplace from the given segment pair.

Definition at line 79 of file CDCFitter2D.icc.h.

117 {
118 return updateGeneric(trajectory2D, axialSegmentPair);
119 }

◆ update() [4/5]

void update ( CDCTrajectory2D trajectory2D,
const CDCObservations2D observations2D 
) const
inherited

Update the trajectory with a fit to the observations.

Definition at line 49 of file CDCFitter2D.icc.h.

54 {
55 return update(trajectory2D, CDCObservations2D(observations2D));
56 }

◆ update() [5/5]

void update ( CDCTrajectory2D trajectory2D,
const CDCSegment2D segment 
) const
inherited

Updates the given trajectory inplace from the given segment.

Definition at line 76 of file CDCFitter2D.icc.h.

110 {
111 updateGeneric(trajectory2D, segment);
112 }

◆ updateGeneric() [1/2]

void updateGeneric ( CDCTrajectory2D trajectory2D,
const AHits &  hits 
) const
privateinherited

Updates a given trajectory with a fit to a collection of hits types, which are convertible to observation circles.

Definition at line 95 of file CDCFitter2D.icc.h.

178 {
179 CDCObservations2D observations2D;
180 observations2D.setFitVariance(m_fitVariance);
181
182 if (m_usePosition) {
183 observations2D.setFitPos(EFitPos::c_RecoPos);
184 observations2D.appendRange(hits);
185 }
186 if (m_useOrientation) {
187 observations2D.setFitPos(EFitPos::c_RLDriftCircle);
188 observations2D.appendRange(hits);
189 }
190
191 if (observations2D.size() < 4) {
192 trajectory2D.clear();
193 } else {
194 AFitMethod::update(trajectory2D, observations2D);
195 }
196 }

◆ updateGeneric() [2/2]

void updateGeneric ( CDCTrajectory2D trajectory2D,
const AStartHits &  startHits,
const AEndHits &  endHits 
) const
privateinherited

Updates a given trajectory with a fit to two collection of hit types, which are convertible to observation circles.

Definition at line 102 of file CDCFitter2D.icc.h.

145 {
146 CDCObservations2D observations2D;
147 observations2D.setFitVariance(m_fitVariance);
148
149 if (m_usePosition) {
150 observations2D.setFitPos(EFitPos::c_RecoPos);
151 observations2D.appendRange(startHits);
152 }
153 if (m_useOrientation) {
154 observations2D.setFitPos(EFitPos::c_RLDriftCircle);
155 observations2D.appendRange(startHits);
156 }
157
158 if (m_usePosition) {
159 observations2D.setFitPos(EFitPos::c_RecoPos);
160 observations2D.appendRange(endHits);
161 }
162 if (m_useOrientation) {
163 observations2D.setFitPos(EFitPos::c_RLDriftCircle);
164 observations2D.appendRange(endHits);
165 }
166
167 if (observations2D.size() < 4) {
168 trajectory2D.clear();
169 } else {
170 AFitMethod::update(trajectory2D, observations2D);
171 }
172 }

◆ useOnlyOrientation()

void useOnlyOrientation
inherited

Setup the fitter to use only reference position and the drift length with right left orientation.

Definition at line 114 of file CDCFitter2D.icc.h.

207 {
208 m_usePosition = false;
209 m_useOrientation = true;
210 }
bool m_useOrientation
Flag indicating the reference position and drift length with right left orientation shall be used in ...
Definition: CDCFitter2D.h:127
bool m_usePosition
Flag indicating the reconstructed position shall be used in the fit.
Definition: CDCFitter2D.h:124

◆ useOnlyPosition()

void useOnlyPosition
inherited

Setup the fitter to use only the reconstructed positions of the hits.

Definition at line 111 of file CDCFitter2D.icc.h.

200 {
201 m_usePosition = true;
202 m_useOrientation = false;
203 }

◆ usePositionAndOrientation()

void usePositionAndOrientation
inherited

Setup the fitter to use both the reconstructed position and the reference position and the drift length with right left orientation.

Definition at line 117 of file CDCFitter2D.icc.h.

214 {
215 m_usePosition = true;
216 m_useOrientation = true;
217 }

Member Data Documentation

◆ m_fitVariance

EFitVariance m_fitVariance
privateinherited

Default variance to be used in the fit.

Definition at line 130 of file CDCFitter2D.h.

◆ m_lineConstrained

bool m_lineConstrained
privateinherited

Memory for the flag indicating that lines should be fitted.

Definition at line 64 of file ExtendedRiemannsMethod.h.

◆ m_originConstrained

bool m_originConstrained
privateinherited

Memory for the flag indicating that curves through the origin shall be fitter.

Definition at line 67 of file ExtendedRiemannsMethod.h.

◆ m_useOrientation

bool m_useOrientation
privateinherited

Flag indicating the reference position and drift length with right left orientation shall be used in the fit.

Definition at line 127 of file CDCFitter2D.h.

◆ m_usePosition

bool m_usePosition
privateinherited

Flag indicating the reconstructed position shall be used in the fit.

Definition at line 124 of file CDCFitter2D.h.


The documentation for this class was generated from the following files: