Skip to content

Commit

Permalink
pass only 1 activity for reference and not the reference run + the cu…
Browse files Browse the repository at this point in the history
…rrent activity
  • Loading branch information
Barthelemy committed Jul 5, 2024
1 parent 371a1a6 commit fd93cdf
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
5 changes: 2 additions & 3 deletions Framework/include/QualityControl/CheckInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ class CheckInterface : public core::UserCodeInterface
/// the activity is the current one, while the run number is the reference run.
///
/// \param path path to the object (no provenance)
/// \param referenceRun Run number of the reference data
/// \param activity Current activity (necessary for the provenance and the pass)
/// \param referenceActivity Reference activity (usually a copy of the current activity with a different run number)
/// \return
std::shared_ptr<MonitorObject> retrieveReference(std::string path, size_t referenceRun, Activity activity);
std::shared_ptr<MonitorObject> retrieveReference(std::string path, Activity referenceActivity);

private:
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDatabase;
Expand Down
4 changes: 2 additions & 2 deletions Framework/include/QualityControl/ReferenceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace o2::quality_control::checker
// Get the reference plot for a given MonitorObject path

static std::shared_ptr<quality_control::core::MonitorObject> getReferencePlot(quality_control::repository::DatabaseInterface* qcdb, std::string& fullPath,
size_t referenceRun, core::Activity activity)
core::Activity referenceActivity)
{
auto [success, path, name] = o2::quality_control::core::RepoPathUtils::splitObjectPath(fullPath);
if (!success) {
return nullptr;
}
return qcdb->retrieveMO(path, name, repository::DatabaseInterface::Timestamp::Latest, activity);
return qcdb->retrieveMO(path, name, repository::DatabaseInterface::Timestamp::Latest, referenceActivity);
}

} // namespace o2::quality_control::checker
Expand Down
4 changes: 2 additions & 2 deletions Framework/src/CheckInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ void CheckInterface::endOfActivity(const Activity& activity)
// noop, override it if you want.
}

shared_ptr<MonitorObject> CheckInterface::retrieveReference(std::string path, size_t referenceRun, Activity activity)
shared_ptr<MonitorObject> CheckInterface::retrieveReference(std::string path, Activity referenceActivity)
{
return o2::quality_control::checker::getReferencePlot(mDatabase.get(), path, referenceRun, activity);
return o2::quality_control::checker::getReferencePlot(mDatabase.get(), path, referenceActivity);
}

} // namespace o2::quality_control::checker
2 changes: 1 addition & 1 deletion Modules/Common/include/Common/ReferenceComparatorCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ReferenceComparatorCheck : public o2::quality_control::checker::CheckInter
std::unique_ptr<ObjectComparatorInterface> mComparator;
std::map<std::string, Quality> mQualityFlags;
std::map<std::string, std::shared_ptr<TPaveText>> mQualityLabels;
quality_control::core::Activity mActivity;
quality_control::core::Activity mActivity /*current*/, mReferenceActivity;
size_t mReferenceRun;
};

Expand Down
6 changes: 4 additions & 2 deletions Modules/Common/src/ReferenceComparatorCheck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ void ReferenceComparatorCheck::startOfActivity(const Activity& activity)
}

mActivity = activity;
mReferenceActivity = activity;
mReferenceActivity.mId = mReferenceRun;
}

void ReferenceComparatorCheck::endOfActivity(const Activity& activity)
Expand Down Expand Up @@ -147,8 +149,8 @@ Quality ReferenceComparatorCheck::getSinglePlotQuality(std::shared_ptr<MonitorOb

// get path of mo and ref (we have to remove the provenance)
std::string path = RepoPathUtils::getPathNoProvenance(mo);

auto referencePlot = retrieveReference(path, mReferenceRun, mActivity);
// todo we could cache the reference plot within a run
auto referencePlot = retrieveReference(path, mReferenceActivity);
if (!referencePlot) {
message = "Reference plot not found";
return Quality::Null;
Expand Down
4 changes: 3 additions & 1 deletion Modules/Common/src/ReferenceComparatorTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ void ReferenceComparatorTask::initialize(quality_control::postprocessing::Trigge
auto fullOutPath = group.outputPath + "/" + path;

// retrieve the reference MO
auto referencePlot = o2::quality_control::checker::getReferencePlot(&qcdb, fullRefPath, mReferenceRun, trigger.activity);
auto referenceActivity = trigger.activity;
referenceActivity.mId = mReferenceRun;
auto referencePlot = o2::quality_control::checker::getReferencePlot(&qcdb, fullRefPath, referenceActivity);
if (!referencePlot) {
continue;
}
Expand Down
5 changes: 2 additions & 3 deletions doc/Advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -1406,11 +1406,10 @@ A reference object is an object from a previous run. It is usually used as a poi

To retrieve a reference plot in your Check, use
```
std::shared_ptr<MonitorObject> CheckInterface::retrieveReference(std::string path, int referenceRun, Activity activity);
std::shared_ptr<MonitorObject> CheckInterface::retrieveReference(std::string path, Activity referenceActivity);
```
- `path` : the path of the object _without the provenance (e.g. `qc`)_
- `referenceRun` : the run of reference
- `activity` : the current activity
- `referenceActivity` : the activity of reference (usually the current activity with a different run number)

If the reference is not found it will return a `nullptr` and the quality is `Null`.

Expand Down

0 comments on commit fd93cdf

Please sign in to comment.