Skip to content

Commit d257ae6

Browse files
authored
[MCH] introduce station deendent checker thresholds (#2445)
Checker thresholds are extended to allow setting different values for specific stations, overriding the global default value. The code is also simplified by removing check of the ratio plots, that are now superseded by the common reference comparator output.
1 parent 0a1d899 commit d257ae6

8 files changed

Lines changed: 231 additions & 340 deletions

File tree

Modules/MUON/MCH/include/MCH/DecodingCheck.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class DecodingCheck : public o2::quality_control::checker::CheckInterface
5252
int mMaxBadST12{ 2 };
5353
int mMaxBadST345{ 3 };
5454
double mMinGoodErrorFrac{ 0.9 };
55+
std::array<std::optional<double>, 5> mMinGoodErrorFracPerStation;
5556
double mMinGoodSyncFrac{ 0.9 };
57+
std::array<std::optional<double>, 5> mMinGoodSyncFracPerStation;
5658

5759
QualityChecker mQualityChecker;
5860

Modules/MUON/MCH/include/MCH/DigitsCheck.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "QualityControl/CheckInterface.h"
2222
#include "QualityControl/Quality.h"
2323
#include <string>
24+
#include <array>
2425

2526
namespace o2::quality_control::core
2627
{
@@ -55,16 +56,15 @@ class DigitsCheck : public o2::quality_control::checker::CheckInterface
5556
std::array<Quality, getNumDE()> checkBadChannelsRatio(TH1F* h);
5657

5758
std::string mMeanRateHistName{ "RatesSignal/LastCycle/MeanRate" };
58-
std::string mMeanRateRatioHistName{ "RatesSignal/LastCycle/MeanRateRefRatio" };
5959
std::string mGoodChanFracHistName{ "RatesSignal/LastCycle/GoodChannelsFraction" };
60-
std::string mGoodChanFracRatioHistName{ "RatesSignal/LastCycle/GoodChannelsFractionRefRatio" };
6160
int mMaxBadST12{ 2 };
6261
int mMaxBadST345{ 3 };
6362
double mMinRate{ 0.001 };
63+
std::array<std::optional<double>, 5> mMinRatePerStation;
6464
double mMaxRate{ 10 };
65-
double mMaxRateDelta{ 0.2 };
65+
std::array<std::optional<double>, 5> mMaxRatePerStation;
6666
double mMinGoodFraction{ 0.9 };
67-
double mMaxGoodFractionDelta{ 0.2 };
67+
std::array<std::optional<double>, 5> mMinGoodFractionPerStation;
6868
double mRatePlotScaleMin{ 0 };
6969
double mRatePlotScaleMax{ 10 };
7070

Modules/MUON/MCH/include/MCH/Helpers.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "QualityControl/DatabaseInterface.h"
2121
#include "QualityControl/Quality.h"
22+
#include "QualityControl/CustomParameters.h"
2223
#include "MCHConstants/DetectionElements.h"
2324
#include <TCanvas.h>
2425
#include <TH1F.h>
@@ -28,6 +29,7 @@
2829
#include <TText.h>
2930
#include <gsl/span>
3031
#include <utility>
32+
#include <array>
3133
#include <optional>
3234

3335
namespace o2::quality_control::core
@@ -52,10 +54,18 @@ constexpr int getNumDE() { return (4 * 4 + 18 * 2 + 26 * 4); }
5254
int getNumDEinChamber(int chIndex);
5355
std::pair<int, int> getDEindexInChamber(int deId);
5456

57+
void getThresholdsPerStation(o2::quality_control::core::CustomParameters customParameters,
58+
const o2::quality_control::core::Activity& activity,
59+
std::string parKey,
60+
std::array<std::optional<double>, 5>& thresholds,
61+
double& defaultThreshold);
62+
5563
o2::quality_control::core::Quality checkDetectorQuality(gsl::span<o2::quality_control::core::Quality>& deQuality);
5664

5765
void addChamberDelimiters(TH1F* h, float xmin = 0, float xmax = 0);
5866
void addChamberDelimiters(TH2F* h);
67+
void drawThresholdsPerStation(TH1* histogram, const std::array<std::optional<double>, 5>& thresholdsPerStation, double defaultThreshold);
68+
void addDEBinLabels(TH1* histogram);
5969

6070
std::string getHistoPath(int deId);
6171
bool matchHistName(std::string hist, std::string name);

Modules/MUON/MCH/include/MCH/PreclustersCheck.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ class PreclustersCheck : public o2::quality_control::checker::CheckInterface
5353

5454
std::string mMeanEffHistNameB{ "Efficiency/LastCycle/MeanEfficiencyB" };
5555
std::string mMeanEffHistNameNB{ "Efficiency/LastCycle/MeanEfficiencyNB" };
56-
std::string mMeanEffRatioHistNameB{ "Efficiency/LastCycle/MeanEfficiencyRefRatioB" };
57-
std::string mMeanEffRatioHistNameNB{ "Efficiency/LastCycle/MeanEfficiencyRefRatioNB" };
5856
int mMaxBadST12{ 2 };
5957
int mMaxBadST345{ 3 };
6058
double mMinEfficiency{ 0.8 };
61-
double mMaxEffDelta{ 0.2 };
59+
std::array<std::optional<double>, 5> mMinEfficiencyPerStation;
6260
double mPseudoeffPlotScaleMin{ 0.0 };
6361
double mPseudoeffPlotScaleMax{ 1.0 };
6462

Modules/MUON/MCH/src/DecodingCheck.cxx

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ void DecodingCheck::startOfActivity(const Activity& activity)
4242
mGoodFracHistName = getConfigurationParameter<std::string>(mCustomParameters, "GoodFracHistName", mGoodFracHistName, activity);
4343
mSyncFracHistName = getConfigurationParameter<std::string>(mCustomParameters, "SyncFracHistName", mSyncFracHistName, activity);
4444

45-
mMinGoodErrorFrac = getConfigurationParameter<double>(mCustomParameters, "MinGoodErrorFrac", mMinGoodErrorFrac, activity);
46-
mMinGoodSyncFrac = getConfigurationParameter<double>(mCustomParameters, "MinGoodSyncFrac", mMinGoodSyncFrac, activity);
45+
getThresholdsPerStation(mCustomParameters, activity, "MinGoodErrorFrac", mMinGoodErrorFracPerStation, mMinGoodErrorFrac);
46+
getThresholdsPerStation(mCustomParameters, activity, "MinGoodSyncFrac", mMinGoodSyncFracPerStation, mMinGoodSyncFrac);
4747

4848
mMaxBadST12 = getConfigurationParameter<int>(mCustomParameters, "MaxBadDE_ST12", mMaxBadST12, activity);
4949
mMaxBadST345 = getConfigurationParameter<int>(mCustomParameters, "MaxBadDE_ST345", mMaxBadST345, activity);
@@ -70,9 +70,24 @@ Quality DecodingCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
7070
return result;
7171
}
7272

73-
for (int deId = 0; deId < getNumDE(); deId++) {
73+
for (auto de : o2::mch::constants::deIdsForAllMCH) {
74+
int chamberId = (de - 100) / 100;
75+
int stationId = chamberId / 2;
76+
77+
int deId = getDEindex(de);
78+
if (deId < 0) {
79+
continue;
80+
}
81+
82+
auto minGoodErrorFrac = mMinGoodErrorFrac;
83+
if (stationId >= 0 && stationId < 5) {
84+
if (mMinGoodErrorFracPerStation[stationId]) {
85+
minGoodErrorFrac = mMinGoodErrorFracPerStation[stationId].value();
86+
}
87+
}
88+
7489
double val = h->GetBinContent(deId + 1);
75-
if (val < mMinGoodErrorFrac) {
90+
if (val < minGoodErrorFrac) {
7691
errorsQuality[deId] = Quality::Bad;
7792
} else {
7893
errorsQuality[deId] = Quality::Good;
@@ -87,9 +102,24 @@ Quality DecodingCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
87102
return result;
88103
}
89104

90-
for (int deId = 0; deId < getNumDE(); deId++) {
105+
for (auto de : o2::mch::constants::deIdsForAllMCH) {
106+
int chamberId = (de - 100) / 100;
107+
int stationId = chamberId / 2;
108+
109+
int deId = getDEindex(de);
110+
if (deId < 0) {
111+
continue;
112+
}
113+
114+
auto minGoodSyncFrac = mMinGoodSyncFrac;
115+
if (stationId >= 0 && stationId < 5) {
116+
if (mMinGoodSyncFracPerStation[stationId]) {
117+
minGoodSyncFrac = mMinGoodSyncFracPerStation[stationId].value();
118+
}
119+
}
120+
91121
double val = h->GetBinContent(deId + 1);
92-
if (val < mMinGoodSyncFrac) {
122+
if (val < minGoodSyncFrac) {
93123
syncQuality[deId] = Quality::Bad;
94124
} else {
95125
syncQuality[deId] = Quality::Good;
@@ -103,37 +133,8 @@ Quality DecodingCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
103133

104134
std::string DecodingCheck::getAcceptedType() { return "TH1"; }
105135

106-
static void updateTitle(TH1* hist, std::string suffix)
107-
{
108-
if (!hist) {
109-
return;
110-
}
111-
TString title = hist->GetTitle();
112-
title.Append(" ");
113-
title.Append(suffix.c_str());
114-
hist->SetTitle(title);
115-
}
116-
117-
static std::string getCurrentTime()
118-
{
119-
time_t t;
120-
time(&t);
121-
122-
struct tm* tmp;
123-
tmp = localtime(&t);
124-
125-
char timestr[500];
126-
strftime(timestr, sizeof(timestr), "(%d/%m/%Y - %R)", tmp);
127-
128-
std::string result = timestr;
129-
return result;
130-
}
131-
132136
void DecodingCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
133137
{
134-
auto currentTime = getCurrentTime();
135-
updateTitle(dynamic_cast<TH1*>(mo->getObject()), currentTime);
136-
137138
if (mo->getName().find("DecodingErrorsPerDE") != std::string::npos) {
138139
auto* h = dynamic_cast<TH2F*>(mo->getObject());
139140
if (!h) {
@@ -193,21 +194,22 @@ void DecodingCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
193194
h->GetYaxis()->SetTitle("good boards fraction");
194195

195196
addChamberDelimiters(h, scaleMin, scaleMax);
197+
addDEBinLabels(h);
196198

197-
// draw horizontal limits
198-
TLine* l = new TLine(0, mMinGoodErrorFrac, h->GetXaxis()->GetXmax(), mMinGoodErrorFrac);
199-
l->SetLineColor(kBlue);
200-
l->SetLineStyle(kDashed);
201-
h->GetListOfFunctions()->Add(l);
202-
203-
if (checkResult == Quality::Good) {
204-
h->SetFillColor(kGreen);
205-
} else if (checkResult == Quality::Bad) {
206-
h->SetFillColor(kRed);
207-
} else if (checkResult == Quality::Medium) {
208-
h->SetFillColor(kOrange);
199+
// only the plot used for the check is beautified by changing the color
200+
// and adding the horizontal lines corresponding to the thresholds
201+
if (matchHistName(mo->getName(), mGoodFracHistName)) {
202+
if (checkResult == Quality::Good) {
203+
h->SetFillColor(kGreen);
204+
} else if (checkResult == Quality::Bad) {
205+
h->SetFillColor(kRed);
206+
} else if (checkResult == Quality::Medium) {
207+
h->SetFillColor(kOrange);
208+
}
209+
h->SetLineColor(kBlack);
210+
211+
drawThresholdsPerStation(h, mMinGoodErrorFracPerStation, mMinGoodErrorFrac);
209212
}
210-
h->SetLineColor(kBlack);
211213
}
212214

213215
if (mo->getName().find("SyncedBoardsFractionPerDE") != std::string::npos) {
@@ -222,21 +224,22 @@ void DecodingCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
222224
h->SetMaximum(scaleMax);
223225

224226
addChamberDelimiters(h, scaleMin, scaleMax);
227+
addDEBinLabels(h);
228+
229+
// only the plot used for the check is beautified by changing the color
230+
// and adding the horizontal lines corresponding to the thresholds
231+
if (matchHistName(mo->getName(), mSyncFracHistName)) {
232+
if (checkResult == Quality::Good) {
233+
h->SetFillColor(kGreen);
234+
} else if (checkResult == Quality::Bad) {
235+
h->SetFillColor(kRed);
236+
} else if (checkResult == Quality::Medium) {
237+
h->SetFillColor(kOrange);
238+
}
239+
h->SetLineColor(kBlack);
225240

226-
// draw horizontal limits
227-
TLine* l = new TLine(0, mMinGoodSyncFrac, h->GetXaxis()->GetXmax(), mMinGoodSyncFrac);
228-
l->SetLineColor(kBlue);
229-
l->SetLineStyle(kDashed);
230-
h->GetListOfFunctions()->Add(l);
231-
232-
if (checkResult == Quality::Good) {
233-
h->SetFillColor(kGreen);
234-
} else if (checkResult == Quality::Bad) {
235-
h->SetFillColor(kRed);
236-
} else if (checkResult == Quality::Medium) {
237-
h->SetFillColor(kOrange);
241+
drawThresholdsPerStation(h, mMinGoodSyncFracPerStation, mMinGoodSyncFrac);
238242
}
239-
h->SetLineColor(kBlack);
240243
}
241244
}
242245

0 commit comments

Comments
 (0)