Skip to content

Commit 702f9df

Browse files
authored
[Common] restored title in quality trending plots (#2259)
The title of the plot was not shown because of the use of a dummy graph to plot the axes. The code has been simplified, removing the need of the dummy graph. The output is visually identical as before, except that the plot title is now also displayed, and the title of the horizontal axis is "time".
1 parent e81c599 commit 702f9df

2 files changed

Lines changed: 21 additions & 29 deletions

File tree

Modules/Common/include/Common/QualityTask.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class QualityTask : public quality_control::postprocessing::PostProcessingInterf
7171
static std::string trendName(const std::string& groupName, const std::string& qualityName);
7272

7373
std::unique_ptr<TGraph> mGraph;
74-
std::unique_ptr<TGraph> mGraphHist;
7574
std::array<std::unique_ptr<TText>, 4> mLabels;
7675
};
7776

@@ -106,4 +105,4 @@ class QualityTask : public quality_control::postprocessing::PostProcessingInterf
106105

107106
} // namespace o2::quality_control_modules::common
108107

109-
#endif // QUALITYCONTROL_QUALITYTASK_H
108+
#endif // QUALITYCONTROL_QUALITYTASK_H

Modules/Common/src/QualityTask.cxx

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ namespace o2::quality_control_modules::common
3737
QualityTask::QualityTrendGraph::QualityTrendGraph(std::string name, std::string title) : TCanvas(name.c_str(), title.c_str())
3838
{
3939
SetGridy(1);
40-
mGraphHist = std::make_unique<TGraph>(0);
4140

4241
mGraph = std::make_unique<TGraph>(0);
42+
mGraph->SetTitle(title.c_str());
4343
mGraph->SetMarkerStyle(kCircle);
44-
mGraph->SetTitle(fmt::format("{};time;quality", title).c_str());
44+
mGraph->SetTitle(fmt::format("{};time;", title).c_str());
4545

46+
// add labels in the middle of the vertical axis bins
4647
mLabels[0] = std::make_unique<TText>(0.09, 0.1 + 0.8 / 8.0, "Null");
4748
mLabels[1] = std::make_unique<TText>(0.09, 0.1 + 3.0 * 0.8 / 8.0, "Bad");
4849
mLabels[2] = std::make_unique<TText>(0.09, 0.1 + 5.0 * 0.8 / 8.0, "Medium");
@@ -59,6 +60,10 @@ QualityTask::QualityTrendGraph::QualityTrendGraph(std::string name, std::string
5960

6061
void QualityTask::QualityTrendGraph::update(uint64_t time, Quality q)
6162
{
63+
Clear();
64+
cd();
65+
66+
// set the position of the point based on the value of the quality flag
6267
float val = 0.5;
6368
if (q == Quality::Bad) {
6469
val = 1.5;
@@ -69,33 +74,21 @@ void QualityTask::QualityTrendGraph::update(uint64_t time, Quality q)
6974
if (q == Quality::Good) {
7075
val = 3.5;
7176
}
72-
// add new point both the the main graph and to the dummy one used for the axis
73-
mGraph->AddPoint(time, val);
74-
mGraphHist->AddPoint(time, 0);
7577

76-
Clear();
77-
cd();
78+
// add a new point to the graph
79+
mGraph->AddPoint(time, val);
7880

79-
// draw axis
80-
mGraphHist->Draw("A");
81-
82-
// configure and beautify axis
83-
auto hAxis = mGraphHist->GetHistogram();
84-
hAxis->SetTitle(GetTitle());
85-
hAxis->GetXaxis()->SetTimeDisplay(1);
86-
hAxis->GetXaxis()->SetNdivisions(505);
87-
hAxis->GetXaxis()->SetTimeOffset(0.0);
88-
hAxis->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M");
89-
hAxis->GetYaxis()->SetTitle("");
90-
hAxis->GetYaxis()->SetTickLength(0.0);
91-
hAxis->GetYaxis()->SetLabelSize(0.0);
92-
hAxis->GetYaxis()->SetNdivisions(3, kFALSE);
93-
hAxis->SetMinimum(0);
94-
hAxis->SetMaximum(4);
95-
hAxis->Draw("AXIS");
96-
97-
// draw main graph
98-
mGraph->Draw("PL,SAME");
81+
// draw the graph and format the axes
82+
mGraph->Draw("APL");
83+
mGraph->GetXaxis()->SetTimeDisplay(1);
84+
mGraph->GetXaxis()->SetNdivisions(505);
85+
mGraph->GetXaxis()->SetTimeOffset(0.0);
86+
mGraph->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M");
87+
mGraph->GetYaxis()->SetTickLength(0.0);
88+
mGraph->GetYaxis()->SetLabelSize(0.0);
89+
mGraph->GetYaxis()->SetNdivisions(3, kFALSE);
90+
mGraph->SetMinimum(0);
91+
mGraph->SetMaximum(4);
9992

10093
// draw labels for vertical axis
10194
for (auto& l : mLabels) {

0 commit comments

Comments
 (0)