From 82588f2538712a924e5afcaae7dd73806caa23b9 Mon Sep 17 00:00:00 2001 From: scott snyder <snyder@bnl.gov> Date: Sat, 20 Jul 2019 15:54:08 +0200 Subject: [PATCH] LWHists: Update for root 6.18 compatibility. If you do a SetBinError with an out-of-bounds bin, older versions of root would still create the error array in the histogram. LWHists had code to emulate this behavior. However, this changed as of root 6.18: if the bin is out of bounds, then the histogram is not changed. Adapt the LWHist code to match. --- Tools/LWHists/src/Flex1DHisto.icc | 7 ++++--- Tools/LWHists/src/Flex2DHisto.icc | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Tools/LWHists/src/Flex1DHisto.icc b/Tools/LWHists/src/Flex1DHisto.icc index 53bf0778b3a..95e25d97e35 100644 --- a/Tools/LWHists/src/Flex1DHisto.icc +++ b/Tools/LWHists/src/Flex1DHisto.icc @@ -1,7 +1,8 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ +#include "RVersion.h" //____________________________________________________________________ template <class T> @@ -306,7 +307,7 @@ template <class T> inline void Flex1DHisto<T>::setBinError(unsigned bin, const double& e) { if (bin>m_nbinsPlus1) {//as in root -#ifdef LW_STRICT_ROOT_BEHAVIOUR +#if defined(LW_STRICT_ROOT_BEHAVIOUR) && ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) m_flexArray.forcePretendSumWMode(); #endif return; @@ -320,7 +321,7 @@ template <class T> inline void Flex1DHisto<T>::setBinContentAndError(unsigned bin, const double& cont, const double& err ) { if (bin>m_nbinsPlus1) {//as in root -#ifdef LW_STRICT_ROOT_BEHAVIOUR +#if defined(LW_STRICT_ROOT_BEHAVIOUR) && ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) m_flexArray.forcePretendSumWMode(); #endif return; diff --git a/Tools/LWHists/src/Flex2DHisto.icc b/Tools/LWHists/src/Flex2DHisto.icc index 63a4b97deb4..604e7f9a5f8 100644 --- a/Tools/LWHists/src/Flex2DHisto.icc +++ b/Tools/LWHists/src/Flex2DHisto.icc @@ -1,7 +1,8 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ +#include "RVersion.h" //____________________________________________________________________ template <class T> @@ -505,7 +506,7 @@ inline void Flex2DHisto<T>::setBinError(unsigned binx, unsigned biny, const doub { //Weird root behaviour: For 2D version of setBinError we ignore rather than wrap: if (binx>m_nbinsxPlus1||biny>m_nbinsyPlus1) {//as in root -#ifdef LW_STRICT_ROOT_BEHAVIOUR +#if defined(LW_STRICT_ROOT_BEHAVIOUR) && ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) m_flexArray.forcePretendSumWMode(); #endif return; @@ -523,10 +524,12 @@ inline void Flex2DHisto<T>::setBinContentAndError(unsigned binx, unsigned biny, { if (binx>m_nbinsxPlus1||biny>m_nbinsyPlus1) { #ifdef LW_STRICT_ROOT_BEHAVIOUR - //Annoyingly enough, root has differnt behaviour for SetBinContent + //Annoyingly enough, root has different behaviour for SetBinContent //(wrap) and SetBinError (ignore) in this case: setBinContent(binx,biny,cont); +#if ROOT_VERSION_CODE < ROOT_VERSION(6,18,0) m_flexArray.forcePretendSumWMode(); +#endif #endif return; } -- GitLab