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