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< WeightedRelation< CDCTrack, const CDCSegment2D > &, CDCTrack &, const CDCSegment2D > 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

 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< WeightedRelation< CDCTrack, const CDCSegment2D > > &relations, std::vector< CDCTrack > &tracks, const std::vector< 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 = 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 = Findlet< WeightedRelation< CDCTrack, const CDCSegment2D > &, CDCTrack &, const CDCSegment2D >
 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.
 
SingleMatchSelector< CDCTrack, CDCRecoHit3D, 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 = 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

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 34 of file SegmentTrackAdderWithNormalization.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

Type of the base class.

Definition at line 39 of file SegmentTrackAdderWithNormalization.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
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 22 of file SegmentTrackAdderWithNormalization.cc.

23 : Super()
24{
27}
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
TrackNormalizer m_trackNormalizer
Findlet for performing the normalization of the tracks afterwards.
Findlet< WeightedRelation< CDCTrack, const CDCSegment2D > &, CDCTrack &, const CDCSegment2D > Super
Type of the base class.
SingleMatchSelector< CDCTrack, CDCRecoHit3D, HitComperator > m_singleHitSelector
The selector for finding the track each hit should belong to.

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< WeightedRelation< CDCTrack, const CDCSegment2D > > &  relations,
std::vector< CDCTrack > &  tracks,
const std::vector< CDCSegment2D > &  segment 
)
override

Apply the findlet.

Definition at line 45 of file SegmentTrackAdderWithNormalization.cc.

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

◆ 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< WeightedRelation< CDCTrack, const CDCSegment2D > &, CDCTrack &, const CDCSegment2D >.

Definition at line 29 of file SegmentTrackAdderWithNormalization.cc.

30{
31 m_singleHitSelector.exposeParameters(moduleParamList, prefixed(prefix, "hitSelector"));
32 moduleParamList->addParameter(prefixed(prefix, "removeUnmatchedSegments"),
34 "Switch to remove hits in segments that have no matching track from all tracks",
36
37}
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< WeightedRelation< CDCTrack, const CDCSegment2D > &, CDCTrack &, const CDCSegment2D >.

Definition at line 39 of file SegmentTrackAdderWithNormalization.cc.

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

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
overridevirtualinherited

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

Reimplemented from ProcessingSignalListener.

Reimplemented in UnionVarSet< AObject >, UnionVarSet< Object >, VariadicUnionVarSet< AVarSets >, ResultStorer< Belle2::CKFToPXDResult >, ResultStorer< Belle2::CKFToSVDResult >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >, OnVarSet< Filter< ATruthVarSet::Object > >, OnVarSet< Filter< AVarSet::Object > >, OnVarSet< BaseFacetFilter >, OnVarSet< BaseFacetRelationFilter >, OnVarSet< BaseAxialSegmentPairFilter >, OnVarSet< BaseSegmentRelationFilter >, OnVarSet< BaseTrackRelationFilter >, OnVarSet< BaseSegmentPairRelationFilter >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreArrayLoader< const Belle2::SpacePoint >, StoreArrayLoader< DataStoreInputTypeRefType >, 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 >, RelationVarSet< ABaseVarSet >, QualityIndicatorFilter, TwoHitVirtualIPQIFilter, MultiHoughSpaceFastInterceptFinder, RawTrackCandCleaner< AHit >, RawTrackCandCleaner< Belle2::vxdHoughTracking::VXDHoughState >, RecoTrackStorer, ROIFinder, SingleHoughSpaceFastInterceptFinder, SpacePointLoaderAndPreparer, TrackCandidateOverlapResolver, and TrackCandidateResultRefiner.

Definition at line 15 of file CompositeProcessingSignalListener.cc.

16{
19 psl->initialize();
20 }
21}
virtual void initialize()
Receive 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_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 58 of file SegmentTrackAdderWithNormalization.h.

◆ m_singleHitSelector

SingleMatchSelector<CDCTrack, CDCRecoHit3D, HitComperator> m_singleHitSelector
private

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

Definition at line 62 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 52 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
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 65 of file SegmentTrackAdderWithNormalization.h.


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