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 fv0
27{
28EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, ctfdictOpt), mSelIR(selIR)
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<o2::fv0::Digit>>("digits");
52 auto channels = pc.inputs().get<gsl::span<o2::fv0::ChannelData>>("channels");
53 if (mSelIR) {
54 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
55 }
56
57 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"FV0", "CTFDATA", 0});
58 auto iosize = mCTFCoder.encode(buffer, digits, channels);
59 pc.outputs().snapshot({"ctfrep", 0}, iosize);
60 if (mSelIR) {
61 mCTFCoder.getIRFramesSelector().clear();
62 }
63 mTimer.Stop();
64 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
65}
66
68{
69 LOGF(info, "FV0 Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
70 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
71}
72
73DataProcessorSpec getEntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt)
74{
75 std::vector<InputSpec> inputs;
76 inputs.emplace_back("digits", "FV0", "DIGITSBC", 0, Lifetime::Timeframe);
77 inputs.emplace_back("channels", "FV0", "DIGITSCH", 0, Lifetime::Timeframe);
78
79 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
80 inputs.emplace_back("ctfdict", "FV0", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("FV0/Calib/CTFDictionaryTree"));
81 }
82 if (selIR) {
83 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
84 }
85 return DataProcessorSpec{
86 "fv0-entropy-encoder",
87 inputs,
88 Outputs{{"FV0", "CTFDATA", 0, Lifetime::Timeframe},
89 {{"ctfrep"}, "FV0", "CTFENCREP", 0, Lifetime::Timeframe}},
90 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, ctfdictOpt)},
91 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
92 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
93 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
94 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
95}
96} // namespace fv0
97} // namespace o2
Convert clusters streams to CTF (EncodedBlocks)
void updateTimeDependentParams(o2::framework::ProcessingContext &pc, bool askTree=false)
void init(o2::framework::InitContext &ic)
void setSelectedIRFrames(const SPAN &sp)
o2::utils::IRFrameSelector & getIRFramesSelector()
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
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.
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const Digit > &digitVec, const gsl::span< const ChannelData > &channelVec)
entropy-encode digits to buffer with CTF
Definition CTFCoder.h:66
void init(o2::framework::InitContext &ic) final
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
EntropyEncoderSpec(bool selIR, const std::string &ctfdictOpt="none")
void run(o2::framework::ProcessingContext &pc) final
GLuint buffer
Definition glcorearb.h:655
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
framework::DataProcessorSpec getEntropyEncoderSpec(bool selIR=false, const std::string &ctfdictOpt="none")
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:62
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< ChannelData > channels
std::vector< Digit > digits