Skip to content
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
230 changes: 136 additions & 94 deletions Modules/EMCAL/src/RawCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <TH1.h>
#include <TH2.h>
#include <TPaveText.h>
#include <TLatex.h>
#include <TList.h>
#include <TRobustEstimator.h>

Expand Down Expand Up @@ -46,76 +47,88 @@ Quality RawCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* m
}
if (mo->getName().find("BunchMinRawAmplitude") == 0) {
auto* h = dynamic_cast<TH1*>(mo->getObject());
Float_t totentries = h->Integral(10, 100); // Exclude dominant part of the channels for which the signal is in the noise range below pedestal
Float_t entriesBadRegion = h->Integral(20, 60);
int first = h->GetXaxis()->GetFirst(),
last = h->GetXaxis()->GetLast();
h->GetXaxis()->SetRangeUser(20, 60);
Int_t maxbin = h->GetMaximumBin();
h->GetXaxis()->SetRange(first, last);
if (maxbin > 30 && maxbin < 50) {
//Float_t entries = h->GetBinContent(maxbin + 1);
if (entriesBadRegion > 0.5 * totentries) {
result = Quality::Bad;
if (h->GetEntries() == 0) {
result = Quality::Medium;
} else {
Float_t totentries = h->Integral(10, 100); // Exclude dominant part of the channels for which the signal is in the noise range below pedestal
Float_t entriesBadRegion = h->Integral(20, 60);
int first = h->GetXaxis()->GetFirst(),
last = h->GetXaxis()->GetLast();
h->GetXaxis()->SetRangeUser(20, 60);
Int_t maxbin = h->GetMaximumBin();
h->GetXaxis()->SetRange(first, last);
if (maxbin > 30 && maxbin < 50) {
//Float_t entries = h->GetBinContent(maxbin + 1);
if (entriesBadRegion > 0.5 * totentries) {
result = Quality::Bad;
}
}
}
} // checker for the raw ampl histos (second peak around 40)
} // checker for the raw ampl histos (second peak around 40)
}
if (mo->getName() == "FECidMaxChWithInput_perSM") {
double errormargin = 2.;
auto* h = dynamic_cast<TH2*>(mo->getObject());
bool hasBadFEC = false;
for (int ism = 0; ism < h->GetXaxis()->GetNbins(); ism++) {
std::unique_ptr<TH1> smbin(h->ProjectionY("nextsm", ism + 1, ism + 1));
if (!smbin->GetEntries())
continue;
// get count rates for truncated mean
std::vector<double> feccounts;
for (int ifec = 0; ifec < smbin->GetXaxis()->GetNbins(); ifec++) {
double countrate = smbin->GetBinContent(ifec + 1);
if (countrate > DBL_EPSILON)
feccounts.push_back(countrate);
}
// evaluate truncated mean to find outliers
double mean, sigma;
TRobustEstimator estimmator;
estimmator.EvaluateUni(feccounts.size(), feccounts.data(), mean, sigma);
// compare count rate of each FEC to truncated mean
for (int ifec = 0; ifec < smbin->GetXaxis()->GetNbins(); ifec++) {
double countrate = smbin->GetBinContent(ifec + 1);
if (countrate > mean + errormargin * sigma) {
hasBadFEC = true;
break;
if (h->GetEntries() == 0) {
result = Quality::Medium;
} else {
bool hasBadFEC = false;
for (int ism = 0; ism < h->GetXaxis()->GetNbins(); ism++) {
std::unique_ptr<TH1> smbin(h->ProjectionY("nextsm", ism + 1, ism + 1));
if (!smbin->GetEntries())
continue;
// get count rates for truncated mean
std::vector<double> feccounts;
for (int ifec = 0; ifec < smbin->GetXaxis()->GetNbins(); ifec++) {
double countrate = smbin->GetBinContent(ifec + 1);
if (countrate > DBL_EPSILON)
feccounts.push_back(countrate);
}
// evaluate truncated mean to find outliers
double mean, sigma;
TRobustEstimator estimmator;
estimmator.EvaluateUni(feccounts.size(), feccounts.data(), mean, sigma);
// compare count rate of each FEC to truncated mean
for (int ifec = 0; ifec < smbin->GetXaxis()->GetNbins(); ifec++) {
double countrate = smbin->GetBinContent(ifec + 1);
if (countrate > mean + errormargin * sigma) {
hasBadFEC = true;
break;
}
}
if (hasBadFEC)
break;
}
if (hasBadFEC)
break;
result = Quality::Bad;
}
if (hasBadFEC)
result = Quality::Bad;
}
if (mo->getName() == "PayloadSizeTFPerDDL") {
std::map<int, double> meanPayloadSizeDDL;
double errormargin = 2.;
auto* h = dynamic_cast<TH2*>(mo->getObject());
std::vector<double> meanPayloads;
for (int ism = 0; ism < h->GetXaxis()->GetNbins(); ism++) {
std::unique_ptr<TH1> smbin(h->ProjectionY("nextsm", ism + 1, ism + 1));
if (!smbin->GetEntries()) {
meanPayloadSizeDDL[ism] = 0;
continue;
if (h->GetEntries() == 0) {
result = Quality::Medium;
} else {
std::vector<double> meanPayloads;
for (int ism = 0; ism < h->GetXaxis()->GetNbins(); ism++) {
std::unique_ptr<TH1> smbin(h->ProjectionY("nextsm", ism + 1, ism + 1));
if (!smbin->GetEntries()) {
meanPayloadSizeDDL[ism] = 0;
continue;
}
auto meanPayload = smbin->GetMean();
meanPayloads.push_back(meanPayload);
meanPayloadSizeDDL[ism] = meanPayload;
// get count rates for truncated mean
}
auto meanPayload = smbin->GetMean();
meanPayloads.push_back(meanPayload);
meanPayloadSizeDDL[ism] = meanPayload;
// get count rates for truncated mean
}
double mean, sigma;
TRobustEstimator estimmator;
estimmator.EvaluateUni(meanPayloads.size(), meanPayloads.data(), mean, sigma);
for (auto [ddlID, payloadmean] : meanPayloadSizeDDL) {
if (payloadmean > mean + errormargin * sigma) {
result = Quality::Bad;
break;
double mean, sigma;
TRobustEstimator estimmator;
estimmator.EvaluateUni(meanPayloads.size(), meanPayloads.data(), mean, sigma);
for (auto [ddlID, payloadmean] : meanPayloadSizeDDL) {
if (payloadmean > mean + errormargin * sigma) {
result = Quality::Bad;
break;
}
}
}
}
Expand All @@ -127,26 +140,27 @@ std::string RawCheck::getAcceptedType() { return "TH1"; }

void RawCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
{
QcInfoLogger::GetInstance().setDetector("EMC");
if (mo->getName().find("Error") != std::string::npos) {
auto* h = dynamic_cast<TH1*>(mo->getObject());
TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC");
h->GetListOfFunctions()->Add(msg);
msg->SetName(Form("%s_msg", mo->GetName()));

if (checkResult == Quality::Good) {
//check the error type, loop on X entries to find the SM and on Y to find the Error Number
//
msg->Clear();
msg->AddText("No Error: OK!!!");
msg->SetFillColor(kGreen);
//
h->SetFillColor(kGreen);
TLatex* msg = new TLatex(0.2, 0.8, "#color[418]{No Error: OK}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
} else if (checkResult == Quality::Bad) {
LOG(info) << "Quality::Bad, setting to red";
msg->Clear();
msg->AddText("Presence of Error Code"); //Type of the Error, in SM XX
msg->AddText("If NOT a technical run,");
msg->AddText("call EMCAL on-call.");
QcInfoLogger::GetInstance() << QcInfoLogger::Error << " QualityBad:Presence of Error Code " << AliceO2::InfoLogger::InfoLogger::endm;
TLatex* msg = new TLatex(0.2, 0.8, "#color[2]{Presence of Error Code}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
h->SetFillColor(kRed);
} else if (checkResult == Quality::Medium) {
LOG(info) << "Quality::medium, setting to orange";
Expand All @@ -156,50 +170,78 @@ void RawCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
}
if (mo->getName().find("BunchMinRawAmplitude") != std::string::npos) {
auto* h = dynamic_cast<TH1*>(mo->getObject());
TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC");
h->GetListOfFunctions()->Add(msg);
msg->SetName(Form("%s_msg", mo->GetName()));

if (checkResult == Quality::Good) {
msg->Clear();
msg->AddText("No Error: OK!!!");
msg->SetFillColor(kGreen);
TLatex* msg = new TLatex(0.3, 0.8, "#color[418]{Data OK}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
h->SetFillColor(kGreen);
} else if (checkResult == Quality::Bad) {
LOG(info) << "Quality::Bad, setting to red";
msg->Clear();
msg->AddText("Min. bunch amplitude outside limits"); //Type of the Error, in SM XX
msg->AddText("If NOT a technical run,");
msg->AddText("call EMCAL on-call.");
QcInfoLogger::GetInstance() << QcInfoLogger::Error << " QualityBad:Bunch min Amplitude outside limits " << AliceO2::InfoLogger::InfoLogger::endm;
TLatex* msg = new TLatex(0.2, 0.8, "#color[2]{Data outside limits}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
msg->SetTextColor(kRed);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
msg = new TLatex(0.2, 0.7, "#color[2]{If NOT techn.run: call EMCAL oncall}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
msg->SetTextColor(kRed);
h->SetFillColor(kRed);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
} else if (checkResult == Quality::Medium) {
LOG(info) << "Quality::medium, setting to orange";
h->SetFillColor(kOrange);
TLatex* msg = new TLatex(0.2, 0.8, "#color[42]{empty:if in run, call EMCAL oncall}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
}
h->SetLineColor(kBlack);
}
std::vector<std::string> payloadhists = { "FECidMaxChWithInput_perSM", "PayloadSizeTFPerDDL" };
if (std::find(payloadhists.begin(), payloadhists.end(), mo->getName()) != payloadhists.end()) {
auto* h = dynamic_cast<TH1*>(mo->getObject());
TPaveText* msg = new TPaveText(0.5, 0.5, 0.9, 0.75, "NDC");
h->GetListOfFunctions()->Add(msg);
msg->SetName(Form("%s_msg", mo->GetName()));

if (checkResult == Quality::Good) {
msg->Clear();
msg->AddText("No Error: OK!!!");
msg->SetFillColor(kGreen);
TLatex* msg = new TLatex(0.2, 0.8, "#color[418]{Data OK}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->SetFillColor(kGreen);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
} else if (checkResult == Quality::Bad) {
LOG(info) << "Quality::Bad, setting to red";
msg->Clear();
msg->AddText("entry out of trend!"); //Type of the Error, in SM XX
msg->AddText("If NOT a technical run,");
msg->AddText("call EMCAL on-call.");
h->SetFillColor(kRed);
TLatex* msg = new TLatex(0.2, 0.8, "#color[2]{Entry out of trend!}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
msg->SetTextColor(kRed);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
msg = new TLatex(0.2, 0.7, "#color[2]{If NOT techn.run: call EMCAL oncall}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
msg->SetTextColor(kRed);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
} else if (checkResult == Quality::Medium) {
LOG(info) << "Quality::medium, setting to orange";
h->SetFillColor(kOrange);
TLatex* msg = new TLatex(0.2, 0.8, "#color[42]{empty:if in run, call EMCAL-oncall}");
msg->SetNDC();
msg->SetTextSize(16);
msg->SetTextFont(43);
h->GetListOfFunctions()->Add(msg);
msg->Draw();
}
h->SetLineColor(kBlack);
}
Expand Down
Loading