Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ find_package(Delphes REQUIRED)
find_package(EDM4HEP REQUIRED)
find_package(ROOT REQUIRED)

# Detect whether Delphes uses ReadEvent (new) or ReadBlock (old)
# ReadEvent was introduced in Delphes 3.5.2pre01.
# Delphes doesn't export a version so checking for the existence of ReadEvent is the only way to detect this.
file(STRINGS "${DELPHES_INCLUDE_DIR}/classes/DelphesHepMC2Reader.h"
_delphes_hepmcreader_content REGEX "ReadEvent")
if(_delphes_hepmcreader_content)
message(STATUS "Delphes: using ReadEvent API (new)")
add_compile_definitions(DELPHES_HAS_READ_EVENT)
else()
message(STATUS "Delphes: using ReadBlock API (old)")
endif()

#--- optional dependencies
if(BUILD_PYTHIA_READER OR BUILD_EVTGEN_READER)
find_package(Pythia8 REQUIRED)
Expand Down
7 changes: 6 additions & 1 deletion standalone/src/DelphesHepMC2Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ class DelphesHepMC2InputReader : public DelphesInputReader {
auto factory = modularDelphes->GetFactory();
bool goodRead = false;
while ((goodRead =
m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)) &&
#ifdef DELPHES_HAS_READ_EVENT
m_reader->ReadEvent(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#else
m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#endif
) &&
!m_reader->EventReady()) {
}
m_readStopWatch.Stop();
Expand Down
7 changes: 6 additions & 1 deletion standalone/src/DelphesHepMC3Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ class DelphesHepMC3InputReader : public DelphesInputReader {
auto factory = modularDelphes->GetFactory();
bool goodRead = false;
while ((goodRead =
m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)) &&
#ifdef DELPHES_HAS_READ_EVENT
m_reader->ReadEvent(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#else
m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#endif
) &&
!m_reader->EventReady()) {
}
m_readStopWatch.Stop();
Expand Down
5 changes: 5 additions & 0 deletions standalone/src/DelphesPythia8EvtGenReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ class DelphesPythia8EvtGenReader : public DelphesInputReader {
m_treeWriter->Clear();
auto factory = modularDelphes->GetFactory();
while (m_reader &&
#ifdef DELPHES_HAS_READ_EVENT
m_reader->ReadEvent(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#else
m_reader->ReadBlock(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#endif
!m_reader->EventReady())
;

Expand Down
5 changes: 5 additions & 0 deletions standalone/src/DelphesPythia8EvtGenReader_k4Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@ class DelphesPythia8EvtGenReader_k4Interface : public DelphesInputReader {
m_treeWriter->Clear();
auto factory = modularDelphes->GetFactory();
while (m_reader &&
#ifdef DELPHES_HAS_READ_EVENT
m_reader->ReadEvent(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#else
m_reader->ReadBlock(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#endif
!m_reader->EventReady())
;

Expand Down
5 changes: 5 additions & 0 deletions standalone/src/DelphesPythia8Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ class DelphesPythia8Reader : public DelphesInputReader {
m_treeWriter->Clear();
auto factory = modularDelphes->GetFactory();
while (reader &&
#ifdef DELPHES_HAS_READ_EVENT
reader->ReadEvent(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#else
reader->ReadBlock(factory, m_allParticleOutputArrayLHEF, m_stableParticleOutputArrayLHEF,
m_partonOutputArrayLHEF) &&
#endif
!reader->EventReady())
;

Expand Down
8 changes: 7 additions & 1 deletion standalone/src/DelphesSTDHEPInputReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ class DelphesSTDHEPInputReader : public DelphesInputReader {
m_treeWriter->Clear();
m_readStopWatch.Start();
auto factory = modularDelphes->GetFactory();
while (m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)) {
while (
#ifdef DELPHES_HAS_READ_EVENT
m_reader->ReadEvent(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#else
m_reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
#endif
) {
if (m_reader->EventReady()) {
m_readStopWatch.Stop();
m_eventCounter++;
Expand Down
Loading