From 43b187ba177e0825dcc4f835fcb7027d25d516db Mon Sep 17 00:00:00 2001 From: Juraj Smiesko Date: Thu, 21 Sep 2023 11:43:32 +0200 Subject: [PATCH] Add EDM4hep version to the output --- tools/include/edm4hep2json.hxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/include/edm4hep2json.hxx b/tools/include/edm4hep2json.hxx index 5bfe205a5..6abbbbaaa 100644 --- a/tools/include/edm4hep2json.hxx +++ b/tools/include/edm4hep2json.hxx @@ -32,6 +32,8 @@ #include "edm4hep/MCRecoTrackerHitPlaneAssociationCollection.h" #include "edm4hep/RecoParticleVertexAssociationCollection.h" +#include "edm4hep/EDM4hepVersion.h" + // podio specific includes #include "podio/Frame.h" #include "podio/UserDataCollection.h" @@ -48,11 +50,13 @@ #include #include -nlohmann::json processEvent(const podio::Frame& frame, std::vector& collList, bool verboser, +nlohmann::json processEvent(const podio::Frame& frame, std::vector& collList, podio::version::Version podioVersion) { std::stringstream podioVersionStr; podioVersionStr << podioVersion; - nlohmann::json jsonDict = {{"podioVersion", podioVersionStr.str()}}; + std::stringstream e4hVersionStr; + e4hVersionStr << edm4hep::version::build_version; + nlohmann::json jsonDict = {{"podioVersion", podioVersionStr.str()}, {"edm4hepVersion", e4hVersionStr.str()}}; for (unsigned i = 0; i < collList.size(); ++i) { auto coll = frame.get(collList[i]); @@ -426,13 +430,13 @@ int read_frames(const std::string& filename, const std::string& jsonFile, const } auto frame = podio::Frame(reader.readEntry(frameName, i)); - auto eventDict = processEvent(frame, collList, verboser, reader.currentFileVersion()); + 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 eventDict = processEvent(frame, collList, verboser, reader.currentFileVersion()); + auto eventDict = processEvent(frame, collList, reader.currentFileVersion()); allEventsDict["Event " + std::to_string(i)] = eventDict; } }