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 trd
29{
30
32{
33 public:
34 EntropyEncoderSpec(bool selIR);
35 ~EntropyEncoderSpec() override = default;
37 void init(o2::framework::InitContext& ic) final;
39 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final;
40
41 private:
42 o2::trd::CTFCoder mCTFCoder;
43 bool mSelIR = false;
44 TStopwatch mTimer;
45};
46
47EntropyEncoderSpec::EntropyEncoderSpec(bool selIR) : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder), mSelIR(selIR)
48{
49 mTimer.Stop();
50 mTimer.Reset();
51}
52
54{
55 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
56 return;
57 }
58}
59
61{
62 mCTFCoder.init<CTF>(ic);
63 int checkBogus = ic.options().get<int>("bogus-trigger-check");
64 mCTFCoder.setCheckBogusTrig(checkBogus < 0 ? 0x7fffffff : checkBogus);
65}
66
68{
69 auto cput = mTimer.CpuTime();
70 mTimer.Start(false);
71 mCTFCoder.updateTimeDependentParams(pc, true);
72 auto triggers = pc.inputs().get<gsl::span<TriggerRecord>>("triggers");
73 auto tracklets = pc.inputs().get<gsl::span<Tracklet64>>("tracklets");
74 auto digits = pc.inputs().get<gsl::span<Digit>>("digits");
75 mCTFCoder.setFirstTFOrbit(pc.services().get<o2::framework::TimingInfo>().firstTForbit);
76 if (mSelIR) {
77 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
78 }
79 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{"TRD", "CTFDATA", 0});
80 auto iosize = mCTFCoder.encode(buffer, triggers, tracklets, digits);
81 pc.outputs().snapshot({"ctfrep", 0}, iosize);
82 if (mSelIR) {
83 mCTFCoder.getIRFramesSelector().clear();
84 }
85 mTimer.Stop();
86 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
87}
88
90{
91 LOGF(info, "TRD Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
92 mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
93}
94
96{
97 std::vector<InputSpec> inputs;
98 inputs.emplace_back("triggers", "TRD", "TRKTRGRD", 0, Lifetime::Timeframe);
99 inputs.emplace_back("tracklets", "TRD", "TRACKLETS", 0, Lifetime::Timeframe);
100 inputs.emplace_back("digits", "TRD", "DIGITS", 0, Lifetime::Timeframe);
101 inputs.emplace_back("ctfdict", "TRD", "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec("TRD/Calib/CTFDictionaryTree"));
102 if (selIR) {
103 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
104 }
105 return DataProcessorSpec{
106 "trd-entropy-encoder",
107 inputs,
108 Outputs{{"TRD", "CTFDATA", 0, Lifetime::Timeframe},
109 {{"ctfrep"}, "TRD", "CTFENCREP", 0, Lifetime::Timeframe}},
110 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(selIR)},
111 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
112 {"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
113 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
114 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
115 {"bogus-trigger-check", VariantType::Int, 10, {"max bogus triggers to report, all if < 0"}},
116 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
117}
118
119} // namespace trd
120} // namespace o2
class for entropy encoding/decoding of TRD data
Convert TRD 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 setFirstTFOrbit(uint32_t n)
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
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.
ServiceRegistryRef services()
The services registry associated with this processing context.
void setCheckBogusTrig(int v)
Definition CTFCoder.h:52
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const TriggerRecord > &trigData, const gsl::span< const Tracklet64 > &trkData, const gsl::span< const Digit > &digData)
entropy-encode data to buffer with CTF
Definition CTFCoder.h:69
~EntropyEncoderSpec() override=default
void run(o2::framework::ProcessingContext &pc) final
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
GLuint buffer
Definition glcorearb.h:655
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
framework::DataProcessorSpec getEntropyEncoderSpec(bool selIR=false)
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:41
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits
std::vector< Tracklet64 > tracklets