From 33641b835f79d43cd99c50294bc4b5a46b59fefc Mon Sep 17 00:00:00 2001 From: Emily Anne Thompson <emily.anne.thompson@cern.ch> Date: Tue, 1 Dec 2020 10:43:52 +0100 Subject: [PATCH] Migrate HVJetMETFilterTool to use DataHandles --- .../HVJetMETFilterTool.h | 10 ++++++---- .../src/HVJetMETFilterTool.cxx | 15 ++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HVJetMETFilterTool.h b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HVJetMETFilterTool.h index 522ae0addeeb..20b66ddceeb0 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HVJetMETFilterTool.h +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HVJetMETFilterTool.h @@ -16,6 +16,8 @@ // DerivationFramework includes #include "DerivationFrameworkInterfaces/ISkimmingTool.h" +#include "xAODMissingET/MissingETContainer.h" +#include "StoreGate/ReadHandleKey.h" namespace DerivationFramework { @@ -43,12 +45,12 @@ 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_RefFinal", ""}; std::string m_metTerm; double m_metCut; - std::string m_jetSGKey; // only needed if we want to cut on dphi(jet,MET) }; diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HVJetMETFilterTool.cxx b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HVJetMETFilterTool.cxx index 16dd62db8b22..177a75b52e9d 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HVJetMETFilterTool.cxx +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HVJetMETFilterTool.cxx @@ -9,8 +9,6 @@ #include "LongLivedParticleDPDMaker/HVJetMETFilterTool.h" #include <vector> #include <string> -#include "xAODMissingET/MissingETContainer.h" -#include "xAODJet/JetContainer.h" // Constructor DerivationFramework::HVJetMETFilterTool::HVJetMETFilterTool( const std::string& t, @@ -19,16 +17,12 @@ DerivationFramework::HVJetMETFilterTool::HVJetMETFilterTool( const std::string& AthAlgTool(t,n,p), m_ntot(0), m_npass(0), - m_metSGKey("MET_RefFinal"), m_metTerm("Final"), - m_metCut(50000.0), - m_jetSGKey("AntiKt4LCTopoJets") + m_metCut(50000.0) { declareInterface<DerivationFramework::ISkimmingTool>(this); - declareProperty("METContainerKey", m_metSGKey); declareProperty("METTerm", m_metTerm); declareProperty("METCut", m_metCut); - declareProperty("JetContainerKey", m_jetSGKey); } // Destructor @@ -39,6 +33,7 @@ DerivationFramework::HVJetMETFilterTool::~HVJetMETFilterTool() { StatusCode DerivationFramework::HVJetMETFilterTool::initialize() { ATH_MSG_VERBOSE("initialize() ..."); + ATH_CHECK(m_metSGKey.initialize()); return StatusCode::SUCCESS; } StatusCode DerivationFramework::HVJetMETFilterTool::finalize() @@ -53,11 +48,9 @@ bool DerivationFramework::HVJetMETFilterTool::eventPassesFilter() const { ++m_ntot; - const xAOD::MissingETContainer* metContainer(0); const xAOD::MissingET* met(0); - StatusCode sc=evtStore()->retrieve(metContainer,m_metSGKey); - // met = (*metContainer)[m_metTerm]; - 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; } -- GitLab