Skip to content

Commit

Permalink
Add an error message for edm4hep2json when the file is incompatible
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Aug 9, 2024
1 parent 4f6fe0c commit 3901e6d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/src/edm4hep2json.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// *nix
#include <getopt.h>

#include "TFile.h"

void printHelp() {
std::cout << "Usage: edm4hep2json [olenfvh] FILEPATH\n"
<< " -o/--out-file output file path\n"
Expand Down Expand Up @@ -115,7 +117,14 @@ int main(int argc, char** argv) {
outFilePath = std::filesystem::path(outFileStr + ".edm4hep.json");
}

return read_frames(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName, nEventsMax, verboser);
{
std::unique_ptr<TFile> inFile(TFile::Open(inFilePath.c_str(), "READ"));
if (!inFile->GetListOfKeys()->FindObject("podio_metadata")) {
std::cout << "ERROR: Reading file produced with an incompatible version of EDM4hep. Aborting..." << std::endl;
return 1;
}
inFile->Close();
}

return EXIT_SUCCESS;
return read_frames(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName, nEventsMax, verboser);
}

0 comments on commit 3901e6d

Please sign in to comment.