From 1f59b0bcb47bd12493c08e48fa44e0ae07e4ad0a Mon Sep 17 00:00:00 2001 From: Emily Anne Thompson <emily.anne.thompson@cern.ch> Date: Tue, 1 Dec 2020 10:38:10 +0100 Subject: [PATCH] Migrate DVMissingETFilterTool to use DataHandles --- .../DVMissingETFilterTool.h | 12 +++++++---- .../src/DVMissingETFilterTool.cxx | 20 +++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/DVMissingETFilterTool.h b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/DVMissingETFilterTool.h index e14b9d0f98f5..57043cc9f931 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/DVMissingETFilterTool.h +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/DVMissingETFilterTool.h @@ -16,6 +16,9 @@ // DerivationFramework includes #include "DerivationFrameworkInterfaces/ISkimmingTool.h" +#include "xAODMissingET/MissingETContainer.h" +#include "xAODJet/JetContainer.h" +#include "StoreGate/ReadHandleKey.h" namespace DerivationFramework { @@ -43,15 +46,16 @@ namespace DerivationFramework { virtual bool eventPassesFilter() const; private: - mutable unsigned int m_ntot; - mutable unsigned int m_npass; - std::string m_metSGKey; + mutable std::atomic<unsigned int> m_ntot; + mutable std::atomic<unsigned int> m_npass; + SG::ReadHandleKey<xAOD::MissingETContainer> m_metSGKey { this, "METContainerKey", "MET_LocHadTopo", ""}; double m_metCut; double m_jetPtCut; bool m_applyDeltaPhiCut; double m_deltaPhiCut; - std::string m_jetSGKey; // only needed if we want to cut on dphi(jet,MET) + SG::ReadHandleKey<xAOD::JetContainer> m_jetSGKey + { this, "JetContainerKey", "AntiKt4LCTopoJets", ""}; // only needed if we want to cut on dphi(jet, MET) }; diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/DVMissingETFilterTool.cxx b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/DVMissingETFilterTool.cxx index f619f5e850f4..5c864917f331 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/DVMissingETFilterTool.cxx +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/DVMissingETFilterTool.cxx @@ -9,8 +9,6 @@ #include "LongLivedParticleDPDMaker/DVMissingETFilterTool.h" #include <vector> #include <string> -#include "xAODMissingET/MissingETContainer.h" -#include "xAODJet/JetContainer.h" // Constructor DerivationFramework::DVMissingETFilterTool::DVMissingETFilterTool( const std::string& t, @@ -19,20 +17,16 @@ DerivationFramework::DVMissingETFilterTool::DVMissingETFilterTool( const std::st AthAlgTool(t,n,p), m_ntot(0), m_npass(0), - m_metSGKey("MET_LocHadTopo"), m_metCut(50000.0), m_jetPtCut(50000.0), m_applyDeltaPhiCut(false), - m_deltaPhiCut(2.), - m_jetSGKey("AntiKt4LCTopoJets") + m_deltaPhiCut(2.) { declareInterface<DerivationFramework::ISkimmingTool>(this); - declareProperty("METContainerKey", m_metSGKey); declareProperty("METCut", m_metCut); declareProperty("JetPtCut", m_jetPtCut); declareProperty("applyDeltaPhiCut", m_applyDeltaPhiCut); declareProperty("DeltaPhiCut", m_deltaPhiCut); - declareProperty("JetContainerKey", m_jetSGKey); } // Destructor @@ -43,6 +37,8 @@ DerivationFramework::DVMissingETFilterTool::~DVMissingETFilterTool() { StatusCode DerivationFramework::DVMissingETFilterTool::initialize() { ATH_MSG_VERBOSE("initialize() ..."); + ATH_CHECK(m_metSGKey.initialize()); + ATH_CHECK(m_jetSGKey.initialize()); return StatusCode::SUCCESS; } StatusCode DerivationFramework::DVMissingETFilterTool::finalize() @@ -57,9 +53,8 @@ bool DerivationFramework::DVMissingETFilterTool::eventPassesFilter() const { ++m_ntot; - const xAOD::MissingETContainer* metContainer(0); - StatusCode sc=evtStore()->retrieve(metContainer,m_metSGKey); - if( sc.isFailure() || !metContainer ) { + SG::ReadHandle<xAOD::MissingETContainer> metContainer(m_metSGKey); + if( !metContainer.isValid() ) { msg(MSG::WARNING) << "No MET container found, will skip this event" << endmsg; return false; } @@ -74,9 +69,8 @@ bool DerivationFramework::DVMissingETFilterTool::eventPassesFilter() const if (m_applyDeltaPhiCut) { double phiMET=metContainer->at(0)->phi(); - const xAOD::JetContainer* jetContainer(0); - StatusCode sc=evtStore()->retrieve(jetContainer,m_jetSGKey); - if( sc.isFailure() || !jetContainer ) { + SG::ReadHandle<xAOD::JetContainer> jetContainer(m_jetSGKey); + if( !jetContainer.isValid() ) { msg(MSG::WARNING) << "No jet container found, will skip this event" << endmsg; return false; } -- GitLab