Skip to content

Commit

Permalink
Add EDM4hep version to the output
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt authored and tmadlener committed Oct 30, 2023
1 parent aec4e6d commit 43b187b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tools/include/edm4hep2json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -48,11 +50,13 @@
#include <sstream>
#include <vector>

nlohmann::json processEvent(const podio::Frame& frame, std::vector<std::string>& collList, bool verboser,
nlohmann::json processEvent(const podio::Frame& frame, std::vector<std::string>& 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]);
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 43b187b

Please sign in to comment.