12#ifndef O2_MCH_RAW_USERLOGIC_ENDPOINT_DECODER_H
13#define O2_MCH_RAW_USERLOGIC_ENDPOINT_DECODER_H
19#include <fmt/printf.h>
20#include <fmt/format.h>
24#include <boost/multiprecision/cpp_int.hpp>
37template <
typename CHARGESUM,
int VERSION>
47 std::function<std::optional<uint16_t>(
FeeLinkId id)> fee2SolarMapper,
73 std::function<std::optional<uint16_t>(
FeeLinkId id)> mFee2SolarMapper;
75 std::map<uint16_t, std::array<ElinkDecoder, 40>> mElinkDecoders;
76 int mNofGbtWordsSeens;
80using namespace boost::multiprecision;
82template <
typename CHARGESUM,
int VERSION>
84 std::function<std::optional<uint16_t>(
FeeLinkId id)> fee2SolarMapper,
88 mFee2SolarMapper{fee2SolarMapper},
89 mDecodedDataHandlers(decodedDataHandlers),
94template <
typename CHARGESUM,
int VERSION>
98 throw std::invalid_argument(
"buffer size should be a multiple of 8");
102 for (
size_t i = 0;
i <
buffer.size();
i += 8) {
112 if (word == 0xFEEDDEEDFEEDDEED) {
118 int gbt = ulword.linkID;
128 if (gbt < 0 || gbt > 11) {
135 throw fmt::format(
"warning : out-of-range gbt {} word={:08X}\n", gbt, word);
141 auto d = mElinkDecoders.find(gbt);
142 if (
d == mElinkDecoders.end()) {
147 auto solarId = mFee2SolarMapper(feeLinkId);
149 if (!solarId.has_value()) {
156 throw std::logic_error(fmt::format(
"{} Could not get solarId from feeLinkId={}\n", __PRETTY_FUNCTION__,
asString(feeLinkId)));
160 mElinkDecoders.emplace(
static_cast<uint16_t>(gbt),
161 impl::makeArray<40>([solarId, *
this](
size_t i) {
165 d = mElinkDecoders.find(gbt);
176 throw fmt::format(
"warning : out-of-range DS ID {} word={:08X}\n", dsid, word);
181 bool incomplete = ulword.incomplete > 0;
184 d->second.at(dsid).append(data50,
error, incomplete);
190template <
typename CHARGESUM,
int VERSION>
193 for (
auto&
arrays : mElinkDecoders) {
194 for (
auto&
d :
arrays.second) {
unsigned short int uint16_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
char error[CURL_ERROR_SIZE]
Decoder for MCH Raw Data Format.
A UserLogicEndpointDecoder groups 12 x (40 UserLogicElinkDecoder objects)
size_t append(Payload bytes)
Append the equivalent n 64-bits words bytes size (=n) must be a multiple of 8.
void reset()
Clear our internal Elinks.
UserLogicEndpointDecoder(uint16_t feeId, std::function< std::optional< uint16_t >(FeeLinkId id)> fee2SolarMapper, DecodedDataHandlers decodedDataHandlers)
std::string asString(const SampaCluster &sc)
std::function< void(DsElecId dsId, int8_t chip, uint32_t error)> SampaErrorHandler