diff --git a/Detectors/PHOS/workflow/CMakeLists.txt b/Detectors/PHOS/workflow/CMakeLists.txt index 7d19c6fabaf48..9a8a07b42de07 100644 --- a/Detectors/PHOS/workflow/CMakeLists.txt +++ b/Detectors/PHOS/workflow/CMakeLists.txt @@ -18,6 +18,8 @@ o2_add_library(PHOSWorkflow src/RawWriterSpec.cxx src/EntropyEncoderSpec.cxx src/EntropyDecoderSpec.cxx + src/ClusterWriterSpec.cxx + src/ClusterWriterWorkflow.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsPHOS O2::DPLUtils O2::PHOSBase @@ -31,6 +33,11 @@ o2_add_executable(reco-workflow SOURCES src/phos-reco-workflow.cxx PUBLIC_LINK_LIBRARIES O2::PHOSWorkflow) +o2_add_executable(cluster-writer-workflow + COMPONENT_NAME phos + SOURCES src/phos-cluster-writer-workflow.cxx + PUBLIC_LINK_LIBRARIES O2::PHOSWorkflow) + o2_add_executable(entropy-encoder-workflow COMPONENT_NAME phos SOURCES src/entropy-encoder-workflow.cxx diff --git a/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterSpec.h b/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterSpec.h new file mode 100644 index 0000000000000..fd34cd0389394 --- /dev/null +++ b/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterSpec.h @@ -0,0 +1,30 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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_PHOS_CLUSTERWRITER +#define O2_PHOS_CLUSTERWRITER + +#include "Framework/DataProcessorSpec.h" + +namespace o2 +{ +namespace phos +{ + +/// create a processor spec +/// write PHOS clusters to ROOT file +framework::DataProcessorSpec getClusterWriterSpec(bool useMC); + +} // namespace phos +} // namespace o2 + +#endif /* O2_PHOS_CLUSTERWRITER */ diff --git a/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterWorkflow.h b/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterWorkflow.h new file mode 100644 index 0000000000000..ba9266338ca76 --- /dev/null +++ b/Detectors/PHOS/workflow/include/PHOSWorkflow/ClusterWriterWorkflow.h @@ -0,0 +1,30 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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_PHOS_CLUSTER_WRITER_WORKFLOW_H +#define O2_PHOS_CLUSTER_WRITER_WORKFLOW_H + +/// @file ClusterWriterWorkflow.h + +#include "Framework/WorkflowSpec.h" + +namespace o2 +{ +namespace phos +{ + +namespace cluster_writer_workflow +{ +framework::WorkflowSpec getWorkflow(bool useMC); +} + +} // namespace phos +} // namespace o2 +#endif diff --git a/Detectors/PHOS/workflow/src/ClusterWriterSpec.cxx b/Detectors/PHOS/workflow/src/ClusterWriterSpec.cxx new file mode 100644 index 0000000000000..f18a6af25f5ff --- /dev/null +++ b/Detectors/PHOS/workflow/src/ClusterWriterSpec.cxx @@ -0,0 +1,67 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 "PHOSWorkflow/ClusterWriterSpec.h" +#include "DPLUtils/MakeRootTreeWriterSpec.h" +#include "DataFormatsPHOS/Cluster.h" +#include "DataFormatsPHOS/MCLabel.h" +#include "DataFormatsPHOS/TriggerRecord.h" +#include "SimulationDataFormat/MCCompLabel.h" +#include "SimulationDataFormat/MCTruthContainer.h" + +using namespace o2::framework; + +namespace o2 +{ +namespace phos +{ + +template +using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition; +using ClusType = std::vector; +using TriggerRecordType = std::vector; +using MCLabelType = o2::dataformats::MCTruthContainer; +using namespace o2::header; + +DataProcessorSpec getClusterWriterSpec(bool useMC) +{ + // Spectators for logging + // this is only to restore the original behavior + auto ClustersSize = std::make_shared(0); + auto ClustersSizeGetter = [ClustersSize](ClusType const& Clusters) { + *ClustersSize = Clusters.size(); + }; + + // auto logger = [ClustersSize](std::vector const& rofs) { +// LOG(INFO) << "ITSClusterWriter pulled " << *compClustersSize << " clusters, in " << rofs.size() << " RO frames"; +// }; + return MakeRootTreeWriterSpec("phos-cluster-writer", + "o2clus_phos.root", + MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with PHOS clusters"}, + BranchDefinition{InputSpec{"clus", "PHS", "CLUSTERS", 0}, + "PHOSCluster", + ClustersSizeGetter}, + BranchDefinition{InputSpec{"clusRecs", "PHS", "CLUSTERTRIGRECS", 0}, + "PHOSClusterTrigRec"}, + + BranchDefinition{InputSpec{"clusMC", "PHS", "CLUSTERTRUEMC", 0}, + "PHOSClusterTrueMC", + (useMC ? 1 : 0), // one branch if mc labels enabled + ""} + +)(); +} + +} // namespace phos +} // namespace o2 diff --git a/Detectors/PHOS/workflow/src/ClusterWriterWorkflow.cxx b/Detectors/PHOS/workflow/src/ClusterWriterWorkflow.cxx new file mode 100644 index 0000000000000..b72ac977414d0 --- /dev/null +++ b/Detectors/PHOS/workflow/src/ClusterWriterWorkflow.cxx @@ -0,0 +1,35 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 "PHOSWorkflow/ClusterWriterWorkflow.h" +#include "PHOSWorkflow/ClusterWriterSpec.h" + +namespace o2 +{ +namespace phos +{ + +namespace cluster_writer_workflow +{ + +framework::WorkflowSpec getWorkflow(bool useMC) +{ + framework::WorkflowSpec specs; + + specs.emplace_back(o2::phos::getClusterWriterSpec(useMC)); + + return specs; +} + +} // namespace cluster_writer_workflow +} // namespace phos +} // namespace o2 diff --git a/Detectors/PHOS/workflow/src/phos-cluster-writer-workflow.cxx b/Detectors/PHOS/workflow/src/phos-cluster-writer-workflow.cxx new file mode 100644 index 0000000000000..21f804c36e65e --- /dev/null +++ b/Detectors/PHOS/workflow/src/phos-cluster-writer-workflow.cxx @@ -0,0 +1,33 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 "PHOSWorkflow/ClusterWriterWorkflow.h" +#include "Framework/ConfigParamSpec.h" + +using namespace o2::framework; + +void customize(std::vector& workflowOptions) +{ + workflowOptions.push_back( + ConfigParamSpec{ + "disable-mc", + o2::framework::VariantType::Bool, + false, + {"disable MC propagation even if available"}}); +} + +#include "Framework/runDataProcessing.h" +#include "Framework/Logger.h" + +WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) +{ + auto useMC = !configcontext.options().get("disable-mc"); + return std::move(o2::phos::cluster_writer_workflow::getWorkflow(useMC)); +}