Belle II Software development
FitFacetVarSet.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/facet/FitFacetVarSet.h>
9
10#include <tracking/trackFindingCDC/fitting/FacetFitter.h>
11
12#include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
13#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14
15#include <tracking/trackFindingCDC/numerics/Quadratic.h>
16
17using namespace Belle2;
18using namespace TrackFindingCDC;
19
20bool FitFacetVarSet::extract(const CDCFacet* ptrFacet)
21{
22 if (not ptrFacet) return false;
23 const CDCFacet& facet = *ptrFacet;
24
25 const Vector2D startWirePos2D = facet.getStartWireHit().getRefPos2D();
26 const Vector2D middleWirePos2D = facet.getMiddleWireHit().getRefPos2D();
27 const Vector2D endWirePos2D = facet.getEndWireHit().getRefPos2D();
28
29 // 0 step fit
30 {
31 constexpr const int nSteps = 0;
32 const double chi2_0 = FacetFitter::fit(facet, nSteps);
33 const UncertainParameterLine2D& fitLine = facet.getFitLine();
34 const double s = fitLine->lengthOnCurve(startWirePos2D, endWirePos2D);
35
36 var<named("chi2_0")>() = chi2_0;
37 var<named("chi2_0_per_s")>() = chi2_0 / s;
38 var<named("fit_0_phi0")>() = fitLine->tangential().phi();
39 var<named("fit_0_phi0_sigma")>() = std::sqrt(fitLine.variance(ELineParameter::c_Phi0));
40 }
41
42 // 1 step fit
43 {
44 constexpr const int nSteps = 1;
45 const double chi2_1 = FacetFitter::fit(facet, nSteps);
46 const UncertainParameterLine2D& fitLine = facet.getFitLine();
47 const double s = fitLine->lengthOnCurve(startWirePos2D, endWirePos2D);
48
49 var<named("chi2_1")>() = chi2_1;
50 var<named("chi2_1_per_s")>() = chi2_1 / s;
51 var<named("fit_1_phi0")>() = fitLine->tangential().phi();
52 var<named("fit_1_phi0_sigma")>() = std::sqrt(fitLine.variance(ELineParameter::c_Phi0));
53 }
54
55 // N step fit
56 {
57 const double chi2 = FacetFitter::fit(facet);
58 const UncertainParameterLine2D& fitLine = facet.getFitLine();
59 const double s = fitLine->lengthOnCurve(startWirePos2D, endWirePos2D);
60
61 var<named("chi2")>() = chi2;
62 var<named("chi2_per_s")>() = chi2 / s;
63
64 // Heuristic flattening functions. Factor is chosen by hand for some experimentation here.
65 constexpr const double erfWidth = 120.0;
66 constexpr const double tanhWidth = 1.64 * erfWidth;
67
68 var<named("erf")>() = std::erf(chi2 / erfWidth);
69 var<named("tanh")>() = std::tanh(chi2 / tanhWidth);
70 var<named("fit_phi0")>() = fitLine->tangential().phi();
71 var<named("fit_phi0_sigma")>() = std::sqrt(fitLine.variance(ELineParameter::c_Phi0));
72
73 const CDCRLWireHit& startRLWireHit = facet.getStartRLWireHit();
74 const CDCRLWireHit& middleRLWireHit = facet.getMiddleRLWireHit();
75 const CDCRLWireHit& endRLWireHit = facet.getEndRLWireHit();
76
77 const double startL = startRLWireHit.getSignedRefDriftLength();
78 const double middleL = middleRLWireHit.getSignedRefDriftLength();
79 const double endL = endRLWireHit.getSignedRefDriftLength();
80
81 const double startDistance = fitLine->distance(startWirePos2D) - startL;
82 const double middleDistance = fitLine->distance(middleWirePos2D) - middleL;
83 const double endDistance = fitLine->distance(endWirePos2D) - endL;
84
85 var<named("start_distance")>() = startDistance;
86 var<named("middle_distance")>() = middleDistance;
87 var<named("end_distance")>() = endDistance;
88 var<named("d2")>() = square(startDistance) + square(middleDistance) + square(endDistance);
89 }
90 return true;
91}
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:32
const UncertainParameterLine2D & getFitLine() const
Getter for the contained line fit information.
Definition: CDCFacet.h:61
const CDCWireHit & getMiddleWireHit() const
Getter for the hit wire of the second oriented wire hit.
CDCRLWireHit & getStartRLWireHit()
Getter for the first oriented wire hit.
const CDCWireHit & getEndWireHit() const
Getter for the hit wire of the third oriented wire hit.
const CDCWireHit & getStartWireHit() const
Getter for the hit wire of the first oriented wire hit.
CDCRLWireHit & getEndRLWireHit()
Getter for the third oriented wire hit.
CDCRLWireHit & getMiddleRLWireHit()
Getter for the second oriented wire hit.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
double getSignedRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:216
const Vector2D & getRefPos2D() const
The two dimensional reference position (z=0) of the underlying wire.
Definition: CDCWireHit.cc:212
static double fit(const CDCFacet &facet, int nSteps=100)
Fits a proper line to facet and returns the chi2.
Definition: FacetFitter.cc:166
bool extract(const CDCFacet *ptrFacet) final
Generate and assign the contained variables.
double distance(const Vector2D &point) const
Gives the signed distance of a point to the line.
const Vector2D & tangential() const
Gives the tangential vector of the line.
double lengthOnCurve(const Vector2D &from, const Vector2D &to) const
Denotes the length on the line between the two points.
A parameter line including including an line covariance matrix which is interpreted as located in the...
double variance(const ELineParameter &i) const
Getter for individual diagonal elements of the covariance matrix.
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:93
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double phi() const
Gives the azimuth angle being the angle to the x axes ( range -M_PI to M_PI )
Definition: Vector2D.h:569
Abstract base class for different kinds of events.