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