diff --git a/tools/include/edm4hep2json.hxx b/tools/include/edm4hep2json.hxx index 615a24ea7..32c8ab765 100644 --- a/tools/include/edm4hep2json.hxx +++ b/tools/include/edm4hep2json.hxx @@ -34,6 +34,7 @@ // podio specific includes #include "podio/Frame.h" +#include "podio/Reader.h" #include "podio/UserDataCollection.h" #include "podio/podioVersion.h" @@ -43,7 +44,6 @@ // STL #include #include -#include #include #include #include @@ -173,13 +173,10 @@ std::vector splitString(const std::string& inString) { return outString; } - -template int read_frames(const std::string& filename, const std::string& jsonFile, const std::string& requestedCollections, const std::string& requestedEvents, const std::string& frameName, int nEventsMax = -1, bool verboser = false) { - ReaderT reader; - reader.openFile(filename); + podio::Reader reader = podio::makeReader(filename); nlohmann::json allEventsDict; @@ -196,7 +193,7 @@ int read_frames(const std::string& filename, const std::string& jsonFile, const auto collList = splitString(requestedCollections); if (collList.empty()) { - auto frame = podio::Frame(reader.readEntry(frameName, 0)); + auto frame = podio::Frame(reader.readFrame(frameName, 0)); collList = frame.getAvailableCollections(); } if (collList.empty()) { @@ -272,13 +269,13 @@ int read_frames(const std::string& filename, const std::string& jsonFile, const std::cout << "INFO: Reading event " << i << std::endl; } - auto frame = podio::Frame(reader.readEntry(frameName, i)); + auto frame = podio::Frame(reader.readFrame(frameName, i)); auto eventDict = processEvent(frame, collList, reader.currentFileVersion()); allEventsDict["Event " + std::to_string(i)] = eventDict; } } else { for (auto& i : eventVec) { - auto frame = podio::Frame(reader.readEntry(frameName, i)); + auto frame = podio::Frame(reader.readFrame(frameName, i)); auto eventDict = processEvent(frame, collList, reader.currentFileVersion()); allEventsDict["Event " + std::to_string(i)] = eventDict; } diff --git a/tools/src/edm4hep2json.cxx b/tools/src/edm4hep2json.cxx index c6e1f1686..461b33cbf 100644 --- a/tools/src/edm4hep2json.cxx +++ b/tools/src/edm4hep2json.cxx @@ -1,13 +1,8 @@ +#include "podio/FrameCategories.h" + // EDM4hep #include "edm4hep2json.hxx" -// ROOT -#include "TFile.h" - -// podio -#include "podio/ROOTLegacyReader.h" -#include "podio/ROOTReader.h" - // std #include @@ -35,7 +30,7 @@ int main(int argc, char** argv) { std::filesystem::path outFilePath; std::string requestedCollections; std::string requestedEvents; - std::string frameName = "events"; + std::string frameName = podio::Category::Event; bool verboser = false; int nEventsMax = -1; @@ -120,20 +115,7 @@ int main(int argc, char** argv) { outFilePath = std::filesystem::path(outFileStr + ".edm4hep.json"); } - bool legacyReader = false; - { - std::unique_ptr inFile(TFile::Open(inFilePath.c_str(), "READ")); - legacyReader = !inFile->GetListOfKeys()->FindObject("podio_metadata"); - } - - if (legacyReader) { - std::cout << "WARNING: Reading legacy file, some collections might not be recognized!" << std::endl; - return read_frames(inFilePath, outFilePath, requestedCollections, requestedEvents, - frameName, nEventsMax, verboser); - } else { - return read_frames(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName, - nEventsMax, verboser); - } + return read_frames(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName, nEventsMax, verboser); return EXIT_SUCCESS; }