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/trackFindingCDC/eventdata/hits/CDCFacet.h>
11
12#include <tracking/trackFindingCDC/numerics/Quadratic.h>
13
14#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15
16#include <framework/core/ModuleParamList.templateDetails.h>
17
18#include <cmath>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22
24 : m_param_phiPullCut(11)
25{
26}
27
29 : m_param_phiPullCut(phiPullCut)
30{
31}
32
34 const std::string& prefix)
35{
36 Super::exposeParameters(moduleParamList, prefix);
37 moduleParamList->addParameter(prefixed(prefix, "phiPullCut"),
39 "Acceptable angle pull in the angle of adjacent tangents to the "
40 "drift circles.",
42}
43
45{
46 facet.adjustFitLine();
47
48 const CDCRLWireHit& startRLWirehit = facet.getStartRLWireHit();
49 const double startDriftLengthVar = startRLWirehit.getRefDriftLengthVariance();
50 const double startDriftLengthStd = sqrt(startDriftLengthVar);
51
52 const CDCRLWireHit& middleRLWirehit = facet.getMiddleRLWireHit();
53 const double middleDriftLengthVar = middleRLWirehit.getRefDriftLengthVariance();
54 const double middleDriftLengthStd = sqrt(middleDriftLengthVar);
55
56 const CDCRLWireHit& endRLWirehit = facet.getEndRLWireHit();
57 const double endDriftLengthVar = endRLWirehit.getRefDriftLengthVariance();
58 const double endDriftLengthStd = sqrt(endDriftLengthVar);
59
60 const ParameterLine2D& startToMiddleLine = facet.getStartToMiddleLine();
61 const ParameterLine2D& startToEndLine = facet.getStartToEndLine();
62 const ParameterLine2D& middleToEndLine = facet.getMiddleToEndLine();
63
64 const Vector2D& startToMiddleTangentialVector = startToMiddleLine.tangential();
65 const Vector2D& startToEndTangentialVector = startToEndLine.tangential();
66 const Vector2D& middleToEndTangentialVector = middleToEndLine.tangential();
67
68 const double startToMiddleLength = startToMiddleTangentialVector.norm();
69 const double startToEndLength = startToEndTangentialVector.norm();
70 const double middleToEndLength = middleToEndTangentialVector.norm();
71
72 const double startCos = startToMiddleTangentialVector.cosWith(startToEndTangentialVector);
73 const double middleCos = startToMiddleTangentialVector.cosWith(middleToEndTangentialVector);
74 const double endCos = startToEndTangentialVector.cosWith(middleToEndTangentialVector);
75
76 const double startPhi = acos(startCos);
77 const double middlePhi = acos(middleCos);
78 const double endPhi = acos(endCos);
79
80 const double startToMiddleSigmaPhi = startDriftLengthStd / startToMiddleLength;
81 const double startToEndSigmaPhi = startDriftLengthStd / startToEndLength;
82
83 const double middleToStartSigmaPhi = middleDriftLengthStd / startToMiddleLength;
84 const double middleToEndSigmaPhi = middleDriftLengthStd / middleToEndLength;
85
86 const double endToStartSigmaPhi = endDriftLengthStd / startToEndLength;
87 const double endToMiddleSigmaPhi = endDriftLengthStd / middleToEndLength;
88
89 const double startPhiSigma = hypot3(startToEndSigmaPhi - startToMiddleSigmaPhi,
90 middleToStartSigmaPhi,
91 endToStartSigmaPhi);
92
93 const double middlePhiSigma = hypot3(startToMiddleSigmaPhi,
94 middleToStartSigmaPhi + middleToEndSigmaPhi,
95 endToMiddleSigmaPhi);
96
97 const double endPhiSigma = hypot3(startToEndSigmaPhi,
98 middleToEndSigmaPhi,
99 endToStartSigmaPhi - endToMiddleSigmaPhi);
100
101 const double startPhiPull = startPhi / startPhiSigma;
102 const double middlePhiPull = middlePhi / middlePhiSigma;
103 const double endPhiPull = endPhi / endPhiSigma;
104
105 if (startPhiPull < m_param_phiPullCut and
106 middlePhiPull < m_param_phiPullCut and
107 endPhiPull < m_param_phiPullCut) {
108
109 // Introducing a mini penalty to distiguish straighter facets as better
110 // This is important since otherwise the ordering of the wires takes precedence and biases
111 // for counterclockwise tracks.
112 double miniPenalty =
113 std::fmin(0.1, (startPhiPull + middlePhiPull + endPhiPull) / m_param_phiPullCut / 1000);
114
115 // Good facet contains three points of the track
116 // the amount carried by this facet can the adjusted more realistically
117 return 3 - miniPenalty;
118 } else {
119 return NAN;
120 }
121}
The Module parameter list class.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:32
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 ...
Definition: CDCRLWireHit.h:41
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:222
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the set of parameters of the filter to the module parameter list.
Definition: Filter.icc.h:40
A line with a support point and tangential vector.
const Vector2D & tangential() const
Gives the tangential vector of the line.
double m_param_phiPullCut
Memory for the pull cu.
Weight operator()(const CDCFacet &facet) final
Main filter method returning the weight of the facet Returns NAN if the cell shall be rejected.
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.
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:32
double cosWith(const Vector2D &rhs) const
Definition: Vector2D.h:187
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:175
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.