Skip to content

Commit

Permalink
dd4hep: patch 1.26 to enable HepMC3FileReader XRootD reading again (#527
Browse files Browse the repository at this point in the history
)

### Briefly, what does this PR introduce?
This patches DD4hep-1.26 to enable the HepMC3FileReader to read XRootD
files again. Ref: AIDASoft/DD4hep#1156.
  • Loading branch information
wdconinc authored Aug 21, 2023
1 parent 314be35 commit 61d855c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/dd4hep/HepMC3FileReader-XRootD.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/DDG4/hepmc/HepMC3FileReader.cpp b/DDG4/hepmc/HepMC3FileReader.cpp
index b94897ab..07b5505f 100644
--- a/DDG4/hepmc/HepMC3FileReader.cpp
+++ b/DDG4/hepmc/HepMC3FileReader.cpp
@@ -129,16 +129,18 @@ HEPMC3FileReader::HEPMC3FileReader(const std::string& nam)
printout(INFO,"HEPMC3FileReader","Created file reader. Try to open input %s", nam.c_str());
m_reader = HepMC3::deduce_reader(nam);
#if HEPMC3_VERSION_CODE >= 3002006
- // to get the runInfo in the Ascii reader we have to force HepMC to read the first event
- m_reader->skip(1);
- // then we get the run info (shared pointer)
- auto runInfo = m_reader->run_info();
- // and close the reader
- m_reader->close();
- // so we can open the file again from the start
- m_reader = HepMC3::deduce_reader(nam);
- // and set the run info object now
- m_reader->set_run_info(runInfo);
+ if (nam.rfind(".root") != nam.size() - 5) {
+ // to get the runInfo in the Ascii reader we have to force HepMC to read the first event
+ m_reader->skip(1);
+ // then we get the run info (shared pointer)
+ auto runInfo = m_reader->run_info();
+ // and close the reader
+ m_reader->close();
+ // so we can open the file again from the start
+ m_reader = HepMC3::deduce_reader(nam);
+ // and set the run info object now
+ m_reader->set_run_info(runInfo);
+ }
#endif
m_directAccess = false;
}
4 changes: 4 additions & 0 deletions packages/dd4hep/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
class Dd4hep(BuiltinDd4hep):
variant("frames", default=True, description="Use podio frames", when="@1.25.1")
variant("frames", default=True, description="Use podio frames", when="@1.24")
patch(
"HepMC3FileReader-XRootD.patch",
when="@=1.26",
)
patch(
"https://github.com/AIDASoft/DD4hep/pull/1086.patch?full_index=1",
sha256="6b049415e2c6989f3927ff2c56e4764de1650cad6ed301d8ac0f047f4e0039c5",
Expand Down

0 comments on commit 61d855c

Please sign in to comment.