Project
Loading...
Searching...
No Matches
Decoder.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
16
17#include "MIDRaw/Decoder.h"
18
19#include "Headers/RDHAny.h"
20#include "DPLUtils/RawParser.h"
21
22namespace o2
23{
24namespace mid
25{
26
27Decoder::Decoder(bool isDebugMode, bool isBare, const ElectronicsDelay& electronicsDelay, const CrateMasks& crateMasks, const FEEIdConfig& feeIdConfig) : mData(), mROFRecords(), mLinkDecoders()
28{
30 auto feeIds = isBare ? feeIdConfig.getConfiguredGBTUniqueIDs() : feeIdConfig.getConfiguredFEEIDs();
31
32 for (auto& feeId : feeIds) {
33#if defined(MID_RAW_VECTORS)
34 mLinkDecoders.emplace_back(createLinkDecoder(feeId, isBare, isDebugMode, crateMasks.getMask(feeId), electronicsDelay, feeIdConfig));
35#else
36 mLinkDecoders.emplace(feeId, createLinkDecoder(feeId, isBare, isDebugMode, crateMasks.getMask(feeId), electronicsDelay, feeIdConfig));
37#endif
38 }
39}
40
42{
44 mData.clear();
45 mROFRecords.clear();
46}
47
48void Decoder::process(gsl::span<const uint8_t> bytes)
49{
51 clear();
52 o2::framework::RawParser parser(bytes.data(), bytes.size());
53 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
54 if (it.size() == 0) {
55 continue;
56 }
57 gsl::span<const uint8_t> payload(it.data(), it.size());
58 auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
59 process(payload, *rdhPtr);
60 }
61}
62
63std::unique_ptr<Decoder> createDecoder(const o2::header::RDHAny& rdh, bool isDebugMode, const ElectronicsDelay& electronicsDelay, const CrateMasks& crateMasks, const FEEIdConfig& feeIdConfig)
64{
66 bool isBare = raw::isBare(rdh);
67 return std::make_unique<Decoder>(isDebugMode, isBare, electronicsDelay, crateMasks, feeIdConfig);
68}
69std::unique_ptr<Decoder> createDecoder(const o2::header::RDHAny& rdh, bool isDebugMode, const char* electronicsDelayFile, const char* crateMasksFile, const char* feeIdConfigFile)
70{
72 o2::mid::ElectronicsDelay electronicsDelay;
73 std::string filename = electronicsDelayFile;
74 if (!filename.empty()) {
75 electronicsDelay = o2::mid::readElectronicsDelay(filename.c_str());
76 }
77
78 o2::mid::CrateMasks crateMasks;
79 filename = crateMasksFile;
80 if (!filename.empty()) {
81 crateMasks = o2::mid::CrateMasks(filename.c_str());
82 }
83
84 o2::mid::FEEIdConfig feeIdConfig;
85 filename = feeIdConfigFile;
86 if (!filename.empty()) {
87 feeIdConfig = o2::mid::FEEIdConfig(filename.c_str());
88 }
89
90 return createDecoder(rdh, isDebugMode, electronicsDelay, crateMasks, feeIdConfig);
91}
92
93} // namespace mid
94} // namespace o2
MID raw data decoder.
Generic parser for consecutive raw pages.
const_iterator begin() const
Definition RawParser.h:618
const_iterator end() const
Definition RawParser.h:623
uint8_t getMask(uint16_t feeId) const
Gets the mask for the feeId.
Definition CrateMasks.h:41
std::unordered_map< uint16_t, std::unique_ptr< LinkDecoder > > mLinkDecoders
Definition Decoder.h:75
Decoder(bool isDebugMode=false, bool isBare=false, const ElectronicsDelay &electronicsDelay=ElectronicsDelay(), const CrateMasks &crateMasks=CrateMasks(), const FEEIdConfig &feeIdConfig=FEEIdConfig())
Definition Decoder.cxx:27
void process(gsl::span< const uint8_t > bytes)
Definition Decoder.cxx:48
std::vector< uint16_t > getConfiguredGBTUniqueIDs() const
std::vector< uint16_t > getConfiguredFEEIDs() const
GLuint GLuint end
Definition glcorearb.h:469
bool isBare(const o2::header::RDHAny &rdh)
Test if the data comes from the common logic.
Definition Utils.h:31
std::unique_ptr< Decoder > createDecoder(const o2::header::RDHAny &rdh, bool isDebugMode, const ElectronicsDelay &electronicsDelay, const CrateMasks &crateMasks, const FEEIdConfig &feeIdConfig)
Definition Decoder.cxx:63
ElectronicsDelay readElectronicsDelay(const char *filename)
std::unique_ptr< LinkDecoder > createLinkDecoder(const o2::header::RDHAny &rdh, uint16_t feeId, bool isDebugMode, uint8_t mask, const ElectronicsDelay &electronicsDelay, const FEEIdConfig &feeIdConfig)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()