From 5838a806879b3cc7c99ef5539f1196e4daf494c0 Mon Sep 17 00:00:00 2001
From: Michael Duehrssen <michael.duehrssen@cern.ch>
Date: Wed, 19 Aug 2020 13:49:33 +0200
Subject: [PATCH] Make calculation of Gauss ratio for the weight more robust

---
 Simulation/BeamEffects/src/BeamSpotReweightingAlg.cxx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Simulation/BeamEffects/src/BeamSpotReweightingAlg.cxx b/Simulation/BeamEffects/src/BeamSpotReweightingAlg.cxx
index f3c3d26c3dd..fc8a8c89f80 100644
--- a/Simulation/BeamEffects/src/BeamSpotReweightingAlg.cxx
+++ b/Simulation/BeamEffects/src/BeamSpotReweightingAlg.cxx
@@ -93,7 +93,8 @@ namespace Simulation
         if(std::abs(pullold)<10 && std::abs(pullnew)<10) {
           //Use Gauss probability ratio to calculate the weight:
           //weight=TMath::Gaus(z,0,35,true)/TMath::Gaus(z,0,42,true);
-          weight=m_input_beam_sigma_z/newsigmaz * std::exp(-pullnew*pullnew/2) / std::exp(-pullold*pullold/2);
+          //This can be simplified to:
+          weight=m_input_beam_sigma_z/newsigmaz * std::exp(0.5*(pullold*pullold - pullnew*pullnew));
         } else {
           ATH_MSG_WARNING("Large pull of beamspot: Beamspot z="<<beamz<<", z="<<z<<"; old sigma_z="<<m_input_beam_sigma_z<<", old pull="<<pullold<<"; new sigma_z="<<newsigmaz<<", new pull="<<pullnew<<" => use default weight="<<weight);
         }  
-- 
GitLab