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

[ZDC] Qc additions #2510

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion Modules/ZDC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

add_library(O2QcZDC)

target_sources(O2QcZDC PRIVATE src/ZDCRecDataCheck.cxx src/ZDCRecDataTask.cxx src/ZDCRecDataPostProcessing.cxx src/PostProcessingConfigZDC.cxx src/ZDCRawDataCheck.cxx src/ZDCRawDataTask.cxx )
target_sources(O2QcZDC PRIVATE src/ZDCRecBeautifyPlots.cxx src/ZDCRecDataCheck.cxx src/ZDCRecDataTask.cxx src/ZDCRecDataPostProcessing.cxx src/PostProcessingConfigZDC.cxx src/ZDCRawDataCheck.cxx src/ZDCRawDataTask.cxx )

target_include_directories(
O2QcZDC
Expand All @@ -19,6 +19,7 @@ install(TARGETS O2QcZDC

add_root_dictionary(O2QcZDC
HEADERS
include/ZDC/ZDCRecBeautifyPlots.h
include/ZDC/ZDCRecDataCheck.h
include/ZDC/ZDCRecDataTask.h
include/ZDC/ZDCRecDataPostProcessing.h
Expand Down
11 changes: 6 additions & 5 deletions Modules/ZDC/include/ZDC/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataTask+;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataCheck+;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataTask+;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataCheck+;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataPostProcessing+;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataTask + ;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRawDataCheck + ;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataTask + ;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataCheck + ;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecDataPostProcessing + ;
#pragma link C++ class o2::quality_control_modules::zdc::ZDCRecBeautifyPlots + ;
#endif
4 changes: 4 additions & 0 deletions Modules/ZDC/include/ZDC/ZDCRawDataCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class ZDCRawDataCheck : public o2::quality_control::checker::CheckInterface
private:
std::vector<sHistoCheck> mVectHistoCheck;
std::vector<std::string> mVectch;
float NOISE_LEVEL_LOW = 0.0;
float NOISE_LEVEL_HIGH = 2.0;
bool COMPARATOR_ARRAY[12];
int REFERENCE_BIN = 7;

// std::string mStringW = "List channels Warning Quality: ";
// std::string mStringE = "List channels Bad Quality: ";
Expand Down
6 changes: 6 additions & 0 deletions Modules/ZDC/include/ZDC/ZDCRawDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ class ZDCRawDataTask final : public TaskInterface
TH2* fSummaryAlignShift;
TH2* fSummaryError;
TH1* fOverBc;
// Begin Stefan addition
TH2* fBCalignment;
// End Stefan addition

std::vector<std::string> fNameHisto;
std::map<std::string, int> fMapBinNameIdSummaryHisto;
Expand All @@ -173,6 +176,9 @@ class ZDCRawDataTask final : public TaskInterface
int fAlignCycle = 1; // param
int fErrorCycle = 1; // param
int fAlignNumEntries = 2000;
// Begin Stefan addition
int FirstEventBC = 0;
// End Stefan addition

sAlignment fMatrixAlign[o2::zdc::NModules][o2::zdc::NChPerModule];
};
Expand Down
52 changes: 52 additions & 0 deletions Modules/ZDC/include/ZDC/ZDCRecBeautifyPlots.h
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
Copy link
Collaborator

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

/// \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
12 changes: 12 additions & 0 deletions Modules/ZDC/include/ZDC/ZDCRecDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class ZDCRecDataTask final : public TaskInterface
int process(const gsl::span<const o2::zdc::BCRecData>& RecBC, const gsl::span<const o2::zdc::ZDCEnergy>& Energy, const gsl::span<const o2::zdc::ZDCTDCData>& TDCData, const gsl::span<const uint16_t>& Info);
bool FillTDCValueHisto();
std::vector<std::string> tokenLine(std::string Line, std::string Delimiter);
// Begin Stefan addition
bool IsEventCentral();
void SetConfigCentralEvent(float tdcLimit, int centraleventconfigvalue);
void settdcLimit(float tdcv) { ftdcLimit = tdcv; };
void setcentraleventconfigvalue(int centrentcfg) { fcentraleventconfigvalue = centrentcfg; };
float gettdcLimit() { return ftdcLimit; };
int getcentraleventconfigvalue() { return fcentraleventconfigvalue; };
// End Stefan addition

private:
std::vector<std::string> mVecCh;
Expand All @@ -127,6 +135,10 @@ class ZDCRecDataTask final : public TaskInterface
int fNumBinY = 0;
double fMinBinY = 0;
double fMaxBinY = 0;
// Begin Stefan addition
float ftdcLimit = 0;
int fcentraleventconfigvalue = 0;
// End Stefan addition
// TH1F* mHistogram = nullptr;
};

Expand Down
142 changes: 136 additions & 6 deletions Modules/ZDC/src/ZDCRawDataCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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;
Expand All @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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;
Expand All @@ -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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

return result;
}

Expand All @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 ?
Please consider another way if indicating problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-02-21 at 11 36 36 The plot would look like this. There are 12x26 bins

}
}
}
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());
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down
Loading
Loading