From ca2bc4b84637b28e16f2ee85c4b9cf88c7a3340c Mon Sep 17 00:00:00 2001 From: James Richard Catmore <james.catmore@cern.ch> Date: Mon, 3 Sep 2018 16:13:39 +0200 Subject: [PATCH] Improvement to DerivationFramework::PrescaleTool to give reproducible results when running in MP/MT ATLASG-1450 It was noted that the derivation framework PrescaleTool is not safe in a multi-process/thread environment due to its use of an event counter, such that the order of execution needs to be the same to get reproducible results. This MR changes the tool to use the event number rather than a counter, and since the event number is independent of the the order of processing, the outcome of the prescaler is now exactly reproducible and predictable. Former-commit-id: 34bb2bdbc7f28e74a954c5952ce0a7efb2fafc9b --- .../DerivationFrameworkTools/CMakeLists.txt | 3 ++- .../DerivationFrameworkTools/PrescaleTool.h | 2 +- .../DerivationFrameworkTools/src/PrescaleTool.cxx | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt index d0fbaa21d62c..15e683fde41a 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt @@ -14,6 +14,7 @@ atlas_depends_on_subdirs( PhysicsAnalysis/AnalysisCommon/PATCore PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces Trigger/TrigAnalysis/TrigDecisionTool + Event/xAOD/xAODEventInfo PRIVATE Control/AthenaKernel PhysicsAnalysis/CommonTools/ExpressionEvaluation ) @@ -26,7 +27,7 @@ atlas_add_library( DerivationFrameworkToolsLib DerivationFrameworkTools/*.h src/*.cxx PUBLIC_HEADERS DerivationFrameworkTools PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AthenaBaseComps xAODBase GaudiKernel PATCoreLib + LINK_LIBRARIES AthenaBaseComps xAODBase GaudiKernel PATCoreLib xAODEventInfo TrigDecisionToolLib ExpressionEvaluationLib DerivationFrameworkInterfacesLib PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} AthenaKernel ) 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 abb82535c52d..150742540a0a 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 { @@ -30,7 +31,6 @@ namespace DerivationFramework { ATH_MSG_FATAL("Prescale of less than 1 makes no sense"); return StatusCode::FAILURE; } - m_eventCounter = 0; return StatusCode::SUCCESS; } @@ -41,9 +41,11 @@ namespace DerivationFramework { bool PrescaleTool::eventPassesFilter() const { + const xAOD::EventInfo* ei = 0; + CHECK( evtStore()->retrieve( ei , "EventInfo" ) ); + uint32_t eventNumber ei->eventNumber(); bool accept(false); - if (m_eventCounter % m_prescale == 0) accept = true; - ++m_eventCounter; + if (eventNumber % m_prescale == 0) accept = true; return accept; } -- GitLab