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{
28
29EntropyDecoderSpec::EntropyDecoderSpec(int verbosity) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder)
30{
31 mTimer.Stop();
32 mTimer.Reset();
33 mCTFCoder.setVerbosity(verbosity);
34 mCTFCoder.setSupportBCShifts(true);
35 mCTFCoder.setDictBinding("ctfdict_ZDC");
36}
37
39{
40 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
41 if (mCTFCoder.getBCShift()) {
42 long norb = mCTFCoder.getBCShift() / o2::constants::lhc::LHCMaxBunches;
44 LOGP(info, "BCs 0 and 3563 will be corrected only for {} BCs (= {} integer orbits)", mCTFCoder.getBCShiftOrbits(), norb);
45 }
46 return;
47 }
48}
49
51{
52 mCTFCoder.init<CTF>(ic);
53}
54
56{
57 auto cput = mTimer.CpuTime();
58 mTimer.Start(false);
59 o2::ctf::CTFIOSize iosize;
60
61 mCTFCoder.updateTimeDependentParams(pc, true);
62 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_ZDC");
63
64 auto& bcdata = pc.outputs().make<std::vector<o2::zdc::BCData>>(OutputRef{"trig"});
65 auto& chans = pc.outputs().make<std::vector<o2::zdc::ChannelData>>(OutputRef{"chan"});
66 auto& peds = pc.outputs().make<std::vector<o2::zdc::OrbitData>>(OutputRef{"peds"});
67
68 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
69 if (buff.size()) {
70 const auto ctfImage = o2::zdc::CTF::getImage(buff.data());
71 iosize = mCTFCoder.decode(ctfImage, bcdata, chans, peds);
72 }
73 pc.outputs().snapshot({"ctfrep", 0}, iosize);
74 mTimer.Stop();
75 LOG(info) << "Decoded " << chans.size() << " ZDC channels in " << bcdata.size() << " triggers and " << peds.size() << " pedestals, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
76}
77
79{
80 LOGF(info, "ZDC Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
81 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
82}
83
85{
86 std::vector<OutputSpec> outputs{
87 OutputSpec{{"trig"}, "ZDC", "DIGITSBC", 0, Lifetime::Timeframe},
88 OutputSpec{{"chan"}, "ZDC", "DIGITSCH", 0, Lifetime::Timeframe},
89 OutputSpec{{"peds"}, "ZDC", "DIGITSPD", 0, Lifetime::Timeframe},
90 OutputSpec{{"ctfrep"}, "ZDC", "CTFDECREP", 0, Lifetime::Timeframe}};
91
92 std::vector<InputSpec> inputs;
93 inputs.emplace_back("ctf_ZDC", "ZDC", "CTFDATA", sspec, Lifetime::Timeframe);
94 inputs.emplace_back("ctfdict_ZDC", "ZDC", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("ZDC/Calib/CTFDictionaryTree"));
95 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
96
97 return DataProcessorSpec{
98 "zdc-entropy-decoder",
99 inputs,
100 outputs,
101 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity)},
102 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
103 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
104}
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
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.
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
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
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:44
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage