Belle II Software  release-08-01-10
AxialLegendreLeafProcessor< ANode > Class Template Reference

Predicate class that is feed the nodes in a WeightedHoughTree walk It decides if a node should be further expanded and extracts items from nodes that are considered as leafs to build tracks. More...

#include <AxialLegendreLeafProcessor.h>

Collaboration diagram for AxialLegendreLeafProcessor< ANode >:

Public Types

using Candidate = std::pair< CDCTrajectory2D, std::vector< CDCRLWireHit > >
 Preliminary structure to save found hits and trajectory information.
 

Public Member Functions

 AxialLegendreLeafProcessor (int maxLevel)
 Initialize a new processor with the maximum level.
 
bool operator() (ANode *node)
 Entry point for the WeightedHoughTree walk to ask if a node is a leaf that should not be further divided into sub nodes.
 
bool skip (const ANode *node)
 Decide if the node should be expanded further or marks an end point of the depth search.
 
bool isLeaf (const ANode *node)
 Decide when a leaf node is reached that should be processed further.
 
void processLeaf (ANode *leaf)
 A valuable leaf has been found in the hough tree walk. More...
 
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.
 
std::vector< CandidategetCandidates () const
 Getter for the candidates structure still used in some tests.
 
const std::vector< CDCTrack > & getTracks () const
 Getter for the tracks.
 
void clear ()
 Clear the found candidates.
 
void setAxialWireHits (std::vector< const CDCWireHit * > axialWireHits)
 Set the pool of all axial wire hits to be used in the postprocessing.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix)
 Expose the parameters as a module parameter list.
 
void beginWalk ()
 Function to notify the leaf processor about changes in parameters before a new walk.
 

Public Attributes

int m_nNodes = 0
 Statistic: Number received node.
 
int m_nSkippedNodes = 0
 Statistic: Number of skipped nodes.
 
int m_nLeafs = 0
 Statistic: Number processed leaf.
 

Private Attributes

int m_param_maxLevel = 1
 Memory for the maximal level of the tree.
 
double m_param_minWeight = 0
 Memory for the minimal weight threshold for following the children of a node.
 
double m_param_maxCurv = NAN
 Memory for the maximal curvature that should be searched in the current walk.
 
double m_param_curlCurv = 0.018
 Memory for the curvature of a curler in the CDC.
 
int m_param_nRoadSearches = 0
 Memory for the number of repeated road searches.
 
int m_param_roadLevel = 0
 Memory for the tree node level which should be the source of hits for the road searches. Defaults to the top most node.
 
std::string m_param_curvResolution = "const"
 Memory for the name of the resolution function to be used. Valid values are 'none', 'const', 'basic', 'origin', 'offOrigin'.
 
std::vector< CDCTrackm_tracks
 Memory for found trajectories.
 
std::vector< const CDCWireHit * > m_axialWireHits
 Memory for the pool of axial wire hits to can be used in the post processing.
 
std::function< double(double)> m_curvResolution
 Memory for the freely defined curvature resolution function.
 

Detailed Description

template<class ANode>
class Belle2::TrackFindingCDC::AxialLegendreLeafProcessor< ANode >

Predicate class that is feed the nodes in a WeightedHoughTree walk It decides if a node should be further expanded and extracts items from nodes that are considered as leafs to build tracks.

It accumulates the tracks in a member vector from where they can be taken after the walk over the tree has been completed.

Definition at line 36 of file AxialLegendreLeafProcessor.h.

Member Function Documentation

◆ processLeaf()

void processLeaf ( ANode *  leaf)

A valuable leaf has been found in the hough tree walk.

Extract its content! It may pull more hits from the whole tree by looking at the top node.

Definition at line 37 of file AxialLegendreLeafProcessor.icc.h.

38  {
39  // Special post processing looking for more hits
40  // Start off by fitting the items of the leaf with a general trajectory
41  // that may have a distinct impact != 0
43  auto fitPos = EFitPos::c_RecoPos;
44  auto fitVariance = EFitVariance::c_DriftLength;
45  // Other combinations of fit information
46  // EFitPos::c_RLDriftCircle x EFitVariance::(c_Nominal, c_Pseudo, c_Proper)
47  // have been tried, but found to be worse, which is
48  // not intutive. Probably the perfect circle trajectory
49  // is not as good of a model on the full CDC volume.
50  CDCObservations2D observations2D(fitPos, fitVariance);
51 
52  CDCKarimakiFitter fitter;
53  // Tested alternative CDCRiemannFitter with only marginal differences;
54 
55  std::vector<WithSharedMark<CDCRLWireHit>> hits(leaf->begin(), leaf->end());
56  std::sort(hits.begin(), hits.end()); // Hits should be naturally sorted
57  observations2D.appendRange(hits);
58  CDCTrajectory2D trajectory2D = fitter.fit(observations2D);
59  {
60  const double curv = trajectory2D.getCurvature();
61  std::array<DiscreteCurv, 2> curvs = leaf->template getBounds<DiscreteCurv>();
62 
63  float lowerCurv = *(curvs[0]);
64  float upperCurv = *(curvs[1]);
65  if (static_cast<double>(ESignUtil::common(lowerCurv, upperCurv)) * curv < 0) {
66  trajectory2D.reverse();
67  }
68  }
69  trajectory2D.setLocalOrigin(Vector2D(0, 0));
70 
71  // Look for more hits near the found trajectory
73  if (m_param_nRoadSearches > 0) {
74  // Acquire all available items in some parent node for the road search
75  // Somewhat bypasses the logic of the tree walk - Must handle with care!
76  ANode* roadNode = leaf;
77  while (roadNode->getParent() and roadNode->getLevel() > m_param_roadLevel) {
78  roadNode = roadNode->getParent();
79  }
80 
81  for (int iRoadSearch = 0; iRoadSearch < m_param_nRoadSearches; ++iRoadSearch) {
82  // Use a road search to find new hits from the trajectory
83  // hits = this->searchRoad(*roadNode, trajectory2D); // In case you only want the road hits
84  // if (hits.size() < 5) return;
85 
86  // Second version always holding on to the originally found hits
87  int nHitsBefore = hits.size();
88  std::vector<WithSharedMark<CDCRLWireHit>> roadHits = this->searchRoad(*roadNode, trajectory2D);
89  std::sort(roadHits.begin(), roadHits.end());
90  hits.insert(hits.end(), roadHits.begin(), roadHits.end());
91  std::inplace_merge(hits.begin(), hits.begin() + nHitsBefore, hits.end());
92  hits.erase(std::unique(hits.begin(), hits.end()), hits.end());
93 
94  // Update the current fit
95  observations2D.clear();
96  observations2D.appendRange(hits);
97  trajectory2D = fitter.fit(observations2D);
98  trajectory2D.setLocalOrigin(Vector2D(0.0, 0.0));
99  }
100  }
101 
102  // Mark found hit as used and safe them with the trajectory
104  std::vector<const CDCWireHit*> foundWireHits;
105  for (CDCRLWireHit& rlWireHit : hits) {
106  foundWireHits.push_back(&rlWireHit.getWireHit());
107  }
108 
110 
111  // Sync up the marks with the used hits
112  for (WithSharedMark<CDCRLWireHit>& markableRLWireHit : leaf->getTree()->getTopNode()) {
113  const AutomatonCell& automatonCell = markableRLWireHit.getWireHit().getAutomatonCell();
114  if (automatonCell.hasTakenFlag() or automatonCell.hasMaskedFlag()) {
115  markableRLWireHit.mark();
116  } else {
117  markableRLWireHit.unmark();
118  }
119  }
120  }
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.
int m_param_roadLevel
Memory for the tree node level which should be the source of hits for the road searches....
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_nRoadSearches
Memory for the number of repeated road searches.
std::vector< CDCTrack > m_tracks
Memory for found trajectories.
static ESign common(ESign n1, ESign n2)
Check if two values have a common sign.
Definition: ESign.h:57
static void addCandidateFromHits(const std::vector< const CDCWireHit * > &foundAxialWireHits, const std::vector< const CDCWireHit * > &allAxialWireHits, std::vector< CDCTrack > &axialTracks, bool withPostprocessing=true)
Create CDCTrack using CDCWireHit hits and store it in the list. Then call the postprocessing on it.

The documentation for this class was generated from the following files: