Skip to content

Commit

Permalink
Lastcommit
Browse files Browse the repository at this point in the history
  • Loading branch information
njacazio committed Nov 21, 2023
1 parent 46aa0b9 commit 41fab7f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 23 deletions.
62 changes: 53 additions & 9 deletions Modules/TOF/include/Base/MessagePad.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// QC includes
#include "QualityControl/Quality.h"
#include "QualityControl/QcInfoLogger.h"
#include "TOF/Utils.h"

// ROOT includes
#include "TPaveText.h"
Expand All @@ -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)
Expand All @@ -54,22 +61,33 @@ struct MessagePad {
template <typename T>
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);
}

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Modules/TOF/include/TOF/CheckCompressedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
7 changes: 6 additions & 1 deletion Modules/TOF/include/TOF/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down Expand Up @@ -102,4 +105,6 @@ bool parseStrParameter(const ParameterType& parametersIn, const std::string& nam
return false;
}

} // namespace o2::quality_control_modules::tof::utils
} // namespace o2::quality_control_modules::tof::utils

#endif
9 changes: 2 additions & 7 deletions Modules/TOF/src/CheckDiagnostics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Quality CheckDiagnostics::check(std::map<std::string, std::shared_ptr<MonitorObj
auto* h = dynamic_cast<TH2F*>(mo->getObject());
if (h->GetEntries() == 0) {
result = Quality::Medium;
mShifterMessages.AddMessage("No entries");
}
}
}
Expand All @@ -59,14 +60,8 @@ void CheckDiagnostics::beautify(std::shared_ptr<MonitorObject> 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;
Expand Down
7 changes: 2 additions & 5 deletions Modules/TOF/src/CheckHitMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -118,11 +120,6 @@ void CheckHitMap::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResul
auto* h = static_cast<TH2F*>(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) {
Expand Down

0 comments on commit 41fab7f

Please sign in to comment.