14#define BOOST_TEST_MODULE Test Utilities MergerObjectStore
15#define BOOST_TEST_MAIN
16#define BOOST_TEST_DYN_LINK
25#include <boost/test/unit_test.hpp>
33BOOST_AUTO_TEST_SUITE(TestObjectExtraction)
35template <
typename TypeToDataRef>
42 ref.payload = tm->Buffer();
46 dh->payloadSize = tm->BufferSize();
47 ref.header =
reinterpret_cast<char const*
>(dh->data());
58 BOOST_REQUIRE(std::holds_alternative<MergeInterfacePtr>(objStore));
60 auto objExtractedCustom =
dynamic_cast<CustomMergeableTObject*
>(std::get<MergeInterfacePtr>(objStore).get());
61 BOOST_REQUIRE(objExtractedCustom !=
nullptr);
74 BOOST_REQUIRE(std::holds_alternative<MergeInterfacePtr>(objStore));
76 auto objExtractedCustom =
dynamic_cast<CustomMergeableObject*
>(std::get<MergeInterfacePtr>(objStore).get());
77 BOOST_REQUIRE(objExtractedCustom !=
nullptr);
86 TH1I* obj =
new TH1I(
"histo",
"histo", 100, 0, 100);
92 BOOST_CHECK(std::holds_alternative<TObjectPtr>(objStore));
94 auto objExtractedHisto =
dynamic_cast<TH1I*
>(std::get<TObjectPtr>(objStore).get());
95 BOOST_REQUIRE(objExtractedHisto !=
nullptr);
105 TObjArray*
array =
new TObjArray();
106 array->SetOwner(
true);
108 TH1I* histo =
new TH1I(
"histo 1d",
"histo 1d", 100, 0, 100);
114 BOOST_CHECK(std::holds_alternative<TObjectPtr>(objStore));
116 auto objExtractedArray =
dynamic_cast<TObjArray*
>(std::get<TObjectPtr>(objStore).get());
117 BOOST_REQUIRE(objExtractedArray !=
nullptr);
127 auto histo = std::make_shared<TH1F>(
"histo 1d",
"histo 1d", 100, 0, 100);
135 BOOST_CHECK(std::holds_alternative<VectorOfTObjectPtrs>(objStore));
136 auto extractedVector = std::get<VectorOfTObjectPtrs>(objStore);
138 auto* extractedHisto =
dynamic_cast<TH1F*
>(extractedVector[0].get());
139 BOOST_CHECK(gsl::span(histo->GetArray(), histo->GetSize()) == gsl::span(extractedHisto->GetArray(), extractedHisto->GetSize()));
142BOOST_AUTO_TEST_SUITE_END()
An example of overriding O2 Mergers merging interface, v0.1.
An example of a custom TObject inheriting MergeInterface.
Definition of ObjectStore for Mergers, v0.1.
Defining PrimaryVertex explicitly as messageable.
ObjectStore extractObjectFrom(const framework::DataRef &ref)
Takes a DataRef, deserializes it (if type is supported) and puts into an ObjectStore.
VectorOfRawTObjects toRawObserverPointers(const VectorOfTObjectPtrs &)
Helper function that converts vector of smart pointers to the vector of raw pointers that is serializ...
std::vector< TObjectPtr > VectorOfTObjectPtrs
BOOST_AUTO_TEST_CASE(MergeableObject)
DataRef makeDataRef(TypeToDataRef *obj)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())