Belle II Software  release-05-01-25
AxialLegendreLeafProcessor.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Bastian Kronenbitter, Thomas Hauth, Viktor Trusov, *
7  * Nils Braun, Oliver Frost *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 #pragma once
12 
13 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
15 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
16 
17 #include <tracking/trackFindingCDC/hough/perigee/CurvRep.h>
18 
19 #include <tracking/trackFindingCDC/hough/baseelements/WithSharedMark.h>
20 
21 #include <vector>
22 
23 namespace Belle2 {
28  class ModuleParamList;
29  namespace TrackFindingCDC {
38  template<class ANode>
39  class AxialLegendreLeafProcessor {
40 
41  public:
43  using Candidate = std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> >;
44 
45  public:
47  explicit AxialLegendreLeafProcessor(int maxLevel)
48  : m_param_maxLevel(maxLevel)
49  {}
50 
51  public: // Node hook to interact with the tree walk
56  bool operator()(ANode* node)
57  {
58  ++m_nNodes;
59  if (skip(node)) {
61  return true;
62  } else if (isLeaf(node)) {
63  ++m_nLeafs;
64  processLeaf(node);
65  return true;
66  } else {
67  return false;
68  }
69  }
70 
72  bool skip(const ANode* node)
73  {
74  bool tooLowWeight = not(node->getWeight() >= m_param_minWeight);
75  bool tooHighCurvature = (static_cast<float>(node->template getLowerBound<DiscreteCurv>()) > m_param_maxCurv or
76  - static_cast<float>(node->template getUpperBound<DiscreteCurv>()) > m_param_maxCurv);
77  return tooLowWeight or tooHighCurvature;
78  }
79 
81  bool isLeaf(const ANode* node)
82  {
83  //if (node->getLevel() <= 6) return false;
84  if (node->getLevel() >= m_param_maxLevel) return true;
85 
86  // Compare the resolution at the mean curvature to the resolution defined by the resolution function
87  std::array<DiscreteCurv, 2> curvs = node->template getBounds<DiscreteCurv>();
88  float lowerCurv = *(curvs[0]);
89  float upperCurv = *(curvs[1]);
90  float curvWidth = std::fabs(upperCurv - lowerCurv);
91  double curvRes = m_curvResolution((lowerCurv + upperCurv) / 2.0);
92  if (curvRes >= curvWidth) return true;
93  return false;
94  }
95 
100  void processLeaf(ANode* leaf);
101 
102  public: // Helper method to execute some steps in the creation of a candidate from a leaf
106  std::vector<WithSharedMark<CDCRLWireHit> >
107  searchRoad(const ANode& node, const CDCTrajectory2D& trajectory2D);
108 
109  public:
111  std::vector<Candidate> getCandidates() const;
112 
114  const std::vector<CDCTrack>& getTracks() const
115  {
116  return m_tracks;
117  }
118 
120  void clear()
121  {
122  m_tracks.clear();
124  }
125 
127  void setAxialWireHits(std::vector<const CDCWireHit*> axialWireHits)
128  {
129  m_axialWireHits = std::move(axialWireHits);
130  }
131 
132  public:
134  void exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix);
135 
137  void beginWalk();
138 
139  public:
141  int m_nNodes = 0;
142 
144  int m_nSkippedNodes = 0;
145 
147  int m_nLeafs = 0;
148 
149  private:
151  int m_param_maxLevel = 1;
152 
154  double m_param_minWeight = 0;
155 
157  double m_param_maxCurv = NAN;
158 
160  double m_param_curlCurv = 0.018;
161 
164 
167 
169  std::string m_param_curvResolution = "const";
170 
171  /*
173  double m_param_maxDistance = 0.2;
174 
176  double m_param_newHitDistance = 0.15;
177  */
178  private:
180  std::vector<CDCTrack> m_tracks;
181 
183  std::vector<const CDCWireHit*> m_axialWireHits;
184 
186  std::function<double(double)> m_curvResolution;
187  };
188  }
190 }
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::AxialLegendreLeafProcessor
AxialLegendreLeafProcessor(int maxLevel)
Initialize a new processor with the maximum level.
Definition: AxialLegendreLeafProcessor.h:56
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_curvResolution
std::function< double(double)> m_curvResolution
Memory for the freely defined curvature resolution function.
Definition: AxialLegendreLeafProcessor.h:195
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_axialWireHits
std::vector< const CDCWireHit * > m_axialWireHits
Memory for the pool of axial wire hits to can be used in the post processing.
Definition: AxialLegendreLeafProcessor.h:192
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_curvResolution
std::string m_param_curvResolution
Memory for the name of the resolution function to be used. Valid values are 'none',...
Definition: AxialLegendreLeafProcessor.h:178
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_nLeafs
int m_nLeafs
Statistic: Number processed leaf.
Definition: AxialLegendreLeafProcessor.h:156
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::searchRoad
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.
Definition: AxialLegendreLeafProcessor.icc.h:136
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::getTracks
const std::vector< CDCTrack > & getTracks() const
Getter for the tracks.
Definition: AxialLegendreLeafProcessor.h:123
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_roadLevel
int m_param_roadLevel
Memory for the tree node level which should be the source of hits for the road searches....
Definition: AxialLegendreLeafProcessor.h:175
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_nNodes
int m_nNodes
Statistic: Number received node.
Definition: AxialLegendreLeafProcessor.h:150
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_minWeight
double m_param_minWeight
Memory for the minimal weight threshold for following the children of a node.
Definition: AxialLegendreLeafProcessor.h:163
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::processLeaf
void processLeaf(ANode *leaf)
A valuable leaf has been found in the hough tree walk.
Definition: AxialLegendreLeafProcessor.icc.h:49
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::skip
bool skip(const ANode *node)
Decide if the node should be expanded further or marks an end point of the depth search.
Definition: AxialLegendreLeafProcessor.h:81
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_maxCurv
double m_param_maxCurv
Memory for the maximal curvature that should be searched in the current walk.
Definition: AxialLegendreLeafProcessor.h:166
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::getCandidates
std::vector< Candidate > getCandidates() const
Getter for the candidates structure still used in some tests.
Definition: AxialLegendreLeafProcessor.icc.h:179
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_nSkippedNodes
int m_nSkippedNodes
Statistic: Number of skipped nodes.
Definition: AxialLegendreLeafProcessor.h:153
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_tracks
std::vector< CDCTrack > m_tracks
Memory for found trajectories.
Definition: AxialLegendreLeafProcessor.h:189
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::Candidate
std::pair< CDCTrajectory2D, std::vector< CDCRLWireHit > > Candidate
Preliminary structure to save found hits and trajectory information.
Definition: AxialLegendreLeafProcessor.h:52
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::setAxialWireHits
void setAxialWireHits(std::vector< const CDCWireHit * > axialWireHits)
Set the pool of all axial wire hits to be used in the postprocessing.
Definition: AxialLegendreLeafProcessor.h:136
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::isLeaf
bool isLeaf(const ANode *node)
Decide when a leaf node is reached that should be processed further.
Definition: AxialLegendreLeafProcessor.h:90
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters as a module parameter list.
Definition: AxialLegendreLeafProcessor.icc.h:194
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_maxLevel
int m_param_maxLevel
Memory for the maximal level of the tree.
Definition: AxialLegendreLeafProcessor.h:160
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::operator()
bool operator()(ANode *node)
Entry point for the WeightedHoughTree walk to ask if a node is a leaf that should not be further divi...
Definition: AxialLegendreLeafProcessor.h:65
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::beginWalk
void beginWalk()
Function to notify the leaf processor about changes in parameters before a new walk.
Definition: AxialLegendreLeafProcessor.icc.h:235
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_curlCurv
double m_param_curlCurv
Memory for the curvature of a curler in the CDC.
Definition: AxialLegendreLeafProcessor.h:169
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::m_param_nRoadSearches
int m_param_nRoadSearches
Memory for the number of repeated road searches.
Definition: AxialLegendreLeafProcessor.h:172
Belle2::TrackFindingCDC::AxialLegendreLeafProcessor::clear
void clear()
Clear the found candidates.
Definition: AxialLegendreLeafProcessor.h:129