Skip to content

Commit

Permalink
ReadEDM4hep: use generic Reader, but need podio 01.02 for this
Browse files Browse the repository at this point in the history
  • Loading branch information
andresailer committed Dec 18, 2024
1 parent ddd4984 commit 3beea52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DDG4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ENDIF()
IF(TARGET EDM4HEP::edm4hep)
dd4hep_add_plugin(DDG4EDM4HEP
SOURCES edm4hep/*.cpp
USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioRootIO
USES DD4hep::DDG4 EDM4HEP::edm4hep EDM4HEP::edm4hepDict podio::podio podio::podioDict podio::podioRootIO podio::podioIO
)
install(TARGETS DDG4EDM4HEP EXPORT DD4hep LIBRARY DESTINATION lib)
set_target_properties(DDG4EDM4HEP PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
Expand Down
12 changes: 6 additions & 6 deletions DDG4/edm4hep/EDM4hepFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <edm4hep/MCParticleCollection.h>

#include <podio/Frame.h>
#include <podio/ROOTReader.h>
#include <podio/Reader.h>

typedef dd4hep::detail::ReferenceBitMask<int> PropertyMask;

Expand Down Expand Up @@ -85,7 +85,7 @@ namespace dd4hep::sim {
class EDM4hepFileReader : public Geant4EventReader {
protected:
/// Reference to reader object
podio::ROOTReader m_reader {};
podio::Reader m_reader;
/// Name of the MCParticle collection to read
std::string m_collectionName;
/// Name of the EventHeader collection to read
Expand All @@ -108,27 +108,27 @@ namespace dd4hep::sim {
/// Initializing constructor
dd4hep::sim::EDM4hepFileReader::EDM4hepFileReader(const std::string& nam)
: Geant4EventReader(nam)
, m_reader(podio::makeReader(nam))
, m_collectionName("MCParticles")
, m_eventHeaderCollectionName("EventHeader")
{
printout(INFO,"EDM4hepFileReader","Created file reader. Try to open input %s",nam.c_str());
m_reader.openFile(nam);
m_directAccess = true;
}

void EDM4hepFileReader::registerRunParameters() {
try {
auto *parameters = new RunParameters();
try {
podio::Frame runFrame = m_reader.readEntry("runs", 0);
podio::Frame runFrame = m_reader.readFrame("runs", 0);
parameters->ingestParameters(runFrame.getParameters());
} catch (std::runtime_error& e) {
// we ignore if we do not have runs information
} catch(std::invalid_argument&) {
// we ignore if we do not have runs information
}
try {
podio::Frame metaFrame = m_reader.readEntry("metadata", 0);
podio::Frame metaFrame = m_reader.readFrame("metadata", 0);
parameters->ingestParameters(metaFrame.getParameters());
} catch (std::runtime_error& e) {
// we ignore if we do not have metadata information
Expand Down Expand Up @@ -156,7 +156,7 @@ namespace dd4hep::sim {
EDM4hepFileReader::EventReaderStatus
EDM4hepFileReader::readParticles(int event_number, Vertices& vertices, std::vector<Particle*>& particles) {
m_currEvent = event_number;
podio::Frame frame = m_reader.readEntry("events", event_number);
podio::Frame frame = m_reader.readFrame("events", event_number);
const auto& primaries = frame.get<edm4hep::MCParticleCollection>(m_collectionName);
int eventNumber = event_number, runNumber = 0;
if (primaries.isValid()) {
Expand Down

0 comments on commit 3beea52

Please sign in to comment.