Skip to content

Commit 3022cfd

Browse files
authored
Common: improve reference run handling in checker (#2376)
* [Common] only verify the reference run validity when checking single plots A valid reference run is not needed when checking canvas objects, because the reference plot is already embedded in the canvas and does not need to be retrieved again from QCDB * [Common] cache reference plots in checker The reference plots are retrieved only once the first time the corresponding object is checked, and cached for all subsequent checks until the start of a new activity. * [Common] clang formatting
1 parent f6820b5 commit 3022cfd

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

Modules/Common/include/Common/ReferenceComparatorCheck.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Common/ObjectComparatorInterface.h"
2323

2424
#include <sstream>
25+
#include <unordered_map>
2526

2627
class TPaveText;
2728

@@ -56,6 +57,7 @@ class ReferenceComparatorCheck : public o2::quality_control::checker::CheckInter
5657
std::map<std::string, std::shared_ptr<TPaveText>> mQualityLabels;
5758
quality_control::core::Activity mActivity /*current*/, mReferenceActivity;
5859
size_t mReferenceRun;
60+
std::unordered_map<std::string, std::shared_ptr<MonitorObject>> mReferencePlots;
5961
};
6062

6163
} // namespace o2::quality_control_modules::common

Modules/Common/src/ReferenceComparatorCheck.cxx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void ReferenceComparatorCheck::startOfActivity(const Activity& activity)
6363
mActivity = activity;
6464
mReferenceActivity = activity;
6565
mReferenceActivity.mId = mReferenceRun;
66+
67+
// clear the cache of reference plots
68+
mReferencePlots.clear();
6669
}
6770

6871
void ReferenceComparatorCheck::endOfActivity(const Activity& activity)
@@ -149,8 +152,18 @@ Quality ReferenceComparatorCheck::getSinglePlotQuality(std::shared_ptr<MonitorOb
149152

150153
// get path of mo and ref (we have to remove the provenance)
151154
std::string path = RepoPathUtils::getPathNoProvenance(mo);
152-
// todo we could cache the reference plot within a run
153-
auto referencePlot = retrieveReference(path, mReferenceActivity);
155+
156+
if (mReferenceRun == 0) {
157+
message = "No reference run provided";
158+
return Quality::Null;
159+
}
160+
161+
// retrieve the reference plot only once and cache it for later use
162+
if (mReferencePlots.count(path) == 0) {
163+
mReferencePlots[path] = retrieveReference(path, mReferenceActivity);
164+
}
165+
166+
auto referencePlot = mReferencePlots[path];
154167
if (!referencePlot) {
155168
message = "Reference plot not found";
156169
return Quality::Null;
@@ -172,11 +185,6 @@ Quality ReferenceComparatorCheck::check(std::map<std::string, std::shared_ptr<Mo
172185
{
173186
Quality result = Quality::Null;
174187

175-
if (mReferenceRun == 0) {
176-
result.addFlag(FlagTypeFactory::Unknown(), "No reference run provided");
177-
return result;
178-
}
179-
180188
for (auto& [key, mo] : *moMap) {
181189
auto moName = mo->getName();
182190
Quality quality;

0 commit comments

Comments
 (0)