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
14#include <vector>
15
20#include "Framework/Task.h"
21#include "MCHCTF/CTFCoder.h"
22#include <TStopwatch.h>
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace mch
29{
31{
32 public:
33 EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt = "none");
34 ~EntropyDecoderSpec() override = default;
36 void init(o2::framework::InitContext& ic) final;
38 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
39
40 private:
41 o2::mch::CTFCoder mCTFCoder;
42 TStopwatch mTimer;
43};
44
45EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt)
46{
47 mTimer.Stop();
48 mTimer.Reset();
49 mCTFCoder.setVerbosity(verbosity);
50 mCTFCoder.setDictBinding("ctfdict_MCH");
51}
52
54{
55 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
56 return;
57 }
58}
59
61{
62 mCTFCoder.init<CTF>(ic);
63}
64
66{
67 auto cput = mTimer.CpuTime();
68 mTimer.Start(false);
69 o2::ctf::CTFIOSize iosize;
70
71 mCTFCoder.updateTimeDependentParams(pc, true);
72 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_MCH");
73
74 auto& rofs = pc.outputs().make<std::vector<o2::mch::ROFRecord>>(OutputRef{"rofs", 0});
75 auto& digits = pc.outputs().make<std::vector<o2::mch::Digit>>(OutputRef{"digits", 0});
76
77 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
78 if (buff.size()) {
79 const auto ctfImage = o2::mch::CTF::getImage(buff.data());
80 iosize = mCTFCoder.decode(ctfImage, rofs, digits);
81 }
82 pc.outputs().snapshot({"ctfrep", 0}, iosize);
83 mTimer.Stop();
84 LOG(info) << "Decoded " << digits.size() << " MCH digits in " << rofs.size() << " ROFRecords, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s.";
85}
86
88{
89 LOGF(info, "MCH Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
90 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
91}
92
93DataProcessorSpec getEntropyDecoderSpec(int verbosity, const char* specName, unsigned int sspec, const std::string& ctfdictOpt)
94{
95 std::vector<OutputSpec> outputs{
96 OutputSpec{{"rofs"}, "MCH", "DIGITROFS", 0, Lifetime::Timeframe},
97 OutputSpec{{"digits"}, "MCH", "DIGITS", 0, Lifetime::Timeframe},
98 OutputSpec{{"ctfrep"}, "MCH", "CTFDECREP", 0, Lifetime::Timeframe},
99 };
100
101 std::vector<InputSpec> inputs;
102 inputs.emplace_back("ctf_MCH", "MCH", "CTFDATA", sspec, Lifetime::Timeframe);
103
104 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
105 inputs.emplace_back("ctfdict_MCH", "MCH", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("MCH/Calib/CTFDictionaryTree"));
106 }
107 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
108
109 return DataProcessorSpec{
110 specName,
111 inputs,
112 outputs,
113 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
114 Options{{"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
115}
116} // namespace mch
117} // namespace o2
#define verbosity
class for entropy encoding/decoding of MCH digit data
Convert CTF (EncodedBlocks) to MCH {Digit,ROFRecord} stream.
const char * specName
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) make(const Output &spec, Args... args)
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, VROF &rofVec, VCOL &digVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:134
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
EntropyDecoderSpec(int verbosity, const std::string &ctfdictOpt="none")
~EntropyDecoderSpec() override=default
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
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, const char *specName, unsigned int sspec, const std::string &ctfdictOpt="none")
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string asString() const
Definition CTFIOSize.cxx:19
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:40
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
std::vector< Digit > digits