Project
Loading...
Searching...
No Matches
test_Algorithm.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#include <gsl/span>
18#include <memory>
19#include <stdexcept>
20#define BOOST_TEST_MODULE Test Utilities MergerAlgorithm
21#define BOOST_TEST_MAIN
22#define BOOST_TEST_DYN_LINK
23
24#include <boost/test/unit_test.hpp>
25
29#include "Mergers/Mergeable.h"
30#include "Mergers/ObjectStore.h"
31
32#include <TObjArray.h>
33#include <TObjString.h>
34#include <TH1.h>
35#include <TH2.h>
36#include <TH3.h>
37#include <THn.h>
38#include <TTree.h>
39#include <THnSparse.h>
40#include <TF1.h>
41#include <TGraph.h>
42#include <TProfile.h>
43#include <TCanvas.h>
44#include <TPaveText.h>
45
46// using namespace o2::framework;
47using namespace o2::mergers;
48
49constexpr size_t bins = 10;
50constexpr size_t min = 0;
51constexpr size_t max = 10;
52
53BOOST_AUTO_TEST_CASE(MergerEmptyObjects)
54{
55 {
56 TH1I* target = nullptr;
57 TH1I* other = new TH1I("obj1", "obj1", bins, min, max);
58 BOOST_CHECK_THROW(algorithm::merge(target, other), std::runtime_error);
59 delete other;
60 }
61 {
62 TH1I* target = new TH1I("obj1", "obj1", bins, min, max);
63 TH1I* other = nullptr;
64 BOOST_CHECK_THROW(algorithm::merge(target, other), std::runtime_error);
65 delete target;
66 }
67}
68
69BOOST_AUTO_TEST_CASE(MergerNotSupportedTObject)
70{
71 TObjString* target = new TObjString("foo");
72 TObjString* other = new TObjString("bar");
74 BOOST_CHECK(target->GetString() == "foo");
75 delete target;
76 delete other;
77}
78
79BOOST_AUTO_TEST_CASE(MergerTheSameObject)
80{
81 TH1I* object = new TH1I("obj1", "obj1", bins, min, max);
82 BOOST_CHECK_THROW(algorithm::merge(object, object), std::runtime_error);
83 delete object;
84}
85
86BOOST_AUTO_TEST_CASE(MergerSingularObjects)
87{
88 {
89 TH1I* target = new TH1I("obj1", "obj1", bins, min, max);
90 target->Fill(5);
91 TH1I* other = new TH1I("obj2", "obj2", bins, min, max);
92 other->Fill(2);
93 other->Fill(2);
94
96 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(2)), 2);
97 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(5)), 1);
98
99 delete other;
100 delete target;
101 }
102 {
103 // mismatching axes - merging should fail.
104 // we should run again merging with gDebug enabled to see more logs from ROOT (tested only manually by visual inspection of logs)
105 TH1I* target = new TH1I("obj1", "obj1", bins, min, max);
106 target->Fill(5);
107 TH1I* other = new TH1I("obj2", "obj2", bins, max, max + 10);
108 other->Fill(2);
109 other->Fill(2);
110
112 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(2)), 0);
113 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(5)), 1);
114
115 delete other;
116 delete target;
117 }
118 {
119 TH2I* target = new TH2I("obj1", "obj1", bins, min, max, bins, min, max);
120 target->Fill(5, 5);
121 TH2I* other = new TH2I("obj2", "obj2", bins, min, max, bins, min, max);
122 other->Fill(2, 2);
123 other->Fill(2, 2);
124
126 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(2, 2)), 2);
127 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(5, 5)), 1);
128
129 delete other;
130 delete target;
131 }
132 {
133 TH3I* target = new TH3I("obj1", "obj1", bins, min, max, bins, min, max, bins, min, max);
134 target->Fill(5, 5, 5);
135 TH3I* other = new TH3I("obj2", "obj2", bins, min, max, bins, min, max, bins, min, max);
136 other->Fill(2, 2, 2);
137 other->Fill(2, 2, 2);
138
140 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(2, 2, 2)), 2);
141 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(5, 5, 5)), 1);
142
143 delete other;
144 delete target;
145 }
146 {
147 const size_t dim = 5;
148 const Int_t binsDims[dim] = {bins, bins, bins, bins, bins};
149 const Double_t mins[dim] = {min, min, min, min, min};
150 const Double_t maxs[dim] = {max, max, max, max, max};
151
152 THnI* target = new THnI("obj1", "obj1", dim, binsDims, mins, maxs);
153 target->FillBin(5, 1);
154 THnI* other = new THnI("obj2", "obj2", dim, binsDims, mins, maxs);
155 other->FillBin(2, 1);
156 other->FillBin(2, 1);
157
159 BOOST_CHECK_EQUAL(target->GetBinContent(2), 2);
160 BOOST_CHECK_EQUAL(target->GetBinContent(5), 1);
161
162 delete other;
163 delete target;
164 }
165 {
166 const size_t dim = 5;
167 const Int_t binsDims[dim] = {bins, bins, bins, bins, bins};
168 const Double_t mins[dim] = {min, min, min, min, min};
169 const Double_t maxs[dim] = {max, max, max, max, max};
170
171 Double_t entry[dim] = {5, 5, 5, 5, 5};
172
173 THnSparseI* target = new THnSparseI("obj1", "obj1", dim, binsDims, mins, maxs);
174 target->Fill(entry);
175 THnSparseI* other = new THnSparseI("obj2", "obj2", dim, binsDims, mins, maxs);
176 entry[0] = entry[1] = entry[2] = entry[3] = entry[4] = 2;
177 other->Fill(entry);
178 other->Fill(entry);
179
181 BOOST_CHECK_EQUAL(target->GetBinContent(0, nullptr), 1);
182 BOOST_CHECK_EQUAL(target->GetBinContent(1), 2);
183
184 delete other;
185 delete target;
186 }
187 {
188 struct format1 {
189 Int_t a;
190 Double_t b;
191 } branch1;
192 ULong64_t branch2;
193
194 auto createTree = [&](std::string name) -> TTree* {
195 TTree* tree = new TTree();
196 tree->SetName(name.c_str());
197 tree->Branch("b1", &branch1, "a/I:b/L:c/F:d/D");
198 tree->Branch("b2", &branch2);
199 return tree;
200 };
201
202 TTree* target = createTree("obj1");
203 TTree* other = createTree("obj2");
204
205 branch1.a = 1;
206 branch1.b = 2;
207 branch2 = 3;
208
209 target->Fill();
210 other->Fill();
211 other->Fill();
212
214 BOOST_CHECK_EQUAL(target->GetEntries(), 3);
215
216 delete other;
217 delete target;
218 }
219 {
220 constexpr Int_t points = 5;
221 Double_t x1[] = {0, 1, 2, 3, 4};
222 Double_t y1[] = {0, 1, 2, 3, 4};
223 Double_t x2[] = {5, 6, 7, 8, 9};
224 Double_t y2[] = {5, 6, 7, 8, 9};
225
226 TGraph* target = new TGraph(points, x1, y1);
227 TGraph* other = new TGraph(points, x2, y2);
228
230 BOOST_CHECK_EQUAL(target->GetN(), 2 * points);
231
232 delete other;
233 delete target;
234 }
235 {
236 auto target = new TProfile("hprof1", "hprof1", bins, min, max, min, max);
237 target->Fill(2, 2, 1);
238 auto other = new TProfile("hprof2", "hprof2", bins, min, max, min, max);
239 other->Fill(5, 5, 1);
240
242 BOOST_CHECK_EQUAL(target->GetEntries(), 2);
243 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(0)), 0);
244 BOOST_CHECK_EQUAL(target->GetBinContent(target->FindBin(1)), 0);
245 BOOST_CHECK_CLOSE(target->GetBinContent(target->FindBin(2)), 2, 0.001);
246 BOOST_CHECK_CLOSE(target->GetBinContent(target->FindBin(5)), 5, 0.001);
247
248 delete other;
249 delete target;
250 }
251 {
252 auto* target = new CustomMergeableTObject("obj1", 123);
253 auto* other = new CustomMergeableTObject("obj2", 321);
254
256 BOOST_CHECK_EQUAL(target->getSecret(), 444);
257
258 delete other;
259 delete target;
260 }
261 {
262 auto* target = new CustomMergeableObject(123);
263 auto* other = new CustomMergeableObject(321);
264
266 BOOST_CHECK_EQUAL(target->getSecret(), 444);
267
268 delete other;
269 delete target;
270 }
271}
272
273BOOST_AUTO_TEST_CASE(MergerCollection)
274{
275 // Setting up the target. Histo 1D + Custom stored in TObjArray.
276 TObjArray* target = new TObjArray();
277 target->SetOwner(true);
278
279 TH1I* targetTH1I = new TH1I("histo 1d", "histo 1d", bins, min, max);
280 targetTH1I->Fill(5);
281 target->Add(targetTH1I);
282
283 CustomMergeableTObject* targetCustom = new CustomMergeableTObject("custom", 9000);
284 target->Add(targetCustom);
285
286 // Setting up the other. Histo 1D + Histo 2D + Custom stored in TList.
287 TList* other = new TList();
288 other->SetOwner(true);
289
290 TH1I* otherTH1I = new TH1I("histo 1d", "histo 1d", bins, min, max);
291 otherTH1I->Fill(2);
292 otherTH1I->Fill(2);
293 other->Add(otherTH1I);
294
295 TH2I* otherTH2I = new TH2I("histo 2d", "histo 2d", bins, min, max, bins, min, max);
296 otherTH2I->Fill(5, 5);
297 other->Add(otherTH2I);
298
299 CustomMergeableTObject* otherCustom = new CustomMergeableTObject("custom", 1);
300 other->Add(otherCustom);
301
302 // Merge
304
305 // Make sure that deleting the object present only in `other` doesn't delete it in the `target`
306 delete other;
307
308 // Checks
309 BOOST_REQUIRE_EQUAL(target->GetEntries(), 3);
310
311 TH1I* resultTH1I = dynamic_cast<TH1I*>(target->FindObject("histo 1d"));
312 BOOST_REQUIRE(resultTH1I != nullptr);
313 BOOST_CHECK_EQUAL(resultTH1I->GetBinContent(resultTH1I->FindBin(2)), 2);
314 BOOST_CHECK_EQUAL(resultTH1I->GetBinContent(resultTH1I->FindBin(5)), 1);
315
316 TH2I* resultTH2I = dynamic_cast<TH2I*>(target->FindObject("histo 2d"));
317 BOOST_REQUIRE(resultTH2I != nullptr);
318 BOOST_CHECK_EQUAL(resultTH2I->GetBinContent(resultTH2I->FindBin(5, 5)), 1);
319
320 auto* resultCustom = dynamic_cast<CustomMergeableTObject*>(target->FindObject("custom"));
321 BOOST_REQUIRE(resultCustom != nullptr);
322 BOOST_CHECK_EQUAL(resultCustom->getSecret(), 9001);
323
324 delete target;
325}
326
327TCanvas* createCanvas(std::string name, std::string title, std::vector<std::shared_ptr<TH1I>>& histograms)
328{
329 auto canvas = new TCanvas(name.c_str(), title.c_str(), 100, 100);
330 canvas->Divide(histograms.size(), 1);
331 for (size_t i = 1; const auto& hist : histograms) {
332 canvas->cd(i);
333 hist->Draw();
334
335 // non-mergeable TPaveText
336 TPaveText* pt = new TPaveText(.05, .1, .95, .8);
337 pt->AddText("test");
338 pt->Draw();
339
340 ++i;
341 }
342 return canvas;
343}
344
345auto collectUnderlyingObjects(TCanvas* canvas) -> std::vector<TObject*>
346{
347 auto collectFromTPad = [](TPad* pad, std::vector<TObject*>& objects, const auto& collectFromTPad) {
348 if (!pad) {
349 return;
350 }
351 auto* primitives = pad->GetListOfPrimitives();
352 for (int i = 0; i < primitives->GetSize(); ++i) {
353 auto* primitive = primitives->At(i);
354 if (auto* primitivePad = dynamic_cast<TPad*>(primitive)) {
355 collectFromTPad(primitivePad, objects, collectFromTPad);
356 } else if (isMergeable(primitive)) {
357 objects.push_back(primitive);
358 }
359 }
360 };
361
362 std::vector<TObject*> collectedObjects;
363 collectFromTPad(canvas, collectedObjects, collectFromTPad);
364
365 return collectedObjects;
366}
367
369{
370 // working example
371 {
372 std::vector<std::shared_ptr<TH1I>> histsC1{
373 std::make_shared<TH1I>("th1", "obj1", bins, min, max),
374 std::make_shared<TH1I>("th2", "obj2", bins, min, max),
375 };
376 histsC1[0]->Fill(5);
377 histsC1[1]->Fill(2);
378 BOOST_CHECK_EQUAL(histsC1[0]->GetBinContent(histsC1[0]->FindBin(5)), 1);
379 BOOST_CHECK_EQUAL(histsC1[1]->GetBinContent(histsC1[1]->FindBin(2)), 1);
380
381 std::vector<std::shared_ptr<TH1I>> histsC2{
382 std::make_shared<TH1I>("th1", "obj1", bins, min, max),
383 std::make_shared<TH1I>("th2", "obj2", bins, min, max),
384 };
385
386 histsC2[0]->Fill(5);
387 histsC2[1]->Fill(2);
388 BOOST_CHECK_EQUAL(histsC2[0]->GetBinContent(histsC2[0]->FindBin(5)), 1);
389 BOOST_CHECK_EQUAL(histsC2[1]->GetBinContent(histsC2[1]->FindBin(2)), 1);
390
391 auto targetCanvas = createCanvas("c1", "test title 1", histsC1);
392 auto otherCanvas = createCanvas("c2", "test title 2", histsC2);
393
394 algorithm::merge(targetCanvas, otherCanvas);
395
396 auto targetObjects = collectUnderlyingObjects(targetCanvas);
397
398 BOOST_CHECK_EQUAL(targetObjects.size(), 2);
399 for (const auto& object : targetObjects) {
400 auto th = static_cast<TH1*>(object);
401 if (std::string(th->GetName()) == "th1") {
402 BOOST_CHECK_EQUAL(th->GetBinContent(th->FindBin(5)), 2);
403 }
404 if (std::string(th->GetName()) == "th2") {
405 BOOST_CHECK_EQUAL(th->GetBinContent(th->FindBin(2)), 2);
406 }
407 }
408 }
409
410 // throw because we try to merge canvases with different number of underlying items
411 {
412 std::vector<std::shared_ptr<TH1I>> histsC1{
413 std::make_shared<TH1I>("th1", "obj1", bins, min, max),
414 std::make_shared<TH1I>("th2", "obj2", bins, min, max),
415 };
416
417 std::vector<std::shared_ptr<TH1I>> histsC2{
418 std::make_shared<TH1I>("th1", "obj1", bins, min, max),
419 };
420
421 auto targetCanvas = createCanvas("c1", "test title 1", histsC1);
422 auto otherCanvas = createCanvas("c2", "test title 2", histsC2);
423
424 BOOST_CHECK_THROW(algorithm::merge(targetCanvas, otherCanvas), std::runtime_error);
425 }
426
427 // throw because we try to merge canvases with different underlying items
428 {
429 std::vector<std::shared_ptr<TH1I>> histsC1{
430 std::make_shared<TH1I>("th1", "obj1", bins, min, max),
431 };
432
433 std::vector<std::shared_ptr<TH1I>> histsC2{
434 std::make_shared<TH1I>("th2", "obj2", bins, min, max),
435 };
436
437 auto targetCanvas = createCanvas("c1", "test title 1", histsC1);
438 auto otherCanvas = createCanvas("c2", "test title 2", histsC2);
439
440 BOOST_CHECK_THROW(algorithm::merge(targetCanvas, otherCanvas), std::runtime_error);
441 }
442}
443
445{
446 TObjArray* main = new TObjArray();
447 main->SetOwner(false);
448
449 TH1I* histo1D = new TH1I("histo 1d", "histo 1d", bins, min, max);
450 histo1D->Fill(5);
451 main->Add(histo1D);
452
453 CustomMergeableTObject* custom = new CustomMergeableTObject("custom", 9000);
454 main->Add(custom);
455
456 // Setting up the other. Histo 1D + Histo 2D + Custom stored in TList.
457 auto* collectionInside = new TList();
458 collectionInside->SetOwner(true);
459
460 TH1I* histo1DinsideCollection = new TH1I("histo 1d", "histo 1d", bins, min, max);
461 histo1DinsideCollection->Fill(2);
462 collectionInside->Add(histo1DinsideCollection);
463
464 TH2I* histo2DinsideCollection = new TH2I("histo 2d", "histo 2d", bins, min, max, bins, min, max);
465 histo2DinsideCollection->Fill(5, 5);
466 collectionInside->Add(histo2DinsideCollection);
467
468 main->Add(collectionInside);
469
470 // I am afraid we can't check more than that.
472}
473
475{
476 TH1F* target = new TH1F("histo 1", "histo 1", bins, min, max);
477 target->SetBit(TH1::kIsAverage);
478 target->Fill(5);
479
480 TH1F* other = new TH1F("histo 2", "histo 2", bins, min, max);
481 other->SetBit(TH1::kIsAverage);
482 other->Fill(5);
483
485 BOOST_CHECK_CLOSE(target->GetBinContent(other->FindBin(5)), 1.0, 0.001);
486
487 delete target;
488 delete other;
489}
490
491BOOST_AUTO_TEST_SUITE(VectorOfHistos)
492
493gsl::span<float> to_span(std::shared_ptr<TH1F>& histo)
494{
495 return {histo->GetArray(), static_cast<uint>(histo->GetSize())};
496}
497
498template <typename T, std::size_t N>
499gsl::span<T, N> to_array(T (&&arr)[N])
500{
501 return arr;
502}
503
504BOOST_AUTO_TEST_CASE(SameLength, *boost::unit_test::tolerance(0.001))
505{
506 auto target1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
507 target1_1->Fill(5);
508 target1_1->Fill(5);
509
510 auto target1_2 = std::make_shared<TH1F>("histo 1-2", "histo 1-2", bins, min, max);
511 target1_2->Fill(5);
512 target1_2->Fill(5);
513 target1_2->Fill(5);
514 target1_2->Fill(5);
515
517
518 auto other1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
519 other1_1->Fill(5);
520
521 auto other1_2 = std::make_shared<TH1F>("histo 1-2", "histo 1-2", bins, min, max);
522 other1_2->Fill(5);
523 other1_2->Fill(5);
524
526
527 BOOST_TEST(target.size() == 2);
528 BOOST_TEST(other.size() == 2);
529
530 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
531 BOOST_TEST(to_span(target1_2) == to_array({0., 0., 0., 0., 0., 0., 4., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
532 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
533 BOOST_TEST(to_span(other1_2) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
534
536
537 BOOST_TEST(target.size() == 2);
538 BOOST_TEST(other.size() == 2);
539
540 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
541 BOOST_TEST(to_span(target1_2) == to_array({0., 0., 0., 0., 0., 0., 6., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
542 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
543 BOOST_TEST(to_span(other1_2) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
544}
545
546BOOST_AUTO_TEST_CASE(TargetLonger, *boost::unit_test::tolerance(0.001))
547{
548 auto target1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
549 target1_1->Fill(5);
550 target1_1->Fill(5);
551
552 auto target1_2 = std::make_shared<TH1F>("histo 1-2", "histo 1-2", bins, min, max);
553 target1_2->Fill(5);
554 target1_2->Fill(5);
555 target1_2->Fill(5);
556 target1_2->Fill(5);
557
559
560 auto other1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
561 other1_1->Fill(5);
562
564
565 BOOST_TEST(target.size() == 2);
566 BOOST_TEST(other.size() == 1);
567
568 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
569 BOOST_TEST(to_span(target1_2) == to_array({0., 0., 0., 0., 0., 0., 4., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
570 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
571
573
574 BOOST_TEST(target.size() == 2);
575 BOOST_TEST(other.size() == 1);
576
577 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
578 BOOST_TEST(to_span(target1_2) == to_array({0., 0., 0., 0., 0., 0., 4., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
579 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
580}
581
582BOOST_AUTO_TEST_CASE(OtherLonger, *boost::unit_test::tolerance(0.001))
583{
584 auto target1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
585 target1_1->Fill(5);
586 target1_1->Fill(5);
587
588 VectorOfTObjectPtrs target{target1_1};
589
590 auto other1_1 = std::make_shared<TH1F>("histo 1-1", "histo 1-1", bins, min, max);
591 other1_1->Fill(5);
592
593 auto other1_2 = std::make_shared<TH1F>("histo 1-2", "histo 1-2", bins, min, max);
594 other1_2->Fill(5);
595 other1_2->Fill(5);
596
598
599 BOOST_TEST(target.size() == 1);
600 BOOST_TEST(other.size() == 2);
601
602 BOOST_TEST(std::string_view{target[0]->GetName()} == "histo 1-1");
603
604 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
605 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
606 BOOST_TEST(to_span(other1_2) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
607
609
610 BOOST_TEST(target.size() == 2);
611 BOOST_TEST(other.size() == 2);
612
613 BOOST_TEST(std::string_view{target[0]->GetName()} == "histo 1-1");
614 BOOST_TEST(std::string_view{target[1]->GetName()} == "histo 1-2");
615
616 BOOST_TEST(to_span(target1_1) == to_array({0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
617 BOOST_TEST(to_span(other1_1) == to_array({0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
618 BOOST_TEST(to_span(other1_2) == to_array({0., 0., 0., 0., 0., 0., 2., 0., 0., 0., 0., 0.}), boost::test_tools::per_element());
619}
620
621BOOST_AUTO_TEST_SUITE_END()
std::vector< std::string > objects
An example of overriding O2 Mergers merging interface, v0.1.
An example of a custom TObject inheriting MergeInterface.
int32_t i
Mergeable concept.
Algorithms for merging objects.
Definition of ObjectStore for Mergers, v0.1.
GLuint entry
Definition glcorearb.h:5735
GLuint GLfloat GLfloat GLfloat GLfloat y1
Definition glcorearb.h:5034
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLenum target
Definition glcorearb.h:1641
GLuint object
Definition glcorearb.h:4041
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
void merge(TObject *const target, TObject *const other)
A function which merges TObjects.
void deleteTCollections(TObject *obj)
bool isMergeable(TObject *obj)
Definition Mergeable.cxx:26
std::vector< TObjectPtr > VectorOfTObjectPtrs
Definition ObjectStore.h:43
gsl::span< T, N > to_array(T(&&arr)[N])
gsl::span< float > to_span(std::shared_ptr< TH1F > &histo)
BOOST_AUTO_TEST_CASE(MergerEmptyObjects)
auto collectUnderlyingObjects(TCanvas *canvas) -> std::vector< TObject * >
auto target1_2
VectorOfTObjectPtrs target
constexpr size_t min
TCanvas * createCanvas(std::string name, std::string title, std::vector< std::shared_ptr< TH1I > > &histograms)
constexpr size_t bins
constexpr size_t max
auto other1_1
BOOST_CHECK_NO_THROW(algorithm::merge(target, other))
auto other1_2
VectorOfTObjectPtrs other
BOOST_TEST(target.size()==2)
#define main
BOOST_CHECK(tree)
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())