diff --git a/Modules/TOF/include/Base/MessagePad.h b/Modules/TOF/include/Base/MessagePad.h index f2cc30aaee..3e19c0ab2d 100644 --- a/Modules/TOF/include/Base/MessagePad.h +++ b/Modules/TOF/include/Base/MessagePad.h @@ -22,6 +22,7 @@ // QC includes #include "QualityControl/Quality.h" #include "QualityControl/QcInfoLogger.h" +#include "TOF/Utils.h" // ROOT includes #include "TPaveText.h" @@ -42,6 +43,12 @@ struct MessagePad { int mEnabledFlag = 1; /// Flag to enable or disable the pad const std::string mName = ""; /// Name of the message pad, can be used to identify the pad if multiple are used + // Messages to print based on quality + std::string mMessageWhenNull = "No quality established"; /// Message to print when quality is Null + std::string mMessageWhenGood = "OK!"; /// Message to print when quality is Good + std::string mMessageWhenMedium = "Email TOF on-call"; /// Message to print when quality is Medium + std::string mMessageWhenBad = ""; /// Message to print when quality is Bad + MessagePad(const std::string name = "", const float padLowX = 0.6, const float padLowY = 0.5, const float padHighX = 0.9, const float padHighY = 0.75) : mName(name) @@ -54,22 +61,33 @@ struct MessagePad { template void configure(const T& CustomParameters) { - if (auto param = CustomParameters.find(mName + "PadLowX"); param != CustomParameters.end()) { - mPadLowX = ::atof(param->second.c_str()); + // Setting position + if (utils::parseFloatParameter(CustomParameters, mName + "PadLowX", mPadLowX)) { ILOG(Info, Support) << "Setting message pad " << mName << " mPadLowX to " << mPadLowX << ENDM; } - if (auto param = CustomParameters.find(mName + "PadLowY"); param != CustomParameters.end()) { - mPadLowY = ::atof(param->second.c_str()); + if (utils::parseFloatParameter(CustomParameters, mName + "PadLowY", mPadLowY)) { ILOG(Info, Support) << "Setting message pad " << mName << " mPadLowY to " << mPadLowY << ENDM; } - if (auto param = CustomParameters.find(mName + "PadHighX"); param != CustomParameters.end()) { - mPadHighX = ::atof(param->second.c_str()); + if (utils::parseFloatParameter(CustomParameters, mName + "PadHighX", mPadHighX)) { ILOG(Info, Support) << "Setting message pad " << mName << " mPadHighX to " << mPadHighX << ENDM; } - if (auto param = CustomParameters.find(mName + "PadHighY"); param != CustomParameters.end()) { - mPadHighY = ::atof(param->second.c_str()); + if (utils::parseFloatParameter(CustomParameters, mName + "PadHighY", mPadHighY)) { ILOG(Info, Support) << "Setting message pad " << mName << " mPadHighY to " << mPadHighY << ENDM; } + // Setting standard messages + if (utils::parseStrParameter(CustomParameters, mName + "MessageWhenNull", mMessageWhenNull)) { + ILOG(Info, Support) << "Setting message pad " << mName << " mMessageWhenNull to " << mMessageWhenNull << ENDM; + } + if (utils::parseStrParameter(CustomParameters, mName + "MessageWhenGood", mMessageWhenGood)) { + ILOG(Info, Support) << "Setting message pad " << mName << " mMessageWhenGood to " << mMessageWhenGood << ENDM; + } + if (utils::parseStrParameter(CustomParameters, mName + "MessageWhenMedium", mMessageWhenMedium)) { + ILOG(Info, Support) << "Setting message pad " << mName << " mMessageWhenMedium to " << mMessageWhenMedium << ENDM; + } + if (utils::parseStrParameter(CustomParameters, mName + "MessageWhenBad", mMessageWhenBad)) { + ILOG(Info, Support) << "Setting message pad " << mName << " mMessageWhenBad to " << mMessageWhenBad << ENDM; + } + // Setting flags configureEnabledFlag(CustomParameters); } @@ -92,6 +110,15 @@ struct MessagePad { mPadHighY = padHighY; } + /// Function to reset the standard quality messages + void clearQualityMessages() + { + mMessageWhenNull = ""; + mMessageWhenGood = ""; + mMessageWhenMedium = ""; + mMessageWhenBad = ""; + } + /// Function to add a message that will be reported in the pad, will only add the message if the flag mEnabledFlag is on void AddMessage(const std::string& message) { @@ -127,11 +154,28 @@ struct MessagePad { mMessagePad->SetTextColor(kWhite); mMessagePad->SetFillStyle(3001); mMessagePad->SetFillColor(kBlack); - mMessagePad->AddText("No quality established"); } + // Add all lines for (const auto& line : mMessages) { mMessagePad->AddText(line.c_str()); } + // Last line: message based on quality + std::string qualityMessage = ""; + if (quality == Quality::Good) { + qualityMessage = mMessageWhenGood; + } else if (quality == Quality::Medium) { + qualityMessage = mMessageWhenMedium; + } else if (quality == Quality::Bad) { + qualityMessage = mMessageWhenBad; + } else if (quality == Quality::Null) { + qualityMessage = mMessageWhenNull; + } else { + qualityMessage = "Quality undefined"; + } + if (qualityMessage != "") { + mMessagePad->AddText(qualityMessage.c_str()); + } + // Clear the messages for next usage mMessages.clear(); return mMessagePad; diff --git a/Modules/TOF/include/TOF/CheckCompressedData.h b/Modules/TOF/include/TOF/CheckCompressedData.h index 11a54de3b0..9a40d51d8e 100644 --- a/Modules/TOF/include/TOF/CheckCompressedData.h +++ b/Modules/TOF/include/TOF/CheckCompressedData.h @@ -45,7 +45,7 @@ class CheckCompressedData : public o2::quality_control::checker::CheckInterface float mDiagnosticThresholdPerSlot = 0; /// Messages to print on the output PAD - MessagePad mShifterMessages{ "", 0.9, 0.1, 1.0, 0.5 }; + MessagePad mShifterMessages{ "CompressedData", 0.9, 0.1, 1.0, 0.5 }; ClassDefOverride(CheckCompressedData, 2); }; diff --git a/Modules/TOF/include/TOF/Utils.h b/Modules/TOF/include/TOF/Utils.h index 4c5a608727..5a3641142f 100644 --- a/Modules/TOF/include/TOF/Utils.h +++ b/Modules/TOF/include/TOF/Utils.h @@ -15,6 +15,9 @@ /// \brief Set of common utilities for Tasks and Checkers /// +#ifndef QC_MODULE_TOF_UTILS_H +#define QC_MODULE_TOF_UTILS_H + namespace o2::quality_control_modules::tof::utils { @@ -102,4 +105,6 @@ bool parseStrParameter(const ParameterType& parametersIn, const std::string& nam return false; } -} // namespace o2::quality_control_modules::tof::utils \ No newline at end of file +} // namespace o2::quality_control_modules::tof::utils + +#endif diff --git a/Modules/TOF/src/CheckDiagnostics.cxx b/Modules/TOF/src/CheckDiagnostics.cxx index d32089031d..92671e6d5b 100644 --- a/Modules/TOF/src/CheckDiagnostics.cxx +++ b/Modules/TOF/src/CheckDiagnostics.cxx @@ -43,6 +43,7 @@ Quality CheckDiagnostics::check(std::map(mo->getObject()); if (h->GetEntries() == 0) { result = Quality::Medium; + mShifterMessages.AddMessage("No entries"); } } } @@ -59,14 +60,8 @@ void CheckDiagnostics::beautify(std::shared_ptr mo, Quality check if (!msg) { return; } - if (checkResult == Quality::Good) { - msg->AddText("OK!"); - } else if (checkResult == Quality::Bad) { + if (checkResult == Quality::Bad) { msg->AddText("No TOF hits for all events."); - msg->AddText("Call TOF on-call."); - } else if (checkResult == Quality::Medium) { - msg->AddText("No entries. IF TOF IN RUN"); - msg->AddText("email TOF on-call."); } } else ILOG(Error, Support) << "Did not get correct histo from " << mo->GetName() << ENDM; diff --git a/Modules/TOF/src/CheckHitMap.cxx b/Modules/TOF/src/CheckHitMap.cxx index d0db557070..72ebcc0f91 100644 --- a/Modules/TOF/src/CheckHitMap.cxx +++ b/Modules/TOF/src/CheckHitMap.cxx @@ -37,7 +37,9 @@ void CheckHitMap::configure() utils::parseBooleanParameter(mCustomParameters, "EnableReferenceHitMap", mEnableReferenceHitMap); utils::parseStrParameter(mCustomParameters, "RefMapCcdbPath", mRefMapCcdbPath); utils::parseIntParameter(mCustomParameters, "RefMapTimestamp", mRefMapTimestamp); + mPhosModuleMessage.clearQualityMessages(); mPhosModuleMessage.configureEnabledFlag(mCustomParameters); + mShifterMessages.mMessageWhenBad = "Call TOF on-call"; mShifterMessages.configure(mCustomParameters); } @@ -118,11 +120,6 @@ void CheckHitMap::beautify(std::shared_ptr mo, Quality checkResul auto* h = static_cast(mo->getObject()); if (checkResult != Quality::Good) { auto msg = mShifterMessages.MakeMessagePad(h, checkResult); - if (checkResult == Quality::Bad) { - msg->AddText("Call TOF on-call."); - } else if (checkResult == Quality::Medium) { - msg->AddText("IF TOF IN RUN email TOF on-call."); - } } auto msgPhos = mPhosModuleMessage.MakeMessagePad(h, Quality::Good, "bl"); if (!msgPhos) {