Project
Loading...
Searching...
No Matches
data-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
14#include "DataGeneratorSpec.h"
16
17using namespace o2::framework;
18
19void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
20{
21 policies.push_back(o2::framework::CallbacksPolicy{
22 [](o2::framework::DeviceSpec const& spec, o2::framework::ConfigContext const& context) -> bool {
23 return spec.name == "calib-tf-dispatcher"; // apply policy only to the upstream device
24 },
26 const auto& hbfu = o2::raw::HBFUtils::Instance();
27 long startTime = hbfu.startTime > 0 ? hbfu.startTime : std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()).time_since_epoch().count();
30 const auto& hbfu = o2::raw::HBFUtils::Instance();
31 dh.firstTForbit = hbfu.getFirstIRofTF({0, hbfu.orbitFirstSampled}).orbit + int64_t(hbfu.nHBFPerTF) * dh.tfCounter;
32 dh.runNumber = hbfu.runNumber;
33 dph.creation = startTime + (dh.firstTForbit - hbfu.orbitFirst) * o2::constants::lhc::LHCOrbitMUS * 1.e-3;
34 });
35 }});
36}
37
38// we need to add workflow options before including Framework/runDataProcessing
39void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
40{
41 // option allowing to set parameters
42 workflowOptions.push_back(ConfigParamSpec{"lanes", o2::framework::VariantType::Int, 2, {"number of data generator lanes"}});
43 workflowOptions.push_back(ConfigParamSpec{"gen-norm", o2::framework::VariantType::Int, 1, {"nominal number of expected generators"}});
44 workflowOptions.push_back(ConfigParamSpec{"gen-slot", o2::framework::VariantType::Int, 0, {"generate TFs of slot in [0 : gen-norm) range"}});
45 workflowOptions.push_back(ConfigParamSpec{"pressure", o2::framework::VariantType::Float, 1.f, {"generation / processing rate factor"}});
46 workflowOptions.push_back(ConfigParamSpec{"mean-latency", o2::framework::VariantType::Int, 1000, {"mean latency of the processor in microseconds"}});
47 workflowOptions.push_back(ConfigParamSpec{"latency-spread", o2::framework::VariantType::Int, 100, {"latency gaussian RMS of the processor in microseconds"}});
48 workflowOptions.push_back(ConfigParamSpec{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings ..."}});
49}
50
51// ------------------------------------------------------------------
52
54
56{
57 WorkflowSpec specs;
58 o2::conf::ConfigurableParam::updateFromString(configcontext.options().get<std::string>("configKeyValues"));
59 auto nlanes = std::max(1, configcontext.options().get<int>("lanes"));
60 auto ngen = std::max(1, configcontext.options().get<int>("gen-norm"));
61 auto slot = std::max(0, configcontext.options().get<int>("gen-slot"));
62 auto latency = std::max(1, configcontext.options().get<int>("mean-latency"));
63 auto latencyRMS = std::max(1, configcontext.options().get<int>("latency-spread"));
64 auto pressure = std::max(0.001f, configcontext.options().get<float>("pressure"));
65 if (slot >= ngen) {
66 slot = 0;
67 ngen = 1;
68 }
69 specs.emplace_back(getTFDispatcherSpec(slot, ngen, nlanes, std::max(1, int(float(latency) / nlanes / pressure))));
70 specs.emplace_back(timePipeline(getTFProcessorCalibInfoTOFSpec(latency, latencyRMS), nlanes));
71 return specs;
72}
uint64_t orbit
Definition RawEventData.h:6
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
void customize(std::vector< o2::framework::CallbacksPolicy > &policies)
Dummy data generator.
static void updateFromString(std::string const &)
ConfigParamRegistry & options() const
constexpr double LHCOrbitMUS
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
DataProcessorSpec timePipeline(DataProcessorSpec original, size_t count)
std::string name
The name of the associated DataProcessorSpec.
Definition DeviceSpec.h:50
the main header struct
Definition DataHeader.h:618