PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
read_frame_legacy_root.cpp File Reference
#include "read_test.h"
#include "podio/Frame.h"
#include "podio/ROOTLegacyReader.h"
#include <iostream>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 8 of file read_frame_legacy_root.cpp.

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