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{
29EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt)
30{
31 mTimer.Stop();
32 mTimer.Reset();
33 mCTFCoder.setVerbosity(verbosity);
34 mCTFCoder.setDictBinding("ctfdict_MID");
35}
36
38{
39 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
40 return;
41 }
42}
43
45{
46 mCTFCoder.init<CTF>(ic);
47}
48
50{
51 auto cput = mTimer.CpuTime();
52 mTimer.Start(false);
53 o2::ctf::CTFIOSize iosize;
54
55 mCTFCoder.updateTimeDependentParams(pc, true);
56 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_MID");
57
58 std::array<std::vector<o2::mid::ROFRecord>, NEvTypes> rofs{};
59 std::array<std::vector<o2::mid::ColumnData>, NEvTypes> cols{};
60 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
61 if (buff.size()) {
62 const auto ctfImage = o2::mid::CTF::getImage(buff.data());
63 iosize = mCTFCoder.decode(ctfImage, rofs, cols);
64 }
65 size_t insize = 0;
66 for (uint32_t it = 0; it < NEvTypes; it++) {
67 insize += cols[it].size() * sizeof(o2::mid::ColumnData);
69 insize += rofs[it].size() * sizeof(o2::mid::ROFRecord);
70 pc.outputs().snapshot(Output{o2::header::gDataOriginMID, "DATAROF", it}, rofs[it]);
71 }
72 iosize.rawIn = insize;
73 pc.outputs().snapshot({"ctfrep", 0}, iosize);
74 mTimer.Stop();
75 LOG(info) << "Decoded {" << cols[0].size() << ',' << cols[1].size() << ',' << cols[2].size()
76 << "} MID columns for {" << rofs[0].size() << ',' << rofs[1].size() << ',' << rofs[2].size()
77 << "} ROFRecords, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
78}
79
81{
82 LOGF(info, "MID Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
83 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
84}
85
86DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string& ctfdictOpt)
87{
88 std::vector<OutputSpec> outputs;
89 for (o2::header::DataHeader::SubSpecificationType subSpec = 0; subSpec < NEvTypes; ++subSpec) {
90 outputs.emplace_back(OutputSpec{header::gDataOriginMID, "DATA", subSpec});
91 outputs.emplace_back(OutputSpec{header::gDataOriginMID, "DATAROF", subSpec});
92 }
93 outputs.emplace_back(OutputSpec{{"ctfrep"}, "MID", "CTFDECREP", 0, Lifetime::Timeframe});
94 std::vector<InputSpec> inputs;
95 inputs.emplace_back("ctf_MID", "MID", "CTFDATA", sspec, Lifetime::Timeframe);
96
97 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
98 inputs.emplace_back("ctfdict_MID", "MID", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("MID/Calib/CTFDictionaryTree"));
99 }
100 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
101
102 return DataProcessorSpec{
103 "mid-entropy-decoder",
104 inputs,
105 outputs,
106 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
107 Options{{"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
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
EntropyDecoderSpec(int verbosity, const std::string &ctfdictOpt="none")
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.
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, const std::string &ctfdictOpt)
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:621
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