8#include <tracking/trackFindingCDC/findlets/minimal/SegmentTrackAdderWithNormalization.h>
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
11#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13#include <framework/core/ModuleParamList.templateDetails.h>
15#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16#include <tracking/trackFindingCDC/utilities/Algorithms.h>
20using namespace TrackFindingCDC;
32 moduleParamList->
addParameter(prefixed(prefix,
"removeUnmatchedSegments"),
34 "Switch to remove hits in segments that have no matching track from all tracks",
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).";
46 std::vector<CDCTrack>& tracks,
const std::vector<CDCSegment2D>& segments)
53 std::vector<CDCRecoHit3D> recoHits3D;
55 for (
const auto& relation : relations) {
56 hit_size += relation.getTo()->size();
59 hit_size += segment.size();
62 hit_size += track.size();
64 recoHits3D.reserve(hit_size);
67 std::vector<WeightedRelation<CDCTrack, const CDCRecoHit3D>> trackHitRelations;
68 trackHitRelations.reserve(2500);
77 for (
const auto& relation : relations) {
78 CDCTrack* track = relation.getFrom();
80 const Weight weight = relation.getWeight();
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()});
96 B2DEBUG(25,
"Had to skip a NAN hit");
99 recoHits3D.push_back(recoHit3D);
100 trackHitRelations.push_back({track, weight, &recoHits3D.back()});
102 segment->setTakenFlag();
110 if (segment->hasTakenFlag())
continue;
114 recoHits3D.push_back({recoHit.getRLWireHit(),
Vector3D(recoHit.getRecoPos2D()), 0});
115 trackHitRelations.push_back({
nullptr, 0, &recoHits3D.back()});
123 recoHits3D.push_back(recoHit3D);
125 trackHitRelations.push_back({&track, -INFINITY, &recoHits3D.back()});
130 std::sort(trackHitRelations.begin(), trackHitRelations.end());
136 recoHit3D.getWireHit()->unsetTakenFlag();
142 for (
const auto& trackHitRelation : trackHitRelations) {
143 CDCTrack* track = trackHitRelation.getFrom();
144 const CDCRecoHit3D* recoHit3D = trackHitRelation.getTo();
146 if (track ==
nullptr)
continue;
148 track->push_back(*recoHit3D);
153 TrackFindingCDC::erase_remove_if(tracks, [](
const CDCTrack & track) {
return track.empty(); });
157 track.sortByArcLength2D();
160 track.setStartTrajectory3D(startTrajectory);
164 track.setEndTrajectory3D(endTrajectory);
The Module parameter list class.
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Class representing a three dimensional reconstructed hit.
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.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a sequence of three dimensional reconstructed hits.
Particle full three dimensional trajectory.
double setLocalOrigin(const Vector3D &localOrigin)
Setter for the origin of the local coordinate system.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
void apply(std::vector< WeightedRelation< CDCTrack, const CDCSegment2D > > &relations, std::vector< CDCTrack > &tracks, const std::vector< CDCSegment2D > &segment) override
Apply the findlet.
std::string getDescription() override
Short description of the findlet.
TrackNormalizer m_trackNormalizer
Findlet for performing the normalization of the tracks afterwards.
SingleMatchSelector< CDCTrack, CDCRecoHit3D, HitComperator > m_singleHitSelector
The selector for finding the track each hit should belong to.
bool m_param_removeUnmatchedSegments
Parameter : Switch to remove hits in segments that have no matching track from all tracks.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub-findlets.
SegmentTrackAdderWithNormalization()
Constructor for registering the sub-findlets.
void apply(std::vector< CDCTrack > &tracks) final
Fit the tracks.
A three dimensional vector.
Type for two related objects with a weight.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.