Belle II Software development
RealisticFacetFilter.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/RealisticFacetFilter.h>
9
10#include <tracking/trackingUtilities/eventdata/hits/CDCFacet.h>
11
12#include <tracking/trackingUtilities/numerics/Quadratic.h>
13
14#include <tracking/trackingUtilities/utilities/StringManipulation.h>
15
16#include <framework/core/ModuleParamList.templateDetails.h>
17#include <framework/geometry/VectorUtil.h>
18
19#include <Math/Vector2D.h>
20
21#include <cmath>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25using namespace TrackingUtilities;
26
31
33 : m_param_phiPullCut(phiPullCut)
34{
35}
36
38 const std::string& prefix)
39{
40 Super::exposeParameters(moduleParamList, prefix);
41 moduleParamList->addParameter(prefixed(prefix, "phiPullCut"),
43 "Acceptable angle pull in the angle of adjacent tangents to the "
44 "drift circles.",
46}
47
49{
50 facet.adjustFitLine();
51
52 const CDCRLWireHit& startRLWirehit = facet.getStartRLWireHit();
53 const double startDriftLengthVar = startRLWirehit.getRefDriftLengthVariance();
54 const double startDriftLengthStd = sqrt(startDriftLengthVar);
55
56 const CDCRLWireHit& middleRLWirehit = facet.getMiddleRLWireHit();
57 const double middleDriftLengthVar = middleRLWirehit.getRefDriftLengthVariance();
58 const double middleDriftLengthStd = sqrt(middleDriftLengthVar);
59
60 const CDCRLWireHit& endRLWirehit = facet.getEndRLWireHit();
61 const double endDriftLengthVar = endRLWirehit.getRefDriftLengthVariance();
62 const double endDriftLengthStd = sqrt(endDriftLengthVar);
63
64 const ParameterLine2D& startToMiddleLine = facet.getStartToMiddleLine();
65 const ParameterLine2D& startToEndLine = facet.getStartToEndLine();
66 const ParameterLine2D& middleToEndLine = facet.getMiddleToEndLine();
67
68 const ROOT::Math::XYVector& startToMiddleTangentialVector = startToMiddleLine.tangential();
69 const ROOT::Math::XYVector& startToEndTangentialVector = startToEndLine.tangential();
70 const ROOT::Math::XYVector& middleToEndTangentialVector = middleToEndLine.tangential();
71
72 const double startToMiddleLength = startToMiddleTangentialVector.R();
73 const double startToEndLength = startToEndTangentialVector.R();
74 const double middleToEndLength = middleToEndTangentialVector.R();
75
76 const double startCos = VectorUtil::CosPhi(startToMiddleTangentialVector, startToEndTangentialVector);
77 const double middleCos = VectorUtil::CosPhi(startToMiddleTangentialVector, middleToEndTangentialVector);
78 const double endCos = VectorUtil::CosPhi(startToEndTangentialVector, middleToEndTangentialVector);
79
80 const double startPhi = acos(startCos);
81 const double middlePhi = acos(middleCos);
82 const double endPhi = acos(endCos);
83
84 const double startToMiddleSigmaPhi = startDriftLengthStd / startToMiddleLength;
85 const double startToEndSigmaPhi = startDriftLengthStd / startToEndLength;
86
87 const double middleToStartSigmaPhi = middleDriftLengthStd / startToMiddleLength;
88 const double middleToEndSigmaPhi = middleDriftLengthStd / middleToEndLength;
89
90 const double endToStartSigmaPhi = endDriftLengthStd / startToEndLength;
91 const double endToMiddleSigmaPhi = endDriftLengthStd / middleToEndLength;
92
93 const double startPhiSigma = hypot3(startToEndSigmaPhi - startToMiddleSigmaPhi,
94 middleToStartSigmaPhi,
95 endToStartSigmaPhi);
96
97 const double middlePhiSigma = hypot3(startToMiddleSigmaPhi,
98 middleToStartSigmaPhi + middleToEndSigmaPhi,
99 endToMiddleSigmaPhi);
100
101 const double endPhiSigma = hypot3(startToEndSigmaPhi,
102 middleToEndSigmaPhi,
103 endToStartSigmaPhi - endToMiddleSigmaPhi);
104
105 const double startPhiPull = startPhi / startPhiSigma;
106 const double middlePhiPull = middlePhi / middlePhiSigma;
107 const double endPhiPull = endPhi / endPhiSigma;
108
109 if (startPhiPull < m_param_phiPullCut and
110 middlePhiPull < m_param_phiPullCut and
111 endPhiPull < m_param_phiPullCut) {
112
113 // Introducing a mini penalty to distinguish straighter facets as better
114 // This is important since otherwise the ordering of the wires takes precedence and biases
115 // for counterclockwise tracks.
116 double miniPenalty =
117 std::fmin(0.1, (startPhiPull + middlePhiPull + endPhiPull) / m_param_phiPullCut / 1000);
118
119 // Good facet contains three points of the track
120 // the amount carried by this facet can the adjusted more realistically
121 return 3 - miniPenalty;
122 } else {
123 return NAN;
124 }
125}
The Module parameter list class.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
RealisticFacetFilter()
Constructor using default direction of flight deviation cut off.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCFacet &facet) final
Main filter method returning the weight of the facet Returns NAN if the cell shall be rejected.
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.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
A line with a support point and tangential vector.
const ROOT::Math::XYVector & tangential() const
Gives the tangential vector of the line.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28
Abstract base class for different kinds of events.