Skip to content

Commit 6f815be

Browse files
committed
ITS: template CellSeed
Signed-off-by: Felix Schlepper <[email protected]>
1 parent 9a81e7d commit 6f815be

File tree

6 files changed

+39
-19
lines changed

6 files changed

+39
-19
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef TRACKINGITSU_INCLUDE_CACELL_H_
1717
#define TRACKINGITSU_INCLUDE_CACELL_H_
1818

19+
#include <array>
20+
1921
#include "ITStracking/Constants.h"
2022
#include "GPUCommonDef.h"
2123

@@ -43,12 +45,17 @@ class Cell final
4345
int mLevel{constants::UnusedIndex};
4446
};
4547

48+
template <int nLayers>
4649
class CellSeed final : public o2::track::TrackParCovF
4750
{
4851
public:
49-
GPUhdDefault() CellSeed() = default;
52+
GPUhd() CellSeed()
53+
{
54+
mClusters.fill(constants::UnusedIndex);
55+
}
5056
GPUhd() CellSeed(int innerL, int cl0, int cl1, int cl2, int trkl0, int trkl1, o2::track::TrackParCovF& tpc, float chi2) : o2::track::TrackParCovF(tpc), mChi2(chi2), mLevel(1)
5157
{
58+
mClusters.fill(constants::UnusedIndex);
5259
setUserField(innerL);
5360
mClusters[innerL + 0] = cl0;
5461
mClusters[innerL + 1] = cl1;
@@ -74,18 +81,25 @@ class CellSeed final : public o2::track::TrackParCovF
7481
GPUhd() int getLevel() const { return mLevel; };
7582
GPUhd() void setLevel(int level) { mLevel = level; };
7683
GPUhd() int* getLevelPtr() { return &mLevel; }
77-
GPUhd() int* getClusters() { return mClusters; }
84+
GPUhd() auto& getClusters() { return mClusters; }
7885
GPUhd() int getCluster(int i) const { return mClusters[i]; }
7986
GPUhd() void printCell() const
8087
{
81-
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\tcls: [%d | %d | %d | %d | %d | %d | %d]\n", mTracklets[0], mTracklets[1], mLevel, mChi2, mClusters[0], mClusters[1], mClusters[2], mClusters[3], mClusters[4], mClusters[5], mClusters[6]);
88+
printf("cell: %d, %d\t lvl: %d\t chi2: %f\tcls: [", mTracklets[0], mTracklets[1], mLevel, mChi2);
89+
for (int i = 0; i < nLayers; ++i) {
90+
printf("%d", mClusters[i]);
91+
if (i < nLayers - 1) {
92+
printf(" | ");
93+
}
94+
}
95+
printf("]\n");
8296
}
8397

8498
private:
8599
float mChi2 = -999.f;
86100
int mLevel = constants::UnusedIndex;
87-
int mTracklets[2] = {constants::UnusedIndex, constants::UnusedIndex};
88-
int mClusters[7] = {constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex};
101+
std::array<int, 2> mTracklets{constants::UnusedIndex, constants::UnusedIndex};
102+
std::array<int, nLayers> mClusters;
89103
};
90104

91105
} // namespace o2::its

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ class TimeFrameGPU;
6565

6666
template <int nLayers = 7>
6767
struct TimeFrame {
68+
using CellSeedN = CellSeed<nLayers>;
6869
friend class gpu::TimeFrameGPU<nLayers>;
70+
6971
TimeFrame();
7072
virtual ~TimeFrame();
73+
7174
const Vertex& getPrimaryVertex(const int ivtx) const { return mPrimaryVertices[ivtx]; }
7275
gsl::span<const Vertex> getPrimaryVertices(int rofId) const;
7376
gsl::span<const Vertex> getPrimaryVertices(int romin, int romax) const;
@@ -298,7 +301,7 @@ struct TimeFrame {
298301

299302
std::array<bounded_vector<Cluster>, nLayers> mUnsortedClusters;
300303
std::vector<bounded_vector<Tracklet>> mTracklets;
301-
std::vector<bounded_vector<CellSeed>> mCells;
304+
std::vector<bounded_vector<CellSeedN>> mCells;
302305
bounded_vector<Road<nLayers - 2>> mRoads;
303306
std::vector<bounded_vector<TrackITSExt>> mTracks;
304307
std::vector<bounded_vector<int>> mCellsNeighbours;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ITStracking/Configuration.h"
2323
#include "ITStracking/MathUtils.h"
2424
#include "ITStracking/TimeFrame.h"
25+
#include "ITStracking/Cell.h"
2526
#include "ITStracking/BoundedAllocator.h"
2627

2728
// #define OPTIMISATION_OUTPUT
@@ -39,6 +40,8 @@ class TrackITSExt;
3940
template <int nLayers = 7>
4041
class TrackerTraits
4142
{
43+
using CellSeedN = CellSeed<nLayers>;
44+
4245
public:
4346
virtual ~TrackerTraits() = default;
4447
virtual void adoptTimeFrame(TimeFrame<nLayers>* tf) { mTimeFrame = tf; }
@@ -55,7 +58,7 @@ class TrackerTraits
5558
virtual void findShortPrimaries();
5659

5760
virtual bool trackFollowing(TrackITSExt* track, int rof, bool outward, const int iteration);
58-
virtual void processNeighbours(int iLayer, int iLevel, const bounded_vector<CellSeed>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeed>& updatedCellSeed, bounded_vector<int>& updatedCellId);
61+
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);
5962

6063
void updateTrackingParameters(const std::vector<TrackingParameters>& trkPars) { mTrkParams = trkPars; }
6164
TimeFrame<nLayers>* getTimeFrame() { return mTimeFrame; }

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ unsigned long TimeFrame<nLayers>::getArtefactsMemory() const
382382
size += sizeof(Tracklet) * trkl.size();
383383
}
384384
for (const auto& cells : mCells) {
385-
size += sizeof(CellSeed) * cells.size();
385+
size += sizeof(CellSeedN) * cells.size();
386386
}
387387
for (const auto& cellsN : mCellsNeighbours) {
388388
size += sizeof(int) * cellsN.size();

Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void Tracker<nLayers>::computeRoadsMClabels()
190190
}
191191
}
192192

193-
const CellSeed& currentCell{mTimeFrame->getCells()[iCell][currentCellIndex]};
193+
const auto& currentCell{mTimeFrame->getCells()[iCell][currentCellIndex]};
194194

195195
if (isFirstRoadCell) {
196196

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void TrackerTraits<nLayers>::computeLayerCells(const int iteration)
319319
}
320320

321321
mTaskArena->execute([&] {
322-
auto forTrackletCells = [&](auto Tag, int iLayer, bounded_vector<CellSeed>& layerCells, int iTracklet, int offset = 0) -> int {
322+
auto forTrackletCells = [&](auto Tag, int iLayer, bounded_vector<CellSeedN>& layerCells, int iTracklet, int offset = 0) -> int {
323323
const Tracklet& currentTracklet{mTimeFrame->getTracklets()[iLayer][iTracklet]};
324324
const int nextLayerClusterIndex{currentTracklet.secondClusterIndex};
325325
const int nextLayerFirstTrackletIndex{mTimeFrame->getTrackletsLookupTable()[iLayer][nextLayerClusterIndex]};
@@ -392,7 +392,7 @@ void TrackerTraits<nLayers>::computeLayerCells(const int iteration)
392392
} else if constexpr (decltype(Tag)::value == PassMode::TwoPassCount::value) {
393393
++foundCells;
394394
} else if constexpr (decltype(Tag)::value == PassMode::TwoPassInsert::value) {
395-
layerCells[offset++] = CellSeed(iLayer, clusId[0], clusId[1], clusId[2], iTracklet, iNextTracklet, track, chi2);
395+
layerCells[offset++] = CellSeedN(iLayer, clusId[0], clusId[1], clusId[2], iTracklet, iNextTracklet, track, chi2);
396396
} else {
397397
static_assert(false, "Unknown mode!");
398398
}
@@ -615,7 +615,7 @@ void TrackerTraits<nLayers>::findCellsNeighbours(const int iteration)
615615
}
616616

617617
template <int nLayers>
618-
void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bounded_vector<CellSeed>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeed>& updatedCellSeeds, bounded_vector<int>& updatedCellsIds)
618+
void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bounded_vector<CellSeedN>& currentCellSeed, const bounded_vector<int>& currentCellId, bounded_vector<CellSeedN>& updatedCellSeeds, bounded_vector<int>& updatedCellsIds)
619619
{
620620
CA_DEBUGGER(std::cout << "Processing neighbours layer " << iLayer << " level " << iLevel << ", size of the cell seeds: " << currentCellSeed.size() << std::endl);
621621
auto propagator = o2::base::Propagator::Instance();
@@ -626,7 +626,7 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
626626

627627
mTaskArena->execute([&] {
628628
auto forCellNeighbours = [&](auto Tag, int iCell, int offset = 0) -> int {
629-
const CellSeed& currentCell{currentCellSeed[iCell]};
629+
const auto& currentCell{currentCellSeed[iCell]};
630630

631631
if constexpr (decltype(Tag)::value != PassMode::TwoPassInsert::value) {
632632
if (currentCell.getLevel() != iLevel) {
@@ -646,7 +646,7 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
646646
for (int iNeighbourCell{startNeighbourId}; iNeighbourCell < endNeighbourId; ++iNeighbourCell) {
647647
CA_DEBUGGER(attempts++);
648648
const int neighbourCellId = mTimeFrame->getCellsNeighbours()[iLayer - 1][iNeighbourCell];
649-
const CellSeed& neighbourCell = mTimeFrame->getCells()[iLayer - 1][neighbourCellId];
649+
const auto& neighbourCell = mTimeFrame->getCells()[iLayer - 1][neighbourCellId];
650650
if (neighbourCell.getSecondTrackletIndex() != currentCell.getFirstTrackletIndex()) {
651651
CA_DEBUGGER(failedByMismatch++);
652652
continue;
@@ -660,7 +660,7 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
660660
}
661661

662662
/// Let's start the fitting procedure
663-
CellSeed seed{currentCell};
663+
CellSeedN seed{currentCell};
664664
const auto& trHit = mTimeFrame->getTrackingFrameInfoOnLayer(iLayer - 1)[neighbourCell.getFirstClusterIndex()];
665665

666666
if (!seed.rotate(trHit.alphaTrackingFrame)) {
@@ -767,17 +767,17 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
767767

768768
for (int startLevel{mTrkParams[iteration].CellsPerRoad()}; startLevel >= mTrkParams[iteration].CellMinimumLevel(); --startLevel) {
769769
CA_DEBUGGER(std::cout << "\t > Processing level " << startLevel << std::endl);
770-
auto seedFilter = [&](const CellSeed& seed) {
770+
auto seedFilter = [&](const auto& seed) {
771771
return seed.getQ2Pt() <= 1.e3 && seed.getChi2() <= mTrkParams[0].MaxChi2NDF * ((startLevel + 2) * 2 - 5);
772772
};
773-
bounded_vector<CellSeed> trackSeeds(mMemoryPool.get());
773+
bounded_vector<CellSeedN> trackSeeds(mMemoryPool.get());
774774
for (int startLayer{mTrkParams[iteration].CellsPerRoad() - 1}; startLayer >= startLevel - 1; --startLayer) {
775775
if ((mTrkParams[iteration].StartLayerMask & (1 << (startLayer + 2))) == 0) {
776776
continue;
777777
}
778778
CA_DEBUGGER(std::cout << "\t\t > Starting processing layer " << startLayer << std::endl);
779779
bounded_vector<int> lastCellId(mMemoryPool.get()), updatedCellId(mMemoryPool.get());
780-
bounded_vector<CellSeed> lastCellSeed(mMemoryPool.get()), updatedCellSeed(mMemoryPool.get());
780+
bounded_vector<CellSeedN> lastCellSeed(mMemoryPool.get()), updatedCellSeed(mMemoryPool.get());
781781

782782
processNeighbours(startLayer, startLevel, mTimeFrame->getCells()[startLayer], lastCellId, updatedCellSeed, updatedCellId);
783783

@@ -805,7 +805,7 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
805805
bounded_vector<TrackITSExt> tracks(mMemoryPool.get());
806806
mTaskArena->execute([&] {
807807
auto forSeed = [&](auto Tag, int iSeed, int offset = 0) {
808-
const CellSeed& seed{trackSeeds[iSeed]};
808+
const auto& seed{trackSeeds[iSeed]};
809809
TrackITSExt temporaryTrack{seed};
810810
temporaryTrack.resetCovariance();
811811
temporaryTrack.setChi2(0);

0 commit comments

Comments
 (0)