diff --git a/Simulation/BeamEffects/share/BeamEffectsAlg_test.ref b/Simulation/BeamEffects/share/BeamEffectsAlg_test.ref index 7ba79842529b7e95c3aee9157cb2ec5b09cb9227..bb42b8c5d058ead706100c086d766af36c514a12 100644 --- a/Simulation/BeamEffects/share/BeamEffectsAlg_test.ref +++ b/Simulation/BeamEffects/share/BeamEffectsAlg_test.ref @@ -1,4 +1,4 @@ -[==========] Running 6 tests from 1 test case. +[==========] Running 7 tests from 1 test case. [----------] Global test environment set-up. ApplicationMgr SUCCESS ==================================================================================================================================== @@ -11,14 +11,17 @@ EventLoopMgr WARNING No events will be processed from external input. HistogramPersis...WARNING Histograms saving not required. ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready -[----------] 6 tests from BeamEffectsAlg_test +[----------] 7 tests from BeamEffectsAlg_test [ RUN ] BeamEffectsAlg_test.empty_alg_execute ClassIDSvc INFO getRegistryEntries: read 1507 CLIDRegistry entries for module ALL BeamEffectsAlg FATAL No input McEventCollection called GEN_EVENT in StoreGate. [ OK ] BeamEffectsAlg_test.empty_alg_execute (179 ms) [ RUN ] BeamEffectsAlg_test.set_properties ClassIDSvc INFO getRegistryEntries: read 359 CLIDRegistry entries for module ALL -[ OK ] BeamEffectsAlg_test.set_properties (2 ms) +[ OK ] BeamEffectsAlg_test.set_properties (1 ms) +[ RUN ] BeamEffectsAlg_test.patchSignalProcessVertex_empty_GenEvent +BeamEffectsAlg WARNING No signal_process_vertex found. Empty GenEvent! +[ OK ] BeamEffectsAlg_test.patchSignalProcessVertex_empty_GenEvent (0 ms) [ RUN ] BeamEffectsAlg_test.signal_process_vertex_exists [ OK ] BeamEffectsAlg_test.signal_process_vertex_exists (1 ms) [ RUN ] BeamEffectsAlg_test.add_signal_process_vertex_atlasG4 @@ -26,9 +29,9 @@ ClassIDSvc INFO getRegistryEntries: read 359 CLIDRegistry entries for [ RUN ] BeamEffectsAlg_test.add_signal_process_vertex_isfG4 [ OK ] BeamEffectsAlg_test.add_signal_process_vertex_isfG4 (0 ms) [ RUN ] BeamEffectsAlg_test.execute_pass_through -[ OK ] BeamEffectsAlg_test.execute_pass_through (1 ms) -[----------] 6 tests from BeamEffectsAlg_test (183 ms total) +[ OK ] BeamEffectsAlg_test.execute_pass_through (0 ms) +[----------] 7 tests from BeamEffectsAlg_test (19 ms total) [----------] Global test environment tear-down -[==========] 6 tests from 1 test case ran. (572 ms total) -[ PASSED ] 6 tests. +[==========] 7 tests from 1 test case ran. (75 ms total) +[ PASSED ] 7 tests. diff --git a/Simulation/BeamEffects/src/BeamEffectsAlg.cxx b/Simulation/BeamEffects/src/BeamEffectsAlg.cxx index 75648f1fd49bc687d6ce2f0e24b04189ba9a6e94..7b5d6c38e7489ed19d8b45f2a00a68ae3f5e3727 100644 --- a/Simulation/BeamEffects/src/BeamEffectsAlg.cxx +++ b/Simulation/BeamEffects/src/BeamEffectsAlg.cxx @@ -101,13 +101,18 @@ namespace Simulation ge.set_signal_process_vertex( signalVertex ); } else { - ATH_MSG_DEBUG("No signal_process_vertex found - using the first GenVertex in the event."); - HepMC::GenVertex *signalVertex = *(ge.vertices_begin()); - ge.set_signal_process_vertex( signalVertex ); + if (!ge.vertices_empty()) { + ATH_MSG_DEBUG("No signal_process_vertex found - using the first GenVertex in the event."); + HepMC::GenVertex *signalVertex = *(ge.vertices_begin()); + ge.set_signal_process_vertex( signalVertex ); + } } if( !ge.signal_process_vertex() ) { // Insanity check - ATH_MSG_ERROR("Failed to set signal_process_vertex for GenEvent!!"); - return StatusCode::FAILURE; + if (!ge.vertices_empty()) { + ATH_MSG_ERROR("Failed to set signal_process_vertex for GenEvent!!"); + return StatusCode::FAILURE; + } + ATH_MSG_WARNING("No signal_process_vertex found. Empty GenEvent!"); } } else { diff --git a/Simulation/BeamEffects/test/BeamEffectsAlg_test.cxx b/Simulation/BeamEffects/test/BeamEffectsAlg_test.cxx index afac3c679c1521400648ad53e4744904fdd635b3..42e2b0b50dd345392f37c13589283097fbc65fa3 100644 --- a/Simulation/BeamEffects/test/BeamEffectsAlg_test.cxx +++ b/Simulation/BeamEffects/test/BeamEffectsAlg_test.cxx @@ -99,6 +99,12 @@ namespace SimTesting { ASSERT_TRUE( m_alg->setProperty( "ISFRun", true).isSuccess() ); } + TEST_F(BeamEffectsAlg_test, patchSignalProcessVertex_empty_GenEvent) { + HepMC::GenEvent ge; + ASSERT_TRUE( patchSignalProcessVertex(ge).isSuccess() ); + ASSERT_TRUE( ge.signal_process_vertex()==nullptr ); + } + TEST_F(BeamEffectsAlg_test, signal_process_vertex_exists) { HepMC::GenEvent ge; CLHEP::HepLorentzVector myPos( 1.0, 1.0, 1.0, 1.0);