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
15
16#include <vector>
17
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace zdc
29{
30EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, ctfdictOpt), mSelIR(selIR)
31{
32 mTimer.Stop();
33 mTimer.Reset();
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 mCTFCoder.updateTimeDependentParams(pc, true);
53 auto bcdata = pc.inputs().get<gsl::span<o2::zdc::BCData>>("trig");
54 auto chans = pc.inputs().get<gsl::span<o2::zdc::ChannelData>>("chan");
55 auto peds = pc.inputs().get<gsl::span<o2::zdc::OrbitData>>("peds");
56 if (mSelIR) {
57 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
58 }
59
60 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"ZDC", "CTFDATA", 0});
61 auto iosize = mCTFCoder.encode(buffer, bcdata, chans, peds);
62 pc.outputs().snapshot({"ctfrep", 0}, iosize);
63 if (mSelIR) {
64 mCTFCoder.getIRFramesSelector().clear();
65 }
66 mTimer.Stop();
67 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
68}
69
71{
72 LOGF(info, "ZDC Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
73 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
74}
75
76DataProcessorSpec getEntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt)
77{
78 std::vector<InputSpec> inputs;
79 inputs.emplace_back("trig", "ZDC", "DIGITSBC", 0, Lifetime::Timeframe);
80 inputs.emplace_back("chan", "ZDC", "DIGITSCH", 0, Lifetime::Timeframe);
81 inputs.emplace_back("peds", "ZDC", "DIGITSPD", 0, Lifetime::Timeframe);
82
83 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
84 inputs.emplace_back("ctfdict", "ZDC", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("ZDC/Calib/CTFDictionaryTree"));
85 }
86 if (selIR) {
87 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
88 }
89 return DataProcessorSpec{
90 "zdc-entropy-encoder",
91 inputs,
92 Outputs{{"ZDC", "CTFDATA", 0, Lifetime::Timeframe},
93 {{"ctfrep"}, "ZDC", "CTFENCREP", 0, Lifetime::Timeframe}},
94 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, ctfdictOpt)},
95 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
96 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
97 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
98 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
99}
100} // namespace zdc
101} // namespace o2
Convert ZDC data 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 BCData > &trgData, const gsl::span< const ChannelData > &chanData, const gsl::span< const OrbitData > &pedData)
entropy-encode data to buffer with CTF
Definition CTFCoder.h:67
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
EntropyEncoderSpec(bool selIR, const std::string &ctfdictOpt="none")
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(o2::framework::InitContext &ic) 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
struct o2::upgrades_utils::@462 zdc
structure to keep FT0 information
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 triggers and cells of the TF
Definition CTF.h:44
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"