47 std::string processorName =
"tpc-clusterer";
51 std::vector<o2::tpc::ClusterHardwareContainer8kb> clusterArray;
53 std::array<std::shared_ptr<o2::tpc::HwClusterer>, NSectors> clusterers;
63 auto processAttributes = std::make_shared<ProcessAttributes>();
64 processAttributes->sendMC = sendMC;
67 auto& clusterArray = processAttributes->clusterArray;
68 auto& mctruthArray = processAttributes->mctruthArray;
69 auto& clusterers = processAttributes->clusterers;
70 auto&
verbosity = processAttributes->verbosity;
71 auto const* sectorHeader = DataRefUtils::getHeader<o2::tpc::TPCSectorHeader*>(dataref);
72 if (sectorHeader ==
nullptr) {
73 LOG(error) <<
"sector header missing on header stack";
76 auto const* dataHeader = DataRefUtils::getHeader<o2::header::DataHeader*>(dataref);
79 const auto sector = sectorHeader->sector();
92 inMCLabels = pc.
inputs().
get<gsl::span<char>>(mclabelref);
94 auto inDigits = pc.
inputs().
get<gsl::span<o2::tpc::Digit>>(dataref);
96 LOG(info) <<
"received " << inDigits.size() <<
" digits, "
100 if (!clusterers[sector]) {
104 clusterers[sector] = std::make_shared<o2::tpc::HwClusterer>(&clusterArray, sector, &mctruthArray);
105 clusterers[sector]->init();
107 auto& clusterer = clusterers[sector];
110 LOG(info) <<
"processing " << inDigits.size() <<
" digit object(s) of sector " << sectorHeader->sector()
118 clusterer->process(inDigits, inMCLabels,
true );
119 const std::vector<o2::tpc::Digit> emptyDigits;
121 clusterer->finishProcess(emptyDigits, emptyLabels,
false);
123 LOG(info) <<
"clusterer produced "
124 << std::accumulate(clusterArray.begin(), clusterArray.end(),
size_t(0), [](
size_t l,
auto const&
r) { return l + r.getContainer()->numberOfClusters; })
126 <<
" for sector " << sectorHeader->sector()
129 LOG(info) <<
"clusterer produced " << mctruthArray.
getIndexedSize() <<
" MC label object(s) for sector " << sectorHeader->sector();
135 std::copy(clusterArray.begin(), clusterArray.end(), outputPages.begin());
138 mctruthArray.flatten_to(mcflat);
143 auto processingFct = [processAttributes, processSectorFunction](
ProcessingContext& pc) {
144 struct SectorInputDesc {
150 std::map<int, SectorInputDesc> inputs;
151 std::vector<InputSpec>
filter = {
156 auto const* sectorHeader = DataRefUtils::getHeader<o2::tpc::TPCSectorHeader*>(inputRef);
157 if (sectorHeader ==
nullptr) {
158 LOG(error) <<
"sector header missing on header stack for input on " << inputRef.spec->binding;
161 const int sector = sectorHeader->sector();
163 inputs[sector].dataref = inputRef;
166 inputs[sector].mclabelref = inputRef;
169 for (
auto const& input : inputs) {
171 throw std::runtime_error(
"missing the required MC label data for sector " +
std::to_string(input.first));
173 processSectorFunction(pc, input.second.dataref, input.second.mclabelref);
176 return processingFct;
179 auto createInputSpecs = [](
bool makeMcInput) {
180 std::vector<InputSpec> inputSpecs{
185 inputSpecs.emplace_back(
"mclabels",
gDataOriginTPC, datadesc, 0, Lifetime::Timeframe);
187 return std::move(inputSpecs);
190 auto createOutputSpecs = [](
bool makeMcOutput) {
191 std::vector<OutputSpec> outputSpecs{
200 return std::move(outputSpecs);
204 {createInputSpecs(sendMC)},
205 {createOutputSpecs(sendMC)},
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.