Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QC-1202 Improve naming of canvas elements created by TrendingTask #2364

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Framework/include/QualityControl/TrendingTaskConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct TrendingTaskConfig : PostProcessingConfig {

// this corresponds to one TTree::Draw() call, i.e. one graph or histogram drawing
struct Graph {
std::string name;
std::string title;
std::string varexp;
std::string selection;
Expand Down
2 changes: 2 additions & 0 deletions Framework/postprocessing.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@
"graphYRange": "0:10000",
"graphs" : [
{
"name": "mean_trend",
"title": "mean trend",
"varexp": "example.mean:time",
"selection": "",
"option": "*L PLC PMC"
}, {
"name": "mean_trend_1000",
"title": "mean trend + 1000",
"varexp": "example.mean + 1000:time",
"selection": "",
Expand Down
10 changes: 7 additions & 3 deletions Framework/src/TrendingTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,26 @@ TCanvas* TrendingTask::drawPlot(const TrendingTaskConfig::Plot& plotConfig)
mTrend->Draw(varexpWithErrors.c_str(), graphConfig.selection.c_str(), "goff");
graphErrors = new TGraphErrors(mTrend->GetSelectedRows(), mTrend->GetVal(1), mTrend->GetVal(0),
mTrend->GetVal(2), mTrend->GetVal(3));
graphErrors->SetName((graphConfig.name + "_errors").c_str());
graphErrors->SetTitle((graphConfig.title + " errors").c_str());
// We draw on the same plotConfig as the main graphConfig, but only error bars
graphErrors->Draw("SAME E");
}
}

if (auto graph = dynamic_cast<TGraph*>(c->FindObject("Graph"))) {
graph->SetName(graphConfig.name.c_str());
graph->SetTitle(graphConfig.title.c_str());
graph->SetName(graphConfig.title.c_str());
legend->AddEntry(graph, graphConfig.title.c_str(), deduceGraphLegendOptions(graphConfig).c_str());
}
if (auto htemp = dynamic_cast<TH1*>(c->FindObject("htemp"))) {
htemp->SetTitle(graphConfig.title.c_str());
htemp->SetName(graphConfig.title.c_str());
if (plotOrder == 1) {
htemp->SetName(graphConfig.name.c_str());
htemp->SetTitle(graphConfig.title.c_str());
legend->AddEntry(htemp, graphConfig.title.c_str(), "lpf");
} else {
htemp->SetName("background");
htemp->SetTitle("background");
// htemp was used by TTree::Draw only to draw axes and title, not to plot data, no need to add it to legend
}
// QCG doesn't empty the buffers before visualizing the plotConfig, nor does ROOT when saving the file,
Expand Down
8 changes: 6 additions & 2 deletions Framework/src/TrendingTaskConfig.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ TrendingTaskConfig::TrendingTaskConfig(std::string id, const boost::property_tre
std::vector<Graph> graphs;
if (const auto& graphsConfig = plotConfig.get_child_optional("graphs"); graphsConfig.has_value()) {
for (const auto& [_, graphConfig] : graphsConfig.value()) {
graphs.push_back({ graphConfig.get<std::string>("title", ""),
// first we use name of the graph, if absent, we use graph title, if absent, we use plot (object) name.
const auto& name = graphConfig.get<std::string>("name", graphConfig.get<std::string>("title", plotConfig.get<std::string>("name")));
graphs.push_back({ name,
graphConfig.get<std::string>("title", ""),
graphConfig.get<std::string>("varexp"),
graphConfig.get<std::string>("selection", ""),
graphConfig.get<std::string>("option", ""),
graphConfig.get<std::string>("graphErrors", "") });
}
} else {
graphs.push_back({ plotConfig.get<std::string>("title", ""),
graphs.push_back({ plotConfig.get<std::string>("name", ""),
plotConfig.get<std::string>("title", ""),
plotConfig.get<std::string>("varexp"),
plotConfig.get<std::string>("selection", ""),
plotConfig.get<std::string>("option", ""),
Expand Down
Loading