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{
28EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, bool nolumi, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, ctfdictOpt), mSelIR(selIR), mNoLumi(nolumi)
29{
30 mTimer.Stop();
31 mTimer.Reset();
32}
33
35{
36 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
37 return;
38 }
39}
40
42{
43 mCTFCoder.init<CTF>(ic);
44}
45
47{
48 auto cput = mTimer.CpuTime();
49 mTimer.Start(false);
50 mCTFCoder.updateTimeDependentParams(pc, true);
51 auto digits = pc.inputs().get<gsl::span<CTPDigit>>("digits");
52 static LumiInfo lumiPrev;
53 const int maxDumRep = 5;
54 static int dumRep = 0;
55 LumiInfo lumi{};
56 if (!mNoLumi) {
57 if (pc.inputs().get<gsl::span<char>>("CTPLumi").size() == sizeof(LumiInfo)) {
58 lumiPrev = lumi = pc.inputs().get<LumiInfo>("CTPLumi");
59 } else {
60 if (dumRep < maxDumRep && lumiPrev.nHBFCounted == 0 && lumiPrev.nHBFCountedFV0 == 0) {
61 LOGP(alarm, "Previous TF lumi used to substitute dummy input is empty, warning {} of {}", ++dumRep, maxDumRep);
62 }
63 lumi = lumiPrev;
64 }
65 }
66 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"CTP", "CTFDATA", 0});
67 auto iosize = mCTFCoder.encode(buffer, digits, lumi);
68 pc.outputs().snapshot({"ctfrep", 0}, iosize);
69 mTimer.Stop();
70 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
71}
72
74{
75 LOGF(info, "CTP Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
76 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
77}
78
79DataProcessorSpec getEntropyEncoderSpec(bool selIR, bool nolumi, const std::string& ctfdictOpt)
80{
81 std::vector<InputSpec> inputs;
82 inputs.emplace_back("digits", "CTP", "DIGITS", 0, Lifetime::Timeframe);
83 if (!nolumi) {
84 inputs.emplace_back("CTPLumi", "CTP", "LUMI", 0, Lifetime::Timeframe);
85 }
86
87 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
88 inputs.emplace_back("ctfdict", "CTP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("CTP/Calib/CTFDictionaryTree"));
89 }
90 if (selIR) {
91 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
92 }
93 return DataProcessorSpec{
94 "ctp-entropy-encoder",
95 inputs,
96 Outputs{{"CTP", "CTFDATA", 0, Lifetime::Timeframe}, {{"ctfrep"}, "CTP", "CTFENCREP", 0, Lifetime::Timeframe}},
97 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, nolumi, ctfdictOpt)},
98 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
99 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
100 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
101 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
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
EntropyEncoderSpec(bool selIR, bool noLumi, const std::string &ctfdictOpt="none")
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
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, const std::string &ctfdictOpt="none")
create a processor spec
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
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