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 ctp
26{
27
28EntropyDecoderSpec::EntropyDecoderSpec(int verbosity) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder)
29{
30 mTimer.Stop();
31 mTimer.Reset();
32 mCTFCoder.setVerbosity(verbosity);
33 mCTFCoder.setSupportBCShifts(true);
34 mCTFCoder.setDictBinding("ctfdict_CTP");
35}
36
38{
39 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
40 return;
41 }
42}
43
45{
46 mCTFCoder.init<CTF>(ic);
47 bool decodeinps = !ic.options().get<bool>("ignore-ctpinputs-decoding-ctf");
48 mCTFCoder.setDecodeInps(decodeinps);
49 LOG(info) << "Decode inputs:" << decodeinps;
50}
51
53{
54 auto cput = mTimer.CpuTime();
55 mTimer.Start(false);
56 o2::ctf::CTFIOSize iosize;
57
59 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_CTP");
60 auto& digits = pc.outputs().make<std::vector<CTPDigit>>(OutputRef{"digits"});
61 auto& lumi = pc.outputs().make<LumiInfo>(OutputRef{"CTPLumi"});
62
63 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
64 if (buff.size()) {
65 const auto ctfImage = o2::ctp::CTF::getImage(buff.data());
66 iosize = mCTFCoder.decode(ctfImage, digits, lumi);
67 }
68 pc.outputs().snapshot({"ctfrep", 0}, iosize);
69 mTimer.Stop();
70 LOG(info) << "Decoded " << digits.size() << " CTP digits, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
71}
72
74{
75 LOGF(info, "CTP Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
76 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
77}
79{
80 mCTFCoder.updateTimeDependentParams(pc, true);
82 const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
83 if (mCTFCoder.getDecodeInps()) {
84 const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
85 if (ctpcfg != nullptr) {
86 mCTFCoder.setCTPConfig(*ctpcfg);
87 LOG(info) << "ctpconfig for run done:" << mCTFCoder.getCTPConfig().getRunNumber();
88 }
89 }
90 }
91}
92
94{
95 std::vector<OutputSpec> outputs{
96 OutputSpec{{"digits"}, "CTP", "DIGITS", 0, Lifetime::Timeframe},
97 OutputSpec{{"CTPLumi"}, "CTP", "LUMI", 0, Lifetime::Timeframe},
98 OutputSpec{{"ctfrep"}, "CTP", "CTFDECREP", 0, Lifetime::Timeframe}};
99
100 std::vector<InputSpec> inputs;
101 inputs.emplace_back("ctf_CTP", "CTP", "CTFDATA", sspec, Lifetime::Timeframe);
102 inputs.emplace_back("ctfdict_CTP", "CTP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/CTFDictionaryTree"));
103 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
104 inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", 1));
105 return DataProcessorSpec{
106 "ctp-entropy-decoder",
107 inputs,
108 outputs,
109 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity)},
110 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
111 {"ignore-ctpinputs-decoding-ctf", VariantType::Bool, false, {"Inputs alignment: false - CTF decoder - has to be compatible with reco: allowed options: 10,01,00"}},
112 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
113}
114
115} // namespace ctp
116} // namespace o2
#define verbosity
Convert CTF (EncodedBlocks) to CTP digit 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)
static auto getImage(const void *newHead)
get const image of the container wrapper, with pointers in the image relocated to new head
CTPConfiguration & getCTPConfig()
Definition CTFCoder.h:59
void setCTPConfig(CTPConfiguration cfg)
Definition CTFCoder.h:57
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
add CTP related shifts
Definition CTFCoder.h:245
void setDecodeInps(bool decodeinps)
Definition CTFCoder.h:56
bool getDecodeInps()
Definition CTFCoder.h:58
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &data, LumiInfo &lumi)
entropy decode data from buffer with CTF
Definition CTFCoder.h:131
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void updateTimeDependentParams(framework::ProcessingContext &pc)
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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.
ServiceRegistryRef services()
The services registry associated with this processing context.
framework::DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec)
create a processor spec
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
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 trigger inputs and classes of the TF
Definition CTF.h:45
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
LumiInfo lumi
std::vector< Digit > digits