From 21337bfb6f2a486bf92b02203cc4adce12e33027 Mon Sep 17 00:00:00 2001
From: John Derek Chapman <chapman@hep.phy.cam.ac.uk>
Date: Thu, 7 Jul 2016 14:16:03 +0200
Subject: [PATCH] python/BeamEffectsConfig.py (getVertexPositionFromFile)
 (getGenEventVertexPositioner): changes to get rid of pre/postExecs for Heavy
 Ion overlay jobs ATLASSIM-2950. Tagging BeamEffects-00-00-11
 (BeamEffects-00-00-11)

	* python/BeamEffectsConfig.py (getVertexPositionFromFile)
	(getGenEventVertexPositioner): changes to get rid of pre/postExecs
	for Heavy Ion overlay jobs ATLASSIM-2950.
	* Tagging BeamEffects-00-00-11

2016-07-07  John Chapman  <John.Chapman@cern.ch>

	* CMakeLists.txt, cmt/requirements - add missing installation of
	jobOptions. ATLASSIM-2395
	* Tagging BeamEffects-00-00-10

2016-06-29  John Chapman  <John.Chapman@cern.ch>

	* src/CrabKissingVertexPositioner.cxx (beamspotFunction)
	(generate): use std::fabs rather than abs. obo Daniele
	Ruini. ATLASSIM-2395
	* Tagging BeamEffects-00-00-09
---
 Simulation/BeamEffects/CMakeLists.txt            |  2 +-
 Simulation/BeamEffects/cmt/requirements          |  1 +
 .../BeamEffects/python/BeamEffectsConfig.py      |  9 ++++-----
 .../src/CrabKissingVertexPositioner.cxx          | 16 ++++++++--------
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Simulation/BeamEffects/CMakeLists.txt b/Simulation/BeamEffects/CMakeLists.txt
index d0fb8f997b4..e8c0b72dabd 100644
--- a/Simulation/BeamEffects/CMakeLists.txt
+++ b/Simulation/BeamEffects/CMakeLists.txt
@@ -40,5 +40,5 @@ atlas_add_component( BeamEffects
 # Install files from the package:
 atlas_install_headers( BeamEffects )
 atlas_install_python_modules( python/*.py )
-
+atlas_install_joboptions( share/*.py )
 
diff --git a/Simulation/BeamEffects/cmt/requirements b/Simulation/BeamEffects/cmt/requirements
index 91f97278da1..29bf4f61714 100644
--- a/Simulation/BeamEffects/cmt/requirements
+++ b/Simulation/BeamEffects/cmt/requirements
@@ -28,6 +28,7 @@ public
 library BeamEffects *.cxx components/*.cxx
 apply_pattern component_library
 apply_pattern declare_python_modules files="*.py"
+apply_pattern declare_joboptions files="*.py"
 
 private
 use TestTools                   TestTools-*              AtlasTest
diff --git a/Simulation/BeamEffects/python/BeamEffectsConfig.py b/Simulation/BeamEffects/python/BeamEffectsConfig.py
index 413dca78023..9d46df79c10 100644
--- a/Simulation/BeamEffects/python/BeamEffectsConfig.py
+++ b/Simulation/BeamEffects/python/BeamEffectsConfig.py
@@ -15,11 +15,14 @@ def getVertexPositionFromFile(name="VertexPositionFromFile", **kwargs):
     from G4AtlasApps.SimFlags import simFlags
     vtxPosFile = "vtx-pos.txt"
     if simFlags.VertexOverrideFile.statusOn:
-        vtxPosFile = str(simFlags.VertexOverrideEventFile())
+        vtxPosFile = str(simFlags.VertexOverrideFile())
     kwargs.setdefault("VertexPositionsFile"         , vtxPosFile)
     runAndEventNosFile ="run-evt-nums.txt"
     if simFlags.VertexOverrideEventFile.statusOn:
         runAndEventNosFile = str(simFlags.VertexOverrideEventFile())
+    if hasattr(simFlags, 'IsEventOverlayInputSim') and simFlags.IsEventOverlayInputSim():
+        from OverlayCommonAlgs.OverlayFlags import overlayFlags
+        runAndEventNosFile = (overlayFlags.EventIDTextFile())
     kwargs.setdefault("RunAndEventNumbersFile"      , runAndEventNosFile)
     return CfgMgr.Simulation__VertexPositionFromFile(name, **kwargs)
 
@@ -58,10 +61,6 @@ def getGenEventValidityChecker(name="GenEventValidityChecker", **kwargs):
 def getGenEventVertexPositioner(name="GenEventVertexPositioner", **kwargs):
     from G4AtlasApps.SimFlags import simFlags
     readVtxPosFromFile = simFlags.VertexOverrideFile.statusOn or simFlags.VertexOverrideEventFile.statusOn
-    if simFlags.ISFRun():
-        from  ISF_Config.ISF_jobProperties import ISF_Flags
-        readVtxPosFromFile = readVtxPosFromFile or ISF_Flags.VertexPositionFromFile()
-    #FIXME we can probably drop this ISF_Flag as it seems redundant
     if readVtxPosFromFile:
         kwargs.setdefault("VertexShifters"          , [ 'VertexPositionFromFile' ])
     elif simFlags.VertexFromCondDB():
diff --git a/Simulation/BeamEffects/src/CrabKissingVertexPositioner.cxx b/Simulation/BeamEffects/src/CrabKissingVertexPositioner.cxx
index 7ab2858d0f4..e3e48488a9e 100644
--- a/Simulation/BeamEffects/src/CrabKissingVertexPositioner.cxx
+++ b/Simulation/BeamEffects/src/CrabKissingVertexPositioner.cxx
@@ -113,8 +113,8 @@ StatusCode  Simulation::CrabKissingVertexPositioner::finalize()
 double Simulation::CrabKissingVertexPositioner::beamspotFunction(double displacement, double angle1, double angle2) const
 {
   if ( angle1<1e-10 ) angle1 = 1e-10; // to avoid divide_by_zero errors
-  double temp(1.0-std::abs(displacement)/m_bunchLength);
-  return sqrt(3.1415)/2 * erf(angle1*temp)/angle1 * exp( -pow(angle2*displacement/m_bunchLength, 2) ) * heaviside(temp);
+  double temp(1.0-std::fabs(displacement)/m_bunchLength);
+  return std::sqrt(3.1415)/2 * std::erf(angle1*temp)/angle1 * std::exp( -pow(angle2*displacement/m_bunchLength, 2) ) * heaviside(temp);
 }
 
 double Simulation::CrabKissingVertexPositioner::getDisplacement(double bunchSize, double angle1, double angle2) const
@@ -139,15 +139,15 @@ CLHEP::HepLorentzVector *Simulation::CrabKissingVertexPositioner::generate() con
   // necessary/preferable.
   double vertexX = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(0);
   double vertexY = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(1);
-  double piwinski_phi = abs(m_thetaX - m_alphaX) * m_bunchLength/sqrt(m_epsilon * m_betaStar);
-  double piwinski_psi = m_alphaPar * m_bunchLength / sqrt( m_epsilon * m_betaStar);
+  double piwinski_phi = std::fabs(m_thetaX - m_alphaX) * m_bunchLength/std::sqrt(m_epsilon * m_betaStar);
+  double piwinski_psi = m_alphaPar * m_bunchLength / std::sqrt( m_epsilon * m_betaStar);
   double vertexZ = 0;
   double vertexT = 0;
   // Time should be set in units of distance, the following methods generate c*t
   if ( m_bunchShape == BunchShape::GAUSS)
     {
-      double zWidth    = m_bunchLength / sqrt(2*(1+pow(piwinski_phi,2)));
-      double timeWidth = m_bunchLength / sqrt(2*(1+pow(piwinski_psi,2)));
+      double zWidth    = m_bunchLength / std::sqrt(2*(1+pow(piwinski_phi,2)));
+      double timeWidth = m_bunchLength / std::sqrt(2*(1+pow(piwinski_psi,2)));
       vertexZ = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , 0., zWidth);
       vertexT = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , 0., timeWidth);
     }
@@ -173,8 +173,8 @@ CLHEP::HepLorentzVector *Simulation::CrabKissingVertexPositioner::generate() con
   const double tx = tan( m_beamCondSvc->beamTilt(1) );
   const double ty = tan( m_beamCondSvc->beamTilt(0) );
 
-  const double sqrt_abc = sqrt(1. + tx*tx + ty*ty);
-  const double sqrt_fgh = sqrt(1. + ty*ty);
+  const double sqrt_abc = std::sqrt(1. + tx*tx + ty*ty);
+  const double sqrt_fgh = std::sqrt(1. + ty*ty);
 
   const double a = ty/sqrt_abc;
   const double b = tx/sqrt_abc;
-- 
GitLab