Skip to content

Commit 70f2477

Browse files
committed
ITS: add scaffolding for tuning of reco-parameters
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 66b9c9c commit 70f2477

10 files changed

Lines changed: 138 additions & 17 deletions

File tree

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ o2_add_library(ITStracking
2121
src/IOUtils.cxx
2222
src/Tracker.cxx
2323
src/TrackerTraits.cxx
24+
src/TrackerTraitsMC.cxx
2425
src/TrackingConfigParam.cxx
2526
src/Vertexer.cxx
2627
src/VertexerTraits.cxx
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
13+
#ifndef TRACKINGITSU_INCLUDE_TRACKERTRAITSMC_H_
14+
#define TRACKINGITSU_INCLUDE_TRACKERTRAITSMC_H_
15+
16+
#include "ITStracking/TrackerTraits.h"
17+
18+
namespace o2::its
19+
{
20+
21+
// This class faciliates the tuning of the reconstruction parameters.
22+
// Two modes are foreseen:
23+
// 1. Inspect and dump the artefacts the reconstrcution produces
24+
// 2. Run the same over MC truth
25+
// Both should faciliate finding sources of in-efficiency (c.f., missing links)
26+
// and allow to tune overall the imposed parameters in a consistent way.
27+
template <int NLayers>
28+
class TrackerTraitsMC : public TrackerTraits<NLayers>
29+
{
30+
public:
31+
TrackerTraitsMC() = default;
32+
~TrackerTraitsMC() override = default;
33+
34+
void computeLayerTracklets(const int iteration, int iVertex) override;
35+
void computeLayerCells(const int iteration) override;
36+
void findCellsNeighbours(const int iteration) override;
37+
void findRoads(const int iteration) override;
38+
39+
const char* getName() const noexcept override { return "TUNE"; }
40+
};
41+
42+
} // namespace o2::its
43+
44+
#endif /* TRACKINGITSU_INCLUDE_TRACKERTRAITSMC_H_ */
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
13+
#include "ITStracking/TrackerTraitsMC.h"
14+
15+
#include "Framework/Logger.h"
16+
17+
namespace o2::its
18+
{
19+
20+
template <int NLayers>
21+
void TrackerTraitsMC<NLayers>::computeLayerTracklets(const int iteration, int iVertex)
22+
{
23+
TrackerTraits<NLayers>::computeLayerTracklets(iteration, iVertex);
24+
}
25+
26+
template <int NLayers>
27+
void TrackerTraitsMC<NLayers>::computeLayerCells(const int iteration)
28+
{
29+
TrackerTraits<NLayers>::computeLayerCells(iteration);
30+
}
31+
32+
template <int NLayers>
33+
void TrackerTraitsMC<NLayers>::findCellsNeighbours(const int iteration)
34+
{
35+
TrackerTraits<NLayers>::findCellsNeighbours(iteration);
36+
}
37+
38+
template <int NLayers>
39+
void TrackerTraitsMC<NLayers>::findRoads(const int iteration)
40+
{
41+
TrackerTraits<NLayers>::findRoads(iteration);
42+
}
43+
44+
template class TrackerTraitsMC<7>;
45+
46+
} // namespace o2::its

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/RecoWorkflow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace reco_workflow
2828

2929
framework::WorkflowSpec getWorkflow(bool useMC, bool doStag, TrackingMode::Type trmode, const bool overrideBeamPosition = false,
3030
bool upstreamDigits = false, bool upstreamClusters = false, bool clrofOnly = false, bool disableRootOutput = false, bool useGeom = false, int useTrig = 0,
31-
bool useGPUWF = false, o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU);
31+
bool useGPUWF = false, o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU, bool enableTuning = false);
3232
}
3333

3434
} // namespace its

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/TrackerSpec.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class TrackerDPL : public framework::Task
4646
int trgType,
4747
const TrackingMode::Type trMode = TrackingMode::Unset,
4848
const bool overrBeamEst = false,
49-
o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU);
49+
o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU,
50+
bool enableTuning = false);
5051
~TrackerDPL() override = default;
5152
void init(framework::InitContext& ic) final;
5253
void run(framework::ProcessingContext& pc) final;
@@ -61,10 +62,11 @@ class TrackerDPL : public framework::Task
6162
std::unique_ptr<o2::gpu::GPUChainITS> mChainITS = nullptr;
6263
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
6364
ITSTrackingInterface mITSTrackingInterface;
65+
bool mEnableTuning = false;
6466
TStopwatch mTimer;
6567
};
6668

67-
framework::DataProcessorSpec getTrackerSpec(bool useMC, bool doStag, bool useGeom, int useTrig, TrackingMode::Type trMode, const bool overrBeamEst = false, o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU);
69+
framework::DataProcessorSpec getTrackerSpec(bool useMC, bool doStag, bool useGeom, int useTrig, TrackingMode::Type trMode, const bool overrBeamEst = false, o2::gpu::gpudatatypes::DeviceType dType = o2::gpu::gpudatatypes::DeviceType::CPU, bool enableTuning = false);
6870

6971
} // namespace o2::its
7072

Detectors/ITSMFT/ITS/workflow/src/RecoWorkflow.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ framework::WorkflowSpec getWorkflow(bool useMC, bool doStag,
3737
bool useGeom,
3838
int useTrig,
3939
bool useGPUWF,
40-
o2::gpu::gpudatatypes::DeviceType dtype)
40+
o2::gpu::gpudatatypes::DeviceType dtype,
41+
bool enableTuning)
4142
{
4243
framework::WorkflowSpec specs;
4344
if (!(upstreamDigits || upstreamClusters)) {
@@ -80,7 +81,7 @@ framework::WorkflowSpec getWorkflow(bool useMC, bool doStag,
8081
.algorithm = AlgorithmSpec{adoptTask<o2::gpu::GPURecoWorkflowSpec>(task)},
8182
.options = taskOptions});
8283
} else {
83-
specs.emplace_back(o2::its::getTrackerSpec(useMC, doStag, useGeom, useTrig, trmode, overrideBeamPosition, dtype));
84+
specs.emplace_back(o2::its::getTrackerSpec(useMC, doStag, useGeom, useTrig, trmode, overrideBeamPosition, dtype, enableTuning));
8485
}
8586
if (!disableRootOutput) {
8687
specs.emplace_back(o2::its::getTrackWriterSpec(useMC));

Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111

1212
#include <vector>
1313

14-
#include "Framework/ControlService.h"
15-
#include "Framework/ConfigParamRegistry.h"
1614
#include "Framework/CCDBParamSpec.h"
1715
#include "Framework/DeviceSpec.h"
16+
#include "Framework/Logger.h"
1817
#include "DataFormatsITSMFT/DPLAlpideParam.h"
1918
#include "ITSWorkflow/TrackerSpec.h"
20-
#include "ITStracking/Definitions.h"
2119
#include "ITStracking/TrackingConfigParam.h"
20+
#include "ITStracking/TrackerTraitsMC.h"
2221

2322
namespace o2
2423
{
@@ -31,19 +30,24 @@ TrackerDPL::TrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr,
3130
int trgType,
3231
const TrackingMode::Type trMode,
3332
const bool overrBeamEst,
34-
o2::gpu::gpudatatypes::DeviceType dType) : mGGCCDBRequest(gr),
35-
mRecChain{o2::gpu::GPUReconstruction::CreateInstance(dType, true)},
36-
mITSTrackingInterface{isMC, doStag, trgType, overrBeamEst}
33+
o2::gpu::gpudatatypes::DeviceType dType,
34+
bool enableTuning) : mRecChain{o2::gpu::GPUReconstruction::CreateInstance(dType, true)},
35+
mGGCCDBRequest(gr),
36+
mITSTrackingInterface{isMC, doStag, trgType, overrBeamEst},
37+
mEnableTuning{enableTuning}
3738
{
3839
mITSTrackingInterface.setTrackingMode(trMode);
3940
}
4041

41-
void TrackerDPL::init(InitContext& ic)
42+
void TrackerDPL::init(InitContext& /*ic*/)
4243
{
4344
mTimer.Stop();
4445
mTimer.Reset();
4546
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
4647
mChainITS.reset(mRecChain->AddChain<o2::gpu::GPUChainITS>());
48+
if (mEnableTuning) {
49+
mChainITS->SetITSTrackerTraits(std::make_unique<TrackerTraitsMC<ITSTrackingInterface::NLayers>>());
50+
}
4751
mITSTrackingInterface.setTraitsFromProvider(mChainITS->GetITSVertexerTraits(),
4852
mChainITS->GetITSTrackerTraits(),
4953
mChainITS->GetITSTimeframe());
@@ -78,7 +82,7 @@ void TrackerDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
7882
mITSTrackingInterface.finaliseCCDB(matcher, obj);
7983
}
8084

81-
void TrackerDPL::endOfStream(EndOfStreamContext& ec)
85+
void TrackerDPL::endOfStream(EndOfStreamContext& /*ec*/)
8286
{
8387
end();
8488
}
@@ -92,7 +96,7 @@ void TrackerDPL::end()
9296
}
9397
}
9498

95-
DataProcessorSpec getTrackerSpec(bool useMC, bool doStag, bool useGeom, int trgType, TrackingMode::Type trMode, const bool overrBeamEst, o2::gpu::gpudatatypes::DeviceType dType)
99+
DataProcessorSpec getTrackerSpec(bool useMC, bool doStag, bool useGeom, int trgType, TrackingMode::Type trMode, const bool overrBeamEst, o2::gpu::gpudatatypes::DeviceType dType, bool enableTuning)
96100
{
97101
const int mLayers = doStag ? o2::itsmft::DPLAlpideParam<o2::detectors::DetID::ITS>::getNLayers() : 1;
98102
std::vector<InputSpec> inputs;
@@ -149,7 +153,8 @@ DataProcessorSpec getTrackerSpec(bool useMC, bool doStag, bool useGeom, int trgT
149153
trgType,
150154
trMode,
151155
overrBeamEst,
152-
dType)},
156+
dType,
157+
enableTuning)},
153158
.options = Options{}};
154159
}
155160

Detectors/ITSMFT/ITS/workflow/src/its-reco-workflow.cxx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "DataFormatsITSMFT/DPLAlpideParamInitializer.h"
1414
#include "CommonUtils/ConfigurableParam.h"
1515
#include "ITStracking/Configuration.h"
16+
#include "ITStracking/TrackingConfigParam.h"
1617
#include "DetectorsRaw/HBFUtilsInitializer.h"
1718
#include "Framework/CallbacksPolicy.h"
1819
#include "Framework/ConfigContext.h"
@@ -46,6 +47,7 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
4647
{"ccdb-meanvertex-seed", o2::framework::VariantType::Bool, false, {"use MeanVertex from CCDB if available to provide beam position seed (default: false)"}},
4748
{"select-with-triggers", o2::framework::VariantType::String, "none", {"use triggers to prescale processed ROFs: phys, trd, none"}},
4849
{"tracking-mode", o2::framework::VariantType::String, "sync", {"sync,async,cosmics,unset,off"}},
50+
{"enable-tuning", o2::framework::VariantType::Bool, false, {"enable MC-based CPU tracker tuning"}},
4951
{"disable-tracking", o2::framework::VariantType::Bool, false, {"disable tracking step"}},
5052
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
5153
{"use-full-geometry", o2::framework::VariantType::Bool, false, {"use full geometry instead of the light-weight ITS part"}},
@@ -70,6 +72,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
7072
auto trmode = configcontext.options().get<std::string>("tracking-mode");
7173
auto selTrig = configcontext.options().get<std::string>("select-with-triggers");
7274
auto useGpuWF = configcontext.options().get<bool>("use-gpu-workflow");
75+
auto enableTuning = configcontext.options().get<bool>("enable-tuning");
7376
auto gpuDevice = static_cast<o2::gpu::gpudatatypes::DeviceType>(configcontext.options().get<int>("gpu-device"));
7477
auto extDigits = configcontext.options().get<bool>("digits-from-upstream");
7578
auto extClusters = configcontext.options().get<bool>("clusters-from-upstream");
@@ -92,10 +95,20 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
9295
LOG(fatal) << "Unknown trigger type requested for events prescaling: " << selTrig;
9396
}
9497
}
98+
const auto trackingMode = o2::its::TrackingMode::fromString(trmode);
99+
if (enableTuning && !useMC) {
100+
LOGP(fatal, "ITS tracker tuning requires MC labels");
101+
}
102+
if (enableTuning && useGpuWF) {
103+
LOGP(fatal, "ITS tracker tuning is CPU-only and cannot use the GPU workflow");
104+
}
105+
if (enableTuning && gpuDevice != o2::gpu::gpudatatypes::DeviceType::CPU) {
106+
LOGP(fatal, "ITS tracker tuning is CPU-only and cannot use GPU tracker traits");
107+
}
95108
auto wf = o2::its::reco_workflow::getWorkflow(
96109
useMC,
97110
doStag,
98-
o2::its::TrackingMode::fromString(trmode),
111+
trackingMode,
99112
beamPosOVerride,
100113
extDigits,
101114
extClusters,
@@ -104,7 +117,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
104117
useGeom,
105118
trType,
106119
useGpuWF,
107-
gpuDevice);
120+
gpuDevice,
121+
enableTuning);
108122

109123
// configure dpl timer to inject correct firstTForbit: start from the 1st orbit of TF containing 1st sampled orbit
110124
o2::raw::HBFUtilsInitializer hbfIni(configcontext, wf);

GPU/GPUTracking/Global/GPUChainITS.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ o2::its::TrackerTraits<7>* GPUChainITS::GetITSTrackerTraits()
5959
return mITSTrackerTraits.get();
6060
}
6161

62+
void GPUChainITS::SetITSTrackerTraits(std::unique_ptr<o2::its::TrackerTraits<7>> trackerTraits)
63+
{
64+
mITSTrackerTraits = std::move(trackerTraits);
65+
}
66+
6267
o2::its::VertexerTraits<7>* GPUChainITS::GetITSVertexerTraits()
6368
{
6469
if (mITSVertexerTraits == nullptr) {

GPU/GPUTracking/Global/GPUChainITS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct Cluster;
2222
struct TrackingFrameInfo;
2323
class TrackITSExt;
2424
class GPUFrameworkExternalAllocator;
25+
template <int>
26+
class TrackerTraits;
2527
} // namespace o2::its
2628

2729
namespace o2::gpu
@@ -42,6 +44,7 @@ class GPUChainITS final : public GPUChain
4244
void MemorySize(size_t&, size_t&) final {};
4345

4446
o2::its::TrackerTraits<7>* GetITSTrackerTraits();
47+
void SetITSTrackerTraits(std::unique_ptr<o2::its::TrackerTraits<7>> trackerTraits);
4548
o2::its::VertexerTraits<7>* GetITSVertexerTraits();
4649
o2::its::TimeFrame<7>* GetITSTimeframe();
4750

0 commit comments

Comments
 (0)