From 9d89cb2dbcbde01c2e9505b268fcbdf24bccbfc0 Mon Sep 17 00:00:00 2001
From: John Kenneth Anders <john.kenneth.anders@cern.ch>
Date: Mon, 29 Jul 2019 11:51:32 +0000
Subject: [PATCH] Merge branch '21.0-atlasg-1450' into '21.0'

Backport ATLASG-1450 fix to 21.0

See merge request atlas/athena!25182

(cherry picked from commit bfd2c1adb1e6118beb6a705dd484195b99ed11fa)

6c5ff66c Backport ATLASG-1450 fix to 21.0
---
 .../DerivationFrameworkTools/CMakeLists.txt                | 3 ++-
 .../DerivationFrameworkTools/PrescaleTool.h                | 2 +-
 .../DerivationFrameworkTools/src/PrescaleTool.cxx          | 7 ++++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt
index c7e5fd910502..df403be80d35 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt
@@ -13,6 +13,7 @@ atlas_depends_on_subdirs( PUBLIC
                           PhysicsAnalysis/AnalysisCommon/PATCore
                           PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces
                           Trigger/TrigAnalysis/TrigDecisionTool
+                          Event/xAOD/xAODEventInfo
                           PRIVATE
                           Control/AthenaKernel
                           PhysicsAnalysis/CommonTools/ExpressionEvaluation )
@@ -25,7 +26,7 @@ atlas_add_library( DerivationFrameworkToolsLib
                    src/*.cxx
                    PUBLIC_HEADERS DerivationFrameworkTools
                    PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
-                   LINK_LIBRARIES AthenaBaseComps xAODBase GaudiKernel PATCoreLib TrigDecisionToolLib ExpressionEvaluationLib
+                   LINK_LIBRARIES AthenaBaseComps xAODBase GaudiKernel PATCoreLib TrigDecisionToolLib ExpressionEvaluationLib xAODEventInfo
                    PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel )
 
 atlas_add_component( DerivationFrameworkTools
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h
index 33dab780dcc3..b5db6fe041bc 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h
@@ -25,7 +25,7 @@ namespace DerivationFramework {
       virtual bool eventPassesFilter() const;
 
     private:
-      mutable int m_prescale, m_eventCounter;	
+      unsigned int m_prescale;	
   }; 
 }
 
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx
index f84499bf1eb4..49ac714aa739 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx
@@ -11,6 +11,7 @@
 // Use of ExpressionParsing to analyse a more complex string
 
 #include "DerivationFrameworkTools/PrescaleTool.h"
+#include "xAODEventInfo/EventInfo.h"
 
 namespace DerivationFramework {
 
@@ -31,7 +32,6 @@ namespace DerivationFramework {
       ATH_MSG_FATAL("Prescale of less than 1 makes no sense");
       return StatusCode::FAILURE;
     }
-    m_eventCounter = 0;
     return StatusCode::SUCCESS;
   }
 
@@ -42,9 +42,10 @@ namespace DerivationFramework {
 
   bool PrescaleTool::eventPassesFilter() const
   {
+    const xAOD::EventInfo* ei = 0;
+    CHECK( evtStore()->retrieve( ei , "EventInfo" ) );
     bool accept(false);
-    if (m_eventCounter % m_prescale == 0) accept = true;
-    ++m_eventCounter; 
+    if (ei->eventNumber() % m_prescale == 0) accept = true;
     return accept;
   }  
 
-- 
GitLab