diff --git a/DDG4/examples/readHEPMC.py b/DDG4/examples/readHEPMC.py index 41b43ec3a09b97c40d3d427bf08d62376e46427a..98728e9f04b695b1519ceae01b7ffcca712e7a2a 100644 --- a/DDG4/examples/readHEPMC.py +++ b/DDG4/examples/readHEPMC.py @@ -16,17 +16,17 @@ def run(input_file): description = kernel.detectorDescription() gen = DDG4.GeneratorAction(kernel,"Geant4InputAction/Input") kernel.generatorAction().adopt(gen) - gen.Input = "Geant4EventReaderHepMC|/home/frankm/SW/data/hepmc_geant4.dat" - gen.Input = "Geant4EventReaderHepMC|/home/frankm/SW/data/" gen.Input = "Geant4EventReaderHepMC|"+input_file gen.OutputLevel = Output.DEBUG gen.HaveAbort = False prim_vtx = DDG4.std_vector('dd4hep::sim::Geant4Vertex*')() parts = gen.new_particles() ret = 1 + evtid=0 while ret: try: - ret = gen.readParticles(0,prim_vtx,parts) + ret = gen.readParticles(evtid,prim_vtx,parts) + evtid = evtid + 1 except Exception,X: logging.info( '\nException: readParticles: %s',str(X)) ret = None diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 090435b7f3117f0482e6b4df624186293848d15a..5f0195c43dcd528368a6acf93f63c6d6990e2a86 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -257,8 +257,8 @@ void Geant4Action::fatal(const char* fmt, ...) const { void Geant4Action::except(const char* fmt, ...) const { va_list args; va_start(args, fmt); - dd4hep::printout(dd4hep::FATAL, m_name, fmt, args); string err = dd4hep::format(m_name, fmt, args); + dd4hep::printout(dd4hep::FATAL, m_name, err.c_str()); va_end(args); throw runtime_error(err); } diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index c607d8d8174ca0f37d5e0fa16a14181cb5b81a4a..ae451357fa329f6258a9aebeae58dc6c8c0c3d8a 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -63,6 +63,7 @@ Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() { ++m_currEvent; EventReaderStatus sc = readParticles(m_currEvent,vertices,particles); for_each(particles.begin(),particles.end(),detail::deleteObject<Particle>); + for_each(vertices.begin(),vertices.end(),detail::deleteObject<Vertex>); return sc; } diff --git a/examples/DDG4/CMakeLists.txt b/examples/DDG4/CMakeLists.txt index ed1ceb7156a38ad5ba6033d39fc0000625f674c3..1768f62c5408053b6a2d8132f40f2c4726d1e851 100644 --- a/examples/DDG4/CMakeLists.txt +++ b/examples/DDG4/CMakeLists.txt @@ -16,6 +16,7 @@ dd4hep_configure_output () dd4hep_package ( DDG4 MAJOR 0 MINOR 0 PATCH 1 USES [DD4hep REQUIRED COMPONENTS DDCore] ) +set(DDG4examples_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/DDG4) # #---Geant4 Testsing----------------------------------------------------------------- # @@ -47,7 +48,14 @@ if (DD4HEP_USE_GEANT4) dd4hep_add_test_reg( test_DDG4_HepMC_reader COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDG4.sh" EXEC_ARGS python ${DD4hep_DIR}/examples/DDG4/examples/readHEPMC.py - ${CMAKE_INSTALL_PREFIX}/examples/DDG4/data/hepmc_geant4.dat + ${DDG4examples_INSTALL}/data/hepmc_geant4.dat REQUIRES DDG4 Geant4 - REGEX_PASS "EventReaderHepMC::moveToEvent INFO Current event number: 9") + REGEX_PASS "Geant4InputAction\\[Input\\]: Event 10 Error when moving to event - EOF") + # Test HepMC input reader + dd4hep_add_test_reg( test_DDG4_HepMC_reader_minbias + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDG4.sh" + EXEC_ARGS python ${DD4hep_DIR}/examples/DDG4/examples/readHEPMC.py + ${DDG4examples_INSTALL}/data/LHCb_MinBias_HepMC.txt + REQUIRES DDG4 Geant4 + REGEX_PASS "Geant4InputAction\\[Input\\]: Event 27 Error when moving to event - EOF") endif()