Project
Loading...
Searching...
No Matches
rawfile-reader-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
17#include "Framework/Logger.h"
18#include <string>
19#include <bitset>
20
21using namespace o2::framework;
22using namespace o2::raw;
23
24// we need to add workflow options before including Framework/runDataProcessing
25void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
26{
27 // option allowing to set parameters
28 std::vector<o2::framework::ConfigParamSpec> options;
29 options.push_back(ConfigParamSpec{"input-conf", VariantType::String, "", {"configuration file with input (obligatory)"}});
30 options.push_back(ConfigParamSpec{"onlyDet", VariantType::String, "all", {"list of dectors"}});
31 options.push_back(ConfigParamSpec{"min-tf", VariantType::Int64, 0L, {"min TF ID to process"}});
32 options.push_back(ConfigParamSpec{"max-tf", VariantType::Int64, 0xffffffffL, {"max TF ID to process"}});
33 options.push_back(ConfigParamSpec{"run-number", VariantType::Int, 0, {"impose run number"}});
34 options.push_back(ConfigParamSpec{"loop", VariantType::Int, 1, {"loop N times (infinite for N<0)"}});
35 options.push_back(ConfigParamSpec{"delay", VariantType::Float, 0.f, {"delay in seconds between consecutive TFs sending"}});
36 options.push_back(ConfigParamSpec{"buffer-size", VariantType::Int64, 5 * 1024L, {"buffer size for files preprocessing"}});
37 options.push_back(ConfigParamSpec{"super-page-size", VariantType::Int64, 1024L * 1024L, {"super-page size for FMQ parts definition"}});
38 options.push_back(ConfigParamSpec{"part-per-sp", VariantType::Bool, false, {"FMQ parts per superpage instead of per HBF"}});
39 options.push_back(ConfigParamSpec{"raw-channel-config", VariantType::String, "", {"optional raw FMQ channel for non-DPL output"}});
40 options.push_back(ConfigParamSpec{"cache-data", VariantType::Bool, false, {"cache data at 1st reading, may require excessive memory!!!"}});
41 options.push_back(ConfigParamSpec{"detect-tf0", VariantType::Bool, false, {"autodetect HBFUtils start Orbit/BC from 1st TF seen"}});
42 options.push_back(ConfigParamSpec{"calculate-tf-start", VariantType::Bool, false, {"calculate TF start instead of using TType"}});
43 options.push_back(ConfigParamSpec{"drop-tf", VariantType::String, "none", {"Drop each TFid%(1)==(2) of detector, e.g. ITS,2,4;TPC,4[,0];..."}});
44 options.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"semicolon separated key=value strings"}});
45 options.push_back(ConfigParamSpec{"send-diststf-0xccdb", VariantType::Bool, false, {"send explicit FLP/DISTSUBTIMEFRAME/0xccdb output"}});
46 options.push_back(ConfigParamSpec{"hbfutils-config", VariantType::String, std::string(o2::base::NameConf::DIGITIZATIONCONFIGFILE), {"configKeyValues ini file for HBFUtils (used if exists)"}});
47 options.push_back(ConfigParamSpec{"timeframes-shm-limit", VariantType::String, "0", {"Minimum amount of SHM required in order to publish data"}});
48 options.push_back(ConfigParamSpec{"metric-feedback-channel-format", VariantType::String, "name=metric-feedback,type=pull,method=connect,address=ipc://{}metric-feedback-{},transport=shmem,rateLogging=0", {"format for the metric-feedback channel for TF rate limiting"}});
49 // options for error-check suppression
50
51 for (int i = 0; i < RawFileReader::NErrorsDefined; i++) {
52 auto ei = RawFileReader::ErrTypes(i);
53 options.push_back(ConfigParamSpec{RawFileReader::nochk_opt(ei), VariantType::Bool, false, {RawFileReader::nochk_expl(ei)}});
54 }
55 std::swap(workflowOptions, options);
56}
57
58// ------------------------------------------------------------------
59
61
63{
64 ReaderInp rinp;
65 rinp.inifile = configcontext.options().get<std::string>("input-conf");
66 rinp.loop = configcontext.options().get<int>("loop");
67 rinp.onlyDet = configcontext.options().get<std::string>("onlyDet");
68 rinp.maxTF = uint32_t(configcontext.options().get<int64_t>("max-tf"));
69 rinp.minTF = uint32_t(configcontext.options().get<int64_t>("min-tf"));
70 rinp.runNumber = configcontext.options().get<int>("run-number");
71 rinp.bufferSize = uint64_t(configcontext.options().get<int64_t>("buffer-size"));
72 rinp.spSize = uint64_t(configcontext.options().get<int64_t>("super-page-size"));
73 rinp.partPerSP = configcontext.options().get<bool>("part-per-sp");
74 rinp.cache = configcontext.options().get<bool>("cache-data");
75 rinp.autodetectTF0 = configcontext.options().get<bool>("detect-tf0");
76 rinp.preferCalcTF = configcontext.options().get<bool>("calculate-tf-start");
77 rinp.rawChannelConfig = configcontext.options().get<std::string>("raw-channel-config");
78 rinp.delay_us = uint32_t(1e6 * configcontext.options().get<float>("delay")); // delay in microseconds
79 rinp.dropTF = configcontext.options().get<std::string>("drop-tf");
80 rinp.sup0xccdb = !configcontext.options().get<bool>("send-diststf-0xccdb");
81 rinp.errMap = 0;
82 for (int i = RawFileReader::NErrorsDefined; i--;) {
83 auto ei = RawFileReader::ErrTypes(i);
85 if (configcontext.options().get<bool>(RawFileReader::nochk_opt(ei).c_str()) ? !defOpt : defOpt) { // cmdl option inverts default!
86 rinp.errMap |= 0x1 << i;
87 }
88 }
89 rinp.minSHM = std::stoul(configcontext.options().get<std::string>("timeframes-shm-limit"));
90 int rateLimitingIPCID = std::stoi(configcontext.options().get<std::string>("timeframes-rate-limit-ipcid"));
91 std::string chanFmt = configcontext.options().get<std::string>("metric-feedback-channel-format");
92 if (rateLimitingIPCID > -1 && !chanFmt.empty()) {
93 rinp.metricChannel = fmt::format(fmt::runtime(chanFmt), o2::framework::ChannelSpecHelpers::defaultIPCFolder(), rateLimitingIPCID);
94 }
95 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
96 auto hbfini = configcontext.options().get<std::string>("hbfutils-config");
97 if (!hbfini.empty() && o2::conf::ConfigurableParam::configFileExists(hbfini)) {
98 o2::conf::ConfigurableParam::updateFromFile(hbfini, "HBFUtils", true); // update only those values which were not touched yet (provenance == kCODE)
99 }
100 return std::move(o2::raw::getRawFileReaderWorkflow(rinp));
101}
int32_t i
Definition of the Names Generator class.
Reader for (multiple) raw data files.
static constexpr std::string_view DIGITIZATIONCONFIGFILE
Definition NameConf.h:89
static bool configFileExists(std::string const &filepath)
static void updateFromFile(std::string const &, std::string const &paramsList="", bool unchangedOnly=false)
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
static std::string nochk_expl(ErrTypes e)
static constexpr bool ErrCheckDefaults[]
static std::string nochk_opt(ErrTypes e)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
framework::WorkflowSpec getRawFileReaderWorkflow(ReaderInp &rinp)
void customize(std::vector< o2::framework::ConfigParamSpec > &workflowOptions)
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
std::string rawChannelConfig
std::string inifile
std::string onlyDet
std::string metricChannel