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
31template <int N>
32std::string EntropyEncoderSpec<N>::getBinding(const std::string& name, int spec)
33{
34 return fmt::format("{}_{}", name, spec);
35}
36
37template <int N>
38EntropyEncoderSpec<N>::EntropyEncoderSpec(bool doStag, bool selIR, const std::string& ctfdictOpt)
39 : mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, doStag, ctfdictOpt),
40 mSelIR(selIR),
41 mDoStaggering(doStag)
42{
43 mTimer.Stop();
44 mTimer.Reset();
45}
46
47template <int N>
49{
50 mCTFCoder.template init<CTF>(ic);
51}
52
53template <int N>
55{
57 mTimer.Reset();
58 }
59 auto cput = mTimer.CpuTime();
60 mTimer.Start(false);
61 updateTimeDependentParams(pc);
62
63 uint32_t nLayers = mDoStaggering ? DPLAlpideParam<N>::getNLayers() : 1;
64
65 if (mSelIR) {
66 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
67 }
68 o2::ctf::CTFIOSize iosize{};
69 for (uint32_t iLayer = 0; iLayer < nLayers; iLayer++) {
70 auto compClusters = pc.inputs().get<gsl::span<o2::itsmft::CompClusterExt>>(getBinding("compClusters", iLayer));
71 auto pspan = pc.inputs().get<gsl::span<unsigned char>>(getBinding("patterns", iLayer));
72 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>(getBinding("ROframes", iLayer));
73
74 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{Origin, "CTFDATA", iLayer});
75 iosize += mCTFCoder.encode(buffer, rofs, compClusters, pspan, mPattIdConverter, iLayer);
76 }
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
85template <int N>
87{
88 LOGP(info, "{} Entropy Encoding total timing: Cpu: {:.3e} Real: {:.3e} s in {} slots",
89 Origin.as<std::string>(), mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
90}
91
92template <int N>
94{
95 mCTFCoder.updateTimeDependentParams(pc, true);
96 if (pc.services().get<o2::framework::TimingInfo>().globalRunNumberChanged) { // this params need to be queried only once
97 if (mSelIR) {
99 }
100 }
102}
103
104template <int N>
106{
107 if (matcher == ConcreteDataMatcher(Origin, "CLUSDICT", 0)) {
108 LOG(info) << Origin.as<std::string>() << " cluster dictionary updated";
109 mPattIdConverter.setDictionary((const TopologyDictionary*)obj);
110 return;
111 }
112 // Note: strictly speaking, for Configurable params we don't need finaliseCCDB check, the singletons are updated at the CCDB fetcher level
113 if (matcher == ConcreteDataMatcher(Origin, "ALPIDEPARAM", 0)) {
114 LOG(info) << "Alpide param updated";
115 return;
116 }
117
118 if (mCTFCoder.template finaliseCCDB<CTF>(matcher, obj)) {
119 return;
120 }
121}
122
123template <int N>
124DataProcessorSpec getEntropyEncoderSpec(bool doStag, bool selIR, const std::string& ctfdictOpt)
125{
128 const auto& par = DPLAlpideParam<N>::Instance();
129 uint32_t nLayers = doStag ? DPLAlpideParam<N>::getNLayers() : 1;
130
131 std::vector<InputSpec> inputs;
132 std::vector<OutputSpec> outputs;
133 for (uint32_t iLayer = 0; iLayer < nLayers; ++iLayer) {
134 inputs.emplace_back(EntropyEncoderSpec<N>::getBinding("compClusters", iLayer), Origin, "COMPCLUSTERS", iLayer, Lifetime::Timeframe);
135 inputs.emplace_back(EntropyEncoderSpec<N>::getBinding("patterns", iLayer), Origin, "PATTERNS", iLayer, Lifetime::Timeframe);
136 inputs.emplace_back(EntropyEncoderSpec<N>::getBinding("ROframes", iLayer), Origin, "CLUSTERSROF", iLayer, Lifetime::Timeframe);
137 outputs.emplace_back(Origin, "CTFDATA", iLayer, Lifetime::Timeframe);
138 }
139 if (selIR) {
140 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
141 inputs.emplace_back("cldict", Origin, "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/ClusterDictionary", Origin.as<std::string>())));
142 }
143 inputs.emplace_back("alppar", Origin, "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Config/AlpideParam", Origin.as<std::string>())));
144
145 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
146 inputs.emplace_back("ctfdict", Origin, "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/CTFDictionaryTree", Origin.as<std::string>())));
147 }
148 outputs.emplace_back(OutputSpec{{"ctfrep"}, Origin, "CTFENCREP", 0, Lifetime::Timeframe});
149 return DataProcessorSpec{
150 Origin == o2::header::gDataOriginITS ? "its-entropy-encoder" : "mft-entropy-encoder",
151 inputs,
152 outputs,
153 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec<N>>(doStag, selIR, ctfdictOpt)},
154 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
155 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
156 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
157 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
158}
159
160framework::DataProcessorSpec getITSEntropyEncoderSpec(bool doStag, bool selIR, const std::string& ctfdictOpt)
161{
162 return getEntropyEncoderSpec<o2::detectors::DetID::ITS>(doStag, selIR, ctfdictOpt);
163}
164
165framework::DataProcessorSpec getMFTEntropyEncoderSpec(bool doStag, bool selIR, const std::string& ctfdictOpt)
166{
167 return getEntropyEncoderSpec<o2::detectors::DetID::MFT>(doStag, selIR, ctfdictOpt);
168}
169
170} // namespace itsmft
171} // namespace o2
Definition of the ITSMFT compact cluster.
Convert clusters streams to CTF (EncodedBlocks)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID ITS
Definition DetID.h:63
static constexpr ID MFT
Definition DetID.h:71
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.
EntropyEncoderSpec(bool doStag, bool selIR, const std::string &ctfdictOpt="none")
void init(o2::framework::InitContext &ic) 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 updateTimeDependentParams(o2::framework::ProcessingContext &pc)
static std::string getBinding(const std::string &name, int spec)
void run(o2::framework::ProcessingContext &pc) final
GLuint buffer
Definition glcorearb.h:655
GLuint const GLchar * name
Definition glcorearb.h:781
constexpr o2::header::DataOrigin gDataOriginMFT
Definition DataHeader.h:572
constexpr o2::header::DataOrigin gDataOriginITS
Definition DataHeader.h:570
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
DataProcessorSpec getEntropyEncoderSpec(bool doStag, bool selIR, const std::string &ctfdictOpt)
framework::DataProcessorSpec getITSEntropyEncoderSpec(bool doStag=false, bool selIR=false, const std::string &ctfdictOpt="none")
create a processor spec
framework::DataProcessorSpec getMFTEntropyEncoderSpec(bool doStag=false, bool selIR=false, const std::string &ctfdictOpt="none")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr int getNLayers()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"