Project
Loading...
Searching...
No Matches
BareGBTDecoder.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
12#ifndef O2_MCH_RAW_BARE_GBT_DECODER_H
13#define O2_MCH_RAW_BARE_GBT_DECODER_H
14
15#include <array>
16#include "BareElinkDecoder.h"
18#include <gsl/span>
19#include <fmt/printf.h>
20#include <fmt/format.h>
21#include "MakeArray.h"
22#include "Assertions.h"
23#include <iostream>
24#include <boost/multiprecision/cpp_int.hpp>
25#include "PayloadDecoder.h"
26
27namespace o2
28{
29namespace mch
30{
31namespace raw
32{
33
37
38template <typename CHARGESUM>
39class BareGBTDecoder : public PayloadDecoder<BareGBTDecoder<CHARGESUM>>
40{
41 public:
46 BareGBTDecoder(uint16_t solarId, DecodedDataHandlers decodedDataHandlers);
47
51
60 size_t append(Payload bytes);
62
67
69 void reset();
71
72 private:
73 void append(uint32_t, int, int);
74
75 private:
76 int mSolarId;
77 std::array<BareElinkDecoder<CHARGESUM>, 40> mElinks;
78 int mNofGbtWordsSeens;
79 uint32_t mOrbit;
80};
81
82using namespace boost::multiprecision;
83
84template <typename CHARGESUM>
86 DecodedDataHandlers decodedDataHandlers)
87 : PayloadDecoder<BareGBTDecoder<CHARGESUM>>(decodedDataHandlers),
88 mSolarId{solarId},
89 mElinks{impl::makeArray<40>([=](uint8_t i) { return BareElinkDecoder<CHARGESUM>(DsElecId{solarId, static_cast<uint8_t>(i / 5), static_cast<uint8_t>(i % 5)}, decodedDataHandlers); })},
90 mNofGbtWordsSeens{0}
91{
92}
93
94template <typename CHARGESUM>
96{
97 if (bytes.size() % 16 != 0) {
98 throw std::invalid_argument("can only bytes by group of 16 (i.e. 128 bits)");
99 }
100 size_t n{0};
101 for (int j = 0; j < bytes.size(); j += 16) {
102 ++mNofGbtWordsSeens;
103 int elinkIndex = 0;
104 for (auto b : bytes.subspan(j, 10)) {
105 const uint8_t b8 = std::to_integer<uint8_t>(b);
106 mElinks[elinkIndex++].append(b8 & 2, b8 & 1);
107 mElinks[elinkIndex++].append(b8 & 8, b8 & 4);
108 mElinks[elinkIndex++].append(b8 & 32, b8 & 16);
109 mElinks[elinkIndex++].append(b8 & 128, b8 & 64);
110 }
111 n += 10;
112 }
113 return n;
114}
115
116template <typename CHARGESUM>
118{
119 for (auto& e : mElinks) {
120 e.reset();
121 }
122}
123} // namespace raw
124} // namespace mch
125} // namespace o2
126
127#endif
int32_t i
uint32_t j
Definition RawData.h:0
Main element of the MCH Bare Raw Data Format decoder.
A BareGBTDecoder groups 40 ElinkDecoder objects.
BareGBTDecoder(uint16_t solarId, DecodedDataHandlers decodedDataHandlers)
size_t append(Payload bytes)
Append the equivalent n GBT words (n x 128 bits, split in 16 bytes). bytes size (=n) must be a multip...
void reset()
Clear our internal Elinks.
Decoder for MCH Raw Data Format.
GLdouble n
Definition glcorearb.h:1982
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...