Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QC-885] Modify reference check to also accept a TH1 … #2358

Merged
merged 26 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a6b31d
[QC-885] Modify ReferenceComparatorCheck to also accept a TH1 instead…
Barthelemy Jun 26, 2024
603a00c
format
Barthelemy Jun 26, 2024
626e7c4
add beautify and doc
Barthelemy Jun 26, 2024
d23cfcd
Format
Barthelemy Jun 26, 2024
714a486
Format
Barthelemy Jun 26, 2024
466a984
cout
Barthelemy Jun 26, 2024
a1ad044
Update ReferenceComparatorCheck.cxx
Barthelemy Jun 26, 2024
4755f09
Update Advanced.md
Barthelemy Jun 26, 2024
d6cb6e1
Update Advanced.md
Barthelemy Jun 26, 2024
6f9e9ef
Update DevelopersTips.md
Barthelemy Jun 26, 2024
4b1c4d4
Merge branch 'master' into ref-plot-check
Barthelemy Jul 1, 2024
142565f
Update Framework/include/QualityControl/ReferenceUtils.h
Barthelemy Jul 1, 2024
71e7460
Update Modules/Common/src/ReferenceComparatorCheck.cxx
Barthelemy Jul 1, 2024
591aa86
Update doc/Advanced.md
Barthelemy Jul 1, 2024
5523798
Update doc/Advanced.md
Barthelemy Jul 1, 2024
81a00d1
Update ReferenceComparatorCheck.cxx
Barthelemy Jul 1, 2024
5262cce
Update ReferenceComparatorCheck.cxx
Barthelemy Jul 1, 2024
ee37571
- use int for the run
Barthelemy Jul 1, 2024
3c62749
format
Barthelemy Jul 1, 2024
da08db6
return a tuple
Barthelemy Jul 1, 2024
1ffb5ed
format
Barthelemy Jul 2, 2024
f84803a
return null quality if no reference run number is provided.
Barthelemy Jul 3, 2024
3da5995
extraction
Barthelemy Jul 3, 2024
da17738
- Keep the activity parameter but document it
Barthelemy Jul 5, 2024
371a1a6
Use extended parameters.
Barthelemy Jul 5, 2024
fd93cdf
pass only 1 activity for reference and not the reference run + the cu…
Barthelemy Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Framework/include/QualityControl/Check.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
// O2
#include <Framework/DataProcessorSpec.h>
// QC
#include "QualityControl/DatabaseInterface.h"
#include "QualityControl/QualityObject.h"
#include "QualityControl/CheckConfig.h"
#include "QualityControl/CheckInterface.h"

namespace o2::quality_control::core
{
Expand Down Expand Up @@ -92,6 +94,11 @@ class Check
static CheckConfig extractConfig(const core::CommonSpec&, const CheckSpec&);
static framework::OutputSpec createOutputSpec(const std::string& detector, const std::string& checkName);

void setDatabase(std::shared_ptr<o2::quality_control::repository::DatabaseInterface> database)
{
mCheckInterface->setDatabase(database);
}

private:
void beautify(std::map<std::string, std::shared_ptr<core::MonitorObject>>& moMap, const core::Quality& quality);

Expand Down
17 changes: 17 additions & 0 deletions Framework/include/QualityControl/CheckInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef QC_CHECKER_CHECKINTERFACE_H
#define QC_CHECKER_CHECKINTERFACE_H

#include "QualityControl/DatabaseInterface.h"
#include "QualityControl/Quality.h"
#include "QualityControl/UserCodeInterface.h"
#include "QualityControl/Activity.h"
Expand Down Expand Up @@ -82,10 +83,26 @@ class CheckInterface : public core::UserCodeInterface
virtual void startOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses
virtual void endOfActivity(const core::Activity& activity); // not fully abstract because we don't want to change all the existing subclasses

void setDatabase(std::shared_ptr<o2::quality_control::repository::DatabaseInterface> database)
{
mDatabase = database;
}

protected:
/// \brief Called each time mCustomParameters is updated.
virtual void configure() override;

/// \brief Retrieve a reference plot at the provided path, matching the give activity and for the provided run.
/// the activity is the current one, while the run number is the reference run.
///
/// \param path path to the object (no provenance)
/// \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, Activity referenceActivity);

private:
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDatabase;

ClassDef(CheckInterface, 6)
};

Expand Down
47 changes: 47 additions & 0 deletions Framework/include/QualityControl/ReferenceUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file ReferenceComparatorUtils.h
/// \author Andrea Ferrero and Barthelemy von Haller
///

#ifndef QUALITYCONTROL_ReferenceUtils_H
#define QUALITYCONTROL_ReferenceUtils_H

#include <memory>
#include "QualityControl/MonitorObject.h"
#include "QualityControl/DatabaseInterface.h"
#include "QualityControl/Activity.h"
#include "QualityControl/ActivityHelpers.h"
#include "QualityControl/QcInfoLogger.h"
#include "QualityControl/RepoPathUtils.h"

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,
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, referenceActivity);
}

} // namespace o2::quality_control::checker

#endif // QUALITYCONTROL_ReferenceUtils_H
30 changes: 30 additions & 0 deletions Framework/include/QualityControl/RepoPathUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,36 @@ class RepoPathUtils

static constexpr auto allowedProvenancesMessage = R"(Allowed provenances are "qc" (real data processed synchronously), "qc_async" (real data processed asynchronously) and "qc_mc" (simulated data).)";
static bool isProvenanceAllowed(const std::string& provenance);

/**
* Splits the provided path and returns both the base path and the object name.
* @param fullPath
* @return A tuple with 1. a boolean to specify if we succeeded (i.e. whether we found a `/`)
* 2. the path
* 3. the object name
*/
static std::tuple<bool, std::string, std::string> splitObjectPath(const std::string& fullPath)
{
std::string delimiter = "/";
std::string det;
size_t pos = fullPath.rfind(delimiter);
if (pos == std::string::npos) {
return { false, "", "" };
}
std::string path = fullPath.substr(0, pos);
std::string name = fullPath.substr(pos + 1);
return { true, path, name };
}

static std::string getPathNoProvenance(std::shared_ptr<MonitorObject> mo)
{
std::string path = mo->getPath();
size_t pos = path.find('/');
if (pos != std::string::npos) {
path = path.substr(pos + 1);
}
return path;
}
};
} // namespace o2::quality_control::core

Expand Down
6 changes: 6 additions & 0 deletions Framework/src/CheckInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
///

#include "QualityControl/CheckInterface.h"
#include "QualityControl/ReferenceUtils.h"
#include "QualityControl/MonitorObject.h"

#include <TClass.h>
Expand Down Expand Up @@ -59,4 +60,9 @@ void CheckInterface::endOfActivity(const Activity& activity)
// noop, override it if you want.
}

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

} // namespace o2::quality_control::checker
1 change: 1 addition & 0 deletions Framework/src/CheckRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ void CheckRunner::init(framework::InitContext& iCtx)
updatePolicyManager.reset();
for (auto& [checkName, check] : mChecks) {
check.init();
check.setDatabase(mDatabase);
updatePolicyManager.addPolicy(check.getName(), check.getUpdatePolicyType(), check.getObjectsNames(), check.getAllObjectsOption(), false);
}
} catch (...) {
Expand Down
4 changes: 4 additions & 0 deletions Modules/Common/include/Common/ReferenceComparatorCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ class ReferenceComparatorCheck : public o2::quality_control::checker::CheckInter
void endOfActivity(const Activity& activity) override;

private:
Quality getSinglePlotQuality(std::shared_ptr<MonitorObject> mo, std::string& message);

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 /*current*/, mReferenceActivity;
size_t mReferenceRun;
};

} // namespace o2::quality_control_modules::common
Expand Down
5 changes: 0 additions & 5 deletions Modules/Common/include/Common/ReferenceComparatorTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
#define QUALITYCONTROL_REFERENCECOMPARATORTASK_H

#include "Common/ReferenceComparatorTaskConfig.h"
#include "Common/BigScreenCanvas.h"
#include "QualityControl/PostProcessingInterface.h"
#include "QualityControl/DatabaseInterface.h"
#include "QualityControl/Quality.h"
#include <TH1.h>
#include <TPad.h>
#include <TCanvas.h>
#include <TPaveText.h>
#include <TText.h>
#include <string>
#include <map>
Expand Down Expand Up @@ -63,8 +60,6 @@ class ReferenceComparatorTask : public quality_control::postprocessing::PostProc
};

private:
std::shared_ptr<o2::quality_control::core::MonitorObject> getReferencePlot(o2::quality_control::repository::DatabaseInterface& qcdb, std::string fullPath, o2::quality_control::core::Activity activity);

int mReferenceRun{ 0 };
int mNotOlderThan{ 120 };

Expand Down
Loading
Loading