PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
read_and_write.cpp File Reference
#include "read_test.h"
#include "podio/EventStore.h"
#include "podio/ROOTReader.h"
#include "podio/ROOTWriter.h"

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 7 of file read_and_write.cpp.

7 {
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}
void processEvent(StoreT &store, int eventNum, podio::version::Version fileVersion)
Definition: read_test.h:46