Project
Loading...
Searching...
No Matches
ClustererSpec.cxx
Go to the documentation of this file.
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
18#include "Framework/Logger.h"
20
21#include <format>
22
23using namespace o2::framework;
24
25namespace o2::iotof
26{
27
29{
30 mNThreads = std::max(1, ic.options().get<int>("nthreads"));
31}
32
34{
35 LOG(info) << "Start running with " << mNThreads << " threads";
36 o2::base::GeometryManager::loadGeometry("o2sim_geometry.root", false, true);
37
38 uint64_t totalClusters = 0;
39
40 // Loop on layers to be added here, for now only one layer is processed
41 int iLayer = 0;
42 auto digits = pc.inputs().get<gsl::span<o2::iotof::Digit>>(std::format("digits_{}", iLayer));
43 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>(std::format("ROframes_{}", iLayer));
44
45 LOG(debug) << "Got " << digits.size() << " digits and " << rofs.size() << " ROFs for layer " << iLayer;
46 gsl::span<const char> labelbuffer;
47 if (mUseMC) {
48 labelbuffer = pc.inputs().get<gsl::span<char>>(std::format("labels_{}", iLayer));
49 LOG(debug) << "Got " << labelbuffer.size() << " bytes of MC labels for layer " << iLayer;
50 }
52
53 std::vector<o2::iotof::Cluster> clusters;
54 std::vector<unsigned char> patterns;
55 std::vector<o2::itsmft::ROFRecord> clusterROFs;
56 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
57 if (mUseMC) {
58 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
59 }
60
61 LOG(info) << "Running IOTOF Clusterer for layer " << iLayer;
62 mClusterer.process(digits,
63 rofs,
65 patterns,
66 clusterROFs,
67 mUseMC ? &labels : nullptr,
68 clusterLabels.get());
69 LOG(info) << "Clusterization produced " << clusters.size() << " clusters for layer " << iLayer;
70 const auto subspec = static_cast<o2::framework::DataAllocator::SubSpecificationType>(iLayer);
71 pc.outputs().snapshot(o2::framework::Output{"TF3", "COMPCLUSTERS", subspec}, clusters);
72 pc.outputs().snapshot(o2::framework::Output{"TF3", "PATTERNS", subspec}, patterns);
73 pc.outputs().snapshot(o2::framework::Output{"TF3", "CLUSTERSROF", subspec}, clusterROFs);
74 if (mUseMC) {
75 pc.outputs().snapshot(o2::framework::Output{"TF3", "CLUSTERSMCTR", subspec}, *clusterLabels);
76 }
77 totalClusters += clusters.size();
78 LOGP(info, "Pushed {} clusters in {} ROFs for layer {}", clusters.size(), clusterROFs.size(), iLayer);
79 LOGP(info, "Pushed {} MC labels for layer {}", mUseMC ? clusterLabels->getNElements() : 0, iLayer);
80}
81
83{
84 static constexpr int nLayers = 2;
85 std::vector<o2::framework::InputSpec> inputs;
86 // Currently TF3 digits (unlike TRK) are not separated by layer, eventually per-layer reading here
87 int iLayer = 0;
88 inputs.emplace_back(std::format("digits_{}", iLayer), "TF3", "DIGITS", iLayer, o2::framework::Lifetime::Timeframe);
89 inputs.emplace_back(std::format("ROframes_{}", iLayer), "TF3", "DIGITSROF", iLayer, o2::framework::Lifetime::Timeframe);
90 if (useMC) {
91 inputs.emplace_back(std::format("labels_{}", iLayer), "TF3", "DIGITSMCTR", iLayer, o2::framework::Lifetime::Timeframe);
92 }
93
94 std::vector<o2::framework::OutputSpec> outputs;
95 outputs.emplace_back("TF3", "COMPCLUSTERS", iLayer, o2::framework::Lifetime::Timeframe);
96 outputs.emplace_back("TF3", "PATTERNS", iLayer, o2::framework::Lifetime::Timeframe);
97 outputs.emplace_back("TF3", "CLUSTERSROF", iLayer, o2::framework::Lifetime::Timeframe);
98 if (useMC) {
99 outputs.emplace_back("TF3", "CLUSTERSMCTR", iLayer, o2::framework::Lifetime::Timeframe);
100 }
101
103 "iotof-clusterer",
104 inputs,
105 outputs,
106 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::iotof::ClustererDPL>(useMC)},
107 o2::framework::Options{{"nthreads", o2::framework::VariantType::Int, 1, {"Number of clustering threads"}}}};
108}
109
111{
112 return getClustererSpec(mctruth);
113}
114
115} // namespace o2::iotof
std::vector< std::string > labels
A const (ready only) version of MCTruthContainer.
Definition of the GeometryManager class.
Definition of IOTOF digit class.
std::ostringstream debug
Definition of the ITSMFT ROFrame (trigger) record.
static void loadGeometry(std::string_view geomFilePath="", bool applyMisalignment=false, bool preferAlignedFile=true)
void snapshot(const Output &spec, T const &object)
o2::header::DataHeader::SubSpecificationType SubSpecificationType
ConfigParamRegistry const & options()
Definition InitContext.h:33
decltype(auto) get(R binding, int part=0) const
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
virtual void process(gsl::span< const Digit > digits, gsl::span< const DigROFRecord > digitROFs, std::vector< o2::iotof::Cluster > &clusters, std::vector< unsigned char > &patterns, std::vector< o2::itsmft::ROFRecord > &clusterROFs, const ConstDigitTruth *digitLabels=nullptr, ClusterTruth *clusterLabels=nullptr, gsl::span< const DigMC2ROFRecord > digMC2ROFs={}, std::vector< o2::itsmft::MC2ROFRecord > *clusterMC2ROFs=nullptr)
Definition Clusterer.cxx:26
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getClustererSpec(bool useMC)
o2::framework::DataProcessorSpec getIOTOFClustererSpec(bool useMC)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters
std::vector< Digit > digits