Skip to content

Commit 1a6216a

Browse files
authored
[QC-913] Support run number as TrendingType in SliceTrendingTask (#1606)
Add tree reader query for run number based on meta.runNumber and the following two trending types for trending as function of the run number - run - multigraphrun
1 parent d51876e commit 1a6216a

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Framework/src/SliceTrendingTask.cxx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void SliceTrendingTask::generatePlots()
172172
drawCanvasMO(c, plot.varexp, plot.name, plot.option, plot.graphErrors, mAxisDivision[varName]);
173173

174174
int NumberPlots = 1;
175-
if (plot.varexp.find(":time") != std::string::npos) { // we plot vs time, multiple plots on canvas possible
175+
if (plot.varexp.find(":time") != std::string::npos || plot.varexp.find(":run") != std::string::npos) { // we plot vs time, multiple plots on canvas possible
176176
NumberPlots = mNumberPads[varName];
177177
}
178178
for (int p = 0; p < NumberPlots; p++) {
@@ -243,9 +243,9 @@ void SliceTrendingTask::drawCanvasMO(TCanvas* thisCanvas, const std::string& var
243243
getTrendErrors(err, errXName, errYName);
244244

245245
// Divide the canvas into the correct number of pads.
246-
if (trendType == "time") {
246+
if (trendType == "time" || trendType == "run") {
247247
thisCanvas->DivideSquare(mNumberPads[varName]); // trending vs time: multiple plots per canvas possible
248-
} else if (trendType == "multigraphtime") {
248+
} else if (trendType == "multigraphtime" || trendType == "multigraphrun") {
249249
thisCanvas->Divide(2, 1);
250250
} else {
251251
thisCanvas->DivideSquare(1);
@@ -258,13 +258,14 @@ void SliceTrendingTask::drawCanvasMO(TCanvas* thisCanvas, const std::string& var
258258
// Setup the tree reader with the needed values.
259259
TTreeReader myReader(mTrend.get());
260260
TTreeReaderValue<UInt_t> retrieveTime(myReader, "time");
261+
TTreeReaderValue<Int_t> retrieveRun(myReader, "meta.runNumber");
261262
TTreeReaderValue<std::vector<SliceInfo>> dataRetrieveVector(myReader, varName.data());
262263

263264
const int nuPa = mNumberPads[varName];
264265
const int nEntries = mTrend->GetEntriesFast();
265266

266267
// Fill the graph(errors) to be published.
267-
if (trendType == "time") {
268+
if (trendType == "time" || trendType == "run") {
268269

269270
for (int p = 0; p < nuPa; p++) {
270271
thisCanvas->cd(p + 1);
@@ -273,7 +274,7 @@ void SliceTrendingTask::drawCanvasMO(TCanvas* thisCanvas, const std::string& var
273274
graphErrors = new TGraphErrors(nEntries);
274275

275276
while (myReader.Next()) {
276-
const double timeStamp = (double)(*retrieveTime);
277+
const double timeStamp = (trendType == "time") ? (double)(*retrieveTime) : (double)(*retrieveRun);
277278
const double dataPoint = (dataRetrieveVector->at(p)).retrieveValue(typeName);
278279
double errorX = 0.;
279280
double errorY = 0.;
@@ -301,7 +302,7 @@ void SliceTrendingTask::drawCanvasMO(TCanvas* thisCanvas, const std::string& var
301302
}
302303
}
303304
} // Trending vs time
304-
else if (trendType == "multigraphtime") {
305+
else if (trendType == "multigraphtime" || trendType == "multigraphrun") {
305306

306307
auto multigraph = new TMultiGraph();
307308
multigraph->SetName("MultiGraph");
@@ -311,7 +312,7 @@ void SliceTrendingTask::drawCanvasMO(TCanvas* thisCanvas, const std::string& var
311312
auto gr = new TGraphErrors(nEntries);
312313

313314
while (myReader.Next()) {
314-
const double timeStamp = (double)(*retrieveTime);
315+
const double timeStamp = (trendType == "multigraphtime") ? (double)(*retrieveTime) : (double)(*retrieveRun);
315316
const double dataPoint = (dataRetrieveVector->at(p)).retrieveValue(typeName);
316317
double errorX = 0.;
317318
double errorY = 0.;
@@ -518,7 +519,7 @@ void SliceTrendingTask::beautifyGraph(T& graph, const SliceTrendingTaskConfig::P
518519
graph->GetXaxis()->SetTimeOffset(0.0);
519520
graph->GetXaxis()->SetLabelOffset(0.02);
520521
graph->GetXaxis()->SetTimeFormat("#splitline{%d.%m.%y}{%H:%M}");
521-
} else if (plotconfig.varexp.find(":meta.runNumber") != std::string::npos) {
522+
} else if (plotconfig.varexp.find(":meta.runNumber") != std::string::npos || plotconfig.varexp.find(":run") != std::string::npos || plotconfig.varexp.find(":multigraphrun") != std::string::npos) {
522523
graph->GetXaxis()->SetNoExponent(true);
523524
}
524525
}

0 commit comments

Comments
 (0)