PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
read_frame_legacy_root.cpp
Go to the documentation of this file.
1#include "read_test.h"
2
3#include "podio/Frame.h"
5
6#include <iostream>
7
8int main() {
9 auto reader = podio::ROOTLegacyReader();
10 try {
11 reader.openFile("example.root");
12 } catch (const std::runtime_error& e) {
13 std::cout << "File could not be opened, aborting." << std::endl;
14 return 1;
15 }
16
17 if (reader.currentFileVersion() != podio::version::build_version) {
18 std::cerr << "The podio build version could not be read back correctly. "
19 << "(expected:" << podio::version::build_version << ", actual: " << reader.currentFileVersion() << ")"
20 << std::endl;
21 return 1;
22 }
23
24 if (reader.getEntries("events") != 2000) {
25 std::cerr << "Could not read back the number of events correctly. "
26 << "(expected:" << 2000 << ", actual: " << reader.getEntries("events") << ")" << std::endl;
27 return 1;
28 }
29
30 for (size_t i = 0; i < reader.getEntries("events"); ++i) {
31 const auto frame = podio::Frame(reader.readNextEntry("events"));
32 processEvent(frame, i, reader.currentFileVersion());
33 }
34
35 // Reading specific entries
36 {
37 auto frame = podio::Frame(reader.readEntry("events", 4));
38 processEvent(frame, 4, reader.currentFileVersion());
39
40 auto nextFrame = podio::Frame(reader.readNextEntry("events"));
41 processEvent(nextFrame, 5, reader.currentFileVersion());
42
43 auto previousFrame = podio::Frame(reader.readEntry("events", 2));
44 processEvent(previousFrame, 2, reader.currentFileVersion());
45 }
46
47 return 0;
48}
int main()
void processEvent(StoreT &store, int eventNum, podio::version::Version fileVersion)
Definition: read_test.h:46