diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/CMakeLists.txt index c7e5fd910502b1a5d47062e170b74efeed676261..df403be80d351bd5563d3c5dbdec3d8157549252 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 33dab780dcc32f41834af74e74960a35a4df9d89..f6f4417db37ebea0ac2aecb4f1a206f4020704b1 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/DerivationFrameworkTools/PrescaleTool.h @@ -13,6 +13,7 @@ #include "AthenaBaseComps/AthAlgTool.h" #include "DerivationFrameworkInterfaces/ISkimmingTool.h" +#include "xAODEventInfo/EventInfo.h" namespace DerivationFramework { @@ -25,7 +26,7 @@ namespace DerivationFramework { virtual bool eventPassesFilter() const; private: - mutable int m_prescale, m_eventCounter; + Gaudi::Property<unsigned int> m_prescale {this, "Prescale", 1}; }; } diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx index f84499bf1eb480a773c79d753daf44139b2d2b78..2f73a533a0fa0ff86cb8743a17e16484e30d43be 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTools/src/PrescaleTool.cxx @@ -11,27 +11,24 @@ // Use of ExpressionParsing to analyse a more complex string #include "DerivationFrameworkTools/PrescaleTool.h" +#include "xAODEventInfo/EventInfo.h" namespace DerivationFramework { PrescaleTool::PrescaleTool(const std::string& t, const std::string& n, const IInterface* p) : - AthAlgTool(t,n,p), - m_prescale(1), - m_eventCounter(0) + AthAlgTool(t,n,p) { declareInterface<DerivationFramework::ISkimmingTool>(this); - declareProperty("Prescale", m_prescale); } StatusCode PrescaleTool::initialize() { - if (m_prescale < 1) { + if (m_prescale < 1u) { ATH_MSG_FATAL("Prescale of less than 1 makes no sense"); return StatusCode::FAILURE; } - m_eventCounter = 0; return StatusCode::SUCCESS; } @@ -42,10 +39,7 @@ namespace DerivationFramework { bool PrescaleTool::eventPassesFilter() const { - bool accept(false); - if (m_eventCounter % m_prescale == 0) accept = true; - ++m_eventCounter; - return accept; + return (Gaudi::Hive::currentContext().eventID().event_number() % m_prescale == 0); } }