PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
IOHelpers.cc
Go to the documentation of this file.
2
3#include "podio/ROOTReader.h"
4
5#if PODIO_ENABLE_SIO
6 #include "podio/SIOReader.h"
7#endif
8
9namespace podio {
10std::unique_ptr<podio::IReader> createReader(const std::string& filename) {
11 const auto fileEnding = [&filename]() -> std::string {
12 const auto n = filename.rfind('.');
13 if (n != std::string::npos) {
14 return filename.substr(n);
15 }
16 return "";
17 }();
18
19 if (fileEnding.empty()) {
20 return nullptr;
21 }
22
23 if (fileEnding == ".root") {
24 return std::make_unique<podio::ROOTReader>();
25 } else if (fileEnding == ".sio") {
26#if PODIO_ENABLE_SIO
27 return std::make_unique<podio::SIOReader>();
28#else
29 std::cerr << "PODIO: You are trying to open a .sio file but podio has not been built with SIO support\nMake sure "
30 "to build PODIO with SIO support to be able to read .sio files"
31 << std::endl;
32 return nullptr;
33#endif
34 } else {
35 return nullptr;
36 }
37}
38
39} // namespace podio
std::unique_ptr< podio::IReader > createReader(const std::string &filename)
Definition: IOHelpers.cc:10