From d744c5dc55e58dc7ed9cfb06823f3c8bceb34ded Mon Sep 17 00:00:00 2001
From: "Ewelina.Maria.Lobodzinska" <ewelina.maria.lobodzinska@cern.ch>
Date: Tue, 12 Sep 2017 11:10:12 +0200
Subject: [PATCH] update Tauolapp to version 1.1.6 update Tauolapp_i to SVN
 version 01-01-06-01 update Starlight to SVN version -00-01-03 update QGSJet_i
 to SVN version -00-00-08

---
 Generators/QGSJet_i/src/QGSJet.cxx            |  15 +-
 .../Starlight_i/Starlight_i/Starlight_i.h     |   4 -
 Generators/Starlight_i/src/Starlight_i.cxx    |   4 -
 Generators/Tauolapp_i/CMakeLists.txt          |  11 +-
 Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h   |  74 ++++++++
 Generators/Tauolapp_i/src/TauolaPP.cxx        | 170 ++++++++++++++++++
 .../src/components/Tauolapp_i_entries.cxx     |   6 +-
 .../src/TrackRecordGenerator.cxx              |   4 -
 Projects/Athena/externals/Tauolapp.cmake      |   2 +-
 9 files changed, 265 insertions(+), 25 deletions(-)
 create mode 100644 Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h
 create mode 100644 Generators/Tauolapp_i/src/TauolaPP.cxx

diff --git a/Generators/QGSJet_i/src/QGSJet.cxx b/Generators/QGSJet_i/src/QGSJet.cxx
index 6235bc897ea0..48e52669b18a 100644
--- a/Generators/QGSJet_i/src/QGSJet.cxx
+++ b/Generators/QGSJet_i/src/QGSJet.cxx
@@ -1,7 +1,3 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
 // ---------------------------------------------------------------------- 
 // Generators/QGSJet.cxx
 //  
@@ -206,11 +202,15 @@ StatusCode QGSJet::genInitialize()
   long int si1 = sip[0];
   long int si2 = sip[1];
 
-  int iSeed = si1;     // FIXME ?
+  // eA
+
+  std::cout << "eA seed: " << si1 << " " << si2 << std::endl; 
+
+  int iSeed = si1%1000000000;     // FIXME ?
 
   // set up initial values
 
-  //  std::cout << "parameters " << m_nEvents << " " << iSeed << " " << m_beamMomentum << " " << m_targetMomentum << " " << m_primaryParticle << " " << m_targetParticle << " " << m_model << " " << m_itab << " " << m_ilheout << " " <<  m_lheout.c_str()<< " " <<  m_paramFile.c_str() << std::endl;
+  std::cout << "parameters " << m_nEvents << " " << iSeed << " " << m_beamMomentum << " " << m_targetMomentum << " " << m_primaryParticle << " " << m_targetParticle << " " << m_model << " " << m_itab << " " << m_ilheout << " " <<  m_lheout.c_str()<< " " <<  m_paramFile.c_str() << std::endl;
 
   crmc_set_f_(m_nEvents, iSeed, m_beamMomentum, m_targetMomentum, m_primaryParticle, m_targetParticle, m_model, m_itab, m_ilheout,  m_paramFile.c_str() ); 
 
@@ -243,6 +243,8 @@ StatusCode QGSJet::callGenerator()
     // save the random number seeds in the event
     CLHEP::HepRandomEngine* engine = p_AtRndmGenSvcQGSJet->GetEngine( qgsjet_rndm_stream );
    const long *s = engine->getSeeds();
+
+   std:: cout << "eA seed s : " << s[0] << " " << s[1] << std::endl;
   
    m_seeds.clear();
    m_seeds.push_back(s[0]);
@@ -327,7 +329,6 @@ StatusCode QGSJet::fillEvt( HepMC::GenEvent* evt )
   hepio.fill_next_event(evt);
   // evt->print();
  
-
   evt->set_random_states( m_seeds );
 
   evt->weights().push_back(1.0); 
diff --git a/Generators/Starlight_i/Starlight_i/Starlight_i.h b/Generators/Starlight_i/Starlight_i/Starlight_i.h
index 5182ba531332..9085363156fa 100644
--- a/Generators/Starlight_i/Starlight_i/Starlight_i.h
+++ b/Generators/Starlight_i/Starlight_i/Starlight_i.h
@@ -1,7 +1,3 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
 // --------------------------------------------------
 // 
 // File:  Generators/Starlight_i.h
diff --git a/Generators/Starlight_i/src/Starlight_i.cxx b/Generators/Starlight_i/src/Starlight_i.cxx
index be943b7101cf..dcc0862caf2e 100644
--- a/Generators/Starlight_i/src/Starlight_i.cxx
+++ b/Generators/Starlight_i/src/Starlight_i.cxx
@@ -1,7 +1,3 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
 // ------------------------------------------------------------- 
 // Generators/Starlight_i.cxx Description: Allows the user
 // to generate Starlight events and store the result in the
diff --git a/Generators/Tauolapp_i/CMakeLists.txt b/Generators/Tauolapp_i/CMakeLists.txt
index 1652ce9c2afe..b0d43aed2d20 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/TauolaPP.h b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h
new file mode 100644
index 000000000000..a5c3988ace7b
--- /dev/null
+++ b/Generators/Tauolapp_i/Tauolapp_i/TauolaPP.h
@@ -0,0 +1,74 @@
+
+#ifndef TAUOLAPP_H
+#define TAUOLAPP_H
+
+#include "AthenaBaseComps/AthAlgorithm.h"
+#include "GaudiKernel/ServiceHandle.h"
+
+
+#include "HepMC/GenEvent.h"
+#include "HepMC/GenVertex.h"
+
+#include "GaudiKernel/IPartPropSvc.h"
+
+#include "AthenaPoolUtilities/AthenaAttributeList.h"
+#include "EventInfo/EventInfo.h"
+#include "EventInfo/EventID.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 {
+public:
+
+  /// Constructor
+  TauolaPP (const std::string& name, ISvcLocator* pSvcLocator);
+
+  /// Initialization of Tauola++ and setting of JO configurables
+  StatusCode initialize();
+
+  /// Pass each event in the McEventCollection to Tauola to (re)decay the taus
+  StatusCode execute();
+
+
+private:
+
+  /// Event record container key
+  std::string m_key;
+
+  /// @name Variables used to configure Tauola
+  //@{
+
+  /// PDG ID of particle to study
+   int m_decay_particle;
+
+  /// TAUOLA decay mode of particles with same charge as "decay_particle"
+  int m_decay_mode_same;
+
+  /// 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/src/TauolaPP.cxx b/Generators/Tauolapp_i/src/TauolaPP.cxx
new file mode 100644
index 000000000000..df06f21fda67
--- /dev/null
+++ b/Generators/Tauolapp_i/src/TauolaPP.cxx
@@ -0,0 +1,170 @@
+#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 2b5e4d162913..88647906b9e2 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 )
 }
diff --git a/Generators/TrackRecordGenerator/src/TrackRecordGenerator.cxx b/Generators/TrackRecordGenerator/src/TrackRecordGenerator.cxx
index 9cf1bf91ad5e..96bfaa1f2ce9 100644
--- a/Generators/TrackRecordGenerator/src/TrackRecordGenerator.cxx
+++ b/Generators/TrackRecordGenerator/src/TrackRecordGenerator.cxx
@@ -1,7 +1,3 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
 // -------------------------------------------------------------
 // File: TrackRecordGenerator/TrackRecordGenerator.cxx
 //   Mostly adopted from the cosmic generator
diff --git a/Projects/Athena/externals/Tauolapp.cmake b/Projects/Athena/externals/Tauolapp.cmake
index 96321e2ac314..f7ccd72db65f 100644
--- a/Projects/Athena/externals/Tauolapp.cmake
+++ b/Projects/Athena/externals/Tauolapp.cmake
@@ -2,6 +2,6 @@
 # File specifying the location of Tauola++ to use.
 #
 
-set( TAUOLAPP_VERSION 1.1.1a )
+set( TAUOLAPP_VERSION 1.1.6 )
 set( TAUOLAPP_ROOT
    ${LCG_RELEASE_DIR}/MCGenerators/tauola++/${TAUOLAPP_VERSION}/${LCG_PLATFORM} )
-- 
GitLab