53 assert(rofId < mNROFsTF && rofId >= 0);
87 const BCType bc = (ts.getTimeStamp() < ts.getTimeStampError()) ?
BCType(0) :
static_cast<BCType>(o2::gpu::CAMath::Floor(ts.getTimeStamp() - ts.getTimeStampError()));
105 const auto rofTS = getROFTimeBounds(rof,
true);
106 return static_cast<float>(rofTS.upper()) >
lower &&
upper >
static_cast<float>(rofTS.lower());
111 return getROFRange(ts.getTimeStamp() - ts.getTimeStampError(), ts.getTimeStamp() + ts.getTimeStampError());
116 return getROFRange(
static_cast<float>(ts.lower()),
static_cast<float>(ts.upper()));
131 return {
first, first <= last ? static_cast<BCType>(last -
first + 1) :
BCType{0}};
149 const TableEntry* mFlatTable{
nullptr};
150 const TableIndex* mIndices{
nullptr};
152 int32_t mLayerCount{0};
157 return mLayers[
layer];
160 GPUh() int32_t getClock() const noexcept
163 uint32_t maxNROFs{0};
164 for (int32_t iL{0}; iL < mLayerCount; ++iL) {
165 const auto&
layer = getLayer(iL);
166 if (
layer.mNROFsTF > maxNROFs) {
168 maxNROFs =
layer.mNROFsTF;
176 GPUhdi() const TableEntry& getOverlap(int32_t from, int32_t to,
size_t rofIdx) const noexcept
178 assert(from < mLayerCount && to < mLayerCount);
179 const auto& idx = mIndices[(from * mLayerCount) + to];
181 return mFlatTable[idx.getFirstEntry() + rofIdx];
184 GPUhdi() bool doROFsOverlap(int32_t layer0,
size_t rof0, int32_t layer1,
size_t rof1) const noexcept
186 if (layer0 == layer1) {
189 assert(layer0 < mLayerCount && layer1 < mLayerCount);
190 const auto& idx = mIndices[(layer0 * mLayerCount) + layer1];
191 if (rof0 >= idx.getEntries()) {
194 const auto& overlap = mFlatTable[idx.getFirstEntry() + rof0];
195 if (overlap.getEntries() == 0) {
198 const size_t firstCompatible = overlap.getFirstEntry();
199 const size_t lastCompatible = firstCompatible + overlap.getEntries() - 1;
200 return rof1 >= firstCompatible && rof1 <= lastCompatible;
203 GPUhdi()
o2::its::
TimeEstBC getTimeStamp(int32_t layer0,
size_t rof0, int32_t layer1,
size_t rof1) const noexcept
205 assert(layer0 < mLayerCount && layer1 < mLayerCount);
206 assert(doROFsOverlap(layer0, rof0, layer1, rof1));
207 return mLayers[layer0].getROFTimeBounds(rof0,
true) + mLayers[layer1].getROFTimeBounds(rof1,
true);
213 for (int32_t
i = 0;
i < mLayerCount; ++
i) {
214 for (int32_t
j = 0;
j < mLayerCount; ++
j) {
223 GPUh()
void printMapping(int32_t from, int32_t to)
const
226 LOGP(error,
"No self-lookup supported");
229 const auto&
idx = mIndices[(from * mLayerCount) + to];
230 LOGF(info,
"Overlap mapping: Layer %d -> Layer %d", from, to);
231 LOGP(info,
"From: {}", mLayers[from].
asString());
232 LOGP(info,
"To : {}", mLayers[to].
asString());
233 for (int32_t
i = 0;
i <
idx.getEntries(); ++
i) {
234 const auto& overlap = getOverlap(from, to,
i);
235 LOGF(info,
"%d -> first %d count %d",
i, overlap.getFirstEntry(), overlap.getEntries());
241 uint32_t totalEntries{0};
242 size_t flatTableSize{0};
243 for (int32_t
i = 0;
i < mLayerCount; ++
i) {
244 for (int32_t
j = 0;
j < mLayerCount; ++
j) {
246 const auto&
idx = mIndices[(
i * mLayerCount) +
j];
247 totalEntries +=
idx.getEntries();
248 flatTableSize +=
idx.getEntries();
252 LOGF(info,
"Total overlap table size: %u entries", totalEntries);
253 LOGF(info,
"Flat table size: %zu entries", flatTableSize);
260 const TableEntry* mFlatTable{
nullptr};
261 const TableIndex* mIndices{
nullptr};
263 int32_t mLayerCount{0};
268 return mLayers[
layer];
271 GPUhdi() const TableEntry& getVertices(int32_t
layer,
size_t rofIdx) const noexcept
276 return mFlatTable[idx.getFirstEntry() + rofIdx];
279 GPUh() int32_t getMaxVerticesPerROF() const noexcept
283 const auto& idx = mIndices[
layer];
284 for (int32_t
i = 0;
i < idx.getEntries(); ++
i) {
285 maxCount = o2::gpu::CAMath::Max(
maxCount,
static_cast<int32_t
>(mFlatTable[idx.getFirstEntry() +
i].getEntries()));
294 const auto& layerDef = mLayers[
layer];
295 int64_t rofLower = o2::gpu::CAMath::Max(
static_cast<int64_t>(layerDef.getROFStartInBC(rofIdx)) -
static_cast<int64_t>(layerDef.mROFAddTimeErr),
int64_t(0));
296 int64_t rofUpper =
static_cast<int64_t>(layerDef.getROFEndInBC(rofIdx)) + layerDef.mROFAddTimeErr;
299 return vUpper >= rofLower && vLower < rofUpper;
306 const auto& idx = mIndices[
layer];
307 LOGF(info,
"Vertex lookup: Layer %d, ROFs %u",
layer, idx.getEntries());
315 const TableEntry* mFlatMask{
nullptr};
316 const TableIndex* mLayerROFOffsets{
nullptr};
317 int32_t mLayerCount{0};
319 GPUhdi() bool isROFEnabled(int32_t
layer, int32_t rofId) const noexcept
322 return mFlatMask[mLayerROFOffsets[
layer] + rofId] != 0u;
328 constexpr int wROF = 10;
329 constexpr int wActive = 10;
330 const int32_t nROFs = mLayerROFOffsets[
layer + 1] - mLayerROFOffsets[
layer];
331 LOGF(info,
"Mask table: Layer %d",
layer);
332 LOGF(info,
"%*s | %*s", wROF,
"ROF", wActive,
"Enabled");
333 LOGF(info,
"%.*s-+-%.*s", wROF,
"----------", wActive,
"----------");
334 for (int32_t rof = 0; rof < nROFs; ++rof) {
335 LOGF(info,
"%*d | %*d", wROF, rof, wActive,
static_cast<int>(isROFEnabled(
layer, rof)));
341 const int32_t nROFs = mLayerROFOffsets[
layer + 1] - mLayerROFOffsets[
layer];
342 int32_t enabledROFs = 0;
343 for (int32_t rof = 0; rof < nROFs; ++rof) {
344 if (isROFEnabled(
layer, rof)) {
348 return std::format(
"ROFMask on Layer {} ROFs enabled: {}/{}",
layer, enabledROFs, nROFs);