-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathBenchmarkTask.cxx
More file actions
93 lines (76 loc) · 3.05 KB
/
BenchmarkTask.cxx
File metadata and controls
93 lines (76 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file BenchmarkTask.cxx
/// \author Barthelemy von Haller
///
#include "Example/BenchmarkTask.h"
#include <Configuration/ConfigurationFactory.h>
#include "QualityControl/QcInfoLogger.h"
#include <TCanvas.h>
#include <TH1.h>
#include <thread>
using namespace std;
using namespace o2::configuration;
namespace o2::quality_control_modules::example
{
// These two cannot be in the header, because ctors and dtors need to know how to construct and destruct
// ConfigurationInterface, which is only forward-declared in the header.
BenchmarkTask::BenchmarkTask() = default;
BenchmarkTask::~BenchmarkTask() = default;
void BenchmarkTask::initialize(o2::framework::InitContext& /*ctx*/)
{
ILOG(Debug, Devel) << "initialize benchmarktask \"" << getName() << "\""
<< ENDM;
mConfigFile = ConfigurationFactory::getConfiguration("file:./example.ini");
string prefix = "qc.tasks_config." + getName();
string taskDefinitionName = mConfigFile->get<std::string>(prefix + ".taskDefinition");
auto taskConfigTree = mConfigFile->getRecursive(taskDefinitionName);
mNumberHistos = taskConfigTree.get<int>("numberHistos");
mNumberChecks = taskConfigTree.get<int>("numberChecks");
mTypeOfChecks = taskConfigTree.get<std::string>("typeOfChecks");
mModuleOfChecks = taskConfigTree.get<std::string>("moduleOfChecks");
mHistos.reserve(mNumberHistos);
// Create and publish the histos
for (size_t i = 0; i < mNumberHistos; i++) {
assert(mHistos.empty()); // because otherwise the code below makes no sense.
stringstream name;
name << "histogram_" << getName() << "_" << i;
mHistos.push_back(new TH1F(name.str().c_str(), name.str().c_str(), 1000, -5, 5));
getObjectsManager()->startPublishing(mHistos[i], PublicationPolicy::Forever);
}
}
void BenchmarkTask::startOfActivity(const Activity& /*activity*/)
{
ILOG(Debug, Devel) << "startOfActivity" << ENDM;
}
void BenchmarkTask::startOfCycle()
{
ILOG(Debug, Devel) << "startOfCycle" << ENDM;
}
void BenchmarkTask::monitorData(o2::framework::ProcessingContext& /*ctx*/)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100) /*100ms*/);
}
void BenchmarkTask::endOfCycle()
{
for (auto histo : mHistos) {
histo->Reset();
histo->FillRandom("gaus", 1000);
}
ILOG(Debug, Devel) << "endOfCycle" << ENDM;
}
void BenchmarkTask::endOfActivity(const Activity& /*activity*/)
{
ILOG(Debug, Devel) << "endOfActivity" << ENDM;
}
void BenchmarkTask::reset() { ILOG(Info, Support) << "Reset" << ENDM; }
} // namespace o2::quality_control_modules::example