Belle II Software development
AxialLegendreLeafProcessor.h
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#pragma once
9
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
11#include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
12#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13
14#include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
15
16#include <tracking/trackFindingCDC/hough/baseelements/WithSharedMark.h>
17
18#include <vector>
19
20namespace Belle2 {
25 class ModuleParamList;
26 namespace TrackFindingCDC {
35 template<class ANode>
37
38 public:
40 using Candidate = std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> >;
41
42 public:
44 explicit AxialLegendreLeafProcessor(int maxLevel)
45 : m_param_maxLevel(maxLevel)
46 {}
47
48 public: // Node hook to interact with the tree walk
53 bool operator()(ANode* node)
54 {
55 ++m_nNodes;
56 if (skip(node)) {
58 return true;
59 } else if (isLeaf(node)) {
60 ++m_nLeafs;
61 processLeaf(node);
62 return true;
63 } else {
64 return false;
65 }
66 }
67
69 bool skip(const ANode* node)
70 {
71 bool tooLowWeight = not(node->getWeight() >= m_param_minWeight);
72 bool tooHighCurvature = (static_cast<float>(node->template getLowerBound<DiscreteCurv>()) > m_param_maxCurv or
73 - static_cast<float>(node->template getUpperBound<DiscreteCurv>()) > m_param_maxCurv);
74 return tooLowWeight or tooHighCurvature;
75 }
76
78 bool isLeaf(const ANode* node)
79 {
80 //if (node->getLevel() <= 6) return false;
81 if (node->getLevel() >= m_param_maxLevel) return true;
82
83 // Compare the resolution at the mean curvature to the resolution defined by the resolution function
84 std::array<DiscreteCurv, 2> curvs = node->template getBounds<DiscreteCurv>();
85 float lowerCurv = *(curvs[0]);
86 float upperCurv = *(curvs[1]);
87 float curvWidth = std::fabs(upperCurv - lowerCurv);
88 double curvRes = m_curvResolution((lowerCurv + upperCurv) / 2.0);
89 if (curvRes >= curvWidth) return true;
90 return false;
91 }
92
97 void processLeaf(ANode* leaf);
98
99 public: // Helper method to execute some steps in the creation of a candidate from a leaf
103 std::vector<WithSharedMark<CDCRLWireHit> >
104 searchRoad(const ANode& node, const CDCTrajectory2D& trajectory2D);
105
106 public:
108 std::vector<Candidate> getCandidates() const;
109
111 const std::vector<CDCTrack>& getTracks() const
112 {
113 return m_tracks;
114 }
115
117 void clear()
118 {
119 m_tracks.clear();
120 m_axialWireHits.clear();
121 }
122
124 void setAxialWireHits(std::vector<const CDCWireHit*> axialWireHits)
125 {
126 m_axialWireHits = std::move(axialWireHits);
127 }
128
129 public:
131 void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix);
132
134 void beginWalk();
135
136 public:
138 int m_nNodes = 0;
139
142
144 int m_nLeafs = 0;
145
146 private:
149
152
154 double m_param_maxCurv = NAN;
155
157 double m_param_curlCurv = 0.018;
158
161
164
166 std::string m_param_curvResolution = "const";
167
168 /*
170 double m_param_maxDistance = 0.2;
171
173 double m_param_newHitDistance = 0.15;
174 */
175 private:
177 std::vector<CDCTrack> m_tracks;
178
180 std::vector<const CDCWireHit*> m_axialWireHits;
181
183 std::function<double(double)> m_curvResolution;
184 };
185 }
187}
The Module parameter list class.
Predicate class that is feed the nodes in a WeightedHoughTree walk It decides if a node should be fur...
bool isLeaf(const ANode *node)
Decide when a leaf node is reached that should be processed further.
std::vector< Candidate > getCandidates() const
Getter for the candidates structure still used in some tests.
std::pair< CDCTrajectory2D, std::vector< CDCRLWireHit > > Candidate
Preliminary structure to save found hits and trajectory information.
std::vector< WithSharedMark< CDCRLWireHit > > searchRoad(const ANode &node, const CDCTrajectory2D &trajectory2D)
Look for more hits near a ftted trajectory from hits available in the give node.
void setAxialWireHits(std::vector< const CDCWireHit * > axialWireHits)
Set the pool of all axial wire hits to be used in the postprocessing.
std::string m_param_curvResolution
Memory for the name of the resolution function to be used. Valid values are 'none',...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters as a module parameter list.
void processLeaf(ANode *leaf)
A valuable leaf has been found in the hough tree walk.
bool skip(const ANode *node)
Decide if the node should be expanded further or marks an end point of the depth search.
void beginWalk()
Function to notify the leaf processor about changes in parameters before a new walk.
std::function< double(double)> m_curvResolution
Memory for the freely defined curvature resolution function.
int m_param_roadLevel
Memory for the tree node level which should be the source of hits for the road searches....
const std::vector< CDCTrack > & getTracks() const
Getter for the tracks.
AxialLegendreLeafProcessor(int maxLevel)
Initialize a new processor with the maximum level.
double m_param_curlCurv
Memory for the curvature of a curler in the CDC.
std::vector< const CDCWireHit * > m_axialWireHits
Memory for the pool of axial wire hits to can be used in the post processing.
int m_param_maxLevel
Memory for the maximal level of the tree.
bool operator()(ANode *node)
Entry point for the WeightedHoughTree walk to ask if a node is a leaf that should not be further divi...
double m_param_maxCurv
Memory for the maximal curvature that should be searched in the current walk.
double m_param_minWeight
Memory for the minimal weight threshold for following the children of a node.
int m_param_nRoadSearches
Memory for the number of repeated road searches.
std::vector< CDCTrack > m_tracks
Memory for found trajectories.
Particle trajectory as it is seen in xy projection represented as a circle.
Abstract base class for different kinds of events.