Skip to content

Commit ec8e8c0

Browse files
committed
ALICE3: share TimeFrame code between CPU and GPU
1 parent e0fc09a commit ec8e8c0

7 files changed

Lines changed: 611 additions & 1324 deletions

File tree

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

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

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,28 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
///
12+
/// \file TimeFrameGPU.h
13+
/// \brief GPU TRK TimeFrame wrapper.
14+
///
1115

1216
#ifndef ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAMEGPU_H
1317
#define ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAMEGPU_H
1418

15-
#include "CommonDataFormat/InteractionRecord.h"
19+
#include "ALICE3GlobalReconstruction/TimeFrameMixin.h"
1620
#include "ITStrackingGPU/TimeFrameGPU.h"
17-
#include "SimulationDataFormat/MCCompLabel.h"
18-
#include "SimulationDataFormat/MCTruthContainer.h"
19-
#include "DataFormatsTRK/Cluster.h"
20-
#include "DataFormatsTRK/ROFRecord.h"
2121

22-
#include <array>
23-
#include <gsl/span>
24-
#include <nlohmann/json.hpp>
25-
26-
class TTree;
27-
28-
namespace o2
29-
{
30-
namespace trk
22+
namespace o2::trk
3123
{
32-
class GeometryTGeo;
3324

3425
template <int nLayers = 11>
35-
class TimeFrameGPU : public o2::its::gpu::TimeFrameGPU<nLayers>
26+
class TimeFrameGPU : public TimeFrameMixin<nLayers, o2::its::gpu::TimeFrameGPU<nLayers>>
3627
{
3728
public:
3829
TimeFrameGPU() = default;
3930
~TimeFrameGPU() override = default;
40-
41-
int loadROFsFromHitTree(TTree* hitsTree, GeometryTGeo* gman, const nlohmann::json& config);
42-
43-
int loadROFrameData(gsl::span<const o2::trk::ROFRecord> rofs,
44-
gsl::span<const o2::trk::Cluster> clusters,
45-
gsl::span<const unsigned char> patterns,
46-
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr,
47-
float yPlaneMLOT = 0.f);
48-
49-
void getPrimaryVerticesFromMC(TTree* mcHeaderTree, int nRofs, Long64_t nEvents, int inROFpileup);
50-
void addTruthSeedingVertices(gsl::span<const o2::trk::ROFRecord> rofs);
51-
52-
/// Mirror of o2::trk::TimeFrame::deriveAndInitTiming for the GPU backend.
53-
/// See the CPU version for the design notes; the two implementations are
54-
/// kept in sync by hand until the dedup follow-up lands.
55-
void deriveAndInitTiming(const std::array<gsl::span<const o2::trk::ROFRecord>, nLayers>& layerROFs);
56-
57-
const o2::InteractionRecord& getTFAnchorIR() const noexcept { return mTFAnchorIR; }
58-
59-
private:
60-
void initTimingTables(const std::array<o2::its::LayerTiming, nLayers>& timings);
61-
62-
bool mTimingTablesInitialised{false};
63-
o2::InteractionRecord mTFAnchorIR{0, 0};
6431
};
6532

66-
} // namespace trk
67-
} // namespace o2
33+
} // namespace o2::trk
6834

69-
#endif
35+
#endif // ALICEO2_ALICE3GLOBALRECONSTRUCTION_TIMEFRAMEGPU_H

0 commit comments

Comments
 (0)