Skip to content

Commit ffe7e55

Browse files
authored
Mergers: actually collect only mergeable objects belonging to TCanvas (#15555)
We were seeing warnings like below when merging certain TCanvases: ``` W 11 Object 'title' with type 'TPaveText' is not one of the mergeable types, skipping W 11 Object 'TPave' with type 'TLegend' is not one of the mergeable types, skipping W 11 Object 'TFrame' with type 'TFrame' is not one of the mergeable types, skipping ``` It is perfectly OK to have some TPaveText in a canvas and expect to have just the histogram merged, but the text should remain as it was, so there is no reason to produce warnings. The change ensures that collectUnderlyingObject actually collects just the mergeable objects from TCanvas, as promised in the documentation. Fixes QC-1344.
1 parent 5d0a12e commit ffe7e55

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Utilities/Mergers/src/MergerAlgorithm.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "Mergers/MergeInterface.h"
2020
#include "Mergers/ObjectStore.h"
21+
#include "Mergers/Mergeable.h"
2122
#include "Framework/Logger.h"
2223

2324
#include <TEfficiency.h>
@@ -63,7 +64,7 @@ auto collectUnderlyingObjects(TCanvas* canvas) -> std::vector<TObject*>
6364
auto* primitive = primitives->At(i);
6465
if (auto* primitivePad = dynamic_cast<TPad*>(primitive)) {
6566
collectFromTPad(primitivePad, objects, collectFromTPad);
66-
} else {
67+
} else if (isMergeable(primitive)) {
6768
objects.push_back(primitive);
6869
}
6970
}

Utilities/Mergers/test/test_Algorithm.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Mergers/MergerAlgorithm.h"
2727
#include "Mergers/CustomMergeableTObject.h"
2828
#include "Mergers/CustomMergeableObject.h"
29+
#include "Mergers/Mergeable.h"
2930
#include "Mergers/ObjectStore.h"
3031

3132
#include <TObjArray.h>
@@ -40,6 +41,7 @@
4041
#include <TGraph.h>
4142
#include <TProfile.h>
4243
#include <TCanvas.h>
44+
#include <TPaveText.h>
4345

4446
// using namespace o2::framework;
4547
using namespace o2::mergers;
@@ -329,6 +331,12 @@ TCanvas* createCanvas(std::string name, std::string title, std::vector<std::shar
329331
for (size_t i = 1; const auto& hist : histograms) {
330332
canvas->cd(i);
331333
hist->Draw();
334+
335+
// non-mergeable TPaveText
336+
TPaveText* pt = new TPaveText(.05, .1, .95, .8);
337+
pt->AddText("test");
338+
pt->Draw();
339+
332340
++i;
333341
}
334342
return canvas;
@@ -345,7 +353,7 @@ auto collectUnderlyingObjects(TCanvas* canvas) -> std::vector<TObject*>
345353
auto* primitive = primitives->At(i);
346354
if (auto* primitivePad = dynamic_cast<TPad*>(primitive)) {
347355
collectFromTPad(primitivePad, objects, collectFromTPad);
348-
} else {
356+
} else if (isMergeable(primitive)) {
349357
objects.push_back(primitive);
350358
}
351359
}

0 commit comments

Comments
 (0)