-
Notifications
You must be signed in to change notification settings - Fork 151
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
[ZDC] Qc additions #2510
base: master
Are you sure you want to change the base?
[ZDC] Qc additions #2510
Changes from all commits
2cfcfc2
ca981b9
b7664cc
0bf868e
c47203a
f66ef85
de72e20
3c7bc14
426d0c9
96a0c59
37454c8
df753bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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 ZDCRecBeautifyPlots.h | ||
/// \author Stefan Cristi Zugravel | ||
/// | ||
|
||
#ifndef QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H | ||
#define QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H | ||
|
||
#include "QualityControl/CheckInterface.h" | ||
|
||
namespace o2::quality_control_modules::zdc | ||
{ | ||
|
||
/// \brief Example QC Check | ||
/// \author Stefan Cristi Zugravel | ||
class ZDCRecBeautifyPlots : public o2::quality_control::checker::CheckInterface | ||
{ | ||
public: | ||
/// Default constructor | ||
ZDCRecBeautifyPlots() = default; | ||
/// Destructor | ||
~ZDCRecBeautifyPlots() override = default; | ||
|
||
// Override interface | ||
void configure() override; | ||
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override; | ||
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override; | ||
std::string getAcceptedType() override; | ||
void reset() override; | ||
void startOfActivity(const Activity& activity) override; | ||
void endOfActivity(const Activity& activity) override; | ||
|
||
private: | ||
std::shared_ptr<Activity> mActivity; | ||
|
||
ClassDefOverride(ZDCRecBeautifyPlots, 3); | ||
}; | ||
|
||
} // namespace o2::quality_control_modules::zdc | ||
|
||
#endif // QC_MODULE_ZDC_ZDCZDCRECBEAUTIFYPLOTS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,27 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje | |
(void)moName; | ||
// For -> Histo to check | ||
for (int ih = 0; ih < (int)mVectHistoCheck.size(); ih++) { | ||
mVectHistoCheck.at(ih).numE = 0; | ||
mVectHistoCheck.at(ih).numW = 0; | ||
mVectHistoCheck.at(ih).stringW = ""; | ||
mVectHistoCheck.at(ih).stringE = ""; | ||
if (mo->getName() == mVectHistoCheck.at(ih).nameHisto) { | ||
// std::ofstream debugFile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coding guidelines encourage the removal of commented out code. |
||
// debugFile.open("debug.txt", std::ios::app); | ||
// if (debugFile.good()) { | ||
// debugFile << mo->getName() << " "; | ||
// debugFile << mVectHistoCheck.at(ih).nameHisto; | ||
// debugFile << " = "; | ||
// if (mo->getName() == mVectHistoCheck.at(ih).nameHisto) { | ||
// debugFile << " equal "; | ||
// } | ||
// else { | ||
// debugFile << " no equal "; | ||
// } | ||
// debugFile << "= \n"; | ||
// debugFile.close(); | ||
// } | ||
if ((mo->getName() == "hpedSummary")) { | ||
mVectHistoCheck.at(ih).numE = 0; | ||
mVectHistoCheck.at(ih).numW = 0; | ||
mVectHistoCheck.at(ih).stringW = ""; | ||
mVectHistoCheck.at(ih).stringE = ""; | ||
auto* h = dynamic_cast<TH1*>(mo->getObject()); | ||
if (h == nullptr) { | ||
ILOG(Error, Support) << "could not cast hpedSummary to TH1*" << ENDM; | ||
|
@@ -87,6 +102,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje | |
} | ||
|
||
if ((mo->getName() == "hAlignPlot") || (mo->getName() == "hAlignPlotShift")) { | ||
mVectHistoCheck.at(ih).numE = 0; | ||
mVectHistoCheck.at(ih).numW = 0; | ||
mVectHistoCheck.at(ih).stringW = ""; | ||
mVectHistoCheck.at(ih).stringE = ""; | ||
int flag_ch_empty = 1; | ||
int flag_all_ch_empty = 1; | ||
auto* h = dynamic_cast<TH2*>(mo->getObject()); | ||
|
@@ -128,6 +147,10 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje | |
} | ||
|
||
if (mo->getName() == "herrorSummary") { | ||
mVectHistoCheck.at(ih).numE = 0; | ||
mVectHistoCheck.at(ih).numW = 0; | ||
mVectHistoCheck.at(ih).stringW = ""; | ||
mVectHistoCheck.at(ih).stringE = ""; | ||
int flag_ch_empty = 1; | ||
auto* h = dynamic_cast<TH2*>(mo->getObject()); | ||
if (h == nullptr) { | ||
|
@@ -161,6 +184,45 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje | |
flag_ch_empty = 1; | ||
} | ||
} | ||
if (mo->getName() == "hBCAlignPlot") { | ||
mVectHistoCheck.at(ih).numE = 0; | ||
mVectHistoCheck.at(ih).numW = 0; | ||
mVectHistoCheck.at(ih).stringW = ""; | ||
mVectHistoCheck.at(ih).stringE = ""; | ||
bool ratio_array[12]; | ||
float ratio = 0.0; | ||
auto* h = dynamic_cast<TH2*>(mo->getObject()); | ||
if (h == nullptr) { | ||
ILOG(Error, Support) << "could not cast herrorSummary to TH2*" << ENDM; | ||
return Quality::Null; | ||
} | ||
if ((int)h->GetNbinsX() != (int)mVectHistoCheck.at(ih).paramch.size()) { | ||
return Quality::Null; | ||
} | ||
for (int x = 0; x < h->GetNbinsX(); x++) { | ||
for (int y = 0; y < h->GetNbinsY(); y++) { | ||
ratio = (h->GetBinContent(x + 1, y + 1)) / (h->GetBinContent(x + 1, REFERENCE_BIN)); | ||
if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) { | ||
ratio_array[y] = true; | ||
} else { | ||
ratio_array[y] = false; | ||
} | ||
} | ||
if (!std::equal(std::begin(ratio_array), std::end(ratio_array), std::begin(COMPARATOR_ARRAY))) { | ||
mVectHistoCheck.at(ih).numE += 1; | ||
mVectHistoCheck.at(ih).stringE = mVectHistoCheck.at(ih).stringE + mVectHistoCheck.at(ih).paramch.at(x).ch + " "; | ||
// std::ofstream debugFile; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment |
||
// debugFile.open("debug.txt", std::ios::app); | ||
// if (debugFile.good()) { | ||
// debugFile << mVectHistoCheck.at(ih).numE << " "; | ||
// debugFile << mVectHistoCheck.at(ih).stringE << " "; | ||
// //debugFile << mVectHistoCheck.at(ih).paramch.at(x).ch << " "; | ||
// debugFile << "= \n"; | ||
// debugFile.close(); | ||
// } | ||
} | ||
} | ||
} | ||
// check result check | ||
if (mVectHistoCheck.at(ih).numW == 0 && mVectHistoCheck.at(ih).numE == 0) { | ||
result = Quality::Good; | ||
|
@@ -175,12 +237,13 @@ Quality ZDCRawDataCheck::check(std::map<std::string, std::shared_ptr<MonitorObje | |
if (mVectHistoCheck.at(ih).numE > 0) { | ||
result = Quality::Bad; | ||
result.addFlag(FlagTypeFactory::Unknown(), | ||
"It is bad because " + std::to_string(mVectHistoCheck.at(ih).numW) + " channels:" + mVectHistoCheck.at(ih).stringE + "have a value in the bad range"); | ||
"It is bad because " + std::to_string(mVectHistoCheck.at(ih).numE) + " channels:" + mVectHistoCheck.at(ih).stringE + "have a value in the bad range"); | ||
mVectHistoCheck.at(ih).quality = 3; | ||
} | ||
} | ||
} | ||
} | ||
// dumpStruct(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem |
||
return result; | ||
} | ||
|
||
|
@@ -198,6 +261,25 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR | |
ILOG(Error, Support) << "could not cast '" << mo->getName() << "' to TH1*" << ENDM; | ||
return; | ||
} | ||
if (mo->getName() == "hBCAlignPlot") { | ||
float ratio = 0.0; | ||
for (int x = 0; x < h->GetNbinsX(); x++) { | ||
for (int y = 0; y < h->GetNbinsY(); y++) { | ||
ratio = (h->GetBinContent(x + 1, y + 1)) / (h->GetBinContent(x + 1, REFERENCE_BIN)); | ||
float xpos = h->GetXaxis()->GetBinCenter(x + 1); | ||
float ypos = h->GetYaxis()->GetBinCenter(y + 1); | ||
std::string strValue = std::format("{:.2f}", ratio); | ||
TLatex* msgr = new TLatex(xpos - 0.35, ypos - 0.15, strValue.c_str()); | ||
msgr->SetTextSize(9); | ||
if ((ratio > NOISE_LEVEL_LOW) && (ratio < NOISE_LEVEL_HIGH)) { | ||
msgr->SetTextColor(kGreen); | ||
} else { | ||
msgr->SetTextColor(kRed); | ||
} | ||
h->GetListOfFunctions()->Add(msgr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are potentially adding a msg for every bin in the plot. That is potentially very dangerous. A plot with a large number of "functions" becomes impossible to display and usually crashes the QCG, respectively the ROOT browser. How many bins are there ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} | ||
} | ||
if (mVectHistoCheck.at(ih).quality == 1) { | ||
std::string errorSt = getCurrentDataTime() + " Ok"; | ||
TLatex* msg = new TLatex(mVectHistoCheck.at(ih).posMsgX, mVectHistoCheck.at(ih).posMsgY, errorSt.c_str()); | ||
|
@@ -209,7 +291,16 @@ void ZDCRawDataCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkR | |
h->SetFillColor(kGreen); | ||
msg->Draw(); | ||
} else if (mVectHistoCheck.at(ih).quality == 3) { | ||
std::string errorSt = getCurrentDataTime() + " Errors --> Call the expert." + mVectHistoCheck.at(ih).stringE; | ||
// std::ofstream debugFile; | ||
// debugFile.open("debug.txt", std::ios::app); | ||
// if (debugFile.good()) { | ||
// debugFile << mVectHistoCheck.at(ih).numE << " "; | ||
// debugFile << mVectHistoCheck.at(ih).stringE << " "; | ||
// //debugFile << mVectHistoCheck.at(ih).paramch.at(x).ch << " "; | ||
// debugFile << "= \n"; | ||
// debugFile.close(); | ||
// } | ||
std::string errorSt = getCurrentDataTime() + " Errors --> Call the expert. " + mVectHistoCheck.at(ih).stringE; | ||
TLatex* msg = new TLatex(mVectHistoCheck.at(ih).posMsgX, mVectHistoCheck.at(ih).posMsgY, errorSt.c_str()); | ||
msg->SetNDC(); | ||
msg->SetTextSize(16); | ||
|
@@ -267,6 +358,45 @@ void ZDCRawDataCheck::init(const Activity& activity) | |
setChCheck("hpedSummary", "TH1F", "PED", "PED_POS_MSG_X", "PED_POS_MSG_Y", activity); | ||
setChCheck("hAlignPlotShift", "TH2F", "ALIGN", "ALIGN_POS_MSG_X", "ALIGN_POS_MSG_Y", activity); | ||
setChCheck("herrorSummary", "TH2F", "ERROR", "ERROR_POS_MSG_X", "ERROR_POS_MSG_Y", activity); | ||
setChCheck("hBCAlignPlot", "TH2F", "PED", "PED_POS_MSG_X", "PED_POS_MSG_Y", activity); | ||
|
||
std::vector<std::string> tokenString; | ||
if (auto param = mCustomParameters.find("REFERENCE_BIN"); param != mCustomParameters.end()) { | ||
ILOG(Debug, Devel) << "Custom parameter - REFERENCE_BIN: " << param->second << ENDM; | ||
tokenString = tokenLine(param->second, ";"); | ||
REFERENCE_BIN = atoi(param->second.c_str()); | ||
} else { | ||
REFERENCE_BIN = 7; | ||
} | ||
if (auto param = mCustomParameters.find("NOISE_LEVEL_LOW"); param != mCustomParameters.end()) { | ||
ILOG(Debug, Devel) << "Custom parameter - NOISE_LEVEL_LOW: " << param->second << ENDM; | ||
tokenString = tokenLine(param->second, ";"); | ||
NOISE_LEVEL_LOW = atof(param->second.c_str()); | ||
} else { | ||
NOISE_LEVEL_LOW = 0.0; | ||
} | ||
if (auto param = mCustomParameters.find("NOISE_LEVEL_HIGH"); param != mCustomParameters.end()) { | ||
ILOG(Debug, Devel) << "Custom parameter - NOISE_LEVEL_HIGH: " << param->second << ENDM; | ||
tokenString = tokenLine(param->second, ";"); | ||
NOISE_LEVEL_HIGH = atof(param->second.c_str()); | ||
} else { | ||
NOISE_LEVEL_HIGH = 2.0; | ||
} | ||
if (auto param = mCustomParameters.find("COMPARATOR_ARRAY"); param != mCustomParameters.end()) { | ||
ILOG(Debug, Devel) << "Custom parameter - COMPARATOR_ARRAY: " << param->second << ENDM; | ||
tokenString = tokenLine(param->second, ";"); | ||
for (int i = 0; i < 12; i++) { | ||
if (atoi(tokenString.at(i).c_str()) == 1) { | ||
COMPARATOR_ARRAY[i] = true; | ||
} else { | ||
COMPARATOR_ARRAY[i] = false; | ||
} | ||
} | ||
} else { | ||
for (int i = 0; i < 12; i++) { | ||
COMPARATOR_ARRAY[i] = false; | ||
} | ||
} | ||
// dumpStruct(); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot to update the class description