Project
Loading...
Searching...
No Matches
ZDCDataReaderDPLSpec.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
13
19
20using namespace o2::framework;
21
22namespace o2
23{
24namespace zdc
25{
26
27ZDCDataReaderDPLSpec::ZDCDataReaderDPLSpec(const RawReaderZDC& rawReader) : mRawReader(rawReader)
28{
29}
30
32{
33 mVerbosity = ic.options().get<int>("log-level");
34 // 0: minimal output
35 // 1: event summary per channel
36 // 2: debug inconsistencies
37 // 3: dump of associated input data
38 // 4: dump of raw input data
39}
40
42{
43 // we call these methods just to trigger finaliseCCDB callback
44 pc.inputs().get<o2::zdc::ModuleConfig*>("moduleconfig");
45}
46
48{
49 if (matcher == ConcreteDataMatcher("ZDC", "MODULECONFIG", 0)) {
50 mRawReader.setModuleConfig((const o2::zdc::ModuleConfig*)obj);
51 mRawReader.setTriggerMask();
52 }
53}
54
56{
57 mRawReader.clear();
58 if (!mInitialized) {
59 mInitialized = true;
61 mRawReader.setVerbosity(mVerbosity);
62 }
63
64 // if we see requested data type input with 0xDEADBEEF subspec and 0 payload this means that the "delayed message"
65 // mechanism created it in absence of real data from upstream. Processor should send empty output to not block the workflow
66 {
67 static size_t contDeadBeef = 0; // number of times 0xDEADBEEF was seen continuously
68 std::vector<InputSpec> dummy{InputSpec{"dummy", ConcreteDataMatcher{o2::header::gDataOriginZDC, o2::header::gDataDescriptionRawData, 0xDEADBEEF}}};
69 for (const auto& ref : InputRecordWalker(pc.inputs(), dummy)) {
70 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
71 auto payloadSize = DataRefUtils::getPayloadSize(ref);
72 if (payloadSize == 0) {
74 if (++contDeadBeef <= maxWarn) {
75 LOGP(alarm, "Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF{}",
76 dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, payloadSize,
77 contDeadBeef == maxWarn ? fmt::format(". {} such inputs in row received, stopping reporting", contDeadBeef) : "");
78 }
79 mRawReader.makeSnapshot(pc); // send empty output
80 return;
81 }
82 }
83 contDeadBeef = 0; // if good data, reset the counter
84 }
85
86 DPLRawParser parser(pc.inputs(), o2::framework::select("zdc:ZDC/RAWDATA"));
87
88 uint64_t count = 0;
89 static uint64_t nErr[4] = {0};
90 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
91 // Processing each page
92 auto rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
93 if (rdhPtr == nullptr || !o2::raw::RDHUtils::checkRDH(rdhPtr, true)) {
94 nErr[0]++;
95 if (nErr[0] < 5) {
96 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader on page " << count;
97 } else if (nErr[0] == 5) {
98 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader on page " << count << " suppressing further messages";
99 }
100 } else {
101 if (it.data() == nullptr) {
102 nErr[1]++;
103 } else if (it.size() == 0) {
104 nErr[2]++;
105 } else {
106 gsl::span<const uint8_t> payload(it.data(), it.size());
107 auto lid = o2::raw::RDHUtils::getLinkID(rdhPtr);
108 auto dataFormat = o2::raw::RDHUtils::getDataFormat(rdhPtr);
109#ifdef O2_ZDC_DEBUG
110 LOG(info) << count << " processBinaryData: size=" << it.size() << " link=" << lid;
111#endif
112 if (mRawReader.processBinaryData(payload, lid, dataFormat)) {
113 nErr[3]++;
114 break;
115 }
116 }
117 }
118 count++;
119 }
120 LOG(info) << "ZDCDataReaderDPLSpec::run processed pages: " << count;
121 if (nErr[0] > 0) {
122 LOG(warning) << "ZDCDataReaderDPLSpec::run - Missing RAWDataHeader occurrences " << nErr[0];
123 }
124 if (nErr[1] > 0) {
125 LOG(warning) << "ZDCDataReaderDPLSpec::run - Null payload pointer occurrences " << nErr[1];
126 }
127 if (nErr[2] > 0) {
128 LOG(warning) << "ZDCDataReaderDPLSpec::run - No payload occurrences " << nErr[2];
129 }
130 if (nErr[0] == 0 && nErr[3] == 0) {
131 mRawReader.accumulateDigits();
132 } else {
133 LOG(warning) << "Not sending output";
134 }
135 mRawReader.makeSnapshot(pc);
136}
137
139{
140 LOG(info) << "DataProcessorSpec initDataProcSpec() for RawReaderZDC";
141 std::vector<OutputSpec> outputSpec;
143 std::vector<InputSpec> inputSpec{{"STF", ConcreteDataTypeMatcher{o2::header::gDataOriginZDC, "RAWDATA"}, Lifetime::Timeframe}};
144 inputSpec.emplace_back("moduleconfig", "ZDC", "MODULECONFIG", 0, Lifetime::Condition, o2::framework::ccdbParamSpec(o2::zdc::CCDBPathConfigModule.data()));
145 if (askSTFDist) {
146 inputSpec.emplace_back("STFDist", "FLP", "DISTSUBTIMEFRAME", 0, Lifetime::Timeframe);
147 }
148 return DataProcessorSpec{
149 "zdc-datareader-dpl",
150 inputSpec,
151 outputSpec,
152 adaptFromTask<ZDCDataReaderDPLSpec>(rawReader),
154 {"log-level", o2::framework::VariantType::Int, 0, {"ZDC data reader verbosity level"}}}};
155}
156} // namespace zdc
157} // namespace o2
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Definition of the Names Generator class.
static std::string getCCDBServer()
Definition NameConf.cxx:123
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
A helper class to iteratate over all parts of all input routes.
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
void setVerbosity(int v)
void setModuleConfig(const ModuleConfig *moduleConfig)
int processBinaryData(gsl::span< const uint8_t > payload, int linkID, uint8_t dataFormat)
static void prepareOutputSpec(std::vector< o2::framework::OutputSpec > &outputSpec)
void makeSnapshot(o2::framework::ProcessingContext &pc)
void init(InitContext &ic) final
void run(ProcessingContext &pc) final
void updateTimeDependentParams(ProcessingContext &pc)
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
GLint GLsizei count
Definition glcorearb.h:399
GLuint GLuint end
Definition glcorearb.h:469
GLint ref
Definition glcorearb.h:291
constexpr o2::header::DataOrigin gDataOriginZDC
Definition DataHeader.h:581
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:601
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< InputSpec > select(char const *matcher="")
struct o2::upgrades_utils::@482 zdc
structure to keep FT0 information
framework::DataProcessorSpec getZDCDataReaderDPLSpec(const RawReaderZDC &rawReader, const bool askSTFDist)
const std::string CCDBPathConfigModule
Definition Constants.h:219
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static o2::header::DataHeader::PayloadSizeType getPayloadSize(const DataRef &ref)
static bool checkRDH(const RDHv4 &rdh, bool verbose=true, bool checkZeros=false)
Definition RDHUtils.cxx:133
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"