Project
Loading...
Searching...
No Matches
EntropyDecoderSpec.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
13
15
16#include <vector>
22
23using namespace o2::framework;
24
25namespace o2
26{
27namespace mid
28{
29
30EntropyDecoderSpec::EntropyDecoderSpec(int verbosity) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder)
31{
32 mTimer.Stop();
33 mTimer.Reset();
34 mCTFCoder.setVerbosity(verbosity);
35 mCTFCoder.setDictBinding("ctfdict_MID");
36}
37
39{
40 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
41 return;
42 }
43}
44
46{
47 mCTFCoder.init<CTF>(ic);
48}
49
51{
52 auto cput = mTimer.CpuTime();
53 mTimer.Start(false);
54 o2::ctf::CTFIOSize iosize;
55
56 mCTFCoder.updateTimeDependentParams(pc, true);
57 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_MID");
58
59 std::array<std::vector<o2::mid::ROFRecord>, NEvTypes> rofs{};
60 std::array<std::vector<o2::mid::ColumnData>, NEvTypes> cols{};
61 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
62 if (buff.size()) {
63 const auto ctfImage = o2::mid::CTF::getImage(buff.data());
64 iosize = mCTFCoder.decode(ctfImage, rofs, cols);
65 }
66 size_t insize = 0;
67 for (uint32_t it = 0; it < NEvTypes; it++) {
68 insize += cols[it].size() * sizeof(o2::mid::ColumnData);
70 insize += rofs[it].size() * sizeof(o2::mid::ROFRecord);
71 pc.outputs().snapshot(Output{o2::header::gDataOriginMID, "DATAROF", it}, rofs[it]);
72 }
73 iosize.rawIn = insize;
74 pc.outputs().snapshot({"ctfrep", 0}, iosize);
75 mTimer.Stop();
76 LOG(info) << "Decoded {" << cols[0].size() << ',' << cols[1].size() << ',' << cols[2].size()
77 << "} MID columns for {" << rofs[0].size() << ',' << rofs[1].size() << ',' << rofs[2].size()
78 << "} ROFRecords, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
79}
80
82{
83 LOGF(info, "MID Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
84 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
85}
86
88{
89 std::vector<OutputSpec> outputs;
90 for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) {
91 outputs.emplace_back(OutputSpec{header::gDataOriginMID, "DATA", subSpec});
92 outputs.emplace_back(OutputSpec{header::gDataOriginMID, "DATAROF", subSpec});
93 }
94 outputs.emplace_back(OutputSpec{{"ctfrep"}, "MID", "CTFDECREP", 0, Lifetime::Timeframe});
95 std::vector<InputSpec> inputs;
96 inputs.emplace_back("ctf_MID", "MID", "CTFDATA", sspec, Lifetime::Timeframe);
97 inputs.emplace_back("ctfdict_MID", "MID", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("MID/Calib/CTFDictionaryTree"));
98 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
99
100 return DataProcessorSpec{
101 "mid-entropy-decoder",
102 inputs,
103 outputs,
104 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity)},
105 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
106 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
107}
108
109} // namespace mid
110} // namespace o2
#define verbosity
Declarations for CTFCoderBase class (support of external dictionaries)
Convert CTF (EncodedBlocks) to MID ROFRecords/ColumnData stream.
Definition of the Names Generator class.
uint32_t cols
void updateTimeDependentParams(o2::framework::ProcessingContext &pc, bool askTree=false)
void setDictBinding(const std::string &s)
void init(o2::framework::InitContext &ic)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
void snapshot(const Output &spec, T const &object)
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.
o2::ctf::CTFIOSize decode(const CTF::base &ec, std::array< VROF, NEvTypes > &rofVec, std::array< VCOL, NEvTypes > &colVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:106
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec)
create a processor spec
constexpr uint32_t NEvTypes
Definition ROFRecord.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
Definition CTFIOSize.cxx:19
uint32_t SubSpecificationType
Definition DataHeader.h:620
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:41
Column data structure for MID.
Definition ColumnData.h:29
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage