Skip to content

Commit 172c9ed

Browse files
authored
ALICE3: use track extension + allow configuring passes via JSON (#15500)
1 parent d9f827c commit 172c9ed

6 files changed

Lines changed: 65 additions & 16 deletions

File tree

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ o2-alice3-global-reconstruction-reco-workflow --tracking-from-hits-config config
1919
- `--tracking-from-hits-config <file>`: Path to tracking-from-hits configuration JSON file
2020
- `--tracking-from-clusters-config <file>`: Path to tracking-from-clusters configuration JSON file
2121
- `--gpu-device <id>`: Tracking device type (`1` CPU, `2` CUDA, `3` HIP)
22+
- `--tracking-threads <n>`: Number of CPU threads used by TRK tracking
2223
- `-b`: Batch mode (no GUI)
2324
- `--disable-root-output`: Skip writing tracks to ROOT file
2425
- `--help`: Show all available options
@@ -80,12 +81,10 @@ The tracking configuration is provided via a JSON file that specifies:
8081
"SaveTimeBenchmarks": false,
8182
"DoUPCIteration": false,
8283
"FataliseUponFailure": true,
83-
"UseTrackFollower": true,
84-
"UseTrackFollowerTop": false,
85-
"UseTrackFollowerBot": false,
86-
"UseTrackFollowerMix": true,
84+
"TrackFollower": "mix",
8785
"TrackFollowerNSigmaCutZ": 1.0,
8886
"TrackFollowerNSigmaCutPhi": 1.0,
87+
"TrackFollowerMaxHypotheses": 1,
8988
"createArtefactLabels": false,
9089
"PrintMemory": false,
9190
"DropTFUponFailure": false

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/include/ALICE3GlobalReconstructionWorkflow/RecoWorkflow.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ o2::framework::WorkflowSpec getWorkflow(bool useMC,
2323
const std::string& hitRecoConfig,
2424
const std::string& clusterRecoConfig,
2525
bool disableRootOutput = false,
26-
o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU);
26+
o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU,
27+
int trackingThreads = 1);
2728

2829
} // namespace o2::trk::global_reco_workflow
2930

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/include/ALICE3GlobalReconstructionWorkflow/TrackerSpec.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class TrackerDPL : public framework::Task
4545
bool isMC,
4646
const std::string& hitRecoConfig,
4747
const std::string& clusterRecoConfig,
48-
gpu::gpudatatypes::DeviceType dType = gpu::gpudatatypes::DeviceType::CPU);
48+
gpu::gpudatatypes::DeviceType dType = gpu::gpudatatypes::DeviceType::CPU,
49+
int trackingThreads = 1);
4950
~TrackerDPL() override = default;
5051
void init(framework::InitContext& ic) final;
5152
void run(framework::ProcessingContext& pc) final;
@@ -67,6 +68,7 @@ class TrackerDPL : public framework::Task
6768
// ITSTrackingInterface mITSTrackingInterface;
6869
bool mIsMC{true};
6970
gpu::gpudatatypes::DeviceType mDeviceType{gpu::gpudatatypes::DeviceType::CPU};
71+
int mTrackingThreads{1};
7072
std::shared_ptr<its::BoundedMemoryResource> mMemoryPool;
7173
std::shared_ptr<its::ExternalAllocator> mGPUAllocator;
7274
std::shared_ptr<tbb::task_arena> mTaskArena;
@@ -79,7 +81,7 @@ class TrackerDPL : public framework::Task
7981
#endif
8082
};
8183

82-
framework::DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, const std::string& clusterRecoConfig, gpu::gpudatatypes::DeviceType dType = gpu::gpudatatypes::DeviceType::CPU);
84+
framework::DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, const std::string& clusterRecoConfig, gpu::gpudatatypes::DeviceType dType = gpu::gpudatatypes::DeviceType::CPU, int trackingThreads = 1);
8385

8486
} // namespace o2::trk
8587
#endif /* O2_TRK_TRACKERDPL */

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/src/RecoWorkflow.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ framework::WorkflowSpec getWorkflow(bool useMC,
2121
const std::string& hitRecoConfig,
2222
const std::string& clusterRecoConfig,
2323
bool disableRootOutput,
24-
o2::gpu::gpudatatypes::DeviceType dtype)
24+
o2::gpu::gpudatatypes::DeviceType dtype,
25+
int trackingThreads)
2526
{
2627
framework::WorkflowSpec specs;
2728

2829
if (!hitRecoConfig.empty() || !clusterRecoConfig.empty()) {
2930
LOG_IF(info, !hitRecoConfig.empty()) << "Using hit reco config from file " << hitRecoConfig;
3031
LOG_IF(info, !clusterRecoConfig.empty()) << "Using cluster reco config from file " << clusterRecoConfig;
31-
specs.emplace_back(o2::trk::getTrackerSpec(useMC, hitRecoConfig, clusterRecoConfig, dtype));
32+
specs.emplace_back(o2::trk::getTrackerSpec(useMC, hitRecoConfig, clusterRecoConfig, dtype, trackingThreads));
3233
if (!disableRootOutput) {
3334
specs.emplace_back(o2::trk::getTrackWriterSpec(useMC));
3435
}

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/src/TrackerSpec.cxx

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ TrackerDPL::TrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr,
7171
bool isMC,
7272
const std::string& hitRecoConfigFileName,
7373
const std::string& clusterRecoConfigFileName,
74-
o2::gpu::gpudatatypes::DeviceType dType)
74+
o2::gpu::gpudatatypes::DeviceType dType,
75+
int trackingThreads)
7576
{
7677
if (!hitRecoConfigFileName.empty()) {
7778
std::ifstream configFile(hitRecoConfigFileName);
@@ -83,6 +84,7 @@ TrackerDPL::TrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr,
8384
}
8485
mIsMC = isMC;
8586
mDeviceType = dType;
87+
mTrackingThreads = std::max(1, trackingThreads);
8688
}
8789

8890
void TrackerDPL::init(InitContext& ic)
@@ -103,6 +105,15 @@ std::vector<o2::its::TrackingParameters> TrackerDPL::createTrackingParamsFromCon
103105
auto loadTrackingParamsFromJson = [](std::vector<o2::its::TrackingParameters>& trackingParams, const nlohmann::json& paramConfigJson) {
104106
for (const auto& paramConfig : paramConfigJson) {
105107
o2::its::TrackingParameters params;
108+
auto applyPassFlag = [&](const char* name, o2::its::IterationStep step) {
109+
if (paramConfig.contains(name)) {
110+
if (paramConfig[name].get<bool>()) {
111+
params.PassFlags.set(step);
112+
} else {
113+
params.PassFlags.reset(step);
114+
}
115+
}
116+
};
106117

107118
if (paramConfig.contains("NLayers")) {
108119
params.NLayers = paramConfig["NLayers"].get<int>();
@@ -172,6 +183,37 @@ std::vector<o2::its::TrackingParameters> TrackerDPL::createTrackingParamsFromCon
172183
if (paramConfig.contains("CreateArtefactLabels")) {
173184
params.CreateArtefactLabels = paramConfig["CreateArtefactLabels"].get<bool>();
174185
}
186+
if (paramConfig.contains("TrackFollower")) {
187+
const auto mode = paramConfig["TrackFollower"].get<std::string>();
188+
if (mode == "top" || mode == "outward") {
189+
params.PassFlags.set(o2::its::IterationStep::TrackFollowerTop);
190+
} else if (mode == "bot" || mode == "bottom" || mode == "inward") {
191+
params.PassFlags.set(o2::its::IterationStep::TrackFollowerBot);
192+
} else if (mode == "mix" || mode == "both") {
193+
params.PassFlags.set(o2::its::IterationStep::TrackFollowerTop);
194+
params.PassFlags.set(o2::its::IterationStep::TrackFollowerBot);
195+
} else if (mode != "off") {
196+
LOGP(fatal, "Invalid ALICE3 TRK tracking parameter TrackFollower: {}", mode);
197+
}
198+
}
199+
if (paramConfig.contains("TrackFollowerNSigmaCutZ")) {
200+
params.TrackFollowerNSigmaCutZ = paramConfig["TrackFollowerNSigmaCutZ"].get<float>();
201+
}
202+
if (paramConfig.contains("TrackFollowerNSigmaCutPhi")) {
203+
params.TrackFollowerNSigmaCutPhi = paramConfig["TrackFollowerNSigmaCutPhi"].get<float>();
204+
}
205+
if (paramConfig.contains("TrackFollowerMaxHypotheses")) {
206+
params.TrackFollowerMaxHypotheses = std::max(1, paramConfig["TrackFollowerMaxHypotheses"].get<int>());
207+
}
208+
applyPassFlag("FirstPass", o2::its::IterationStep::FirstPass);
209+
applyPassFlag("RebuildClusterLUT", o2::its::IterationStep::RebuildClusterLUT);
210+
applyPassFlag("UseUPCMask", o2::its::IterationStep::UseUPCMask);
211+
applyPassFlag("SelectUPCVertices", o2::its::IterationStep::SelectUPCVertices);
212+
applyPassFlag("ResetVertices", o2::its::IterationStep::ResetVertices);
213+
applyPassFlag("SkipROFsAboveThreshold", o2::its::IterationStep::SkipROFsAboveThreshold);
214+
applyPassFlag("MarkVerticesAsUPC", o2::its::IterationStep::MarkVerticesAsUPC);
215+
applyPassFlag("TrackFollowerTop", o2::its::IterationStep::TrackFollowerTop);
216+
applyPassFlag("TrackFollowerBot", o2::its::IterationStep::TrackFollowerBot);
175217
if (paramConfig.contains("PrintMemory")) {
176218
params.PrintMemory = paramConfig["PrintMemory"].get<bool>();
177219
}
@@ -255,7 +297,7 @@ void TrackerDPL::run(ProcessingContext& pc)
255297
mMemoryPool = std::make_shared<its::BoundedMemoryResource>();
256298
}
257299
if (mTaskArena.get() == nullptr) {
258-
mTaskArena = std::make_shared<tbb::task_arena>(1); /// TODO: make it configurable
300+
mTaskArena = std::make_shared<tbb::task_arena>(mTrackingThreads);
259301
}
260302

261303
mTrackingParams = createTrackingParamsFromConfig();
@@ -309,7 +351,7 @@ void TrackerDPL::endOfStream(EndOfStreamContext& ec)
309351
LOGF(info, "TRK CA-Tracker total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
310352
}
311353

312-
DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, const std::string& clusterRecoConfig, o2::gpu::gpudatatypes::DeviceType dType)
354+
DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, const std::string& clusterRecoConfig, o2::gpu::gpudatatypes::DeviceType dType, int trackingThreads)
313355
{
314356
std::vector<InputSpec> inputs;
315357
std::vector<OutputSpec> outputs;
@@ -337,7 +379,8 @@ DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, c
337379
useMC,
338380
hitRecoConfig,
339381
clusterRecoConfig,
340-
dType)},
382+
dType,
383+
trackingThreads)},
341384
Options{ConfigParamSpec{"max-loops", VariantType::Int, 1, {"max number of loops"}}
342385
#ifdef O2_WITH_ACTS
343386
,
@@ -373,7 +416,8 @@ DataProcessorSpec getTrackerSpec(bool useMC, const std::string& hitRecoConfig, c
373416
useMC,
374417
hitRecoConfig,
375418
clusterRecoConfig,
376-
dType)},
419+
dType,
420+
trackingThreads)},
377421
Options{}};
378422
}
379423

Detectors/Upgrades/ALICE3/GlobalReconstruction/workflow/src/alice3-global-reconstruction-workflow.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
3939
{"tracking-from-hits-config", VariantType::String, "", {"JSON file with tracking from hits configuration"}},
4040
{"tracking-from-clusters-config", VariantType::String, "", {"JSON file with tracking from clusters configuration"}},
4141
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
42-
{"gpu-device", VariantType::Int, 1, {"use gpu device: CPU=1,CUDA=2,HIP=3 (default: CPU)"}}};
42+
{"gpu-device", VariantType::Int, 1, {"use gpu device: CPU=1,CUDA=2,HIP=3 (default: CPU)"}},
43+
{"tracking-threads", VariantType::Int, 1, {"number of CPU threads used by TRK tracking"}}};
4344
std::swap(workflowOptions, options);
4445
}
4546

@@ -52,6 +53,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
5253
auto hitRecoConfig = configcontext.options().get<std::string>("tracking-from-hits-config");
5354
auto clusterRecoConfig = configcontext.options().get<std::string>("tracking-from-clusters-config");
5455
auto gpuDevice = static_cast<o2::gpu::gpudatatypes::DeviceType>(configcontext.options().get<int>("gpu-device"));
56+
auto trackingThreads = configcontext.options().get<int>("tracking-threads");
5557
auto disableRootOutput = configcontext.options().get<bool>("disable-root-output");
5658
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
5759

@@ -61,5 +63,5 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
6163

6264
o2::conf::ConfigurableParam::writeINI("o2alice3globalrecoflow_configuration.ini");
6365

64-
return o2::trk::global_reco_workflow::getWorkflow(useMC, hitRecoConfig, clusterRecoConfig, disableRootOutput, gpuDevice);
66+
return o2::trk::global_reco_workflow::getWorkflow(useMC, hitRecoConfig, clusterRecoConfig, disableRootOutput, gpuDevice, trackingThreads);
6567
}

0 commit comments

Comments
 (0)