diff --git a/Generators/Tauolapp_i/CMakeLists.txt b/Generators/Tauolapp_i/CMakeLists.txt index 1652ce9c2afe716c4a5456874e1eba2c0f854223..a51c2d944cb0f2cb960f5b4324538f09a48b92e0 100644 --- a/Generators/Tauolapp_i/CMakeLists.txt +++ b/Generators/Tauolapp_i/CMakeLists.txt @@ -8,12 +8,19 @@ atlas_subdir( Tauolapp_i ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps + Control/AthenaKernel Database/AthenaPOOL/AthenaPoolUtilities Event/EventInfo GaudiKernel Generators/GeneratorObjects ) +# Set the version of Tauolapp to use: +set( TAUOLAPP_VERSION 1.1.6 ) +set( TAUOLAPP_ROOT + ${LCG_RELEASE_DIR}/MCGenerators/tauola++/${TAUOLAPP_VERSION}/${ATLAS_PLATFORM} ) + # External dependencies: +find_package( CLHEP ) find_package( HepMC ) find_package( Tauolapp ) @@ -21,8 +28,8 @@ find_package( Tauolapp ) atlas_add_component( Tauolapp_i src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${TAUOLAPP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} - LINK_LIBRARIES ${TAUOLAPP_LIBRARIES} ${HEPMC_LIBRARIES} AthenaBaseComps AthenaPoolUtilities EventInfo GaudiKernel GeneratorObjects ) + INCLUDE_DIRS ${TAUOLAPP_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} + LINK_LIBRARIES ${TAUOLAPP_LIBRARIES} ${HEPMC_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps AthenaPoolUtilities EventInfo GaudiKernel GeneratorObjects ) # Install files from the package: atlas_install_headers( Tauolapp_i ) diff --git a/Generators/Tauolapp_i/Tauolapp_i/TauolaAlg.h b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h similarity index 69% rename from Generators/Tauolapp_i/Tauolapp_i/TauolaAlg.h rename to Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h index 1acb6a87a644cb6e6f48896af5493adfe26279f7..32023286aebab92376b8c8c47a235afb24840f69 100644 --- a/Generators/Tauolapp_i/Tauolapp_i/TauolaAlg.h +++ b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h @@ -2,8 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef TAUOLAALG_H -#define TAUOLAALG_H + +#ifndef TAUOLAPP_H +#define TAUOLAPP_H #include "AthenaBaseComps/AthAlgorithm.h" #include "GaudiKernel/ServiceHandle.h" @@ -21,15 +22,17 @@ 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 TauolaAlg : public AthAlgorithm { +class TauolaPP : public AthAlgorithm { public: /// Constructor - TauolaAlg (const std::string& name, ISvcLocator* pSvcLocator); + TauolaPP (const std::string& name, ISvcLocator* pSvcLocator); /// Initialization of Tauola++ and setting of JO configurables StatusCode initialize(); @@ -55,6 +58,21 @@ private: /// TAUOLA decay mode of particles with opposite charge as "decay_particle" int m_decay_mode_opp; + /// tau mass to be taken by TAUOLA + double m_tau_mass; + + // TAUOLA switch for spin effects + bool m_spin_correlation; + + // TAUOLA switch for radiative corrections for leptonic tau decays + bool m_setRadiation; + + // TAUOLA cut-off for radiative corrections + double m_setRadiationCutOff; + + static IAtRndmGenSvc* &atRndmGenSvc(); + static std::string &tauolapp_stream(); + }; #endif diff --git a/Generators/Tauolapp_i/cmt/requirements b/Generators/Tauolapp_i/cmt/requirements index 080a11737e6d89e140c8f2a160f3f531af18ab2d..359ade5d6f65019377587f6f1c1f139213b0a68c 100644 --- a/Generators/Tauolapp_i/cmt/requirements +++ b/Generators/Tauolapp_i/cmt/requirements @@ -12,6 +12,9 @@ use AtlasHepMC AtlasHepMC-* External private use Tauolapp Tauolapp-* External +use AtlasCLHEP AtlasCLHEP-* External +use AthenaKernel AthenaKernel-* Control + macro_append fflags "" Linux " -fno-automatic " end_private @@ -21,3 +24,4 @@ apply_pattern component_library apply_pattern declare_scripts files="*.sh" apply_pattern declare_joboptions files="*.py" + diff --git a/Generators/Tauolapp_i/src/TauolaAlg.cxx b/Generators/Tauolapp_i/src/TauolaAlg.cxx deleted file mode 100644 index 6276cfa3e8a87923ca35b3cf96cbd2200ecfe047..0000000000000000000000000000000000000000 --- a/Generators/Tauolapp_i/src/TauolaAlg.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "Tauolapp_i/TauolaAlg.h" - -// Tauola header files -#include "Tauola/Log.h" -#include "Tauola/Tauola.h" -#include "Tauola/TauolaHepMCEvent.h" -using namespace Tauolapp; - - -// Constructor -TauolaAlg::TauolaAlg(const std::string& name, ISvcLocator* pSvcLocator) - : AthAlgorithm(name, pSvcLocator) -{ - //Key to HepMC record - declareProperty("McEventKey", m_key="GEN_EVENT"); - - //TAUOLA configurables - //TAUOLA decay mode of particles with same/opposite charge as "decay_particle" - declareProperty("decay_mode_same", m_decay_mode_same=1); - declareProperty("decay_mode_opposite", m_decay_mode_opp=2); - declareProperty("decay_particle",m_decay_particle=15); -} - - -StatusCode TauolaAlg::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; - } - - // Setup and intialise Tauola Interface - Tauola::setSameParticleDecayMode(m_decay_mode_same); - Tauola::setOppositeParticleDecayMode(m_decay_mode_opp); - // etc.... see Tauola.h for the full list of configurables - // Note: some need to be set before (or after) calling Tauola::initialise(); - - // Tauola::setHiggsScalarPseudoscalarMixingAngle(atof(argv[5])); - // Tauola::setHiggsScalarPseudoscalarPDG(25); - - Tauola::initialise(); - // Tauola::setEtaKpi(0,0,0); // switches to decay eta K0_S and pi0 1/0 on/off. - // Tauola::spin_correlation.setAll(false); - - return StatusCode::SUCCESS; -} - - -StatusCode TauolaAlg::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; - } - - // Const_cast to make an event possible to update - McEventCollection* mcCollptr = const_cast<McEventCollection*>(mcCollptr_const); - - // Loop over all events in McEventCollection - McEventCollection::iterator itr; - for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { - - // Convert event record to format readable by tauola interface - TauolaHepMCEvent * t_event = new TauolaHepMCEvent(*itr); - - // t_event->getEvent()->print(); - - // remove tau decays first - t_event->undecayTaus(); - // decay taus - t_event->decayTaus(); - } - return StatusCode::SUCCESS; -} diff --git a/Generators/Tauolapp_i/src/TauolaPP.cxx b/Generators/Tauolapp_i/src/TauolaPP.cxx new file mode 100644 index 0000000000000000000000000000000000000000..02c25bf2f516de7e59e3daa8f79d217b17d558aa --- /dev/null +++ b/Generators/Tauolapp_i/src/TauolaPP.cxx @@ -0,0 +1,174 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "Tauolapp_i/TauolaPP.h" + +// Tauola header files +#include "Tauola/Log.h" +#include "Tauola/Tauola.h" +#include "Tauola/TauolaHepMCEvent.h" + +#include "Tauola/f_Variables.h" + +// for proper seeding +#include "CLHEP/Random/RandFlat.h" +#include "AthenaKernel/IAtRndmGenSvc.h" +//for Ranlux +#include "CLHEP/Random/Randomize.h" + +using namespace Tauolapp; +using namespace CLHEP; + +RanluxEngine theRanluxEngine(123456,1); + +double RanluxGenerator() +{ + std::cout<<" called Ranlux "<<std::endl; + return 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) +{ + //Key to HepMC record + declareProperty("McEventKey", m_key="GEN_EVENT"); + + //TAUOLA configurables + //TAUOLA decay mode of particles with same/opposite charge as "decay_particle" + declareProperty("decay_mode_same", m_decay_mode_same=1); + declareProperty("decay_mode_opposite", m_decay_mode_opp=2); + declareProperty("decay_particle",m_decay_particle=15); + declareProperty("tau_mass",m_tau_mass=1.77684); + declareProperty("spin_correlation",m_spin_correlation=true); + declareProperty("setRadiation",m_setRadiation=true); + declareProperty("setRadiationCutOff",m_setRadiationCutOff=0.01); +} + + +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; + } + + + + // 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()); + const long* sip = engine->getSeeds(); + long int si1 = sip[0]; + long int si2 = sip[1]; + + + atRndmGenSvc()->CreateStream(si1, si2, tauolapp_stream()); + tauolapp_stream() = "TAUOLAPP"; + + + + // Setup and intialise Tauola Interface + Tauola::setSameParticleDecayMode(m_decay_mode_same); + Tauola::setOppositeParticleDecayMode(m_decay_mode_opp); + // etc.... see Tauola.h for the full list of configurables + // Note: some need to be set before (or after) calling Tauola::initialize(); + + // Tauola::setHiggsScalarPseudoscalarMixingAngle(atof(argv[5])); + // Tauola::setHiggsScalarPseudoscalarPDG(25); + + Tauola::initialize(); + + Tauola::setEtaK0sPi(1,0,1); // switches to decay eta K0_S and pi0 1/0 on/off. + Tauola::spin_correlation.setAll(m_spin_correlation); + Tauola::setRadiation(m_setRadiation); + Tauola::setRadiationCutOff(m_setRadiationCutOff); + + //call RanLux generator for ++ part of Tauola + Tauola::setRandomGenerator(RanluxGenerator); + + //seeding tauola-fortran generator + Tauola::setSeed((int) si1,0,0); + + //seeding tauola++ generator + theRanluxEngine.setSeed(si2,1); + + //setting tau mass + parmas_.amtau=m_tau_mass; + + //cout<<"tauola tau mass "<<Tauola::getTauMass()<<endl; + + return StatusCode::SUCCESS; +} + + +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; + } + + HepRandomEngine* engine = atRndmGenSvc()->GetEngine(tauolapp_stream()); + const long* sip = engine->getSeeds(); + long int si1 = sip[0]; + long int si2 = sip[1]; + + + //seeding tauola-fortran generator + Tauola::setSeed((int) si1,0,0); + + //seeding tauola++ generator + theRanluxEngine.setSeed(si2,1); + + + // Const_cast to make an event possible to update + McEventCollection* mcCollptr = const_cast<McEventCollection*>(mcCollptr_const); + + // Loop over all events in McEventCollection + McEventCollection::iterator itr; + for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { + + // Convert event record to format readable by tauola interface + TauolaHepMCEvent * t_event = new TauolaHepMCEvent(*itr); + + // t_event->getEvent()->print(); + + // remove tau decays first + t_event->undecayTaus(); + // decay taus + t_event->decayTaus(); + } + return StatusCode::SUCCESS; +} diff --git a/Generators/Tauolapp_i/src/components/Tauolapp_i_entries.cxx b/Generators/Tauolapp_i/src/components/Tauolapp_i_entries.cxx index 2b5e4d162913ad46e6c96605283b15b430abd0ef..88647906b9e27b2dfe6cc425f71a5e87c38f12f4 100644 --- a/Generators/Tauolapp_i/src/components/Tauolapp_i_entries.cxx +++ b/Generators/Tauolapp_i/src/components/Tauolapp_i_entries.cxx @@ -1,7 +1,7 @@ -#include "Tauolapp_i/TauolaAlg.h" +#include "Tauolapp_i/TauolaPP.h" #include "GaudiKernel/DeclareFactoryEntries.h" -DECLARE_ALGORITHM_FACTORY( TauolaAlg ) +DECLARE_ALGORITHM_FACTORY( TauolaPP ) DECLARE_FACTORY_ENTRIES( Tauolapp_i ) { - DECLARE_ALGORITHM( TauolaAlg ) + DECLARE_ALGORITHM( TauolaPP ) }