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