12 {
13
16
17 std::cout << "start writting collections...\n";
18 auto& info = store.create<EventInfoCollection>("info");
19 auto& hits = store.create<ExampleHitCollection>("hits");
20 auto& clusters = store.create<ExampleClusterCollection>("clusters");
21 auto& hits_subset = store.create<ExampleHitCollection>("hits_subset");
22 hits_subset.setSubsetCollection(true);
23
24 writer.registerForWrite("clusters");
25
26 writer.registerForWrite("hits_subset");
27
28 unsigned nevents = 2;
29
30 for (unsigned i = 0; i < nevents; ++i) {
31
32 auto item1 = MutableEventInfo();
33 item1.Number(i);
34 info.push_back(item1);
35
36 auto& evtMD = store.getEventMetaData();
37 evtMD.setValue("UserEventWeight", (float)100. * i);
38 std::cout << " event number: " << i << std::endl;
39 evtMD.setValue("UserEventName", std::to_string(i));
40
41 auto hit1 = ExampleHit(0xbad, 0., 0., 0., 23. + i);
42 auto hit2 = ExampleHit(0xcaffee, 1., 0., 0., 12. + i);
43
44 hits.push_back(hit1);
45 hits.push_back(hit2);
46
47
48 auto cluster = MutableExampleCluster();
49 auto clu0 = MutableExampleCluster();
50 auto clu1 = MutableExampleCluster();
51
52 clu0.addHits(hit1);
53 clu0.energy(hit1.energy());
54 clu1.addHits(hit2);
55 clu1.energy(hit2.energy());
56 cluster.addHits(hit1);
57 cluster.addHits(hit2);
58 cluster.energy(hit1.energy() + hit2.energy());
59 cluster.addClusters(clu0);
60 cluster.addClusters(clu1);
61
62
63 hits_subset.push_back(hit1);
64 hits_subset.push_back(hit2);
65
66
67 clusters.push_back(clu0);
68 clusters.push_back(clu1);
69 clusters.push_back(cluster);
70
71 writer.writeEvent();
72 store.clearCollections();
73 }
74 writer.finish();
75}