Project
Loading...
Searching...
No Matches
Decoder.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
16#ifndef O2_MID_DECODER_H
17#define O2_MID_DECODER_H
18
19#include <cstdint>
20#if !defined(MID_RAW_VECTORS)
21#include <unordered_map>
22#endif
23#include <vector>
24#include <gsl/gsl>
25#include "Framework/Logger.h"
28#include "MIDRaw/CrateMasks.h"
31#include "MIDRaw/FEEIdConfig.h"
32#include "MIDRaw/LinkDecoder.h"
33#include "MIDRaw/Utils.h"
35
36namespace o2
37{
38namespace mid
39{
40
42{
43 public:
44 Decoder(bool isDebugMode = false, bool isBare = false, const ElectronicsDelay& electronicsDelay = ElectronicsDelay(), const CrateMasks& crateMasks = CrateMasks(), const FEEIdConfig& feeIdConfig = FEEIdConfig());
45 virtual ~Decoder() = default;
46 void process(gsl::span<const uint8_t> bytes);
47 template <class RDH>
48 void process(gsl::span<const uint8_t> payload, const RDH& rdh)
49 {
51 auto feeId = o2::raw::RDHUtils::getFEEID(rdh);
52#if defined(MID_RAW_VECTORS)
53 mLinkDecoders[feeId]->process(payload, o2::raw::RDHUtils::getHeartBeatOrbit(rdh), o2::raw::RDHUtils::getTriggerType(rdh), mData, mROFRecords);
54#else
55 auto linkDecoder = mLinkDecoders.find(feeId);
56 if (linkDecoder != mLinkDecoders.end()) {
57 linkDecoder->second->process(payload, o2::raw::RDHUtils::getHeartBeatOrbit(rdh), o2::raw::RDHUtils::getTriggerType(rdh), mData, mROFRecords);
58 } else {
59 LOG(alarm) << "Unexpected feeId " << feeId << " in RDH";
60 }
61#endif
62 }
64 const std::vector<ROBoard>& getData() const { return mData; }
65
67 const std::vector<ROFRecord>& getROFRecords() const { return mROFRecords; }
68
69 void clear();
70
71 protected:
72#if defined(MID_RAW_VECTORS)
73 std::vector<std::unique_ptr<LinkDecoder>> mLinkDecoders{};
74#else
75 std::unordered_map<uint16_t, std::unique_ptr<LinkDecoder>> mLinkDecoders{};
76#endif
77
78 private:
79 std::vector<ROBoard> mData{};
80 std::vector<ROFRecord> mROFRecords{};
81};
82
83std::unique_ptr<Decoder> createDecoder(const o2::header::RDHAny& rdh, bool isDebugMode, const ElectronicsDelay& electronicsDelay, const CrateMasks& crateMasks, const FEEIdConfig& feeIdConfig);
84std::unique_ptr<Decoder> createDecoder(const o2::header::RDHAny& rdh, bool isDebugMode, const char* electronicsDelayFile = "", const char* crateMasksFile = "", const char* feeIdConfigFile = "");
85
86} // namespace mid
87} // namespace o2
88
89#endif /* O2_MID_DECODER_H */
MID crate masks.
MID RO crate parameters.
Raw data utilities for MID.
Delay parameters for MID electronics.
Hardware Id to FeeId mapper.
Class interface for the MID link decoder.
Definition of the MID event record.
Structure to store the readout board information.
std::unordered_map< uint16_t, std::unique_ptr< LinkDecoder > > mLinkDecoders
Definition Decoder.h:75
const std::vector< ROFRecord > & getROFRecords() const
Gets the vector of data RO frame records.
Definition Decoder.h:67
void process(gsl::span< const uint8_t > payload, const RDH &rdh)
Definition Decoder.h:48
const std::vector< ROBoard > & getData() const
Gets the vector of data.
Definition Decoder.h:64
virtual ~Decoder()=default
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
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"