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{
28
29EntropyDecoderSpec::EntropyDecoderSpec(int verbosity) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Decoder)
30{
31 mTimer.Stop();
32 mTimer.Reset();
33 mCTFCoder.setVerbosity(verbosity);
34 mCTFCoder.setDictBinding("ctfdict_TOF");
35}
36
38{
39 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
40 return;
41 }
42}
43
45{
46 mCTFCoder.init<CTF>(ic);
47}
48
50{
51 auto cput = mTimer.CpuTime();
52 mTimer.Start(false);
53 o2::ctf::CTFIOSize iosize;
54
55 mCTFCoder.updateTimeDependentParams(pc, true);
56 auto buff = pc.inputs().get<gsl::span<o2::ctf::BufferType>>("ctf_TOF");
57
58 auto& digitheader = pc.outputs().make<DigitHeader>(OutputRef{"digitheader"});
59 auto& digits = pc.outputs().make<std::vector<Digit>>(OutputRef{"digits"});
60 auto& row = pc.outputs().make<std::vector<ReadoutWindowData>>(OutputRef{"row"});
61 auto& patterns = pc.outputs().make<std::vector<uint8_t>>(OutputRef{"patterns"});
62 // auto& diagnostic = pc.outputs().make<o2::tof::Diagnostic>(OutputRef{"diafreq"});
63
64 // since the buff is const, we cannot use EncodedBlocks::relocate directly, instead we wrap its data to another flat object
65 if (buff.size()) {
66 const auto ctfImage = o2::tof::CTF::getImage(buff.data());
67 iosize = mCTFCoder.decode(ctfImage, row, digits, patterns);
68 }
69
70 // fill diagnostic frequencies
71 mFiller.clearCounts();
72 for (auto digit : digits) {
73 mFiller.addCount(digit.getChannel());
74 }
75 mFiller.setReadoutWindowData(row, patterns);
77 auto diagnostic = mFiller.getDiagnosticFrequency();
78 auto creationTime = pc.services().get<o2::framework::TimingInfo>().creation;
79 diagnostic.setTimeStamp(creationTime / 1000);
80 // add TFIDInfo
83 diagnostic.setTFIDInfo(tfinfo);
84 pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "DIAFREQ", 0}, diagnostic);
85 pc.outputs().snapshot({"ctfrep", 0}, iosize);
86 mTimer.Stop();
87 LOG(info) << "Decoded " << digits.size() << " digits in " << row.size() << " ROF, (" << iosize.asString() << ") in " << mTimer.CpuTime() - cput << " s";
88}
89
91{
92 LOGF(info, "TOF Entropy Decoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
93 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
94}
95
97{
98 std::vector<OutputSpec> outputs{
99 OutputSpec{{"digitheader"}, o2::header::gDataOriginTOF, "DIGITHEADER", 0, Lifetime::Timeframe},
100 OutputSpec{{"digits"}, o2::header::gDataOriginTOF, "DIGITS", 0, Lifetime::Timeframe},
101 OutputSpec{{"row"}, o2::header::gDataOriginTOF, "READOUTWINDOW", 0, Lifetime::Timeframe},
102 OutputSpec{{"patterns"}, o2::header::gDataOriginTOF, "PATTERNS", 0, Lifetime::Timeframe},
103 OutputSpec{{"diafreq"}, o2::header::gDataOriginTOF, "DIAFREQ", 0, Lifetime::Timeframe},
104 OutputSpec{{"ctfrep"}, o2::header::gDataOriginTOF, "CTFDECREP", 0, Lifetime::Timeframe}};
105
106 std::vector<InputSpec> inputs;
107 inputs.emplace_back("ctf_TOF", "TOF", "CTFDATA", sspec, Lifetime::Timeframe);
108 inputs.emplace_back("ctfdict_TOF", "TOF", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("TOF/Calib/CTFDictionaryTree"));
109 inputs.emplace_back("trigoffset", "CTP", "Trig_Offset", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/TriggerOffsets"));
110
111 return DataProcessorSpec{
112 "tof-entropy-decoder",
113 inputs,
114 outputs,
115 AlgorithmSpec{adaptFromTask<EntropyDecoderSpec>(verbosity)},
116 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
117 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
118}
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
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.
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
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 ...
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