Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MUON: introduce station-dependent checker thresholds #2445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Modules/MUON/MCH/include/MCH/DecodingCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class DecodingCheck : public o2::quality_control::checker::CheckInterface
int mMaxBadST12{ 2 };
int mMaxBadST345{ 3 };
double mMinGoodErrorFrac{ 0.9 };
std::array<std::optional<double>, 5> mMinGoodErrorFracPerStation;
double mMinGoodSyncFrac{ 0.9 };
std::array<std::optional<double>, 5> mMinGoodSyncFracPerStation;

QualityChecker mQualityChecker;

Expand Down
8 changes: 4 additions & 4 deletions Modules/MUON/MCH/include/MCH/DigitsCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "QualityControl/CheckInterface.h"
#include "QualityControl/Quality.h"
#include <string>
#include <array>

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

std::string mMeanRateHistName{ "RatesSignal/LastCycle/MeanRate" };
std::string mMeanRateRatioHistName{ "RatesSignal/LastCycle/MeanRateRefRatio" };
std::string mGoodChanFracHistName{ "RatesSignal/LastCycle/GoodChannelsFraction" };
std::string mGoodChanFracRatioHistName{ "RatesSignal/LastCycle/GoodChannelsFractionRefRatio" };
int mMaxBadST12{ 2 };
int mMaxBadST345{ 3 };
double mMinRate{ 0.001 };
std::array<std::optional<double>, 5> mMinRatePerStation;
double mMaxRate{ 10 };
double mMaxRateDelta{ 0.2 };
std::array<std::optional<double>, 5> mMaxRatePerStation;
double mMinGoodFraction{ 0.9 };
double mMaxGoodFractionDelta{ 0.2 };
std::array<std::optional<double>, 5> mMinGoodFractionPerStation;
double mRatePlotScaleMin{ 0 };
double mRatePlotScaleMax{ 10 };

Expand Down
10 changes: 10 additions & 0 deletions Modules/MUON/MCH/include/MCH/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "QualityControl/DatabaseInterface.h"
#include "QualityControl/Quality.h"
#include "QualityControl/CustomParameters.h"
#include "MCHConstants/DetectionElements.h"
#include <TCanvas.h>
#include <TH1F.h>
Expand All @@ -28,6 +29,7 @@
#include <TText.h>
#include <gsl/span>
#include <utility>
#include <array>
#include <optional>

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

void getThresholdsPerStation(o2::quality_control::core::CustomParameters customParameters,
const o2::quality_control::core::Activity& activity,
std::string parKey,
std::array<std::optional<double>, 5>& thresholds,
double& defaultThreshold);

o2::quality_control::core::Quality checkDetectorQuality(gsl::span<o2::quality_control::core::Quality>& deQuality);

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

std::string getHistoPath(int deId);
bool matchHistName(std::string hist, std::string name);
Expand Down
4 changes: 1 addition & 3 deletions Modules/MUON/MCH/include/MCH/PreclustersCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ class PreclustersCheck : public o2::quality_control::checker::CheckInterface

std::string mMeanEffHistNameB{ "Efficiency/LastCycle/MeanEfficiencyB" };
std::string mMeanEffHistNameNB{ "Efficiency/LastCycle/MeanEfficiencyNB" };
std::string mMeanEffRatioHistNameB{ "Efficiency/LastCycle/MeanEfficiencyRefRatioB" };
std::string mMeanEffRatioHistNameNB{ "Efficiency/LastCycle/MeanEfficiencyRefRatioNB" };
int mMaxBadST12{ 2 };
int mMaxBadST345{ 3 };
double mMinEfficiency{ 0.8 };
double mMaxEffDelta{ 0.2 };
std::array<std::optional<double>, 5> mMinEfficiencyPerStation;
double mPseudoeffPlotScaleMin{ 0.0 };
double mPseudoeffPlotScaleMax{ 1.0 };

Expand Down
125 changes: 64 additions & 61 deletions Modules/MUON/MCH/src/DecodingCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void DecodingCheck::startOfActivity(const Activity& activity)
mGoodFracHistName = getConfigurationParameter<std::string>(mCustomParameters, "GoodFracHistName", mGoodFracHistName, activity);
mSyncFracHistName = getConfigurationParameter<std::string>(mCustomParameters, "SyncFracHistName", mSyncFracHistName, activity);

mMinGoodErrorFrac = getConfigurationParameter<double>(mCustomParameters, "MinGoodErrorFrac", mMinGoodErrorFrac, activity);
mMinGoodSyncFrac = getConfigurationParameter<double>(mCustomParameters, "MinGoodSyncFrac", mMinGoodSyncFrac, activity);
getThresholdsPerStation(mCustomParameters, activity, "MinGoodErrorFrac", mMinGoodErrorFracPerStation, mMinGoodErrorFrac);
getThresholdsPerStation(mCustomParameters, activity, "MinGoodSyncFrac", mMinGoodSyncFracPerStation, mMinGoodSyncFrac);

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

for (int deId = 0; deId < getNumDE(); deId++) {
for (auto de : o2::mch::constants::deIdsForAllMCH) {
int chamberId = (de - 100) / 100;
int stationId = chamberId / 2;

int deId = getDEindex(de);
if (deId < 0) {
continue;
}

auto minGoodErrorFrac = mMinGoodErrorFrac;
if (stationId >= 0 && stationId < 5) {
if (mMinGoodErrorFracPerStation[stationId]) {
minGoodErrorFrac = mMinGoodErrorFracPerStation[stationId].value();
}
}

double val = h->GetBinContent(deId + 1);
if (val < mMinGoodErrorFrac) {
if (val < minGoodErrorFrac) {
errorsQuality[deId] = Quality::Bad;
} else {
errorsQuality[deId] = Quality::Good;
Expand All @@ -87,9 +102,24 @@ Quality DecodingCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
return result;
}

for (int deId = 0; deId < getNumDE(); deId++) {
for (auto de : o2::mch::constants::deIdsForAllMCH) {
int chamberId = (de - 100) / 100;
int stationId = chamberId / 2;

int deId = getDEindex(de);
if (deId < 0) {
continue;
}

auto minGoodSyncFrac = mMinGoodSyncFrac;
if (stationId >= 0 && stationId < 5) {
if (mMinGoodSyncFracPerStation[stationId]) {
minGoodSyncFrac = mMinGoodSyncFracPerStation[stationId].value();
}
}

double val = h->GetBinContent(deId + 1);
if (val < mMinGoodSyncFrac) {
if (val < minGoodSyncFrac) {
syncQuality[deId] = Quality::Bad;
} else {
syncQuality[deId] = Quality::Good;
Expand All @@ -103,37 +133,8 @@ Quality DecodingCheck::check(std::map<std::string, std::shared_ptr<MonitorObject

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

static void updateTitle(TH1* hist, std::string suffix)
{
if (!hist) {
return;
}
TString title = hist->GetTitle();
title.Append(" ");
title.Append(suffix.c_str());
hist->SetTitle(title);
}

static std::string getCurrentTime()
{
time_t t;
time(&t);

struct tm* tmp;
tmp = localtime(&t);

char timestr[500];
strftime(timestr, sizeof(timestr), "(%d/%m/%Y - %R)", tmp);

std::string result = timestr;
return result;
}

void DecodingCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
{
auto currentTime = getCurrentTime();
updateTitle(dynamic_cast<TH1*>(mo->getObject()), currentTime);

if (mo->getName().find("DecodingErrorsPerDE") != std::string::npos) {
auto* h = dynamic_cast<TH2F*>(mo->getObject());
if (!h) {
Expand Down Expand Up @@ -193,21 +194,22 @@ void DecodingCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
h->GetYaxis()->SetTitle("good boards fraction");

addChamberDelimiters(h, scaleMin, scaleMax);
addDEBinLabels(h);

// draw horizontal limits
TLine* l = new TLine(0, mMinGoodErrorFrac, h->GetXaxis()->GetXmax(), mMinGoodErrorFrac);
l->SetLineColor(kBlue);
l->SetLineStyle(kDashed);
h->GetListOfFunctions()->Add(l);

if (checkResult == Quality::Good) {
h->SetFillColor(kGreen);
} else if (checkResult == Quality::Bad) {
h->SetFillColor(kRed);
} else if (checkResult == Quality::Medium) {
h->SetFillColor(kOrange);
// only the plot used for the check is beautified by changing the color
// and adding the horizontal lines corresponding to the thresholds
if (matchHistName(mo->getName(), mGoodFracHistName)) {
if (checkResult == Quality::Good) {
h->SetFillColor(kGreen);
} else if (checkResult == Quality::Bad) {
h->SetFillColor(kRed);
} else if (checkResult == Quality::Medium) {
h->SetFillColor(kOrange);
}
h->SetLineColor(kBlack);

drawThresholdsPerStation(h, mMinGoodErrorFracPerStation, mMinGoodErrorFrac);
}
h->SetLineColor(kBlack);
}

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

addChamberDelimiters(h, scaleMin, scaleMax);
addDEBinLabels(h);

// only the plot used for the check is beautified by changing the color
// and adding the horizontal lines corresponding to the thresholds
if (matchHistName(mo->getName(), mSyncFracHistName)) {
if (checkResult == Quality::Good) {
h->SetFillColor(kGreen);
} else if (checkResult == Quality::Bad) {
h->SetFillColor(kRed);
} else if (checkResult == Quality::Medium) {
h->SetFillColor(kOrange);
}
h->SetLineColor(kBlack);

// draw horizontal limits
TLine* l = new TLine(0, mMinGoodSyncFrac, h->GetXaxis()->GetXmax(), mMinGoodSyncFrac);
l->SetLineColor(kBlue);
l->SetLineStyle(kDashed);
h->GetListOfFunctions()->Add(l);

if (checkResult == Quality::Good) {
h->SetFillColor(kGreen);
} else if (checkResult == Quality::Bad) {
h->SetFillColor(kRed);
} else if (checkResult == Quality::Medium) {
h->SetFillColor(kOrange);
drawThresholdsPerStation(h, mMinGoodSyncFracPerStation, mMinGoodSyncFrac);
}
h->SetLineColor(kBlack);
}
}

Expand Down
Loading
Loading