Project
Loading...
Searching...
No Matches
raw-parser.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#include "Framework/Logger.h"
19#include "Headers/DataHeader.h"
21#include <vector>
22#include <sstream>
23
24using namespace o2::framework;
25
26// we need to add workflow options before including Framework/runDataProcessing
27void customize(std::vector<ConfigParamSpec>& workflowOptions)
28{
29 workflowOptions.push_back(
31 "input-spec", VariantType::String, "A:FLP/RAWDATA", {"selection string input specs"}});
32}
33
35
37{
38 WorkflowSpec workflow;
39 workflow.emplace_back(DataProcessorSpec{
40 "raw-parser",
41 select(config.options().get<std::string>("input-spec").c_str()),
42 Outputs{},
43 AlgorithmSpec{[](InitContext& setup) {
44 auto loglevel = setup.options().get<int>("log-level");
45 return adaptStateless([loglevel](InputRecord& inputs, DataAllocator& outputs) {
46 DPLRawParser parser(inputs);
47 o2::header::DataHeader const* lastDataHeader = nullptr;
48 std::stringstream rdhprintout;
49 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
50 // retrieving RDH v4
51 auto const* rdh = it.get_if<o2::header::RAWDataHeaderV4>();
52 // retrieving the raw pointer of the page
53 auto const* raw = it.raw();
54 // retrieving payload pointer of the page
55 auto const* payload = it.data();
56 // size of payload
57 size_t payloadSize = it.size();
58 // offset of payload in the raw page
59 size_t offset = it.offset();
60
61 // Note: the following code is only for printing out raw page information
62 const auto* dh = it.o2DataHeader();
63 if (loglevel > 0) {
64 if (dh != lastDataHeader) {
65 if (!rdhprintout.str().empty()) {
66 LOG(info) << rdhprintout.str();
67 rdhprintout.str(std::string());
68 }
69 // print the DataHeader information only for the first part or if we have high verbosity
70 if (loglevel > 1 || dh->splitPayloadIndex == 0) {
71 rdhprintout << fmt::format("DH: {}/{}/{}", dh->dataOrigin, dh->dataDescription, dh->subSpecification) << " "
72 << " TF " << dh->tfCounter << " firstOrbit " << dh->firstTForbit << " Run " << dh->runNumber << " |";
73
74 // at high verbosity print part number, otherwise only the total number of parts
75 if (loglevel > 1) {
76 rdhprintout << " part " + std::to_string(dh->splitPayloadIndex) + " of " + std::to_string(dh->splitPayloadParts);
77 } else {
78 rdhprintout << " " + std::to_string(dh->splitPayloadParts) + " part(s)";
79 }
80 rdhprintout << " payload size " << dh->payloadSize;
81
82 const auto* dph = it.o2DataProcessingHeader();
83 if (dph) {
84 rdhprintout << " | DPH: "
85 << " Start " << dph->startTime << " dT " << dph->duration << " Creation " << dph->creation;
86 }
87 rdhprintout << std::endl;
88 }
89 rdhprintout << DPLRawParser<>::RDHInfo(it) << std::endl;
90 }
91 rdhprintout << it << " payload size " << it.size() << std::endl;
92 }
93 lastDataHeader = dh;
94 }
95 if (loglevel > 0) {
96 LOG(info) << rdhprintout.str();
97 }
98 }); }},
99 Options{
100 {"log-level", VariantType::Int, 1, {"Logging level [0-2]"}}}});
101 return workflow;
102}
A raw page parser for DPL input.
WorkflowSpec defineDataProcessing(ConfigContext const &config)
This function hooks up the the workflow specifications into the DPL driver.
void customize(std::vector< ConfigParamSpec > &workflowOptions)
ConfigParamRegistry & options() const
The parser handles transparently input in the format of raw pages.
const_iterator end() const
const_iterator begin() const
The input API of the Data Processing Layer This class holds the inputs which are valid for processing...
GLuint GLuint end
Definition glcorearb.h:469
GLintptr offset
Definition glcorearb.h:660
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
std::vector< InputSpec > select(char const *matcher="")
std::vector< OutputSpec > Outputs
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
the main header struct
Definition DataHeader.h:618
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"