Skip to content

Commit 806f5d6

Browse files
committed
ALICE3: share TimeFrame code between CPU and GPU
1 parent f3fa6a9 commit 806f5d6

11 files changed

Lines changed: 795 additions & 1326 deletions

File tree

Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/TimeFrameGPU.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace o2::its::gpu
2525
{
2626

2727
template <int NLayers>
28-
class TimeFrameGPU final : public TimeFrame<NLayers>
28+
class TimeFrameGPU : public TimeFrame<NLayers>
2929
{
3030
using typename TimeFrame<NLayers>::IndexTableUtilsN;
3131
using typename TimeFrame<NLayers>::ROFOverlapTableN;
@@ -35,7 +35,7 @@ class TimeFrameGPU final : public TimeFrame<NLayers>
3535

3636
public:
3737
TimeFrameGPU() = default;
38-
~TimeFrameGPU() final = default;
38+
~TimeFrameGPU() override = default;
3939

4040
/// Most relevant operations
4141
void pushMemoryStack(const int);

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TimeFrameGPU.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,4 +694,5 @@ void TimeFrameGPU<NLayers>::wipe()
694694
}
695695

696696
template class TimeFrameGPU<7>;
697+
template class TimeFrameGPU<11>;
697698
} // namespace o2::its::gpu

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackerTraitsGPU.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,5 @@ void TrackerTraitsGPU<NLayers>::setBz(float bz)
380380
}
381381

382382
template class TrackerTraitsGPU<7>;
383+
template class TrackerTraitsGPU<11>;
383384
} // namespace o2::its

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,4 +1258,184 @@ template void computeTrackSeedHandler(TrackSeed<7>* trackSeeds,
12581258
const o2::base::PropagatorF::MatCorrType matCorrType,
12591259
o2::its::ExternalAllocator* alloc);
12601260

1261+
/// Explicit instantiation of ALICE3 handlers
1262+
template void countTrackletsInROFsHandler<11>(const IndexTableUtils<11>* utils,
1263+
const ROFMaskTable<11>::View& rofMask,
1264+
const int layer,
1265+
const ROFOverlapTable<11>::View& rofOverlaps,
1266+
const ROFVertexLookupTable<11>::View& vertexLUT,
1267+
const int vertexId,
1268+
const Vertex* vertices,
1269+
const int* rofPV,
1270+
const Cluster** clusters,
1271+
std::vector<unsigned int> nClusters,
1272+
const int** ROFClusters,
1273+
const unsigned char** usedClusters,
1274+
const int** clustersIndexTables,
1275+
int** trackletsLUTs,
1276+
gsl::span<int*> trackletsLUTsHost,
1277+
const int iteration,
1278+
const float NSigmaCut,
1279+
bounded_vector<float>& phiCuts,
1280+
const float resolutionPV,
1281+
std::array<float, 11>& minRs,
1282+
std::array<float, 11>& maxRs,
1283+
bounded_vector<float>& resolutions,
1284+
std::vector<float>& radii,
1285+
bounded_vector<float>& mulScatAng,
1286+
o2::its::ExternalAllocator* alloc,
1287+
gpu::Streams& streams);
1288+
1289+
template void computeTrackletsInROFsHandler<11>(const IndexTableUtils<11>* utils,
1290+
const ROFMaskTable<11>::View& rofMask,
1291+
const int layer,
1292+
const ROFOverlapTable<11>::View& rofOverlaps,
1293+
const ROFVertexLookupTable<11>::View& vertexLUT,
1294+
const int vertexId,
1295+
const Vertex* vertices,
1296+
const int* rofPV,
1297+
const Cluster** clusters,
1298+
std::vector<unsigned int> nClusters,
1299+
const int** ROFClusters,
1300+
const unsigned char** usedClusters,
1301+
const int** clustersIndexTables,
1302+
Tracklet** tracklets,
1303+
gsl::span<Tracklet*> spanTracklets,
1304+
gsl::span<int> nTracklets,
1305+
int** trackletsLUTs,
1306+
gsl::span<int*> trackletsLUTsHost,
1307+
const int iteration,
1308+
const float NSigmaCut,
1309+
bounded_vector<float>& phiCuts,
1310+
const float resolutionPV,
1311+
std::array<float, 11>& minRs,
1312+
std::array<float, 11>& maxRs,
1313+
bounded_vector<float>& resolutions,
1314+
std::vector<float>& radii,
1315+
bounded_vector<float>& mulScatAng,
1316+
o2::its::ExternalAllocator* alloc,
1317+
gpu::Streams& streams);
1318+
1319+
template void countCellsHandler<11>(const Cluster** sortedClusters,
1320+
const Cluster** unsortedClusters,
1321+
const TrackingFrameInfo** tfInfo,
1322+
Tracklet** tracklets,
1323+
int** trackletsLUT,
1324+
const int nTracklets,
1325+
const int layer,
1326+
CellSeed* cells,
1327+
int** cellsLUTsArrayDevice,
1328+
int* cellsLUTsHost,
1329+
const float bz,
1330+
const float maxChi2ClusterAttachment,
1331+
const float cellDeltaTanLambdaSigma,
1332+
const float nSigmaCut,
1333+
const std::vector<float>& layerxX0Host,
1334+
o2::its::ExternalAllocator* alloc,
1335+
gpu::Streams& streams);
1336+
1337+
template void computeCellsHandler<11>(const Cluster** sortedClusters,
1338+
const Cluster** unsortedClusters,
1339+
const TrackingFrameInfo** tfInfo,
1340+
Tracklet** tracklets,
1341+
int** trackletsLUT,
1342+
const int nTracklets,
1343+
const int layer,
1344+
CellSeed* cells,
1345+
int** cellsLUTsArrayDevice,
1346+
int* cellsLUTsHost,
1347+
const float bz,
1348+
const float maxChi2ClusterAttachment,
1349+
const float cellDeltaTanLambdaSigma,
1350+
const float nSigmaCut,
1351+
const std::vector<float>& layerxX0Host,
1352+
gpu::Streams& streams);
1353+
1354+
template void countCellNeighboursHandler<11>(CellSeed** cellsLayersDevice,
1355+
int* neighboursLUT,
1356+
int** cellsLUTs,
1357+
gpuPair<int, int>* cellNeighbours,
1358+
int* neighboursIndexTable,
1359+
const Tracklet** tracklets,
1360+
const float maxChi2ClusterAttachment,
1361+
const float bz,
1362+
const int layerIndex,
1363+
const unsigned int nCells,
1364+
const unsigned int nCellsNext,
1365+
const int maxCellNeighbours,
1366+
o2::its::ExternalAllocator* alloc,
1367+
gpu::Stream& stream);
1368+
1369+
template void computeCellNeighboursHandler<11>(CellSeed** cellsLayersDevice,
1370+
int* neighboursLUT,
1371+
int** cellsLUTs,
1372+
gpuPair<int, int>* cellNeighbours,
1373+
int* neighboursIndexTable,
1374+
const Tracklet** tracklets,
1375+
const float maxChi2ClusterAttachment,
1376+
const float bz,
1377+
const int layerIndex,
1378+
const unsigned int nCells,
1379+
const unsigned int nCellsNext,
1380+
const int maxCellNeighbours,
1381+
gpu::Stream& stream);
1382+
1383+
template void processNeighboursHandler<11>(const int startLayer,
1384+
const int startLevel,
1385+
CellSeed** allCellSeeds,
1386+
CellSeed* currentCellSeeds,
1387+
std::array<int, 9>& nCells,
1388+
const unsigned char** usedClusters,
1389+
std::array<int*, 9>& neighbours,
1390+
gsl::span<int*> neighboursDeviceLUTs,
1391+
const TrackingFrameInfo** foundTrackingFrameInfo,
1392+
bounded_vector<TrackSeed<11>>& seedsHost,
1393+
const float bz,
1394+
const float maxChi2ClusterAttachment,
1395+
const float maxChi2NDF,
1396+
const std::vector<float>& layerxX0Host,
1397+
const o2::base::Propagator* propagator,
1398+
const o2::base::PropagatorF::MatCorrType matCorrType,
1399+
o2::its::ExternalAllocator* alloc);
1400+
1401+
template void countTrackSeedHandler(TrackSeed<11>* trackSeeds,
1402+
const TrackingFrameInfo** foundTrackingFrameInfo,
1403+
const Cluster** unsortedClusters,
1404+
int* seedLUT,
1405+
const std::vector<float>& layerRadiiHost,
1406+
const std::vector<float>& minPtsHost,
1407+
const std::vector<float>& layerxX0Host,
1408+
const unsigned int nSeeds,
1409+
const float bz,
1410+
const int startLevel,
1411+
const float maxChi2ClusterAttachment,
1412+
const float maxChi2NDF,
1413+
const int reseedIfShorter,
1414+
const bool repeatRefitOut,
1415+
const bool shiftRefToCluster,
1416+
const o2::base::Propagator* propagator,
1417+
const o2::base::PropagatorF::MatCorrType matCorrType,
1418+
o2::its::ExternalAllocator* alloc);
1419+
1420+
template void computeTrackSeedHandler(TrackSeed<11>* trackSeeds,
1421+
const TrackingFrameInfo** foundTrackingFrameInfo,
1422+
const Cluster** unsortedClusters,
1423+
o2::its::TrackITSExt* tracks,
1424+
const int* seedLUT,
1425+
const std::vector<float>& layerRadiiHost,
1426+
const std::vector<float>& minPtsHost,
1427+
const std::vector<float>& layerxX0Host,
1428+
const unsigned int nSeeds,
1429+
const unsigned int nTracks,
1430+
const float bz,
1431+
const int startLevel,
1432+
const float maxChi2ClusterAttachment,
1433+
const float maxChi2NDF,
1434+
const int reseedIfShorter,
1435+
const bool repeatRefitOut,
1436+
const bool shiftRefToCluster,
1437+
const o2::base::Propagator* propagator,
1438+
const o2::base::PropagatorF::MatCorrType matCorrType,
1439+
o2::its::ExternalAllocator* alloc);
1440+
12611441
} // namespace o2::its

Detectors/Upgrades/ALICE3/GlobalReconstruction/reconstruction/include/ALICE3GlobalReconstruction/TimeFrame.h

Lines changed: 5 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,106 +10,26 @@
1010
// or submit itself to any jurisdiction.
1111
///
1212
/// \file TimeFrame.h
13-
/// \brief TRK TimeFrame class derived from ITS TimeFrame
13+
/// \brief CPU TRK TimeFrame wrapper.
1414
///
1515

1616
#ifndef ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAME_H
1717
#define ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAME_H
1818

19-
#include "CommonDataFormat/InteractionRecord.h"
19+
#include "ALICE3GlobalReconstruction/TimeFrameMixin.h"
2020
#include "ITStracking/TimeFrame.h"
21-
#include "ITStracking/Constants.h"
22-
#include "ITStracking/Configuration.h"
23-
#include "SimulationDataFormat/MCCompLabel.h"
24-
#include "SimulationDataFormat/MCTruthContainer.h"
25-
#include "DataFormatsTRK/Cluster.h"
26-
#include "DataFormatsTRK/ROFRecord.h"
27-
#include <array>
28-
#include <gsl/span>
29-
#include <vector>
30-
#include <unordered_map>
31-
#include <bitset>
32-
#include <cstdint>
3321

34-
#include <nlohmann/json.hpp>
35-
36-
class TTree;
37-
38-
namespace o2
39-
{
40-
namespace trk
22+
namespace o2::trk
4123
{
42-
class GeometryTGeo;
4324

44-
/// TRK TimeFrame class that extends ITS TimeFrame functionality
45-
/// This allows for customization of tracking algorithms specific to the TRK detector
4625
template <int nLayers = 11>
47-
class TimeFrame : public o2::its::TimeFrame<nLayers>
26+
class TimeFrame : public TimeFrameMixin<nLayers, o2::its::TimeFrame<nLayers>>
4827
{
4928
public:
5029
TimeFrame() = default;
5130
~TimeFrame() override = default;
52-
53-
/// Override methods if needed for TRK-specific behavior
54-
/// For now, we inherit all functionality from ITS TimeFrame
55-
56-
/// Process hits from TTree to initialize ROFs
57-
/// \param hitsTree Tree containing TRK hits
58-
/// \param mcHeaderTree Tree containing MC event headers
59-
/// \param nEvents Number of events to process
60-
/// \param gman TRK geometry manager instance
61-
/// \param config Configuration parameters for hit reconstruction
62-
int loadROFsFromHitTree(TTree* hitsTree, GeometryTGeo* gman, const nlohmann::json& config);
63-
64-
/// Load ROF data from TRK clustered inputs (without topology dictionary for the time being).
65-
/// Patterns are expected as [rowSpan, colSpan, bitmap...] for each cluster.
66-
int loadROFrameData(gsl::span<const o2::trk::ROFRecord> rofs,
67-
gsl::span<const o2::trk::Cluster> clusters,
68-
gsl::span<const unsigned char> patterns,
69-
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr,
70-
float yPlaneMLOT = 0.f);
71-
72-
/// Add primary vertices from MC headers for each ROF
73-
/// \param mcHeaderTree Tree containing MC event headers
74-
/// \param nRofs Number of ROFs (Read-Out Frames)
75-
/// \param nEvents Number of events to process
76-
/// \param inROFpileup Number of events per ROF
77-
void getPrimaryVerticesFromMC(TTree* mcHeaderTree, int nRofs, Long64_t nEvents, int inROFpileup);
78-
79-
/// Add primary vertices using truth seeding from the DigitizationContext (collisioncontext.root).
80-
/// Maps each MC collision to its ROF via the ROF BCData timestamps (TRK digitising timing).
81-
/// \param rofs Span of TRK ROF records used to determine which ROF each collision falls into
82-
void addTruthSeedingVertices(gsl::span<const o2::trk::ROFRecord> rofs);
83-
84-
/// Derive the per-layer LayerTiming from the per-layer ROF spans and initialise
85-
/// the ROF lookup tables. Each layer can have its own mROFLength and mROFBias,
86-
/// so staggered TRK readouts are handled naturally as long as the input
87-
/// ROFRecords carry the right BCData. The TF anchor (used to keep timing
88-
/// values bounded when expressed as BC offsets) is set to the earliest
89-
/// rofs[0].BCData across layers; consumers can read it back via getTFAnchorIR().
90-
/// Idempotent — must be called before loadROFrameData() in the cluster path.
91-
/// \param layerROFs One ROFRecord span per layer.
92-
void deriveAndInitTiming(const std::array<gsl::span<const o2::trk::ROFRecord>, nLayers>& layerROFs);
93-
94-
/// TF anchor IR: the earliest first-ROF BCData seen across all layers when
95-
/// deriveAndInitTiming() was called. All LayerTiming BC values (and any BC
96-
/// the tracker emits via clockLayer.getROFStartInBC) are offsets from this
97-
/// anchor — add anchor.toLong() to convert back to absolute BC.
98-
const o2::InteractionRecord& getTFAnchorIR() const noexcept { return mTFAnchorIR; }
99-
100-
private:
101-
/// One-shot setup of the per-layer LayerTiming and the three ROF lookup tables
102-
/// (overlap, vertex lookup, multiplicity mask). Idempotent: subsequent calls are
103-
/// no-ops, so the data-loading entry points may invoke it on every TF without
104-
/// rebuilding the tables. Mirrors the initOnceDone gate in
105-
/// ITSTrackingInterface::updateTimeDependentParams.
106-
void initTimingTables(const std::array<o2::its::LayerTiming, nLayers>& timings);
107-
108-
bool mTimingTablesInitialised{false};
109-
o2::InteractionRecord mTFAnchorIR{0, 0};
11031
};
11132

112-
} // namespace trk
113-
} // namespace o2
33+
} // namespace o2::trk
11434

11535
#endif // ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAME_H

0 commit comments

Comments
 (0)