8#include <framework/pcore/MsgHandler.h>
11#include <TClonesArray.h>
15#include <gtest/gtest.h>
21 TEST(MsgHandlerTest, conversion)
24 TVector3 a(1.0, 2.0, 3.0);
25 handler.add(&a,
"vector");
26 TVector3 b(42.0, 7.0, -20.0);
27 handler.add(&b,
"vectorb");
28 TNamed c(
"abc",
"def");
29 handler.add(&c,
"named");
30 EvtMessage* msg = handler.encode_msg(MSG_EVENT);
34 vector<TObject*> objs;
37 ASSERT_EQ(3, objs.size());
38 ASSERT_EQ(3, names.size());
39 ASSERT_EQ(
"vector", names[0]);
40 ASSERT_EQ(
"vectorb", names[1]);
41 ASSERT_EQ(
"named", names[2]);
43 auto a2 =
dynamic_cast<TVector3*
>(objs[0]);
44 ASSERT_NE(a2,
nullptr);
45 EXPECT_TRUE(*a2 == a);
47 auto b2 =
dynamic_cast<TVector3*
>(objs[1]);
48 ASSERT_NE(b2,
nullptr);
49 EXPECT_TRUE(*b2 == b);
51 auto c2 =
dynamic_cast<TNamed*
>(objs[2]);
52 ASSERT_NE(c2,
nullptr);
53 EXPECT_TRUE(std::string(c2->GetName()) == c.GetName());
54 EXPECT_TRUE(std::string(c2->GetTitle()) == c.GetTitle());
59 TEST(MsgHandlerTest, compression)
61 TClonesArray longarray(
"Belle2::EventMetaData");
62 longarray.ExpandCreate(1000);
63 for (
int algo : {0, 1, 2}) {
64 for (
int level = 0; level < 10; ++level) {
66 handler.add(&longarray,
"mcparticles");
67 EvtMessage* msg = handler.encode_msg(MSG_EVENT);
70 vector<TObject*> objs;
73 ASSERT_EQ(1, objs.size());
74 ASSERT_EQ(1, names.size());
75 ASSERT_EQ(names[0],
"mcparticles");
76 for (
auto o : objs)
delete o;
Class to manage streamed object.
A class to encode/decode an EvtMessage.
virtual void decode_msg(EvtMessage *msg, std::vector< TObject * > &objlist, std::vector< std::string > &namelist)
Decode an EvtMessage into a vector list of objects with names.
Abstract base class for different kinds of events.