Project
Loading...
Searching...
No Matches
CTFCoder.h
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
15
16#ifndef O2_ITSMFT_CTFCODER_H
17#define O2_ITSMFT_CTFCODER_H
18
19#include <algorithm>
20#include <iterator>
21#include <string>
33
34//#define _CHECK_INCREMENTES_ // Uncoment this the check the incremements being non-negative
35
36class TTree;
37
38namespace o2
39{
40namespace itsmft
41{
42
43template <int N>
44class CTFCoder final : public o2::ctf::CTFCoderBase
45{
46 public:
48
49 using PMatrix = std::array<std::array<bool, ClusterPattern::MaxRowSpan + 2>, ClusterPattern::MaxColSpan + 2>;
50 using RowColBuff = std::vector<PixelData>;
51
52 CTFCoder(o2::ctf::CTFCoderBase::OpType op, bool doStag, const std::string& ctfdictOpt = "none") : o2::ctf::CTFCoderBase(op, CTF::getNBlocks(), ID, 1.f, ctfdictOpt), mDoStaggering(doStag) {}
53 ~CTFCoder() final = default;
54
56 template <typename VEC>
57 o2::ctf::CTFIOSize encode(VEC& buff, const gsl::span<const ROFRecord>& rofRecVec, const gsl::span<const CompClusterExt>& cclusVec,
58 const gsl::span<const unsigned char>& pattVec, const LookUp& clPattLookup, int layer);
59
61 template <typename VROF, typename VCLUS, typename VPAT>
62 o2::ctf::CTFIOSize decode(const CTF::base& ec, VROF& rofRecVec, VCLUS& cclusVec, VPAT& pattVec, const NoiseMap* noiseMap, const LookUp& clPattLookup);
63
65 template <typename VROF, typename VDIG>
66 o2::ctf::CTFIOSize decode(const CTF::base& ec, VROF& rofRecVec, VDIG& digVec, const NoiseMap* noiseMap, const LookUp& clPattLookup);
67
68 void createCoders(const std::vector<char>& bufVec, o2::ctf::CTFCoderBase::OpType op) final;
69
70 private:
71 CompressedClusters decodeCompressedClusters(const CTF::base& ec, o2::ctf::CTFIOSize& sz);
72
74 void compress(CompressedClusters& compCl, const gsl::span<const ROFRecord>& rofRecVec, const gsl::span<const CompClusterExt>& cclusVec,
75 const gsl::span<const unsigned char>& pattVec, const LookUp& clPattLookup, int strobeLength);
76 size_t estimateCompressedSize(const CompressedClusters& compCl);
77
79 template <typename VROF, typename VCLUS, typename VPAT>
80 void decompress(const CompressedClusters& compCl, VROF& rofRecVec, VCLUS& cclusVec, VPAT& pattVec, const NoiseMap* noiseMap, const LookUp& clPattLookup);
81
83 template <typename VROF, typename VDIG>
84 void decompress(const CompressedClusters& compCl, VROF& rofRecVec, VDIG& digVec, const NoiseMap* noiseMap, const LookUp& clPattLookup);
85
86 void appendToTree(TTree& tree, CTF& ec, int id = -1);
87 void readFromTree(TTree& tree, int entry, int id, std::vector<ROFRecord>& rofRecVec, std::vector<CompClusterExt>& cclusVec, std::vector<unsigned char>& pattVec, const NoiseMap* noiseMap, const LookUp& clPattLookup);
88
89 bool mDoStaggering{false};
90};
91
93template <int N>
94template <typename VEC>
95o2::ctf::CTFIOSize CTFCoder<N>::encode(VEC& buff, const gsl::span<const ROFRecord>& rofRecVec, const gsl::span<const CompClusterExt>& cclusVec,
96 const gsl::span<const unsigned char>& pattVec, const LookUp& clPattLookup, int layer)
97{
99 const auto& par = DPLAlpideParam<N>::Instance();
100 int strobeLength = mDoStaggering ? par.roFrameLayerLengthInBC[layer] : par.roFrameLengthInBC;
101 // what to do which each field: see o2::ctd::Metadata explanation
102 constexpr MD optField[CTF::getNBlocks()] = {
103 MD::EENCODE_OR_PACK, // BLCfirstChipROF
104 MD::EENCODE_OR_PACK, // BLCbcIncROF
105 MD::EENCODE_OR_PACK, // BLCorbitIncROF
106 MD::EENCODE_OR_PACK, // BLCnclusROF
107 MD::EENCODE_OR_PACK, // BLCchipInc
108 MD::EENCODE_OR_PACK, // BLCchipMul
109 MD::EENCODE_OR_PACK, // BLCrow
110 MD::EENCODE_OR_PACK, // BLCcolInc
111 MD::EENCODE_OR_PACK, // BLCpattID
112 MD::EENCODE_OR_PACK // BLCpattMap
113 };
114 CompressedClusters compCl;
115 compress(compCl, rofRecVec, cclusVec, pattVec, clPattLookup, strobeLength);
116 compCl.header.maxStreams = mDoStaggering ? par.getNLayers() : 1;
117 compCl.header.streamID = mDoStaggering ? layer : 0;
118 // book output size with some margin
119 auto szIni = estimateCompressedSize(compCl);
120 buff.resize(szIni);
121
122 auto ec = CTF::create(buff);
123 using ECB = CTF::base;
124
125 ec->setHeader(compCl.header);
126 assignDictVersion(static_cast<o2::ctf::CTFDictHeader&>(ec->getHeader()));
127 ec->setANSHeader(mANSVersion);
128 // at every encoding the buffer might be autoexpanded, so we don't work with fixed pointer ec
129 o2::ctf::CTFIOSize iosize;
130#define ENCODEITSMFT(part, slot, bits) CTF::get(buff.data())->encode(part, int(slot), bits, optField[int(slot)], &buff, mCoders[int(slot)], getMemMarginFactor());
131 // clang-format off
132 iosize += ENCODEITSMFT(compCl.firstChipROF, CTF::BLCfirstChipROF, 0);
133 iosize += ENCODEITSMFT(compCl.bcIncROF, CTF::BLCbcIncROF, 0);
134 iosize += ENCODEITSMFT(compCl.orbitIncROF, CTF::BLCorbitIncROF, 0);
135 iosize += ENCODEITSMFT(compCl.nclusROF, CTF::BLCnclusROF, 0);
136 //
137 iosize += ENCODEITSMFT(compCl.chipInc, CTF::BLCchipInc, 0);
138 iosize += ENCODEITSMFT(compCl.chipMul, CTF::BLCchipMul, 0);
139 iosize += ENCODEITSMFT(compCl.row, CTF::BLCrow, 0);
140 iosize += ENCODEITSMFT(compCl.colInc, CTF::BLCcolInc, 0);
141 iosize += ENCODEITSMFT(compCl.pattID, CTF::BLCpattID, 0);
142 iosize += ENCODEITSMFT(compCl.pattMap, CTF::BLCpattMap, 0);
143 // clang-format on
144 //CTF::get(buff.data())->print(getPrefix());
145 iosize.rawIn = rofRecVec.size() * sizeof(ROFRecord) + cclusVec.size() * sizeof(CompClusterExt) + pattVec.size() * sizeof(unsigned char);
146 return iosize;
147}
148
150template <int N>
151template <typename VROF, typename VCLUS, typename VPAT>
152o2::ctf::CTFIOSize CTFCoder<N>::decode(const CTF::base& ec, VROF& rofRecVec, VCLUS& cclusVec, VPAT& pattVec, const NoiseMap* noiseMap, const LookUp& clPattLookup)
153{
154 o2::ctf::CTFIOSize iosize;
155 auto compCl = decodeCompressedClusters(ec, iosize);
156 const auto& par = DPLAlpideParam<N>::Instance();
157 uint32_t nLayers = mDoStaggering ? par.getNLayers() : 1;
158 if (compCl.header.maxStreams != nLayers) {
159 throw std::runtime_error(fmt::format("header maxStreams={} is not the same as NStreams={} in {}staggered mode", compCl.header.maxStreams, nLayers, mDoStaggering ? "" : "non-"));
160 }
161 decompress(compCl, rofRecVec, cclusVec, pattVec, noiseMap, clPattLookup);
162 iosize.rawIn = rofRecVec.size() * sizeof(ROFRecord) + cclusVec.size() * sizeof(CompClusterExt) + pattVec.size() * sizeof(unsigned char);
163 return iosize;
164}
165
167template <int N>
168template <typename VROF, typename VDIG>
169o2::ctf::CTFIOSize CTFCoder<N>::decode(const CTF::base& ec, VROF& rofRecVec, VDIG& digVec, const NoiseMap* noiseMap, const LookUp& clPattLookup)
170{
171 o2::ctf::CTFIOSize iosize;
172 auto compCl = decodeCompressedClusters(ec, iosize);
173 decompress(compCl, rofRecVec, digVec, noiseMap, clPattLookup);
174 iosize.rawIn += rofRecVec.size() * sizeof(ROFRecord) + digVec.size() * sizeof(Digit);
175 return iosize;
176}
177
179template <int N>
180template <typename VROF, typename VCLUS, typename VPAT>
181void CTFCoder<N>::decompress(const CompressedClusters& compCl, VROF& rofRecVec, VCLUS& cclusVec, VPAT& pattVec, const NoiseMap* noiseMap, const LookUp& clPattLookup)
182{
183 PMatrix pmat{};
184 RowColBuff firedPixBuff{}, maskedPixBuff{};
185 rofRecVec.resize(compCl.header.nROFs);
186 cclusVec.clear();
187 cclusVec.reserve(compCl.header.nClusters);
188 pattVec.clear();
189 pattVec.reserve(compCl.header.nPatternBytes);
191 uint32_t clCount = 0, chipCount = 0;
192 auto pattIt = compCl.pattMap.begin();
193 auto pattItStored = pattIt;
194
195 // >> ====== Helper functions for reclusterization after masking some pixels in decoded clusters ======
196 // clusterize the pmat matrix holding pixels of the single cluster after masking the noisy ones
197
198 auto clusterize = [&](uint16_t chipID, int16_t row, int16_t col, int leftFired) {
199#ifdef _ALLOW_DIAGONAL_ALPIDE_CLUSTERS_
200 const std::array<int16_t, 8> walkRow = {1, -1, 0, 0, 1, 1, -1, -1};
201 const std::array<int16_t, 8> walkCol = {0, 0, -1, 1, 1, -1, 1, 1};
202#else
203 const std::array<int16_t, 4> walkRow = {1, -1, 0, 0};
204 const std::array<int16_t, 4> walkCol = {0, 0, -1, 1};
205#endif
206 Clusterer::BBox bbox(chipID);
207 // check and add to new cluster seed fired pixels around ir1, ic1, return true if there are still fired pixels left
208 std::function<bool(int16_t, int16_t)> checkPixelAndNeighbours = [&](int16_t ir1, int16_t ic1) {
209 // if pixel in pmat is fired, add it to new cluster seed and adjust the BBox, decreasing the number of fired pixels left
210 auto checkPixel = [&](int16_t ir1, int16_t ic1) {
211 if (pmat[ir1][ic1]) {
212 pmat[ir1][ic1] = false;
213 uint16_t r = row + ir1 - 1, c = col + ic1 - 1;
214 firedPixBuff.emplace_back(r, c);
215 bbox.adjust(r, c);
216 leftFired--;
217 return true;
218 }
219 return false;
220 };
221 // check and add to new cluster seed fired pixels at and around ir1, ic1, return true if there are still fired pixels left
222 if (checkPixel(ir1, ic1) && leftFired) {
223 uint16_t iw = 0;
224 while (checkPixelAndNeighbours(ir1 + walkRow[iw], ic1 + walkCol[iw]) && ++iw < walkRow.size()) {
225 }
226 }
227 return leftFired;
228 };
229 // true will be returned if after incremental check of neighbours fired pixels are still left
230
231 firedPixBuff.clear(); // start new cluster seed
232 for (auto s : maskedPixBuff) { // we start checking from the holes remaining from the masked pixels
233 uint16_t iw = 0;
234 do {
235 checkPixelAndNeighbours(s.getRowDirect() + walkRow[iw], s.getCol() + walkCol[iw]);
236 if (!firedPixBuff.empty()) {
237 bbox.chipID = chipID;
238 Clusterer::streamCluster(firedPixBuff, nullptr, bbox, clPattLookup, &cclusVec, &pattVec, nullptr, 0);
239 firedPixBuff.clear();
240 bbox.clear();
241 }
242 } while (leftFired && ++iw < walkRow.size());
243 if (!leftFired) {
244 break;
245 }
246 }
247 };
248
249 auto reclusterize = [&]() {
250 auto clus = cclusVec.back(); // original newly added cluster
251 // acquire pattern
253 auto pattItPrev = pattIt;
254 maskedPixBuff.clear();
255 int rowRef = clus.getRow(), colRef = clus.getCol();
256 if (clPattLookup.size() == 0 && clus.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) {
257 throw std::runtime_error("Clusters contain pattern IDs, but no dictionary is provided...");
258 }
259 if (clus.getPatternID() == o2::itsmft::CompCluster::InvalidPatternID) {
260 patt.acquirePattern(pattIt);
261 } else if (clPattLookup.isGroup(clus.getPatternID())) {
262 patt.acquirePattern(pattIt);
263 float xCOG = 0, zCOG = 0;
264 patt.getCOG(xCOG, zCOG); // for grouped patterns the reference pixel is at COG
265 rowRef -= round(xCOG);
266 colRef -= round(zCOG);
267 } else {
268 patt = clPattLookup.getPattern(clus.getPatternID());
269 }
270 int rowSpan = patt.getRowSpan(), colSpan = patt.getColumnSpan(), nMasked = 0;
271 if (rowSpan == 1 && colSpan == 1) { // easy case: 1 pixel cluster
272 if (noiseMap->isNoisy(clus.getChipID(), rowRef, colRef)) { // just kill the cluster
273 std::copy(pattItStored, pattItPrev, back_inserter(pattVec)); // save patterns from after last saved to the one before killing this
274 pattItStored = pattIt; // advance to the head of the pattern iterator
275 cclusVec.pop_back();
276 }
277 // otherwise do nothing: cluster was already added, eventual patterns will be copied in large block at next modified cluster writing
278 } else {
279 int rowSpan = patt.getRowSpan(), colSpan = patt.getColumnSpan(), nMasked = 0, nPixels = 0; // apply noise and fill hits matrix
280 for (int ir = 0; ir < rowSpan; ir++) {
281 int row = rowRef + ir;
282 for (int ic = 0; ic < colSpan; ic++) {
283 if (patt.isSet(ir, ic)) {
284 if (noiseMap->isNoisy(clus.getChipID(), row, colRef + ic)) {
285 maskedPixBuff.emplace_back(ir + 1, ic + 1);
286 pmat[ir + 1][ic + 1] = false; // reset since might be left from prev cluster
287 nMasked++;
288 } else {
289 pmat[ir + 1][ic + 1] = true;
290 nPixels++;
291 }
292 } else {
293 pmat[ir + 1][ic + 1] = false; // reset since might be left from prev cluster
294 }
295 }
296 }
297
298 if (nMasked) {
299 cclusVec.pop_back(); // remove added cluster
300 std::copy(pattItStored, pattItPrev, back_inserter(pattVec)); // save patterns from after last saved to the one before killing this
301 pattItStored = pattIt; // advance to the head of the pattern iterator
302 if (nPixels) { // need to reclusterize remaining pixels
303 clusterize(clus.getChipID(), rowRef, colRef, nPixels);
304 }
305 }
306 }
307 };
308 // << ====== Helper functions for reclusterization after masking some pixels in decoded clusters ======
309
310 for (uint32_t irof = 0; irof < compCl.header.nROFs; irof++) {
311 // restore ROFRecord
312 auto& rofRec = rofRecVec[irof];
313 if (compCl.orbitIncROF[irof]) { // new orbit
314 prevIR.bc = compCl.bcIncROF[irof]; // bcInc has absolute meaning
315 prevIR.orbit += compCl.orbitIncROF[irof];
316 } else {
317 prevIR.bc += compCl.bcIncROF[irof];
318 }
319 rofRec.setBCData(prevIR);
320 rofRec.setFirstEntry(cclusVec.size());
321
322 // resrore chips data
323 auto chipID = compCl.firstChipROF[irof];
324 uint16_t col = 0;
325 int inChip = 0;
326 for (uint32_t icl = 0; icl < compCl.nclusROF[irof]; icl++) {
327 auto& clus = cclusVec.emplace_back();
328 if (inChip++ < compCl.chipMul[chipCount]) { // still the same chip
329 clus.setCol((col += compCl.colInc[clCount]));
330 } else { // new chip starts
331 chipID += compCl.chipInc[++chipCount];
332 inChip = 1;
333 clus.setCol((col = compCl.colInc[clCount])); // colInc has abs. col meaning
334 }
335 clus.setRow(compCl.row[clCount]);
336 clus.setPatternID(compCl.pattID[clCount]);
337 clus.setChipID(chipID);
338 if (noiseMap) { // noise masking was requested
339 reclusterize();
340 }
341 clCount++;
342 }
343 if (compCl.nclusROF[irof]) {
344 chipCount++; // since next chip for sure will be new and inChip will be 0...
345 }
346 rofRec.setNEntries(cclusVec.size() - rofRec.getFirstEntry());
347 }
348 if (noiseMap) { // reclusterization was requested
349 if (pattItStored != pattIt) { // copy unsaved patterns
350 std::copy(pattItStored, pattIt, back_inserter(pattVec));
351 }
352 } else { // copy decoded patterns as they are
353 pattVec.resize(compCl.header.nPatternBytes);
354 memcpy(pattVec.data(), compCl.pattMap.data(), compCl.header.nPatternBytes);
355 }
356 assert(chipCount == compCl.header.nChips);
357
358 if (clCount != compCl.header.nClusters) {
359 LOG(error) << "expected " << compCl.header.nClusters << " but counted " << clCount << " in ROFRecords";
360 throw std::runtime_error("mismatch between expected and counter number of clusters");
361 }
362}
363
365template <int N>
366template <typename VROF, typename VDIG>
367void CTFCoder<N>::decompress(const CompressedClusters& compCl, VROF& rofRecVec, VDIG& digVec, const NoiseMap* noiseMap, const LookUp& clPattLookup)
368{
369 rofRecVec.resize(compCl.header.nROFs);
370 digVec.reserve(compCl.header.nClusters * 2);
371 o2::InteractionRecord prevIR(compCl.header.firstBC, compCl.header.firstOrbit);
372 uint32_t clCount = 0, chipCount = 0;
373 auto pattIt = compCl.pattMap.begin();
375 for (uint32_t irof = 0; irof < compCl.header.nROFs; irof++) {
376 size_t chipStartNDig = digVec.size();
377 // restore ROFRecord
378 auto& rofRec = rofRecVec[irof];
379 if (compCl.orbitIncROF[irof]) { // new orbit
380 prevIR.bc = compCl.bcIncROF[irof]; // bcInc has absolute meaning
381 prevIR.orbit += compCl.orbitIncROF[irof];
382 } else {
383 prevIR.bc += compCl.bcIncROF[irof];
384 }
385 rofRec.setBCData(prevIR);
386 rofRec.setFirstEntry(digVec.size());
387
388 // resrore chips data
389 uint16_t chipID = compCl.firstChipROF[irof], col = 0;
390 int inChip = 0;
391 for (uint32_t icl = 0; icl < compCl.nclusROF[irof]; icl++) {
392 if (inChip++ < compCl.chipMul[chipCount]) { // still the same chip
393 col += compCl.colInc[clCount];
394 } else { // new chip starts
395 // sort digits of previous chip in col/row
396 auto added = digVec.size() - chipStartNDig;
397 if (added > 1) { // we need to sort digits in colums and in rows within a column
398 std::sort(digVec.end() - added, digVec.end(),
399 [](Digit& a, Digit& b) { return a.getColumn() < b.getColumn() || (a.getColumn() == b.getColumn() && a.getRow() < b.getRow()); });
400 }
401 chipStartNDig = digVec.size();
402 chipID += compCl.chipInc[++chipCount];
403#ifdef _CHECK_INCREMENTES_
404 if (int16_t(compCl.chipInc[chipCount]) < 0) {
405 LOG(warning) << "Negative chip increment " << int16_t(compCl.chipInc[chipCount]) << " -> " << chipID;
406 }
407#endif
408 inChip = 1;
409 col = compCl.colInc[clCount]; // colInc has abs. col meaning
410 }
411 uint16_t rowRef = compCl.row[clCount], colRef = col;
412 auto pattID = compCl.pattID[clCount];
414 patt.acquirePattern(pattIt);
415 } else {
416 if (clPattLookup.size() == 0) {
417 throw std::runtime_error("Clusters contain pattern IDs, but no dictionary is provided...");
418 }
420 patt.acquirePattern(pattIt);
421 } else if (clPattLookup.isGroup(pattID)) {
422 patt.acquirePattern(pattIt);
423 float xCOG = 0., zCOG = 0.;
424 patt.getCOG(xCOG, zCOG); // for grouped patterns the reference pixel is at COG
425 rowRef -= round(xCOG);
426 colRef -= round(zCOG);
427 } else {
428 patt = clPattLookup.getPattern(pattID);
429 }
430 }
431 clCount++;
432
433 auto fillRowCol = [&digVec, chipID, rowRef, colRef, noiseMap](int r, int c) {
434 r += rowRef;
435 c += colRef;
436 if (noiseMap && noiseMap->isNoisy(chipID, r, c)) {
437 return;
438 }
439 digVec.emplace_back(chipID, uint16_t(r), uint16_t(c));
440 };
441 patt.process(fillRowCol);
442 }
443 auto added = digVec.size() - chipStartNDig;
444 if (added > 1) { // Last chip of the ROF: we need to sort digits in colums and in rows within a column
445 std::sort(digVec.end() - added, digVec.end(),
446 [](Digit& a, Digit& b) { return a.getColumn() < b.getColumn() || (a.getColumn() == b.getColumn() && a.getRow() < b.getRow()); });
447 }
448
449 if (compCl.nclusROF[irof]) {
450 chipCount++; // since next chip for sure will be new and incChip will be 0...
451 }
452 rofRec.setNEntries(digVec.size() - rofRec.getFirstEntry());
453 }
454 // explicit patterns
455 assert(pattIt == compCl.pattMap.end());
456 assert(chipCount == compCl.header.nChips);
457
458 if (clCount != compCl.header.nClusters) {
459 LOG(error) << "expected " << compCl.header.nClusters << " but counted " << clCount << " in ROFRecords";
460 throw std::runtime_error("mismatch between expected and counter number of clusters");
461 }
462}
463
464} // namespace itsmft
465} // namespace o2
466
467#endif // O2_ITSMFT_CTFCODER_H
Declarations for CTFCoderBase class (support of external dictionaries)
Definition of the ITSMFT compact cluster.
Definition of the ITSMFT digit.
uint32_t op
Definitions for ITS/MFT CTF data.
Definition of the ITSMFT ROFrame (trigger) record.
#define ENCODEITSMFT(part, slot, bits)
Definition of the ITS cluster finder.
Definition of the LookUp class.
Definition of the ITSMFT NoiseMap.
Transient data classes for single pixel and set of pixels from current chip.
uint32_t col
Definition RawData.h:4
uint32_t c
Definition RawData.h:2
<<======================== Auxiliary classes =======================<<
EncodedBlocks< CTFHeader, N, uint32_t > base
static auto create(void *head, size_t sz)
create container from arbitrary buffer of predefined size (in bytes!!!). Head is supposed to respect ...
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 createCoders(const std::vector< char > &bufVec, o2::ctf::CTFCoderBase::OpType op) final
Definition CTFCoder.cxx:198
~CTFCoder() final=default
static constexpr o2::detectors::DetID ID
Definition CTFCoder.h:47
std::array< std::array< bool, ClusterPattern::MaxRowSpan+2 >, ClusterPattern::MaxColSpan+2 > PMatrix
Definition CTFCoder.h:49
CTFCoder(o2::ctf::CTFCoderBase::OpType op, bool doStag, const std::string &ctfdictOpt="none")
Definition CTFCoder.h:52
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 layer)
entropy-encode clusters to buffer with CTF
Definition CTFCoder.h:95
std::vector< PixelData > RowColBuff
Definition CTFCoder.h:50
o2::ctf::CTFIOSize decode(const CTF::base &ec, VROF &rofRecVec, VCLUS &cclusVec, VPAT &pattVec, const NoiseMap *noiseMap, const LookUp &clPattLookup)
entropy decode clusters from buffer with CTF
Definition CTFCoder.h:152
int getRowSpan() const
Returns the number of rows.
void acquirePattern(iterator &pattIt)
int getColumnSpan() const
Returns the number of columns.
static int getCOG(int rowSpan, int colSpan, const unsigned char patt[MaxPatternBytes], float &xCOG, float &zCOG)
Static: Compute pattern's COG position. Returns the number of fired pixels.
void process(Processor procRowCol)
bool isSet(int row, int col) const
static constexpr uint8_t MaxColSpan
static void streamCluster(const std::vector< PixelData > &pixbuf, const std::array< Label, MaxLabels > *lblBuff, const BBox &bbox, const LookUp &pattIdConverter, VCLUS *compClusPtr, VPAT *patternsPtr, MCTruth *labelsClusPtr, int nlab, bool isHuge=false)
Definition Clusterer.h:273
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
Digit class for the ITS.
Definition Digit.h:30
int size() const
Definition LookUp.h:44
auto getPattern(int id) const
Definition LookUp.h:45
bool isGroup(int id) const
Definition LookUp.h:43
NoiseMap class for the ITS and MFT.
Definition NoiseMap.h:39
bool isNoisy(int chip, int row, int col) const
Definition NoiseMap.h:151
GLuint entry
Definition glcorearb.h:5735
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean r
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Detector header base.
uint32_t nChips
number of clusters in TF
Definition CTF.h:35
uint8_t streamID
Number of streams per TF (== NLayers for staggered ITS/MFT readout, 1 for non-staggered one)
Definition CTF.h:40
uint32_t nPatternBytes
number of fired chips in TF : this is for the version with chipInc stored once per new chip
Definition CTF.h:36
uint32_t firstOrbit
number of bytes for explict patterns
Definition CTF.h:37
uint16_t firstBC
1st orbit of TF
Definition CTF.h:38
uint32_t nClusters
number of ROFrame in TF
Definition CTF.h:34
uint32_t nROFs
Definition CTF.h:33
uint8_t maxStreams
1st BC of TF
Definition CTF.h:39
wrapper for the Entropy-encoded clusters of the TF
Definition CTF.h:71
@ BLCnclusROF
Definition CTF.h:77
@ BLCfirstChipROF
Definition CTF.h:74
@ BLCbcIncROF
Definition CTF.h:75
@ BLCorbitIncROF
Definition CTF.h:76
Compressed but not yet entropy-encoded clusters.
Definition CTF.h:45
std::vector< int16_t > chipInc
number of clusters in ROF
Definition CTF.h:56
std::vector< int16_t > bcIncROF
1st chip ID in the ROF
Definition CTF.h:51
std::vector< int32_t > orbitIncROF
increment of ROF BC wrt BC of previous ROF
Definition CTF.h:52
std::vector< uint16_t > pattID
increment of pixel column wrt that of prev. pixel (sometimes can be slightly negative)
Definition CTF.h:60
std::vector< uint16_t > firstChipROF
Definition CTF.h:50
std::vector< uint32_t > nclusROF
increment of ROF orbit wrt orbit of previous ROF
Definition CTF.h:53
std::vector< uint8_t > pattMap
cluster pattern ID
Definition CTF.h:61
std::vector< uint16_t > row
clusters in chip
Definition CTF.h:58
std::vector< int16_t > colInc
row of fired pixel
Definition CTF.h:59
std::vector< uint16_t > chipMul
increment of chipID wrt that of prev. chip
Definition CTF.h:57
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
LookUp clPattLookup
std::vector< int > row
std::vector< unsigned char > pattVec
std::vector< CompClusterExt > cclusVec