PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
read_and_write.cpp
Go to the documentation of this file.
1#include "read_test.h"
2// podio specific includes
3#include "podio/EventStore.h"
4#include "podio/ROOTReader.h"
5#include "podio/ROOTWriter.h"
6
7int main() {
8 auto reader = podio::ROOTReader();
9 auto store = podio::EventStore();
10 reader.openFile("example.root");
11 store.setReader(&reader);
12
13 // test writing a subset of the event to a new file
14 auto writer = podio::ROOTWriter("example_copy.root", &store);
15 writer.registerForWrite("info");
16 writer.registerForWrite("mcparticles");
17 writer.registerForWrite("hits");
18 writer.registerForWrite("clusters");
19
20 unsigned nEvents = reader.getEntries();
21 for (unsigned i = 0; i < nEvents; ++i) {
22 if (i % 1000 == 0) {
23 std::cout << "reading event " << i << std::endl;
24 }
25 processEvent(store, i, reader.currentFileVersion());
26
27 writer.writeEvent();
28
29 store.clear();
30 reader.endOfEvent();
31 }
32 reader.closeFile();
33 return 0;
34}
int main()
void processEvent(StoreT &store, int eventNum, podio::version::Version fileVersion)
Definition: read_test.h:46