Belle II Software development
SegmentTrackAdderWithNormalization Class Referenceabstract

Add the matched segments to the tracks and normalize the tracks afterwards. More...

#include <SegmentTrackAdderWithNormalization.h>

Inheritance diagram for SegmentTrackAdderWithNormalization:
Findlet< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > &, TrackingUtilities::CDCTrack &, const TrackingUtilities::CDCSegment2D > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

 SegmentTrackAdderWithNormalization ()
 Constructor for registering the sub-findlets.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) override
 Expose the parameters of the sub-findlets.
 
std::string getDescription () override
 Short description of the findlet.
 
void apply (std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > > &relations, std::vector< TrackingUtilities::CDCTrack > &tracks, const std::vector< TrackingUtilities::CDCSegment2D > &segment) override
 Apply the findlet.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void initialize () override
 Receive and dispatch signal before the start of the event processing.
 
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.
 
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
 Type of the base class.
 

Private Attributes

bool m_param_removeUnmatchedSegments = true
 Parameter : Switch to remove hits in segments that have no matching track from all tracks.
 
TrackingUtilities::SingleMatchSelector< TrackingUtilities::CDCTrack, TrackingUtilities::CDCRecoHit3D, TrackingUtilities::HitComperatorm_singleHitSelector
 The selector for finding the track each hit should belong to.
 
TrackNormalizer m_trackNormalizer
 Findlet for performing the normalization of the tracks afterwards.
 
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

Add the matched segments to the tracks and normalize the tracks afterwards.

Also deletes all hits from the tracks, that are part of segments, that were not matched to these tracks.

Definition at line 37 of file SegmentTrackAdderWithNormalization.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

using Super
private
Initial value:
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

Type of the base class.

Definition at line 42 of file SegmentTrackAdderWithNormalization.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Constructor & Destructor Documentation

◆ SegmentTrackAdderWithNormalization()

Constructor for registering the sub-findlets.

Definition at line 23 of file SegmentTrackAdderWithNormalization.cc.

24 : Super()
25{
28}
TrackNormalizer m_trackNormalizer
Findlet for performing the normalization of the tracks afterwards.
TrackingUtilities::SingleMatchSelector< TrackingUtilities::CDCTrack, TrackingUtilities::CDCRecoHit3D, TrackingUtilities::HitComperator > m_singleHitSelector
The selector for finding the track each hit should belong to.
TrackingUtilities::Findlet< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > &, TrackingUtilities::CDCTrack &, const TrackingUtilities::CDCSegment2D > Super
Type of the base 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.

◆ apply()

void apply ( std::vector< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > > & relations,
std::vector< TrackingUtilities::CDCTrack > & tracks,
const std::vector< TrackingUtilities::CDCSegment2D > & segment )
override

Apply the findlet.

Definition at line 46 of file SegmentTrackAdderWithNormalization.cc.

48{
49 // Storage space for the hits
50 // Important to reserve enough space as otherwise references to the elements used by the
51 // `WeightedRelations` in the vector `trackHitRelations` are not valid anymore
52 // !!! We cannot use a deque or list as these do not guarantee valid pointer comparisons as
53 // used by `std::sort` below !!!
54 std::vector<CDCRecoHit3D> recoHits3D;
55 int hit_size = 0;
56 for (const auto& relation : relations) {
57 hit_size += relation.getTo()->size();
58 }
59 for (const CDCSegment2D& segment : segments) {
60 hit_size += segment.size();
61 }
62 for (CDCTrack& track : tracks) {
63 hit_size += track.size();
64 }
65 recoHits3D.reserve(hit_size);
66
67 // Relations for the matching tracks
68 std::vector<WeightedRelation<CDCTrack, const CDCRecoHit3D>> trackHitRelations;
69 trackHitRelations.reserve(2500);
70
71 // We construct track hit relations denoting to which track each hit should belong from 3 sources
72 // 1. From the given track segment matches with the weight of the match
73 // 2. From the unmatch, untaken segments schedule the hits for removal with lower weight
74 // 3. From the original track content with lowest weight
75 // Hence if a hit is mentioned in source 1. it takes precedence over 2. and 3. to so on.
76
77 // 1. Add the relations for the matched segments with the match weight
78 for (const auto& relation : relations) {
79 CDCTrack* track = relation.getFrom();
80 const CDCSegment2D& segment = *(relation.getTo());
81 const Weight weight = relation.getWeight();
82 const CDCTrajectory3D& trajectory3D = track->getStartTrajectory3D();
83
84 for (const CDCRecoHit2D& recoHit : segment) {
85
86 // In case the hit is already in the matched track - keep its reconstructed position
87 MayBePtr<const CDCRecoHit3D> ptrRecoHit3D = track->find(recoHit.getWireHit());
88 if (ptrRecoHit3D != nullptr) {
89 recoHits3D.push_back(*ptrRecoHit3D);
90 trackHitRelations.push_back({track, weight, &recoHits3D.back()});
91 continue;
92 }
93
94 // Otherwise reconstruct the position into the third dimension
95 CDCRecoHit3D recoHit3D = CDCRecoHit3D::reconstruct(recoHit, trajectory3D);
96 if (std::isnan(recoHit3D.getArcLength2D())) {
97 B2DEBUG(25, "Had to skip a NAN hit");
98 continue;
99 }
100 recoHits3D.push_back(recoHit3D);
101 trackHitRelations.push_back({track, weight, &recoHits3D.back()});
102 }
103 segment->setTakenFlag();
104 }
105
106 // 2. Add also those segments, that have no track-partner and schedule them for removal
108 for (const CDCSegment2D& segment : segments) {
109
110 // Skip segment already used in the steps before or marked outside as already taken.
111 if (segment->hasTakenFlag()) continue;
112
113 // Add hit with destination track nullptr
114 for (const CDCRecoHit2D& recoHit : segment) {
115 recoHits3D.push_back({recoHit.getRLWireHit(), Vector3D(recoHit.getRecoPos2D()), 0});
116 trackHitRelations.push_back({nullptr, 0, &recoHits3D.back()});
117 }
118 }
119 }
120
121 // 3. Add the original hit content of the track with lowest priority
122 for (CDCTrack& track : tracks) {
123 for (const CDCRecoHit3D& recoHit3D : track) {
124 recoHits3D.push_back(recoHit3D);
125 // cppcheck-suppress invalidContainer
126 trackHitRelations.push_back({&track, -INFINITY, &recoHits3D.back()});
127 }
128 }
129
130 // Thin out the weighted relations by selecting only the best matching track for each hit.
131 std::sort(trackHitRelations.begin(), trackHitRelations.end());
132 m_singleHitSelector.apply(trackHitRelations);
133
134 // Remove all hits from the tracks in order to rebuild them completely
135 for (CDCTrack& track : tracks) {
136 for (const CDCRecoHit3D& recoHit3D : track) {
137 recoHit3D.getWireHit()->unsetTakenFlag();
138 }
139 track.clear();
140 }
141
142 // Now add the hits to their destination tracks
143 for (const auto& trackHitRelation : trackHitRelations) {
144 CDCTrack* track = trackHitRelation.getFrom();
145 const CDCRecoHit3D* recoHit3D = trackHitRelation.getTo();
146
147 if (track == nullptr) continue;
148
149 track->push_back(*recoHit3D);
150 recoHit3D->getWireHit()->setTakenFlag();
151 }
152
153 // Drop tracks which have no hits
154 erase_remove_if(tracks, [](const CDCTrack & track) { return track.empty(); });
155
156 // Establish the ordering
157 for (CDCTrack& track : tracks) {
158 track.sortByArcLength2D();
159 CDCTrajectory3D startTrajectory = track.getStartTrajectory3D();
160 startTrajectory.setLocalOrigin(track.front().getRecoPos3D());
161 track.setStartTrajectory3D(startTrajectory);
162
163 CDCTrajectory3D endTrajectory = track.getEndTrajectory3D();
164 endTrajectory.setLocalOrigin(track.back().getRecoPos3D());
165 track.setEndTrajectory3D(endTrajectory);
166 }
167
168 // Normalize the trajectory and hit contents of the tracks
169 m_trackNormalizer.apply(tracks);
170}
bool m_param_removeUnmatchedSegments
Parameter : Switch to remove hits in segments that have no matching track from all tracks.
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
void unsetTakenFlag()
Resets the taken flag to false.
const CDCWireHit & getWireHit() const
Getter for the wire hit.
static CDCRecoHit3D reconstruct(const CDCRecoHit2D &recoHit2D, const CDCTrajectory2D &trajectory2D)
Reconstructs the three dimensional hit from the two dimensional and the two dimensional trajectory.
double getArcLength2D() const
Getter for the travel distance in the xy projection.
double setLocalOrigin(const Vector3D &localOrigin)
Setter for the origin of the local coordinate system.
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34

◆ 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 SegmentTrackAdderWithNormalization.cc.

31{
32 m_singleHitSelector.exposeParameters(moduleParamList, prefixed(prefix, "hitSelector"));
33 moduleParamList->addParameter(prefixed(prefix, "removeUnmatchedSegments"),
35 "Switch to remove hits in segments that have no matching track from all tracks",
37
38}
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
overridevirtual

Short description of the findlet.

Reimplemented from Findlet< TrackingUtilities::WeightedRelation< TrackingUtilities::CDCTrack, const TrackingUtilities::CDCSegment2D > &, TrackingUtilities::CDCTrack &, const TrackingUtilities::CDCSegment2D >.

Definition at line 40 of file SegmentTrackAdderWithNormalization.cc.

41{
42 return "Add the matched segments to the tracks and normalize the tracks afterwards. Also deletes all "
43 "hits from tracks, that are now part in another track (or should not be part in any).";
44}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overrideinherited

Receive and dispatch signal before the start of the event processing.

Definition at line 30 of file CompositeProcessingSignalListener.cc.

16{
19 psl->initialize();
20 }
21}
void initialize() override
Receive and dispatch signal before the start of the event processing.
virtual void initialize()
Receive signal before the start of the event processing.

◆ 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_param_removeUnmatchedSegments

bool m_param_removeUnmatchedSegments = true
private

Parameter : Switch to remove hits in segments that have no matching track from all tracks.

Definition at line 63 of file SegmentTrackAdderWithNormalization.h.

◆ m_singleHitSelector

The selector for finding the track each hit should belong to.

Definition at line 68 of file SegmentTrackAdderWithNormalization.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.

◆ m_trackNormalizer

TrackNormalizer m_trackNormalizer
private

Findlet for performing the normalization of the tracks afterwards.

Definition at line 71 of file SegmentTrackAdderWithNormalization.h.


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