Project
Loading...
Searching...
No Matches
EntropyEncoderSpec.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 ctp
27{
28
29EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, bool nolumi) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder), mSelIR(selIR), mNoLumi(nolumi)
30{
31 mTimer.Stop();
32 mTimer.Reset();
33}
34
36{
37 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
38 return;
39 }
40}
41
43{
44 mCTFCoder.init<CTF>(ic);
45}
46
48{
49 auto cput = mTimer.CpuTime();
50 mTimer.Start(false);
51 mCTFCoder.updateTimeDependentParams(pc, true);
52 auto digits = pc.inputs().get<gsl::span<CTPDigit>>("digits");
53 static LumiInfo lumiPrev;
54 const int maxDumRep = 5;
55 static int dumRep = 0;
56 LumiInfo lumi{};
57 if (!mNoLumi) {
58 if (pc.inputs().get<gsl::span<char>>("CTPLumi").size() == sizeof(LumiInfo)) {
59 lumiPrev = lumi = pc.inputs().get<LumiInfo>("CTPLumi");
60 } else {
61 if (dumRep < maxDumRep && lumiPrev.nHBFCounted == 0 && lumiPrev.nHBFCountedFV0 == 0) {
62 LOGP(alarm, "Previous TF lumi used to substitute dummy input is empty, warning {} of {}", ++dumRep, maxDumRep);
63 }
64 lumi = lumiPrev;
65 }
66 }
67 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"CTP", "CTFDATA", 0});
68 auto iosize = mCTFCoder.encode(buffer, digits, lumi);
69 pc.outputs().snapshot({"ctfrep", 0}, iosize);
70 mTimer.Stop();
71 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
72}
73
75{
76 LOGF(info, "CTP Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
77 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
78}
79
81{
82 std::vector<InputSpec> inputs;
83 inputs.emplace_back("digits", "CTP", "DIGITS", 0, Lifetime::Timeframe);
84 if (!nolumi) {
85 inputs.emplace_back("CTPLumi", "CTP", "LUMI", 0, Lifetime::Timeframe);
86 }
87 inputs.emplace_back("ctfdict", "CTP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/CTFDictionaryTree"));
88 if (selIR) {
89 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
90 }
91 return DataProcessorSpec{
92 "ctp-entropy-encoder",
93 inputs,
94 Outputs{{"CTP", "CTFDATA", 0, Lifetime::Timeframe}, {{"ctfrep"}, "CTP", "CTFENCREP", 0, Lifetime::Timeframe}},
95 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, nolumi)},
96 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
97 {"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
98 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
99 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
100 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
101}
102
103} // namespace ctp
104} // namespace o2
Convert CTP data to CTF (EncodedBlocks)
void updateTimeDependentParams(o2::framework::ProcessingContext &pc, bool askTree=false)
void init(o2::framework::InitContext &ic)
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const CTPDigit > &data, const LumiInfo &lumi)
entropy-encode data to buffer with CTF
Definition CTFCoder.h:76
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
add CTP related shifts
Definition CTFCoder.h:245
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
EntropyEncoderSpec(bool selIR, bool noLumi)
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(o2::framework::InitContext &ic) final
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.
GLuint buffer
Definition glcorearb.h:655
GLsizeiptr size
Definition glcorearb.h:659
framework::DataProcessorSpec getEntropyEncoderSpec(bool selIR=false, bool noLumiInput=false)
create a processor spec
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
std::vector< OutputSpec > Outputs
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
wrapper for the Entropy-encoded trigger inputs and classes of the TF
Definition CTF.h:45
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
LumiInfo lumi
std::vector< Digit > digits