1818#include " QualityControl/MonitorObject.h"
1919#include " QualityControl/Quality.h"
2020#include " QualityControl/QcInfoLogger.h"
21+ #include " Skeleton/SkeletonTask.h"
22+ #include " QualityControl/Data.h"
2123// ROOT
2224#include < TH1.h>
2325
2426#include < DataFormatsQualityControl/FlagType.h>
2527#include < DataFormatsQualityControl/FlagTypeFactory.h>
28+ #include < memory>
2629
2730using namespace std ;
2831using namespace o2 ::quality_control;
@@ -40,6 +43,12 @@ void SkeletonCheck::configure()
4043}
4144
4245Quality SkeletonCheck::check (std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
46+ {
47+ Data data{ *moMap };
48+ return check (data);
49+ }
50+
51+ Quality SkeletonCheck::check (const quality_control::core::Data& data)
4352{
4453 // THUS FUNCTION BODY IS AN EXAMPLE. PLEASE REMOVE EVERYTHING YOU DO NOT NEED.
4554 Quality result = Quality::Null;
@@ -49,35 +58,35 @@ Quality SkeletonCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
4958 // and you can get your custom parameters:
5059 ILOG (Debug, Devel) << " custom param physics.pp.myOwnKey1 : " << mCustomParameters .atOrDefaultValue (" myOwnKey1" , " default_value" , " physics" , " pp" ) << ENDM;
5160
52- // This is an example of accessing the histogram 'example' created by SkeletonTask
53- for (auto & [moName, mo] : *moMap) {
54- if (mo->getName () == " example" ) {
55- auto * h = dynamic_cast <TH1*>(mo->getObject ());
56- if (h == nullptr ) {
57- ILOG (Error, Support) << " Could not cast `example` to TH1*, skipping" << ENDM;
58- continue ;
59- }
60- // unless we find issues, we assume the quality is good
61- result = Quality::Good;
62-
63- // an example of a naive quality check: we want bins 1-7 to be non-empty and bins 0 and >7 to be empty.
64- for (int i = 0 ; i < h->GetNbinsX (); i++) {
65- if (i > 0 && i < 8 && h->GetBinContent (i) == 0 ) {
66- result = Quality::Bad;
67- // optionally, we can add flags indicating the effect on data and a comment explaining why it was assigned.
68- result.addFlag (FlagTypeFactory::BadPID (), " It is bad because there is nothing in bin " + std::to_string (i));
69- break ;
70- } else if ((i == 0 || i > 7 ) && h->GetBinContent (i) > 0 ) {
71- result = Quality::Medium;
72- // optionally, we can add flags indicating the effect on data and a comment explaining why it was assigned.
73- result.addFlag (FlagTypeFactory::Unknown (), " It is medium because bin " + std::to_string (i) + " is not empty" );
74- result.addFlag (FlagTypeFactory::BadTracking (), " We can assign more than one Flag to a Quality" );
75- }
61+ auto MOs = data.getAllOfTypeIf <std::shared_ptr<MonitorObject>>([](const auto & mo) { return mo->getName () == " example" ; });
62+
63+ for (const auto & mo : MOs) {
64+ auto * h = dynamic_cast <TH1*>(mo->getObject ());
65+ if (h == nullptr ) {
66+ ILOG (Error, Support) << " Could not cast `example` to TH1*, skipping" << ENDM;
67+ continue ;
68+ }
69+ // unless we find issues, we assume the quality is good
70+ result = Quality::Good;
71+
72+ // an example of a naive quality check: we want bins 1-7 to be non-empty and bins 0 and >7 to be empty.
73+ for (int i = 0 ; i < h->GetNbinsX (); i++) {
74+ if (i > 0 && i < 8 && h->GetBinContent (i) == 0 ) {
75+ result = Quality::Bad;
76+ // optionally, we can add flags indicating the effect on data and a comment explaining why it was assigned.
77+ result.addFlag (FlagTypeFactory::BadPID (), " It is bad because there is nothing in bin " + std::to_string (i));
78+ break ;
79+ } else if ((i == 0 || i > 7 ) && h->GetBinContent (i) > 0 ) {
80+ result = Quality::Medium;
81+ // optionally, we can add flags indicating the effect on data and a comment explaining why it was assigned.
82+ result.addFlag (FlagTypeFactory::Unknown (), " It is medium because bin " + std::to_string (i) + " is not empty" );
83+ result.addFlag (FlagTypeFactory::BadTracking (), " We can assign more than one Flag to a Quality" );
7684 }
77- // optionally, we can associate some custom metadata to a Quality
78- result.addMetadata (" mykey" , " myvalue" );
7985 }
86+ // optionally, we can associate some custom metadata to a Quality
87+ result.addMetadata (" mykey" , " myvalue" );
8088 }
89+
8190 return result;
8291}
8392
0 commit comments