Project
Loading...
Searching...
No Matches
TrackITS.h
Go to the documentation of this file.
1// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_ITS_TRACKITS_H
17#define ALICEO2_ITS_TRACKITS_H
18
19#include <cstdint>
20
21#include "GPUCommonDef.h"
25
26namespace o2
27{
28namespace itsmft
29{
30class Cluster;
31}
32
33namespace its
34{
35
37{
38 public:
39 static constexpr unsigned int ExtendedPatternShift = 24;
40 static constexpr int MaxLayersInTrackPattern = 8;
41
42 private:
43 enum UserBits {
44 kSharedClusters = 1 << 28
45 };
46
48 using ClusRefs = o2::dataformats::RangeRefComp<4>;
49
50 public:
51 using o2::track::TrackParCov::TrackParCov; // inherit base constructors
52 static constexpr int MaxClusters = 16;
53
54 GPUhdDefault() TrackITS() = default;
55 GPUhdDefault() TrackITS(const TrackITS& t) = default;
56 GPUhd() TrackITS(const o2::track::TrackParCov& parcov) : o2::track::TrackParCov{parcov} {}
57 GPUhd() TrackITS(const o2::track::TrackParCov& parCov, float chi2, const o2::track::TrackParCov& outer)
58 : o2::track::TrackParCov{parCov}, mParamOut{outer}, mChi2{chi2} {}
59 GPUhdDefault() TrackITS& operator=(const TrackITS& tr) = default;
60 GPUhdDefault() TrackITS& operator=(TrackITS&& tr) = default;
61 GPUhdDefault() ~TrackITS() = default;
62
63 // These functions must be provided
64 bool propagate(float alpha, float x, float bz);
65 bool update(const Cluster& c, float chi2);
66
67 // Other functions
68 GPUhdi() float getChi2() const { return mChi2; }
69 GPUhdi() int getNClusters() const { return mClusRef.getEntries(); }
70 GPUhdi() int getNumberOfClusters() const { return getNClusters(); }
71 int getFirstClusterEntry() const { return mClusRef.getFirstEntry(); }
72 int getClusterEntry(int i) const { return getFirstClusterEntry() + i; }
74 {
75 mClusRef.setFirstEntry(mClusRef.getFirstEntry() + bias);
76 }
77 void setFirstClusterEntry(int offs)
78 {
79 mClusRef.setFirstEntry(offs);
80 }
82 {
83 mClusRef.setEntries(n);
84 }
85 bool operator<(const TrackITS& o) const;
86 void getImpactParams(float x, float y, float z, float bz, float ip[2]) const;
87 // bool getPhiZat(float r,float &phi,float &z) const;
88
89 void setClusterRefs(int firstEntry, int n)
90 {
91 mClusRef.set(firstEntry, n);
92 }
93
94 const ClusRefs& getClusterRefs() const { return mClusRef; }
95 GPUhdi() ClusRefs& getClusterRefs() { return mClusRef; }
96
97 GPUhdi() void setChi2(float chi2) { mChi2 = chi2; }
98
99 bool isBetter(const TrackITS& best, float maxChi2) const;
100
101 GPUhdi() auto& getTimeStamp() { return mTime; }
102 GPUhdi() const auto& getTimeStamp() const { return mTime; }
103
104 GPUhdi() o2::track::TrackParCov& getParamIn() { return *this; }
105 GPUhdi() const o2::track::TrackParCov& getParamIn() const { return *this; }
106
107 GPUhdi() o2::track::TrackParCov& getParamOut() { return mParamOut; }
108 GPUhdi() const o2::track::TrackParCov& getParamOut() const { return mParamOut; }
109
110 GPUhdi() void setPattern(uint32_t p) { mPattern = p; }
111 GPUhdi() uint32_t getPattern() const { return mPattern; }
112 bool hasHitOnLayer(uint32_t i) const { return mPattern & (0x1 << i); }
113 bool isFakeOnLayer(uint32_t i) const { return !(mPattern & (0x1 << (16 + i))); }
114 bool isExtendedOnLayer(uint32_t i) const { return (mPattern & (0x1 << (ExtendedPatternShift + i))); } // only correct if getNClusters <= 8 on layers <= 8
115 template <int NLayers>
116 GPUhdi() static constexpr uint32_t getLayerPatternMask()
117 {
118 return (NLayers >= 32) ? 0xffffffffu : ((1u << NLayers) - 1u);
119 }
120 template <int NLayers>
121 GPUhdi() void setExtendedLayerPattern(uint32_t pattern)
122 {
123 pattern &= getLayerPatternMask<NLayers>();
124 setUserField(static_cast<uint16_t>(pattern));
125 if constexpr (NLayers <= MaxLayersInTrackPattern) {
126 setPattern(getPattern() | (pattern << ExtendedPatternShift));
127 }
128 }
129 template <int NLayers>
130 GPUhdi() uint32_t getExtendedLayerPattern() const
131 {
132 const auto mask = getLayerPatternMask<NLayers>();
133 if constexpr (NLayers <= MaxLayersInTrackPattern) {
134 const auto pattern = (getPattern() >> ExtendedPatternShift) & mask;
135 if (pattern) {
136 return pattern;
137 }
138 }
139 return getUserField() & mask;
140 }
141 GPUhdi() void clearExtendedLayerPattern()
142 {
143 setUserField(0);
144 getParamOut().setUserField(0);
145 }
146 GPUhdi() uint32_t getLastClusterLayer() const
147 {
148 uint32_t r{0}, v{mPattern & ((1 << 16) - 1)};
149 while (v >>= 1) {
150 r++;
151 }
152 return r;
153 }
154 GPUhdi() uint32_t getFirstClusterLayer() const
155 {
156 int s{0};
157 while (!(mPattern & (1 << s))) {
158 s++;
159 }
160 return s;
161 }
162 int getNFakeClusters() const;
163
164 void setSharedClusters(bool toggle = true) { mClusterSizes = toggle ? (mClusterSizes | kSharedClusters) : (mClusterSizes & ~kSharedClusters); }
165 bool hasSharedClusters() const { return mClusterSizes & kSharedClusters; }
166
167 void setClusterSize(int l, int size)
168 {
169 if (l >= 8) {
170 return;
171 }
172 if (size > 15) {
173 size = 15;
174 }
175 mClusterSizes &= ~(0xf << (l * 4));
176 mClusterSizes |= (size << (l * 4));
177 }
178
179 int getClusterSize(int l)
180 {
181 if (l >= 7) {
182 return 0;
183 }
184 return (mClusterSizes >> (l * 4)) & 0xf;
185 }
186
187 int getClusterSizes() const
188 {
189 return mClusterSizes;
190 }
191
192 private:
193 o2::track::TrackParCov mParamOut;
194 ClusRefs mClusRef;
195 float mChi2 = 0.;
196 uint32_t mPattern = 0;
197 uint32_t mClusterSizes = 0u;
198 TimeStamp mTime;
199
200 ClassDefNV(TrackITS, 7);
201};
202
203class TrackITSExt : public TrackITS
204{
206 public:
207 static constexpr int MaxClusters = 16;
208 using TrackITS::TrackITS; // inherit base constructors
209
210 GPUh() TrackITSExt(o2::track::TrackParCov&& parCov, short ncl, float chi2, o2::track::TrackParCov&& outer, std::array<int, MaxClusters> cls)
211 : TrackITS(parCov, chi2, outer), mIndex{cls}
212 {
214 }
215
216 GPUh() TrackITSExt(o2::track::TrackParCov& parCov, short ncl, float chi2, std::uint32_t rof, o2::track::TrackParCov& outer, std::array<int, MaxClusters> cls)
217 : TrackITS(parCov, chi2, outer), mIndex{cls}
218 {
220 }
221
222 GPUhdDefault() TrackITSExt(const TrackITSExt& t) = default;
223
224 void setClusterIndex(int l, int i)
225 {
226 int ncl = getNumberOfClusters();
227 mIndex[ncl++] = (l << 28) + i;
228 getClusterRefs().setEntries(ncl);
229 }
230
231 GPUhdi() int getClusterIndex(int lr) const { return mIndex[lr]; }
232
233 GPUh() int getFirstLayerClusterIndex() const
234 {
235 return getClusterIndex(getFirstClusterLayer());
236 }
237
238 GPUhdi() void setExternalClusterIndex(int layer, int idx, bool newCluster = false)
239 {
240 if (newCluster) {
241 getClusterRefs().setEntries(getNumberOfClusters() + 1);
242 uint32_t pattern = getPattern();
243 pattern |= 0x1 << layer;
244 setPattern(pattern);
245 }
246 mIndex[layer] = idx;
247 }
248
250 {
251 return mIndex;
252 }
253
254#ifndef GPUCA_GPUCODE
255 // build order-independent hash via the external cluster idx (unique within a TF) for the selected layers
256 // cluster indices are either sorted inward or outward
257 size_t hash(uint16_t layerMask = 0xFFFF, bool inward = true) const noexcept
258 {
259 size_t h1 = 0, h2 = 0;
260 int from = (int)getLastClusterLayer(), to = -1, step = -1;
261 if (inward) {
262 from = (int)getFirstClusterLayer();
263 to = MaxClusters;
264 step = 1;
265 }
266 // clusters are stored continously but they do not necesarrily correspond to the layers
267 for (int layer = from, slot{0}; layer != to; layer += step) {
268 if (hasHitOnLayer(layer)) {
269 int idx = mIndex[slot++];
270 if (layerMask & (uint16_t(1) << layer)) {
271 size_t v = std::hash<int>{}(idx);
272 h1 ^= v;
273 h2 += v * 0x9e3779b97f4a7c15ULL; // boost's hash_combine
274 }
275 }
276 }
277 return h1 ^ (h2 << 1);
278 }
279#endif
280
281 private:
282 std::array<int, MaxClusters> mIndex = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
283 ClassDefNV(TrackITSExt, 3);
284};
285} // namespace its
286} // namespace o2
287#endif /* ALICEO2_ITS_TRACKITS_H */
Base track model for the Barrel, params only, w/o covariance.
int32_t i
Class to refer to the 1st entry and N elements of some group in the continuous container.
uint32_t c
Definition RawData.h:2
o2::track::TrackParCov TrackParCov
Definition Recon.h:39
HMPID cluster implementation.
Definition Cluster.h:27
void setClusterIndex(int l, int i)
Definition TrackITS.h:224
GPUhdDefault() TrackITSExt(const TrackITSExt &t)=default
size_t hash(uint16_t layerMask=0xFFFF, bool inward=true) const noexcept
Definition TrackITS.h:257
GPUh() int getFirstLayerClusterIndex() const
Definition TrackITS.h:233
GPUhdi() void setExternalClusterIndex(int layer
int bool MaxClusters & getClusterIndexes()
Definition TrackITS.h:249
static constexpr int MaxClusters
< heavy version of TrackITS, with clusters embedded
Definition TrackITS.h:207
GPUh() TrackITSExt(o2
Definition TrackITS.h:210
GPUhdi() int getClusterIndex(int lr) const
Definition TrackITS.h:231
GPUhdi() void setExtendedLayerPattern(uint32_t pattern)
Definition TrackITS.h:121
GPUhdi() auto &getTimeStamp()
Definition TrackITS.h:101
bool operator<(const TrackITS &o) const
Definition TrackITS.cxx:27
bool hasHitOnLayer(uint32_t i) const
Definition TrackITS.h:112
GPUhdi() const auto &getTimeStamp() const
Definition TrackITS.h:102
const ClusRefs & getClusterRefs() const
Definition TrackITS.h:94
void setClusterRefs(int firstEntry, int n)
Definition TrackITS.h:89
GPUhdi() int getNClusters() const
Definition TrackITS.h:69
int getNFakeClusters() const
Definition TrackITS.cxx:110
static constexpr int MaxClusters
Definition TrackITS.h:52
GPUhdi() ClusRefs &getClusterRefs()
Definition TrackITS.h:95
GPUhdi() uint32_t getLastClusterLayer() const
Definition TrackITS.h:146
void getImpactParams(float x, float y, float z, float bz, float ip[2]) const
Definition TrackITS.cxx:40
GPUhdDefault() TrackITS &operator
int getClusterEntry(int i) const
Definition TrackITS.h:72
void shiftFirstClusterEntry(int bias)
Definition TrackITS.h:73
void setNumberOfClusters(int n)
Definition TrackITS.h:81
GPUhdi() uint32_t getPattern() const
Definition TrackITS.h:111
int getClusterSize(int l)
Definition TrackITS.h:179
GPUhdi() uint32_t getFirstClusterLayer() const
Definition TrackITS.h:154
bool isFakeOnLayer(uint32_t i) const
Definition TrackITS.h:113
GPUhdi() uint32_t getExtendedLayerPattern() const
Definition TrackITS.h:130
void setClusterSize(int l, int size)
Definition TrackITS.h:167
GPUhdi() int getNumberOfClusters() const
Definition TrackITS.h:70
GPUhdi() const o2
Definition TrackITS.h:105
int getFirstClusterEntry() const
Definition TrackITS.h:71
int getClusterSizes() const
Definition TrackITS.h:187
GPUhdi() float getChi2() const
Definition TrackITS.h:68
void setFirstClusterEntry(int offs)
Definition TrackITS.h:77
bool propagate(float alpha, float x, float bz)
Definition TrackITS.cxx:72
bool hasSharedClusters() const
Definition TrackITS.h:165
GPUhd() TrackITS(const o2
Definition TrackITS.h:56
static constexpr unsigned int ExtendedPatternShift
Definition TrackITS.h:39
void setSharedClusters(bool toggle=true)
Definition TrackITS.h:164
static constexpr int MaxLayersInTrackPattern
Definition TrackITS.h:40
GPUhdDefault() TrackITS()=default
GPUhdi() void clearExtendedLayerPattern()
Definition TrackITS.h:141
bool isBetter(const TrackITS &best, float maxChi2) const
Definition TrackITS.cxx:94
bool isExtendedOnLayer(uint32_t i) const
Definition TrackITS.h:114
bool update(const Cluster &c, float chi2)
Definition TrackITS.cxx:82
GPUhdi() void setChi2(float chi2)
Definition TrackITS.h:97
GPUhdi() static const expr uint32_t getLayerPatternMask()
Definition TrackITS.h:116
Cluster class for the ITSMFT.
Definition Cluster.h:34
GLdouble n
Definition glcorearb.h:1982
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLenum array
Definition glcorearb.h:4274
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean r
Definition glcorearb.h:1233
GLint GLuint mask
Definition glcorearb.h:291
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
const int step
track setChi2(hypo.chi2)
const bool const bool const int FollowDirection BestTrial TrackITSInternal< NLayers > & best
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::array< uint16_t, 5 > pattern