CbmRoot
Loading...
Searching...
No Matches
CaTrackFinderWindow.h
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer], Maksym Zyzak */
4
9
10#pragma once // include this header only once per compilation unit
11
12#include "CaBranch.h"
13#include "CaCloneMerger.h"
14#include "CaGrid.h"
15#include "CaHit.h"
16#include "CaSimd.h"
17#include "CaTrackExtender.h"
18#include "CaTrackFitter.h"
19#include "CaTrackingMonitor.h"
20#include "CaVector.h"
21#include "CaWindowData.h"
22
23namespace cbm::algo::ca
24{
25
26 class Track;
27 class Triplet;
28 class Framework;
29
33 public:
35 TrackFinderWindow(const ca::Parameters<fvec>& pars, const fscal mass, const ca::TrackingMode& mode,
36 ca::TrackingMonitorData& monitorData);
38 ~TrackFinderWindow() = default;
39
42
45
48
51
52 void CaTrackFinderSlice(const ca::InputData& input, WindowData& wData);
53
55 void InitTimeslice(size_t nHitKeys) { fvHitKeyToTrack.reset(nHitKeys, -1); }
56
57 private:
60
61 typedef std::array<Vector<ca::Triplet>, constants::size::MaxNstations> TripletArray_t;
62
63 // TripletData_t:
64 // 1 -> vHitFirstTriplet /// link hit -> first triplet { hit, *, *}
65 // 2 -> vHitNofTriplets /// link hit ->n triplets { hit, *, *}
66 // 3 -> vTriplets;
67 typedef std::tuple<Vector<int>, Vector<int>, TripletArray_t> TripletData_t;
68
69 void ConstructTriplets(WindowData& wData);
70
71 void ReadWindowData(const Vector<Hit>& hits, WindowData& wData);
72
73 void PrepareGrid(const Vector<Hit>& hits, WindowData& wData);
74
75 void PrepareCAIteration(const ca::Iteration& caIteration, WindowData& wData, const bool isFirst);
76
77 void CreateTracks(WindowData& wData, const ca::Iteration& caIteration, TripletArray_t& vTriplets);
78
79 void CreateTrackCandidates(WindowData& wData, TripletArray_t& vTriplets, const int min_level,
80 const int firstTripletLevel);
81
82 void DoCompetitionLoop(const WindowData& wData);
83
84 void SelectTracks(WindowData& wData);
85
86 void SearchNeighbors(WindowData& wData);
87
88 void CAFindTrack(int ista, ca::Branch& best_tr, const ca::Triplet* curr_trip, ca::Branch& curr_tr,
89 unsigned char min_best_l, ca::Branch* new_tr, WindowData& wData, TripletArray_t& vTriplets);
90
91 bool checkTripletMatch(const ca::Triplet& l, const ca::Triplet& r, fscal& dchi2, WindowData& wData) const;
92
93 // ** Functions, which pack and unpack indexes of station and triplet **
94
95 // TODO: move to ca::Triplet class (S.Zharko)
99 static unsigned int PackTripletId(unsigned int iStation, unsigned int iTriplet);
100
103 static unsigned int TripletId2Station(unsigned int id);
104
107 static unsigned int TripletId2Triplet(unsigned int id);
108
109
110 private:
113
114 static constexpr bool fDebug = false; // print debug info
115
119
124
126 Vector<int> fvHitKeyToTrack{"TrackFinderWindow::fvHitKeyToTrack"};
127
128 // Persistent to avoid memory allocations.
129 // Only used in CreateTrackCandidates().
131
132 // Track candidates created out of adjacent triplets before the final track selection.
133 // The candidates may share any amount of hits.
134 Vector<ca::Branch> fvTrackCandidates{"TrackFinderWindow::fvTrackCandidates"};
135
136 // Triplets and related meta data
138
139 // Triplet temporary storage. Only used in ConstructTriplets().
141 };
142
143 // ********************************************
144 // ** Inline member functions implementation **
145 // ********************************************
146
147 // ---------------------------------------------------------------------------------------------------------------------
148 //
149 [[gnu::always_inline]] inline unsigned int TrackFinderWindow::PackTripletId(unsigned int iStation,
150 unsigned int iTriplet)
151 {
152 assert(iStation < constants::size::MaxNstations);
153 assert(iTriplet < constants::size::MaxNtriplets);
154 constexpr unsigned int kMoveStation = constants::size::TripletBits;
155 return (iStation << kMoveStation) + iTriplet;
156 }
157
158 // ---------------------------------------------------------------------------------------------------------------------
159 //
160 [[gnu::always_inline]] inline unsigned int TrackFinderWindow::TripletId2Station(unsigned int id)
161 {
162 constexpr unsigned int kMoveStation = constants::size::TripletBits;
163 return id >> kMoveStation;
164 }
165
166 // ---------------------------------------------------------------------------------------------------------------------
167 //
168 [[gnu::always_inline]] inline unsigned int TrackFinderWindow::TripletId2Triplet(unsigned int id)
169 {
170 constexpr unsigned int kTripletMask = (1u << constants::size::TripletBits) - 1u;
171 return id & kTripletMask;
172 }
173
174
175} // namespace cbm::algo::ca
A class to store hit information in a backet-sorted way on 2D grid.
A generic hit for the CA tracker (header)
Monitor specialization for the tracking algorithm.
Container for all data, which are processed within a single sub-timeslice (implementation)
static vector< vector< QAHit > > hits
A set of parameters for the CA Track finder iteration.
A container for all external parameters of the CA tracking algorithm.
TrackFinderWindow & operator=(TrackFinderWindow &&)=delete
Move assignment operator.
TrackExtender fTrackExtender
Object of the track extender algorithm.
TrackFinderWindow(const TrackFinderWindow &)=default
Copy constructor.
std::tuple< Vector< int >, Vector< int >, TripletArray_t > TripletData_t
TrackFinderWindow & operator=(const TrackFinderWindow &)=delete
Copy assignment operator.
TrackFitter fTrackFitter
Object of the track extender algorithm.
TrackFinderWindow(TrackFinderWindow &&)=default
Move constructor.
CloneMerger fCloneMerger
Object of the clone merger algorithm.
void CAFindTrack(int ista, ca::Branch &best_tr, const ca::Triplet *curr_trip, ca::Branch &curr_tr, unsigned char min_best_l, ca::Branch *new_tr, WindowData &wData, TripletArray_t &vTriplets)
~TrackFinderWindow()=default
Destructor.
void CreateTrackCandidates(WindowData &wData, TripletArray_t &vTriplets, const int min_level, const int firstTripletLevel)
ca::Branch fNewTr[constants::size::MaxNstations]
const Parameters< fvec > & fParameters
Object of Framework parameters class.
static unsigned int TripletId2Triplet(unsigned int id)
void DoCompetitionLoop(const WindowData &wData)
std::array< Vector< ca::Triplet >, constants::size::MaxNstations > TripletArray_t
fscal fDefaultMass
mass of the propagated particle [GeV/c2]
TrackFinderWindow(const ca::Parameters< fvec > &pars, const fscal mass, const ca::TrackingMode &mode, ca::TrackingMonitorData &monitorData)
Default constructor.
bool checkTripletMatch(const ca::Triplet &l, const ca::Triplet &r, fscal &dchi2, WindowData &wData) const
static unsigned int PackTripletId(unsigned int iStation, unsigned int iTriplet)
void CaTrackFinderSlice(const ca::InputData &input, WindowData &wData)
void PrepareCAIteration(const ca::Iteration &caIteration, WindowData &wData, const bool isFirst)
TrackingMonitorData & frMonitorData
Reference to monitor data.
void ReadWindowData(const Vector< Hit > &hits, WindowData &wData)
static unsigned int TripletId2Station(unsigned int id)
Triplet class represents a short 3-hits track segment called a "triplet".
Definition CaTriplet.h:22
void reset(std::size_t count, Tinput... value)
Clears vector and resizes it to the selected size with selected values.
Definition CaVector.h:121
Container for internal data, processed on a single time window.
constexpr fscal MuonMass
Particle masses etc used for the track fit, fscal precision.
Definition CaDefs.h:83
constexpr int MaxNstations
Max number of stations, 2^6 = 64.
Definition CaDefs.h:44
constexpr unsigned int TripletBits
Amount of bits to code one triplet.
Definition CaDefs.h:41
constexpr int MaxNtriplets
Max number of triplets, 2^26 = 67,108,864.
Definition CaDefs.h:45
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
@ Triplet
number of triplets
kf::fscal fscal
Definition CaSimd.h:14