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{
27EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt)
28{
29 mTimer.Stop();
30 mTimer.Reset();
31 mCTFCoder.setVerbosity(verbosity);
32 mCTFCoder.setSupportBCShifts(true);
33 mCTFCoder.setDictBinding("ctfdict_CTP");
34}
35
37{
38 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
39 return;
40 }
41}
42
44{
45 mCTFCoder.init<CTF>(ic);
46 bool decodeinps = !ic.options().get<bool>("ignore-ctpinputs-decoding-ctf");
47 mCTFCoder.setDecodeInps(decodeinps);
48 LOG(info) << "Decode inputs:" << decodeinps;
49}
50
52{
53 auto cput = mTimer.CpuTime();
54 mTimer.Start(false);
55 o2::ctf::CTFIOSize iosize;
56
58 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_CTP");
59 auto& digits = pc.outputs().make<std::vector<CTPDigit>>(OutputRef{"digits"});
60 auto& lumi = pc.outputs().make<LumiInfo>(OutputRef{"CTPLumi"});
61
62 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
63 if (buff.size()) {
64 const auto ctfImage = o2::ctp::CTF::getImage(buff.data());
65 iosize = mCTFCoder.decode(ctfImage, digits, lumi);
66 }
67 pc.outputs().snapshot({"ctfrep", 0}, iosize);
68 mTimer.Stop();
69 LOG(info) << "Decoded " << digits.size() << " CTP digits, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
70}
71
73{
74 LOGF(info, "CTP Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
75 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
76}
78{
79 mCTFCoder.updateTimeDependentParams(pc, true);
81 const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
82 if (mCTFCoder.getDecodeInps()) {
83 const auto ctpcfg = pc.inputs().get<o2::ctp::CTPConfiguration*>("ctpconfig");
84 if (ctpcfg != nullptr) {
85 mCTFCoder.setCTPConfig(*ctpcfg);
86 LOG(info) << "ctpconfig for run done:" << mCTFCoder.getCTPConfig().getRunNumber();
87 }
88 }
89 }
90}
91
92DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string& ctfdictOpt)
93{
94 std::vector<OutputSpec> outputs{
95 OutputSpec{{"digits"}, "CTP", "DIGITS", 0, Lifetime::Timeframe},
96 OutputSpec{{"CTPLumi"}, "CTP", "LUMI", 0, Lifetime::Timeframe},
97 OutputSpec{{"ctfrep"}, "CTP", "CTFDECREP", 0, Lifetime::Timeframe}};
98
99 std::vector<InputSpec> inputs;
100 inputs.emplace_back("ctf_CTP", "CTP", "CTFDATA", sspec, Lifetime::Timeframe);
101
102 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
103 inputs.emplace_back("ctfdict_CTP", "CTP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/CTFDictionaryTree"));
104 }
105 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
106 inputs.emplace_back("ctpconfig", "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", 1));
107 return DataProcessorSpec{
108 "ctp-entropy-decoder",
109 inputs,
110 outputs,
111 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
112 Options{{"ignore-ctpinputs-decoding-ctf", VariantType::Bool, false, {"Inputs alignment: false - CTF decoder - has to be compatible with reco: allowed options: 10,01,00"}},
113 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
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
EntropyDecoderSpec(int verbosity, const std::string &ctfdictOpt="none")
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, const std::string &ctfdictOpt)
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 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