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{
30EntropyEncoderSpec::EntropyEncoderSpec(o2::header::DataOrigin orig, bool selIR, const std::string& ctfdictOpt)
31 : mOrigin(orig), mCTFCoder(o2::ctf::CTFCoderBase::OpType::Encoder, orig == o2::header::gDataOriginITS ? o2::detectors::DetID::ITS : o2::detectors::DetID::MFT, ctfdictOpt), mSelIR(selIR)
32{
34 mTimer.Stop();
35 mTimer.Reset();
36}
37
39{
40 mCTFCoder.init<CTF>(ic);
41}
42
44{
46 mTimer.Reset();
47 }
48 auto cput = mTimer.CpuTime();
49 mTimer.Start(false);
51
52 auto compClusters = pc.inputs().get<gsl::span<o2::itsmft::CompClusterExt>>("compClusters");
53 auto pspan = pc.inputs().get<gsl::span<unsigned char>>("patterns");
54 auto rofs = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("ROframes");
55 if (mSelIR) {
56 mCTFCoder.setSelectedIRFrames(pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("selIRFrames"));
57 }
58 auto& buffer = pc.outputs().make<std::vector<o2::ctf::BufferType>>(Output{mOrigin, "CTFDATA", 0});
59 auto iosize = mCTFCoder.encode(buffer, rofs, compClusters, pspan, mPattIdConverter, mStrobeLength);
60 pc.outputs().snapshot({"ctfrep", 0}, iosize);
61 if (mSelIR) {
62 mCTFCoder.getIRFramesSelector().clear();
63 }
64 mTimer.Stop();
65 LOG(info) << iosize.asString() << " in " << mTimer.CpuTime() - cput << " s";
66}
67
69{
70 LOGF(info, "%s Entropy Encoding total timing: Cpu: %.3e Real: %.3e s in %d slots",
71 mOrigin.as<std::string>(), mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
72}
73
75{
76 mCTFCoder.updateTimeDependentParams(pc, true);
77 if (pc.services().get<o2::framework::TimingInfo>().globalRunNumberChanged) { // this params need to be queried only once
78 if (mSelIR) {
80 if (mOrigin == o2::header::gDataOriginITS) {
82 } else {
84 }
85 }
86 }
87}
88
90{
91 if (matcher == ConcreteDataMatcher(mOrigin, "CLUSDICT", 0)) {
92 LOG(info) << mOrigin.as<std::string>() << " cluster dictionary updated";
93 mPattIdConverter.setDictionary((const TopologyDictionary*)obj);
94 return;
95 }
96 // Note: strictly speaking, for Configurable params we don't need finaliseCCDB check, the singletons are updated at the CCDB fetcher level
97 if (matcher == ConcreteDataMatcher(mOrigin, "ALPIDEPARAM", 0)) {
98 LOG(info) << "Alpide param updated";
99 if (mOrigin == o2::header::gDataOriginITS) {
101 mStrobeLength = par.roFrameLengthInBC;
102 } else {
104 mStrobeLength = par.roFrameLengthInBC;
105 }
106 return;
107 }
108
109 if (mCTFCoder.finaliseCCDB<CTF>(matcher, obj)) {
110 return;
111 }
112}
113
114DataProcessorSpec getEntropyEncoderSpec(o2::header::DataOrigin orig, bool selIR, const std::string& ctfdictOpt)
115{
116 std::vector<InputSpec> inputs;
117 inputs.emplace_back("compClusters", orig, "COMPCLUSTERS", 0, Lifetime::Timeframe);
118 inputs.emplace_back("patterns", orig, "PATTERNS", 0, Lifetime::Timeframe);
119 inputs.emplace_back("ROframes", orig, "CLUSTERSROF", 0, Lifetime::Timeframe);
120 if (selIR) {
121 inputs.emplace_back("selIRFrames", "CTF", "SELIRFRAMES", 0, Lifetime::Timeframe);
122 inputs.emplace_back("cldict", orig, "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/ClusterDictionary", orig.as<std::string>())));
123 inputs.emplace_back("alppar", orig, "ALPIDEPARAM", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Config/AlpideParam", orig.as<std::string>())));
124 }
125
126 if (ctfdictOpt.empty() || ctfdictOpt == "ccdb") {
127 inputs.emplace_back("ctfdict", orig, "CTFDICT", 0, Lifetime::Condition, ccdbParamSpec(fmt::format("{}/Calib/CTFDictionaryTree", orig.as<std::string>())));
128 }
129 return DataProcessorSpec{
130 orig == o2::header::gDataOriginITS ? "its-entropy-encoder" : "mft-entropy-encoder",
131 inputs,
132 Outputs{{orig, "CTFDATA", 0, Lifetime::Timeframe},
133 {{"ctfrep"}, orig, "CTFENCREP", 0, Lifetime::Timeframe}},
134 AlgorithmSpec{adaptFromTask<EntropyEncoderSpec>(orig, selIR, ctfdictOpt)},
135 Options{{"irframe-margin-bwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame lower boundary when selection is requested"}},
136 {"irframe-margin-fwd", VariantType::UInt32, 0u, {"margin in BC to add to the IRFrame upper boundary when selection is requested"}},
137 {"mem-factor", VariantType::Float, 1.f, {"Memory allocation margin factor"}},
138 {"ans-version", VariantType::String, {"version of ans entropy coder implementation to use"}}}};
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)
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.
EntropyEncoderSpec(o2::header::DataOrigin orig, bool selIR, const std::string &ctfdictOpt="none")
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.
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, 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 ...
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"