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
22using namespace o2::framework;
23
24namespace o2
25{
26namespace zdc
27{
28EntropyDecoderSpec::EntropyDecoderSpec(int verbosity, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder, ctfdictOpt)
29{
30 mTimer.Stop();
31 mTimer.Reset();
32 mCTFCoder.setVerbosity(verbosity);
33 mCTFCoder.setSupportBCShifts(true);
34 mCTFCoder.setDictBinding("ctfdict_ZDC");
35}
36
38{
39 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
40 if (mCTFCoder.getBCShift()) {
41 long norb = mCTFCoder.getBCShift() / o2::constants::lhc::LHCMaxBunches;
43 LOGP(info, "BCs 0 and 3563 will be corrected only for {} BCs (= {} integer orbits)", mCTFCoder.getBCShiftOrbits(), norb);
44 }
45 return;
46 }
47}
48
50{
51 mCTFCoder.init<CTF>(ic);
52}
53
55{
56 auto cput = mTimer.CpuTime();
57 mTimer.Start(false);
58 o2::ctf::CTFIOSize iosize;
59
60 mCTFCoder.updateTimeDependentParams(pc, true);
61 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_ZDC");
62
63 auto& bcdata = pc.outputs().make<std::vector<o2::zdc::BCData>>(OutputRef{"trig"});
64 auto& chans = pc.outputs().make<std::vector<o2::zdc::ChannelData>>(OutputRef{"chan"});
65 auto& peds = pc.outputs().make<std::vector<o2::zdc::OrbitData>>(OutputRef{"peds"});
66
67 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
68 if (buff.size()) {
69 const auto ctfImage = o2::zdc::CTF::getImage(buff.data());
70 iosize = mCTFCoder.decode(ctfImage, bcdata, chans, peds);
71 }
72 pc.outputs().snapshot({"ctfrep", 0}, iosize);
73 mTimer.Stop();
74 LOG(info) << "Decoded " << chans.size() << " ZDC channels in " << bcdata.size() << " triggers and " << peds.size() << " pedestals, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
75}
76
78{
79 LOGF(info, "ZDC Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
80 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
81}
82
83DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string& ctfdictOpt)
84{
85 std::vector<OutputSpec> outputs{
86 OutputSpec{{"trig"}, "ZDC", "DIGITSBC", 0, Lifetime::Timeframe},
87 OutputSpec{{"chan"}, "ZDC", "DIGITSCH", 0, Lifetime::Timeframe},
88 OutputSpec{{"peds"}, "ZDC", "DIGITSPD", 0, Lifetime::Timeframe},
89 OutputSpec{{"ctfrep"}, "ZDC", "CTFDECREP", 0, Lifetime::Timeframe}};
90
91 std::vector<InputSpec> inputs;
92 inputs.emplace_back("ctf_ZDC", "ZDC", "CTFDATA", sspec, Lifetime::Timeframe);
93
94 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
95 inputs.emplace_back("ctfdict_ZDC", "ZDC", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("ZDC/Calib/CTFDictionaryTree"));
96 }
97 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
98
99 return DataProcessorSpec{
100 "zdc-entropy-decoder",
101 inputs,
102 outputs,
103 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
104 Options{{"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
105}
106} // namespace zdc
107} // namespace o2
#define verbosity
Header to collect LHC related constants.
Convert CTF (EncodedBlocks) to ZDC BCData/ChannelData/OrbitData 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)
auto getBCShift() const
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.
void setBCShiftOrbits(long v)
Definition CTFCoder.h:51
o2::ctf::CTFIOSize decode(const CTF::base &ec, VTRG &trigVec, VCHAN &chanVec, VPED &pedVec)
entropy decode data from buffer with CTF
Definition CTFCoder.h:157
auto getBCShiftOrbits() const
Definition CTFCoder.h:52
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 init(o2::framework::InitContext &ic) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
constexpr int LHCMaxBunches
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
struct o2::upgrades_utils::@462 zdc
structure to keep FT0 information
framework::DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string &ctfdictOpt)
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:44
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage