diff --git a/Generators/Tauolapp_i/CMakeLists.txt b/Generators/Tauolapp_i/CMakeLists.txt index 6f2e3f9accb59716535a35a1f9def0de935eeea0..a0d399619d342eb3fa9b381797cedfcf96873b22 100644 --- a/Generators/Tauolapp_i/CMakeLists.txt +++ b/Generators/Tauolapp_i/CMakeLists.txt @@ -16,7 +16,7 @@ atlas_add_component( Tauolapp_i Tauolapp_i/*.h src/*.cxx src/components/*.cxx INCLUDE_DIRS ${TAUOLAPP_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} LINK_LIBRARIES ${TAUOLAPP_LIBRARIES} AtlasHepMCLib ${CLHEP_LIBRARIES} - AthenaBaseComps AthenaKernel AthenaPoolUtilities GaudiKernel + AthenaBaseComps AthenaKernel AthenaPoolUtilities CxxUtils GaudiKernel GeneratorObjects ) # Install files from the package: diff --git a/Generators/Tauolapp_i/Tauolapp_i/ATLAS_CHECK_THREAD_SAFETY b/Generators/Tauolapp_i/Tauolapp_i/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..f38ebe2e7c122061daa07964ba7c20115fecf5c2 --- /dev/null +++ b/Generators/Tauolapp_i/Tauolapp_i/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Generators/Tauolapp_i diff --git a/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h index e1ed48600bed0797b07314968f40be9b4cf08e3f..ffe1ead986ca369fe7d8fab5d20cef92cc4ae96d 100644 --- a/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h +++ b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ @@ -7,36 +7,28 @@ #define TAUOLAPP_H #include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaKernel/IAtRndmGenSvc.h" +#include "CxxUtils/checker_macros.h" #include "GaudiKernel/ServiceHandle.h" - #include "AtlasHepMC/GenEvent.h" #include "AtlasHepMC/GenVertex.h" -#include "GaudiKernel/IPartPropSvc.h" - -#include "AthenaPoolUtilities/AthenaAttributeList.h" -#include "GeneratorObjects/McEventCollection.h" - -class StoreGateSvc; - -class IAtRndmGenSvc; - /// @brief This Algorithm provides an easy interface to Tauola C++ interface /// @author Nadia Davidson, Marcin Wolter /// @todo Convert to use standard GenModule base class -class TauolaPP : public AthAlgorithm { +class ATLAS_NOT_THREAD_SAFE TauolaPP : public AthAlgorithm { public: /// Constructor TauolaPP (const std::string& name, ISvcLocator* pSvcLocator); /// Initialization of Tauola++ and setting of JO configurables - StatusCode initialize(); + virtual StatusCode initialize() override; /// Pass each event in the McEventCollection to Tauola to (re)decay the taus - StatusCode execute(); + virtual StatusCode execute() override; private: @@ -48,7 +40,7 @@ private: //@{ /// PDG ID of particle to study - int m_decay_particle; + int m_decay_particle; /// TAUOLA decay mode of particles with same charge as "decay_particle" int m_decay_mode_same; @@ -59,17 +51,21 @@ private: /// tau mass to be taken by TAUOLA double m_tau_mass; - // TAUOLA switch for spin effects + /// TAUOLA switch for spin effects bool m_spin_correlation; - // TAUOLA switch for radiative corrections for leptonic tau decays + /// TAUOLA switch for radiative corrections for leptonic tau decays bool m_setRadiation; - // TAUOLA cut-off for radiative corrections + /// TAUOLA cut-off for radiative corrections double m_setRadiationCutOff; + //@} + + /// Random number generator + ServiceHandle<IAtRndmGenSvc> m_atRndmGenSvc; - static IAtRndmGenSvc* &atRndmGenSvc(); - static std::string &tauolapp_stream(); + /// Random number generator stream name + std::string m_tauolapp_stream; }; diff --git a/Generators/Tauolapp_i/src/TauolaPP.cxx b/Generators/Tauolapp_i/src/TauolaPP.cxx index 4fff219ec1d76cbab4fb3b1152f27455ab5d1f3b..4ff26b8314ab998c669c3078704f11eff0def43d 100644 --- a/Generators/Tauolapp_i/src/TauolaPP.cxx +++ b/Generators/Tauolapp_i/src/TauolaPP.cxx @@ -2,6 +2,7 @@ Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ +#include "GeneratorObjects/McEventCollection.h" #include "Tauolapp_i/TauolaPP.h" // Tauola header files @@ -20,41 +21,22 @@ using TauolaHepMCParticle=TauolaHepMC3Particle; #include "Tauola/f_Variables.h" -// for proper seeding -#include "CLHEP/Random/RandFlat.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -//for Ranlux -#include "CLHEP/Random/Randomize.h" +#include "CLHEP/Random/RandFlat.h" // for proper seeding +#include "CLHEP/Random/Randomize.h" //for Ranlux -using namespace Tauolapp; -using namespace CLHEP; -RanluxEngine theRanluxEngine(123456,1); +CLHEP::RanluxEngine theRanluxEngine(123456,1); -double RanluxGenerator() +double RanluxGenerator ATLAS_NOT_THREAD_SAFE () { - return RandFlat::shoot(&theRanluxEngine); + return CLHEP::RandFlat::shoot(&theRanluxEngine); } - -//Random number service -IAtRndmGenSvc* &TauolaPP::atRndmGenSvc() -{ - static IAtRndmGenSvc *p_AtRndmGenSvc = 0; - return p_AtRndmGenSvc; -} - -std::string &TauolaPP::tauolapp_stream() -{ - - static std::string s_tauolapp_stream = "TAUOLAPP_INIT"; - return s_tauolapp_stream; -} - - // Constructor TauolaPP::TauolaPP(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator) + : AthAlgorithm(name, pSvcLocator), + m_atRndmGenSvc("AtRndmGenSvc", name), + m_tauolapp_stream("TAUOLAPP_INIT") { //Key to HepMC record declareProperty("McEventKey", m_key="GEN_EVENT"); @@ -74,39 +56,20 @@ TauolaPP::TauolaPP(const std::string& name, ISvcLocator* pSvcLocator) StatusCode TauolaPP::initialize(){ - // Get the Storegate collection - /// @todo Can't thi be removed? - evtStore().setName( "StoreGateSvc"); - StatusCode sc = evtStore().retrieve(); - if ( !sc.isSuccess() ) { - ATH_MSG_ERROR ("Could not locate StoreGateSvc"); - return sc; - } - + ATH_CHECK( m_atRndmGenSvc.retrieve() ); - - // Random number service - StatusCode RndmStatus = service("AtRndmGenSvc", atRndmGenSvc(), true); - - if(!RndmStatus.isSuccess() || atRndmGenSvc() == 0) - { - ATH_MSG_ERROR("Could not get Random number service!"); - return StatusCode::FAILURE; - } - - - HepRandomEngine* engine = atRndmGenSvc()->GetEngine(tauolapp_stream()); + CLHEP::HepRandomEngine* engine = m_atRndmGenSvc->GetEngine(m_tauolapp_stream); const long* sip = engine->getSeeds(); long int si1 = sip[0]; long int si2 = sip[1]; - atRndmGenSvc()->CreateStream(si1, si2, tauolapp_stream()); - tauolapp_stream() = "TAUOLAPP"; - + m_atRndmGenSvc->CreateStream(si1, si2, m_tauolapp_stream); + m_tauolapp_stream = "TAUOLAPP"; // Setup and intialise Tauola Interface + using Tauolapp::Tauola; Tauola::setSameParticleDecayMode(m_decay_mode_same); Tauola::setOppositeParticleDecayMode(m_decay_mode_opp); // etc.... see Tauola.h for the full list of configurables @@ -133,9 +96,7 @@ StatusCode TauolaPP::initialize(){ theRanluxEngine.setSeed(si2,1); //setting tau mass - parmas_.amtau=m_tau_mass; - - //cout<<"tauola tau mass "<<Tauola::getTauMass()<<endl; + Tauolapp::parmas_.amtau=m_tau_mass; return StatusCode::SUCCESS; } @@ -145,14 +106,11 @@ StatusCode TauolaPP::execute() { // Load HepMC info const McEventCollection* mcCollptr_const; - if ( evtStore()->retrieve(mcCollptr_const, m_key).isFailure() ) { - ATH_MSG_ERROR ("Could not retrieve McEventCollection"); - return StatusCode::FAILURE; - } + ATH_CHECK( evtStore()->retrieve(mcCollptr_const, m_key) ); - HepRandomEngine* engine = atRndmGenSvc()->GetEngine(tauolapp_stream()); - const long* sip = engine->getSeeds(); - long int si2 = sip[1]; + CLHEP::HepRandomEngine* engine = m_atRndmGenSvc->GetEngine(m_tauolapp_stream); + const long* sip = engine->getSeeds(); + const long int si2 = sip[1]; // We leave the Fortran random engine as it is. @@ -164,10 +122,9 @@ StatusCode TauolaPP::execute() { McEventCollection* mcCollptr = const_cast<McEventCollection*>(mcCollptr_const); // Loop over all events in McEventCollection - McEventCollection::iterator itr; - for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { + for (HepMC::GenEvent* evt : *mcCollptr) { // Convert event record to format readable by tauola interface - TauolaHepMCEvent * t_event = new TauolaHepMCEvent(*itr); + auto t_event = new Tauolapp::TauolaHepMCEvent(evt); #ifdef HEPMC3 //move to GeV