Project
Loading...
Searching...
No Matches
fake-irframe-generator-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
18#include "Framework/Lifetime.h"
19#include "Framework/Logger.h"
20#include "Framework/Output.h"
21#include "Framework/Task.h"
25#include <fmt/format.h>
26#include <sstream>
27#include <stdexcept>
28#include <vector>
29#include <rapidjson/document.h>
30#include <rapidjson/istreamwrapper.h>
31
32using namespace o2::mch;
33using namespace o2::framework;
34
40class IRFrameGenerator : public Task
41{
42 public:
43 void init(InitContext& ic) override
44 {
45 std::stringstream in(ic.options().get<std::string>("irframes"));
46 rapidjson::IStreamWrapper isw(in);
47 rapidjson::Document d;
48 d.ParseStream(isw);
49
50 if (!d.IsArray()) {
51 throw std::runtime_error(fmt::format("input string is not expected json : {}", in.str()));
52 }
53 for (auto& v : d.GetArray()) {
54 const auto& jstart = v["min"].GetObject();
55 o2::InteractionRecord start{static_cast<uint16_t>(std::stoi(jstart["bc"].GetString())),
56 static_cast<uint32_t>(std::stoi(jstart["orbit"].GetString()))};
57 const auto& jend = v["max"].GetObject();
58 o2::InteractionRecord end{static_cast<uint16_t>(std::stoi(jend["bc"].GetString())),
59 static_cast<uint32_t>(std::stoi(jend["orbit"].GetString()))};
60 mIRFrames.emplace_back(start, end);
61 }
62 LOGP(info, "Fake IRFrames to be used");
63 for (const auto& ir : mIRFrames) {
64 LOGP(info, "{}", ir.asString());
65 }
66 }
67
68 void run(ProcessingContext& pc) override
69 {
70 pc.outputs().snapshot(OutputRef{"irframes"}, mIRFrames);
71 }
72
73 private:
74 std::vector<o2::dataformats::IRFrame> mIRFrames;
75};
76
78
80{
81 std::string defaultFrames = R"(
82[
83 {
84 "min": {
85 "bc": "0",
86 "orbit": "1021"
87 },
88 "max": {
89 "bc": "1000",
90 "orbit": "1021"
91 }
92 },
93 {
94 "min": {
95 "bc": "2000",
96 "orbit": "1023"
97 },
98 "max": {
99 "bc": "2500",
100 "orbit": "1023"
101 }
102 }
103])";
104 return WorkflowSpec{
106 "mch-fake-irframe-generator",
107 Inputs{InputSpec{"digits", "MCH", "DIGITS", 0, Lifetime::Timeframe}},
108 Outputs{
109 OutputSpec{{"irframes"}, "ITS", "IRFRAMES", 0, Lifetime::Timeframe}},
110 AlgorithmSpec{adaptFromTask<IRFrameGenerator>()},
111 Options{
112 {"irframes", VariantType::String, defaultFrames, {"list of IRFrame to fake (json format)"}}}}};
113}
unsigned short int uint16_t
unsigned int uint32_t
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 d
Class to delimit start and end IR of certain time period.
void init(InitContext &ic) override
void run(ProcessingContext &pc) override
void snapshot(const Output &spec, T const &object)
ConfigParamRegistry const & options()
Definition InitContext.h:33
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
WorkflowSpec defineDataProcessing(const ConfigContext &cc)
GLuint GLuint end
Definition glcorearb.h:469
const GLdouble * v
Definition glcorearb.h:832
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
std::string asString() const
std::vector< o2::mch::ChannelCode > cc
o2::InteractionRecord ir(0, 0)