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
21#include <TStopwatch.h>
22
23using namespace o2::framework;
24
25namespace o2
26{
27namespace hmpid
28{
29
31{
32 public:
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::hmpid::CTFCoder mCTFCoder;
42 TStopwatch mTimer;
43};
44
45EntropyDecoderSpec::EntropyDecoderSpec(int verbosity) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder)
46{
47 mTimer.Stop();
48 mTimer.Reset();
49 mCTFCoder.setVerbosity(verbosity);
50 mCTFCoder.setSupportBCShifts(true);
51 mCTFCoder.setDictBinding("ctfdict_HMP");
52}
53
55{
56 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
57 return;
58 }
59}
60
62{
63 mCTFCoder.init<CTF>(ic);
64}
65
67{
68 auto cput = mTimer.CpuTime();
69 mTimer.Start(false);
70 o2::ctf::CTFIOSize iosize;
71
72 mCTFCoder.updateTimeDependentParams(pc, true);
73 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_HMP");
74
75 auto& triggers = pc.outputs().make<std::vector<Trigger>>(OutputRef{"triggers"});
76 auto& digits = pc.outputs().make<std::vector<Digit>>(OutputRef{"digits"});
77
78 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
79 if (buff.size()) {
80 const auto ctfImage = o2::hmpid::CTF::getImage(buff.data());
81 iosize = mCTFCoder.decode(ctfImage, triggers, digits);
82 }
83 pc.outputs().snapshot({"ctfrep", 0}, iosize);
84 mTimer.Stop();
85 LOG(info) << "Decoded " << digits.size() << " HMPID digits in " << triggers.size() << " triggers, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
86}
87
89{
90 LOGF(info, "HMPID Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
91 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
92}
93
95{
96 std::vector<OutputSpec> outputs{
97 OutputSpec{{"triggers"}, "HMP", "INTRECORDS", 0, Lifetime::Timeframe},
98 OutputSpec{{"digits"}, "HMP", "DIGITS", 0, Lifetime::Timeframe},
99 OutputSpec{{"ctfrep"}, "HMP", "CTFDECREP", 0, Lifetime::Timeframe}};
100
101 std::vector<InputSpec> inputs;
102 inputs.emplace_back("ctf_HMP", "HMP", "CTFDATA", sspec, Lifetime::Timeframe);
103 inputs.emplace_back("ctfdict_HMP", "HMP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("HMP/Calib/CTFDictionaryTree"));
104 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
105
106 return DataProcessorSpec{
107 "hmpid-entropy-decoder",
108 inputs,
109 outputs,
110 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity)},
111 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
112 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
113}
114
115} // namespace hmpid
116} // namespace o2
#define verbosity
class for entropy encoding/decoding of HMPID data
Convert CTF (EncodedBlocks) to HMP digit/tracklets stream.
void setSupportBCShifts(bool v=true)
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, VTRG &trigVec, VDIG &digVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:132
~EntropyDecoderSpec() override=default
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
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
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 triggers and cells of the TF
Definition CTF.h:39
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
std::vector< Digit > digits