Belle II Software development
TrackCandidateOverlapResolver Class Referenceabstract

Findlet for rejecting wrong SpacePointTrackCands and for removing bad hits. More...

#include <TrackCandidateOverlapResolver.h>

Inheritance diagram for TrackCandidateOverlapResolver:
Findlet< SpacePointTrackCand > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invocation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invocation.
 

Public Member Functions

 TrackCandidateOverlapResolver ()
 Find intercepts in the 2D Hough space.
 
 ~TrackCandidateOverlapResolver ()
 Default destructor.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters of the sub findlets.
 
void initialize () override
 Create the store arrays.
 
void apply (std::vector< SpacePointTrackCand > &spacePointTrackCandsToResolve) override
 Reject bad SpacePointTrackCands and bad hits inside the remaining.
 
virtual std::string getDescription ()
 Brief description of the purpose of the concrete findlet.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
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.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

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 = TrackFindingCDC::Findlet< SpacePointTrackCand >
 Parent class.
 

Private Attributes

StoreArray< SVDClusterm_svdClusters
 Stay connected to the DataStore for timing improvement.
 
std::string m_nameSVDClusters = "SVDClusters"
 Name of array of SVDCluster.
 
std::string m_resolveMethod = "greedy"
 Strategy used to resolve overlaps.
 
double m_minActivityState = 0.7
 Minimum of activityState of candidate required to be accepted by the algorithm.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Findlet for rejecting wrong SpacePointTrackCands and for removing bad hits.

Definition at line 28 of file TrackCandidateOverlapResolver.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes = std::tuple<AIOTypes...>
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors = std::tuple< std::vector<AIOTypes>... >
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Parent class.

Definition at line 30 of file TrackCandidateOverlapResolver.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ TrackCandidateOverlapResolver()

Find intercepts in the 2D Hough space.

Definition at line 26 of file TrackCandidateOverlapResolver.cc.

26 : Super()
27{
28}
TrackFindingCDC::Findlet< SpacePointTrackCand > Super
Parent class.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ apply()

void apply ( std::vector< SpacePointTrackCand > &  spacePointTrackCandsToResolve)
override

Reject bad SpacePointTrackCands and bad hits inside the remaining.

Definition at line 55 of file TrackCandidateOverlapResolver.cc.

56{
57 //Create matrix[svdCluster][track]
58 unsigned short nHits = m_svdClusters.getEntries();
59
60 //Create subset of active Candidates
61 std::vector<SpacePointTrackCand*> activeCandidates;
62 auto requiredSpace = spacePointTrackCandsToResolve.size();
63 activeCandidates.reserve(requiredSpace);
64 for (SpacePointTrackCand& sptc : spacePointTrackCandsToResolve) {
65 if (sptc.hasRefereeStatus(SpacePointTrackCand::c_isActive)) activeCandidates.push_back(&sptc);
66 }
67 unsigned short const nActiveCandidates = activeCandidates.size();
68 if (nActiveCandidates < 2) {
69 B2DEBUG(29, "Less than 2 active SPTC. No reason to do SVDOverlapResolver!");
70 return;
71 }
72
73 //now fill the cluster/track matrix:
74 std::vector<std::vector<unsigned short> > svdHitRelatedTracks(nHits);
75 //TODO: Check if one saves time by reserving some space for each single of those vectors;
76 for (unsigned short iCand = 0; iCand < nActiveCandidates; ++iCand) {
77
78 for (const SpacePoint* spacePointPointer : activeCandidates.at(iCand)->getHits()) {
79 //only SVD is handled with this algorithm
80 if (spacePointPointer->getType() != VXD::SensorInfoBase::SensorType::SVD) continue;
81
82 //at the position of the svdCluster Index, the track index is pushed back;
83 RelationVector<SVDCluster> svdClusterRelations = spacePointPointer->getRelationsTo<SVDCluster>(m_nameSVDClusters);
84 for (SVDCluster const& svdClusterPointer : svdClusterRelations) {
85 svdHitRelatedTracks[svdClusterPointer.getArrayIndex()].push_back(iCand);
86 }
87 }
88 }
89
90 //Create the overlap matrix and store it into the OverlapNetwork
91 OverlapMatrixCreator overlapMatrixCreator(svdHitRelatedTracks, nActiveCandidates);
92 auto overlapMatrix = overlapMatrixCreator.getOverlapMatrix();
93
94 //Resolve overlap
95 //Create an empty object of the type,
96 //that needs to be given to Scrooge.
97 std::vector<OverlapResolverNodeInfo> qiTrackOverlap;
98 qiTrackOverlap.reserve(nActiveCandidates);
99
100 //fill this object with the necessary information:
101 for (unsigned short iCand = 0; iCand < nActiveCandidates; ++iCand) {
102 qiTrackOverlap.emplace_back(
103 activeCandidates[iCand]->getQualityIndicator(),
104 iCand,
105 overlapMatrix.at(iCand),
106 1);
107 }
108
109 if (m_resolveMethod == "greedy") {
110 //make a Scrooge and update the activity
111 Scrooge scrooge;
112 scrooge.performSelection(qiTrackOverlap);
113
114 } else if (m_resolveMethod == "hopfield") {
115 //Performs the actual HNN.
116 //As the parameter is taken as reference, the values are changed and can be reused below.
117 HopfieldNetwork hopfieldNetwork;
118 unsigned maxIterations = 20;
119 if (hopfieldNetwork.doHopfield(qiTrackOverlap, maxIterations) == maxIterations) {
120 B2WARNING("Hopfield Network failed converge.");
121 }
122 }
123
124 for (auto&& track : qiTrackOverlap) {
125 if (track.activityState < m_minActivityState) {
126 activeCandidates[track.trackIndex]->removeRefereeStatus(SpacePointTrackCand::c_isActive);
127 }
128 }
129}
Hopfield Algorithm with number based inputs.
unsigned short doHopfield(std::vector< OverlapResolverNodeInfo > &overlapResolverNodeInfos, unsigned short nIterations=20)
Performance of the actual algorithm.
Creates a vector of vectors, that knows which track is conflicting with which other.
Class for type safe access to objects that are referred to in relations.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29
Executes greedy algorithm for vector of QITrackOverlap structs.
Definition: Scrooge.h:26
void performSelection(std::vector< OverlapResolverNodeInfo > &overlapResolverNodeInfo)
Sets the isActive flag in m_qiTrackOverlap to false, for killed tracks.
Definition: Scrooge.h:33
Storage for (VXD) SpacePoint-based track candidates.
@ c_isActive
bit 11: SPTC is active (i.e.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
StoreArray< SVDCluster > m_svdClusters
Stay connected to the DataStore for timing improvement.
std::string m_resolveMethod
Strategy used to resolve overlaps.
double m_minActivityState
Minimum of activityState of candidate required to be accepted by the algorithm.

◆ beginEvent()

void beginEvent ( )
overridevirtualinherited

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

Reimplemented from ProcessingSignalListener.

Reimplemented in SpacePointTagger< Belle2::CKFToPXDResult, Belle2::PXDCluster >, SpacePointTagger< Belle2::CKFToSVDResult, Belle2::SVDCluster >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, SharingHitsMatcher< Belle2::TrackFindingCDC::CDCTrack, Belle2::TrackFindingCDC::CDCSegment2D >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCFacet >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCWireHit, true >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCTrack >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentTriple >, RecoTrackStorer, ROIFinder, and SVDHoughTracking.

Definition at line 31 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overridevirtualinherited

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

Reimplemented from ProcessingSignalListener.

Reimplemented in LayerRelationFilter< AFilter >, FourHitFilter, QualityIndicatorFilter, ThreeHitFilter, TwoHitVirtualIPFilter, TwoHitVirtualIPQIFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, and TrackCandidateResultRefiner.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

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

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

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

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
overridevirtual

Expose the parameters of the sub findlets.

Reimplemented from Findlet< SpacePointTrackCand >.

Definition at line 30 of file TrackCandidateOverlapResolver.cc.

31{
32 Super::exposeParameters(moduleParamList, prefix);
33
34 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "ResolveMethod"), m_resolveMethod,
35 "Strategy used to resolve overlaps. Currently implemented are \"greedy\" and \"hopfield\".",
37 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "NameSVDClusters"), m_nameSVDClusters,
38 "Name of expected SVDClusters StoreArray.", m_nameSVDClusters);
39
40 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "minActivityState"), m_minActivityState,
41 "Sets the minimal value of activity for acceptance. [0,1]", m_minActivityState);
42}
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ 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 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overridevirtual

Create the store arrays.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 44 of file TrackCandidateOverlapResolver.cc.

45{
47
49
50 B2ASSERT("ResolveMethod has to be either 'greedy' or 'hopfield'. Selected ResolveMethod: " << m_resolveMethod,
51 m_resolveMethod == "greedy" || m_resolveMethod == "hopfield");
52
53}
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
void initialize() override
Receive and dispatch signal before the start of the event processing.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
virtual void terminate()
Receive Signal for termination of the event processing.

Member Data Documentation

◆ m_initialized

bool m_initialized = false
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_minActivityState

double m_minActivityState = 0.7
private

Minimum of activityState of candidate required to be accepted by the algorithm.

Definition at line 58 of file TrackCandidateOverlapResolver.h.

◆ m_nameSVDClusters

std::string m_nameSVDClusters = "SVDClusters"
private

Name of array of SVDCluster.

Definition at line 52 of file TrackCandidateOverlapResolver.h.

◆ m_resolveMethod

std::string m_resolveMethod = "greedy"
private

Strategy used to resolve overlaps.

Definition at line 55 of file TrackCandidateOverlapResolver.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 52 of file CompositeProcessingSignalListener.h.

◆ m_svdClusters

StoreArray<SVDCluster> m_svdClusters
private

Stay connected to the DataStore for timing improvement.

Definition at line 50 of file TrackCandidateOverlapResolver.h.

◆ m_terminated

bool m_terminated = false
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: