Belle II Software  release-05-01-25
BendFacetVarSet.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/facet/BendFacetVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
13 
14 using namespace Belle2;
15 using namespace TrackFindingCDC;
16 
17 bool BendFacetVarSet::extract(const CDCFacet* ptrFacet)
18 {
19  if (not ptrFacet) return false;
20  const CDCFacet& facet = *ptrFacet;
21 
23  facet.adjustFitLine();
24 
25  const CDCRLWireHit& startRLWirehit = facet.getStartRLWireHit();
26  const double startDriftLengthVar = startRLWirehit.getRefDriftLengthVariance();
27  const double startDriftLengthSigma = sqrt(startDriftLengthVar);
28  const double startWeight = 1.0 / startDriftLengthVar;
29 
30  const CDCRLWireHit& middleRLWirehit = facet.getMiddleRLWireHit();
31  const double middleDriftLengthVar = middleRLWirehit.getRefDriftLengthVariance();
32  const double middleDriftLengthSigma = sqrt(middleDriftLengthVar);
33  const double middleWeight = 1.0 / middleDriftLengthVar;
34 
35  const CDCRLWireHit& endRLWirehit = facet.getEndRLWireHit();
36  const double endDriftLengthVar = endRLWirehit.getRefDriftLengthVariance();
37  const double endDriftLengthSigma = sqrt(endDriftLengthVar);
38  const double endWeight = 1.0 / endDriftLengthVar;
39 
40  const double sumWeight = startWeight + middleWeight + endWeight;
41 
42  const ParameterLine2D& startToMiddleLine = facet.getStartToMiddleLine();
43  const ParameterLine2D& startToEndLine = facet.getStartToEndLine();
44  const ParameterLine2D& middleToEndLine = facet.getMiddleToEndLine();
45 
46  const double startDistance = middleToEndLine.distance(startRLWirehit.getRefPos2D()) - startRLWirehit.getSignedRefDriftLength();
47  const double middleDistance = startToEndLine.distance(middleRLWirehit.getRefPos2D()) - middleRLWirehit.getSignedRefDriftLength();
48  const double endDistance = startToMiddleLine.distance(endRLWirehit.getRefPos2D()) - endRLWirehit.getSignedRefDriftLength();
49 
50  const double startOptimalStep = startDistance * startWeight / sumWeight;
51  const double middleOptimalStep = middleDistance * middleWeight / sumWeight;
52  const double endOptimalStep = endDistance * endWeight / sumWeight;
53 
54  const double startChi2 = startDistance * (startDistance - startOptimalStep) * startWeight;
55  const double middleChi2 = middleDistance * (middleDistance - middleOptimalStep) * middleWeight;
56  const double endChi2 = endDistance * (endDistance - endOptimalStep) * endWeight;
57 
58  const Vector2D& startToMiddleTangentialVector = startToMiddleLine.tangential();
59  const Vector2D& startToEndTangentialVector = startToEndLine.tangential();
60  const Vector2D& middleToEndTangentialVector = middleToEndLine.tangential();
61 
62  const double startToMiddleLength = startToMiddleTangentialVector.norm();
63  const double startToEndLength = startToEndTangentialVector.norm();
64  const double middleToEndLength = middleToEndTangentialVector.norm();
65 
66  const double startPhi = startToMiddleTangentialVector.angleWith(startToEndTangentialVector);
67  const double middlePhi = startToMiddleTangentialVector.angleWith(middleToEndTangentialVector);
68  const double endPhi = startToEndTangentialVector.angleWith(middleToEndTangentialVector);
69 
70  const double startToMiddleSigmaPhi = startDriftLengthSigma / startToMiddleLength;
71  const double startToEndSigmaPhi = startDriftLengthSigma / startToEndLength;
72 
73  const double middleToStartSigmaPhi = middleDriftLengthSigma / startToMiddleLength;
74  const double middleToEndSigmaPhi = middleDriftLengthSigma / middleToEndLength;
75 
76  const double endToStartSigmaPhi = endDriftLengthSigma / startToEndLength;
77  const double endToMiddleSigmaPhi = endDriftLengthSigma / middleToEndLength;
78 
79  const double startPhiSigma = hypot3(startToEndSigmaPhi - startToMiddleSigmaPhi,
80  middleToStartSigmaPhi,
81  endToStartSigmaPhi);
82 
83  const double middlePhiSigma = hypot3(startToMiddleSigmaPhi,
84  middleToStartSigmaPhi + middleToEndSigmaPhi,
85  endToMiddleSigmaPhi);
86 
87  const double endPhiSigma = hypot3(startToEndSigmaPhi,
88  middleToEndSigmaPhi,
89  endToStartSigmaPhi - endToMiddleSigmaPhi);
90 
91  const double startPhiPull = startPhi / startPhiSigma;
92  const double middlePhiPull = middlePhi / middlePhiSigma;
93  const double endPhiPull = endPhi / endPhiSigma;
94 
95  const double curv = 2 * middlePhi / startToEndLength;
96  const double curvSigma = 2 * middlePhiSigma / startToEndLength;
97  const double curvPull = middlePhiPull / startToEndLength;
98 
99  var<named("start_phi")>() = startPhi;
100  var<named("start_phi_sigma")>() = startPhiSigma;
101  var<named("start_phi_pull")>() = startPhiPull;
102  var<named("start_d")>() = startDistance;
103  var<named("start_chi2")>() = startChi2;
104 
105  var<named("middle_phi")>() = middlePhi;
106  var<named("middle_phi_sigma")>() = middlePhiSigma;
107  var<named("middle_phi_pull")>() = middlePhiPull;
108  var<named("middle_d")>() = middleDistance;
109  var<named("middle_chi2")>() = middleChi2;
110 
111  var<named("end_phi")>() = endPhi;
112  var<named("end_phi_sigma")>() = endPhiSigma;
113  var<named("end_phi_pull")>() = endPhiPull;
114  var<named("end_d")>() = endDistance;
115  var<named("end_chi2")>() = endChi2;
116 
117  var<named("s")>() = startToEndLength;
118 
119  var<named("curv")>() = curv;
120  var<named("curv_sigma")>() = curvSigma;
121  var<named("curv_pull")>() = curvPull;
122 
123  return true;
124 }
Belle2::TrackFindingCDC::CDCFacet::getStartToEndLine
ParameterLine2D getStartToEndLine() const
Getter for the tangential line from the first to the third hit.
Definition: CDCFacet.cc:96
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::BendFacetVarSet::extract
bool extract(const CDCFacet *ptrFacet) final
Generate and assign the contained variables.
Definition: BendFacetVarSet.cc:17
Belle2::TrackFindingCDC::CDCRLWireHit::getSignedRefDriftLength
double getSignedRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:226
Belle2::TrackFindingCDC::ParameterLine2D
A line with a support point and tangential vector.
Definition: ParameterLine2D.h:48
Belle2::TrackFindingCDC::CDCFacet::adjustFitLine
void adjustFitLine() const
Adjusts the contained fit line to touch such that it touches the first and third hit.
Definition: CDCFacet.cc:63
Belle2::TrackFindingCDC::CDCRLWireHit::getRefDriftLengthVariance
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:232
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCFacet::getStartToMiddleLine
ParameterLine2D getStartToMiddleLine() const
Getter for the tangential line from the first to the second hit.
Definition: CDCFacet.cc:88
Belle2::TrackFindingCDC::CDCRLWireHit
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:51
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getMiddleRLWireHit
CDCRLWireHit & getMiddleRLWireHit()
Getter for the second oriented wire hit.
Definition: CDCRLWireHitTriple.h:243
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::ParameterLine2D::distance
double distance(const Vector2D &point) const
Gives the signed distance of a point to the line.
Definition: ParameterLine2D.h:211
Belle2::TrackFindingCDC::ParameterLine2D::tangential
const Vector2D & tangential() const
Gives the tangential vector of the line.
Definition: ParameterLine2D.h:135
Belle2::TrackFindingCDC::Vector2D::norm
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:189
Belle2::TrackFindingCDC::CDCRLWireHit::getRefPos2D
const Vector2D & getRefPos2D() const
The two dimensional reference position of the underlying wire.
Definition: CDCRLWireHit.cc:158
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getEndRLWireHit
CDCRLWireHit & getEndRLWireHit()
Getter for the third oriented wire hit.
Definition: CDCRLWireHitTriple.h:249
Belle2::TrackFindingCDC::CDCFacet::getMiddleToEndLine
ParameterLine2D getMiddleToEndLine() const
Getter for the tangential line from the second to the third hit.
Definition: CDCFacet.cc:104
Belle2::TrackFindingCDC::VarSet< BendFacetVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::VarSet< BendFacetVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getStartRLWireHit
CDCRLWireHit & getStartRLWireHit()
Getter for the first oriented wire hit.
Definition: CDCRLWireHitTriple.h:237