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#ifdef O2_WITH_ACTS
27 mUseACTS = ic.options().get<bool>("useACTS");
28#endif
29}
30
32{
33 auto digits = pc.inputs().get<gsl::span<o2::itsmft::Digit>>("digits");
34 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
35
36 gsl::span<const o2::itsmft::MC2ROFRecord> mc2rofs;
37 gsl::span<const char> labelbuffer;
38 if (mUseMC) {
39 labelbuffer = pc.inputs().get<gsl::span<char>>("labels");
40 mc2rofs = pc.inputs().get<gsl::span<o2::itsmft::MC2ROFRecord>>("MC2ROframes");
41 }
43
44 std::vector<o2::trk::Cluster> clusters;
45 std::vector<unsigned char> patterns;
46 std::vector<o2::trk::ROFRecord> clusterROFs;
47 std::unique_ptr<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> clusterLabels;
48 std::vector<o2::trk::MC2ROFRecord> clusterMC2ROFs;
49 if (mUseMC) {
50 clusterLabels = std::make_unique<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>();
51 }
52 o2::base::GeometryManager::loadGeometry("o2sim_geometry.root", false, true);
53
54#ifdef O2_WITH_ACTS
55 if (mUseACTS) {
56 LOG(info) << "Running TRKClusterer with ACTS";
57 mClustererACTS.process(digits,
58 rofs,
60 patterns,
61 clusterROFs,
62 mUseMC ? &labels : nullptr,
63 clusterLabels.get(),
64 mc2rofs,
65 mUseMC ? &clusterMC2ROFs : nullptr);
66 } else
67#endif
68 {
69 LOG(info) << "Running TRKClusterer";
70 mClusterer.process(digits,
71 rofs,
73 patterns,
74 clusterROFs,
75 mUseMC ? &labels : nullptr,
76 clusterLabels.get(),
77 mc2rofs,
78 mUseMC ? &clusterMC2ROFs : nullptr);
79 }
80
81 pc.outputs().snapshot(o2::framework::Output{"TRK", "COMPCLUSTERS", 0}, clusters);
82 pc.outputs().snapshot(o2::framework::Output{"TRK", "PATTERNS", 0}, patterns);
83 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSROF", 0}, clusterROFs);
84
85 if (mUseMC) {
86 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSMCTR", 0}, *clusterLabels);
87 pc.outputs().snapshot(o2::framework::Output{"TRK", "CLUSTERSMC2ROF", 0}, clusterMC2ROFs);
88 }
89
90 LOGP(info, "TRKClusterer pushed {} clusters in {} ROFs", clusters.size(), clusterROFs.size());
91}
92
94{
95 std::vector<o2::framework::InputSpec> inputs;
96 inputs.emplace_back("digits", "TRK", "DIGITS", 0, o2::framework::Lifetime::Timeframe);
97 inputs.emplace_back("ROframes", "TRK", "DIGITSROF", 0, o2::framework::Lifetime::Timeframe);
98
99 std::vector<o2::framework::OutputSpec> outputs;
100 outputs.emplace_back("TRK", "COMPCLUSTERS", 0, o2::framework::Lifetime::Timeframe);
101 outputs.emplace_back("TRK", "PATTERNS", 0, o2::framework::Lifetime::Timeframe);
102 outputs.emplace_back("TRK", "CLUSTERSROF", 0, o2::framework::Lifetime::Timeframe);
103
104 if (useMC) {
105 inputs.emplace_back("labels", "TRK", "DIGITSMCTR", 0, o2::framework::Lifetime::Timeframe);
106 inputs.emplace_back("MC2ROframes", "TRK", "DIGITSMC2ROF", 0, o2::framework::Lifetime::Timeframe);
107 outputs.emplace_back("TRK", "CLUSTERSMCTR", 0, o2::framework::Lifetime::Timeframe);
108 outputs.emplace_back("TRK", "CLUSTERSMC2ROF", 0, o2::framework::Lifetime::Timeframe);
109 }
110
112 "trk-clusterer",
113 inputs,
114 outputs,
115 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<o2::trk::ClustererDPL>(useMC)},
116 o2::framework::Options{{"nthreads", o2::framework::VariantType::Int, 1, {"Number of clustering threads"}}
117#ifdef O2_WITH_ACTS
118 ,
119 {"useACTS", o2::framework::VariantType::Bool, false, {"Use ACTS for clustering"}}
120#endif
121 }};
122}
123
124} // 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
virtual 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)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters
std::vector< Digit > digits