File indexing completed on 2025-01-18 10:17:19
0001
0002
0003
0004 #include <podio/CollectionBase.h>
0005 #include <podio/Frame.h>
0006
0007 #include "PodioDatamodel/EventInfoCollection.h"
0008 #include "PodioDatamodel/ExampleHitCollection.h"
0009 #include <podio/podioVersion.h>
0010
0011 #if podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR < 99
0012 #include <podio/ROOTFrameWriter.h>
0013 #include <podio/ROOTFrameReader.h>
0014 namespace podio {
0015 using ROOTWriter = podio::ROOTFrameWriter;
0016 using ROOTReader = podio::ROOTFrameReader;
0017 }
0018 #else
0019 #include <podio/ROOTWriter.h>
0020 #include <podio/ROOTReader.h>
0021 #endif
0022
0023 #include <JANA/JApplication.h>
0024 #include <JANA/JFactoryGenerator.h>
0025
0026 #include "PodioExampleProcessor.h"
0027 #include "ExampleClusterFactory.h"
0028 #include "ExampleMultifactory.h"
0029
0030 #include <iostream>
0031 #include <cassert>
0032
0033
0034 void create_hits_file() {
0035
0036 MutableEventInfo eventinfo1(7, 0, 22);
0037 EventInfoCollection eventinfos1;
0038 eventinfos1.push_back(eventinfo1);
0039
0040 ExampleHitCollection hits1;
0041 hits1.push_back(MutableExampleHit(22, -1, -1, 0, 100, 0));
0042 hits1.push_back(MutableExampleHit(49, 1, 1, 0, 15.5, 0));
0043 hits1.push_back(MutableExampleHit(47, 1, 2, 0, 0.5, 0));
0044 hits1.push_back(MutableExampleHit(42, 2, 1, 0, 4.0, 0));
0045
0046 podio::Frame event1;
0047 event1.put(std::move(hits1), "hits");
0048 event1.put(std::move(eventinfos1), "eventinfos");
0049
0050 podio::ROOTWriter writer("hits.root");
0051 writer.writeFrame(event1, "events");
0052
0053 MutableEventInfo eventinfo2(8, 0, 22);
0054 EventInfoCollection eventinfos2;
0055 eventinfos2.push_back(eventinfo2);
0056
0057 ExampleHitCollection hits2;
0058 hits2.push_back(MutableExampleHit(42, 5, -5, 5, 7.6, 0));
0059 hits2.push_back(MutableExampleHit(618, -3, -5, 1, 99.9, 0));
0060 hits2.push_back(MutableExampleHit(27, -10, 10, 10, 22.2, 0));
0061 hits2.push_back(MutableExampleHit(28, -9, 11, 10, 7.8, 0));
0062
0063 podio::Frame event2;
0064 event2.put(std::move(hits2), "hits");
0065 event2.put(std::move(eventinfos2), "eventinfos");
0066
0067 writer.writeFrame(event2, "events");
0068 writer.finish();
0069
0070 }
0071
0072 void verify_clusters_file() {
0073 podio::ROOTReader reader;
0074 reader.openFile("podio_output.root");
0075 auto event0 = podio::Frame(reader.readEntry("events", 0));
0076
0077 std::cout << "Event 0: Expected 2 clusters, got " << event0.get("clusters")->size() << std::endl;
0078 assert(event0.get("clusters")->size() == 2);
0079
0080 auto event1 = podio::Frame(reader.readEntry("events", 1));
0081 std::cout << "Event 1: Expected 3 clusters, got " << event1.get("clusters")->size() << std::endl;
0082 assert(event1.get("clusters")->size() == 3);
0083 }
0084
0085
0086 int main() {
0087
0088 create_hits_file();
0089
0090 JApplication app;
0091 app.Add(new PodioExampleProcessor);
0092 app.Add(new JFactoryGeneratorT<ExampleClusterFactory>());
0093 app.Add(new JFactoryGeneratorT<ExampleMultifactory>());
0094 app.Add("hits.root");
0095 app.AddPlugin("PodioFileReader");
0096 app.AddPlugin("PodioFileWriter");
0097 app.SetParameterValue("podio:output_file", "podio_output.root");
0098 app.SetParameterValue("podio:output_collections", "hits_filtered,clusters_from_hits_filtered,clusters_filtered");
0099 app.Run();
0100
0101 verify_clusters_file();
0102
0103 return app.GetExitCode();
0104 }
0105