Belle II Software development
StereoHitTrackQuadTreeMatcher< AQuadTree > Class Template Referenceabstract

A matcher algorithm for using a stereo quad tree for matching rl tagged wire hits to tracks. More...

#include <StereoHitTrackQuadTreeMatcher.h>

Inheritance diagram for StereoHitTrackQuadTreeMatcher< AQuadTree >:
MatcherInterface< TrackingUtilities::CDCTrack, TrackingUtilities::CDCRLWireHit > Findlet< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCRLWireHit, WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCRLWireHit > > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using WeightedRelationItem
 Shortcut class name for a weighted relation between a collector item and a collection item.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters to the module.
 
void initialize () override
 Initialize the filter and the quad tree.
 
void terminate () override
 Terminate the filter and the quad tree.
 
void apply (std::vector< TrackingUtilities::CDCTrack > &collectorItems, const std::vector< TrackingUtilities::CDCRLWireHit > &collectionItems, std::vector< WeightedRelationItem > &weightedRelations) override
 Main function: create weighted relations between collectors and collection items using the implemented functionality overridden in a derived class.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
virtual std::string getDescription ()
 Brief description of the purpose of the concrete findlet.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 

Protected Types

using ToVector
 Short hand for ToRangeImpl.
 

Protected Member Functions

virtual void match (TrackingUtilities::CDCTrack &collectorItem, const std::vector< TrackingUtilities::CDCRLWireHit > &collectionItems, std::vector< WeightedRelationItem > &relationsForCollector)
 Override this function to implement your own matching algorithm between one collector and many collection items.
 
virtual Weight match (TrackingUtilities::CDCTrack &collectorItem, const TrackingUtilities::CDCRLWireHit &collectionItem)
 Override this function to implement your own matching algorithm between one collector and one collection items.
 
void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = MatcherInterface<TrackingUtilities::CDCTrack, TrackingUtilities::CDCRLWireHit>
 The parent class.
 

Private Member Functions

void match (TrackingUtilities::CDCTrack &track, const std::vector< TrackingUtilities::CDCRLWireHit > &rlWireHits, std::vector< Super::WeightedRelationItem > &relationsForCollector) override
 Create a QuadTree and fill with each unused stereo hit (to be exact: twice for each stereo hit - right and left).
 
void writeDebugInformation ()
 Use the writeDebugInformation function of the quad tree to write the tree into a root file with a ascending number.
 

Private Attributes

double m_param_checkForInWireBoundsFactor = 1.0
 Parameters Set to false to skip the in-wire-bound check (good for second stage).
 
unsigned int m_param_quadTreeLevel = 7
 Maximum level of the quad tree search.
 
unsigned int m_param_minimumNumberOfHits = 5
 Minimal number of hits a quad tree node must have to be called a found bin.
 
bool m_param_checkForB2BTracks = true
 Set to false to skip the B2B check (good for curlers).
 
bool m_param_writeDebugInformation = false
 Set to true to output debug information.
 
unsigned int m_numberOfPassedDebugCalls = 0
 Store the number of passed calls to the debug function.
 
AQuadTree m_quadTreeInstance
 Quad tree instance.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized
 Flag to keep track whether initialization happened before.
 
bool m_terminated
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

template<class AQuadTree>
class Belle2::TrackFindingCDC::StereoHitTrackQuadTreeMatcher< AQuadTree >

A matcher algorithm for using a stereo quad tree for matching rl tagged wire hits to tracks.

Definition at line 27 of file StereoHitTrackQuadTreeMatcher.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

template<class AQuadTree>
using Super = MatcherInterface<TrackingUtilities::CDCTrack, TrackingUtilities::CDCRLWireHit>
private

The parent class.

Definition at line 31 of file StereoHitTrackQuadTreeMatcher.h.

◆ ToVector

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ WeightedRelationItem

using WeightedRelationItem
inherited

Shortcut class name for a weighted relation between a collector item and a collection item.

Definition at line 46 of file MatcherInterface.h.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Base class for a findlet, which outputs a list of weighted relations between elements in a list of Co...

◆ apply()

void apply ( std::vector< TrackingUtilities::CDCTrack > & collectorItems,
const std::vector< TrackingUtilities::CDCRLWireHit > & collectionItems,
std::vector< WeightedRelationItem > & weightedRelations )
inlineoverrideinherited

Main function: create weighted relations between collectors and collection items using the implemented functionality overridden in a derived class.

Definition at line 52 of file MatcherInterface.h.

54 {
55 for (ACollectorItem& collectorItem : collectorItems) {
56 match(collectorItem, collectionItems, weightedRelations);
57 }
58
59 std::sort(weightedRelations.begin(), weightedRelations.end());
60 }

◆ beginEvent()

void beginEvent ( )
overrideinherited

Receive and dispatch signal for the start of a new event.

Definition at line 36 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
void beginEvent() override
Receive and dispatch signal for the start of a new event.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overrideinherited

Receive and dispatch signal for the beginning of a new run.

Definition at line 33 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overrideinherited

Receive and dispatch signal for the end of the run.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
void endRun() override
Receive and dispatch signal for the end of the run.
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

template<class AQuadTree>
void exposeParameters ( ModuleParamList * moduleParamList,
const std::string & prefix )
overridevirtual

Expose the parameters to the module.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 36 of file StereoHitTrackQuadTreeMatcher.cc.

38{
40
42 "The number of levels for the quad tree search.",
44
45 moduleParamList->addParameter(prefixed(prefix, "minimumNumberOfHits"), m_param_minimumNumberOfHits,
46 "The minimum number of hits in a quad tree bin to be called as result.",
48
49 moduleParamList->addParameter(prefixed(prefix, "writeDebugInformation"), m_param_writeDebugInformation,
50 "Set to true to output debug information.",
52
53 moduleParamList->addParameter(prefixed(prefix, "checkForB2BTracks"),
55 "Set to false to skip the check for back-2-back tracks "
56 "(good for cosmics).",
58
59 moduleParamList->addParameter(prefixed(prefix, "checkForInWireBoundsFactor"),
61 "Used to scale the CDC before checking "
62 "whether hits are in the CDC z bounds.",
64}
A matcher algorithm for using a stereo quad tree for matching rl tagged wire hits to tracks.
bool m_param_checkForB2BTracks
Set to false to skip the B2B check (good for curlers).
bool m_param_writeDebugInformation
Set to true to output debug information.
unsigned int m_param_minimumNumberOfHits
Minimal number of hits a quad tree node must have to be called a found bin.
double m_param_checkForInWireBoundsFactor
Parameters Set to false to skip the in-wire-bound check (good for second stage).
unsigned int m_param_quadTreeLevel
Maximum level of the quad tree search.

◆ getDescription()

virtual std::string getDescription ( )
inlinevirtualinherited

Brief description of the purpose of the concrete findlet.

Definition at line 60 of file Findlet.h.

61 {
62 return "(no description)";
63 }

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

template<class AQuadTree>
void initialize ( )
overridevirtual

◆ match() [1/3]

template<class AQuadTree>
void match ( TrackingUtilities::CDCTrack & track,
const std::vector< TrackingUtilities::CDCRLWireHit > & rlWireHits,
std::vector< Super::WeightedRelationItem > & relationsForCollector )
overrideprivate

Create a QuadTree and fill with each unused stereo hit (to be exact: twice for each stereo hit - right and left).

The QuadTree has two dimensions: inverse slope in z-direction and z0. Each bin with a high number of items (= stereo hits) in it is stored. Later, the one node with the highest number of items in it is taken and each hit is assigned to the track.

Definition at line 86 of file StereoHitTrackQuadTreeMatcher.cc.

88{
89 // TODO: Extract this into smaller steps
90 // TODO: Split the filtering from the rest.
91 // This means this method would output WeightedRelations based on the quad tree decision and a second filter step
92 // can be applied on these weighted relations
93
94 // Reconstruct the hits to the track
95 const CDCTrajectory2D& trajectory2D = track.getStartTrajectory3D().getTrajectory2D();
96 const bool isCurler = trajectory2D.isCurler();
97
100 recoHits.reserve(rlWireHits.size() + track.size());
101
102 /*
103 * Use the given trajectory to reconstruct the 2d hits in the vector in z direction
104 * to match the trajectory perfectly. Then add the newly created reconstructed 3D hit to the given list.
105 */
106 for (const CDCRLWireHit& rlWireHit : rlWireHits) {
107 if (rlWireHit.getWireHit().getAutomatonCell().hasTakenFlag()) continue;
108
109 const CDCWire& wire = rlWireHit.getWire();
110 const WireLine& wireLine = wire.getWireLine();
111 double signedDriftLength = rlWireHit.getSignedRefDriftLength();
112 for (const ROOT::Math::XYZVector& recoPos3D : trajectory2D.reconstructBoth3D(wireLine, signedDriftLength)) {
113 // Skip hits out of CDC
115 continue;
116 }
117
118 // If the track is a curler, shift all perpS values to positive ones.
119 // Else do not use this hit if m_param_checkForB2BTracks is enabled.
120 double perpS = trajectory2D.calcArcLength2D(VectorUtil::getXYVector(recoPos3D));
121 if (perpS < 0) {
122 if (isCurler) {
123 perpS += trajectory2D.getArcLength2DPeriod();
124 } else if (m_param_checkForB2BTracks) {
125 continue;
126 }
127 }
129 }
130 }
131
132 // Also add already found stereo hits of the track
133 for (const CDCRecoHit3D& recoHit : track) {
134 if (not recoHit.isAxial()) {
135 recoHit.getWireHit().getAutomatonCell().setAssignedFlag();
136 const CDCRLWireHit& rlWireHit = recoHit.getRLWireHit();
137 recoHits.emplace_back(recoHit, &rlWireHit);
138 }
139 }
140
141 // Do the tree finding
143
146 }
147
149 m_quadTreeInstance.fell();
150
151 if (foundStereoHitsWithNode.size() != 1) {
152 return;
153 }
154
155 // There is the possibility that we have added one cdc hits twice (as left and right one). We search for those cases here:
157 const auto& node = foundStereoHitsWithNode[0].first;
158
162 // Turn vector of pairs into vector of first items
164 const CDCRecoHit3D& recoHit3D = recoHitWithRL.first;
165 allHits.push_back(recoHit3D);
166 }
168 const CDCRecoHit3D& recoHit3D = recoHitWithRL.first;
169 foundHits.push_back(recoHit3D);
170 }
171 m_quadTreeInstance.drawDebugPlot(allHits, foundHits, node);
172 }
173
174 // Remove all assigned hits, which where already found before (and do not need to be added again)
177 const auto& automatonCell = recoHit3D.getWireHit().getAutomatonCell();
178 return automatonCell.hasAssignedFlag();
179 };
180
182 foundStereoHits.end(),
184 foundStereoHits.end());
185
186 // Sort the found stereo hits by same CDCHit and smaller distance to the node
189
190
191 const CDCRecoHit3D& rhsRecoHit = rhs.first;
192 const CDCRecoHit3D& lhsRecoHit = lhs.first;
193
194 const CDCWireHit& rhsWireHit = rhsRecoHit.getWireHit();
195 const CDCWireHit& lhsWireHit = lhsRecoHit.getWireHit();
196
197 if (lhsWireHit < rhsWireHit) {
198 return true;
199 } else if (rhsWireHit < lhsWireHit) {
200 return false;
201 } else {
203 }
204 };
205
206 const auto& sameHitComparer = [](const CDCRecoHitWithRLPointer & lhs,
208 const CDCRecoHit3D& rhsRecoHit = rhs.first;
209 const CDCRecoHit3D& lhsRecoHit = lhs.first;
210
211 return lhsRecoHit.getWireHit() == rhsRecoHit.getWireHit();
212 };
213
215 foundStereoHits.end(),
217
218 // If the same hit is added as right and left hypothesis, do only use the one with the smaller distance to the node.
220 foundStereoHits.end(),
222 foundStereoHits.end());
223
224 // Add the found stereo hits to the relation vector. In the moment, all hits get the same weight (may change later).
228 }
229}
void writeDebugInformation()
Use the writeDebugInformation function of the quad tree to write the tree into a root file with a asc...

◆ match() [2/3]

virtual void match ( TrackingUtilities::CDCTrack & collectorItem,
const std::vector< TrackingUtilities::CDCRLWireHit > & collectionItems,
std::vector< WeightedRelationItem > & relationsForCollector )
inlineprotectedvirtualinherited

Override this function to implement your own matching algorithm between one collector and many collection items.

A reason to override this instead of the other match function could be, if you want to apply some sort of caching for each collector item.

Definition at line 68 of file MatcherInterface.h.

70 {
71 for (const ACollectionItem& collectionItem : collectionItems) {
72 Weight weight = match(collectorItem, collectionItem);
73 relationsForCollector.emplace_back(&collectorItem, weight, &collectionItem);
74 }
75 };

◆ match() [3/3]

virtual Weight match ( TrackingUtilities::CDCTrack & collectorItem,
const TrackingUtilities::CDCRLWireHit & collectionItem )
inlineprotectedvirtualinherited

Override this function to implement your own matching algorithm between one collector and one collection items.

If you override this function, you just have to return a weight - the rest of the logic is handled by the MatcherInterface class.

Definition at line 82 of file MatcherInterface.h.

84 {
85 return NAN;
86 }

◆ terminate()

template<class AQuadTree>
void terminate ( )
overridevirtual

◆ writeDebugInformation()

template<class AQuadTree>
void writeDebugInformation ( )
private

Use the writeDebugInformation function of the quad tree to write the tree into a root file with a ascending number.

Definition at line 232 of file StereoHitTrackQuadTreeMatcher.cc.

233{
234 std::string outputFileName = "quadTreeContent_call_" + std::to_string(m_numberOfPassedDebugCalls) + ".root";
235 m_quadTreeInstance.writeDebugInfoToFile(outputFileName);
236
238}
unsigned int m_numberOfPassedDebugCalls
Store the number of passed calls to the debug function.

Member Data Documentation

◆ m_initialized

bool m_initialized
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_numberOfPassedDebugCalls

template<class AQuadTree>
unsigned int m_numberOfPassedDebugCalls = 0
private

Store the number of passed calls to the debug function.

Definition at line 69 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_param_checkForB2BTracks

template<class AQuadTree>
bool m_param_checkForB2BTracks = true
private

Set to false to skip the B2B check (good for curlers).

Definition at line 64 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_param_checkForInWireBoundsFactor

template<class AQuadTree>
double m_param_checkForInWireBoundsFactor = 1.0
private

Parameters Set to false to skip the in-wire-bound check (good for second stage).

Definition at line 58 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_param_minimumNumberOfHits

template<class AQuadTree>
unsigned int m_param_minimumNumberOfHits = 5
private

Minimal number of hits a quad tree node must have to be called a found bin.

Definition at line 62 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_param_quadTreeLevel

template<class AQuadTree>
unsigned int m_param_quadTreeLevel = 7
private

Maximum level of the quad tree search.

Definition at line 60 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_param_writeDebugInformation

template<class AQuadTree>
bool m_param_writeDebugInformation = false
private

Set to true to output debug information.

Definition at line 66 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_quadTreeInstance

template<class AQuadTree>
AQuadTree m_quadTreeInstance
private

Quad tree instance.

Definition at line 72 of file StereoHitTrackQuadTreeMatcher.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.


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