Project
Loading...
Searching...
No Matches
ZDCRawParserDPLSpec.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
15
16#include <iostream>
17#include <vector>
18#include <string>
19#include <gsl/span>
22#include "CCDB/CcdbApi.h"
25#include "Framework/Logger.h"
44
45using namespace o2::framework;
46
47namespace o2
48{
49namespace zdc
50{
51
53{
54 mTimer.Stop();
55 mTimer.Reset();
56}
57
59{
60 mTimer.Stop();
61 mTimer.Reset();
62}
63
65{
66 mVerbosity = ic.options().get<int>("log-level");
67 mWorker.setVerbosity(mVerbosity);
68}
69
71{
72 if (!mInitialized) {
73 mWorker.init();
74 mWorker.setVerbosity(mVerbosity);
75 mInitialized = true;
76 mTimer.Stop();
77 mTimer.Reset();
78 mTimer.Start(false);
79 }
80
81 DPLRawParser parser(pc.inputs(), o2::framework::select("zdc:ZDC/RAWDATA"));
82
83 uint64_t count = 0;
84 static uint64_t nErr[3] = {0};
85 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
86 // Processing each page
87 auto rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
88 if (rdhPtr == nullptr || !o2::raw::RDHUtils::checkRDH(rdhPtr, true)) {
89 nErr[0]++;
90 if (nErr[0] < 5) {
91 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader on page " << count;
92 } else if (nErr[0] == 5) {
93 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader on page " << count << " suppressing further messages";
94 }
95 } else {
96 if (it.data() == nullptr) {
97 nErr[1]++;
98 } else if (it.size() == 0) {
99 nErr[2]++;
100 } else {
101 // retrieving the raw pointer of the page
102 auto const* raw = it.raw();
103 // retrieving payload pointer of the page
104 auto const* payload = it.data();
105 // size of payload
106 size_t payloadSize = it.size();
107 // offset of payload in the raw page
108 size_t offset = it.offset();
109 int dataFormat = o2::raw::RDHUtils::getDataFormat(rdhPtr);
110#ifdef O2_ZDC_DEBUG
111 int linkID = o2::raw::RDHUtils::getLinkID(rdhPtr);
112 LOG(info) << count << " ZDCRawParserDPLSpec::run: fmt=" << dataFormat << " size=" << it.size() << " link=" << linkID;
113#endif
114 if (dataFormat == 2) {
115 for (int32_t ip = 0; (ip + PayloadPerGBTW) <= payloadSize; ip += PayloadPerGBTW) {
116 const uint32_t* gbtw = (const uint32_t*)&payload[ip];
117#ifdef O2_ZDC_DEBUG
119#endif
120 if (gbtw[0] != 0xffffffff || gbtw[1] != 0xffffffff || (gbtw[2] & 0xffff) != 0xffff) {
121 mWorker.processWord(gbtw);
122 }
123 }
124 } else if (dataFormat == 0) {
125 for (int32_t ip = 0; ip < payloadSize; ip += NBPerGBTW) {
126#ifdef O2_ZDC_DEBUG
127 o2::zdc::Digits2Raw::print_gbt_word((const uint32_t*)&payload[ip]);
128#endif
129 mWorker.processWord((const uint32_t*)&payload[ip]);
130 }
131 } else {
132 LOG(error) << "ZDCDataReaderDPLSpec::run - Unsupported DataFormat " << dataFormat;
133 }
134 }
135 }
136 count++;
137 }
138 LOG(info) << "ZDCDataReaderDPLSpec::run processed pages: " << count;
139 if (nErr[0] > 0) {
140 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader occurrences " << nErr[0];
141 }
142 if (nErr[1] > 0) {
143 LOG(warning) << "ZDCDataReaderDPLSpec::run - Null payload pointer occurrences " << nErr[1];
144 }
145 if (nErr[2] > 0) {
146 LOG(warning) << "ZDCDataReaderDPLSpec::run - No payload occurrences " << nErr[2];
147 }
148}
149
151{
152 mWorker.write();
153 mTimer.Stop();
154 LOGF(info, "ZDC RAW data parsing: Cpu: %.3e Real: %.3e s in %d slots", mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
155}
156
158{
159 using device = o2::zdc::ZDCRawParserDPLSpec;
160 std::vector<InputSpec> inputs;
161 inputs.emplace_back("raw", o2::framework::ConcreteDataTypeMatcher{"ZDC", "RAWDATA"}, Lifetime::Timeframe);
162
163 std::vector<OutputSpec> outputs;
164 return DataProcessorSpec{
165 "zdc-raw-parser",
166 inputs,
167 outputs,
168 AlgorithmSpec{adaptFromTask<device>()},
169 Options{{"log-level", o2::framework::VariantType::Int, 0, {"Verbosity level"}}}};
170}
171
172} // namespace zdc
173} // namespace o2
#define verbosity
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
A raw page parser for DPL input.
Definition of the Names Generator class.
Class to describe pedestal data accumulated over the orbit.
Class to describe reconstructed ZDC event (single BC with signal in one of detectors)
Container class to store NTimeBinsPerBC ADC values of single ZDC channel.
Container of ZDC raw data.
converts digits to raw format
The parser handles transparently input in the format of raw pages.
const_iterator end() const
const_iterator begin() const
ConfigParamRegistry const & options()
Definition InitContext.h:33
InputRecord & inputs()
The inputs associated with this processing context.
static void print_gbt_word(const uint32_t *word, const ModuleConfig *moduleConfig=nullptr)
int processWord(const uint32_t *word)
Definition DumpRaw.cxx:237
void setVerbosity(int v)
Definition DumpRaw.h:35
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
GLint GLsizei count
Definition glcorearb.h:399
GLuint GLuint end
Definition glcorearb.h:469
GLintptr offset
Definition glcorearb.h:660
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > select(char const *matcher="")
struct o2::upgrades_utils::@463 zdc
structure to keep FT0 information
constexpr int NBPerGBTW
constexpr int PayloadPerGBTW
framework::DataProcessorSpec getZDCRawParserDPLSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static bool checkRDH(const RDHv4 &rdh, bool verbose=true, bool checkZeros=false)
Definition RDHUtils.cxx:133
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"