forked from AliceO2Group/QualityControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnalysisTask.cxx
96 lines (78 loc) · 2.76 KB
/
AnalysisTask.cxx
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
94
95
96
// 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 AnalysisTask.cxx
/// \author Piotr Konopka
///
#include <TCanvas.h>
#include <TH1.h>
#include "QualityControl/QcInfoLogger.h"
#include "Example/AnalysisTask.h"
#include <Framework/TableConsumer.h>
#include <Framework/InputRecord.h>
#include <arrow/table.h>
namespace o2::quality_control_modules::example
{
AnalysisTask::~AnalysisTask()
{
delete mHistogram;
}
void AnalysisTask::initialize(o2::framework::InitContext& /*ctx*/)
{
ILOG(Debug, Devel) << "initialize AnalysisTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
mHistogram = new TH1F("example", "example", 20, 0, 30000);
getObjectsManager()->startPublishing(mHistogram);
}
void AnalysisTask::startOfActivity(const Activity& activity)
{
ILOG(Debug, Devel) << "startOfActivity" << activity.mId << ENDM;
mHistogram->Reset();
}
void AnalysisTask::startOfCycle()
{
ILOG(Debug, Devel) << "startOfCycle" << ENDM;
}
void AnalysisTask::monitorData(o2::framework::ProcessingContext& ctx)
{
ILOG(Info, Devel) << "Monitor data" << ENDM;
auto s = ctx.inputs().get<framework::TableConsumer>("aod-data");
auto table = s->asArrowTable();
if (table->num_rows() == 0) {
ILOG(Error, Support) << "The arrow table is empty" << table->num_rows() << ENDM;
return;
}
ILOG(Info, Devel) << "The arrow table has " << table->num_rows() << " rows" << ENDM;
mHistogram->Fill(table->num_rows());
if (table->num_columns() == 0) {
ILOG(Error, Support) << "No columns in the arrow table" << table->num_columns() << ENDM;
return;
}
ILOG(Info, Support) << "The arrow table has " << table->num_columns() << " columns" << ENDM;
mHistogram->Fill(table->num_columns());
// Here you can perform analysis of the columnar data.
// Please refer to the documentation of DPL Analysis, Apache Arrow
// and RDataFrame's support of Apache Arrow.
}
void AnalysisTask::endOfCycle()
{
ILOG(Debug, Devel) << "endOfCycle" << ENDM;
}
void AnalysisTask::endOfActivity(const Activity& /*activity*/)
{
ILOG(Debug, Devel) << "endOfActivity" << ENDM;
}
void AnalysisTask::reset()
{
// clean all the monitor objects here
ILOG(Debug, Devel) << "Resetting the histograms" << ENDM;
mHistogram->Reset();
}
} // namespace o2::quality_control_modules::example