Skip to content

Commit

Permalink
QC-1155 Allow for multiple graphs in one canvas in TrendingTask (#2338)
Browse files Browse the repository at this point in the history
* QC-1155 Allow for multiple graphs in one canvas in TrendingTask

This allows to draw more than one histogram or TGraph on one plot (canvas) in TrendingTask.
If more than one graph is used, a legend is automatically added to the plot.

The configuration scheme has been adapted accordingly to allow for multiple graphs.
The old way is still supported, but has been removed from documentation to encourage users to move to the new scheme.

There is also a possibility to select custom color palette expected, but we will need ROOT bump to 6.32 before this can be enabled.

Some refactoring is included as well.

* test both the new and old config format

* GraphAxisLabel -> GraphAxesLabels
  • Loading branch information
knopers8 authored Jun 17, 2024
1 parent 5c913d0 commit 71b0269
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 119 deletions.
11 changes: 8 additions & 3 deletions Framework/include/QualityControl/TrendingTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <TTree.h>

class TAxis;
class TCanvas;

namespace o2::quality_control::repository
{
Expand Down Expand Up @@ -54,9 +55,6 @@ class TrendingTask : public PostProcessingInterface
void update(Trigger, framework::ServiceRegistryRef) override;
void finalize(Trigger, framework::ServiceRegistryRef) override;

static void setUserAxisLabel(TAxis* xAxis, TAxis* yAxis, const std::string& graphAxisLabel);
static void setUserYAxisRange(TH1* hist, const std::string& graphYAxisRange);

private:
struct {
Long64_t runNumber = 0;
Expand All @@ -66,8 +64,15 @@ class TrendingTask : public PostProcessingInterface
}
} mMetaData;

static void setUserAxesLabels(TAxis* xAxis, TAxis* yAxis, const std::string& graphAxesLabels);
static void setUserYAxisRange(TH1* hist, const std::string& graphYAxisRange);
static void formatTimeXAxis(TH1* background);
static void formatRunNumberXAxis(TH1* background);
static std::string deduceGraphLegendOptions(const TrendingTaskConfig::Graph& graphConfig);

void trendValues(const Trigger& t, repository::DatabaseInterface&);
void generatePlots();
TCanvas* drawPlot(const TrendingTaskConfig::Plot& plotConfig);
bool canContinueTrend(TTree* tree);

TrendingTaskConfig mConfig;
Expand Down
16 changes: 12 additions & 4 deletions Framework/include/QualityControl/TrendingTaskConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ struct TrendingTaskConfig : PostProcessingConfig {
TrendingTaskConfig(std::string name, const boost::property_tree::ptree& config);
~TrendingTaskConfig() = default;

struct Plot {
std::string name;
// this corresponds to one TTree::Draw() call, i.e. one graph or histogram drawing
struct Graph {
std::string title;
std::string varexp;
std::string selection;
std::string option;
std::string graphErrors;
std::string option; // the list of possible options are documented in TGraphPainter and THistPainter
std::string errors;
};

// this corresponds to one canvas which can include multiple graphs
struct Plot {
std::string name;
std::string title;
std::string graphAxisLabel;
std::string graphYRange;
int colorPalette = 0;
std::vector<Graph> graphs;
};

struct DataSource {
Expand Down
54 changes: 37 additions & 17 deletions Framework/postprocessing.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,39 +81,59 @@
{
"name": "mean_of_histogram",
"title": "Mean trend of the example histogram",
"varexp": "example.mean:time",
"selection": "",
"option": "*L",
"graphAxisLabel": "Mean X:time"
"graphAxisLabel": "Mean X:time",
"graphYRange": "0:10000",
"graphs" : [
{
"title": "mean trend",
"varexp": "example.mean:time",
"selection": "",
"option": "*L PLC PMC"
}, {
"title": "mean trend + 1000",
"varexp": "example.mean + 1000:time",
"selection": "",
"option": "* PMC",
"graphErrors": "1:200"
}
]
},
{
"name": "histogram_of_means",
"title": "Distribution of mean values in the example histogram",
"varexp": "example.mean",
"selection": "",
"option": ""
"graphs" : [{
"varexp": "example.mean",
"selection": "",
"option": ""
}]
},
{
"name": "correlation_mean_stddev",
"title": "Correlation between the mean and stddev of the example histogram",
"varexp": "example.mean:example.stddev",
"selection": "",
"option": "*"
"graphs" : [{
"varexp": "example.mean:example.stddev",
"selection": "",
"option": "*"
}]
},
{
"name": "correlation_stddev_entries",
"title": "Correlation between the stddev and entries of the example histogram",
"varexp": "example.stddev:example.entries",
"selection": "",
"option": "*",
"graphAxisLabel": "stddev:entries"
"graphAxisLabel": "stddev:entries",
"graphs" : [{
"varexp": "example.stddev:example.entries",
"selection": "",
"option": "*"
}]
},
{
"name": "example_quality",
"title": "Trend of the example histogram's quality",
"varexp": "QcCheck.name:time",
"selection": "",
"option": "*"
"graphs" : [{
"varexp": "QcCheck.name:time",
"selection": "",
"option": "*"
}]
}
],
"initTrigger": [
Expand Down
Loading

0 comments on commit 71b0269

Please sign in to comment.