diff --git a/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernel.cxx b/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernel.cxx index 88816dd09e601c6e8296e8003785a124d541d779..b97decb5d82dd8cb7df4803ba0d41468aa7d3785 100644 --- a/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernel.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernel.cxx @@ -388,7 +388,6 @@ StatusCode ISF::SimKernel::execute() // block defines scope for Benchmarks // -> benchmarks will be stared/stopped automatically via the CustomBenchmarkGuard // constructor and destructor, respectively - StatusCode simSC; { // setup sim svc benchmarks //PMonUtils::CustomBenhmarkGuard benchPDG ( m_benchPDGCode, pdgCode ); @@ -396,9 +395,12 @@ StatusCode ISF::SimKernel::execute() PMonUtils::CustomBenchmarkGuard benchSimID( m_benchSimID , simID , numParticles ); // ===> simulate particle - simSC = m_simSvcs[simID]->simulateVector( particles); - if ( simSC.isFailure()) + // NB Passing only the hard-scatter McEventCollection is not + // correct if Geant4 simulation were to be used for pile-up Hits + // in Fast Chain. + if (m_simSvcs[simID]->simulateVector(particles, m_outputHardScatterTruth.ptr()).isFailure()) { ATH_MSG_WARNING( "Simulation of particles failed in Simulator: " << m_simSvcNames[simID]); + } } } diff --git a/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernelMT.cxx b/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernelMT.cxx index aa7b6ac32ff88a66c3231000673df429b95cb6ab..3ee6b49b963b6d48f5727c58526cf9fe99935289 100644 --- a/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernelMT.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Algorithms/src/SimKernelMT.cxx @@ -172,7 +172,7 @@ StatusCode ISF::SimKernelMT::execute() { if (not particles.empty()) { ISFParticleContainer newSecondaries; //ATH_CHECK( simTool.simulate( std::move(curParticle), newSecondaries ) ); - ATH_CHECK( simTool.simulateVector( particles, newSecondaries ) ); + ATH_CHECK( simTool.simulateVector( particles, newSecondaries, outputTruth.ptr() ) ); // add any returned ISFParticles to the list of particles to be simulated simParticles.splice( end(simParticles), std::move(newSecondaries) ); // delete simulated particles @@ -190,7 +190,7 @@ StatusCode ISF::SimKernelMT::execute() { if (not particles.empty()) { ISFParticleContainer newSecondaries; if(!lastSimulator) { ATH_MSG_FATAL("Particles with no assigned simulator. Bail!"); return StatusCode::FAILURE; } - ATH_CHECK( lastSimulator->simulateVector( particles, newSecondaries ) ); + ATH_CHECK( lastSimulator->simulateVector( particles, newSecondaries, outputTruth.ptr() ) ); // add any returned ISFParticles to the list of particles to be simulated simParticles.splice( end(simParticles), std::move(newSecondaries) ); // delete simulated particles diff --git a/Simulation/ISF/ISF_Core/ISF_Algorithms/test/SimKernelMT_test.cxx b/Simulation/ISF/ISF_Core/ISF_Algorithms/test/SimKernelMT_test.cxx index 94333ecf1a81107e032f99af5bb1c8e8a4fbf130..d59845c7b3880096c3770a9fab31899e3e09f16c 100644 --- a/Simulation/ISF/ISF_Core/ISF_Algorithms/test/SimKernelMT_test.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Algorithms/test/SimKernelMT_test.cxx @@ -139,8 +139,8 @@ public: MOCK_METHOD0(finalize, StatusCode()); MOCK_METHOD0(setupEvent, StatusCode()); - MOCK_METHOD2(simulate, StatusCode(const ISF::ISFParticle&, ISF::ISFParticleContainer&)); - MOCK_METHOD2(simulateVector, StatusCode(const ISF::ConstISFParticleVector&, ISF::ISFParticleContainer&)); + MOCK_METHOD3(simulate, StatusCode(const ISF::ISFParticle&, ISF::ISFParticleContainer&, McEventCollection*)); + MOCK_METHOD3(simulateVector, StatusCode(const ISF::ConstISFParticleVector&, ISF::ISFParticleContainer&, McEventCollection*)); MOCK_METHOD0(releaseEvent, StatusCode()); MOCK_CONST_METHOD1(bid, int(const ISF::ISFParticle&)); @@ -693,7 +693,7 @@ protected: ); ASSERT_NE( m_mockSimulatorTool, nullptr ); - EXPECT_CALL( *m_mockSimulatorTool, simulateVector(::testing::_,::testing::_) ) + EXPECT_CALL( *m_mockSimulatorTool, simulateVector(::testing::_,::testing::_,::testing::_) ) .Times(1) .WillOnce(::testing::Return(StatusCode::SUCCESS)); diff --git a/Simulation/ISF/ISF_Core/ISF_Interfaces/CMakeLists.txt b/Simulation/ISF/ISF_Core/ISF_Interfaces/CMakeLists.txt index f6b0d775acfb33866ae407d991597e60881a5ead..5925a11fd646fd75e3ab098377e8860514fab678 100644 --- a/Simulation/ISF/ISF_Core/ISF_Interfaces/CMakeLists.txt +++ b/Simulation/ISF/ISF_Core/ISF_Interfaces/CMakeLists.txt @@ -13,6 +13,7 @@ atlas_depends_on_subdirs( PUBLIC DetectorDescription/AtlasDetDescr DetectorDescription/GeoPrimitives GaudiKernel + Generators/GeneratorObjects Simulation/Barcode/BarcodeEvent Simulation/ISF/ISF_Core/ISF_Event ) @@ -26,5 +27,5 @@ atlas_add_library( ISF_Interfaces PUBLIC_HEADERS ISF_Interfaces INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel AtlasDetDescr GeoPrimitives GaudiKernel ISF_Event StoreGateLib SGtests ) + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps AthenaKernel AtlasDetDescr GeoPrimitives GaudiKernel GeneratorObjects ISF_Event StoreGateLib SGtests ) diff --git a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulationSvc.h b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulationSvc.h index 7a11a6e5b5b949244d5e1c8e88baa6685e17da49..8dcc7aedb6972a7b23009be0be00aa23a6f9c6fd 100644 --- a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulationSvc.h +++ b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulationSvc.h @@ -16,6 +16,7 @@ #include "AthenaBaseComps/AthService.h" #include "StoreGate/StoreGateSvc.h" +#include "GeneratorObjects/McEventCollection.h" // ISF includes #include "ISF_Interfaces/ISimulationSvc.h" @@ -99,7 +100,7 @@ namespace ISF { } /** Simulation call for vectors of particles */ - virtual StatusCode simulateVector(const ConstISFParticleVector& particles) { + virtual StatusCode simulateVector(const ConstISFParticleVector& particles, McEventCollection* mcEventCollection) { // this implementation is a wrapper in case the simulator does // implement particle-vector input ConstISFParticleVector::const_iterator partIt = particles.begin(); @@ -108,7 +109,7 @@ namespace ISF { // simulate each particle individually for ( ; partIt != partItEnd; partIt++) { ATH_MSG_VERBOSE( m_screenOutputPrefix << "Starting simulation of particle: " << (*partIt) ); - if ( this->simulate(**partIt).isFailure()) { + if ( this->simulate(**partIt, mcEventCollection).isFailure()) { ATH_MSG_WARNING("Simulation of particle failed!" << endmsg << " -> simulator: " << this->simSvcDescriptor() << " -> particle : " << (ISFParticle&)(**partIt) ); @@ -119,7 +120,7 @@ namespace ISF { } /** Simulation call for individual particles */ - virtual StatusCode simulate(const ISFParticle& isp); + virtual StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection); /** wrapper call to start chrono with given tag */ const ChronoEntity* chronoStart(const IChronoSvc::ChronoTag& tag ) { @@ -228,7 +229,7 @@ namespace ISF { /** Simulation Call --- hand over to the particleProcessor if it exists */ - inline StatusCode BaseSimulationSvc::simulate(const ISFParticle& /*isp*/) + inline StatusCode BaseSimulationSvc::simulate(const ISFParticle& /*isp*/, McEventCollection*) { return StatusCode::SUCCESS; } diff --git a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulatorTool.h b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulatorTool.h index dec2ba66ae0195d6342e1dc8968caf94efbd306c..84a42200f338137dc5395b0dd63ccbbb965733b5 100644 --- a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulatorTool.h +++ b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/BaseSimulatorTool.h @@ -70,11 +70,11 @@ namespace ISF { { return StatusCode::FAILURE; } /** */ - virtual StatusCode simulate( const ISFParticle& , ISFParticleContainer& ) override + virtual StatusCode simulate( const ISFParticle& , ISFParticleContainer&, McEventCollection*) override { return StatusCode::FAILURE; } /** Simulation call for vectors of particles */ - virtual StatusCode simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer& secondaries) override + virtual StatusCode simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) override { // this implementation is a wrapper in case the simulator does // implement particle-vector input @@ -82,7 +82,7 @@ namespace ISF { // simulate each particle individually for (auto* cisp : particles) { ATH_MSG_VERBOSE( "Starting simulation of particle: " << (*cisp) ); - ATH_CHECK(this->simulate(*cisp, secondaries)); + ATH_CHECK(this->simulate(*cisp, secondaries, mcEventCollection)); } return StatusCode::SUCCESS; diff --git a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulationSvc.h b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulationSvc.h index 132c7602117ba0e64529435e8464efdd704b60d9..314c61c8ae584bfeeed0857c1e114219c5fc07a7 100644 --- a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulationSvc.h +++ b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulationSvc.h @@ -17,6 +17,8 @@ #include "ISF_Event/ISFParticleVector.h" #include "ISF_Event/SimSvcID.h" +class McEventCollection; + namespace ISF { class ISFParticle; @@ -45,10 +47,10 @@ namespace ISF { virtual StatusCode setParticleBroker( IParticleBroker *broker) = 0; /** Simulation call for vectors of particles*/ - virtual StatusCode simulateVector(const ConstISFParticleVector &particles) = 0; + virtual StatusCode simulateVector(const ConstISFParticleVector &particles, McEventCollection* mcEventCollection) = 0; /** Simulation call for individual particles*/ - virtual StatusCode simulate(const ISFParticle& isp) = 0; + virtual StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection) = 0; /** Return the simulation service descriptor */ virtual std::string& simSvcDescriptor() = 0; diff --git a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulatorTool.h b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulatorTool.h index 8d6c4280cda2ec0c695ff013290b6c88c37f5617..2fb58a4a29d0b6da95f9c8c13d53c609a4020482 100644 --- a/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulatorTool.h +++ b/Simulation/ISF/ISF_Core/ISF_Interfaces/ISF_Interfaces/ISimulatorTool.h @@ -17,6 +17,8 @@ #include "ISF_Event/ISFParticleContainer.h" #include "ISF_Event/ISFParticleVector.h" +class McEventCollection; + namespace ISF { class ISimulatorTool : virtual public IAlgTool { @@ -24,10 +26,10 @@ public: DeclareInterfaceID(ISimulatorTool, 1, 0); /** Simulation call for individual particles*/ - virtual StatusCode simulate(const ISFParticle& isp, ISFParticleContainer& secondaries ) = 0; + virtual StatusCode simulate(const ISFParticle& isp, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) = 0; /** Simulation call for vectors of particles*/ - virtual StatusCode simulateVector(const ConstISFParticleVector &particles, ISFParticleContainer& secondaries) = 0; + virtual StatusCode simulateVector(const ConstISFParticleVector &particles, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) = 0; /** Create data containers for an event */ virtual StatusCode setupEvent() = 0; diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.cxx b/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.cxx index 269a95f885d98ecea9291aff888cbb9eeaf0c041..6c96c3fcdc1987ebcbb3e24d3e715fdfeec8a024 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.cxx @@ -25,11 +25,11 @@ StatusCode ISF::ParticleKillerSimSvc::initialize() } /** Simulation Call */ -StatusCode ISF::ParticleKillerSimSvc::simulate(const ISF::ISFParticle& particle) +StatusCode ISF::ParticleKillerSimSvc::simulate(const ISF::ISFParticle& particle, McEventCollection* mcEventCollection) { ATH_MSG_VERBOSE( m_screenOutputPrefix << " simulate" ); ISFParticleContainer secondaries; - ATH_CHECK(m_simulatorTool->simulate( particle, secondaries)); + ATH_CHECK(m_simulatorTool->simulate( particle, secondaries, mcEventCollection)); ATH_MSG_VERBOSE( "Returned "<< secondaries.size() << " secondaries."); return StatusCode::SUCCESS; } diff --git a/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.h b/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.h index 2c62b3a7b2cdbb7da6fba64bb4579b96c6c6954a..3e8f7ebea7bb1ec571427b956ca6a5e940826ed3 100644 --- a/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.h +++ b/Simulation/ISF/ISF_Core/ISF_Services/src/ParticleKillerSimSvc.h @@ -36,7 +36,7 @@ namespace ISF { virtual StatusCode initialize() override; /** Simulation Call */ - virtual StatusCode simulate(const ISF::ISFParticle& isp) override; + virtual StatusCode simulate(const ISF::ISFParticle& isp, McEventCollection* mcEventCollection) override; private: PublicToolHandle<ISF::ISimulatorTool> m_simulatorTool{this, "SimulatorTool", "ISF__ParticleKillerSimTool", ""}; diff --git a/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.cxx b/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.cxx index b75d9522d9abbf9570c15b2ab5fa09a4b347d548..ead0be17bc2afc0e18aaddf92c1b6a74d51f824b 100644 --- a/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.cxx +++ b/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.cxx @@ -17,7 +17,7 @@ StatusCode ISF::ParticleKillerSimTool::initialize() { return StatusCode::SUCCESS; } -StatusCode ISF::ParticleKillerSimTool::simulate( const ISFParticle& isp, ISFParticleContainer& ) { +StatusCode ISF::ParticleKillerSimTool::simulate( const ISFParticle& isp, ISFParticleContainer&, McEventCollection* ) { // give a screen output that you entered ParticleKillerSimSvc ATH_MSG_VERBOSE( "Particle '" << isp << "' received for simulation." ); @@ -29,9 +29,9 @@ StatusCode ISF::ParticleKillerSimTool::simulate( const ISFParticle& isp, ISFPart return StatusCode::SUCCESS; } -StatusCode ISF::ParticleKillerSimTool::simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer& secondaries) { +StatusCode ISF::ParticleKillerSimTool::simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) { for (auto isp : particles) { - ATH_CHECK(simulate(*isp, secondaries)); + ATH_CHECK(simulate(*isp, secondaries, mcEventCollection)); } return StatusCode::SUCCESS; } diff --git a/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.h b/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.h index 79f8a6d3fca83c352a0039a03000b6b8212064c8..977596f68f42f86f7bd1a89ba4cefe61082eedfc 100644 --- a/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.h +++ b/Simulation/ISF/ISF_Core/ISF_Tools/src/ParticleKillerSimTool.h @@ -27,10 +27,10 @@ public: virtual StatusCode initialize() override; - virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer& ) override; + virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer&, McEventCollection* ) override; /** */ - virtual StatusCode simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer& ) override; + virtual StatusCode simulateVector(const ConstISFParticleVector& particles, ISFParticleContainer&, McEventCollection* ) override; virtual StatusCode setupEvent() override { return StatusCode::SUCCESS; }; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/NativeFastCaloSimSvc.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/NativeFastCaloSimSvc.h index dab22a3193fe801c2f3da2cda08b4241d0384228..814030cbda7a6d76738cfa5c8fbafcd70acdef26 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/NativeFastCaloSimSvc.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/ISF_FastCaloSimParametrization/NativeFastCaloSimSvc.h @@ -64,7 +64,7 @@ namespace ISF { StatusCode finalize(); /** Simulation Call */ - StatusCode simulate(const ISFParticle& isp); + StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection); /** Setup Event chain - in case of a begin-of event action is needed */ StatusCode setupEvent(); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/NativeFastCaloSimSvc.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/NativeFastCaloSimSvc.cxx index 357f5a8c6700239ee6f4a46f8eb20512e8c53a4f..a51d2b7d668e0af8bac3d2c57a322061a812d895 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/NativeFastCaloSimSvc.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/src/NativeFastCaloSimSvc.cxx @@ -269,7 +269,7 @@ StatusCode ISF::NativeFastCaloSimSvc::releaseEvent() /** Simulation Call */ -StatusCode ISF::NativeFastCaloSimSvc::simulate(const ISF::ISFParticle& isfp) +StatusCode ISF::NativeFastCaloSimSvc::simulate(const ISF::ISFParticle& isfp, McEventCollection*) { // read the particle's barcode Barcode::ParticleBarcode bc = isfp.barcode(); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.cxx index a6a4af6f39c1fe22f945c0dac6beb2ecc555c461..bff289b31c7437e1693282f55998fcc70a17a343 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.cxx @@ -36,10 +36,10 @@ StatusCode ISF::FastCaloSimSvc::releaseEvent() } /** Simulation Call */ -StatusCode ISF::FastCaloSimSvc::simulate(const ISF::ISFParticle& isfp) +StatusCode ISF::FastCaloSimSvc::simulate(const ISF::ISFParticle& isfp, McEventCollection* mcEventCollection) { ISF::ISFParticleContainer secondaries; - ATH_CHECK(m_simulatorTool->simulate(isfp, secondaries)); + ATH_CHECK(m_simulatorTool->simulate(isfp, secondaries, mcEventCollection)); if (not secondaries.empty()) { for (auto particle : secondaries) { m_particleBroker->push( particle, &isfp); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.h index a8c4303e595f3d32f3d81b9bf261cfbee0e70d4d..a641ed7bd2e10bb3fe4a9f753629ad27598210cf 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvc.h @@ -20,7 +20,6 @@ namespace ISF { /** @class FastCaloSimSvc - @author Michael.Duehrssen -at- cern.ch */ class FastCaloSimSvc : public BaseSimulationSvc { @@ -36,7 +35,7 @@ namespace ISF { virtual StatusCode initialize() override; /** Simulation Call */ - virtual StatusCode simulate(const ISFParticle& isp) override; + virtual StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection) override; /** Setup Event chain - in case of a begin-of event action is needed */ virtual StatusCode setupEvent() override; diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.cxx index af0bb682a6e430885b44dd89ef9793f57006104d..cf2e6e856eeb69f1ddd2fd450f7f95cc9a6beb78 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.cxx @@ -485,7 +485,7 @@ StatusCode ISF::FastCaloSimSvcPU::releaseEvent() /** Simulation Call */ -StatusCode ISF::FastCaloSimSvcPU::simulate(const ISF::ISFParticle& isfp) +StatusCode ISF::FastCaloSimSvcPU::simulate(const ISF::ISFParticle& isfp, McEventCollection*) { ATH_MSG_INFO(m_screenOutputPrefix<<" now doing FastCaloSimSvcPU simulate for bcid="<<isfp.getBCID()); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.h index b548f4ff847bc6c97f8e508a5de4ec26013d5057..4fde7943b03abdcc68f6c74d2e1ff61f4ad3092e 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcPU.h @@ -67,7 +67,7 @@ namespace ISF StatusCode finalize(); /** Simulation Call */ - StatusCode simulate(const ISFParticle& isp); + StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection); /** Setup Event chain - in case of a begin-of event action is needed */ StatusCode setupEvent(); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.cxx index ca3a14cc4c17bf5731c18cab332c790ecc47ac94..fe5bdab772cfa1aa3806abbcb6ac95133bb80b11 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.cxx @@ -187,7 +187,7 @@ StatusCode ISF::FastCaloSimSvcV2::releaseEvent() } /** Simulation Call */ -StatusCode ISF::FastCaloSimSvcV2::simulate(const ISF::ISFParticle& isfp) +StatusCode ISF::FastCaloSimSvcV2::simulate(const ISF::ISFParticle& isfp, McEventCollection*) { ATH_MSG_VERBOSE("NEW PARTICLE! FastCaloSimSvcV2 called with ISFParticle: " << isfp); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.h index d7d60dc0ac7f00bf39185a02341e16712fe7c62f..8084442777265d94fc9cd52bb23dcf8ec5312878 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloSimSvcV2.h @@ -60,7 +60,7 @@ namespace ISF { StatusCode finalize(); /** Simulation Call */ - StatusCode simulate(const ISFParticle& isp); + StatusCode simulate(const ISFParticle& isp, McEventCollection* mcEventCollection); /** Setup Event chain - in case of a begin-of event action is needed */ StatusCode setupEvent(); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.cxx b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.cxx index 5e5750d5d57490728decd422bbd0bb51d0d667be..acb708cfc99172f46c4817e8e33b5be5caeb1af8 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.cxx +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.cxx @@ -196,7 +196,7 @@ StatusCode ISF::FastCaloTool::commonSetup() return StatusCode::SUCCESS; } -StatusCode ISF::FastCaloTool::simulate(const ISFParticle& isp, ISFParticleContainer& secondaries) +StatusCode ISF::FastCaloTool::simulate(const ISFParticle& isp, ISFParticleContainer& secondaries, McEventCollection*) { ATH_MSG_VERBOSE( "FastCaloTool " << name() << " simulate()" ); diff --git a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.h b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.h index 6856b4b58cf8afbff4487a95635c8043960b7a02..749dc4c5a7cc0ce6fc4c7cb438056e69099a6e52 100644 --- a/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.h +++ b/Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimServices/src/FastCaloTool.h @@ -53,7 +53,7 @@ public: StatusCode initialize() override; - virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer& ); + virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer&, McEventCollection* ); virtual StatusCode setupEventST() override; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.cxx index b47a6ff1a9cb9400679d7fbc3d683d6a381c3f3a..51d0dc84aee0363a2f0e40b66195dfc7f9beb70b 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.cxx @@ -39,10 +39,10 @@ StatusCode iFatras::FatrasSimSvc::releaseEvent() } /** Simulation Call */ -StatusCode iFatras::FatrasSimSvc::simulate(const ISF::ISFParticle& isfp) +StatusCode iFatras::FatrasSimSvc::simulate(const ISF::ISFParticle& isfp, McEventCollection* mcEventCollection) { ISF::ISFParticleContainer secondaries; - ATH_CHECK(m_simulatorTool->simulate(isfp, secondaries)); + ATH_CHECK(m_simulatorTool->simulate(isfp, secondaries, mcEventCollection)); if (not secondaries.empty()) { for (auto particle : secondaries) { m_particleBroker->push( particle, &isfp); diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.h index 65dd73f77d28cb38adad0076ef30bdba6f24f586..b9e087659822288a65936d53c7a096105e8bc507 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimSvc.h @@ -36,7 +36,7 @@ namespace iFatras { virtual StatusCode finalize() override; /** Simulation Call */ - virtual StatusCode simulate(const ISF::ISFParticle& isp) override; + virtual StatusCode simulate(const ISF::ISFParticle& isp, McEventCollection* mcEventCollection) override; /** Setup Event chain - in case of a begin-of event action is needed */ virtual StatusCode setupEvent() override; diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.cxx index d9a2390fcf71b22c560d0dd3470b40a205241378..69124815b89a71fbfbbb8cd3cffe4b962fed75d5 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.cxx @@ -37,7 +37,7 @@ StatusCode ISF::FatrasSimTool::initialize() { return StatusCode::SUCCESS; } -StatusCode ISF::FatrasSimTool::simulate( const ISFParticle& isp, ISFParticleContainer& secondaries) { +StatusCode ISF::FatrasSimTool::simulate( const ISFParticle& isp, ISFParticleContainer& secondaries, McEventCollection* ) { // give a screen output that you entered FatrasSimSvc ATH_MSG_VERBOSE( "Particle " << isp << " received for simulation." ); diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.h index 287c45125eb4a45d39c8c6ca13b21f3b7f129f5c..ea6977911f780f9945d2aa4f76afba927f109f5a 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/src/FatrasSimTool.h @@ -26,7 +26,7 @@ namespace ISF { virtual StatusCode initialize() override; - virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer& ) override; + virtual StatusCode simulate( const ISFParticle& isp, ISFParticleContainer&, McEventCollection* ) override; virtual StatusCode setupEvent() override { return StatusCode::SUCCESS; }; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.cxx index 2718c5a84e1d1222f94e3e5374ab0c79ebd52042..1cb07748296eb9f82c1a39e673099fbf3406cef9 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.cxx @@ -38,18 +38,18 @@ StatusCode iGeant4::Geant4SimSvc::releaseEvent() } /** Simulation Call */ -StatusCode iGeant4::Geant4SimSvc::simulate(const ISF::ISFParticle& isp) +StatusCode iGeant4::Geant4SimSvc::simulate(const ISF::ISFParticle& isp, McEventCollection* mcEventCollection) { ISF::ISFParticleContainer secondaries; // filled, but not used - ATH_CHECK(m_simulatorTool->simulate(isp, secondaries)); + ATH_CHECK(m_simulatorTool->simulate(isp, secondaries, mcEventCollection)); return StatusCode::SUCCESS; } /** Simulation Call */ -StatusCode iGeant4::Geant4SimSvc::simulateVector(const ISF::ConstISFParticleVector& particles) +StatusCode iGeant4::Geant4SimSvc::simulateVector(const ISF::ConstISFParticleVector& particles, McEventCollection* mcEventCollection) { ISF::ISFParticleContainer secondaries; // filled, but not used - ATH_CHECK (m_simulatorTool->simulateVector(particles,secondaries)); + ATH_CHECK (m_simulatorTool->simulateVector(particles,secondaries, mcEventCollection)); return StatusCode::SUCCESS; } diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.h index 9943f0bf6acddf59714b112ba4bd26f6ae6e4295..6b9c340908218acb15aff3b36b7860fab2e75bc2 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Services/src/Geant4SimSvc.h @@ -36,10 +36,10 @@ namespace iGeant4 { virtual StatusCode finalize() override; /** Simulation Call */ - virtual StatusCode simulate(const ISF::ISFParticle& isp) override; + virtual StatusCode simulate(const ISF::ISFParticle& isp, McEventCollection* mcEventCollection) override; /** Simulation Call for vector of ISF particles */ - virtual StatusCode simulateVector(const ISF::ConstISFParticleVector& particles) override; + virtual StatusCode simulateVector(const ISF::ConstISFParticleVector& particles, McEventCollection* mcEventCollection) override; /** Setup Event chain - in case of a begin-of event action is needed */ virtual StatusCode setupEvent() override; diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx index 206c8123aff13152bf76e45c0dd50ec1a5765f9b..2be786cf81cd4211dd86b060aabad3a9c30f1216 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx @@ -224,7 +224,7 @@ void iGeant4::G4TransportTool::finalizeOnce() } //________________________________________________________________________ -StatusCode iGeant4::G4TransportTool::simulate( const ISF::ISFParticle& isp, ISF::ISFParticleContainer& secondaries ) { +StatusCode iGeant4::G4TransportTool::simulate( const ISF::ISFParticle& isp, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) { // give a screen output that you entered Geant4SimSvc ATH_MSG_VERBOSE( "Particle " << isp << " received for simulation." ); @@ -233,7 +233,7 @@ StatusCode iGeant4::G4TransportTool::simulate( const ISF::ISFParticle& isp, ISF: // wrap the given ISFParticle into a STL vector of ISFParticles with length 1 // (minimizing code duplication) const ISF::ConstISFParticleVector ispVector(1, &isp); - StatusCode success = this->simulateVector(ispVector, secondaries); + StatusCode success = this->simulateVector(ispVector, secondaries, mcEventCollection); ATH_MSG_VERBOSE( "Simulation done" ); // Geant4 call done @@ -241,11 +241,11 @@ StatusCode iGeant4::G4TransportTool::simulate( const ISF::ISFParticle& isp, ISF: } //________________________________________________________________________ -StatusCode iGeant4::G4TransportTool::simulateVector( const ISF::ConstISFParticleVector& particles, ISF::ISFParticleContainer& secondaries ) { +StatusCode iGeant4::G4TransportTool::simulateVector( const ISF::ConstISFParticleVector& particles, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection) { ATH_MSG_DEBUG (name() << ".simulateVector(...) : Received a vector of " << particles.size() << " particles for simulation."); /** Process ParticleState from particle stack */ - G4Event* inputEvent = m_inputConverter->ISF_to_G4Event(particles, genEvent()); + G4Event* inputEvent = m_inputConverter->ISF_to_G4Event(particles, genEvent(mcEventCollection)); if (!inputEvent) { ATH_MSG_ERROR("ISF Event conversion failed "); return StatusCode::FAILURE; @@ -377,26 +377,25 @@ void iGeant4::G4TransportTool::push( ISF::ISFParticle *particle, const ISF::ISFP } //________________________________________________________________________ -HepMC::GenEvent* iGeant4::G4TransportTool::genEvent() const +HepMC::GenEvent* iGeant4::G4TransportTool::genEvent(McEventCollection* mcEventCollection) const { - // collect last GenEvent from McEventCollection - - McEventCollection* mcEventCollection(nullptr); - // retrieve McEventCollection from storegate - if (evtStore()->contains<McEventCollection>(m_mcEventCollectionName)) { - if (evtStore()->retrieve( mcEventCollection, m_mcEventCollectionName).isFailure()) { - ATH_MSG_WARNING( "Unable to retrieve McEventCollection with name=" << m_mcEventCollectionName - << "."); - } - else { - ATH_MSG_DEBUG( "Sucessfully retrieved McEventCollection with name=" << m_mcEventCollectionName); - - return mcEventCollection->back(); + if(!mcEventCollection) { + // retrieve McEventCollection from storegate + if (evtStore()->contains<McEventCollection>(m_mcEventCollectionName)) { + if (evtStore()->retrieve( mcEventCollection, m_mcEventCollectionName).isFailure()) { + ATH_MSG_ERROR( "Unable to retrieve McEventCollection with name=" << m_mcEventCollectionName + << "."); + return nullptr; + } + else { + ATH_MSG_WARNING( "Fallback. Sucessfully retrieved McEventCollection with name=" << m_mcEventCollectionName); + } } + else { return nullptr; } } - return nullptr; - + // collect last GenEvent from McEventCollection + return mcEventCollection->back(); } //________________________________________________________________________ diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h index a56f84a3cd71aef38907f7b69e1fc86718f7a7fc..a02c42784d037590914583d825b04f15d56d37bc 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.h @@ -77,9 +77,9 @@ namespace iGeant4 /// This is done (for now) because we get multiple tool instances in hive. void finalizeOnce(); - virtual StatusCode simulate( const ISF::ISFParticle& isp, ISF::ISFParticleContainer& secondaries ) override; + virtual StatusCode simulate( const ISF::ISFParticle& isp, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection ) override; - virtual StatusCode simulateVector( const ISF::ConstISFParticleVector& particles, ISF::ISFParticleContainer& secondaries ) override; + virtual StatusCode simulateVector( const ISF::ConstISFParticleVector& particles, ISF::ISFParticleContainer& secondaries, McEventCollection* mcEventCollection ) override; virtual StatusCode setupEvent() override; @@ -98,7 +98,7 @@ namespace iGeant4 /// This command prints a message about a G4Command depending on its returnCode void commandLog(int returnCode, const std::string& commandString) const; - HepMC::GenEvent* genEvent() const; + HepMC::GenEvent* genEvent(McEventCollection* mcEventCollection) const; /// @name Configurable Properties /// @{ diff --git a/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/ISF_ParSimServices/ParametricSimSvc.h b/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/ISF_ParSimServices/ParametricSimSvc.h index f13ed9866ef1b1e1f2509ac77432d29fd0ae8e88..6d1cf7f0bf430e6cdbeb01e458ca684a739dee68 100644 --- a/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/ISF_ParSimServices/ParametricSimSvc.h +++ b/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/ISF_ParSimServices/ParametricSimSvc.h @@ -52,7 +52,7 @@ namespace iParSim { StatusCode finalize(); /** Simulation Call */ - StatusCode simulate(const ISF::ISFParticle& isp); + StatusCode simulate(const ISF::ISFParticle& isp, McEventCollection* mcEventCollection); /** Setup Event chain - in case of a begin-of event action is needed */ StatusCode setupEvent(); diff --git a/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/src/ParametricSimSvc.cxx b/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/src/ParametricSimSvc.cxx index 367f2a53591ec2d50db12f2623a50a89ecf5cdd8..27dbb7d5bb34d58ba998e88c6cf448bd646706ba 100644 --- a/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/src/ParametricSimSvc.cxx +++ b/Simulation/ISF/ISF_ParametricSim/ISF_ParSimServices/src/ParametricSimSvc.cxx @@ -67,7 +67,7 @@ StatusCode iParSim::ParametricSimSvc::releaseEvent() } /** Simulation Call */ -StatusCode iParSim::ParametricSimSvc::simulate(const ISF::ISFParticle& isp) +StatusCode iParSim::ParametricSimSvc::simulate(const ISF::ISFParticle& isp, McEventCollection*) { // give a screen output that you entered ParametricSimSvc ATH_MSG_VERBOSE( m_screenOutputPrefix << "Particle " << isp << " received for simulation." );