Skip to content

Commit 0d9b8d0

Browse files
committed
trk
Signed-off-by: Felix Schlepper <[email protected]>
1 parent 6689680 commit 0d9b8d0

File tree

3 files changed

+111
-61
lines changed

3 files changed

+111
-61
lines changed

Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROFLookupTables.h

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -635,30 +635,40 @@ class ROFVertexLookupTable : public LayerTimingBase<NLayers>
635635
};
636636

637637
// GPU friendly view of the table below
638-
template <uint32_t NLayers, typename ROFRange>
638+
template <int32_t NLayers, typename ROFRange>
639639
struct ROFTimeSliceTableView {
640640
const ROFRange* mFlatTable{nullptr};
641+
const uint8_t* mFlatMask{nullptr};
642+
const int32_t* mLayerROFOffsets{nullptr};
641643
int32_t mSlices{0};
642644

645+
GPUhdi() const uint8_t* getMask(int32_t layer, int32_t slice) const
646+
{
647+
assert(layer < NLayers);
648+
assert(sliceIdx < mSlices);
649+
const auto& range = getSlice(layer, slice);
650+
return &mFlatMask[mLayerROFOffsets[layer] + range.getFirstEntry()];
651+
}
652+
643653
// Get the BC range for a given layer and slice
644-
GPUhdi() const ROFRange& getSlice(uint32_t layer, int32_t sliceIdx) const
654+
GPUhdi() const ROFRange& getSlice(int32_t layer, int32_t slice) const
645655
{
646656
assert(layer < NLayers);
647657
assert(sliceIdx < mSlices);
648-
return mFlatTable[(layer * mSlices) + sliceIdx];
658+
return mFlatTable[(layer * mSlices) + slice];
649659
}
650660

651661
// Check if a BC falls within a specific slice
652-
GPUhdi() bool isInSlice(uint32_t layer, int32_t sliceIdx, int32_t bc) const
662+
GPUhdi() bool isInSlice(int32_t layer, int32_t slice, int32_t bc) const
653663
{
654-
const auto& range = getSlice(layer, sliceIdx);
664+
const auto& range = getSlice(layer, slice);
655665
int32_t start = range.getFirstEntry();
656666
int32_t end = range.getEntriesBound();
657667
return bc >= start && bc < end;
658668
}
659669

660670
// Find which slice a BC belongs to (returns -1 if not found)
661-
GPUhdi() int32_t findSlice(uint32_t layer, int32_t bc) const
671+
GPUhdi() int32_t findSlice(int32_t layer, int32_t bc) const
662672
{
663673
assert(layer < NLayers);
664674
int32_t left = 0;
@@ -694,17 +704,24 @@ struct ROFTimeSliceTableView {
694704
constexpr int w_start = 12;
695705
constexpr int w_end = 12;
696706
constexpr int w_range = 10;
697-
707+
constexpr int w_active = 12;
698708
LOGF(info, "Slice table: Layer %d", layer);
699-
LOGF(info, "%*s | %*s | %*s | %*s", w_slice, "Slice", w_start, "BC.Start", w_end, "BC.End", w_range, "Range");
700-
LOGF(info, "%.*s-+-%.*s-+-%.*s-+-%.*s", w_slice, "----------", w_start, "------------", w_end, "------------", w_range, "----------");
701-
709+
LOGF(info, "%*s | %*s | %*s | %*s | %*s", w_slice, "Slice", w_start, "BC.Start", w_end, "BC.End", w_range, "Range", w_active, "ActiveROFs");
710+
LOGF(info, "%.*s-+-%.*s-+-%.*s-+-%.*s-+-%.*s", w_slice, "----------", w_start, "------------", w_end, "------------", w_range, "----------", w_active, "------------");
702711
for (int32_t i = 0; i < mSlices; ++i) {
703712
const auto& range = getSlice(layer, i);
704713
int32_t start = range.getFirstEntry();
705714
int32_t rangeLen = range.getEntries();
706715
int32_t end = range.getEntriesBound();
707-
LOGF(info, "%*d | %*d | %*d | %*d", w_slice, i, w_start, start, w_end, end, w_range, rangeLen);
716+
717+
// Count active ROFs in this slice
718+
const uint8_t* mask = getMask(layer, i);
719+
int32_t activeCount = 0;
720+
for (int32_t j = 0; j < rangeLen; ++j) {
721+
activeCount += mask[j];
722+
}
723+
724+
LOGF(info, "%*d | %*d | %*d | %*d | %*d/%d", w_slice, i, w_start, start, w_end, end, w_range, rangeLen, w_active, activeCount, rangeLen);
708725
}
709726
}
710727
};
@@ -723,24 +740,47 @@ class ROFTimeSliceTable : public LayerTimingBase<NLayers>
723740
{
724741
mSlices = nSlices;
725742
std::vector<ROFRange> table[NLayers];
743+
int32_t totalROFs = 0;
726744
for (int32_t layer{0}; layer < NLayers; ++layer) {
727745
buildSlices(layer, table[layer]);
746+
mLayerROFOffsets[layer] = totalROFs;
747+
totalROFs += this->getLayer(layer).mNROFsTF;
728748
}
749+
mFlatMask.resize(totalROFs, 1);
729750
flatten(table);
730751
}
731752

753+
GPUh() void selectROFs(int32_t bcStart, int32_t bcEnd)
754+
{
755+
for (int32_t layer{0}; layer < NLayers; ++layer) {
756+
const auto& lay = this->getLayer(layer);
757+
int32_t offset = mLayerROFOffsets[layer];
758+
for (int32_t rofId{0}; rofId < lay.mNROFsTF; ++rofId) {
759+
auto bounds = lay.getROFTimeBounds(rofId);
760+
int32_t rofStart = bounds.getFirstEntry();
761+
int32_t rofEnd = bounds.getEntriesBound();
762+
bool isCompatible = rofStart < bcEnd && rofEnd > bcStart;
763+
mFlatMask[offset + rofId] = isCompatible ? 1 : 0;
764+
}
765+
}
766+
}
767+
732768
GPUhd() View getView() const
733769
{
734770
View view;
735771
view.mFlatTable = mFlatTable.data();
772+
view.mFlatMask = mFlatMask.data();
773+
view.mLayerROFOffsets = mLayerROFOffsets;
736774
view.mSlices = mSlices;
737775
return view;
738776
}
739777

740-
GPUd() View getDeviceView(const ROFRange* deviceFlatTablePtr) const
778+
GPUd() View getDeviceView(const ROFRange* deviceFlatTablePtr, const uint8_t* deviceFlatMaskPtr) const
741779
{
742780
View view;
743781
view.mFlatTable = deviceFlatTablePtr;
782+
view.mFlatMask = deviceFlatMaskPtr;
783+
view.mLayerROFOffsets = mLayerROFOffsets;
744784
view.mSlices = mSlices;
745785
return view;
746786
}
@@ -768,7 +808,9 @@ class ROFTimeSliceTable : public LayerTimingBase<NLayers>
768808
}
769809

770810
int32_t mSlices{0};
811+
int32_t mLayerROFOffsets[NLayers];
771812
std::vector<ROFRange> mFlatTable;
813+
std::vector<uint8_t> mFlatMask;
772814
};
773815

774816
} // namespace o2::its

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ namespace its
3838
{
3939
class TrackITSExt;
4040

41-
template <int nLayers = 7>
41+
template <int NLayers = 7>
4242
class TrackerTraits
4343
{
4444
public:
45-
using IndexTableUtilsN = IndexTableUtils<nLayers>;
46-
using CellSeedN = CellSeed<nLayers>;
45+
using IndexTableUtilsN = IndexTableUtils<NLayers>;
46+
using CellSeedN = CellSeed<NLayers>;
4747

4848
virtual ~TrackerTraits() = default;
49-
virtual void adoptTimeFrame(TimeFrame<nLayers>* tf) { mTimeFrame = tf; }
49+
virtual void adoptTimeFrame(TimeFrame<NLayers>* tf) { mTimeFrame = tf; }
5050
virtual void initialiseTimeFrame(const int iteration) { mTimeFrame->initialise(iteration, mTrkParams[iteration], mTrkParams[iteration].NLayers); }
5151

52-
virtual void computeLayerTracklets(const int iteration, int iSlice, int iVertex);
52+
virtual void computeLayerTracklets(const int iteration, const int iSlice, const int iVertex);
5353
virtual void computeLayerCells(const int iteration);
5454
virtual void findCellsNeighbours(const int iteration);
5555
virtual void findRoads(const int iteration);
@@ -63,7 +63,7 @@ class TrackerTraits
6363
virtual void processNeighbours(int iLayer, int iLevel, const bounded_vector<CellSeedN>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeedN>& updatedCellSeed, bounded_vector<int>& updatedCellId);
6464

6565
void updateTrackingParameters(const std::vector<TrackingParameters>& trkPars) { mTrkParams = trkPars; }
66-
TimeFrame<nLayers>* getTimeFrame() { return mTimeFrame; }
66+
TimeFrame<NLayers>* getTimeFrame() { return mTimeFrame; }
6767

6868
virtual void setBz(float bz);
6969
float getBz() const { return mBz; }
@@ -101,15 +101,15 @@ class TrackerTraits
101101

102102
protected:
103103
o2::gpu::GPUChainITS* mChain = nullptr;
104-
TimeFrame<nLayers>* mTimeFrame;
104+
TimeFrame<NLayers>* mTimeFrame;
105105
std::vector<TrackingParameters> mTrkParams;
106106

107107
float mBz{-999.f};
108108
bool mIsZeroField{false};
109109
};
110110

111-
template <int nLayers>
112-
inline const int4 TrackerTraits<nLayers>::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
111+
template <int NLayers>
112+
inline const int4 TrackerTraits<NLayers>::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
113113
{
114114
const float zRangeMin = o2::gpu::GPUCommonMath::Min(z1, z2) - maxdeltaz;
115115
const float phiRangeMin = (maxdeltaphi > o2::constants::math::PI) ? 0.f : phi - maxdeltaphi;

0 commit comments

Comments
 (0)