CbmRoot
Loading...
Searching...
No Matches
CaParameters.h
Go to the documentation of this file.
1/* Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
9
10#pragma once // include this header only once per compilation unit
11
12#include "CaDefs.h"
13#include "CaIteration.h"
14#include "CaSearchWindow.h"
15#include "CaStation.h"
16#include "CaVector.h"
17#include "KfFieldRegion.h"
18#include "KfSetup.h"
19
20#include <boost/serialization/array.hpp>
21#include <boost/serialization/utility.hpp>
22
23#include <array>
24#include <numeric>
25#include <type_traits>
26#include <utility>
27
28namespace cbm::algo::ca
29{
30 class InitManager;
31 enum class EDetectorID;
32
33 using constants::Undef;
34
37 template<typename DataT>
38 using StationsContainer_t = std::array<ca::Station<DataT>, constants::size::MaxNstations>;
39
46
53 template<typename DataT>
54 class alignas(constants::misc::Alignment) Parameters {
56 friend class InitManager;
57
58 using DetectorID_t = std::underlying_type_t<EDetectorID>;
59 template<typename T>
60 using StationArray_t = std::array<T, constants::size::MaxNstations>;
61
62 public:
64 Parameters();
65
67 ~Parameters() noexcept = default;
68
70 Parameters(const Parameters& other) = default;
71
73 template<typename DataIn>
74 Parameters(const Parameters<DataIn>& other)
90 , fRandomSeed(other.GetRandomSeed())
102 {
103 fTargetPos[0] = kfutils::simd::Cast<DataIn, DataT>(other.GetTargetPositionX());
104 fTargetPos[1] = kfutils::simd::Cast<DataIn, DataT>(other.GetTargetPositionY());
105 fTargetPos[2] = kfutils::simd::Cast<DataIn, DataT>(other.GetTargetPositionZ());
106 for (size_t i = 0; i < constants::size::MaxNstations; i++) {
107 fStations[i] = other.GetStation(i);
108 }
109 }
110
112 Parameters& operator=(const Parameters& other) = default;
113
115 Parameters(Parameters&& other) = default;
116
118 Parameters& operator=(Parameters&& other) = default;
119
121 void Print(int verbosityLevel = 0) const;
122
126 std::string ToString(int verbosity = 0, int indentLevel = 0) const;
127
129 unsigned int GetMaxDoubletsPerSinglet() const { return fMaxDoubletsPerSinglet; }
130
132 unsigned int GetMaxTripletPerDoublets() const { return fMaxTripletPerDoublets; }
133
136
138 int GetNstationsActive(EDetectorID detectorID) const;
139
141 int GetNstationsGeometry() const { return fvFirstGeoId.back(); }
142
144 int GetNstationsGeometry(EDetectorID detectorID) const
145 {
146 return fvFirstGeoId[static_cast<int>(detectorID) + 1] - fvFirstGeoId[static_cast<int>(detectorID)];
147 }
148
150 const std::array<int, constants::size::MaxNdetectors + 1>& GetFirstGeoId() const { return fvFirstGeoId; }
151
155 [[gnu::always_inline]] std::pair<EDetectorID, int> GetStationIndexLocal(int geoIndex) const
156 {
157 return fvGeoToLocalIdMap[geoIndex];
158 }
159
162
166 [[gnu::always_inline]] int GetStationIndexGeometry(int localIndex, EDetectorID detectorID) const
167 {
168 if (localIndex >= GetNstationsGeometry(detectorID)) {
169 return -1;
170 }
171 return fvLocalToGeoIdMap[fvFirstGeoId[static_cast<int>(detectorID)] + localIndex];
172 }
173
176
180 [[gnu::always_inline]] int GetStationIndexActive(int localIndex, EDetectorID detectorID) const
181 {
182 int geoIndex = GetStationIndexGeometry(localIndex, detectorID);
183 return (geoIndex < 0) ? -1 : fvGeoToActiveMap[geoIndex];
184 }
185
188
191
194
196 int GetNcaIterations() const { return fCAIterations.size(); }
197
200
203 const Station<DataT>& GetStation(int iStation) const { return fStations[iStation]; }
204
211 const SearchWindow& GetSearchWindow(int iStation, int iTrackGr) const
212 {
213 assert(iStation < fNstationsActiveTotal && iStation > 0);
214 assert(iTrackGr < int(fCAIterations.size()));
215 return fSearchWindows[iTrackGr * constants::size::MaxNstations + iStation];
216 }
217
219 const std::array<SearchWindow, constants::size::MaxNstations * constants::size::MaxNtrackGroups>&
221 {
222 return fSearchWindows;
223 }
224
226 DataT GetTargetPositionX() const { return fTargetPos[0]; }
227
229 DataT GetTargetPositionY() const { return fTargetPos[1]; }
230
232 DataT GetTargetPositionZ() const { return fTargetPos[2]; }
233
236
239
243 int GetRandomSeed() const { return fRandomSeed; }
244
246 const auto& GetActiveSetup() const { return fActiveSetup; }
247
249 const auto& GetGeometrySetup() const { return fGeometrySetup; }
250
253
255 float GetDefaultMass() const { return fDefaultMass; }
256
259 {
260 auto iDet = static_cast<DetectorID_t>(detId);
261 return fMisalignmentX[iDet] * fMisalignmentX[iDet];
262 }
263
266 {
267 auto iDet = static_cast<DetectorID_t>(detId);
268 return fMisalignmentY[iDet] * fMisalignmentY[iDet];
269 }
270
273 {
274 auto iDet = static_cast<DetectorID_t>(detId);
275 return fMisalignmentT[iDet] * fMisalignmentT[iDet];
276 }
277
279 const std::array<float, constants::size::MaxNdetectors> GetMisalignmentX() const { return fMisalignmentX; }
280
282 const std::array<float, constants::size::MaxNdetectors> GetMisalignmentY() const { return fMisalignmentY; }
283
285 const std::array<float, constants::size::MaxNdetectors> GetMisalignmentT() const { return fMisalignmentT; }
286
289 bool IsActive(EDetectorID detId) const { return GetNstationsActive(detId) != 0; }
290
292 void CheckConsistency() const;
293
294 // ***************************
295 // ** Flags for development **
296 // ***************************
297
300
303
306
309
312
315
317
318 private:
321
324
325 unsigned int fMaxDoubletsPerSinglet{150};
326 unsigned int fMaxTripletPerDoublets{15};
327
329 "ca::Parameters::fCAIterations"};
330
331 /*************************
332 ** Geometry parameters **
333 *************************/
335 alignas(constants::misc::Alignment) std::array<DataT, 3> fTargetPos{Undef<float>, Undef<float>, Undef<float>};
336
339
342
345
346 // ** Station layout arrays **
350 alignas(constants::misc::Alignment) std::array<int, constants::size::MaxNdetectors + 1> fvFirstGeoId{};
351
358
360 alignas(constants::misc::Alignment) StationArray_t<std::pair<EDetectorID, int>> fvGeoToLocalIdMap{};
361
370
373
374
376
377
383 std::array<SearchWindow, constants::size::MaxNstations* constants::size::MaxNtrackGroups> fSearchWindows = {};
384
386 int fRandomSeed = 1;
388
390 std::array<float, constants::size::MaxNdetectors> fMisalignmentX{0.};
391
393 std::array<float, constants::size::MaxNdetectors> fMisalignmentY{0.};
394
396 std::array<float, constants::size::MaxNdetectors> fMisalignmentT{0.};
397
398 // ***************************
399 // ** Flags for development **
400 // ***************************
401
408
409 bool fDevIsParSearchWUsed = false;
411
414 template<class Archive>
415 void serialize(Archive& ar, const unsigned int)
416 {
419
420 ar& fCAIterations;
421 ar& fTargetPos;
422
425
426 ar& fStations;
427
428 ar& fvFirstGeoId;
434
435 ar& fSearchWindows;
436
438 ar& fRandomSeed;
439 ar& fDefaultMass;
440
441 ar& fMisalignmentX;
442 ar& fMisalignmentY;
443 ar& fMisalignmentT;
444
451 }
452 };
453} // namespace cbm::algo::ca
Compile-time constants definition for the CA tracking algorithm.
Magnetic flux density interpolation along the track vs. z-coordinate (header)
Setup representation for the Kalman-filter framework (header)
A CA Parameters object initialization class.
A container for all external parameters of the CA tracking algorithm.
DataT GetTargetPositionX() const
Gets X component of target position.
bool DevIsUseOfOriginalField() const
Is original field must be used instead of the approximated one.
StationArray_t< int > fvGeoToActiveMap
void serialize(Archive &ar, const unsigned int)
const std::array< SearchWindow, constants::size::MaxNstations *constants::size::MaxNtrackGroups > & GetSearchWindows() const
Provides access to the map of search windows vs. active station global index and tracks group (const)
StationArray_t< int > fvLocalToGeoIdMap
Map of (local, det) to geo indices.
int fGhostSuppression
flag: if true, ghost tracks are suppressed
const auto & GetActiveSetup() const
Gets active setup.
float GetDefaultMass() const
Gets default mass.
const SearchWindow & GetSearchWindow(int iStation, int iTrackGr) const
Gets a search window for a selected station and track group.
StationArray_t< int > fvActiveToGeoMap
Map of active to geo indices.
int GetStationIndexActive(int localIndex, EDetectorID detectorID) const
Calculates global index of station used by track finder.
DataT GetTargetPositionZ() const
Gets Z component of target position.
std::array< float, constants::size::MaxNdetectors > fMisalignmentY
misalignment of the detector systems in Y
bool fDevIsMatchTripletsViaMc
Flag to match triplets using Mc information.
int GetNstationsGeometry(EDetectorID detectorID) const
Gets number of stations, provided by setup geometry for given detector ID.
DataT GetTargetPositionY() const
Gets Y component of target position.
bool DevIsMatchTripletsViaMc() const
Flag to match triplets using Mc information.
std::array< float, constants::size::MaxNdetectors > fMisalignmentX
misalignment of the detector systems in X
int GetNstationsGeometry() const
Gets total number of stations, provided by setup geometry.
IterationsContainer_t fCAIterations
L1 tracking iterations vector.
bool DevIsIgnoreHitSearchAreas() const
Are the hit search areas ignored.
bool DevIsMatchDoubletsViaMc() const
Flag to match doublets using MC information.
bool fDevIsExtendTracksViaMc
Flag to extend tracks using Mc information.
float GetMisalignmentXsq(EDetectorID detId) const
Gets misalignment of the detector systems in X, squared rms.
std::string ToString(int verbosity=0, int indentLevel=0) const
String representation of the class contents.
~Parameters() noexcept=default
Destructor.
int GetNstationsActive() const
Gets total number of active stations.
std::array< int, constants::size::MaxNdetectors+1 > fvFirstGeoId
First index of the station on the particular detector.
bool DevIsExtendTracksViaMc() const
Flag to extend tracks using Mc information.
kf::Setup< DataT > fGeometrySetup
Geometrical KF-setup (including inactive stations)
const kf::FieldRegion< DataT > & GetVertexFieldRegion() const
Gets kf::FieldRegion object at primary vertex.
const std::array< float, constants::size::MaxNdetectors > GetMisalignmentY() const
Provides access to the misalignment of the detector systems in Y.
float GetMisalignmentYsq(EDetectorID detId) const
Gets misalignment of the detector systems in Y, squared rms.
StationArray_t< std::pair< EDetectorID, int > > fvGeoToLocalIdMap
Map of geo to (local, det) indices.
int GetGhostSuppression() const
Gets ghost suppression flag.
std::array< T, constants::size::MaxNstations > StationArray_t
const StationArray_t< int > & GetGeoToActiveMap() const
Provides access to global indexes of stations used by track finder (const)
const StationArray_t< int > & GetActiveToGeoMap() const
Provides access to the map of active to geo station indices (const)
Parameters & operator=(Parameters &&other)=default
Move assignment operator.
int fNstationsActiveTotal
total number of active tracking stations
void Print(int verbosityLevel=0) const
Prints configuration.
bool fDevIsSuppressOverlapHitsViaMc
Flag to match hits in overlaps using Mc information.
const StationsContainer_t< DataT > & GetStations() const
Provides access to L1Stations container (const)
const std::array< int, constants::size::MaxNdetectors+1 > & GetFirstGeoId() const
Provides access to the first index of the station on each particular detector (const)
unsigned int GetMaxDoubletsPerSinglet() const
Gets upper-bound cut on max number of doublets per one singlet.
std::array< float, constants::size::MaxNdetectors > fMisalignmentT
miscalibration of the detector systems in Time
int GetStationIndexGeometry(int localIndex, EDetectorID detectorID) const
Calculates global index of station among geometry (accounts for inactive stations)
const IterationsContainer_t & GetCAIterations() const
Provides access to L1CAIteration vector (const)
unsigned int GetMaxTripletPerDoublets() const
Gets upper-bound cut on max number of triplets per one doublet.
float GetMisalignmentTsq(EDetectorID detId) const
Gets miscalibration of the detector systems in Time, squared rms.
kf::Setup< DataT > fActiveSetup
Active KF-setup (every layer is an active tracking station)
const Station< DataT > & GetStation(int iStation) const
Gets reference to the particular station.
bool fDevIsMatchDoubletsViaMc
Flag to match doublets using MC information.
kf::FieldValue< DataT > fVertexFieldValue
Field value object at primary vertex (between target and the first station)
const auto & GetGeometrySetup() const
Gets active setup.
const std::array< float, constants::size::MaxNdetectors > GetMisalignmentT() const
Provides access to the misalignment of the detector systems in Time.
unsigned int fMaxDoubletsPerSinglet
Upper-bound cut on max number of doublets per one singlet.
const StationArray_t< std::pair< EDetectorID, int > > & GetGeoToLocalIdMap() const
Provides access to local indexes of stations (const)
StationsContainer_t< DataT > fStations
Array of stations.
void CheckConsistency() const
Class invariant checker.
bool fDevIsUseOfOriginalField
Force use of original field.
Parameters & operator=(const Parameters &other)=default
Copy assignment operator.
friend class boost::serialization::access
Serialization function.
std::underlying_type_t< EDetectorID > DetectorID_t
const StationArray_t< int > & GetLocalToGeoIdMap() const
Provides access to global indexes of stations among geometry (const)
Parameters(Parameters &&other)=default
Move constructor.
kf::FieldRegion< DataT > fVertexFieldRegion
Field region object at primary vertex (between target and the first station)
const kf::FieldValue< DataT > & GetVertexFieldValue() const
Gets kf::FieldValue object at primary vertex.
unsigned int fMaxTripletPerDoublets
Upper-bound cut on max number of triplets per one doublet.
int GetRandomSeed() const
Gets random seed.
bool DevIsParSearchWUsed() const
const std::array< float, constants::size::MaxNdetectors > GetMisalignmentX() const
Provides access to the misalignment of the detector systems in X.
bool IsActive(EDetectorID detId) const
Checks, if the detector subsystem active.
bool DevIsSuppressOverlapHitsViaMc() const
Flag to match hits in overlaps using Mc information.
bool fDevIsIgnoreHitSearchAreas
Process all hits on the station ignoring hit search area.
Parameters()
Default constructor.
std::pair< EDetectorID, int > GetStationIndexLocal(int geoIndex) const
Gets local index of station.
int GetNcaIterations() const
Provides number of iterations.
std::array< SearchWindow, constants::size::MaxNstations *constants::size::MaxNtrackGroups > fSearchWindows
Map of search windows vs. active station global index and tracks group.
std::array< DataT, 3 > fTargetPos
Target position.
Class L1SearchWindow defines a parameterisation of hits search window for CA tracking algorithm TODO:...
Magnetic field region, corresponding to a hit triplet.
Magnetic flux density vector.
KF-framework representation of the detector setup.
Definition KfSetup.h:33
constexpr int Alignment
Default alignment of data (bytes)
Definition CaDefs.h:103
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 T2 Undef
Undefined values.
Definition CaDefs.h:110
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176
std::array< ca::Station< DataT >, constants::size::MaxNstations > StationsContainer_t
@ Intrpl
Interpolated magnetic field.