Skip to content

Commit 8c9d8df

Browse files
MIDAggregator (#2189)
* add MIDAggregator * Add MIDAggregator * clang format error
1 parent 2f70542 commit 8c9d8df

9 files changed

Lines changed: 240 additions & 105 deletions

File tree

Modules/MUON/MID/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_sources(
2020
src/HistoHelper.cxx
2121
src/MIDTrending.cxx
2222
src/TrendingTaskConfigMID.cxx
23+
src/MIDAggregator.cxx
2324
)
2425

2526
target_include_directories(
@@ -53,7 +54,8 @@ add_root_dictionary(
5354
include/MID/HistoHelper.h
5455
include/MID/MIDTrending.h
5556
include/MID/TrendingTaskConfigMID.h
56-
LINKDEF include/MID/LinkDef.h)
57+
include/MID/MIDAggregator.h
58+
LINKDEF include/MID/LinkDef.h)
5759

5860

5961
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/MID DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/QualityControl")

Modules/MUON/MID/include/MID/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
#pragma link C++ class o2::quality_control_modules::mid::HistoHelper + ;
2020
#pragma link C++ class o2::quality_control::postprocessing::TrendingTaskConfigMID + ;
2121
#pragma link C++ class o2::quality_control::postprocessing::MIDTrending + ;
22+
#pragma link C++ class o2::quality_control_modules::mid::MIDAggregator + ;
2223

2324
#endif
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
///
13+
/// \file MIDAggregator.h
14+
/// \author V.Ramillien
15+
///
16+
17+
#ifndef QUALITYCONTROL_MIDAGGREGATOR_H
18+
#define QUALITYCONTROL_MIDAGGREGATOR_H
19+
20+
// ROOT
21+
#include <Rtypes.h>
22+
// QC
23+
#include "QualityControl/AggregatorInterface.h"
24+
25+
namespace o2::quality_control_modules::mid
26+
{
27+
28+
/// \brief Example QC quality aggregator
29+
/// \author My Name
30+
class MIDAggregator : public o2::quality_control::checker::AggregatorInterface
31+
{
32+
public:
33+
// Override interface
34+
void configure() override;
35+
std::map<std::string, o2::quality_control::core::Quality> aggregate(o2::quality_control::core::QualityObjectsMapType& qoMap) override;
36+
37+
ClassDefOverride(MIDAggregator, 1);
38+
};
39+
40+
} // namespace o2::quality_control_modules::mid
41+
42+
#endif // QUALITYCONTROL_MIDAGGREGATOR_H

Modules/MUON/MID/src/CalibMQcCheck.cxx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ Quality CalibMQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
3434
Quality result = Quality::Null;
3535
for (auto& item : *moMap) {
3636
if (item.second->getName() == "NbBadChannelTF") {
37-
auto nbTFs = static_cast<TH1F*>(item.second->getObject())->GetBinContent(1);
38-
mHistoHelper.setNTFs(nbTFs);
39-
result = (nbTFs == 0) ? Quality::Bad : Quality::Good;
37+
auto nbTFs = dynamic_cast<TH1F*>(item.second->getObject())->GetBinContent(1);
38+
if (nbTFs) {
39+
mHistoHelper.setNTFs(nbTFs);
40+
result = (nbTFs == 0) ? Quality::Bad : Quality::Good;
41+
}
4042
return result;
4143
}
4244
}
@@ -56,10 +58,12 @@ void CalibMQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
5658
auto color = mHistoHelper.getColor(checkResult);
5759
if (mo->getName().find("BendBadMap") != std::string::npos) {
5860
auto* h2 = static_cast<TH2*>(mo->getObject());
59-
if (checkResult == Quality::Bad) {
60-
mHistoHelper.addLatex(h2, 0.2, 0.8, color, "Calib objects not produced!");
61+
if (h2) {
62+
if (checkResult == Quality::Bad) {
63+
mHistoHelper.addLatex(h2, 0.2, 0.8, color, "Calib objects not produced!");
64+
}
65+
mHistoHelper.addLatex(h2, 0.15, 0.5, color, fmt::format("Quality::{}", checkResult.getName()));
6166
}
62-
mHistoHelper.addLatex(h2, 0.15, 0.5, color, fmt::format("Quality::{}", checkResult.getName()));
6367
}
6468
}
6569

Modules/MUON/MID/src/CalibQcCheck.cxx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ Quality CalibQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>
4646

4747
for (auto& item : *moMap) {
4848
if (item.second->getName() == "NbTimeFrame") {
49-
mHistoHelper.setNTFs(static_cast<TH1F*>(item.second->getObject())->GetBinContent(1));
49+
mHistoHelper.setNTFs(dynamic_cast<TH1F*>(item.second->getObject())->GetBinContent(1));
5050
result = mHistoHelper.getNTFs() == 0 ? Quality::Bad : Quality::Good;
5151
} else if (item.second->getName() == "NbDeadROF") {
52-
mDeadRof = static_cast<TH1F*>(item.second->getObject())->GetBinContent(1);
52+
mDeadRof = dynamic_cast<TH1F*>(item.second->getObject())->GetBinContent(1);
5353
}
5454
}
5555
return result;
@@ -66,17 +66,21 @@ void CalibQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResu
6666
// Normalize Map and Strips objects
6767
if (mo->getName().find("Noise") != std::string::npos) {
6868
// Scale histograms with noise info
69-
auto histo = static_cast<TH1*>(mo->getObject());
70-
mHistoHelper.normalizeHistoTokHz(histo);
71-
if (mo->getName().find("Map") != std::string::npos) {
72-
histo->SetMaximum(10.);
69+
auto histo = dynamic_cast<TH1*>(mo->getObject());
70+
if (histo) {
71+
mHistoHelper.normalizeHistoTokHz(histo);
72+
if (mo->getName().find("Map") != std::string::npos) {
73+
histo->SetMaximum(10.);
74+
}
7375
}
7476
} else if (mo->getName().find("Dead") != std::string::npos) {
7577
if (mDeadRof > 0.) {
7678
// Scale histograms with dead channels info
77-
auto histo = static_cast<TH1*>(mo->getObject());
78-
histo->Scale(100. / mDeadRof);
79-
mHistoHelper.updateTitle(histo, " (%)");
79+
auto histo = dynamic_cast<TH1*>(mo->getObject());
80+
if (histo) {
81+
histo->Scale(100. / mDeadRof);
82+
mHistoHelper.updateTitle(histo, " (%)");
83+
}
8084
}
8185
}
8286
}

Modules/MUON/MID/src/ClustQcCheck.cxx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,39 @@ void ClustQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResu
116116

117117
if (mo->getName() == "ClusterMap11") {
118118
auto* h2 = dynamic_cast<TH2F*>(mo->getObject());
119-
updateTitle(h2, "(Hz)");
120-
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
121-
updateTitle(h2, getCurrentTime());
122-
h2->SetMaximum(mClusterScale);
119+
if (h2) {
120+
updateTitle(h2, "(Hz)");
121+
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
122+
updateTitle(h2, getCurrentTime());
123+
h2->SetMaximum(mClusterScale);
124+
}
123125
}
124126
if (mo->getName() == "ClusterMap12") {
125127
auto* h2 = dynamic_cast<TH2F*>(mo->getObject());
126-
updateTitle(h2, "(Hz)");
127-
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
128-
updateTitle(h2, getCurrentTime());
129-
h2->SetMaximum(mClusterScale);
128+
if (h2) {
129+
updateTitle(h2, "(Hz)");
130+
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
131+
updateTitle(h2, getCurrentTime());
132+
h2->SetMaximum(mClusterScale);
133+
}
130134
}
131135
if (mo->getName() == "ClusterMap21") {
132136
auto* h2 = dynamic_cast<TH2F*>(mo->getObject());
133-
updateTitle(h2, "(Hz)");
134-
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
135-
updateTitle(h2, getCurrentTime());
136-
h2->SetMaximum(mClusterScale);
137+
if (h2) {
138+
updateTitle(h2, "(Hz)");
139+
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
140+
updateTitle(h2, getCurrentTime());
141+
h2->SetMaximum(mClusterScale);
142+
}
137143
}
138144
if (mo->getName() == "ClusterMap22") {
139145
auto* h2 = dynamic_cast<TH2F*>(mo->getObject());
140-
updateTitle(h2, "(Hz)");
141-
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
142-
updateTitle(h2, getCurrentTime());
143-
h2->SetMaximum(mClusterScale);
146+
if (h2) {
147+
updateTitle(h2, "(Hz)");
148+
updateTitle(h2, Form("- TF=%3.0f -", mClusterTF));
149+
updateTitle(h2, getCurrentTime());
150+
h2->SetMaximum(mClusterScale);
151+
}
144152
}
145153
}
146154

Modules/MUON/MID/src/DigitsQcCheck.cxx

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Quality DigitsQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
6767
TH1* meanMultiHits = nullptr;
6868
for (auto& item : *moMap) {
6969
if (item.second->getName() == "NbDigitTF") {
70-
mHistoHelper.setNTFs(static_cast<TH1F*>(item.second->getObject())->GetBinContent(1));
70+
mHistoHelper.setNTFs(dynamic_cast<TH1F*>(item.second->getObject())->GetBinContent(1));
7171
} else if (item.second->getName() == "MeanMultiHits") {
72-
meanMultiHits = static_cast<TH1*>(item.second->getObject());
72+
meanMultiHits = dynamic_cast<TH1*>(item.second->getObject());
7373
}
7474
}
7575

@@ -88,7 +88,7 @@ Quality DigitsQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
8888
for (auto& item : *moMap) {
8989
if (item.second->getName().find("MultHitMT") != std::string::npos) {
9090
std::string hName = item.second->getName();
91-
auto mean = static_cast<TH1*>(item.second->getObject())->GetMean();
91+
auto mean = dynamic_cast<TH1*>(item.second->getObject())->GetMean();
9292
meanMultiHits->SetBinContent(ref[hName], mean);
9393
auto qual = Quality::Good;
9494
if (mean == 0.) {
@@ -124,29 +124,31 @@ Quality DigitsQcCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
124124
nBadLB = 0;
125125
maxVal = 0;
126126
minVal = 1000;
127-
auto histo = static_cast<TH2F*>(item.second->getObject());
128-
mHistoHelper.normalizeHistoTokHz(histo);
129-
for (int bx = 1; bx < 15; bx++) {
130-
for (int by = 1; by < 37; by++) {
131-
if (!((bx > 6) && (bx < 9) && (by > 15) && (by < 22))) { // central zone empty
132-
double val = histo->GetBinContent(bx, by);
133-
if (val > maxVal) {
134-
maxVal = val;
135-
}
136-
if (val < minVal) {
137-
minVal = val;
138-
}
139-
if (val == 0) {
140-
nEmptyLB++;
141-
} else if (val > mLocalBoardThreshold) {
142-
nBadLB++;
127+
auto histo = dynamic_cast<TH2F*>(item.second->getObject());
128+
if (histo) {
129+
mHistoHelper.normalizeHistoTokHz(histo);
130+
for (int bx = 1; bx < 15; bx++) {
131+
for (int by = 1; by < 37; by++) {
132+
if (!((bx > 6) && (bx < 9) && (by > 15) && (by < 22))) { // central zone empty
133+
double val = histo->GetBinContent(bx, by);
134+
if (val > maxVal) {
135+
maxVal = val;
136+
}
137+
if (val < minVal) {
138+
minVal = val;
139+
}
140+
if (val == 0) {
141+
nEmptyLB++;
142+
} else if (val > mLocalBoardThreshold) {
143+
nBadLB++;
144+
}
145+
if ((bx == 1) || (bx == 14) || (by == 1) || (by == 33)) {
146+
by += 3;
147+
} // zones 1 board
148+
else if (!((bx > 4) && (bx < 11) && (by > 12) && (by < 25))) {
149+
by += 1;
150+
} // zones 2 boards
143151
}
144-
if ((bx == 1) || (bx == 14) || (by == 1) || (by == 33)) {
145-
by += 3;
146-
} // zones 1 board
147-
else if (!((bx > 4) && (bx < 11) && (by > 12) && (by < 25))) {
148-
by += 1;
149-
} // zones 2 boards
150152
}
151153
}
152154
}
@@ -211,19 +213,23 @@ void DigitsQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
211213
if (mo->getName().find("MultHitMT") != std::string::npos) {
212214
// This matches "MultHitMT*"
213215
if (mHistoHelper.getNTFs() > 0) {
214-
auto histo = static_cast<TH1F*>(mo->getObject());
215-
histo->SetFillColor(color);
216-
mHistoHelper.addLatex(histo, 0.15, 0.82, color, Form("Limit : [%g;%g]", mMinMultThreshold, mMeanMultThreshold));
217-
mHistoHelper.addLatex(histo, 0.3, 0.62, color, Form("Mean=%g ", histo->GetMean()));
218-
mHistoHelper.addLatex(histo, 0.3, 0.52, color, fmt::format("Quality::{}", checkResult.getName()));
219-
histo->SetTitleSize(0.04);
220-
histo->SetLineColor(kBlack);
216+
auto histo = dynamic_cast<TH1F*>(mo->getObject());
217+
if (histo) {
218+
histo->SetFillColor(color);
219+
mHistoHelper.addLatex(histo, 0.15, 0.82, color, Form("Limit : [%g;%g]", mMinMultThreshold, mMeanMultThreshold));
220+
mHistoHelper.addLatex(histo, 0.3, 0.62, color, Form("Mean=%g ", histo->GetMean()));
221+
mHistoHelper.addLatex(histo, 0.3, 0.52, color, fmt::format("Quality::{}", checkResult.getName()));
222+
histo->SetTitleSize(0.04);
223+
histo->SetLineColor(kBlack);
224+
}
221225
}
222226
} else if (mo->getName() == "MeanMultiHits") {
223-
auto histo = static_cast<TH1F*>(mo->getObject());
224-
mHistoHelper.addLatex(histo, 0.3, 0.52, color, fmt::format("Quality::{}", checkResult.getName()));
225-
mHistoHelper.updateTitleWithNTF(histo);
226-
histo->SetStats(0);
227+
auto histo = dynamic_cast<TH1F*>(mo->getObject());
228+
if (histo) {
229+
mHistoHelper.addLatex(histo, 0.3, 0.52, color, fmt::format("Quality::{}", checkResult.getName()));
230+
mHistoHelper.updateTitleWithNTF(histo);
231+
histo->SetStats(0);
232+
}
227233
} else {
228234
// Change palette contours so that visibility of low-multiplicity strips or boards is improved
229235
std::vector<double> zcontoursLoc{ 0, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10, 25, 50, 75, 100 };
@@ -238,7 +244,7 @@ void DigitsQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
238244
std::string lbHistoName = "LocalBoardsMap";
239245
if (mo->getName().find(lbHistoName) != std::string::npos) {
240246
// This matches "LocalBoardsMap*"
241-
auto histo = static_cast<TH2F*>(mo->getObject());
247+
auto histo = dynamic_cast<TH2F*>(mo->getObject());
242248
if (mo->getName() == lbHistoName) {
243249
// This is LocalBoardsMap and it was already scaled in the checker
244250
if (!checkResult.getReasons().empty()) {
@@ -260,13 +266,13 @@ void DigitsQcCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
260266
if (mo->getName().find("BendHitsMap") != std::string::npos) {
261267
// This matches both [N]BendHitsMap*
262268
int maxStrip = 20; // 20kHz Max Display
263-
auto histo = static_cast<TH2F*>(mo->getObject());
269+
auto histo = dynamic_cast<TH2F*>(mo->getObject());
264270
mHistoHelper.normalizeHistoTokHz(histo);
265271
histo->SetMaximum(zcontoursStrip.back());
266272
histo->SetContour(zcontoursStrip.size(), zcontoursStrip.data());
267273
histo->SetStats(0);
268274
} else if (mo->getName() == "Hits") {
269-
auto histo = static_cast<TH1F*>(mo->getObject());
275+
auto histo = dynamic_cast<TH1F*>(mo->getObject());
270276
mHistoHelper.normalizeHistoTokHz(histo);
271277
histo->SetStats(0);
272278
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
///
13+
/// \file MIDAggregator.cxx
14+
/// \author V.Ramillien
15+
///
16+
17+
#include "MID/MIDAggregator.h"
18+
#include "QualityControl/QcInfoLogger.h"
19+
20+
using namespace std;
21+
using namespace o2::quality_control::core;
22+
23+
namespace o2::quality_control_modules::mid
24+
{
25+
26+
void MIDAggregator::configure() {}
27+
28+
std::map<std::string, Quality> MIDAggregator::aggregate(QualityObjectsMapType& qoMap)
29+
{
30+
std::map<std::string, Quality> result;
31+
32+
ILOG(Info, Devel) << "Entered Aggregator::aggregate" << ENDM;
33+
ILOG(Info, Devel) << " received a list of size : " << qoMap.size() << ENDM;
34+
for (const auto& item : qoMap) {
35+
ILOG(Info, Devel) << "Object: " << (*item.second) << ENDM;
36+
}
37+
38+
if (qoMap.empty()) {
39+
Quality null = Quality::Null;
40+
std::string NullReason = "QO map given to the aggregator '" + mName + "' is empty.";
41+
null.addMetadata(Quality::Null.getName(), NullReason);
42+
return { { mName, null } };
43+
}
44+
45+
// we return the worse quality of all the objects we receive
46+
Quality current = Quality::Good;
47+
for (auto qo : qoMap) {
48+
if (qo.second->getQuality().isWorseThan(current)) {
49+
current = qo.second->getQuality();
50+
}
51+
}
52+
53+
ILOG(Info, Devel) << " result: " << current << ENDM;
54+
result["newQuality"] = current;
55+
56+
// add one more
57+
// Quality plus = Quality::Medium;
58+
// result["another"] = plus;
59+
60+
result["another"] = current;
61+
62+
return result;
63+
}
64+
} // namespace o2::quality_control_modules::mid

0 commit comments

Comments
 (0)