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
17#include "Framework/Logger.h"
19
20namespace o2::trk
21{
22
24{
25 mNThreads = std::max(1, ic.options().get<int>("nthreads"));
26}
27
29{
30 auto digits = pc.inputs().get<gsl::span<o2::itsmft::Digit>>("digits");
31 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
32
33 gsl::span<const o2::itsmft::MC2ROFRecord> mc2rofs;
34 gsl::span<const char> labelbuffer;
35 if (mUseMC) {
36 labelbuffer = pc.inputs().get<gsl::span<char>>("labels");
37 mc2rofs = pc.inputs().get<gsl::span<o2::itsmft::MC2ROFRecord>>("MC2ROframes");
38 }
40
41 std::vector<o2::trk::Cluster> clusters;
42 std::vector<unsigned char> patterns;
43 std::vector<o2::trk::ROFRecord> clusterROFs;
44 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
45 std::vector<o2::trk::MC2ROFRecord> clusterMC2ROFs;
46 if (mUseMC) {
47 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
48 }
49 o2::base::GeometryManager::loadGeometry("o2sim_geometry.root", false, true);
50
51 mClusterer.process(digits,
52 rofs,
54 patterns,
55 clusterROFs,
56 mUseMC ? &labels : nullptr,
57 clusterLabels.get(),
58 mc2rofs,
59 mUseMC ? &clusterMC2ROFs : nullptr);
60
61 pc.outputs().snapshot(o2::framework::Output{"TRK", "COMPCLUSTERS", 0}, clusters);
62 pc.outputs().snapshot(o2::framework::Output{"TRK", "PATTERNS", 0}, patterns);
63 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSROF", 0}, clusterROFs);
64
65 if (mUseMC) {
66 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSMCTR", 0}, *clusterLabels);
67 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSMC2ROF", 0}, clusterMC2ROFs);
68 }
69
70 LOGP(info, "TRKClusterer pushed {} clusters in {} ROFs", clusters.size(), clusterROFs.size());
71}
72
74{
75 std::vector<o2::framework::InputSpec> inputs;
76 inputs.emplace_back("digits", "TRK", "DIGITS", 0, o2::framework::Lifetime::Timeframe);
77 inputs.emplace_back("ROframes", "TRK", "DIGITSROF", 0, o2::framework::Lifetime::Timeframe);
78
79 std::vector<o2::framework::OutputSpec> outputs;
80 outputs.emplace_back("TRK", "COMPCLUSTERS", 0, o2::framework::Lifetime::Timeframe);
81 outputs.emplace_back("TRK", "PATTERNS", 0, o2::framework::Lifetime::Timeframe);
82 outputs.emplace_back("TRK", "CLUSTERSROF", 0, o2::framework::Lifetime::Timeframe);
83
84 if (useMC) {
85 inputs.emplace_back("labels", "TRK", "DIGITSMCTR", 0, o2::framework::Lifetime::Timeframe);
86 inputs.emplace_back("MC2ROframes", "TRK", "DIGITSMC2ROF", 0, o2::framework::Lifetime::Timeframe);
87 outputs.emplace_back("TRK", "CLUSTERSMCTR", 0, o2::framework::Lifetime::Timeframe);
88 outputs.emplace_back("TRK", "CLUSTERSMC2ROF", 0, o2::framework::Lifetime::Timeframe);
89 }
90
92 "trk-clusterer",
93 inputs,
94 outputs,
95 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::trk::ClustererDPL>(useMC)},
96 o2::framework::Options{{"nthreads", o2::framework::VariantType::Int, 1, {"Number of clustering threads"}}}};
97}
98
99} // namespace o2::trk
std::vector< std::string > labels
A const (ready only) version of MCTruthContainer.
Definition of the GeometryManager class.
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 init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
void process(gsl::span< const Digit > digits, gsl::span< const DigROFRecord > digitROFs, std::vector< o2::trk::Cluster > &clusters, std::vector< unsigned char > &patterns, std::vector< o2::trk::ROFRecord > &clusterROFs, const ConstDigitTruth *digitLabels=nullptr, ClusterTruth *clusterLabels=nullptr, gsl::span< const DigMC2ROFRecord > digMC2ROFs={}, std::vector< o2::trk::MC2ROFRecord > *clusterMC2ROFs=nullptr)
Definition Clusterer.cxx:25
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getClustererSpec(bool useMC)
std::vector< Cluster > clusters
std::vector< Digit > digits