-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathTrackITS.h
More file actions
219 lines (184 loc) · 6.82 KB
/
TrackITS.h
File metadata and controls
219 lines (184 loc) · 6.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file TrackITS.h
/// \brief Definition of the ITS track
/// \author iouri.belikov@cern.ch
#ifndef ALICEO2_ITS_TRACKITS_H
#define ALICEO2_ITS_TRACKITS_H
#include <cstdint>
#include "GPUCommonDef.h"
#include "ReconstructionDataFormats/Track.h"
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsITS/TimeEstBC.h"
namespace o2
{
namespace itsmft
{
class Cluster;
}
namespace its
{
class TrackITS : public o2::track::TrackParCov
{
enum UserBits {
kSharedClusters = 1 << 28
};
using Cluster = o2::itsmft::Cluster;
using ClusRefs = o2::dataformats::RangeRefComp<4>;
public:
using o2::track::TrackParCov::TrackParCov; // inherit base constructors
static constexpr int MaxClusters = 16;
GPUhdDefault() TrackITS() = default;
GPUhdDefault() TrackITS(const TrackITS& t) = default;
GPUhd() TrackITS(const o2::track::TrackParCov& parcov) : o2::track::TrackParCov{parcov} {}
GPUhd() TrackITS(const o2::track::TrackParCov& parCov, float chi2, const o2::track::TrackParCov& outer)
: o2::track::TrackParCov{parCov}, mParamOut{outer}, mChi2{chi2} {}
GPUhdDefault() TrackITS& operator=(const TrackITS& tr) = default;
GPUhdDefault() TrackITS& operator=(TrackITS&& tr) = default;
GPUhdDefault() ~TrackITS() = default;
// These functions must be provided
bool propagate(float alpha, float x, float bz);
bool update(const Cluster& c, float chi2);
// Other functions
GPUhdi() float getChi2() const { return mChi2; }
GPUhdi() int getNClusters() const { return mClusRef.getEntries(); }
GPUhdi() int getNumberOfClusters() const { return getNClusters(); }
int getFirstClusterEntry() const { return mClusRef.getFirstEntry(); }
int getClusterEntry(int i) const { return getFirstClusterEntry() + i; }
void shiftFirstClusterEntry(int bias)
{
mClusRef.setFirstEntry(mClusRef.getFirstEntry() + bias);
}
void setFirstClusterEntry(int offs)
{
mClusRef.setFirstEntry(offs);
}
void setNumberOfClusters(int n)
{
mClusRef.setEntries(n);
}
bool operator<(const TrackITS& o) const;
void getImpactParams(float x, float y, float z, float bz, float ip[2]) const;
// bool getPhiZat(float r,float &phi,float &z) const;
void setClusterRefs(int firstEntry, int n)
{
mClusRef.set(firstEntry, n);
}
const ClusRefs& getClusterRefs() const { return mClusRef; }
GPUhdi() ClusRefs& getClusterRefs() { return mClusRef; }
GPUhdi() void setChi2(float chi2) { mChi2 = chi2; }
bool isBetter(const TrackITS& best, float maxChi2) const;
GPUhdi() auto& getTimeStamp() { return mTime; }
GPUhdi() const auto& getTimeStamp() const { return mTime; }
GPUhdi() o2::track::TrackParCov& getParamIn() { return *this; }
GPUhdi() const o2::track::TrackParCov& getParamIn() const { return *this; }
GPUhdi() o2::track::TrackParCov& getParamOut() { return mParamOut; }
GPUhdi() const o2::track::TrackParCov& getParamOut() const { return mParamOut; }
GPUhdi() void setPattern(uint32_t p) { mPattern = p; }
GPUhdi() uint32_t getPattern() const { return mPattern; }
bool hasHitOnLayer(uint32_t i) const { return mPattern & (0x1 << i); }
bool isFakeOnLayer(uint32_t i) const { return !(mPattern & (0x1 << (16 + i))); }
bool isExtendedOnLayer(uint32_t i) const { return (mPattern & (0x1 << (24 + i))); } // only correct if getNClusters <= 8 on layers <= 8
uint32_t getLastClusterLayer() const
{
uint32_t r{0}, v{mPattern & ((1 << 16) - 1)};
while (v >>= 1) {
r++;
}
return r;
}
uint32_t getFirstClusterLayer() const
{
int s{0};
while (!(mPattern & (1 << s))) {
s++;
}
return s;
}
int getNFakeClusters() const;
void setSharedClusters(bool toggle = true) { mClusterSizes = toggle ? (mClusterSizes | kSharedClusters) : (mClusterSizes & ~kSharedClusters); }
bool hasSharedClusters() const { return mClusterSizes & kSharedClusters; }
void setClusterSize(int l, int size)
{
if (l >= 8) {
return;
}
if (size > 15) {
size = 15;
}
mClusterSizes &= ~(0xf << (l * 4));
mClusterSizes |= (size << (l * 4));
}
int getClusterSize(int l)
{
if (l >= 7) {
return 0;
}
return (mClusterSizes >> (l * 4)) & 0xf;
}
int getClusterSizes() const
{
return mClusterSizes;
}
private:
o2::track::TrackParCov mParamOut; ///< parameter at largest radius
ClusRefs mClusRef; ///< references on clusters
float mChi2 = 0.; ///< Chi2 for this track
uint32_t mPattern = 0; ///< layers pattern
uint32_t mClusterSizes = 0u; ///< 4bit packed cluster sizes
TimeStamp mTime; ///< track time stamp with error in BC since start of TF, symmetrical
ClassDefNV(TrackITS, 7);
};
class TrackITSExt : public TrackITS
{
///< heavy version of TrackITS, with clusters embedded
public:
static constexpr int MaxClusters = 16; /// Prepare for overlaps and new detector configurations
using TrackITS::TrackITS; // inherit base constructors
GPUh() TrackITSExt(o2::track::TrackParCov&& parCov, short ncl, float chi2, o2::track::TrackParCov&& outer, std::array<int, MaxClusters> cls)
: TrackITS(parCov, chi2, outer), mIndex{cls}
{
setNumberOfClusters(ncl);
}
GPUh() TrackITSExt(o2::track::TrackParCov& parCov, short ncl, float chi2, std::uint32_t rof, o2::track::TrackParCov& outer, std::array<int, MaxClusters> cls)
: TrackITS(parCov, chi2, outer), mIndex{cls}
{
setNumberOfClusters(ncl);
}
GPUhdDefault() TrackITSExt(const TrackITSExt& t) = default;
void setClusterIndex(int l, int i)
{
int ncl = getNumberOfClusters();
mIndex[ncl++] = (l << 28) + i;
getClusterRefs().setEntries(ncl);
}
GPUhdi() const int& getClusterIndex(int lr) const { return mIndex[lr]; }
GPUhdi() void setExternalClusterIndex(int layer, int idx, bool newCluster = false)
{
if (newCluster) {
getClusterRefs().setEntries(getNumberOfClusters() + 1);
uint32_t pattern = getPattern();
pattern |= 0x1 << layer;
setPattern(pattern);
}
mIndex[layer] = idx;
}
GPUh() std::array<int, MaxClusters>& getClusterIndexes()
{
return mIndex;
}
private:
std::array<int, MaxClusters> mIndex = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; ///< Indices of associated clusters
ClassDefNV(TrackITSExt, 3);
};
} // namespace its
} // namespace o2
#endif /* ALICEO2_ITS_TRACKITS_H */