From bdeafe0164c6cca78d8cd034d3e8d12f2a013da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 21 Nov 2023 18:58:42 +0100 Subject: [PATCH] Add raw checkers --- Modules/TOF/include/TOF/CheckRaw.h | 52 +++++++++++++ Modules/TOF/src/CheckRaw.cxx | 115 +++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 Modules/TOF/include/TOF/CheckRaw.h create mode 100644 Modules/TOF/src/CheckRaw.cxx diff --git a/Modules/TOF/include/TOF/CheckRaw.h b/Modules/TOF/include/TOF/CheckRaw.h new file mode 100644 index 0000000000..0471b84577 --- /dev/null +++ b/Modules/TOF/include/TOF/CheckRaw.h @@ -0,0 +1,52 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 CheckRaw.h +/// \author Nicolo' Jacazio +/// \brief Checker for the raw compressed data for TOF +/// + +#ifndef QC_MODULE_TOF_CHECKCOMPRESSEDDATA_H +#define QC_MODULE_TOF_CHECKCOMPRESSEDDATA_H + +#include "QualityControl/CheckInterface.h" +#include "QualityControl/MonitorObject.h" +#include "QualityControl/Quality.h" + +namespace o2::quality_control_modules::tof +{ + +/// \brief Checker for the data produced by the TOF compressor (i.e. checking raw data) +/// +/// \author Nicolo' Jacazio +class CheckRaw : public o2::quality_control::checker::CheckInterface +{ + public: + /// Default constructor + CheckRaw() = default; + /// Destructor + ~CheckRaw() override = default; + + // Override interface + void configure(std::string name) override; + Quality check(std::map>* moMap) override; + void beautify(std::shared_ptr mo, Quality checkResult) override; + std::string getAcceptedType() override; + + private: + float mDiagnosticThresholdPerSlot = 0; + + ClassDefOverride(CheckRaw, 1); +}; + +} // namespace o2::quality_control_modules::tof + +#endif // QC_MODULE_TOF_CHECKCOMPRESSEDDATA_H diff --git a/Modules/TOF/src/CheckRaw.cxx b/Modules/TOF/src/CheckRaw.cxx new file mode 100644 index 0000000000..16c988da10 --- /dev/null +++ b/Modules/TOF/src/CheckRaw.cxx @@ -0,0 +1,115 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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 CheckRaw.cxx +/// \author Nicolo' Jacazio +/// \brief Checker for the raw compressed data for TOF +/// + +// QC +#include "TOF/CheckRaw.h" +#include "QualityControl/QcInfoLogger.h" + +// ROOT +#include +#include +#include +#include + +using namespace std; + +namespace o2::quality_control_modules::tof +{ + +void CheckRaw::configure(std::string) +{ + mDiagnosticThresholdPerSlot = 0; + if (auto param = mCustomParameters.find("DiagnosticThresholdPerSlot"); param != mCustomParameters.end()) { + mDiagnosticThresholdPerSlot = ::atof(param->second.c_str()); + } +} + +Quality CheckRaw::check(std::map>* moMap) +{ + + Quality result = Quality::Null; + ILOG(Info, Support) << "Checking quality of raw data" << ENDM; + + for (auto& [moName, mo] : *moMap) { + (void)moName; + if (mo->getName() == "hDiagnostic") { + auto* h = dynamic_cast(mo->getObject()); + result = Quality::Good; + for (int i = 1; i < h->GetNbinsX(); i++) { + for (int j = 1; j < h->GetNbinsY(); j++) { + const float content = h->GetBinContent(i, j); + if (content > mDiagnosticThresholdPerSlot) { // If above threshold + result = Quality::Bad; + } else if (content > 0) { // If larger than zero + result = Quality::Medium; + } + } + } + } else if (mo->getName() == "DRMCounter") { + auto* h = dynamic_cast(mo->getObject()); + if (h->GetEntries() == 0) { + result = Quality::Medium; + } + } else if (mo->getName() == "LTMCounter") { + auto* h = dynamic_cast(mo->getObject()); + if (h->GetEntries() == 0) { + result = Quality::Medium; + } + } + } + return result; +} + +std::string CheckRaw::getAcceptedType() { return "TH2F"; } + +void CheckRaw::beautify(std::shared_ptr mo, Quality checkResult) +{ + if (mo->getName() == "hDiagnostic") { + auto* h = dynamic_cast(mo->getObject()); + TPaveText* msg = new TPaveText(0.9, 0.1, 1.0, 0.5, "blNDC"); + h->GetListOfFunctions()->Add(msg); + msg->SetBorderSize(1); + msg->SetTextColor(kWhite); + msg->SetFillColor(kBlack); + msg->AddText("Default message for hDiagnostic"); + msg->SetName(Form("%s_msg", mo->GetName())); + + if (checkResult == Quality::Good) { + ILOG(Info, Support) << "Quality::Good, setting to green" << ENDM; + msg->Clear(); + msg->AddText("OK!"); + msg->SetFillColor(kGreen); + msg->SetTextColor(kBlack); + } else if (checkResult == Quality::Bad) { + ILOG(Info, Support) << "Quality::Bad, setting to red" << ENDM; + msg->Clear(); + msg->AddText("Diagnostics"); + msg->AddText("above"); + msg->AddText(Form("threshold (%.0f)", mDiagnosticThresholdPerSlot)); + msg->SetFillColor(kRed); + msg->SetTextColor(kBlack); + } else if (checkResult == Quality::Medium) { + ILOG(Info, Support) << "Quality::medium, setting to yellow" << ENDM; + msg->Clear(); + msg->AddText("Diagnostics above zero"); + msg->SetFillColor(kYellow); + msg->SetTextColor(kBlack); + } + } else { + ILOG(Error, Support) << "Did not get correct histo from " << mo->GetName() << ENDM; + } +} +} // namespace o2::quality_control_modules::tof