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
21using namespace o2::framework;
22
23namespace o2
24{
25namespace emcal
26{
27EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, unsigned int sspecOut, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt), mSSpecOut(sspecOut)
28{
29 mTimer.Stop();
30 mTimer.Reset();
31 mCTFCoder.setVerbosity(verbosity);
32 mCTFCoder.setSupportBCShifts(true);
33 mCTFCoder.setDictBinding("ctfdict_EMC");
34}
35
37{
38 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
39 return;
40 }
41}
42
44{
45 mCTFCoder.init<CTF>(ic);
46}
47
49{
50 auto cput = mTimer.CpuTime();
51 mTimer.Start(false);
52 o2::ctf::CTFIOSize iosize;
53
54 mCTFCoder.updateTimeDependentParams(pc, true);
55 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_EMC");
56
57 auto& triggers = pc.outputs().make<std::vector<TriggerRecord>>(OutputRef{"triggers", mSSpecOut});
58 auto& cells = pc.outputs().make<std::vector<Cell>>(OutputRef{"cells", mSSpecOut});
59
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::emcal::CTF::getImage(buff.data());
63 iosize = mCTFCoder.decode(ctfImage, triggers, cells);
64 }
65 pc.outputs().snapshot({"ctfrep", 0}, iosize);
66 mTimer.Stop();
67 LOG(info) << "Decoded " << cells.size() << " EMCAL cells in " << triggers.size() << " triggers, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
68}
69
71{
72 LOGF(info, "EMCAL Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
73 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
74}
75
76DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspecInp, unsigned int sspecOut, const std::string& ctfdictOpt)
77{
78 std::vector<OutputSpec> outputs{
79 OutputSpec{{"triggers"}, "EMC", "CELLSTRGR", sspecOut, Lifetime::Timeframe},
80 OutputSpec{{"cells"}, "EMC", "CELLS", sspecOut, Lifetime::Timeframe},
81 OutputSpec{{"ctfrep"}, "EMC", "CTFDECREP", 0, Lifetime::Timeframe}};
82
83 std::vector<InputSpec> inputs;
84 inputs.emplace_back("ctf_EMC", "EMC", "CTFDATA", sspecInp, Lifetime::Timeframe);
85
86 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
87 inputs.emplace_back("ctfdict_EMC", "EMC", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("EMC/Calib/CTFDictionaryTree"));
88 }
89 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
90
91 return DataProcessorSpec{
92 "emcal-entropy-decoder",
93 inputs,
94 outputs,
95 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, sspecOut, ctfdictOpt)},
96 Options{{"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
97}
98} // namespace emcal
99} // namespace o2
#define verbosity
Convert CTF (EncodedBlocks) to EMCAL digit/channels strean.
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
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VCELL &cellVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:134
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
EntropyDecoderSpec(int verbosity, unsigned int sspecOut, const std::string &ctfdictOpt="none")
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(o2::framework::InitContext &ic) final
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.
framework::DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspecInp, unsigned int sspecOut=0, const std::string &ctfdictOpt="none")
create a processor spec
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
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:41
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
std::vector< Cell > cells