Project
Loading...
Searching...
No Matches
RawGBTDecoderSpec.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
18
19#include <chrono>
20#include <vector>
26#include "Framework/Logger.h"
27#include "Framework/Output.h"
29#include "Framework/Task.h"
30#include "Headers/RDHAny.h"
34#include "MIDRaw/LinkDecoder.h"
35
36namespace o2
37{
38namespace mid
39{
40
42{
43 public:
44 RawGBTDecoderDeviceDPL(bool isDebugMode, const std::vector<uint16_t>& feeIds, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay) : mIsDebugMode(isDebugMode), mFeeIds(feeIds), mCrateMasks(crateMasks), mElectronicsDelay(electronicsDelay) {}
45
47 {
48 auto stop = [this]() {
49 double scaleFactor = (mNROFs == 0) ? 0. : 1.e6 / mNROFs;
50 LOG(info) << "Processing time / " << mNROFs << " ROFs: full: " << mTimer.count() * scaleFactor << " us decoding: " << mTimerAlgo.count() * scaleFactor << " us";
51 };
52 ic.services().get<o2::framework::CallbackService>().set<o2::framework::CallbackService::Id::Stop>(stop);
53
54 auto idx = ic.services().get<o2::framework::ParallelContext>().index1D();
55 mFeeId = mFeeIds[idx];
56 }
57
59 {
60 auto tStart = std::chrono::high_resolution_clock::now();
61
63
64 auto tAlgoStart = std::chrono::high_resolution_clock::now();
65
66 o2::header::DataHeader const* dh = nullptr;
67
68 if (!mDecoder) {
69 auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(parser.begin().raw());
70 mDecoder = createGBTDecoder(*rdhPtr, mFeeId, mIsDebugMode, mCrateMasks.getMask(mFeeId), mElectronicsDelay);
71 }
72
73 std::vector<ROBoard> data;
74 std::vector<ROFRecord> rofRecords;
75
76 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
77 dh = it.o2DataHeader();
78 auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
79 gsl::span<const uint8_t> payload(it.data(), it.size());
80 mDecoder->process(payload, o2::raw::RDHUtils::getHeartBeatOrbit(rdhPtr), o2::raw::RDHUtils::getTriggerType(rdhPtr), data, rofRecords);
81 }
82
83 mTimerAlgo += std::chrono::high_resolution_clock::now() - tAlgoStart;
84
87
88 mTimer += std::chrono::high_resolution_clock::now() - tStart;
89 mNROFs += rofRecords.size();
90 }
91
92 private:
93 std::unique_ptr<LinkDecoder> mDecoder{nullptr};
94 bool mIsDebugMode{false};
95 std::vector<uint16_t> mFeeIds{};
96 CrateMasks mCrateMasks{};
97 ElectronicsDelay mElectronicsDelay{};
98 uint16_t mFeeId{0};
99 std::chrono::duration<double> mTimer{0};
100 std::chrono::duration<double> mTimerAlgo{0};
101 unsigned int mNROFs{0};
102};
103
104framework::DataProcessorSpec getRawGBTDecoderSpec(bool isDebugMode, const std::vector<uint16_t>& feeIds, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay)
105{
106 std::vector<o2::framework::InputSpec> inputSpecs{o2::framework::InputSpec{"mid_raw", header::gDataOriginMID, header::gDataDescriptionRawData, 0, o2::framework::Lifetime::Timeframe}};
107 std::vector<o2::framework::OutputSpec> outputSpecs{o2::framework::OutputSpec{header::gDataOriginMID, "DECODED", 0, o2::framework::Lifetime::Timeframe}, o2::framework::OutputSpec{header::gDataOriginMID, "DECODEDROF", 0, o2::framework::Lifetime::Timeframe}};
108
110 "MIDRawGBTDecoder",
111 {inputSpecs},
112 {outputSpecs},
113 o2::framework::adaptFromTask<RawGBTDecoderDeviceDPL>(isDebugMode, feeIds, crateMasks, electronicsDelay)};
114}
115
116} // namespace mid
117} // namespace o2
A raw page parser for DPL input.
Class interface for the MID link decoder.
Definition of the MID event record.
Structure to store the readout board information.
Data processor spec for MID GBT raw decoder device.
buffer_type const * raw() const
get pointer to raw block at current position, rdh starts here
The parser handles transparently input in the format of raw pages.
const_iterator end() const
const_iterator begin() const
void snapshot(const Output &spec, T const &object)
ServiceRegistryRef services()
Definition InitContext.h:34
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
uint8_t getMask(uint16_t feeId) const
Gets the mask for the feeId.
Definition CrateMasks.h:41
void init(o2::framework::InitContext &ic)
void run(o2::framework::ProcessingContext &pc)
RawGBTDecoderDeviceDPL(bool isDebugMode, const std::vector< uint16_t > &feeIds, const CrateMasks &crateMasks, const ElectronicsDelay &electronicsDelay)
GLuint GLuint end
Definition glcorearb.h:469
GLboolean * data
Definition glcorearb.h:298
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:597
std::unique_ptr< LinkDecoder > createGBTDecoder(const o2::header::RDHAny &rdh, uint16_t feeId, bool isDebugMode, uint8_t mask, const ElectronicsDelay &electronicsDelay)
o2::framework::DataProcessorSpec getRawGBTDecoderSpec(bool isDebugMode, const std::vector< uint16_t > &feeIds, const CrateMasks &crateMasks, const ElectronicsDelay &electronicsDelay)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
the main header struct
Definition DataHeader.h:618
SubSpecificationType subSpecification
Definition DataHeader.h:656
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"