Project
Loading...
Searching...
No Matches
RawDecoderSpec.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>
21#include "Framework/Logger.h"
22#include "Framework/Output.h"
23#include "Framework/Task.h"
25#include "Headers/RDHAny.h"
26#include "MIDRaw/Decoder.h"
28
29namespace of = o2::framework;
30
31namespace o2
32{
33namespace mid
34{
35
37{
38 public:
39 RawDecoderDeviceDPL(bool isDebugMode, const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay, header::DataHeader::SubSpecificationType subSpec) : mIsDebugMode(isDebugMode), mFeeIdConfig(feeIdConfig), mCrateMasks(crateMasks), mElectronicsDelay(electronicsDelay), mSubSpec(subSpec) {}
40
42 {
43 auto stop = [this]() {
44 if (mDecoder) {
45 LOG(info) << "Capacities: ROFRecords: " << mDecoder->getROFRecords().capacity() << " LocalBoards: " << mDecoder->getData().capacity();
46 double scaleFactor = (mNROFs == 0) ? 0. : 1.e6 / mNROFs;
47 LOG(info) << "Processing time / " << mNROFs << " ROFs: full: " << mTimer.count() * scaleFactor << " us decoding: " << mTimerAlgo.count() * scaleFactor << " us";
48 }
49 };
50 ic.services().get<of::CallbackService>().set<of::CallbackService::Id::Stop>(stop);
51 }
52
54 {
55 auto tStart = std::chrono::high_resolution_clock::now();
56
57 auto tAlgoStart = std::chrono::high_resolution_clock::now();
58
60 std::vector<ROBoard> data;
61 std::vector<ROFRecord> rofs;
62 pc.outputs().snapshot(of::Output{header::gDataOriginMID, "DECODED", mSubSpec}, data);
63 pc.outputs().snapshot(of::Output{header::gDataOriginMID, "DECODEDROF", mSubSpec}, rofs);
64 return;
65 }
66
67 std::vector<of::InputSpec> filter{of::InputSpec{"filter", of::ConcreteDataTypeMatcher{header::gDataOriginMID, header::gDataDescriptionRawData}, of::Lifetime::Timeframe}};
68
69 of::DPLRawParser parser(pc.inputs(), filter);
70
71 if (!mDecoder) {
72 auto const* rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(parser.begin().raw());
73 mDecoder = createDecoder(*rdhPtr, mIsDebugMode, mElectronicsDelay, mCrateMasks, mFeeIdConfig);
74 }
75
76 mDecoder->clear();
77 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
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, *rdhPtr);
81 }
82
83 mTimerAlgo += std::chrono::high_resolution_clock::now() - tAlgoStart;
84
85 pc.outputs().snapshot(of::Output{header::gDataOriginMID, "DECODED", mSubSpec}, mDecoder->getData());
86 pc.outputs().snapshot(of::Output{header::gDataOriginMID, "DECODEDROF", mSubSpec}, mDecoder->getROFRecords());
87
88 mTimer += std::chrono::high_resolution_clock::now() - tStart;
89 mNROFs += mDecoder->getROFRecords().size();
90 }
91
92 private:
93 std::unique_ptr<Decoder> mDecoder{nullptr};
94 bool mIsDebugMode{false};
95 FEEIdConfig mFeeIdConfig{};
96 CrateMasks mCrateMasks{};
97 ElectronicsDelay mElectronicsDelay{};
99 std::chrono::duration<double> mTimer{0};
100 std::chrono::duration<double> mTimerAlgo{0};
101 unsigned int mNROFs{0};
102};
103
104of::DataProcessorSpec getRawDecoderSpec(bool isDebugMode, const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay, std::vector<of::InputSpec> inputSpecs, bool askDISTSTF, o2::header::DataHeader::SubSpecificationType subSpecType)
105{
106 if (askDISTSTF) {
107 inputSpecs.emplace_back(getDiSTSTFSpec());
108 }
109 std::vector<of::OutputSpec> outputSpecs{of::OutputSpec{header::gDataOriginMID, "DECODED", subSpecType, of::Lifetime::Timeframe}, of::OutputSpec{header::gDataOriginMID, "DECODEDROF", subSpecType, of::Lifetime::Timeframe}};
111 "MIDRawDecoder",
112 {inputSpecs},
113 {outputSpecs},
114 of::adaptFromTask<o2::mid::RawDecoderDeviceDPL>(isDebugMode, feeIdConfig, crateMasks, electronicsDelay, subSpecType)};
115}
116
118{
119 return getRawDecoderSpec(isDebugMode, FEEIdConfig(), CrateMasks(), ElectronicsDelay(), true);
120}
121
122of::DataProcessorSpec getRawDecoderSpec(bool isDebugMode, const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay, bool askDISTSTF)
123{
124 std::vector<of::InputSpec> inputSpecs{{"mid_raw", of::ConcreteDataTypeMatcher{header::gDataOriginMID, header::gDataDescriptionRawData}, of::Lifetime::Timeframe}};
126 return getRawDecoderSpec(isDebugMode, feeIdConfig, crateMasks, electronicsDelay, inputSpecs, askDISTSTF, subSpec);
127}
128
129of::DataProcessorSpec getRawDecoderSpec(bool isDebugMode, const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks, const ElectronicsDelay& electronicsDelay, bool askDISTSTF, header::DataHeader::SubSpecificationType subSpec)
130{
131 std::vector<of::InputSpec> inputSpecs{{"mid_raw", header::gDataOriginMID, header::gDataDescriptionRawData, subSpec, o2::framework::Lifetime::Timeframe}};
132
133 return getRawDecoderSpec(isDebugMode, feeIdConfig, crateMasks, electronicsDelay, inputSpecs, askDISTSTF, subSpec);
134}
135} // namespace mid
136} // namespace o2
A raw page parser for DPL input.
MID raw data decoder.
Data processor spec for MID raw decoder device.
Handler for raw data input specs.
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.
RawDecoderDeviceDPL(bool isDebugMode, const FEEIdConfig &feeIdConfig, const CrateMasks &crateMasks, const ElectronicsDelay &electronicsDelay, header::DataHeader::SubSpecificationType subSpec)
void init(of::InitContext &ic)
void run(of::ProcessingContext &pc)
GLuint GLuint end
Definition glcorearb.h:469
GLboolean * data
Definition glcorearb.h:298
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
constexpr o2::header::DataOrigin gDataOriginMID
Definition DataHeader.h:573
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:597
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
bool isDroppedTF(o2::framework::ProcessingContext &pc, o2::header::DataOrigin origin=o2::header::gDataOriginMID)
framework::DataProcessorSpec getRawDecoderSpec(bool isDebugMode=false)
o2::framework::InputSpec getDiSTSTFSpec()
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 ...
uint32_t SubSpecificationType
Definition DataHeader.h:620
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"