CbmRoot
Loading...
Searching...
No Matches
KfDefs.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#ifndef KF_CORE_KfDefs_h
11#define KF_CORE_KfDefs_h 1
12
13#include "KfSimd.h"
14
15#include <array>
16#include <functional>
17#include <limits>
18#include <tuple>
19
20namespace cbm::algo::kf
21{
22 // ---- Tag dispatching ------------------------------------------------------------------------------------------------
23
27 template<auto...>
28 struct Tag {
29 };
30
31 static constexpr Tag<0, 0> Tag00 = {};
32 static constexpr Tag<0, 1> Tag01 = {};
33 static constexpr Tag<0, 2> Tag02 = {};
34 static constexpr Tag<0, 3> Tag03 = {};
35 static constexpr Tag<0, 4> Tag04 = {};
36 static constexpr Tag<0, 5> Tag05 = {};
37 static constexpr Tag<0, 6> Tag06 = {};
38 static constexpr Tag<0, 7> Tag07 = {};
39
40 static constexpr Tag<1, 0> Tag10 = {};
41 static constexpr Tag<1, 1> Tag11 = {};
42 static constexpr Tag<1, 2> Tag12 = {};
43 static constexpr Tag<1, 3> Tag13 = {};
44 static constexpr Tag<1, 4> Tag14 = {};
45 static constexpr Tag<1, 5> Tag15 = {};
46 static constexpr Tag<1, 6> Tag16 = {};
47 static constexpr Tag<1, 7> Tag17 = {};
48
49 static constexpr Tag<2, 0> Tag20 = {};
50 static constexpr Tag<2, 1> Tag21 = {};
51 static constexpr Tag<2, 2> Tag22 = {};
52 static constexpr Tag<2, 3> Tag23 = {};
53 static constexpr Tag<2, 4> Tag24 = {};
54 static constexpr Tag<2, 5> Tag25 = {};
55 static constexpr Tag<2, 6> Tag26 = {};
56 static constexpr Tag<2, 7> Tag27 = {};
57
58 static constexpr Tag<3, 0> Tag30 = {};
59 static constexpr Tag<3, 1> Tag31 = {};
60 static constexpr Tag<3, 2> Tag32 = {};
61 static constexpr Tag<3, 3> Tag33 = {};
62 static constexpr Tag<3, 4> Tag34 = {};
63 static constexpr Tag<3, 5> Tag35 = {};
64 static constexpr Tag<3, 6> Tag36 = {};
65 static constexpr Tag<3, 7> Tag37 = {};
66
67 static constexpr Tag<4, 0> Tag40 = {};
68 static constexpr Tag<4, 1> Tag41 = {};
69 static constexpr Tag<4, 2> Tag42 = {};
70 static constexpr Tag<4, 3> Tag43 = {};
71 static constexpr Tag<4, 4> Tag44 = {};
72 static constexpr Tag<4, 5> Tag45 = {};
73 static constexpr Tag<4, 6> Tag46 = {};
74 static constexpr Tag<4, 7> Tag47 = {};
75
76 static constexpr Tag<5, 0> Tag50 = {};
77 static constexpr Tag<5, 1> Tag51 = {};
78 static constexpr Tag<5, 2> Tag52 = {};
79 static constexpr Tag<5, 3> Tag53 = {};
80 static constexpr Tag<5, 4> Tag54 = {};
81 static constexpr Tag<5, 5> Tag55 = {};
82 static constexpr Tag<5, 6> Tag56 = {};
83 static constexpr Tag<5, 7> Tag57 = {};
84
85 static constexpr Tag<6, 0> Tag60 = {};
86 static constexpr Tag<6, 1> Tag61 = {};
87 static constexpr Tag<6, 2> Tag62 = {};
88 static constexpr Tag<6, 3> Tag63 = {};
89 static constexpr Tag<6, 4> Tag64 = {};
90 static constexpr Tag<6, 5> Tag65 = {};
91 static constexpr Tag<6, 6> Tag66 = {};
92 static constexpr Tag<6, 7> Tag67 = {};
93
94 static constexpr Tag<7, 0> Tag70 = {};
95 static constexpr Tag<7, 1> Tag71 = {};
96 static constexpr Tag<7, 2> Tag72 = {};
97 static constexpr Tag<7, 3> Tag73 = {};
98 static constexpr Tag<7, 4> Tag74 = {};
99 static constexpr Tag<7, 5> Tag75 = {};
100 static constexpr Tag<7, 6> Tag76 = {};
101 static constexpr Tag<7, 7> Tag77 = {};
102
103 // ---- Enumerations -------------------------------------------------------------------------------------------------
104 //
107 enum class EFieldMode
108 {
111 };
112
116 template<typename Float>
117 struct FloatTag {
118 using Float_t = Float;
119 };
120
123 // TODO: SZh 21.08.2024: Develop the concept of field types at different setup regions. At the moment the only
124 // two global options are available.
125 enum class EFieldType
126 {
129 };
130
131 enum class DoFitTime
132 {
133 N = false,
134 Y = true
135 };
136
137 enum class DoPrintDebug
138 {
139 N = false,
140 Y = true
141 };
142
143 // ---- Type traits --------------------------------------------------------------------------------------------------
144
147 template<typename T>
148 struct Literal {
149 using type = T;
150 };
151
152 template<>
154 using type = fscal;
155 };
156
157 template<typename T>
158 using Literal_t = typename Literal<T>::type;
159
160
161 // ---- Common data types --------------------------------------------------------------------------------------------
162 //
164 template<class T>
165 using GeoVector_t = std::array<T, 3>;
166
169 using FieldFn_t = std::function<std::tuple<double, double, double>(double, double, double)>;
170} // namespace cbm::algo::kf
171
173{
174 // ----- Array sizes -------------------------------------------------------------------------------------------------
175 //constexpr int MaxNofFieldSlices = 64; ///< Max number of field slices
176 //constexpr int MaxNofMaterialLayers = 32; ///< Max number of the material layers
177 // NOTE: max uint8_t is assumed in order to satisfy fles::Subsystem
178 constexpr int MaxNofDetSubsystems = 256;
179 constexpr int MaxNofDetComponents = 128;
180
181 // ----- Control -----------------------------------------------------------------------------------------------------
182 constexpr int DebugLvl = 0;
183 constexpr bool GetterCheck = true;
184
185
186 // ----- Math --------------------------------------------------------------------------------------------------------
187 template<class T = double>
188 constexpr auto Pi = Literal_t<T>(3.14159265358979323846L);
189
190 // ----- Physics -----------------------------------------------------------------------------------------------------
191 template<class T = double>
192 constexpr auto MuonMass = Literal_t<T>(0.105658375523L);
193
194 template<class T = double>
195 constexpr auto PionMass = Literal_t<T>(0.1395703918L);
196
197 template<class T = double>
198 constexpr auto KaonMass = Literal_t<T>(0.493677L);
199
200 template<class T = double>
201 constexpr auto ElectronMass = Literal_t<T>(0.0005109989500015L);
202
203 template<class T = double>
204 constexpr auto ProtonMass = Literal_t<T>(0.93827208816L);
205
206 template<class T = double>
207 constexpr auto SpeedOfLight = Literal_t<T>(29.9792458L);
208
209 template<class T = double>
211
212 template<class T = double>
213 constexpr auto MinField = Literal_t<T>(1.e-4L);
214
215 // ----- Undefined values --------------------------------------------------------------------------------------------
217 template<typename T1, typename T2 = T1>
218 constexpr T2 Undef;
219
220 template<>
221 inline constexpr int Undef<int> = std::numeric_limits<int>::min();
222
223 template<>
224 inline constexpr unsigned Undef<unsigned> = std::numeric_limits<unsigned>::max();
225
226 template<>
227 inline constexpr float Undef<float> = std::numeric_limits<float>::signaling_NaN();
228
229 template<>
230 inline constexpr double Undef<double> = std::numeric_limits<double>::signaling_NaN();
231
232 template<>
233 inline constexpr fscal Undef<fvec> = std::numeric_limits<fscal>::signaling_NaN();
234
235 // ----- Other -------------------------------------------------------------------------------------------------------
237 constexpr auto ZeroFieldFn = [](double, double, double) constexpr { return std::make_tuple(0., 0., 0.); };
238
239 // ----- Debug flags (NOTE: to be modified only by the experts) ------------------------------------------------------
240 //
241 namespace dbg
242 {
243 } // namespace dbg
244} // namespace cbm::algo::kf::defs
245
246#endif // KF_CORE_KfDefs_h
Implementation selection for the SIMD utilities (VS or pseudo)
constexpr auto PionMass
Pion mass [GeV/c2].
Definition KfDefs.h:195
constexpr auto ElectronMass
Electron mass [GeV/c2].
Definition KfDefs.h:201
constexpr auto ZeroFieldFn
Zero magnetic field function.
Definition KfDefs.h:237
constexpr T2 Undef
Undefined values.
Definition KfDefs.h:218
constexpr int MaxNofDetSubsystems
Max number of detector types (STS, TRD, RICH,...)
Definition KfDefs.h:178
constexpr auto MinField
Minimal (negligible) magnetic field value [kG].
Definition KfDefs.h:213
constexpr auto SpeedOfLightInv
Inverse speed of light [ns/cm].
Definition KfDefs.h:210
constexpr auto Pi
Value of PI, used in ROOT TMath.
Definition KfDefs.h:188
constexpr auto ProtonMass
Proton mass [GeV/c2] (PDG 11.08.2022)
Definition KfDefs.h:204
constexpr bool GetterCheck
Bound check in getters.
Definition KfDefs.h:183
constexpr int DebugLvl
Level of debug output.
Definition KfDefs.h:182
constexpr auto MuonMass
Muon mass [GeV/c2].
Definition KfDefs.h:192
constexpr int MaxNofDetComponents
Max number of detector components (stations, layers, ...)
Definition KfDefs.h:179
constexpr auto KaonMass
Kaon mass [GeV/c2] (PDG 22.08.2023)
Definition KfDefs.h:198
constexpr auto SpeedOfLight
Speed of light [cm/ns].
Definition KfDefs.h:207
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
Definition KfDefs.h:108
@ Original
Original magnetic field function.
Definition KfDefs.h:110
@ Interpolated
Interpolated magnetic field.
Definition KfDefs.h:109
static constexpr Tag< 7, 0 > Tag70
Tag for (7,0) element.
Definition KfDefs.h:94
static constexpr Tag< 4, 1 > Tag41
Tag for (4,1) element.
Definition KfDefs.h:68
static constexpr Tag< 1, 2 > Tag12
Tag for (1,2) element.
Definition KfDefs.h:42
static constexpr Tag< 3, 0 > Tag30
Tag for (3,0) element.
Definition KfDefs.h:58
static constexpr Tag< 6, 1 > Tag61
Tag for (6,1) element.
Definition KfDefs.h:86
static constexpr Tag< 0, 4 > Tag04
Tag for (0,4) element.
Definition KfDefs.h:35
static constexpr Tag< 4, 0 > Tag40
Tag for (4,0) element.
Definition KfDefs.h:67
static constexpr Tag< 4, 5 > Tag45
Tag for (4,5) element.
Definition KfDefs.h:72
static constexpr Tag< 1, 3 > Tag13
Tag for (1,3) element.
Definition KfDefs.h:43
static constexpr Tag< 4, 3 > Tag43
Tag for (4,3) element.
Definition KfDefs.h:70
static constexpr Tag< 7, 2 > Tag72
Tag for (7,2) element.
Definition KfDefs.h:96
static constexpr Tag< 7, 3 > Tag73
Tag for (7,3) element.
Definition KfDefs.h:97
static constexpr Tag< 3, 6 > Tag36
Tag for (3,6) element.
Definition KfDefs.h:64
static constexpr Tag< 7, 4 > Tag74
Tag for (7,4) element.
Definition KfDefs.h:98
static constexpr Tag< 2, 3 > Tag23
Tag for (2,3) element.
Definition KfDefs.h:52
static constexpr Tag< 3, 7 > Tag37
Tag for (3,7) element.
Definition KfDefs.h:65
static constexpr Tag< 2, 7 > Tag27
Tag for (2,7) element.
Definition KfDefs.h:56
static constexpr Tag< 3, 1 > Tag31
Tag for (3,1) element.
Definition KfDefs.h:59
static constexpr Tag< 0, 3 > Tag03
Tag for (0,3) element.
Definition KfDefs.h:34
static constexpr Tag< 5, 4 > Tag54
Tag for (5,4) element.
Definition KfDefs.h:80
std::array< T, 3 > GeoVector_t
Geometry (spatial) vector.
Definition KfDefs.h:165
static constexpr Tag< 7, 7 > Tag77
Tag for (7,7) element.
Definition KfDefs.h:101
static constexpr Tag< 1, 7 > Tag17
Tag for (1,7) element.
Definition KfDefs.h:47
typename Literal< T >::type Literal_t
Definition KfDefs.h:158
static constexpr Tag< 1, 4 > Tag14
Tag for (1,4) element.
Definition KfDefs.h:44
static constexpr Tag< 5, 0 > Tag50
Tag for (5,0) element.
Definition KfDefs.h:76
static constexpr Tag< 1, 6 > Tag16
Tag for (1,6) element.
Definition KfDefs.h:46
static constexpr Tag< 2, 4 > Tag24
Tag for (2,4) element.
Definition KfDefs.h:53
static constexpr Tag< 0, 1 > Tag01
Tag for (0,1) element.
Definition KfDefs.h:32
static constexpr Tag< 6, 3 > Tag63
Tag for (6,3) element.
Definition KfDefs.h:88
static constexpr Tag< 3, 2 > Tag32
Tag for (3,2) element.
Definition KfDefs.h:60
static constexpr Tag< 4, 6 > Tag46
Tag for (4,6) element.
Definition KfDefs.h:73
static constexpr Tag< 2, 2 > Tag22
Tag for (2,2) element.
Definition KfDefs.h:51
static constexpr Tag< 1, 1 > Tag11
Tag for (1,1) element.
Definition KfDefs.h:41
static constexpr Tag< 5, 5 > Tag55
Tag for (5,5) element.
Definition KfDefs.h:81
static constexpr Tag< 4, 2 > Tag42
Tag for (4,2) element.
Definition KfDefs.h:69
static constexpr Tag< 5, 6 > Tag56
Tag for (5,6) element.
Definition KfDefs.h:82
static constexpr Tag< 0, 7 > Tag07
Tag for (0,7) element.
Definition KfDefs.h:38
static constexpr Tag< 2, 6 > Tag26
Tag for (2,6) element.
Definition KfDefs.h:55
static constexpr Tag< 5, 7 > Tag57
Tag for (5,7) element.
Definition KfDefs.h:83
static constexpr Tag< 7, 6 > Tag76
Tag for (7,6) element.
Definition KfDefs.h:100
@ Y
Fit the time component.
Definition KfDefs.h:134
@ N
Do not fit the time component.
Definition KfDefs.h:133
static constexpr Tag< 6, 0 > Tag60
Tag for (6,0) element.
Definition KfDefs.h:85
static constexpr Tag< 5, 2 > Tag52
Tag for (5,2) element.
Definition KfDefs.h:78
static constexpr Tag< 1, 0 > Tag10
Tag for (1,0) element.
Definition KfDefs.h:40
static constexpr Tag< 2, 5 > Tag25
Tag for (2,5) element.
Definition KfDefs.h:54
static constexpr Tag< 2, 1 > Tag21
Tag for (2,1) element.
Definition KfDefs.h:50
static constexpr Tag< 0, 6 > Tag06
Tag for (0,6) element.
Definition KfDefs.h:37
EFieldType
Magnetic field type in different setup regions.
Definition KfDefs.h:126
@ Normal
Field near the tracker subsystem.
Definition KfDefs.h:127
@ Null
No magnetic field.
Definition KfDefs.h:128
static constexpr Tag< 1, 5 > Tag15
Tag for (1,5) element.
Definition KfDefs.h:45
static constexpr Tag< 6, 4 > Tag64
Tag for (6,4) element.
Definition KfDefs.h:89
static constexpr Tag< 6, 6 > Tag66
Tag for (6,6) element.
Definition KfDefs.h:91
static constexpr Tag< 3, 5 > Tag35
Tag for (3,5) element.
Definition KfDefs.h:63
static constexpr Tag< 6, 7 > Tag67
Tag for (6,7) element.
Definition KfDefs.h:92
static constexpr Tag< 3, 3 > Tag33
Tag for (3,3) element.
Definition KfDefs.h:61
static constexpr Tag< 6, 5 > Tag65
Tag for (6,5) element.
Definition KfDefs.h:90
static constexpr Tag< 3, 4 > Tag34
Tag for (3,4) element.
Definition KfDefs.h:62
static constexpr Tag< 0, 2 > Tag02
Tag for (0,2) element.
Definition KfDefs.h:33
static constexpr Tag< 6, 2 > Tag62
Tag for (6,2) element.
Definition KfDefs.h:87
static constexpr Tag< 2, 0 > Tag20
Tag for (2,0) element.
Definition KfDefs.h:49
static constexpr Tag< 4, 4 > Tag44
Tag for (4,4) element.
Definition KfDefs.h:71
static constexpr Tag< 0, 5 > Tag05
Tag for (0,5) element.
Definition KfDefs.h:36
static constexpr Tag< 4, 7 > Tag47
Tag for (4,7) element.
Definition KfDefs.h:74
static constexpr Tag< 7, 5 > Tag75
Tag for (7,5) element.
Definition KfDefs.h:99
static constexpr Tag< 5, 3 > Tag53
Tag for (5,3) element.
Definition KfDefs.h:79
std::function< std::tuple< double, double, double >(double, double, double)> FieldFn_t
Magnetic field function type Signature: tuple<Bx, By, Bz>(x, y, z);.
Definition KfDefs.h:169
static constexpr Tag< 5, 1 > Tag51
Tag for (5,1) element.
Definition KfDefs.h:77
static constexpr Tag< 0, 0 > Tag00
Tag for (0,0) element.
Definition KfDefs.h:31
static constexpr Tag< 7, 1 > Tag71
Tag for (7,1) element.
Definition KfDefs.h:95
A floating-point tag for tag dispatching.
Definition KfDefs.h:117
Replaces the type T with the Literal::type to handle the constant expressions for different constants...
Definition KfDefs.h:148
A generic tag for tag dispatching.
Definition KfDefs.h:28