diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/CMakeLists.txt b/Detectors/Upgrades/ALICE3/TRK/workflow/CMakeLists.txt index c9f4099017717..e86ed7982c85b 100644 --- a/Detectors/Upgrades/ALICE3/TRK/workflow/CMakeLists.txt +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/CMakeLists.txt @@ -10,23 +10,21 @@ # or submit itself to any jurisdiction. o2_add_library(TRKWorkflow + TARGETVARNAME targetName SOURCES src/DigitReaderSpec.cxx src/DigitWriterSpec.cxx - # src/RecoWorkflow.cxx - # src/ClusterWriterWorkflow.cxx - # src/ClustererSpec.cxx - # src/ClusterWriterSpec.cxx - # src/TrackerSpec.cxx - # src/TrackWriterSpec.cxx - # src/TrackReaderSpec.cxx - # src/VertexReaderSpec.cxx + src/TrackerSpec.cxx + src/RecoWorkflow.cxx PUBLIC_LINK_LIBRARIES O2::Framework + O2::GPUWorkflow O2::SimConfig O2::DataFormatsITSMFT O2::SimulationDataFormat O2::DPLUtils) -# o2_add_executable(reco-workflow -# SOURCES src/trk-reco-workflow.cxx -# COMPONENT_NAME alice3-trk -# PUBLIC_LINK_LIBRARIES O2::TRKWorkflow) \ No newline at end of file +o2_add_executable(reco-workflow + SOURCES src/trk-reco-workflow.cxx + COMPONENT_NAME alice3-trk + PUBLIC_LINK_LIBRARIES O2::TRKWorkflow + O2::TRKSimulation + O2::ITStracking) \ No newline at end of file diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/RecoWorkflow.h b/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/RecoWorkflow.h new file mode 100644 index 0000000000000..0c2489aa4b9c4 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/RecoWorkflow.h @@ -0,0 +1,33 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef O2_TRK_RECOWORKFLOW_H +#define O2_TRK_RECOWORKFLOW_H + +#include "Framework/WorkflowSpec.h" +#include "GPUDataTypes.h" + +namespace o2::trk +{ +namespace reco_workflow +{ + +o2::framework::WorkflowSpec getWorkflow(bool useMC, + bool upstreamDigits = false, + bool upstreamClusters = false, + bool disableRootOutput = false, + bool useGPUWF = false, + o2::gpu::GPUDataTypes::DeviceType dType = o2::gpu::GPUDataTypes::DeviceType::CPU); +} + +} // namespace o2::trk + +#endif diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/TrackerSpec.h b/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/TrackerSpec.h new file mode 100644 index 0000000000000..3c82a4fd7b89d --- /dev/null +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/include/TRKWorkflow/TrackerSpec.h @@ -0,0 +1,56 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// @file TrackerSpec.h + +#ifndef O2_TRK_TRACKERDPL +#define O2_TRK_TRACKERDPL + +#include "DataFormatsITSMFT/TopologyDictionary.h" + +#include "Framework/DataProcessorSpec.h" +#include "Framework/Task.h" + +#include "ITStracking/TrackingInterface.h" +#include "GPUDataTypes.h" + +#include "DetectorsBase/GRPGeomHelper.h" + +#include "TStopwatch.h" + +namespace o2::trk +{ +class TrackerDPL : public framework::Task +{ + public: + TrackerDPL(std::shared_ptr gr, + bool isMC, + gpu::GPUDataTypes::DeviceType dType = gpu::GPUDataTypes::DeviceType::CPU); + ~TrackerDPL() override = default; + void init(framework::InitContext& ic) final; + void run(framework::ProcessingContext& pc) final; + void endOfStream(framework::EndOfStreamContext& ec) final; + // void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final; + void stop() final; + + private: + void updateTimeDependentParams(framework::ProcessingContext& pc); + // std::unique_ptr mRecChain = nullptr; + // std::unique_ptr mChainITS = nullptr; + // std::shared_ptr mGGCCDBRequest; + // ITSTrackingInterface mITSTrackingInterface; + TStopwatch mTimer; +}; + +framework::DataProcessorSpec getTrackerSpec(bool useMC, gpu::GPUDataTypes::DeviceType dType = gpu::GPUDataTypes::DeviceType::CPU); + +} // namespace o2::trk +#endif /* O2_TRK_TRACKERDPL */ \ No newline at end of file diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/src/RecoWorkflow.cxx b/Detectors/Upgrades/ALICE3/TRK/workflow/src/RecoWorkflow.cxx new file mode 100644 index 0000000000000..3b2b44729b259 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/src/RecoWorkflow.cxx @@ -0,0 +1,31 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "TRKWorkflow/RecoWorkflow.h" +#include "TRKWorkflow/TrackerSpec.h" +#include "Framework/CCDBParamSpec.h" + +namespace o2::trk::reco_workflow +{ + +framework::WorkflowSpec getWorkflow(bool useMC, + bool upstreamDigits, + bool upstreamClusters, + bool disableRootOutput, + bool useGPUWF, + o2::gpu::GPUDataTypes::DeviceType dtype) +{ + framework::WorkflowSpec specs; + specs.emplace_back(o2::trk::getTrackerSpec(useMC, dtype)); + return specs; +} + +} // namespace o2::trk::reco_workflow \ No newline at end of file diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/src/TrackerSpec.cxx b/Detectors/Upgrades/ALICE3/TRK/workflow/src/TrackerSpec.cxx new file mode 100644 index 0000000000000..4057bab3b948f --- /dev/null +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/src/TrackerSpec.cxx @@ -0,0 +1,116 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include + +#include "Framework/ControlService.h" +#include "Framework/ConfigParamRegistry.h" +#include "Framework/CCDBParamSpec.h" +#include "TRKWorkflow/TrackerSpec.h" + +namespace o2 +{ +using namespace framework; +namespace trk +{ +using Vertex = o2::dataformats::Vertex>; + +TrackerDPL::TrackerDPL(std::shared_ptr gr, + bool isMC, + o2::gpu::GPUDataTypes::DeviceType dType) +{ + // mITSTrackingInterface.setTrackingMode(trMode); +} + +void TrackerDPL::init(InitContext& ic) +{ + // mTimer.Stop(); + // mTimer.Reset(); + // o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest); + // mChainITS.reset(mRecChain->AddChain()); + // mITSTrackingInterface.setTraitsFromProvider(mChainITS->GetITSVertexerTraits(), + // mChainITS->GetITSTrackerTraits(), + // mChainITS->GetITSTimeframe()); +} + +void TrackerDPL::stop() +{ + LOGF(info, "CPU Reconstruction total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); +} + +void TrackerDPL::run(ProcessingContext& pc) +{ + auto cput = mTimer.CpuTime(); + auto realt = mTimer.RealTime(); + mTimer.Start(false); + // mITSTrackingInterface.updateTimeDependentParams(pc); + // mITSTrackingInterface.run(pc); + mTimer.Stop(); + LOGP(info, "CPU Reconstruction time for this TF {} s (cpu), {} s (wall)", mTimer.CpuTime() - cput, mTimer.RealTime() - realt); +} + +// void TrackerDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) +// { +// // mITSTrackingInterface.finaliseCCDB(matcher, obj); +// } + +void TrackerDPL::endOfStream(EndOfStreamContext& ec) +{ + LOGF(info, "TRK CA-Tracker total timing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); +} + +DataProcessorSpec getTrackerSpec(bool useMC, o2::gpu::GPUDataTypes::DeviceType dType) +{ + std::vector inputs; + + // inputs.emplace_back("compClusters", "TRK", "COMPCLUSTERS", 0, Lifetime::Timeframe); + // inputs.emplace_back("patterns", "TRK", "PATTERNS", 0, Lifetime::Timeframe); + // inputs.emplace_back("ROframes", "TRK", "CLUSTERSROF", 0, Lifetime::Timeframe); + + // inputs.emplace_back("itscldict", "TRK", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("ITS/Calib/ClusterDictionary")); + // inputs.emplace_back("itsalppar", "TRK", "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec("ITS/Config/AlpideParam")); + auto ggRequest = std::make_shared(false, // orbitResetTime + false, // GRPECS=true + false, // GRPLHCIF + false, // GRPMagField + false, // askMatLUT + o2::base::GRPGeomRequest::None, // geometry, but ignored until it will be put in the CCDB + inputs, + true); + std::vector outputs; + outputs.emplace_back("TRK", "TRACKS", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "TRACKCLSID", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "TRKTrackROF", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "VERTICES", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "VERTICESROF", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "IRFRAMES", 0, Lifetime::Timeframe); + + if (useMC) { + // inputs.emplace_back("trkmclabels", "TRK", "CLUSTERSMCTR", 0, Lifetime::Timeframe); + // inputs.emplace_back("TRKMC2ROframes", "TRK", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "VERTICESMCTR", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "VERTICESMCPUR", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "TRACKSMCTR", 0, Lifetime::Timeframe); + // outputs.emplace_back("TRK", "TRKTrackMC2ROF", 0, Lifetime::Timeframe); + } + + return DataProcessorSpec{ + "trk-tracker", + inputs, + outputs, + AlgorithmSpec{adaptFromTask(ggRequest, + useMC, + dType)}, + Options{}}; +} + +} // namespace trk +} // namespace o2 diff --git a/Detectors/Upgrades/ALICE3/TRK/workflow/src/trk-reco-workflow.cxx b/Detectors/Upgrades/ALICE3/TRK/workflow/src/trk-reco-workflow.cxx new file mode 100644 index 0000000000000..0f75d42710400 --- /dev/null +++ b/Detectors/Upgrades/ALICE3/TRK/workflow/src/trk-reco-workflow.cxx @@ -0,0 +1,80 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include "TRKWorkflow/RecoWorkflow.h" +#include "CommonUtils/ConfigurableParam.h" +#include "ITStracking/TrackingConfigParam.h" +#include "ITStracking/Configuration.h" + +#include "Framework/CallbacksPolicy.h" +#include "Framework/ConfigContext.h" +#include "Framework/CompletionPolicyHelpers.h" + +#include + +using namespace o2::framework; + +void customize(std::vector& policies) +{ + // o2::raw::HBFUtilsInitializer::addNewTimeSliceCallback(policies); +} + +void customize(std::vector& policies) +{ + // ordered policies for the writers + policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*(?:TRK|trk).*[W,w]riter.*")); +} + +void customize(std::vector& workflowOptions) +{ + // option allowing to set parameters + std::vector options{ + {"digits-from-upstream", VariantType::Bool, false, {"digits will be provided from upstream, skip digits reader"}}, + {"clusters-from-upstream", VariantType::Bool, false, {"clusters will be provided from upstream, skip clusterizer"}}, + {"disable-root-output", VariantType::Bool, false, {"do not write output root files"}}, + {"disable-mc", VariantType::Bool, false, {"disable MC propagation even if available"}}, + {"disable-tracking", VariantType::Bool, false, {"disable tracking step"}}, + {"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}, + {"use-gpu-workflow", VariantType::Bool, false, {"use GPU workflow (default: false)"}}, + {"gpu-device", VariantType::Int, 1, {"use gpu device: CPU=1,CUDA=2,HIP=3 (default: CPU)"}}}; + std::swap(workflowOptions, options); +} + +#include "Framework/runDataProcessing.h" +#include "Framework/Logger.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) +{ + // Update the (declared) parameters if changed from the command line + auto useMC = !configcontext.options().get("disable-mc"); + auto useGpuWF = configcontext.options().get("use-gpu-workflow"); + auto gpuDevice = static_cast(configcontext.options().get("gpu-device")); + auto extDigits = configcontext.options().get("digits-from-upstream"); + auto extClusters = configcontext.options().get("clusters-from-upstream"); + auto disableRootOutput = configcontext.options().get("disable-root-output"); + o2::conf::ConfigurableParam::updateFromString(configcontext.options().get("configKeyValues")); + + // write the configuration used for the reco workflow + o2::conf::ConfigurableParam::writeINI("o2itsrecoflow_configuration.ini"); + + return o2::trk::reco_workflow::getWorkflow(useMC, extDigits, extClusters, disableRootOutput, useGpuWF, gpuDevice); +}