Project
Loading...
Searching...
No Matches
FT0DataReaderDPLSpec.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
13
14#ifndef O2_FT0DATAREADERDPLSPEC_H
15#define O2_FT0DATAREADERDPLSPEC_H
18#include "Framework/Task.h"
22#include "Framework/Lifetime.h"
23#include "Framework/Output.h"
28#include <iostream>
29#include <vector>
30#include <gsl/span>
32
33using namespace o2::framework;
34
35namespace o2
36{
37namespace ft0
38{
39template <typename RawReader>
41{
42 public:
43 FT0DataReaderDPLSpec(const RawReader& rawReader) : mRawReader(rawReader) {}
45 ~FT0DataReaderDPLSpec() override = default;
46 typedef RawReader RawReader_t;
47 void init(InitContext& ic) final { o2::ft0::SingleLUT::Instance().printFullMap(); }
48 void run(ProcessingContext& pc) final
49 {
50 // if we see requested data type input with 0xDEADBEEF subspec and 0 payload this means that the "delayed message"
51 // mechanism created it in absence of real data from upstream. Processor should send empty output to not block the workflow
52 {
53 static size_t contDeadBeef = 0; // number of times 0xDEADBEEF was seen continuously
54 std::vector<InputSpec> dummy{InputSpec{"dummy", ConcreteDataMatcher{o2::header::gDataOriginFT0, o2::header::gDataDescriptionRawData, 0xDEADBEEF}}};
55 for (const auto& ref : InputRecordWalker(pc.inputs(), dummy)) {
56 const auto dh = o2::framework::DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
57 auto payloadSize = DataRefUtils::getPayloadSize(ref);
58 if (payloadSize == 0) {
60 if (++contDeadBeef <= maxWarn) {
61 LOGP(alarm, "Found input [{}/{}/{:#x}] TF#{} 1st_orbit:{} Payload {} : assuming no payload for all links in this TF{}",
62 dh->dataOrigin.str, dh->dataDescription.str, dh->subSpecification, dh->tfCounter, dh->firstTForbit, payloadSize,
63 contDeadBeef == maxWarn ? fmt::format(". {} such inputs in row received, stopping reporting", contDeadBeef) : "");
64 }
65 mRawReader.makeSnapshot(pc); // send empty output
66 return;
67 }
68 }
69 contDeadBeef = 0; // if good data, reset the counter
70 }
71 std::vector<InputSpec> filter{InputSpec{"filter", ConcreteDataTypeMatcher{o2::header::gDataOriginFT0, o2::header::gDataDescriptionRawData}, Lifetime::Timeframe}};
72 DPLRawParser parser(pc.inputs(), filter);
73 std::size_t count = 0;
74 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
75 //Proccessing each page
76 count++;
77 auto rdhPtr = reinterpret_cast<const o2::header::RDHAny*>(it.raw());
78 gsl::span<const uint8_t> payload(it.data(), it.size());
79 mRawReader.process(payload, o2::raw::RDHUtils::getLinkID(rdhPtr), o2::raw::RDHUtils::getEndPointID(rdhPtr));
80 }
81 LOG(info) << "Pages: " << count;
82 mRawReader.accumulateDigits();
83 mRawReader.makeSnapshot(pc);
84 mRawReader.clear();
85 }
87};
88
89template <typename RawReader>
90framework::DataProcessorSpec getFT0DataReaderDPLSpec(const RawReader& rawReader, bool askSTFDist)
91{
92 LOG(info) << "DataProcessorSpec initDataProcSpec() for RawReaderFT0";
93 std::vector<OutputSpec> outputSpec;
94 RawReader::prepareOutputSpec(outputSpec);
95 std::vector<InputSpec> inputSpec{{"STF", ConcreteDataTypeMatcher{o2::header::gDataOriginFT0, "RAWDATA"}, Lifetime::Timeframe}};
96 if (askSTFDist) {
97 inputSpec.emplace_back("STFDist", "FLP", "DISTSUBTIMEFRAME", 0, Lifetime::Timeframe);
98 }
99 return DataProcessorSpec{
100 "ft0-datareader-dpl",
101 inputSpec,
102 outputSpec,
103 adaptFromTask<FT0DataReaderDPLSpec<RawReader>>(rawReader),
104 Options{}};
105}
106
107} // namespace ft0
108} // namespace o2
109
110#endif /* O2_FT0DATAREADERDPL_H */
A raw page parser for DPL input.
A helper class to iteratate over all parts of all input routes.
Type wrappers for enfording a specific serialization method.
static SingleLUT & Instance(const Table_t *table=nullptr, long timestamp=-1)
The parser handles transparently input in the format of raw pages.
const_iterator end() const
const_iterator begin() const
A helper class to iteratate over all parts of all input routes.
~FT0DataReaderDPLSpec() override=default
void run(ProcessingContext &pc) final
FT0DataReaderDPLSpec(const RawReader &rawReader)
void init(InitContext &ic) final
GLint GLsizei count
Definition glcorearb.h:399
GLuint GLuint end
Definition glcorearb.h:469
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
constexpr o2::header::DataDescription gDataDescriptionRawData
Definition DataHeader.h:597
constexpr o2::header::DataOrigin gDataOriginFT0
Definition DataHeader.h:566
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< ConfigParamSpec > Options
framework::DataProcessorSpec getFT0DataReaderDPLSpec(const RawReader &rawReader, bool askSTFDist)
struct o2::upgrades_utils::@462 ft0
structure to keep V0C information
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)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"