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 LOG(info) << "Clusterization produced " << patterns.size() << " patterns for layer " << iLayer;
71 LOG(info) << "Clusterization produced " << clusterROFs.size() << " ROFs for layer " << iLayer;
72 const auto subspec = static_cast<o2::framework::DataAllocator::SubSpecificationType>(iLayer);
73 pc.outputs().snapshot(o2::framework::Output{"TF3", "CLUSTERS", subspec}, clusters);
74 pc.outputs().snapshot(o2::framework::Output{"TF3", "PATTERNS", subspec}, patterns);
75 pc.outputs().snapshot(o2::framework::Output{"TF3", "CLUSTERSROF", subspec}, clusterROFs);
76 if (mUseMC) {
77 pc.outputs().snapshot(o2::framework::Output{"TF3", "CLUSTERSMCTR", subspec}, *clusterLabels);
78 }
79 totalClusters += clusters.size();
80 LOGP(info, "Pushed {} clusters, {} patterns, in {} ROFs for layer {}", clusters.size(), patterns.size(), clusterROFs.size(), iLayer);
81 LOGP(info, "Pushed {} MC labels for layer {}", mUseMC ? clusterLabels->getNElements() : 0, iLayer);
82}
83
85{
86 static constexpr int nLayers = 2;
87 std::vector<o2::framework::InputSpec> inputs;
88 // Currently TF3 digits (unlike TRK) are not separated by layer, eventually per-layer reading here
89 int iLayer = 0;
90 inputs.emplace_back(std::format("digits_{}", iLayer), "TF3", "DIGITS", iLayer, o2::framework::Lifetime::Timeframe);
91 inputs.emplace_back(std::format("ROframes_{}", iLayer), "TF3", "DIGITSROF", iLayer, o2::framework::Lifetime::Timeframe);
92 if (useMC) {
93 inputs.emplace_back(std::format("labels_{}", iLayer), "TF3", "DIGITSMCTR", iLayer, o2::framework::Lifetime::Timeframe);
94 }
95
96 std::vector<o2::framework::OutputSpec> outputs;
97 outputs.emplace_back("TF3", "CLUSTERS", iLayer, o2::framework::Lifetime::Timeframe);
98 outputs.emplace_back("TF3", "PATTERNS", iLayer, o2::framework::Lifetime::Timeframe);
99 outputs.emplace_back("TF3", "CLUSTERSROF", iLayer, o2::framework::Lifetime::Timeframe);
100 if (useMC) {
101 outputs.emplace_back("TF3", "CLUSTERSMCTR", iLayer, o2::framework::Lifetime::Timeframe);
102 }
103
105 "iotof-clusterer",
106 inputs,
107 outputs,
108 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::iotof::ClustererDPL>(useMC)},
109 o2::framework::Options{{"nthreads", o2::framework::VariantType::Int, 1, {"Number of clustering threads"}}}};
110}
111
113{
114 return getClustererSpec(mctruth);
115}
116
117} // namespace o2::iotof
A const (ready only) version of MCTruthContainer.
Definition of the GeometryManager class.
Definition of the IOTOF cluster.
Definition of IOTOF digit class.
std::ostringstream debug
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Definition of the ITSMFT ROFrame (trigger) record.
std::vector< o2::MCCompLabel > labels
static void loadGeometry(std::string_view geomFilePath="", bool applyMisalignment=false, bool preferAlignedFile=true)
void snapshot(const Output &spec, T const &object)
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
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