diff --git a/Calorimeter/CaloG4/EcalG4_SD/CMakeLists.txt b/Calorimeter/CaloG4/EcalG4_SD/CMakeLists.txt index 487688ec1084a2d8a6c8188f0de5f052ef8ba2cd..43b61dd7c56347d1c4c84c431c3ccd44059c43d2 100644 --- a/Calorimeter/CaloG4/EcalG4_SD/CMakeLists.txt +++ b/Calorimeter/CaloG4/EcalG4_SD/CMakeLists.txt @@ -11,12 +11,20 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_component( EcalG4_SD +atlas_add_library( EcalG4_SDLib src/*.cxx - src/components/*.cxx + OBJECT + NO_PUBLIC_HEADERS INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel FaserCaloSimEvent G4AtlasToolsLib FaserMCTruth ) +atlas_add_library( ECALG4_SD + src/components/*.cxx + OBJECT + NO_PUBLIC_HEADERS + PRIVATE_LINK_LIBRARIES EcalG4_SDLib ) + + # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt b/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt index bc2a131d7fb3dab8009d11430e10ae9f4ee6faa6..0bd53e3eec590210a250a1a766928c45c4ce4181 100644 --- a/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt +++ b/Simulation/G4Faser/G4FaserAlg/CMakeLists.txt @@ -15,16 +15,19 @@ find_package( Eigen ) atlas_add_library( G4FaserAlgLib src/*.cxx + OBJECT + #PUBLIC_HEADERS G4FaserAlg NO_PUBLIC_HEADERS INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${GEANT4_LIBRARIES} ${EIGEN_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib G4AtlasAlgLib AthenaBaseComps AthenaKernel GaudiKernel G4AtlasInterfaces SGTools StoreGateLib SGtests EventInfo GeneratorObjects GeoModelInterfaces FaserISF_InterfacesLib FaserMCTruthBaseLib ) + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${EIGEN_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AthenaBaseComps AthenaKernel CXXUtils GaudiKernel G4AtlasInterfaces G4AtlasAlgLib SGTools StoreGateLib EventInfo GeneratorObjects GeoModelInterfaces HepMC_InterfacesLib FaserISF_InterfacesLib FaserMCTruthBaseLib ) # Component(s) in the package: -atlas_add_component( G4FaserAlg +atlas_add_library( G4FaserAlg src/components/*.cxx + OBJECT NO_PUBLIC_HEADERS INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${GEANT4_LIBRARIES} ${EIGEN_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AthenaBaseComps AthenaKernel GaudiKernel G4AtlasInterfaces G4FaserAlgLib G4AtlasAlgLib SGTools StoreGateLib SGtests EventInfo GeneratorObjects FaserMCTruthBaseLib ) + PRIVATE_LINK_LIBRARIES ${GEANT4_LIBRARIES} ${EIGEN_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AthenaBaseComps AthenaKernel CXXUtils GaudiKernel G4AtlasInterfaces G4FaserAlgLib G4AtlasAlgLib SGTools StoreGateLib EventInfo GeneratorObjects FaserMCTruthBaseLib) atlas_add_test( G4FaserAlgConfig_TestFaser SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/test/G4FaserAlgConfigNew_Test.py GeoModel.FaserVersion="'FASER-01'" IOVDb.GlobalTag="'OFLCOND-FASER-01'" Output.HITSFileName='faser.HITS.pool.root' diff --git a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx index 69ff7cfd61bceff6cebf6a01043012c78c0a379b..c721f09e0ddb63ecaa62c28c506b53f0b7a6fc5b 100644 --- a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx +++ b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.cxx @@ -8,6 +8,7 @@ #include "G4AtlasAlg/G4AtlasActionInitialization.h" #include "AthenaKernel/RNGWrapper.h" +#include "CxxUtils/checker_macros.h" // Can we safely include all of these? #include "G4AtlasAlg/G4AtlasMTRunManager.h" @@ -39,7 +40,7 @@ // Athena includes #include "StoreGate/ReadHandle.h" #include "StoreGate/WriteHandle.h" -#include "EventInfo/EventInfo.h" +// #include "EventInfo/EventInfo.h" #include "FaserMCTruthBase/FaserTruthStrategyManager.h" #include "GeoModelInterfaces/IGeoModelSvc.h" #include "GaudiKernel/IThreadInitTool.h" @@ -324,10 +325,11 @@ StatusCode G4FaserAlg::execute() } } + const EventContext& ctx = Gaudi::Hive::currentContext(); // Set the RNG to use for this event. We need to reset it for MT jobs // because of the mismatch between Gaudi slot-local and G4 thread-local RNG. ATHRNG::RNGWrapper* rngWrapper = m_rndmGenSvc->getEngine(this, m_randomStreamName); - rngWrapper->setSeed( name(), Gaudi::Hive::currentContext() ); + rngWrapper->setSeed( m_randomStreamName, ctx); G4Random::setTheEngine(*rngWrapper); ATH_MSG_DEBUG("Calling SimulateG4Event"); @@ -349,8 +351,12 @@ StatusCode G4FaserAlg::execute() } ATH_MSG_DEBUG("Recorded output GenEvent collection " << outputTruthCollection.name() << " in store " << outputTruthCollection.store()); + + std::unique_ptr<McEventCollection> shadowTruth{}; + shadowTruth = std::make_unique<McEventCollection>(); + G4Event *inputEvent{}; - ATH_CHECK( m_inputConverter->convertHepMCToG4Event(*outputTruthCollection, inputEvent, HepMcParticleLink::find_enumFromKey(outputTruthCollection.name())) ); + ATH_CHECK( m_inputConverter->convertHepMCToG4Event(*outputTruthCollection, inputEvent, *shadowTruth, HepMcParticleLink::find_enumFromKey(outputTruthCollection.name())) ); bool abort = false; // Worker run manager @@ -378,20 +384,14 @@ StatusCode G4FaserAlg::execute() setFilterPassed(false); } if (m_flagAbortedEvents) { - // FIXME This code is updating an object which is already in - // StoreGate, which is not really allowed. The long term - // solution is to switch Simulation to use xAOD::EventInfo, then - // use an SG::WriteDecorHandle (when available) to set the error - // state. - const DataHandle<EventInfo> eic = 0; - if ( sgSvc()->retrieve( eic ).isFailure() || !eic ) { - ATH_MSG_WARNING( "Failed to retrieve EventInfo" ); + SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey, ctx); + if (!eventInfo.isValid()) { + ATH_MSG_FATAL( "Failed to retrieve xAOD::EventInfo while trying to update the error state!" ); + return StatusCode::FAILURE; } else { - // Gotta cast away the const... sadface - EventInfo *ei = const_cast< EventInfo * > (&(*eic)); - ei->setErrorState(EventInfo::Core,EventInfo::Error); - ATH_MSG_WARNING( "Set error state in event info!" ); + eventInfo->updateErrorState(xAOD::EventInfo::Core,xAOD::EventInfo::Error); + ATH_MSG_WARNING( "Set error state in xAOD::EventInfo!" ); } } } diff --git a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h index 1dbadf47ac6ed83bd5012ead048d077d951e624f..4c0a356a1f8787204d786deb46f8b488b310fcb1 100644 --- a/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h +++ b/Simulation/G4Faser/G4FaserAlg/src/G4FaserAlg.h @@ -27,6 +27,7 @@ #include "G4AtlasInterfaces/IPhysicsListSvc.h" #include "G4AtlasInterfaces/IUserLimitsSvc.h" #include "GeneratorObjects/McEventCollection.h" +#include "xAODEventInfo/EventInfo.h" // ISF includes #include "FaserISF_Interfaces/IFaserTruthSvc.h" @@ -98,6 +99,7 @@ private: Gaudi::Property<bool> m_flagAbortedEvents{this, "FlagAbortedEvents", false, ""}; SG::ReadHandleKey<McEventCollection> m_inputTruthCollectionKey{this, "InputTruthCollection", "BeamTruthEvent", "Input hard scatter collection"}; //!< input hard scatter collection SG::WriteHandleKey<McEventCollection> m_outputTruthCollectionKey{this, "OutputTruthCollection", "TruthEvent", "Output hard scatter truth collection"};//!< output hard scatter truth collection + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "EventInfo", "EventInfo", "EventInfo key"}; /// Central Truth Service ServiceHandle<ISF::IFaserTruthSvc> m_truthRecordSvc{this, "TruthRecordService", "ISF_FaserTruthRecordSvc", ""}; /// Geo ID Service diff --git a/Simulation/G4Utilities/G4UserActions/CMakeLists.txt b/Simulation/G4Utilities/G4UserActions/CMakeLists.txt index aa8a780c71d07c1a5af11705a9a9b19d4f782ccd..093345ccc3f2da3b7b7b5fb147068ffc902f8f38 100644 --- a/Simulation/G4Utilities/G4UserActions/CMakeLists.txt +++ b/Simulation/G4Utilities/G4UserActions/CMakeLists.txt @@ -13,12 +13,13 @@ find_package( TBB ) find_package( XercesC ) # Component(s) in the package: -atlas_add_component( G4UserActions +atlas_add_library( G4UserActions src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib EventInfo TrackerSimEvent ScintSimEvent FaserMCTruth FaserMCTruthBaseLib TruthUtils SimHelpers PathResolver G4DebuggingHelperLib) - + OBJECT + NO_PUBLIC_HEADERS + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS} + PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps AthenaKernel StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib EventInfo TrackerSimEvent ScintSimEvent FaserMCTruth FaserMCTruthBaseLib TruthUtils SimHelpers PathResolver G4DebuggingHelperLib) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/package_filters.txt b/package_filters.txt index a3d9a255812e659b5993d914ab93c7e501ea2777..7dbd00e5f493aa30f05eb4af467f4630931aeeb0 100644 --- a/package_filters.txt +++ b/package_filters.txt @@ -77,20 +77,22 @@ #+Scintillator/ScintEventCnv/ScintSimEventTPCnv #+Scintillator/ScintSimEvent +Scintillator/.* -+Simulation/G4Extensions/Pythia8Decayer -##+Simulation/G4Faser/G4FaserAlg -+Simulation/G4Sim/FaserMCTruth -+Simulation/G4Sim/FaserMCTruthBase -+Simulation/G4Utilities/Geo2G4 -+Simulation/G4Utilities/GeoMaterial2G4 -+Simulation/G4Utilities/G4UserActions -+Simulation/ISF/ISF_Core/FaserISF_Event -+Simulation/ISF/ISF_Core/FaserISF_Interfaces -+Simulation/ISF/ISF_Core/FaserISF_Services -+Simulation/ISF/ISF_Geant4/FaserISF_Geant4Event -+Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Interfaces -+Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools --Simulation/.* +#+Simulation/G4Extensions/Pythia8Decayer +#+Simulation/G4Faser/G4FaserAlg +#+Simulation/G4Faser/G4FaserServices +#+Simulation/G4Faser/G4FaserTools +#+Simulation/G4Sim/FaserMCTruth +#+Simulation/G4Sim/FaserMCTruthBase +#+Simulation/G4Utilities/Geo2G4 +#+Simulation/G4Utilities/GeoMaterial2G4 +#+Simulation/G4Utilities/G4UserActions +#+Simulation/ISF/ISF_Core/FaserISF_Event +#+Simulation/ISF/ISF_Core/FaserISF_Interfaces +#+Simulation/ISF/ISF_Core/FaserISF_Services +#+Simulation/ISF/ISF_Geant4/FaserISF_Geant4Event +#+Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Interfaces +#+Simulation/ISF/ISF_HepMC/FaserISF_HepMC_Tools ++Simulation/.* +Tracker/TrackerAlignTools/TrackerAlignGenTools +Tracker/TrackerConditions/FaserSCT_ConditionsAlgorithms +Tracker/TrackerConditions/FaserSCT_ConditionsData