Skip to content

Commit

Permalink
Simplify choice correct podio reader and writer
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored and andresailer committed Apr 22, 2024
1 parent f08e335 commit 445ab1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
12 changes: 6 additions & 6 deletions DDDigi/io/DigiEdm4hepInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
#include "DigiIO.h"

// podio/edm4hep include files
#include <podio/Frame.h>
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#include <podio/podioVersion.h>
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include <podio/ROOTReader.h>
#else
#include <podio/ROOTFrameReader.h>
namespace podio {
using ROOTReader = podio::ROOTFrameReader;
}
#endif
#include <podio/Frame.h>

#include <edm4hep/SimTrackerHit.h>
#include <edm4hep/SimCalorimeterHit.h>
Expand Down Expand Up @@ -51,11 +55,7 @@ namespace dd4hep {
const podio::CollectionBase* get(const std::string& nam) const { return frame.get(nam); }
};

#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
using reader_t = podio::ROOTReader;
#else
using reader_t = podio::ROOTFrameReader;
#endif
using frame_t = edm4hep_read_frame_t;

/// EDM4HEP Digi input reader: Collection descriptor definition
Expand Down
15 changes: 5 additions & 10 deletions DDDigi/io/DigiEdm4hepOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
#include "DigiIO.h"

/// edm4hep include files
#include <podio/CollectionBase.h>
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#include <podio/podioVersion.h>
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include <podio/ROOTWriter.h>
#else
#include <podio/ROOTFrameWriter.h>
namespace podio {
using ROOTWriter = podio::ROOTFrameWriter;
}
#endif
#include <podio/Frame.h>
#include <edm4hep/SimTrackerHit.h>
Expand Down Expand Up @@ -53,11 +56,7 @@ namespace dd4hep {
using headercollection_t = std::pair<std::string,std::unique_ptr<edm4hep::EventHeaderCollection> >;
DigiEdm4hepOutput* m_parent { nullptr };
/// Reference to podio writer
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
std::unique_ptr<podio::ROOTWriter> m_writer { };
#else
std::unique_ptr<podio::ROOTFrameWriter> m_writer { };
#endif
/// edm4hep event header collection
headercollection_t m_header { };
/// MC particle collection
Expand Down Expand Up @@ -197,11 +196,7 @@ namespace dd4hep {
clear();
m_writer.reset();
std::string fname = m_parent->next_stream_name();
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
m_writer = std::make_unique<podio::ROOTWriter>(fname);
#else
m_writer = std::make_unique<podio::ROOTFrameWriter>(fname);
#endif
m_parent->info("+++ Opened EDM4HEP output file %s", fname.c_str());
}

Expand Down
15 changes: 5 additions & 10 deletions DDG4/edm4hep/Geant4Output2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
#include <edm4hep/SimCalorimeterHitCollection.h>
#include <edm4hep/EDM4hepVersion.h>
/// podio include files
#include <podio/podioVersion.h>
#include <podio/Frame.h>
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include <podio/ROOTWriter.h>
#else
#include <podio/ROOTFrameWriter.h>
namespace podio {
using ROOTWriter = podio::ROOTFrameWriter;
}
#endif
#include <podio/podioVersion.h>

/// Namespace for the AIDA detector description toolkit
namespace dd4hep {
Expand All @@ -52,11 +55,7 @@ namespace dd4hep {
*/
class Geant4Output2EDM4hep : public Geant4OutputAction {
protected:
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
using writer_t = podio::ROOTWriter;
#else
using writer_t = podio::ROOTFrameWriter;
#endif
using stringmap_t = std::map< std::string, std::string >;
using trackermap_t = std::map< std::string, edm4hep::SimTrackerHitCollection >;
using calorimeterpair_t = std::pair< edm4hep::SimCalorimeterHitCollection, edm4hep::CaloHitContributionCollection >;
Expand Down Expand Up @@ -246,11 +245,7 @@ void Geant4Output2EDM4hep::beginRun(const G4Run* run) {
}
}
if ( !fname.empty() ) {
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
m_file = std::make_unique<podio::ROOTWriter>(fname);
#else
m_file = std::make_unique<podio::ROOTFrameWriter>(fname);
#endif
if ( !m_file ) {
fatal("+++ Failed to open output file: %s", fname.c_str());
}
Expand Down

0 comments on commit 445ab1f

Please sign in to comment.