Skip to content

Commit fc3ace1

Browse files
mconcasalibuild
andauthored
ALICE3-TRK: Add skeleton for the TRK reconstruction WF (#14222)
--------- Co-authored-by: ALICE Builder <alibuild@users.noreply.github.com>
1 parent f1e0a12 commit fc3ace1

File tree

6 files changed

+326
-12
lines changed

6 files changed

+326
-12
lines changed

Detectors/Upgrades/ALICE3/TRK/workflow/CMakeLists.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@
1010
# or submit itself to any jurisdiction.
1111

1212
o2_add_library(TRKWorkflow
13+
TARGETVARNAME targetName
1314
SOURCES src/DigitReaderSpec.cxx
1415
src/DigitWriterSpec.cxx
15-
# src/RecoWorkflow.cxx
16-
# src/ClusterWriterWorkflow.cxx
17-
# src/ClustererSpec.cxx
18-
# src/ClusterWriterSpec.cxx
19-
# src/TrackerSpec.cxx
20-
# src/TrackWriterSpec.cxx
21-
# src/TrackReaderSpec.cxx
22-
# src/VertexReaderSpec.cxx
16+
src/TrackerSpec.cxx
17+
src/RecoWorkflow.cxx
2318
PUBLIC_LINK_LIBRARIES O2::Framework
19+
O2::GPUWorkflow
2420
O2::SimConfig
2521
O2::DataFormatsITSMFT
2622
O2::SimulationDataFormat
2723
O2::DPLUtils)
2824

29-
# o2_add_executable(reco-workflow
30-
# SOURCES src/trk-reco-workflow.cxx
31-
# COMPONENT_NAME alice3-trk
32-
# PUBLIC_LINK_LIBRARIES O2::TRKWorkflow)
25+
o2_add_executable(reco-workflow
26+
SOURCES src/trk-reco-workflow.cxx
27+
COMPONENT_NAME alice3-trk
28+
PUBLIC_LINK_LIBRARIES O2::TRKWorkflow
29+
O2::TRKSimulation
30+
O2::ITStracking)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2019-2020 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+
#ifndef O2_TRK_RECOWORKFLOW_H
13+
#define O2_TRK_RECOWORKFLOW_H
14+
15+
#include "Framework/WorkflowSpec.h"
16+
#include "GPUDataTypes.h"
17+
18+
namespace o2::trk
19+
{
20+
namespace reco_workflow
21+
{
22+
23+
o2::framework::WorkflowSpec getWorkflow(bool useMC,
24+
bool upstreamDigits = false,
25+
bool upstreamClusters = false,
26+
bool disableRootOutput = false,
27+
bool useGPUWF = false,
28+
o2::gpu::GPUDataTypes::DeviceType dType = o2::gpu::GPUDataTypes::DeviceType::CPU);
29+
}
30+
31+
} // namespace o2::trk
32+
33+
#endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2019-2020 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+
/// @file TrackerSpec.h
13+
14+
#ifndef O2_TRK_TRACKERDPL
15+
#define O2_TRK_TRACKERDPL
16+
17+
#include "DataFormatsITSMFT/TopologyDictionary.h"
18+
19+
#include "Framework/DataProcessorSpec.h"
20+
#include "Framework/Task.h"
21+
22+
#include "ITStracking/TrackingInterface.h"
23+
#include "GPUDataTypes.h"
24+
25+
#include "DetectorsBase/GRPGeomHelper.h"
26+
27+
#include "TStopwatch.h"
28+
29+
namespace o2::trk
30+
{
31+
class TrackerDPL : public framework::Task
32+
{
33+
public:
34+
TrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr,
35+
bool isMC,
36+
gpu::GPUDataTypes::DeviceType dType = gpu::GPUDataTypes::DeviceType::CPU);
37+
~TrackerDPL() override = default;
38+
void init(framework::InitContext& ic) final;
39+
void run(framework::ProcessingContext& pc) final;
40+
void endOfStream(framework::EndOfStreamContext& ec) final;
41+
// void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
42+
void stop() final;
43+
44+
private:
45+
void updateTimeDependentParams(framework::ProcessingContext& pc);
46+
// std::unique_ptr<o2::gpu::GPUReconstruction> mRecChain = nullptr;
47+
// std::unique_ptr<o2::gpu::GPUChainITS> mChainITS = nullptr;
48+
// std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
49+
// ITSTrackingInterface mITSTrackingInterface;
50+
TStopwatch mTimer;
51+
};
52+
53+
framework::DataProcessorSpec getTrackerSpec(bool useMC, gpu::GPUDataTypes::DeviceType dType = gpu::GPUDataTypes::DeviceType::CPU);
54+
55+
} // namespace o2::trk
56+
#endif /* O2_TRK_TRACKERDPL */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2019-2020 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+
#include "TRKWorkflow/RecoWorkflow.h"
13+
#include "TRKWorkflow/TrackerSpec.h"
14+
#include "Framework/CCDBParamSpec.h"
15+
16+
namespace o2::trk::reco_workflow
17+
{
18+
19+
framework::WorkflowSpec getWorkflow(bool useMC,
20+
bool upstreamDigits,
21+
bool upstreamClusters,
22+
bool disableRootOutput,
23+
bool useGPUWF,
24+
o2::gpu::GPUDataTypes::DeviceType dtype)
25+
{
26+
framework::WorkflowSpec specs;
27+
specs.emplace_back(o2::trk::getTrackerSpec(useMC, dtype));
28+
return specs;
29+
}
30+
31+
} // namespace o2::trk::reco_workflow
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Copyright 2019-2020 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+
#include <vector>
13+
14+
#include "Framework/ControlService.h"
15+
#include "Framework/ConfigParamRegistry.h"
16+
#include "Framework/CCDBParamSpec.h"
17+
#include "TRKWorkflow/TrackerSpec.h"
18+
19+
namespace o2
20+
{
21+
using namespace framework;
22+
namespace trk
23+
{
24+
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
25+
26+
TrackerDPL::TrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr,
27+
bool isMC,
28+
o2::gpu::GPUDataTypes::DeviceType dType)
29+
{
30+
// mITSTrackingInterface.setTrackingMode(trMode);
31+
}
32+
33+
void TrackerDPL::init(InitContext& ic)
34+
{
35+
// mTimer.Stop();
36+
// mTimer.Reset();
37+
// o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
38+
// mChainITS.reset(mRecChain->AddChain<o2::gpu::GPUChainITS>());
39+
// mITSTrackingInterface.setTraitsFromProvider(mChainITS->GetITSVertexerTraits(),
40+
// mChainITS->GetITSTrackerTraits(),
41+
// mChainITS->GetITSTimeframe());
42+
}
43+
44+
void TrackerDPL::stop()
45+
{
46+
LOGF(info, "CPU Reconstruction total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
47+
}
48+
49+
void TrackerDPL::run(ProcessingContext& pc)
50+
{
51+
auto cput = mTimer.CpuTime();
52+
auto realt = mTimer.RealTime();
53+
mTimer.Start(false);
54+
// mITSTrackingInterface.updateTimeDependentParams(pc);
55+
// mITSTrackingInterface.run(pc);
56+
mTimer.Stop();
57+
LOGP(info, "CPU Reconstruction time for this TF {} s (cpu), {} s (wall)", mTimer.CpuTime() - cput, mTimer.RealTime() - realt);
58+
}
59+
60+
// void TrackerDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
61+
// {
62+
// // mITSTrackingInterface.finaliseCCDB(matcher, obj);
63+
// }
64+
65+
void TrackerDPL::endOfStream(EndOfStreamContext& ec)
66+
{
67+
LOGF(info, "TRK CA-Tracker total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
68+
}
69+
70+
DataProcessorSpec getTrackerSpec(bool useMC, o2::gpu::GPUDataTypes::DeviceType dType)
71+
{
72+
std::vector<InputSpec> inputs;
73+
74+
// inputs.emplace_back("compClusters", "TRK", "COMPCLUSTERS", 0, Lifetime::Timeframe);
75+
// inputs.emplace_back("patterns", "TRK", "PATTERNS", 0, Lifetime::Timeframe);
76+
// inputs.emplace_back("ROframes", "TRK", "CLUSTERSROF", 0, Lifetime::Timeframe);
77+
78+
// inputs.emplace_back("itscldict", "TRK", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("ITS/Calib/ClusterDictionary"));
79+
// inputs.emplace_back("itsalppar", "TRK", "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/Config/AlpideParam"));
80+
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
81+
false, // GRPECS=true
82+
false, // GRPLHCIF
83+
false, // GRPMagField
84+
false, // askMatLUT
85+
o2::base::GRPGeomRequest::None, // geometry, but ignored until it will be put in the CCDB
86+
inputs,
87+
true);
88+
std::vector<OutputSpec> outputs;
89+
outputs.emplace_back("TRK", "TRACKS", 0, Lifetime::Timeframe);
90+
// outputs.emplace_back("TRK", "TRACKCLSID", 0, Lifetime::Timeframe);
91+
// outputs.emplace_back("TRK", "TRKTrackROF", 0, Lifetime::Timeframe);
92+
// outputs.emplace_back("TRK", "VERTICES", 0, Lifetime::Timeframe);
93+
// outputs.emplace_back("TRK", "VERTICESROF", 0, Lifetime::Timeframe);
94+
// outputs.emplace_back("TRK", "IRFRAMES", 0, Lifetime::Timeframe);
95+
96+
if (useMC) {
97+
// inputs.emplace_back("trkmclabels", "TRK", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
98+
// inputs.emplace_back("TRKMC2ROframes", "TRK", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe);
99+
// outputs.emplace_back("TRK", "VERTICESMCTR", 0, Lifetime::Timeframe);
100+
// outputs.emplace_back("TRK", "VERTICESMCPUR", 0, Lifetime::Timeframe);
101+
// outputs.emplace_back("TRK", "TRACKSMCTR", 0, Lifetime::Timeframe);
102+
// outputs.emplace_back("TRK", "TRKTrackMC2ROF", 0, Lifetime::Timeframe);
103+
}
104+
105+
return DataProcessorSpec{
106+
"trk-tracker",
107+
inputs,
108+
outputs,
109+
AlgorithmSpec{adaptFromTask<TrackerDPL>(ggRequest,
110+
useMC,
111+
dType)},
112+
Options{}};
113+
}
114+
115+
} // namespace trk
116+
} // namespace o2
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2019-2020 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+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
13+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
14+
// All rights not expressly granted are reserved.
15+
//
16+
// This software is distributed under the terms of the GNU General Public
17+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
18+
//
19+
// In applying this license CERN does not waive the privileges and immunities
20+
// granted to it by virtue of its status as an Intergovernmental Organization
21+
// or submit itself to any jurisdiction.
22+
23+
#include "TRKWorkflow/RecoWorkflow.h"
24+
#include "CommonUtils/ConfigurableParam.h"
25+
#include "ITStracking/TrackingConfigParam.h"
26+
#include "ITStracking/Configuration.h"
27+
28+
#include "Framework/CallbacksPolicy.h"
29+
#include "Framework/ConfigContext.h"
30+
#include "Framework/CompletionPolicyHelpers.h"
31+
32+
#include <vector>
33+
34+
using namespace o2::framework;
35+
36+
void customize(std::vector<CallbacksPolicy>& policies)
37+
{
38+
// o2::raw::HBFUtilsInitializer::addNewTimeSliceCallback(policies);
39+
}
40+
41+
void customize(std::vector<CompletionPolicy>& policies)
42+
{
43+
// ordered policies for the writers
44+
policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*(?:TRK|trk).*[W,w]riter.*"));
45+
}
46+
47+
void customize(std::vector<ConfigParamSpec>& workflowOptions)
48+
{
49+
// option allowing to set parameters
50+
std::vector<ConfigParamSpec> options{
51+
{"digits-from-upstream", VariantType::Bool, false, {"digits will be provided from upstream, skip digits reader"}},
52+
{"clusters-from-upstream", VariantType::Bool, false, {"clusters will be provided from upstream, skip clusterizer"}},
53+
{"disable-root-output", VariantType::Bool, false, {"do not write output root files"}},
54+
{"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}},
55+
{"disable-tracking", VariantType::Bool, false, {"disable tracking step"}},
56+
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}},
57+
{"use-gpu-workflow", VariantType::Bool, false, {"use GPU workflow (default: false)"}},
58+
{"gpu-device", VariantType::Int, 1, {"use gpu device: CPU=1,CUDA=2,HIP=3 (default: CPU)"}}};
59+
std::swap(workflowOptions, options);
60+
}
61+
62+
#include "Framework/runDataProcessing.h"
63+
#include "Framework/Logger.h"
64+
65+
WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
66+
{
67+
// Update the (declared) parameters if changed from the command line
68+
auto useMC = !configcontext.options().get<bool>("disable-mc");
69+
auto useGpuWF = configcontext.options().get<bool>("use-gpu-workflow");
70+
auto gpuDevice = static_cast<o2::gpu::GPUDataTypes::DeviceType>(configcontext.options().get<int>("gpu-device"));
71+
auto extDigits = configcontext.options().get<bool>("digits-from-upstream");
72+
auto extClusters = configcontext.options().get<bool>("clusters-from-upstream");
73+
auto disableRootOutput = configcontext.options().get<bool>("disable-root-output");
74+
o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
75+
76+
// write the configuration used for the reco workflow
77+
o2::conf::ConfigurableParam::writeINI("o2itsrecoflow_configuration.ini");
78+
79+
return o2::trk::reco_workflow::getWorkflow(useMC, extDigits, extClusters, disableRootOutput, useGpuWF, gpuDevice);
80+
}

0 commit comments

Comments
 (0)