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
22#include <TStopwatch.h>
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace hmpid
29{
31{
32 public:
33 EntropyEncoderSpec(bool selIR = false, const std::string& ctfdictOpt = "none");
34 ~EntropyEncoderSpec() override = default;
36 void init(o2::framework::InitContext& ic) final;
38 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
39
40 private:
41 o2::hmpid::CTFCoder mCTFCoder;
42 bool mSelIR = false;
43 TStopwatch mTimer;
44};
45
46EntropyEncoderSpec::EntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, ctfdictOpt), mSelIR(selIR)
47{
48 mTimer.Stop();
49 mTimer.Reset();
50}
51
53{
54 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
55 return;
56 }
57}
58
60{
61 mCTFCoder.init<CTF>(ic);
62}
63
65{
66 auto cput = mTimer.CpuTime();
67 mTimer.Start(false);
68 mCTFCoder.updateTimeDependentParams(pc, true);
69 auto triggers = pc.inputs().get<gsl::span<Trigger>>("triggers");
70 auto digits = pc.inputs().get<gsl::span<Digit>>("digits");
71 if (mSelIR) {
72 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
73 }
74 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"HMP", "CTFDATA", 0});
75
76 auto iosize = mCTFCoder.encode(buffer, triggers, digits);
77 pc.outputs().snapshot({"ctfrep", 0}, iosize);
78 if (mSelIR) {
79 mCTFCoder.getIRFramesSelector().clear();
80 }
81 mTimer.Stop();
82 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
83}
84
86{
87 LOGF(info, "HMPID Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
88 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
89}
90
91DataProcessorSpec getEntropyEncoderSpec(bool selIR, const std::string& ctfdictOpt)
92{
93 std::vector<InputSpec> inputs;
94 inputs.emplace_back("triggers", "HMP", "INTRECORDS", 0, Lifetime::Timeframe);
95 inputs.emplace_back("digits", "HMP", "DIGITS", 0, Lifetime::Timeframe);
96
97 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
98 inputs.emplace_back("ctfdict", "HMP", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("HMP/Calib/CTFDictionaryTree"));
99 }
100 if (selIR) {
101 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
102 }
103 return DataProcessorSpec{
104 "hmpid-entropy-encoder",
105 inputs,
106 Outputs{{"HMP", "CTFDATA", 0, Lifetime::Timeframe},
107 {{"ctfrep"}, "HMP", "CTFENCREP", 0, Lifetime::Timeframe}},
108 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR, ctfdictOpt)},
109 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
110 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
111 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
112 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
113}
114} // namespace hmpid
115} // namespace o2
class for entropy encoding/decoding of HMPID data
Convert HMP 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 Trigger > &trigData, const gsl::span< const Digit > &digData)
entropy-encode data to buffer with CTF
Definition CTFCoder.h:62
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
EntropyEncoderSpec(bool selIR=false, const std::string &ctfdictOpt="none")
void init(o2::framework::InitContext &ic) final
~EntropyEncoderSpec() override=default
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) 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 triggers and cells of the TF
Definition CTF.h:39
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits