Skip to content

Commit 8997573

Browse files
Copilotknopers8
andcommitted
Address review comments: Add encapsulatedInheritFrom method and fix cosmetic issues
Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com>
1 parent fddcbd3 commit 8997573

File tree

14 files changed

+65
-14
lines changed

14 files changed

+65
-14
lines changed

Framework/include/QualityControl/MonitorObject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class MonitorObject : public TObject
117117
/// \brief Get metadata value of given key, returns std::nullopt if none exists;
118118
std::optional<std::string> getMetadata(const std::string& key);
119119

120+
/// \brief Check if the encapsulated object inherits from the given class name
121+
/// \param className Name of the class to check inheritance from
122+
/// \return true if the encapsulated object inherits from the given class, false otherwise
123+
bool encapsulatedInheritFrom(std::string_view className) const;
124+
120125
void Draw(Option_t* option) override;
121126
TObject* DrawClone(Option_t* option) const override;
122127

Framework/src/MonitorObject.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ std::optional<std::string> MonitorObject::getMetadata(const std::string& key)
162162
return std::nullopt;
163163
}
164164

165+
bool MonitorObject::encapsulatedInheritFrom(std::string_view className) const
166+
{
167+
if (!mObject) {
168+
return false;
169+
}
170+
return mObject->IsA()->InheritsFrom(className.data());
171+
}
172+
165173
std::string MonitorObject::getPath() const
166174
{
167175
return RepoPathUtils::getMoPath(this);

Modules/CPV/src/PedestalCheck.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ Quality PedestalCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
279279
return result;
280280
}
281281

282-
//
283-
284282
void PedestalCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
285283
{
286284
return; // do noting for the time being. Maybe in the future we will do something sofisticated

Modules/Common/src/MeanIsAbove.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ Quality MeanIsAbove::check(std::map<std::string, std::shared_ptr<MonitorObject>>
5555
void MeanIsAbove::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
5656
{
5757
// A line is drawn at the level of the threshold.
58-
// Its colour depends on the quality.auto* th1 = dynamic_cast<TH1*>(mo->getObject());
58+
// Its colour depends on the quality.
59+
60+
if (!mo->encapsulatedInheritFrom("TH1")) {
61+
ILOG(Error, Support) << "object not checkable" << ENDM;
62+
return;
63+
}
64+
65+
auto* th1 = dynamic_cast<TH1*>(mo->getObject());
5966

6067
Double_t xMin = th1->GetXaxis()->GetXmin();
6168
Double_t xMax = th1->GetXaxis()->GetXmax();

Modules/EMCAL/include/EMCAL/NumPhysTriggCheck.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class NumPhysTriggCheck : public o2::quality_control::checker::CheckInterface
4646
/// \param checkResult Quality status of this checker
4747
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
4848

49-
/// \brief Accept only TH1 histograms as input
50-
/// \return Name of the accepted object: TH1 ClassDefOverride(NumPhysTriggCheck, 1);
49+
ClassDefOverride(NumPhysTriggCheck, 1);
5150

5251
private:
5352
double mFracToMaxGood = 0.5; ///< Thresholds for minimum fraction of physics triggers compared to maximum

Modules/EMCAL/include/EMCAL/RawErrorCheck.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ class RawErrorCheck : public o2::quality_control::checker::CheckInterface
5656
/// \param checkResult Quality status of this checker
5757
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
5858

59-
/// \brief Accept only TH2 histograms as input
60-
/// \return Name of the accepted object: TH2 ClassDefOverride(RawErrorCheck, 2);
59+
ClassDefOverride(RawErrorCheck, 2);
6160

6261
private:
6362
/// \brief Decode key of a configurable parameter as boolean

Modules/HMPID/include/HMPID/HmpidRawChecks.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class HmpidRawChecks : public o2::quality_control::checker::CheckInterface
4848
void configure() override;
4949
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
5050
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
51-
// private:
51+
52+
private:
5253
std::array<Quality, 14> check_hHmpBigMap(TProfile2D* h); // <-- Dimensione da chiarire
5354
std::array<Quality, 42> check_hHmpHvSectorQ(TH2F* h);
5455
std::array<Quality, 14> check_hHmpPadOccPrf(TProfile* h);

Modules/TOF/src/CheckHitMap.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Quality CheckHitMap::check(std::map<std::string, std::shared_ptr<MonitorObject>>
4949
Quality result = Quality::Null;
5050

5151
for (auto& [moName, mo] : *moMap) {
52+
if (!mo->encapsulatedInheritFrom("TH2F")) {
53+
ILOG(Error, Support) << "Cannot check MO " << mo->getName() << " " << moName << " which is not of type TH2F" << ENDM;
54+
continue;
55+
}
5256
ILOG(Debug, Devel) << "Checking " << mo->getName() << ENDM;
5357
const auto* h = static_cast<TH2F*>(mo->getObject());
5458
if (h->GetEntries() == 0) { // Histogram is empty
@@ -128,6 +132,10 @@ Quality CheckHitMap::check(std::map<std::string, std::shared_ptr<MonitorObject>>
128132
void CheckHitMap::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
129133
{
130134
ILOG(Debug, Devel) << "Beautifying " << mo->getName() << ENDM;
135+
if (!mo->encapsulatedInheritFrom("TH2F")) {
136+
ILOG(Error, Support) << "Cannot beautify MO " << mo->getName() << " which is not of type TH2F" << ENDM;
137+
return;
138+
}
131139
if (1) {
132140
auto* h = static_cast<TH2F*>(mo->getObject());
133141
if (checkResult != Quality::Good) {

Modules/TOF/src/CheckNoise.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Quality CheckNoise::check(std::map<std::string, std::shared_ptr<MonitorObject>>*
3636
Quality result = Quality::Null;
3737

3838
for (auto& [moName, mo] : *moMap) {
39+
if (!mo->encapsulatedInheritFrom("TH1F")) {
40+
ILOG(Error, Support) << "Cannot check MO " << mo->getName() << " " << moName << " which is not of type TH1F" << ENDM;
41+
continue;
42+
}
3943
if (mo->getName() != mAcceptedName) {
4044
ILOG(Error, Support) << "Cannot check MO " << mo->getName() << " " << moName << " which does not have name " << mAcceptedName << ENDM;
4145
continue;
@@ -61,6 +65,10 @@ Quality CheckNoise::check(std::map<std::string, std::shared_ptr<MonitorObject>>*
6165
void CheckNoise::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
6266
{
6367
ILOG(Debug, Devel) << "Beautifying " << mo->getName() << ENDM;
68+
if (!mo->encapsulatedInheritFrom("TH2F")) {
69+
ILOG(Error, Support) << "Cannot beautify MO " << mo->getName() << " which is not of type TH2F" << ENDM;
70+
return;
71+
}
6472
if (mo->getName() == mAcceptedName) {
6573
auto* h = static_cast<TH2F*>(mo->getObject());
6674
auto msg = mShifterMessages.MakeMessagePad(h, checkResult);

Modules/TOF/src/CheckRawMultiplicity.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Quality CheckRawMultiplicity::check(std::map<std::string, std::shared_ptr<Monito
6767
float hitsIntegral = 0.f;
6868

6969
for (auto& [moName, mo] : *moMap) {
70+
if (!mo->encapsulatedInheritFrom("TH1")) {
71+
ILOG(Error, Support) << "Cannot check MO " << mo->getName() << " " << moName << " which is not of type TH1" << ENDM;
72+
continue;
73+
}
7074
ILOG(Debug, Devel) << "Checking " << mo->getName() << ENDM;
7175
if (mo->getName() == "Multiplicity/Integrated") {
7276
const auto* h = static_cast<TH1I*>(mo->getObject());
@@ -151,6 +155,10 @@ Quality CheckRawMultiplicity::check(std::map<std::string, std::shared_ptr<Monito
151155
void CheckRawMultiplicity::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
152156
{
153157
ILOG(Debug, Devel) << "Beautifying " << mo->getName() << ENDM;
158+
if (!mo->encapsulatedInheritFrom("TH1")) {
159+
ILOG(Error, Support) << "Cannot beautify MO " << mo->getName() << " which is not of type TH1" << ENDM;
160+
return;
161+
}
154162
if (mo->getName() == "Multiplicity/Integrated") {
155163
auto* h = static_cast<TH1I*>(mo->getObject());
156164
auto msg = mShifterMessages.MakeMessagePad(h, checkResult);

0 commit comments

Comments
 (0)