Skip to content

Commit 0044c47

Browse files
Copilotknopers8
andauthored
QC-373 Replace largely unused and not respected CheckInterface::getAcceptedType and isObjectCheckable with an optional helper (#2597)
* Initial plan * Remove CheckInterface::getAcceptedType and isObjectCheckable methods from framework and all user code Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> * Apply ALICE coding guidelines formatting using git-clang-format Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> * Address review comments: Add encapsulatedInheritFrom method and fix cosmetic issues Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> * Fix TOF check classes to use consistent types and add mAcceptedType constants Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> * Rename encapsulatedInheritFrom to encapsulatedInheritsFrom method Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> * bump MonitorObject version * missing TClass inclusion --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: knopers8 <14327588+knopers8@users.noreply.github.com> Co-authored-by: Piotr Konopka <piotr.jan.konopka@cern.ch>
1 parent 5c59a48 commit 0044c47

File tree

190 files changed

+47
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+47
-388
lines changed

Framework/include/QualityControl/CheckInterface.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ class CheckInterface : public core::UserCodeInterface
6969
/// then this should be reset here.
7070
virtual void reset(); // not fully abstract because we don't want to change all the existing subclasses
7171

72-
/// \brief Returns the name of the class that can be treated by this check.
73-
///
74-
/// The name of the class returned by this method will be checked against the MonitorObject's encapsulated
75-
/// object's class. If it is the same or a parent then the check will be applied. Therefore, this method
76-
/// must return the highest class in the hierarchy that this check can use.
77-
/// If the class does not override it, we return "TObject".
78-
virtual std::string getAcceptedType();
79-
80-
bool isObjectCheckable(const std::shared_ptr<core::MonitorObject> mo);
81-
bool isObjectCheckable(const core::MonitorObject* mo);
82-
8372
virtual void startOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses
8473
virtual void endOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses
8574

Framework/include/QualityControl/MonitorObject.h

Lines changed: 6 additions & 1 deletion
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 encapsulatedInheritsFrom(std::string_view className) const;
124+
120125
void Draw(Option_t* option) override;
121126
TObject* DrawClone(Option_t* option) const override;
122127

@@ -149,7 +154,7 @@ class MonitorObject : public TObject
149154
void releaseObject();
150155
void cloneAndSetObject(const MonitorObject&);
151156

152-
ClassDefOverride(MonitorObject, 14);
157+
ClassDefOverride(MonitorObject, 15);
153158
};
154159

155160
} // namespace o2::quality_control::core

Framework/src/CheckInterface.cxx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,12 @@
1818
#include "QualityControl/ReferenceUtils.h"
1919
#include "QualityControl/MonitorObject.h"
2020

21-
#include <TClass.h>
22-
2321
using namespace std;
2422
using namespace o2::quality_control::core;
2523

2624
namespace o2::quality_control::checker
2725
{
2826

29-
std::string CheckInterface::getAcceptedType() { return "TObject"; }
30-
31-
bool CheckInterface::isObjectCheckable(const std::shared_ptr<MonitorObject> mo)
32-
{
33-
return isObjectCheckable(mo.get());
34-
}
35-
36-
bool CheckInterface::isObjectCheckable(const MonitorObject* mo)
37-
{
38-
TObject* encapsulated = mo->getObject();
39-
40-
return encapsulated->IsA()->InheritsFrom(getAcceptedType().c_str());
41-
}
42-
4327
void CheckInterface::configure()
4428
{
4529
// noop, override it if you want.

Framework/src/MonitorObject.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "QualityControl/MonitorObject.h"
1818
#include <TObject.h>
19+
#include <TClass.h>
1920
#include "QualityControl/RepoPathUtils.h"
2021
#include "QualityControl/QcInfoLogger.h"
2122

@@ -162,6 +163,14 @@ std::optional<std::string> MonitorObject::getMetadata(const std::string& key)
162163
return std::nullopt;
163164
}
164165

166+
bool MonitorObject::encapsulatedInheritsFrom(std::string_view className) const
167+
{
168+
if (!mObject) {
169+
return false;
170+
}
171+
return mObject->IsA()->InheritsFrom(className.data());
172+
}
173+
165174
std::string MonitorObject::getPath() const
166175
{
167176
return RepoPathUtils::getMoPath(this);

Framework/test/testCheckInterface.cxx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class TestCheck : public checker::CheckInterface
6262
str->String().Append(" is beautiful now");
6363
}
6464

65-
std::string getAcceptedType() override
66-
{
67-
return "TObjString";
68-
}
69-
7065
string mValidString;
7166
};
7267

@@ -90,6 +85,4 @@ TEST_CASE("test_invoke_all_interface_methods")
9085

9186
testCheck.beautify(mo);
9287
CHECK(reinterpret_cast<TObjString*>(mo->getObject())->String() == "A string is beautiful now");
93-
94-
CHECK(testCheck.getAcceptedType() == "TObjString");
9588
}

Modules/Benchmark/include/Benchmark/AlwaysGoodCheck.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class AlwaysGoodCheck : public o2::quality_control::checker::CheckInterface
3737
void configure() override;
3838
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
3939
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
40-
std::string getAcceptedType() override;
41-
4240
ClassDefOverride(AlwaysGoodCheck, 2);
4341
};
4442

Modules/Benchmark/src/AlwaysGoodCheck.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ Quality AlwaysGoodCheck::check(std::map<std::string, std::shared_ptr<MonitorObje
3333
return Quality::Good;
3434
}
3535

36-
std::string AlwaysGoodCheck::getAcceptedType() { return ""; }
37-
3836
void AlwaysGoodCheck::beautify(std::shared_ptr<MonitorObject>, Quality)
3937
{
4038
}

Modules/CPV/include/CPV/PedestalCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class PedestalCheck : public o2::quality_control::checker::CheckInterface
3737
void configure() override;
3838
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
3939
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
40-
std::string getAcceptedType() override;
4140

4241
private:
4342
int getRunNumberFromMO(std::shared_ptr<MonitorObject> mo);

Modules/CPV/include/CPV/PhysicsCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class PhysicsCheck : public o2::quality_control::checker::CheckInterface
3737
void configure() override;
3838
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
3939
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
40-
std::string getAcceptedType() override { return "TH1"; }
4140

4241
private:
4342
int getRunNumberFromMO(std::shared_ptr<MonitorObject> mo);

Modules/CPV/src/PedestalCheck.cxx

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

282-
// std::string PedestalCheck::getAcceptedType() { return "TObject"; }
283-
std::string PedestalCheck::getAcceptedType() { return "TH1"; }
284-
285282
void PedestalCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult)
286283
{
287284
return; // do noting for the time being. Maybe in the future we will do something sofisticated

0 commit comments

Comments
 (0)