Project
Loading...
Searching...
No Matches
DCSConsumerSpec.h
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
12#ifndef O2_DCS_CONSUMER_H
13#define O2_DCS_CONSUMER_H
14
18
24#include "Framework/Task.h"
25#include "Framework/Logger.h"
27#include <TStopwatch.h>
28
29using namespace o2::framework;
30namespace o2h = o2::header;
31
32namespace o2
33{
34namespace dcs
35{
37{
38
40
41 public:
43 {
44 mReportTiming = ic.options().get<bool>("report-timing");
45 }
46
48 {
49 TStopwatch sw;
50 uint64_t tfid;
51 for (auto& input : pc.inputs()) {
52 tfid = header::get<o2::framework::DataProcessingHeader*>(input.header)->startTime;
53 LOG(debug) << "tfid = " << tfid;
54 break; // we break because one input is enough to get the TF ID
55 }
56
57 LOG(debug) << "TF: " << tfid << " --> reading binary blob...";
58 mTFs++;
59 auto vect = pc.inputs().get<gsl::span<DPCOM>>("COMMONDPs");
60 LOG(info) << "vector has " << vect.size() << " Data Points inside";
61 sw.Stop();
62 if (mReportTiming) {
63 LOGP(info, "Timing CPU:{:.3e} Real:{:.3e} at slice {}", sw.CpuTime(), sw.RealTime(), pc.services().get<o2::framework::TimingInfo>().timeslice);
64 }
65 }
66
68 {
69
70 LOG(info) << "Number of processed TFs = " << mTFs;
71 }
72
73 private:
74 uint64_t mTFs = 0;
75 bool mReportTiming = false;
76};
77
78} // namespace dcs
79
80namespace framework
81{
82
84{
85 return DataProcessorSpec{
86 "dcs-consumer",
87 Inputs{{"COMMONDPs", "DCS", "COMMON", 0, Lifetime::Timeframe}},
88 Outputs{},
89 AlgorithmSpec{adaptFromTask<o2::dcs::DCSConsumer>()},
90 Options{{"report-timing", VariantType::Bool, false, {"Report timing for every slice"}}}};
91}
92
93} // namespace framework
94} // namespace o2
95
96#endif
std::ostringstream debug
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(o2::framework::ProcessingContext &pc) final
DataProcessorSpec getDCSConsumerSpec(DetID det)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
O2 data header classes and API, v0.1.
Definition DetID.h:49
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
TStopwatch sw