Project
Loading...
Searching...
No Matches
ReaderDriverSpec.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
13
14#include <vector>
15#include <cassert>
16#include <fairmq/Device.h>
19#include "Framework/Task.h"
20#include "Framework/Logger.h"
27#include "TFile.h"
28#include "TTree.h"
29
30using namespace o2::framework;
31
32namespace o2
33{
34namespace globaltracking
35{
37
39{
40 public:
41 ReadeDriverSpec(size_t minSHM) : mMinSHM(minSHM) {}
42 ~ReadeDriverSpec() override = default;
43 void init(o2::framework::InitContext& ic) final;
45
46 protected:
47 int mTFRateLimit = -999;
48 int mNTF = 0;
49 size_t mMinSHM = 0;
50};
51
53{
54 mNTF = ic.options().get<int>("max-tf");
55}
56
58{
59 if (mTFRateLimit == -999) {
60 mTFRateLimit = std::stoi(pc.services().get<RawDeviceService>().device()->fConfig->GetValue<std::string>("timeframes-rate-limit"));
61 }
62 static RateLimiter limiter;
63 static int count = 0;
64 if (!count) {
65 if (HBFINI::NTFs < 0) {
66 LOGP(fatal, "Number of TFs to process was not initizalized in the HBFUtilsInitializer");
67 }
68 mNTF = (mNTF > 0 && mNTF < HBFINI::NTFs) ? mNTF : HBFINI::NTFs;
69 } else { // check only for count > 0
70 limiter.check(pc, mTFRateLimit, mMinSHM);
71 }
72 auto& v = pc.outputs().make<std::vector<o2::dataformats::IRFrame>>(Output{"GLO", "READER_DRIVER", 0});
73 if (!HBFINI::IRFrameSel.getMin().isDummy() && !HBFINI::IRFrameSel.getMax().isDummy()) {
74 v.push_back(HBFINI::IRFrameSel);
75 LOGP(debug, "OUTVEC {}/{}", v.back().getMin().asString(), v.back().getMax().asString());
76 }
77 count++;
78 if ((HBFINI::LastIRFrameIndex == -1 && count >= mNTF) || (v.size() && v.back().isLast())) {
80 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
81 }
82}
83
84DataProcessorSpec getReaderDriverSpec(const std::string& metricChannel, size_t minSHM)
85{
86 std::vector<OutputSpec> outputSpec;
87 std::vector<ConfigParamSpec> options;
88 options.emplace_back(ConfigParamSpec{"max-tf", o2::framework::VariantType::Int, -1, {"max TFs to process (<1 : no limits)"}});
89 if (!metricChannel.empty()) {
90 options.emplace_back(ConfigParamSpec{"channel-config", VariantType::String, metricChannel, {"Out-of-band channel config for TF throttling"}});
91 }
92 return DataProcessorSpec{
94 Inputs{},
95 Outputs{{"GLO", "READER_DRIVER", 0, Lifetime::Timeframe}},
96 AlgorithmSpec{adaptFromTask<ReadeDriverSpec>(minSHM)},
97 options};
98}
99
100} // namespace globaltracking
101} // namespace o2
Class to delimit start and end IR of certain time period.
std::ostringstream debug
decltype(auto) make(const Output &spec, Args... args)
ConfigParamRegistry const & options()
Definition InitContext.h:33
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
int check(ProcessingContext &ctx, int maxInFlight, size_t minSHM)
virtual fair::mq::Device * device()=0
virtual void endOfStream(EndOfStreamContext &context)
This is invoked whenever we have an EndOfStream event.
Definition Task.h:43
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
GLint GLsizei count
Definition glcorearb.h:399
const GLdouble * v
Definition glcorearb.h:832
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
framework::DataProcessorSpec getReaderDriverSpec(const std::string &metricChannel="", size_t minSHM=0)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr char ReaderDriverDevice[]
static o2::dataformats::IRFrame IRFrameSel