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.
 
TrackingUtilities::CDCTrajectory2D fit (const CDCObservations2D &observations2D) const
 Fits a collection of observation drift circles.
 
TrackingUtilities::CDCTrajectory2D fit (CDCObservations2D &&observations2D) const
 Fits a collection of observation drift circles.
 
TrackingUtilities::CDCTrajectory2D fit (const TrackingUtilities::CDCTrack &track) const
 Fits the track.
 
TrackingUtilities::CDCTrajectory2D fit (const TrackingUtilities::CDCSegment3D &segment) const
 Fits the segment.
 
TrackingUtilities::CDCTrajectory2D fit (const TrackingUtilities::CDCSegment2D &fromSegment, const TrackingUtilities::CDCSegment2D &toSegment) const
 Fits to the two segments.
 
TrackingUtilities::CDCTrajectory2D fit (const TrackingUtilities::CDCSegment2D &segment) const
 Fits the segment.
 
TrackingUtilities::CDCTrajectory2D fit (const std::vector< const TrackingUtilities::CDCWireHit * > &wireHit) const
 Fits to the wire hit observations.
 
TrackingUtilities::CDCTrajectory2D fit (const std::vector< const CDC::CDCWire * > &wires) const
 Fits to the wire positions. Explicit specialisation to be used from python.
 
TrackingUtilities::CDCTrajectory2D fit (const TrackingUtilities::CDCWireHitSegment &wireHits) const
 Fits to the wire positions. Explicit specialisation to be used from python.
 
void update (TrackingUtilities::CDCTrajectory2D &trajectory2D, const CDCObservations2D &observations2D) const
 Update the trajectory with a fit to the observations.
 
void update (TrackingUtilities::CDCTrajectory2D &trajectory2D, CDCObservations2D &&observations2D) const
 Update the trajectory with a fit to the observations.
 
void update (TrackingUtilities::CDCTrajectory2D &trajectory2D, const TrackingUtilities::CDCSegment2D &segment) const
 Updates the given trajectory inplace from the given segment.
 
void update (TrackingUtilities::CDCTrajectory2D &trajectory2D, const TrackingUtilities::CDCAxialSegmentPair &axialSegmentPair) const
 Updates the given trajectory inplace from the given segment pair.
 
void update (TrackingUtilities::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

TrackingUtilities::CDCTrajectory2D fitGeneric (const AHits &hits) const
 Fits a collection of hit typs which are convertible to observation circles.
 
TrackingUtilities::CDCTrajectory2D fitGeneric (const AStartHits &startHits, const AEndHits &endHits) const
 Fits together two collections of hit types which are convertible to observation circles.
 
void updateGeneric (TrackingUtilities::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 (TrackingUtilities::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.
 
TrackingUtilities::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]

TrackingUtilities::CDCTrajectory2D fit ( CDCObservations2D && observations2D) const
inherited

Fits a collection of observation drift circles.

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

45 {
46 TrackingUtilities::CDCTrajectory2D result;
47 update(result, observations2D);
48 return result;
49 }

◆ fit() [2/9]

TrackingUtilities::CDCTrajectory2D fit ( const CDCObservations2D & observations2D) const
inherited

Fits a collection of observation drift circles.

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

39 {
40 return fit(CDCObservations2D(observations2D));
41 }

◆ fit() [3/9]

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

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

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

91 {
92 return fitGeneric(wires);
93 }

◆ fit() [4/9]

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

Fits to the wire hit observations.

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

85 {
86 return fitGeneric(wireHits);
87 }

◆ fit() [5/9]

TrackingUtilities::CDCTrajectory2D fit ( const TrackingUtilities::CDCSegment2D & fromSegment,
const TrackingUtilities::CDCSegment2D & toSegment ) const
inherited

Fits to the two segments.

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

104 {
105 return fitGeneric(fromSegment, toSegment);
106 }

◆ fit() [6/9]

Fits the segment.

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

78 {
79 return fitGeneric(segment);
80 }

◆ fit() [7/9]

Fits the segment.

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

72 {
73 return fitGeneric(segment);
74 }

◆ fit() [8/9]

Fits the track.

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

66 {
67 return fitGeneric(track);
68 }

◆ fit() [9/9]

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

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

97 {
98 return fitGeneric(wireHits);
99 }

◆ fitGeneric() [1/2]

TrackingUtilities::CDCTrajectory2D fitGeneric ( const AHits & hits) const
privateinherited

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

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

125 {
126 TrackingUtilities::CDCTrajectory2D result;
127 updateGeneric(result, hits);
128 return result;
129 }

◆ fitGeneric() [2/2]

TrackingUtilities::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 92 of file CDCFitter2D.icc.h.

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

◆ fitInternal()

UncertainPerigeeCircle fitInternal ( CDCObservations2D & observations2D) const
privateinherited

Internal method doing the heavy work.

Definition at line 296 of file ExtendedRiemannsMethod.cc.

297{
298 using namespace NParabolicParameterIndices;
299
300 // Matrix of weighted sums
301 Eigen::Matrix< double, 5, 5 > s = getWXYRLSumMatrix(observations2D);
302
303 // The same as above without drift lengths
304 Eigen::Matrix<double, 4, 4> sNoL = s.block<4, 4>(0, 0);
305
306 // Determine NDF : Circle fit eats up to 3 degrees of freedom depending on the constraints
307 size_t ndf = observations2D.size() - 1;
308
309 if (not isOriginConstrained()) {
310 --ndf;
311 }
312
313 if (not isLineConstrained()) {
314 --ndf;
315 }
316
317 // Parameters to be fitted
318 UncertainPerigeeCircle resultCircle;
319 double chi2 = 0;
320
321 size_t nObservationsWithDriftRadius = observations2D.getNObservationsWithDriftRadius();
322 if (nObservationsWithDriftRadius > 0) {
323 resultCircle = UncertainPerigeeCircle(::fit(s, isLineConstrained(), isOriginConstrained()));
324 chi2 = calcChi2(resultCircle, s);
325 } else {
326 if (not isOriginConstrained()) {
327 // Alternative implementation for comparison
328
329 // Matrix of averages
330 Eigen::Matrix< double, 4, 4> aNoL = sNoL / sNoL(iW);
331
332 // Measurement means
333 Eigen::Matrix< double, 4, 1> meansNoL = aNoL.row(iW);
334
335 // Covariance matrix
336 Eigen::Matrix< double, 4, 4> cNoL = aNoL - meansNoL * meansNoL.transpose();
337
338 resultCircle = UncertainPerigeeCircle(fitSeperateOffset(meansNoL, cNoL, isLineConstrained()));
339
340 } else {
341 resultCircle = UncertainPerigeeCircle(::fit(sNoL, isLineConstrained(), isOriginConstrained()));
342 }
343
344 chi2 = calcChi2(resultCircle, sNoL);
345 }
346
347 // Covariance calculation does not need the drift lengths, which is why we do not forward them.
348 PerigeePrecision perigeePrecision =
349 calcPrecision(resultCircle, sNoL, isLineConstrained(), isOriginConstrained());
350
351 // Use in pivoting in case the matrix is not full rank as it is for the constrained cases
352 PerigeeCovariance perigeeCovariance = PerigeeUtil::covarianceFromPrecision(perigeePrecision);
353
354 resultCircle.setNDF(ndf);
355 resultCircle.setChi2(chi2);
356 resultCircle.setPerigeeCovariance(perigeeCovariance);
357 return resultCircle;
358}
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.
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.

◆ 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}

◆ 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 42 of file ExtendedRiemannsMethod.h.

43 {
44 return m_lineConstrained;
45 }

◆ isOriginConstrained()

bool isOriginConstrained ( ) const
inlineinherited

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

Definition at line 48 of file ExtendedRiemannsMethod.h.

49 {
50 return m_originConstrained;
51 }

◆ setFitVariance()

void setFitVariance ( EFitVariance fitVariance)
inherited

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

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

222 {
223 m_fitVariance = fitVariance;
224 }

◆ setLineConstrained()

void setLineConstrained ( bool constrained = true)
inlineinherited

Indicator if this fitter is setup to fit lines.

Definition at line 54 of file ExtendedRiemannsMethod.h.

55 {
56 m_lineConstrained = constrained;
57 }

◆ setOriginConstrained()

void setOriginConstrained ( bool constrained = true)
inlineinherited

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

Definition at line 60 of file ExtendedRiemannsMethod.h.

61 {
62 m_originConstrained = constrained;
63 }

◆ update() [1/5]

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

Update the trajectory with a fit to the observations.

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

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

◆ update() [2/5]

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

Update the trajectory with a fit to the observations.

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

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

◆ update() [3/5]

void update ( TrackingUtilities::CDCTrajectory2D & trajectory2D,
const TrackingUtilities::CDCAxialSegmentPair & axialSegmentPair ) const
inherited

Updates the given trajectory inplace from the given segment pair.

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

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

◆ update() [4/5]

void update ( TrackingUtilities::CDCTrajectory2D & trajectory2D,
const TrackingUtilities::CDCSegment2D & segment ) const
inherited

Updates the given trajectory inplace from the given segment.

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

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

◆ update() [5/5]

void update ( TrackingUtilities::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 36 of file ExtendedRiemannsMethod.cc.

38{
39 size_t nObservations = observations2D.size();
40 trajectory2D.clear();
41 if (not nObservations) return;
42
43 Vector2D origin = Vector2D(0.0, 0.0);
44 Vector2D centralPoint = observations2D.getCentralPoint();
45
46 const Vector2D& ref = isOriginConstrained() ? origin : centralPoint;
47 observations2D.passiveMoveBy(ref);
48
49 UncertainPerigeeCircle perigeeCircle = fitInternal(observations2D);
50
51 double frontX = observations2D.getX(0);
52 double frontY = observations2D.getY(0);
53 Vector2D frontPos(frontX, frontY);
54
55 double backX = observations2D.getX(nObservations - 1);
56 double backY = observations2D.getY(nObservations - 1);
57 Vector2D backPos(backX, backY);
58
59 Vector2D overPos(0, 0);
60 double totalPerps = (perigeeCircle->arcLengthBetween(frontPos, overPos) +
61 perigeeCircle->arcLengthBetween(overPos, backPos));
62
63 if (totalPerps < 0) {
64 perigeeCircle.reverse();
65 }
66
67 trajectory2D = CDCTrajectory2D(ref, perigeeCircle);
68}
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.
TrackingUtilities::Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
void passiveMoveBy(const TrackingUtilities::Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
TrackingUtilities::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.

◆ updateGeneric() [1/2]

void updateGeneric ( TrackingUtilities::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 99 of file CDCFitter2D.icc.h.

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

◆ updateGeneric() [2/2]

void updateGeneric ( TrackingUtilities::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 106 of file CDCFitter2D.icc.h.

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

◆ useOnlyOrientation()

void useOnlyOrientation ( )
inherited

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

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

208 {
209 m_usePosition = false;
210 m_useOrientation = true;
211 }

◆ useOnlyPosition()

void useOnlyPosition ( )
inherited

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

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

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

◆ 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 121 of file CDCFitter2D.icc.h.

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

Member Data Documentation

◆ m_fitVariance

EFitVariance m_fitVariance
privateinherited

Default variance to be used in the fit.

Definition at line 134 of file CDCFitter2D.h.

◆ m_lineConstrained

bool m_lineConstrained
privateinherited

Memory for the flag indicating that lines should be fitted.

Definition at line 67 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 70 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 131 of file CDCFitter2D.h.

◆ m_usePosition

bool m_usePosition
privateinherited

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

Definition at line 128 of file CDCFitter2D.h.


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