PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
read_and_write_sio.cpp
Go to the documentation of this file.
1#include "read_test.h"
2
3#include "podio/EventStore.h"
4#include "podio/SIOReader.h"
5#include "podio/SIOWriter.h"
6
7int main() {
8 podio::SIOReader reader;
9 reader.openFile("example.sio");
10
11 auto store = podio::EventStore();
12 store.setReader(&reader);
13
14 auto writer = podio::SIOWriter("example_copy.sio", &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}
unsigned getEntries() const override
get the number of events available from this reader
Definition: SIOReader.h:54
podio::version::Version currentFileVersion() const override
Get the podio version with which the current file has been written.
Definition: SIOReader.h:61
void closeFile() override
Definition: SIOReader.cc:74
void openFile(const std::string &filename) override
Definition: SIOReader.cc:62
void endOfEvent() override
Prepare the reader to read the next event.
Definition: SIOReader.cc:107
int main()
void processEvent(StoreT &store, int eventNum, podio::version::Version fileVersion)
Definition: read_test.h:46