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 tof
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.setDictBinding("ctfdict_TOF");
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_TOF");
56
57 auto& digitheader = pc.outputs().make<DigitHeader>(OutputRef{"digitheader"});
58 auto& digits = pc.outputs().make<std::vector<Digit>>(OutputRef{"digits"});
59 auto& row = pc.outputs().make<std::vector<ReadoutWindowData>>(OutputRef{"row"});
60 auto& patterns = pc.outputs().make<std::vector<uint8_t>>(OutputRef{"patterns"});
61 // auto& diagnostic = pc.outputs().make<o2::tof::Diagnostic>(OutputRef{"diafreq"});
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::tof::CTF::getImage(buff.data());
66 iosize = mCTFCoder.decode(ctfImage, row, digits, patterns);
67 }
68
69 // fill diagnostic frequencies
70 mFiller.clearCounts();
71 for (auto digit : digits) {
72 mFiller.addCount(digit.getChannel());
73 }
74 mFiller.setReadoutWindowData(row, patterns);
76 auto diagnostic = mFiller.getDiagnosticFrequency();
77 auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation;
78 diagnostic.setTimeStamp(creationTime / 1000);
79 // add TFIDInfo
82 diagnostic.setTFIDInfo(tfinfo);
83 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIAFREQ", 0}, diagnostic);
84 pc.outputs().snapshot({"ctfrep", 0}, iosize);
85 mTimer.Stop();
86 LOG(info) << "Decoded " << digits.size() << " digits in " << row.size() << " ROF, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
87}
88
90{
91 LOGF(info, "TOF Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
92 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
93}
94
95DataProcessorSpec getEntropyDecoderSpec(int verbosity, unsigned int sspec, const std::string& ctfdictOpt)
96{
97 std::vector<OutputSpec> outputs{
98 OutputSpec{{"digitheader"}, o2::header::gDataOriginTOF, "DIGITHEADER", 0, Lifetime::Timeframe},
99 OutputSpec{{"digits"}, o2::header::gDataOriginTOF, "DIGITS", 0, Lifetime::Timeframe},
100 OutputSpec{{"row"}, o2::header::gDataOriginTOF, "READOUTWINDOW", 0, Lifetime::Timeframe},
101 OutputSpec{{"patterns"}, o2::header::gDataOriginTOF, "PATTERNS", 0, Lifetime::Timeframe},
102 OutputSpec{{"diafreq"}, o2::header::gDataOriginTOF, "DIAFREQ", 0, Lifetime::Timeframe},
103 OutputSpec{{"ctfrep"}, o2::header::gDataOriginTOF, "CTFDECREP", 0, Lifetime::Timeframe}};
104
105 std::vector<InputSpec> inputs;
106 inputs.emplace_back("ctf_TOF", "TOF", "CTFDATA", sspec, Lifetime::Timeframe);
107
108 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
109 inputs.emplace_back("ctfdict_TOF", "TOF", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/CTFDictionaryTree"));
110 }
111 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
112
113 return DataProcessorSpec{
114 "tof-entropy-decoder",
115 inputs,
116 outputs,
117 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity, ctfdictOpt)},
118 Options{{"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
119}
120} // namespace tof
121} // namespace o2
#define verbosity
Convert CTF (EncodedBlocks) to FT0 digit/channels strean.
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
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.
ServiceRegistryRef services()
The services registry associated with this processing context.
o2::ctf::CTFIOSize decode(const CTF::base &ec, VROF &rofRecVec, VDIG &cdigVec, VPAT &pattVec)
entropy decode clusters from buffer with CTF
Definition CTFCoder.h:119
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
EntropyDecoderSpec(int verbosity, const std::string &ctfdictOpt="none")
Diagnostic & getDiagnosticFrequency()
void addCount(int channel)
void setReadoutWindowData(const VROF &row, const VPAT &pattern)
Decoder class for TOF.
Definition Decoder.h:39
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:575
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
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 ...
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
std::string asString() const
Definition CTFIOSize.cxx:19
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:81
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
auto * ctfImage
std::vector< Digit > digits
std::vector< int > row