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
 Types that should be served to apply on invocation.
 
using IOVectors
 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 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
 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
 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

Findlet for rejecting wrong SpacePointTrackCands and for removing bad hits.

Definition at line 28 of file TrackCandidateOverlapResolver.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

Parent class.

Definition at line 30 of file TrackCandidateOverlapResolver.h.

◆ ToVector

using ToVector
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 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

◆ 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}
unsigned short doHopfield(std::vector< OverlapResolverNodeInfo > &overlapResolverNodeInfos, unsigned short nIterations=20)
Performance of the actual algorithm.
void performSelection(std::vector< OverlapResolverNodeInfo > &overlapResolverNodeInfo)
Sets the isActive flag in m_qiTrackOverlap to false, for killed tracks.
Definition Scrooge.h:33
@ c_isActive
bit 11: SPTC is active (i.e.
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 ( )
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()

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

Expose the parameters of the sub findlets.

Reimplemented from CompositeProcessingSignalListener.

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)
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription() [1/2]

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 }

◆ getDescription() [2/2]

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()

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}

◆ terminate()

void terminate ( )
overrideinherited

Receive and dispatch Signal for termination of the event processing.

Definition at line 42 of file CompositeProcessingSignalListener.cc.

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

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_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 60 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
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: