Belle II Software  release-08-01-10
AxialHitQuadTreeProcessor Class Referenceabstract

A QuadTreeProcessor for TrackHits. More...

#include <AxialHitQuadTreeProcessor.h>

Inheritance diagram for AxialHitQuadTreeProcessor:
Collaboration diagram for AxialHitQuadTreeProcessor:

Public Types

using Item = QuadTreeItem< const CDCWireHit >
 The QuadTree will only see items of this type.
 
using QuadTree = QuadTreeNode< long, float, Item >
 The used QuadTree.
 
using XSpan = typename QuadTree::XSpan
 This pair describes the span in X for a node.
 
using YSpan = typename QuadTree::YSpan
 This pair describes the span in Y for a node.
 
using XYSpans = std::pair< XSpan, YSpan >
 This pair of spans describes the span of a node.
 
using QuadTreeChildren = typename QuadTree::Children
 Alias for the QuadTree Children.
 
using CandidateReceiver = std::function< void(const std::vector< const CDCWireHit * > &, QuadTree *)>
 This lambda function can be used for postprocessing.
 

Public Member Functions

 AxialHitQuadTreeProcessor (int lastLevel, int seedLevel, const XYSpans &ranges, PrecisionUtil::PrecisionFunction precisionFunction)
 Constructor.
 
 AxialHitQuadTreeProcessor (const Vector2D &localOrigin, const YSpan &curvSpan, const LookupTable< Vector2D > *cosSinLookupTable)
 Constructor for the quad tree processor used in the off-origin extension. More...
 
void drawHits (std::vector< const CDCWireHit * > hits, unsigned int color=46) const
 Draw QuadTree node.
 
void drawNode (QuadTree *node) const
 Draw QuadTree node.
 
void clear ()
 Delete all the QuadTreeItems in the tree and clear the tree.
 
void seed (const std::vector< const CDCWireHit * > &datas)
 Fill in the items in the given vector. More...
 
std::vector< const CDCWireHit * > getAssignedItems ()
 Get items that have been assigned to the seed level The returned elements are unique even if items are assigned multiple times.
 
void fill (const CandidateReceiver &candidateReceiver, int nHitsThreshold)
 Start filling the already created tree. More...
 
void fill (const CandidateReceiver &candidateReceiver, int nHitsThreshold, float yLimit)
 Fill vector of QuadTree instances with hits. More...
 
virtual void afterFillDebugHook (QuadTreeChildren &children)
 Override that function if you want to receive debug output whenever the children of a node are filled the first time Maybe you want to make some nice plots or statistics.
 
const std::map< std::pair< long, float >, std::vector< Item * > > & getDebugInformation () const
 Return the debug information if collected.
 

Static Public Member Functions

static const LookupTable< Vector2D > & getCosSinLookupTable ()
 Get the standard lookup table containing equally spaces unit vectors (cos, sin) More...
 
static std::vector< float > createCurvBound (YSpan curvSpan, int lastLevel)
 Constructs an array with the curvature bounds as generated by the default bin divisions.
 

Protected Member Functions

bool isLeaf (QuadTree *node) const final
 lastLevel depends on curvature of the track candidate
 
XYSpans createChild (QuadTree *node, int i, int j) const final
 Return the new ranges. More...
 
bool isInNode (QuadTree *node, const CDCWireHit *wireHit) const final
 Check whether hit belongs to the quadtree node: More...
 
bool checkDerivative (QuadTree *node, const CDCWireHit *wireHit) const
 Check derivative of the sinogram. More...
 
bool checkExtremum (QuadTree *node, const CDCWireHit *wireHit) const
 Checks whether extremum point is located whithin QuadTree node's ranges. More...
 
virtual XYSpans createChild (QuadTree *node, int iX, int iY) const
 Implement that function if you want to provide a new processor. More...
 
virtual bool isInNode (QuadTree *node, const CDCWireHit *item) const=0
 Implement that function if you want to provide a new processor. More...
 
virtual bool isLeaf (QuadTree *node) const
 Function which checks if given node is leaf Implemented as virtual to keep possibility of changing lastLevel values depending on region is phase-space (i.e. More...
 
int getLastLevel () const
 Return the parameter last level.
 

Protected Attributes

std::unique_ptr< QuadTreem_quadTree
 The quad tree we work with.
 
std::deque< Itemm_items
 Storage space for the items that are referenced by the quad tree nodes.
 
std::vector< QuadTree * > m_seededTrees
 Vector of QuadTrees QuadTree instances (which are filled in the vector) cover the whole Legendre phase-space; each instance is processes independently.
 

Private Member Functions

void fillGivenTree (QuadTree *node, const CandidateReceiver &candidateReceiver, int nItemsThreshold, float yLimit)
 Internal function to do the real quad tree search: fill the nodes, check which of the n*m bins we need to process further and go one level deeper.
 
void createChildren (QuadTree *node, QuadTreeChildren &m_children) const
 Creates the sub node of a given node. More...
 
void fillChildren (QuadTree *node, const std::vector< Item * > &items)
 This function is called by fillGivenTree and fills the items into the corresponding children. More...
 
void callResultFunction (QuadTree *node, const CandidateReceiver &candidateReceiver) const
 When a node is accepted as a result, we extract a vector with the items (back transformed to AData*) and pass it together with the result node to the candidate receiver function.
 

Private Attributes

const LookupTable< Vector2D > * m_cosSinLookupTable
 Pinned lookup table for precompute cosine and sine values.
 
Vector2D m_localOrigin
 Local origin on which the phase space coordinates are centered.
 
bool m_twoSidedPhaseSpace
 Indicator whether the two sided phases space insertion check should be used This option should automatically split back to back tracks in the low curvature regions.
 
const double c_curlCurv = 0.02
 The curvature above which the trajectory is considered a curler.
 
PrecisionUtil::PrecisionFunction m_precisionFunction
 Lambda which holds resolution function for the quadtree.
 
int m_lastLevel
 The last level to be filled.
 
int m_seedLevel
 The first level to be filled, effectively skip forward to this higher granularity level.
 
bool m_debugOutput
 A flag to control the creation of the debug output.
 
std::map< std::pair< long, float >, std::vector< Item * > > m_debugOutputMap
 The calculated debug map.
 

Detailed Description

A QuadTreeProcessor for TrackHits.

Definition at line 26 of file AxialHitQuadTreeProcessor.h.

Constructor & Destructor Documentation

◆ AxialHitQuadTreeProcessor()

AxialHitQuadTreeProcessor ( const Vector2D localOrigin,
const YSpan curvSpan,
const LookupTable< Vector2D > *  cosSinLookupTable 
)

Constructor for the quad tree processor used in the off-origin extension.

Currently only used in zero level mode to collect hits that are in a phase space part with respect to the given point.

Definition at line 108 of file AxialHitQuadTreeProcessor.cc.

111  : QuadTreeProcessor(0, 0, { {0, cosSinLookupTable->getNPoints() - 1}, curvSpan})
112 , m_cosSinLookupTable(cosSinLookupTable)
113 , m_localOrigin(localOrigin)
114 {
115  // Never use two sided mode in off origin extension
116  m_twoSidedPhaseSpace = false;
117 }
bool m_twoSidedPhaseSpace
Indicator whether the two sided phases space insertion check should be used This option should automa...
Vector2D m_localOrigin
Local origin on which the phase space coordinates are centered.
const LookupTable< Vector2D > * m_cosSinLookupTable
Pinned lookup table for precompute cosine and sine values.
int getNPoints() const
Return the number of finite sampling points in this lookup table.
Definition: LookupTable.h:108
QuadTreeProcessor(int lastLevel, int seedLevel, const XYSpans &xySpans, bool debugOutput=false)
Constructor is very simple.

Member Function Documentation

◆ checkDerivative()

bool checkDerivative ( QuadTree node,
const CDCWireHit wireHit 
) const
protected

Check derivative of the sinogram.

Parameters
nodeQuadTree node
wireHitpointer to the hit to check
Returns
returns true in cases:
- positive derivative and no extremum in the node's ranges or
- extremum located in the node's ranges
returns false in other cases (namely negative derivative

Definition at line 261 of file AxialHitQuadTreeProcessor.cc.

◆ checkExtremum()

bool checkExtremum ( QuadTree node,
const CDCWireHit wireHit 
) const
protected

Checks whether extremum point is located whithin QuadTree node's ranges.

Parameters
nodeQuadTree node
wireHithit to check
Returns
true or false

Definition at line 280 of file AxialHitQuadTreeProcessor.cc.

◆ createChild() [1/2]

AxialHitQuadTreeProcessor::XYSpans createChild ( QuadTree node,
int  i,
int  j 
) const
finalprotected

Return the new ranges.

We do not use the standard ranges for the lower levels.

Parameters
nodequadtree node
itheta index of the child
jrho index of the child
Returns
returns ranges of the (i;j) child

Definition at line 135 of file AxialHitQuadTreeProcessor.cc.

◆ createChild() [2/2]

virtual XYSpans createChild ( QuadTree node,
int  iX,
int  iY 
) const
inlineprotectedvirtualinherited

Implement that function if you want to provide a new processor.

It decides which node-spans the n * m children of the node should have. It is called when creating the nodes. The two indices iX and iY tell you where the new node will be created (as node.children[iX][iY]). You can check some information on the level or the x- or y-values by using the methods implemented for node.

Returns
a XYSpan pair of a x- and a y-span that the new child should have. If you don nt want to provide custom spans, just return XYSpans(XSpan(node->getXBinBound(iX), node->getXBinBound(iX + 1)), YSpan(node->getYBinBound(iY), node->getYBinBound(iY + 1)));

Definition at line 311 of file QuadTreeProcessor.h.

312  {
313  AX xMin = node->getXLowerBound(iX);
314  AX xMax = node->getXUpperBound(iX);
315  AY yMin = node->getYLowerBound(iY);
316  AY yMax = node->getYUpperBound(iY);
317  return XYSpans({xMin, xMax}, {yMin, yMax});
318  }
std::pair< XSpan, YSpan > XYSpans
This pair of spans describes the span of a node.

◆ createChildren()

void createChildren ( QuadTree node,
QuadTreeChildren m_children 
) const
inlineprivateinherited

Creates the sub node of a given node.

This function is called by fillGivenTree. To calculate the spans of the children nodes the user-defined function createChiildWithParent is used.

Definition at line 249 of file QuadTreeProcessor.h.

◆ fill() [1/2]

void fill ( const CandidateReceiver candidateReceiver,
int  nHitsThreshold 
)
inlineinherited

Start filling the already created tree.

Parameters
candidateReceiverthe lambda function to call after a node was selected
nHitsThresholdthe threshold on the number of items

Definition at line 168 of file QuadTreeProcessor.h.

◆ fill() [2/2]

void fill ( const CandidateReceiver candidateReceiver,
int  nHitsThreshold,
float  yLimit 
)
inlineinherited

Fill vector of QuadTree instances with hits.

Parameters
candidateReceiverthe lambda function to call after a node was selected
nHitsThresholdthe threshold on the number of items
yLimitthe threshold in the rho (curvature) variable

Definition at line 179 of file QuadTreeProcessor.h.

◆ fillChildren()

void fillChildren ( QuadTree node,
const std::vector< Item * > &  items 
)
inlineprivateinherited

This function is called by fillGivenTree and fills the items into the corresponding children.

For this the user-defined method isInNode is called.

Definition at line 265 of file QuadTreeProcessor.h.

◆ getCosSinLookupTable()

const LookupTable< Vector2D > & getCosSinLookupTable ( )
static

Get the standard lookup table containing equally spaces unit vectors (cos, sin)

It contains 2**16 + 1 sampling points between -pi and pi.

Definition at line 88 of file AxialHitQuadTreeProcessor.cc.

◆ isInNode() [1/2]

virtual bool isInNode ( QuadTree node,
const CDCWireHit item 
) const
protectedpure virtualinherited

Implement that function if you want to provide a new processor.

It is called when filling the quad tree after creation. For every item in a node and every child node this function gets called and should decide, if the item should go into this child node or not.

Parameters
nodechild node
itemitem to be filled into the child node or not
Returns
true if this item belongs into this node.

◆ isInNode() [2/2]

bool isInNode ( QuadTree node,
const CDCWireHit wireHit 
) const
finalprotected

Check whether hit belongs to the quadtree node:

Parameters
nodequadtree node
wireHithit being checked
Returns
returns true if sinogram of the hit crosses (geometrically) borders of the node

Definition at line 193 of file AxialHitQuadTreeProcessor.cc.

◆ isLeaf()

virtual bool isLeaf ( QuadTree node) const
inlineprotectedvirtualinherited

Function which checks if given node is leaf Implemented as virtual to keep possibility of changing lastLevel values depending on region is phase-space (i.e.

setting lastLevel as a function of Y-variable)

Definition at line 334 of file QuadTreeProcessor.h.

◆ seed()

void seed ( const std::vector< const CDCWireHit * > &  datas)
inlineinherited

Fill in the items in the given vector.

They are transformed to QuadTreeItems internally.

Definition at line 103 of file QuadTreeProcessor.h.


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