Project
Loading...
Searching...
No Matches
ZeroSuppressionSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 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
16
18
19#include <vector>
20#include <gsl/gsl>
21#include "Framework/Output.h"
22#include "Framework/Task.h"
31
32namespace of = o2::framework;
33
34namespace o2
35{
36namespace mid
37{
38
40{
41 public:
42 ZeroSuppressionDeviceDPL(bool useMC) : mUseMC(useMC) {}
43
45 {
46 }
47
49 {
50 const auto patterns = specs::getData(pc, "mid_zs_in", EventType::Standard);
51 const auto inROFRecords = specs::getRofs(pc, "mid_zs_in", EventType::Standard);
52 const auto inMCContainer = mUseMC ? specs::getLabels(pc, "mid_zs_in") : nullptr;
53
55
56 auto& zsData = pc.outputs().make<std::vector<ColumnData>>(of::OutputRef{"mid_zs_out_0"});
57 auto& zsROFs = pc.outputs().make<std::vector<ROFRecord>>(of::OutputRef{"mid_zs_out_rof_0"});
58
59 zsData.reserve(patterns.size());
60 zsROFs.reserve(inROFRecords.size());
61
62 std::vector<ROFRecord> tmpROFs(1);
63 for (auto& rof : inROFRecords) {
64 mConverter.process(patterns.subspan(rof.firstEntry, rof.nEntries));
65 if (!mConverter.getData().empty()) {
66 std::vector<ROBoard> decodedData = mConverter.getData();
67 mResponse.applyZeroSuppression(decodedData);
68 tmpROFs.front().interactionRecord = rof.interactionRecord;
69 tmpROFs.front().eventType = rof.eventType;
70 tmpROFs.front().firstEntry = 0;
71 tmpROFs.front().nEntries = decodedData.size();
72 mAggregator.process(decodedData, tmpROFs);
73 auto& tmpOut = mAggregator.getData();
74 zsROFs.emplace_back(rof.interactionRecord, rof.eventType, zsData.size(), tmpOut.size());
75 zsData.insert(zsData.end(), tmpOut.begin(), tmpOut.end());
76
77 if (mUseMC) {
78 for (auto outColIt = zsData.begin() + zsROFs.back().firstEntry, outEnd = zsData.begin() + zsROFs.back().firstEntry + zsROFs.back().nEntries; outColIt != outEnd; ++outColIt) {
79 for (auto inColIt = patterns.begin() + rof.firstEntry, inEnd = patterns.begin() + rof.firstEntry + rof.nEntries; inColIt != inEnd; ++inColIt) {
80 if (inColIt->deId == outColIt->deId && inColIt->columnId == outColIt->columnId) {
81 auto inIdx = std::distance(patterns.begin(), inColIt);
82 auto outIdx = std::distance(zsData.begin(), outColIt);
83 outMCContainer.addElements(outIdx, inMCContainer->getLabels(inIdx));
84 break;
85 }
86 }
87 }
88 }
89 }
90 }
91
92 if (mUseMC) {
93 pc.outputs().snapshot(of::Output{header::gDataOriginMID, "DATALABELS", 0}, outMCContainer);
94 }
95 }
96
97 private:
98 ColumnDataToLocalBoard mConverter{};
99 DecodedDataAggregator mAggregator{};
100 ROBoardResponse mResponse{};
101 bool mUseMC{true};
102};
103
104framework::DataProcessorSpec getZeroSuppressionSpec(bool useMC, std::string_view dataDesc)
105{
106 auto inputSpecs = specs::buildInputSpecs("mid_zs_in", dataDesc, useMC);
107 auto outputSpecs = specs::buildStandardOutputSpecs("mid_zs_out", "DATA", useMC);
108
110 "MIDZeroSuppression",
111 {inputSpecs},
112 {outputSpecs},
113 of::AlgorithmSpec{of::adaptFromTask<o2::mid::ZeroSuppressionDeviceDPL>(useMC)}};
114}
115} // namespace mid
116} // namespace o2
Utilities for MID Column Data Specs.
Converter from ColumnData to raw local boards.
Strip pattern (aka digits)
Label for MID.
MID decoded raw data aggregator.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the MID event record.
Local board response.
MID zero suppression spec.
A container to hold and manage MC truth information/labels.
void addElements(uint32_t dataindex, gsl::span< CompatibleLabel > elements)
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
std::vector< ROBoard > getData() const
Gets vector of ROBoard.
void process(gsl::span< const ColumnData > data, bool allowEmpty=false)
void process(gsl::span< const ROBoard > localBoards, gsl::span< const ROFRecord > rofRecords)
const std::vector< ColumnData > & getData(EventType eventType=EventType::Standard)
Gets the vector of data.
bool applyZeroSuppression(std::vector< ROBoard > &locs) const
void run(o2::framework::ProcessingContext &pc)
void init(o2::framework::InitContext &ic)
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< framework::InputSpec > buildInputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC)
std::vector< framework::OutputSpec > buildStandardOutputSpecs(std::string_view dataBind, std::string_view dataDesc, bool useMC)
std::array< gsl::span< const ColumnData >, NEvTypes > getData(framework::ProcessingContext &pc, std::string_view dataBind)
std::unique_ptr< const o2::dataformats::MCTruthContainer< MCLabel > > getLabels(framework::ProcessingContext &pc, std::string_view dataBind)
std::array< gsl::span< const ROFRecord >, NEvTypes > getRofs(framework::ProcessingContext &pc, std::string_view dataBind)
framework::DataProcessorSpec getZeroSuppressionSpec(bool useMC=true, std::string_view dataDesc="DATAMC")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...