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
23
24using namespace o2::framework;
25
26namespace o2
27{
28namespace itsmft
29{
30
32 : mOrigin(orig), mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, orig == o2::header::gDataOriginITS ? o2::detectors::DetID::ITS : o2::detectors::DetID::MFT), mSelIR(selIR)
33{
35 mTimer.Stop();
36 mTimer.Reset();
37}
38
40{
41 mCTFCoder.init<CTF>(ic);
42}
43
45{
47 mTimer.Reset();
48 }
49 auto cput = mTimer.CpuTime();
50 mTimer.Start(false);
52
53 auto compClusters = pc.inputs().get<gsl::span<o2::itsmft::CompClusterExt>>("compClusters");
54 auto pspan = pc.inputs().get<gsl::span<unsigned char>>("patterns");
55 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
56 if (mSelIR) {
57 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
58 }
59 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{mOrigin, "CTFDATA", 0});
60 auto iosize = mCTFCoder.encode(buffer, rofs, compClusters, pspan, mPattIdConverter, mStrobeLength);
61 pc.outputs().snapshot({"ctfrep", 0}, iosize);
62 if (mSelIR) {
63 mCTFCoder.getIRFramesSelector().clear();
64 }
65 mTimer.Stop();
66 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
67}
68
70{
71 LOGF(info, "%s Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
72 mOrigin.as<std::string>(), mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
73}
74
76{
77 mCTFCoder.updateTimeDependentParams(pc, true);
78 if (pc.services().get<o2::framework::TimingInfo>().globalRunNumberChanged) { // this params need to be queried only once
79 if (mSelIR) {
81 if (mOrigin == o2::header::gDataOriginITS) {
83 } else {
85 }
86 }
87 }
88}
89
91{
92 if (matcher == ConcreteDataMatcher(mOrigin, "CLUSDICT", 0)) {
93 LOG(info) << mOrigin.as<std::string>() << " cluster dictionary updated";
94 mPattIdConverter.setDictionary((const TopologyDictionary*)obj);
95 return;
96 }
97 // Note: strictly speaking, for Configurable params we don't need finaliseCCDB check, the singletons are updated at the CCDB fetcher level
98 if (matcher == ConcreteDataMatcher(mOrigin, "ALPIDEPARAM", 0)) {
99 LOG(info) << "Alpide param updated";
100 if (mOrigin == o2::header::gDataOriginITS) {
102 mStrobeLength = par.roFrameLengthInBC;
103 } else {
105 mStrobeLength = par.roFrameLengthInBC;
106 }
107 return;
108 }
109
110 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
111 return;
112 }
113}
114
116{
117 std::vector<InputSpec> inputs;
118 inputs.emplace_back("compClusters", orig, "COMPCLUSTERS", 0, Lifetime::Timeframe);
119 inputs.emplace_back("patterns", orig, "PATTERNS", 0, Lifetime::Timeframe);
120 inputs.emplace_back("ROframes", orig, "CLUSTERSROF", 0, Lifetime::Timeframe);
121 if (selIR) {
122 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
123 inputs.emplace_back("cldict", orig, "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/ClusterDictionary", orig.as<std::string>())));
124 inputs.emplace_back("alppar", orig, "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Config/AlpideParam", orig.as<std::string>())));
125 }
126 inputs.emplace_back("ctfdict", orig, "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/CTFDictionaryTree", orig.as<std::string>())));
127 return DataProcessorSpec{
128 orig == o2::header::gDataOriginITS ? "its-entropy-encoder" : "mft-entropy-encoder",
129 inputs,
130 Outputs{{orig, "CTFDATA", 0, Lifetime::Timeframe},
131 {{"ctfrep"}, orig, "CTFENCREP", 0, Lifetime::Timeframe}},
132 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(orig, selIR)},
133 Options{{"ctf-dict", VariantType::String, "ccdb", {"CTF dictionary: empty or ccdb=CCDB, none=no external dictionary otherwise: local filename"}},
134 {"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
135 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
136 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
137 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
138}
139
140} // namespace itsmft
141} // namespace o2
Definition of the ITSMFT compact cluster.
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)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
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.
ServiceRegistryRef services()
The services registry associated with this processing context.
o2::ctf::CTFIOSize encode(VEC &buff, const gsl::span< const ROFRecord > &rofRecVec, const gsl::span< const CompClusterExt > &cclusVec, const gsl::span< const unsigned char > &pattVec, const LookUp &clPattLookup, int strobeLength)
entropy-encode clusters to buffer with CTF
Definition CTFCoder.h:88
void init(o2::framework::InitContext &ic) final
void updateTimeDependentParams(o2::framework::ProcessingContext &pc)
EntropyEncoderSpec(o2::header::DataOrigin orig, bool selIR)
void run(o2::framework::ProcessingContext &pc) final
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void setDictionary(const TopologyDictionary *dict)
Definition LookUp.cxx:42
GLuint buffer
Definition glcorearb.h:655
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:572
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
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(o2::header::DataOrigin orig, bool selIR=false)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::enable_if_t< std::is_same< T, std::string >::value==true, T > as() const
get the descriptor as std::string
Definition DataHeader.h:301
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:69
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"