Project
Loading...
Searching...
No Matches
dump-pages-workflow.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
24
25#include <random>
26#include <iostream>
27#include <queue>
28#include <fstream>
29#include <stdexcept>
34#include "Framework/Lifetime.h"
35#include "Framework/Output.h"
36#include "Framework/Task.h"
40
44
45using namespace o2;
46using namespace o2::framework;
47using namespace o2::raw;
48
49namespace o2
50{
51namespace mch
52{
53namespace raw
54{
55
57
59{
60 public:
61 DumpPagesTask(std::string spec) : mInputSpec(spec) {}
62 //_________________________________________________________________________________________________
64 {
66 LOG(info) << "initializing pager dumper";
67
68 auto outputFileName = ic.options().get<std::string>("outfile");
69 mOutputFile.open(outputFileName, std::ios::binary);
70 if (!mOutputFile.is_open()) {
71 throw std::invalid_argument("Cannot open output file \"" + outputFileName + "\"");
72 }
73
74 auto stop = [this]() {
76 LOG(info) << "stop file reader";
77 this->mOutputFile.close();
78 };
79 ic.services().get<CallbackService>().set<CallbackService::Id::Stop>(stop);
80 }
81
82 //_________________________________________________________________________________________________
84 {
85 // get the input buffer
86 auto& inputs = pc.inputs();
87 DPLRawParser parser(inputs, o2::framework::select(mInputSpec.c_str()));
88 for (auto it = parser.begin(), end = parser.end(); it != end; ++it) {
89 auto const* raw = it.raw();
90 if (!raw) {
91 continue;
92 }
93 size_t payloadSize = it.size();
94
95 mOutputFile.write(reinterpret_cast<const char*>(raw), sizeof(RDH) + payloadSize);
96 }
97 }
98
99 private:
100 std::string mInputSpec{"TF:MCH/RAWDATA"};
101 std::ofstream mOutputFile{};
102};
103
104//_________________________________________________________________________________________________
105// clang-format off
107{
108 auto inputs = o2::framework::select("TF:MCH/RAWDATA");
109 //o2::mch::raw::DumpPagesTask task("TF:MCH/RAWDATA");
110 return DataProcessorSpec{
111 specName,
112 inputs,
113 Outputs{},
114 //AlgorithmSpec{adaptFromTask<o2::mch::raw::DumpPagesTask>(std::move(task))},
115 AlgorithmSpec{adaptFromTask<o2::mch::raw::DumpPagesTask>("TF:MCH/RAWDATA")},
116 Options{{"outfile", VariantType::String, "data.raw", {"output file name"}}}};
117}
118// clang-format on
119
120} // end namespace raw
121} // end namespace mch
122} // end namespace o2
123
124using namespace o2;
125using namespace o2::framework;
126
128{
129 WorkflowSpec specs;
130
131 // The producer to generate some data in the workflow
132 DataProcessorSpec producer = mch::raw::getDumpPagesSpec("mch-page-dumper");
133 specs.push_back(producer);
134
135 return specs;
136}
A raw page parser for DPL input.
Definition of the RAW Data Header.
const char * specName
The parser handles transparently input in the format of raw pages.
const_iterator end() const
const_iterator begin() const
ServiceRegistryRef services()
Definition InitContext.h:34
ConfigParamRegistry const & options()
Definition InitContext.h:33
InputRecord & inputs()
The inputs associated with this processing context.
void run(framework::ProcessingContext &pc)
void init(framework::InitContext &ic)
WorkflowSpec defineDataProcessing(const ConfigContext &)
GLuint GLuint end
Definition glcorearb.h:469
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > select(char const *matcher="")
std::vector< OutputSpec > Outputs
o2::framework::DataProcessorSpec getDumpPagesSpec(const char *specName)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"