Skip to content

Commit

Permalink
[Common] added generic checker from trend graphs
Browse files Browse the repository at this point in the history
The checker is designed to verify that the values of trend graphs are
within given minimum and maximum limits.
The limits can be specified as fixed values, or values relative to either
the mean or the standard deviation of a given set of graph points.
  • Loading branch information
aferrero2707 committed Sep 20, 2024
1 parent ce72c93 commit 83fdd47
Show file tree
Hide file tree
Showing 4 changed files with 553 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Modules/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ target_sources(O2QcCommon
src/ReferenceComparatorTask.cxx
src/ReferenceComparatorTaskConfig.cxx
src/ReferenceComparatorCheck.cxx
src/CheckerThresholdsConfig.cxx
src/TrendCheck.cxx
src/NonEmpty.cxx
src/MeanIsAbove.cxx
src/TH1Reductor.cxx
Expand Down Expand Up @@ -68,6 +70,7 @@ add_root_dictionary(O2QcCommon
include/Common/ObjectComparatorKolmogorov.h
include/Common/ReferenceComparatorTask.h
include/Common/ReferenceComparatorCheck.h
include/Common/TrendCheck.h
include/Common/MeanIsAbove.h
include/Common/TH1Ratio.h
include/Common/TH2Ratio.h
Expand Down
1 change: 1 addition & 0 deletions Modules/Common/include/Common/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma link C++ class o2::quality_control_modules::common::ObjectComparatorKolmogorov + ;
#pragma link C++ class o2::quality_control_modules::common::ReferenceComparatorTask + ;
#pragma link C++ class o2::quality_control_modules::common::ReferenceComparatorCheck + ;
#pragma link C++ class o2::quality_control_modules::common::TrendCheck + ;
#pragma link C++ class o2::quality_control_modules::common::WorstOfAllAggregator + ;
#pragma link C++ class o2::quality_control_modules::common::IncreasingEntries + ;
#pragma link C++ class o2::quality_control_modules::common::TH1SliceReductor + ;
Expand Down
83 changes: 83 additions & 0 deletions Modules/Common/include/Common/TrendCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// 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 TrendCheck.h
/// \author Andrea Ferrero
/// \brief Generic checker for trending graphs
///

#ifndef QC_MODULE_COMMON_TRENDCHECK_H
#define QC_MODULE_COMMON_TRENDCHECK_H

#include "QualityControl/CheckInterface.h"

#include <optional>
#include <array>
#include <unordered_map>

class TGraph;
class TObject;

using namespace o2::quality_control::core;

namespace o2::quality_control_modules::common
{

class CheckerThresholdsConfig;

/// \brief Generic checker for trending graphs
///
/// \author Andrea Ferrero
class TrendCheck : public o2::quality_control::checker::CheckInterface
{
public:
/// Default constructor
TrendCheck() = default;
/// Destructor
~TrendCheck() override = default;

void configure() override;
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
std::string getAcceptedType() override;

void startOfActivity(const Activity& activity) override;
void endOfActivity(const Activity& activity) override;

ClassDefOverride(TrendCheck, 1);

private:
enum ThresholdsMode {
ExpectedRange,
DeviationFromMean,
StdDeviation
};

std::array<std::optional<std::pair<double, double>>, 2> getThresholds(std::string key, TGraph* graph);
void getGraphsFromObject(TObject* object, std::vector<TGraph*>& graphs);
double getInteractionRate();

Activity mActivity;
ThresholdsMode mTrendCheckMode{ ExpectedRange };
int mNPointsForAverage{ 0 };
std::pair<float, float> mQualityLabelPosition{ 0.12, 0.8 };
std::pair<float, float> mQualityLabelSize{ 0.5, 0.07 };
std::shared_ptr<CheckerThresholdsConfig> mThresholds;
std::unordered_map<std::string, std::vector<std::pair<double, std::pair<double, double>>>> mAverageTrend;
std::unordered_map<std::string, std::vector<std::pair<double, std::pair<double, double>>>> mThresholdsTrendBad;
std::unordered_map<std::string, std::vector<std::pair<double, std::pair<double, double>>>> mThresholdsTrendMedium;
std::unordered_map<std::string, Quality> mQualities;
};

} // namespace o2::quality_control_modules::common

#endif // QC_MODULE_COMMON_TRENDCHECK_H
Loading

0 comments on commit 83fdd47

Please sign in to comment.