diff --git a/Detectors/Upgrades/ITS3/workflow/CMakeLists.txt b/Detectors/Upgrades/ITS3/workflow/CMakeLists.txt index 649e4d737d42c..bcb3cf46375e9 100644 --- a/Detectors/Upgrades/ITS3/workflow/CMakeLists.txt +++ b/Detectors/Upgrades/ITS3/workflow/CMakeLists.txt @@ -15,13 +15,8 @@ o2_add_library(ITS3Workflow 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 PUBLIC_LINK_LIBRARIES O2::Framework O2::SimConfig O2::DataFormatsITSMFT @@ -35,27 +30,7 @@ o2_add_library(ITS3Workflow O2::GPUTracking O2::ITSBase) -# o2_add_executable(digit-writer-workflow -# SOURCES src/digit-writer-workflow.cxx -# COMPONENT_NAME its3 -# PUBLIC_LINK_LIBRARIES O2::ITS3Workflow) - -# o2_add_executable(digit-reader-workflow -# SOURCES src/digit-reader-workflow.cxx -# COMPONENT_NAME its3 -# PUBLIC_LINK_LIBRARIES O2::ITS3Workflow) - o2_add_executable(reco-workflow SOURCES src/its3-reco-workflow.cxx COMPONENT_NAME its3 PUBLIC_LINK_LIBRARIES O2::ITS3Workflow) - -# o2_add_executable(cluster-writer-workflow -# SOURCES src/its-cluster-writer-workflow.cxx -# COMPONENT_NAME its -# PUBLIC_LINK_LIBRARIES O2::ITSWorkflow) - -# o2_add_executable(cluster-reader-workflow -# SOURCES src/its-cluster-reader-workflow.cxx -# COMPONENT_NAME its -# PUBLIC_LINK_LIBRARIES O2::ITSWorkflow) diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterReaderSpec.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterReaderSpec.h deleted file mode 100644 index c411c2accace1..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterReaderSpec.h +++ /dev/null @@ -1,76 +0,0 @@ -// 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 ClusterReaderSpec.h - -#ifndef O2_ITSMFT_CLUSTERREADER -#define O2_ITSMFT_CLUSTERREADER - -#include "TFile.h" -#include "TTree.h" - -#include "Framework/DataProcessorSpec.h" -#include "Framework/Task.h" -#include "Headers/DataHeader.h" -#include "DataFormatsITSMFT/CompCluster.h" -#include "SimulationDataFormat/MCCompLabel.h" -#include "SimulationDataFormat/MCTruthContainer.h" -#include "DataFormatsITSMFT/ROFRecord.h" - -using namespace o2::framework; - -namespace o2::its3 -{ - -class ClusterReader : public Task -{ - public: - ClusterReader(bool useMC, bool usePatterns = true); - - void init(InitContext& ic) final; - void run(ProcessingContext& pc) final; - - protected: - void connectTree(const std::string& filename); - - std::vector mClusROFRec, *mClusROFRecPtr = &mClusROFRec; - std::vector mClusterCompArray, *mClusterCompArrayPtr = &mClusterCompArray; - std::vector mPatternsArray, *mPatternsArrayPtr = &mPatternsArray; - o2::dataformats::MCTruthContainer mClusterMCTruth, *mClusterMCTruthPtr = &mClusterMCTruth; - std::vector mClusMC2ROFs, *mClusMC2ROFsPtr = &mClusMC2ROFs; - - o2::header::DataOrigin mOrigin = o2::header::gDataOriginITS; - - std::unique_ptr mFile; - std::unique_ptr mTree; - - bool mUseMC = true; // use MC truth - bool mUsePatterns = true; // send patterns - - std::string mDetName = "ITS"; // pretending to be ITS - std::string mDetNameLC = "its"; - std::string mDetNameReal = "IT3"; - std::string mFileName = ""; - std::string mClusTreeName = "o2sim"; - std::string mClusROFBranchName = "ClustersROF"; - std::string mClusterPattBranchName = "ClusterPatt"; - std::string mClusterCompBranchName = "ClusterComp"; - std::string mClustMCTruthBranchName = "ClusterMCTruth"; - std::string mClustMC2ROFBranchName = "ClustersMC2ROF"; -}; - -/// create a processor spec -/// read ITS/MFT cluster data from a root file -framework::DataProcessorSpec getITS3ClusterReaderSpec(bool useMC = true, bool usePatterns = true); - -} // namespace o2::its3 - -#endif /* O2_ITSMFT_CLUSTERREADER */ diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterSpec.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterSpec.h deleted file mode 100644 index 49106871d89d5..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterSpec.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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 ClusterWriterSpec.h - -#ifndef O2_ITS_CLUSTERWRITER -#define O2_ITS_CLUSTERWRITER - -#include "Framework/DataProcessorSpec.h" - -namespace o2 -{ -namespace its3 -{ - -/// create a processor spec -/// write ITS clusters to ROOT file -framework::DataProcessorSpec getClusterWriterSpec(bool useMC); - -} // namespace its3 -} // namespace o2 - -#endif /* O2_ITS_CLUSTERWRITER */ diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterWorkflow.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterWorkflow.h deleted file mode 100644 index 05268e7ca3a1e..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/ClusterWriterWorkflow.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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_ITS_CLUSTER_WRITER_WORKFLOW_H -#define O2_ITS_CLUSTER_WRITER_WORKFLOW_H - -/// @file ClusterWriterWorkflow.h - -#include "Framework/WorkflowSpec.h" - -namespace o2 -{ -namespace its3 -{ - -namespace cluster_writer_workflow -{ -framework::WorkflowSpec getWorkflow(bool useMC); -} - -} // namespace its3 -} // namespace o2 -#endif diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackReaderSpec.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackReaderSpec.h deleted file mode 100644 index 1686b7c275941..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackReaderSpec.h +++ /dev/null @@ -1,79 +0,0 @@ -// 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 TrackReaderSpec.h - -#ifndef O2_ITS3_TRACKREADER -#define O2_ITS3_TRACKREADER - -#include "TFile.h" -#include "TTree.h" - -#include "Framework/DataProcessorSpec.h" -#include "Framework/Task.h" -#include "Headers/DataHeader.h" -#include "DataFormatsITS/TrackITS.h" -#include "SimulationDataFormat/MCCompLabel.h" -#include "SimulationDataFormat/MCTruthContainer.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "ReconstructionDataFormats/Vertex.h" - -namespace o2 -{ -namespace its3 -{ - -class TrackReader : public o2::framework::Task -{ - using Vertex = o2::dataformats::Vertex>; - - public: - TrackReader(bool useMC = true); - ~TrackReader() override = default; - void init(o2::framework::InitContext& ic) final; - void run(o2::framework::ProcessingContext& pc) final; - - protected: - void connectTree(const std::string& filename); - - std::vector mROFRec, *mROFRecInp = &mROFRec; - std::vector mVerticesROFRec, *mVerticesROFRecInp = &mVerticesROFRec; - std::vector mTracks, *mTracksInp = &mTracks; - std::vector mVertices, *mVerticesInp = &mVertices; - std::vector mClusInd, *mClusIndInp = &mClusInd; - std::vector mMCTruth, *mMCTruthInp = &mMCTruth; - std::vector mMCVertTruth, *mMCVTruthInp = &mMCTruth; - - o2::header::DataOrigin mOrigin = o2::header::gDataOriginITS; - - bool mUseMC = true; // use MC truth - - std::unique_ptr mFile; - std::unique_ptr mTree; - std::string mInputFileName = ""; - std::string mTrackTreeName = "o2sim"; - std::string mROFBranchName = "ITSTracksROF"; - std::string mTrackBranchName = "ITSTrack"; - std::string mClusIdxBranchName = "ITSTrackClusIdx"; - std::string mVertexBranchName = "Vertices"; - std::string mVertexROFBranchName = "VerticesROF"; - std::string mTrackMCTruthBranchName = "ITSTrackMCTruth"; - std::string mTrackMCVertTruthBranchName = "ITSVertexMCTruth"; -}; - -/// create a processor spec -/// read ITS track data from a root file -framework::DataProcessorSpec getITS3TrackReaderSpec(bool useMC = true); - -} // namespace its3 -} // namespace o2 - -#endif /* O2_ITS3_TRACKREADER */ diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackWriterSpec.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackWriterSpec.h deleted file mode 100644 index 32f704fd61b45..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/TrackWriterSpec.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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 TrackWriterSpec.h - -#ifndef O2_ITS3_TRACKWRITER -#define O2_ITS3_TRACKWRITER - -#include "Framework/DataProcessorSpec.h" - -namespace o2 -{ -namespace its3 -{ - -/// create a processor spec -/// write ITS tracks to ROOT file -o2::framework::DataProcessorSpec getTrackWriterSpec(bool useMC); - -} // namespace its3 -} // namespace o2 - -#endif /* O2_ITS_TRACKWRITER */ diff --git a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/VertexReaderSpec.h b/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/VertexReaderSpec.h deleted file mode 100644 index 6c723d07982f2..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/include/ITS3Workflow/VertexReaderSpec.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 VertexReaderSpec.h - -#ifndef O2_ITS3_VERTEXREADER -#define O2_ITS3_VERTEXREADER - -#include "TFile.h" -#include "TTree.h" - -#include "Framework/DataProcessorSpec.h" -#include "Framework/Task.h" -#include "ReconstructionDataFormats/Vertex.h" -#include "DataFormatsITSMFT/ROFRecord.h" - -namespace o2 -{ -namespace its3 -{ -// read ITS vertices from the output tree of ITS tracking - -class VertexReader : public o2::framework::Task -{ - using Vertex = o2::dataformats::Vertex>; - - public: - VertexReader() = default; - ~VertexReader() override = default; - void init(o2::framework::InitContext& ic) final; - void run(o2::framework::ProcessingContext& pc) final; - - protected: - void connectTree(const std::string& filename); - void accumulate(); - - std::vector mVerticesROFRec, *mVerticesROFRecPtr = &mVerticesROFRec; - std::vector mVertices, *mVerticesPtr = &mVertices; - - o2::header::DataOrigin mOrigin = o2::header::gDataOriginITS; - - std::unique_ptr mFile; - std::unique_ptr mTree; - std::string mFileName = ""; - std::string mVertexTreeName = "o2sim"; - std::string mVertexBranchName = "Vertices"; - std::string mVertexROFBranchName = "VerticesROF"; -}; - -/// create a processor spec -/// read ITS vertex data from a root file -o2::framework::DataProcessorSpec getITS3VertexReaderSpec(); - -} // namespace its3 -} // namespace o2 - -#endif /* O2_ITS3_VERTEXREADER */ diff --git a/Detectors/Upgrades/ITS3/workflow/src/ClusterReaderSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/ClusterReaderSpec.cxx deleted file mode 100644 index 5030b1fcdd30a..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/ClusterReaderSpec.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// 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 ClusterReaderSpec.cxx - -#include - -#include "TTree.h" - -#include "Framework/ControlService.h" -#include "Framework/ConfigParamRegistry.h" -#include "Framework/Logger.h" -#include "ITS3Workflow/ClusterReaderSpec.h" -#include -#include "CommonUtils/NameConf.h" - -using namespace o2::framework; -using namespace o2::itsmft; - -namespace o2 -{ -namespace its3 -{ - -ClusterReader::ClusterReader(bool useMC, bool usePatterns) -{ - mUseMC = useMC; - mUsePatterns = usePatterns; -} - -void ClusterReader::init(InitContext& ic) -{ - mFileName = o2::utils::concat_string(o2::base::NameConf::rectifyDirectory(ic.options().get("input-dir")), - ic.options().get((mDetNameLC + "-cluster-infile").c_str())); - connectTree(mFileName); -} - -void ClusterReader::run(ProcessingContext& pc) -{ - auto ent = mTree->GetReadEntry() + 1; - assert(ent < mTree->GetEntries()); // this should not happen - mTree->GetEntry(ent); - LOG(info) << mDetNameReal << "ClusterReader pushes " << mClusROFRec.size() << " ROFRecords," - << mClusterCompArray.size() << " compact clusters at entry " << ent; - - // This is a very ugly way of providing DataDescription, which anyway does not need to contain detector name. - // To be fixed once the names-definition class is ready - pc.outputs().snapshot(Output{mOrigin, "CLUSTERSROF", 0}, mClusROFRec); - pc.outputs().snapshot(Output{mOrigin, "COMPCLUSTERS", 0}, mClusterCompArray); - if (mUsePatterns) { - pc.outputs().snapshot(Output{mOrigin, "PATTERNS", 0}, mPatternsArray); - } - if (mUseMC) { - pc.outputs().snapshot(Output{mOrigin, "CLUSTERSMCTR", 0}, mClusterMCTruth); - pc.outputs().snapshot(Output{mOrigin, "CLUSTERSMC2ROF", 0}, mClusMC2ROFs); - } - - if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) { - pc.services().get().endOfStream(); - pc.services().get().readyToQuit(QuitRequest::Me); - } -} - -void ClusterReader::connectTree(const std::string& filename) -{ - mTree.reset(nullptr); // in case it was already loaded - mFile.reset(TFile::Open(filename.c_str())); - assert(mFile && !mFile->IsZombie()); - mTree.reset((TTree*)mFile->Get(mClusTreeName.c_str())); - assert(mTree); - - mTree->SetBranchAddress((mDetName + mClusROFBranchName).c_str(), &mClusROFRecPtr); - mTree->SetBranchAddress((mDetName + mClusterCompBranchName).c_str(), &mClusterCompArrayPtr); - if (mUsePatterns) { - mTree->SetBranchAddress((mDetName + mClusterPattBranchName).c_str(), &mPatternsArrayPtr); - } - if (mUseMC) { - if (mTree->GetBranch((mDetName + mClustMCTruthBranchName).c_str()) && - mTree->GetBranch((mDetName + mClustMC2ROFBranchName).c_str())) { - mTree->SetBranchAddress((mDetName + mClustMCTruthBranchName).c_str(), &mClusterMCTruthPtr); - mTree->SetBranchAddress((mDetName + mClustMC2ROFBranchName).c_str(), &mClusMC2ROFsPtr); - } else { - LOG(info) << "MC-truth is missing"; - mUseMC = false; - } - } - LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries"; -} - -DataProcessorSpec getITS3ClusterReaderSpec(bool useMC, bool usePatterns) -{ - std::vector outputSpec; - outputSpec.emplace_back("IT3", "CLUSTERSROF", 0, Lifetime::Timeframe); - outputSpec.emplace_back("IT3", "COMPCLUSTERS", 0, Lifetime::Timeframe); - if (usePatterns) { - outputSpec.emplace_back("IT3", "PATTERNS", 0, Lifetime::Timeframe); - } - if (useMC) { - outputSpec.emplace_back("IT3", "CLUSTERSMCTR", 0, Lifetime::Timeframe); - outputSpec.emplace_back("IT3", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe); - } - - return DataProcessorSpec{ - "its3-cluster-reader", - Inputs{}, - outputSpec, - AlgorithmSpec{adaptFromTask(useMC, usePatterns)}, - Options{ - {"its-cluster-infile", VariantType::String, "o2clus_its.root", {"Name of the input cluster file"}}, - {"input-dir", VariantType::String, "none", {"Input directory"}}}}; -} - -} // namespace its3 -} // namespace o2 diff --git a/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterSpec.cxx deleted file mode 100644 index 0231560b3ac25..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterSpec.cxx +++ /dev/null @@ -1,72 +0,0 @@ -// 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 ClusterWriterSpec.cxx - -#include - -#include "ITS3Workflow/ClusterWriterSpec.h" -#include "DPLUtils/MakeRootTreeWriterSpec.h" -#include "DataFormatsITSMFT/CompCluster.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "SimulationDataFormat/MCCompLabel.h" -#include "SimulationDataFormat/MCTruthContainer.h" - -using namespace o2::framework; - -namespace o2 -{ -namespace its3 -{ - -template -using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition; -using CompClusType = std::vector; -using PatternsType = std::vector; -using ROFrameRType = std::vector; -using LabelsType = o2::dataformats::MCTruthContainer; -using ROFRecLblT = std::vector; -using namespace o2::header; - -DataProcessorSpec getClusterWriterSpec(bool useMC) -{ - // Spectators for logging - // this is only to restore the original behavior - auto compClustersSize = std::make_shared(0); - auto compClustersSizeGetter = [compClustersSize](CompClusType const& compClusters) { - *compClustersSize = compClusters.size(); - }; - auto logger = [compClustersSize](std::vector const& rofs) { - LOG(info) << "ITS3ClusterWriter pulled " << *compClustersSize << " clusters, in " << rofs.size() << " RO frames"; - }; - return MakeRootTreeWriterSpec("its3-cluster-writer", - "o2clus_its.root", - MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with ITS clusters"}, - BranchDefinition{InputSpec{"compclus", "ITS", "COMPCLUSTERS", 0}, - "ITSClusterComp", - compClustersSizeGetter}, - BranchDefinition{InputSpec{"patterns", "ITS", "PATTERNS", 0}, - "ITSClusterPatt"}, - BranchDefinition{InputSpec{"ROframes", "ITS", "CLUSTERSROF", 0}, - "ITSClustersROF", - logger}, - BranchDefinition{InputSpec{"labels", "ITS", "CLUSTERSMCTR", 0}, - "ITSClusterMCTruth", - (useMC ? 1 : 0), // one branch if mc labels enabled - ""}, - BranchDefinition{InputSpec{"MC2ROframes", "ITS", "CLUSTERSMC2ROF", 0}, - "ITSClustersMC2ROF", - (useMC ? 1 : 0), // one branch if mc labels enabled - ""})(); -} - -} // namespace its3 -} // namespace o2 diff --git a/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterWorkflow.cxx b/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterWorkflow.cxx deleted file mode 100644 index ae79b7797d57d..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/ClusterWriterWorkflow.cxx +++ /dev/null @@ -1,36 +0,0 @@ -// 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 ClusterWriterWorkflow.cxx - -#include "ITS3Workflow/ClusterWriterWorkflow.h" -#include "ITS3Workflow/ClusterWriterSpec.h" - -namespace o2 -{ -namespace its3 -{ - -namespace cluster_writer_workflow -{ - -framework::WorkflowSpec getWorkflow(bool useMC) -{ - framework::WorkflowSpec specs; - - specs.emplace_back(getClusterWriterSpec(useMC)); - - return specs; -} - -} // namespace cluster_writer_workflow -} // namespace its3 -} // namespace o2 diff --git a/Detectors/Upgrades/ITS3/workflow/src/RecoWorkflow.cxx b/Detectors/Upgrades/ITS3/workflow/src/RecoWorkflow.cxx index 721ef36335631..21ae5b4a72345 100644 --- a/Detectors/Upgrades/ITS3/workflow/src/RecoWorkflow.cxx +++ b/Detectors/Upgrades/ITS3/workflow/src/RecoWorkflow.cxx @@ -11,9 +11,9 @@ #include "ITS3Workflow/RecoWorkflow.h" #include "ITS3Workflow/ClustererSpec.h" -#include "ITS3Workflow/ClusterWriterSpec.h" #include "ITS3Workflow/TrackerSpec.h" -#include "ITS3Workflow/TrackWriterSpec.h" +#include "ITSWorkflow/ClusterWriterSpec.h" +#include "ITSWorkflow/TrackWriterSpec.h" #include "ITS3Workflow/DigitReaderSpec.h" #include "Framework/Logger.h" @@ -34,14 +34,14 @@ framework::WorkflowSpec getWorkflow(bool useMC, const std::string& trmode, o2::g } if (!disableRootOutput) { - specs.emplace_back(o2::its3::getClusterWriterSpec(useMC)); + specs.emplace_back(o2::its::getClusterWriterSpec(useMC)); } if (trmode != "off") { specs.emplace_back(o2::its3::getTrackerSpec(useMC, useGeom, useTrig, trmode, overrideBeamPosition, dtype)); if (!disableRootOutput) { - specs.emplace_back(o2::its3::getTrackWriterSpec(useMC)); + specs.emplace_back(o2::its::getTrackWriterSpec(useMC)); } } diff --git a/Detectors/Upgrades/ITS3/workflow/src/TrackReaderSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/TrackReaderSpec.cxx deleted file mode 100644 index 409fa69e7815b..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/TrackReaderSpec.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// 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 TrackReaderSpec.cxx - -#include -#include -#include "Framework/ControlService.h" -#include "Framework/ConfigParamRegistry.h" -#include "ITS3Workflow/TrackReaderSpec.h" -#include "CommonUtils/NameConf.h" - -using namespace o2::framework; -using namespace o2::its3; - -namespace o2 -{ -namespace its3 -{ - -TrackReader::TrackReader(bool useMC) -{ - mUseMC = useMC; -} - -void TrackReader::init(InitContext& ic) -{ - mInputFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get("input-dir")), - ic.options().get("its3-tracks-infile")); - connectTree(mInputFileName); -} - -void TrackReader::run(ProcessingContext& pc) -{ - auto ent = mTree->GetReadEntry() + 1; - assert(ent < mTree->GetEntries()); // this should not happen - mTree->GetEntry(ent); - LOG(info) << "Pushing " << mTracks.size() << " track in " << mROFRec.size() << " ROFs at entry " << ent; - pc.outputs().snapshot(Output{mOrigin, "ITSTrackROF", 0}, mROFRec); - pc.outputs().snapshot(Output{mOrigin, "TRACKS", 0}, mTracks); - pc.outputs().snapshot(Output{mOrigin, "TRACKCLSID", 0}, mClusInd); - pc.outputs().snapshot(Output{"ITS", "VERTICES", 0}, mVertices); - pc.outputs().snapshot(Output{"ITS", "VERTICESROF", 0}, mVerticesROFRec); - if (mUseMC) { - pc.outputs().snapshot(Output{mOrigin, "TRACKSMCTR", 0}, mMCTruth); - pc.outputs().snapshot(Output{mOrigin, "VERTICESMCTR", 0}, mMCVertTruth); - } - - if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) { - pc.services().get().endOfStream(); - pc.services().get().readyToQuit(QuitRequest::Me); - } -} - -void TrackReader::connectTree(const std::string& filename) -{ - mTree.reset(nullptr); // in case it was already loaded - mFile.reset(TFile::Open(filename.c_str())); - assert(mFile && !mFile->IsZombie()); - mTree.reset((TTree*)mFile->Get(mTrackTreeName.c_str())); - assert(mTree); - assert(mTree->GetBranch(mROFBranchName.c_str())); - - mTree->SetBranchAddress(mROFBranchName.c_str(), &mROFRecInp); - mTree->SetBranchAddress(mTrackBranchName.c_str(), &mTracksInp); - mTree->SetBranchAddress(mClusIdxBranchName.c_str(), &mClusIndInp); - if (!mTree->GetBranch(mVertexBranchName.c_str())) { - LOG(warning) << "No " << mVertexBranchName << " branch in " << mTrackTreeName << " -> vertices will be empty"; - } else { - mTree->SetBranchAddress(mVertexBranchName.c_str(), &mVerticesInp); - } - if (!mTree->GetBranch(mVertexROFBranchName.c_str())) { - LOG(warning) << "No " << mVertexROFBranchName << " branch in " << mTrackTreeName - << " -> vertices ROFrecords will be empty"; - } else { - mTree->SetBranchAddress(mVertexROFBranchName.c_str(), &mVerticesROFRecInp); - } - if (mUseMC) { - if (mTree->GetBranch(mTrackMCTruthBranchName.c_str())) { - mTree->SetBranchAddress(mTrackMCTruthBranchName.c_str(), &mMCTruthInp); - } else { - LOG(warning) << "MC-truth is missing, message will be empty"; - } - } - LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries"; -} - -DataProcessorSpec getITS3TrackReaderSpec(bool useMC) -{ - std::vector outputSpec; - outputSpec.emplace_back("ITS", "ITSTrackROF", 0, Lifetime::Timeframe); - outputSpec.emplace_back("ITS", "TRACKS", 0, Lifetime::Timeframe); - outputSpec.emplace_back("ITS", "TRACKCLSID", 0, Lifetime::Timeframe); - outputSpec.emplace_back("ITS", "VERTICES", 0, Lifetime::Timeframe); - outputSpec.emplace_back("ITS", "VERTICESROF", 0, Lifetime::Timeframe); - if (useMC) { - outputSpec.emplace_back("ITS", "TRACKSMCTR", 0, Lifetime::Timeframe); - outputSpec.emplace_back("ITS", "VERTICESMCTR", 0, Lifetime::Timeframe); - } - - return DataProcessorSpec{ - "its3-track-reader", - Inputs{}, - outputSpec, - AlgorithmSpec{adaptFromTask(useMC)}, - Options{ - {"its-tracks-infile", VariantType::String, "o2trac_its.root", {"Name of the input ITS3 track file"}}, - {"input-dir", VariantType::String, "none", {"Input directory"}}}}; -} - -} // namespace its3 -} // namespace o2 diff --git a/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx deleted file mode 100644 index 856c806e74247..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// 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 TrackWriterSpec.cxx - -#include - -#include "ITS3Workflow/TrackWriterSpec.h" -#include "DPLUtils/MakeRootTreeWriterSpec.h" -#include "DataFormatsITS/TrackITS.h" -#include "DataFormatsITSMFT/ROFRecord.h" -#include "SimulationDataFormat/MCCompLabel.h" -#include "SimulationDataFormat/MCTruthContainer.h" -#include "ReconstructionDataFormats/Vertex.h" - -using namespace o2::framework; - -namespace o2 -{ -namespace its3 -{ -using Vertex = o2::dataformats::Vertex>; - -template -using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition; -using LabelsType = std::vector; -using ROFRecLblT = std::vector; -using namespace o2::header; - -DataProcessorSpec getTrackWriterSpec(bool useMC) -{ - // Spectators for logging - // this is only to restore the original behavior - auto tracksSize = std::make_shared(0); - auto tracksSizeGetter = [tracksSize](std::vector const& tracks) { - *tracksSize = tracks.size(); - }; - auto logger = [tracksSize](std::vector const& rofs) { - LOG(info) << "ITS3TrackWriter pulled " << *tracksSize << " tracks, in " << rofs.size() << " RO frames"; - }; - // NOTE: We name the branches as ITS and not IT3 to ensure matching works. - return MakeRootTreeWriterSpec("its3-track-writer", - "o2trac_its.root", - MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with ITS3 tracks"}, - BranchDefinition>{InputSpec{"tracks", "ITS", "TRACKS", 0}, - "ITSTrack", - tracksSizeGetter}, - BranchDefinition>{InputSpec{"trackClIdx", "ITS", "TRACKCLSID", 0}, - "ITSTrackClusIdx"}, - BranchDefinition>{InputSpec{"vertices", "ITS", "VERTICES", 0}, - "Vertices"}, - BranchDefinition>{InputSpec{"vtxROF", "ITS", "VERTICESROF", 0}, - "VerticesROF"}, - BranchDefinition>{InputSpec{"ROframes", "ITS", "ITSTrackROF", 0}, - "ITSTracksROF", - logger}, - BranchDefinition{InputSpec{"labels", "ITS", "TRACKSMCTR", 0}, - "ITSTrackMCTruth", - (useMC ? 1 : 0), // one branch if mc labels enabled - ""}, - BranchDefinition{InputSpec{"labelsVertices", "ITS", "VERTICESMCTR", 0}, - "ITSVertexMCTruth", - (useMC ? 1 : 0), // one branch if mc labels enabled - ""}, - BranchDefinition>{InputSpec{"purityVertices", "ITS", "VERTICESMCPUR", 0}, - "ITSVertexMCPurity", (useMC ? 1 : 0), ""}, - BranchDefinition{InputSpec{"MC2ROframes", "ITS", "ITSTrackMC2ROF", 0}, - "ITSTracksMC2ROF", - (useMC ? 1 : 0), // one branch if mc labels enabled - ""})(); -} - -} // namespace its3 -} // namespace o2 diff --git a/Detectors/Upgrades/ITS3/workflow/src/VertexReaderSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/VertexReaderSpec.cxx deleted file mode 100644 index 25fd3e530161a..0000000000000 --- a/Detectors/Upgrades/ITS3/workflow/src/VertexReaderSpec.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// 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 VertexReaderSpec.cxx - -#include - -#include "Framework/ControlService.h" -#include "Framework/ConfigParamRegistry.h" -#include "Framework/Logger.h" -#include "ITSWorkflow/VertexReaderSpec.h" -#include "CommonUtils/NameConf.h" - -using namespace o2::framework; -using namespace o2::its; - -namespace o2 -{ -namespace its -{ - -void VertexReader::init(InitContext& ic) -{ - mFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get("input-dir")), - ic.options().get("its-vertex-infile")); - connectTree(mFileName); -} - -void VertexReader::run(ProcessingContext& pc) -{ - auto ent = mTree->GetReadEntry() + 1; - assert(ent < mTree->GetEntries()); // this should not happen - mTree->GetEntry(ent); - LOG(info) << "Pushing " << mVerticesPtr->size() << " vertices in " << mVerticesROFRecPtr->size() - << " ROFs at entry " << ent; - pc.outputs().snapshot(Output{"IT3", "VERTICES", 0}, mVertices); - pc.outputs().snapshot(Output{"IT3", "VERTICESROF", 0}, mVerticesROFRec); - - if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) { - pc.services().get().endOfStream(); - pc.services().get().readyToQuit(QuitRequest::Me); - } -} - -void VertexReader::connectTree(const std::string& filename) -{ - mTree.reset(nullptr); // in case it was already loaded - mFile.reset(TFile::Open(filename.c_str())); - assert(mFile && !mFile->IsZombie()); - mTree.reset((TTree*)mFile->Get(mVertexTreeName.c_str())); - assert(mTree); - assert(mTree->GetBranch(mVertexBranchName.c_str())); - assert(mTree->GetBranch(mVertexROFBranchName.c_str())); - mTree->SetBranchAddress(mVertexBranchName.c_str(), &mVerticesPtr); - mTree->SetBranchAddress(mVertexROFBranchName.c_str(), &mVerticesROFRecPtr); - LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries"; -} - -DataProcessorSpec getITS3VertexReaderSpec() -{ - std::vector outputSpec; - outputSpec.emplace_back("IT3", "VERTICES", 0, Lifetime::Timeframe); - outputSpec.emplace_back("IT3", "VERTICESROF", 0, Lifetime::Timeframe); - - return DataProcessorSpec{ - "its3-vertex-reader", - Inputs{}, - outputSpec, - AlgorithmSpec{adaptFromTask()}, - Options{ - {"its3-vertex-infile", VariantType::String, "o2trac_its3.root", {"Name of the input ITS3 vertex file"}}, - {"input-dir", VariantType::String, "none", {"Input directory"}}}}; -} - -} // namespace its -} // namespace o2