Belle II Software development
FitSegmentRelationVarSet.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/filters/segmentRelation/FitSegmentRelationVarSet.h>
9
10#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
11
12#include <tracking/trackFindingCDC/fitting/CDCRiemannFitter.h>
13
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
18{
19 if (not ptrSegmentRelation) return false;
20
21 const CDCSegment2D* fromSegment = ptrSegmentRelation->first;
22 const CDCSegment2D* toSegment = ptrSegmentRelation->second;
23
24 const CDCRiemannFitter& riemannFitter = CDCRiemannFitter::getFitter();
25
26 CDCTrajectory2D commonTrajectory2D = riemannFitter.fit(*fromSegment, *toSegment);
27
28 double noRLChi2 = 0;
29 for (const CDCRecoHit2D& recoHit2D : *fromSegment) {
30 double dist = std::fabs(commonTrajectory2D.getDist2D(recoHit2D.getRefPos2D())) - recoHit2D.getRefDriftLength();
31 noRLChi2 += dist * dist / recoHit2D.getRefDriftLengthVariance();
32 }
33 for (const CDCRecoHit2D& recoHit2D : *toSegment) {
34 double dist = std::fabs(commonTrajectory2D.getDist2D(recoHit2D.getRefPos2D())) - recoHit2D.getRefDriftLength();
35 noRLChi2 += dist * dist / recoHit2D.getRefDriftLengthVariance();
36 }
37
38 finitevar<named("is_fitted")>() = commonTrajectory2D.isFitted();
39 finitevar<named("curv")>() = commonTrajectory2D.getCurvature();
40
41 using namespace NPerigeeParameterIndices;
42 finitevar<named("curv_var")>() = commonTrajectory2D.getLocalVariance(c_Curv);
43
44 finitevar<named("chi2")>() = std::fabs(commonTrajectory2D.getChi2());
45 finitevar<named("chi2_no_rl")>() = noRLChi2;
46 finitevar<named("chi2_per_ndf")>() = std::fabs(commonTrajectory2D.getChi2() / commonTrajectory2D.getNDF());
47 finitevar<named("chi2_no_rl_per_ndf")>() = noRLChi2 / commonTrajectory2D.getNDF();
48 finitevar<named("ndf")>() = commonTrajectory2D.getNDF();
49 finitevar<named("p_value")>() = commonTrajectory2D.getPValue();
50 return true;
51}
CDCTrajectory2D fit(const CDCObservations2D &observations2D) const
Fits a collection of observation drift circles.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
Class implementing the Riemann fit for two dimensional trajectory circle.
static const CDCRiemannFitter & getFitter()
Static getter for a general Riemann fitter.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Particle trajectory as it is seen in xy projection represented as a circle.
double getChi2() const
Getter for the chi2 value of the circle fit.
double getPValue() const
Getter for p-value.
bool isFitted() const
Checks if the circle is already set to a valid value.
double getLocalVariance(EPerigeeParameter i) const
Getter for an individual diagonal element of the covariance matrix of the local helix parameters.
size_t getNDF() const
Getter for the number of degrees of freedom of the circle fit.
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) final
Generate and assign the contained variables.
Type for two related objects.
Definition: Relation.h:21
AssignFinite< Float_t > finitevar()
Reference getter for the value of the ith variable. Transforms non-finite values to finite value.
Definition: VarSet.h:130
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Abstract base class for different kinds of events.