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