1717#include < TCanvas.h>
1818#include < TGraph.h>
1919#include < TH1.h>
20+ #include < TH2I.h>
2021
2122#include " QualityControl/QcInfoLogger.h"
2223#include " QualityControl/QCInputs.h"
@@ -38,19 +39,20 @@ void SkeletonLateTask::initialize(o2::framework::InitContext& /*ctx*/)
3839{
3940 // THUS FUNCTION BODY IS AN EXAMPLE. PLEASE REMOVE EVERYTHING YOU DO NOT NEED.
4041
41- // This is how logs are created. QcInfoLogger is used. In production, FairMQ logs will go to InfoLogger as well.
42- ILOG (Debug, Devel) << " initialize SkeletonLateTask" << ENDM;
43- ILOG (Debug, Support) << " A debug targeted for support" << ENDM;
44- ILOG (Info, Ops) << " An Info log targeted for operators" << ENDM;
42+ // This creates and registers a graph for publication, we will track "example" histogram mean here
43+ mMeanTrend = std::make_unique<TGraph>();
44+ mMeanTrend ->SetName (" mean_trend" );
45+ mMeanTrend ->SetTitle (" mean_trend" );
46+ mMeanTrend ->GetXaxis ()->SetTimeDisplay (kTRUE );
47+ mMeanTrend ->SetMarkerStyle (kStar ); // star markers
48+ mMeanTrend ->SetLineStyle (kSolid ); // solid line
49+ getObjectsManager ()->startPublishing (mMeanTrend .get (), PublicationPolicy::Forever);
4550
46- // This creates and registers a histogram for publication at the end of each cycle, until the end of the task lifetime
47- mGraph = std::make_unique<TGraph>();
48- mGraph ->SetName (" graph_example" );
49- mGraph ->SetTitle (" graph_example" );
50- mGraph ->SetMarkerStyle (kStar ); // star markers
51- mGraph ->SetLineStyle (kSolid ); // solid line
52- getObjectsManager ()->startPublishing (mGraph .get (), PublicationPolicy::Forever);
51+ // This creates and registers a 2D histogram for publication, we will fill it with means of "example" and "example2" histograms
52+ mCorrelation = std::make_unique<TH2I>(" correlation" , " correlation" , 20 , 0 , 10500 , 20 , 0 , 255 );
53+ getObjectsManager ()->startPublishing (mCorrelation .get (), PublicationPolicy::Forever);
5354
55+ // this demonstrates how to get a property tree of custom parameters
5456 auto plots = mCustomParameters .getOptionalPtree (" plots" );
5557 if (plots.has_value ()) {
5658 ILOG (Info, Support) << " nested param: " << plots.value ().get <std::string>(" nested" ) << ENDM;
@@ -62,23 +64,35 @@ void SkeletonLateTask::startOfActivity(const Activity& activity)
6264 // THIS FUNCTION BODY IS AN EXAMPLE. PLEASE REMOVE EVERYTHING YOU DO NOT NEED.
6365 ILOG (Debug, Devel) << " startOfActivity " << activity.mId << ENDM;
6466
65- // remove all existing points
66- mGraph -> Set ( 0 );
67+ // remove all existing data in plots to have them clean in a start->stop->start sequence
68+ reset ( );
6769}
6870
6971void SkeletonLateTask::process (const quality_control::core::QCInputs& data)
7072{
7173 // THIS FUNCTION BODY IS AN EXAMPLE. PLEASE REMOVE EVERYTHING YOU DO NOT NEED.
7274
73- if (auto histoOpt = getMonitorObject<TH1>(data, " example" )) {
74- const TH1& histo = histoOpt.value ();
75+ // this is how a MonitorObject can be obtained, incl. the wrapper itself
76+ if (auto moOpt = getMonitorObject (data, " example" )) {
77+ const MonitorObject& mo = moOpt.value ();
78+ auto validityEndSeconds = mo.getValidity ().getMax () / 1000 ;
7579
76- ILOG (Info, Ops) << " Histogram " << histo.GetName () << " has " << histo.GetEntries () << " entries" << ENDM;
77- mGraph ->AddPoint (histo.GetEntries (), histo.GetMean ());
80+ auto histo = dynamic_cast <TH1*>(mo.getObject ());
81+ if (histo) {
82+ mMeanTrend ->AddPoint (validityEndSeconds, histo->GetMean ());
83+ ILOG (Debug, Devel) << " New point in graph" << ENDM;
84+ }
7885 }
7986
80- if (auto qoOpt = getQualityObject (data, " QcCheck" )) {
81- ILOG (Info, Ops) << " Got QcCheck result: " << qoOpt.value ().get ().getQuality () << ENDM;
87+ // this is how objects can be retrieved without a MonitorObject wrapper
88+ auto example1Opt = getMonitorObject<TH1>(data, " example" );
89+ auto example2Opt = getMonitorObject<TH1>(data, " example2" );
90+ if (example1Opt.has_value () && example2Opt.has_value ()) {
91+ const TH1& example1 = example1Opt.value ();
92+ const TH1& example2 = example2Opt.value ();
93+
94+ mCorrelation ->Fill (example1.GetMean (), example2.GetMean ());
95+ ILOG (Debug, Devel) << " New entry in correlation" << ENDM;
8296 }
8397}
8498
@@ -94,8 +108,11 @@ void SkeletonLateTask::reset()
94108
95109 // Clean all the monitor objects here.
96110 ILOG (Debug, Devel) << " Resetting the plots" << ENDM;
97- if (mGraph ) {
98- mGraph ->Clear ();
111+ if (mMeanTrend ) {
112+ mMeanTrend ->Set (0 );
113+ }
114+ if (mCorrelation ) {
115+ mCorrelation ->Reset ();
99116 }
100117}
101118
0 commit comments