Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Sep 20, 2023
1 parent 59d8ced commit b247fb4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
52 changes: 25 additions & 27 deletions tools/include/edm4hep2json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
#define EDM4HEP_TO_JSON_H

// EDM4hep event data model
#include "edm4hep/EventHeaderCollection.h"
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/CaloHitContributionCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/RawCalorimeterHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"
#include "edm4hep/ParticleIDCollection.h"
#include "edm4hep/ClusterCollection.h"
#include "edm4hep/TrackerHitCollection.h"
#include "edm4hep/TrackerHitPlaneCollection.h"
#include "edm4hep/EventHeaderCollection.h"
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/ParticleIDCollection.h"
#include "edm4hep/RawCalorimeterHitCollection.h"
#include "edm4hep/RawTimeSeriesCollection.h"
#include "edm4hep/TrackCollection.h"
#include "edm4hep/VertexCollection.h"
#include "edm4hep/RecDqdxCollection.h"
#include "edm4hep/RecIonizationClusterCollection.h"
#include "edm4hep/ReconstructedParticleCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/SimPrimaryIonizationClusterCollection.h"
#include "edm4hep/TrackerPulseCollection.h"
#include "edm4hep/RecIonizationClusterCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TimeSeriesCollection.h"
#include "edm4hep/RecDqdxCollection.h"
#include "edm4hep/TrackCollection.h"
#include "edm4hep/TrackerHitCollection.h"
#include "edm4hep/TrackerHitPlaneCollection.h"
#include "edm4hep/TrackerPulseCollection.h"
#include "edm4hep/VertexCollection.h"

#include "edm4hep/MCRecoParticleAssociationCollection.h"
#include "edm4hep/MCRecoCaloAssociationCollection.h"
#include "edm4hep/MCRecoTrackerAssociationCollection.h"
#include "edm4hep/MCRecoTrackerHitPlaneAssociationCollection.h"
#include "edm4hep/MCRecoCaloParticleAssociationCollection.h"
#include "edm4hep/MCRecoClusterParticleAssociationCollection.h"
#include "edm4hep/MCRecoParticleAssociationCollection.h"
#include "edm4hep/MCRecoTrackParticleAssociationCollection.h"
#include "edm4hep/MCRecoTrackerAssociationCollection.h"
#include "edm4hep/MCRecoTrackerHitPlaneAssociationCollection.h"
#include "edm4hep/RecoParticleVertexAssociationCollection.h"

// podio specific includes
Expand Down Expand Up @@ -83,7 +83,8 @@ nlohmann::json processEvent(const podio::Frame& frame, std::vector<std::string>&
} else if (coll->getTypeName() == "edm4hep::CaloHitContributionCollection") {
auto& hitContribCollection = frame.get<edm4hep::CaloHitContributionCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i], {{"collection", hitContribCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i],
{{"collection", hitContribCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
} else if (coll->getTypeName() == "edm4hep::SimCalorimeterHitCollection") {
auto& hitCollection = frame.get<edm4hep::SimCalorimeterHitCollection>(collList[i]);
Expand Down Expand Up @@ -120,7 +121,8 @@ nlohmann::json processEvent(const podio::Frame& frame, std::vector<std::string>&
} else if (coll->getTypeName() == "edm4hep::TrackerHitPlaneCollection") {
auto& hitPlaneCollection = frame.get<edm4hep::TrackerHitPlaneCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i], {{"collection", hitPlaneCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i],
{{"collection", hitPlaneCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
} else if (coll->getTypeName() == "edm4hep::RawTimeSeries") {
auto& rtsCollection = frame.get<edm4hep::RawTimeSeriesCollection>(collList[i]);
Expand Down Expand Up @@ -154,26 +156,22 @@ nlohmann::json processEvent(const podio::Frame& frame, std::vector<std::string>&
} else if (coll->getTypeName() == "edm4hep::TrackerPulseCollection") {
auto& tpCollection = frame.get<edm4hep::TrackerPulseCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i],
{{"collection", tpCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i], {{"collection", tpCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
} else if (coll->getTypeName() == "edm4hep::RecIonizationClusterCollection") {
auto& ricCollection = frame.get<edm4hep::RecIonizationClusterCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i],
{{"collection", ricCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i], {{"collection", ricCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
} else if (coll->getTypeName() == "edm4hep::TimeSeriesCollection") {
auto& tsCollection = frame.get<edm4hep::TimeSeriesCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i],
{{"collection", tsCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i], {{"collection", tsCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
} else if (coll->getTypeName() == "edm4hep::RecDqdxCollection") {
auto& recCollection = frame.get<edm4hep::RecDqdxCollection>(collList[i]);
nlohmann::json jsonColl{
{collList[i],
{{"collection", recCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
{collList[i], {{"collection", recCollection}, {"collID", coll->getID()}, {"collType", coll->getTypeName()}}}};
jsonDict.insert(jsonColl.begin(), jsonColl.end());
}
// Associations
Expand Down Expand Up @@ -360,7 +358,7 @@ int read_frames(const std::string& filename, const std::string& jsonFile, const
}
if (verboser) {
std::cout << "INFO: Following collections will be converted:" << std::endl;
for (const auto& collName: collList) {
for (const auto& collName : collList) {
std::cout << " * " << collName << std::endl;
}
}
Expand Down
13 changes: 4 additions & 9 deletions tools/src/edm4hep2json.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,11 @@ int main(int argc, char** argv) {

if (legacyReader) {
std::cout << "WARNING: Reading legacy file, some collections might not be recognized!" << std::endl;
return read_frames<podio::ROOTLegacyReader>(inFilePath,
outFilePath,
requestedCollections,
requestedEvents,
frameName,
nEventsMax,
verboser);
return read_frames<podio::ROOTLegacyReader>(inFilePath, outFilePath, requestedCollections, requestedEvents,
frameName, nEventsMax, verboser);
} else {
return read_frames<podio::ROOTFrameReader>(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName,
nEventsMax, verboser);
return read_frames<podio::ROOTFrameReader>(inFilePath, outFilePath, requestedCollections, requestedEvents,
frameName, nEventsMax, verboser);
}

return EXIT_SUCCESS;
Expand Down

0 comments on commit b247fb4

Please sign in to comment.