diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HnlSkimmingTool.h b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HnlSkimmingTool.h index 187e4f3cb51b4f18a7d31869fb5a4322043cdcb6..ffb6beb7c63ae0434bdb315ac01c6801e90db943 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HnlSkimmingTool.h +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/HnlSkimmingTool.h @@ -17,6 +17,7 @@ #include "TrigDecisionTool/TrigDecisionTool.h" #include "xAODEgamma/ElectronContainer.h" #include "xAODMuon/MuonContainer.h" +#include "StoreGate/ReadHandleKey.h" #include <string> #include <vector> @@ -50,7 +51,7 @@ namespace DerivationFramework { std::vector<std::string> m_triggers; // Muons - std::string m_muonSGKey; + SG::ReadHandleKey<xAOD::MuonContainer> m_muonSGKey { this, "MuonContainerKey", "Muons", ""}; // Prompt muons float m_mu1PtMin; float m_mu1AbsEtaMax; @@ -68,7 +69,7 @@ namespace DerivationFramework { float m_mu2d0Min; // Electrons - std::string m_electronSGKey; + SG::ReadHandleKey<xAOD::ElectronContainer> m_electronSGKey { this, "ElectronContainerKey", "Electrons", ""}; // Prompt electrons float m_el1PtMin; float m_el1AbsEtaMax; @@ -86,13 +87,17 @@ namespace DerivationFramework { float m_dPhiMin; - void getPromptMuonCandidates(const xAOD::MuonContainer* muons, + //void getPromptMuonCandidates(const xAOD::MuonContainer* muons, + void getPromptMuonCandidates(SG::ReadHandle<DataVector<xAOD::Muon_v1>>& muons, std::vector<const xAOD::Muon*>& promptMuonCandidates) const; - void getDisplacedMuonCandidates(const xAOD::MuonContainer* muons, + //void getDisplacedMuonCandidates(const xAOD::MuonContainer* muons, + void getDisplacedMuonCandidates(SG::ReadHandle<DataVector<xAOD::Muon_v1>>& muons, std::vector<const xAOD::Muon*>& displacedMuonCandidates) const; - void getPromptElectronCandidates(const xAOD::ElectronContainer* electrons, + //void getPromptElectronCandidates(const xAOD::ElectronContainer* electrons, + void getPromptElectronCandidates(SG::ReadHandle<DataVector<xAOD::Electron_v1>>& electrons, std::vector<const xAOD::Electron*>& promptElectronCandidates) const; - void getDisplacedElectronCandidates(const xAOD::ElectronContainer* electrons, + //void getDisplacedElectronCandidates(const xAOD::ElectronContainer* electrons, + void getDisplacedElectronCandidates(SG::ReadHandle<DataVector<xAOD::Electron_v1>>& electrons, std::vector<const xAOD::Electron*>& displacedElectronCandidates) const; }; diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HnlSkimmingTool.cxx b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HnlSkimmingTool.cxx index e699c5d6e4a81b57cf892f411bbd1d86bc2261c5..74b5de6af183871b624b0533c5016a9ba2351ec4 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HnlSkimmingTool.cxx +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/HnlSkimmingTool.cxx @@ -30,8 +30,6 @@ DerivationFramework::HnlSkimmingTool::HnlSkimmingTool(const std::string& t, declareProperty("TrigDecisionTool", m_trigDecisionTool, "Tool to access the trigger decision"); declareProperty("Triggers", m_triggers=std::vector<std::string>()); - // Muons - declareProperty("MuonContainerKey", m_muonSGKey="Muons"); // Prompt muons declareProperty("Mu1PtMin", m_mu1PtMin=-1.); declareProperty("Mu1AbsEtaMax", m_mu1AbsEtaMax=2.5); @@ -48,8 +46,6 @@ DerivationFramework::HnlSkimmingTool::HnlSkimmingTool(const std::string& t, declareProperty("Mu2IsoCut", m_mu2IsoCut=1.); declareProperty("Mu2d0Min", m_mu2d0Min=0.1, "Unit is mm"); - // Electrons - declareProperty("ElectronContainerKey", m_electronSGKey="Electrons"); // Prompt electrons declareProperty("El1PtMin", m_el1PtMin=-1.); declareProperty("El1AbsEtaMax", m_el1AbsEtaMax=2.5); @@ -75,6 +71,8 @@ StatusCode DerivationFramework::HnlSkimmingTool::initialize() ATH_CHECK(m_trigDecisionTool.retrieve()); ATH_MSG_INFO("Retrieved tool: " << m_trigDecisionTool); + ATH_CHECK(m_muonSGKey.initialize()); + ATH_CHECK(m_electronSGKey.initialize()); return StatusCode::SUCCESS; } @@ -123,20 +121,18 @@ bool DerivationFramework::HnlSkimmingTool::eventPassesFilter() const if (not passedTrigger) return acceptEvent; // Retrieve muon container - const xAOD::MuonContainer* muons = nullptr; + SG::ReadHandle<xAOD::MuonContainer> muons(m_muonSGKey); if (m_isPromptMuon or m_isDisplacedMuon) { - StatusCode sc = evtStore()->retrieve(muons, m_muonSGKey); - if (sc.isFailure()) { + if( !muons.isValid() ) { ATH_MSG_FATAL("No muon collection with name " << m_muonSGKey << " found in StoreGate!"); return acceptEvent; } } // Retrieve electron container - const xAOD::ElectronContainer* electrons = nullptr; + SG::ReadHandle<xAOD::ElectronContainer> electrons(m_electronSGKey); if ((not m_isPromptMuon) or (not m_isDisplacedMuon)) { - StatusCode sc = evtStore()->retrieve(electrons, m_electronSGKey); - if (sc.isFailure()) { + if( !electrons.isValid() ) { ATH_MSG_FATAL("No electron collection with name " << m_electronSGKey << " found in StoreGate!"); return acceptEvent; } @@ -231,7 +227,8 @@ bool DerivationFramework::HnlSkimmingTool::eventPassesFilter() const return acceptEvent; } -void DerivationFramework::HnlSkimmingTool::getPromptMuonCandidates(const xAOD::MuonContainer* muons, +//void DerivationFramework::HnlSkimmingTool::getPromptMuonCandidates(const xAOD::MuonContainer* muons, +void DerivationFramework::HnlSkimmingTool::getPromptMuonCandidates(SG::ReadHandle<DataVector<xAOD::Muon_v1>>& muons, std::vector<const xAOD::Muon*>& promptMuonCandidates) const { for (const xAOD::Muon* muon : *muons) { @@ -270,7 +267,8 @@ void DerivationFramework::HnlSkimmingTool::getPromptMuonCandidates(const xAOD::M } } -void DerivationFramework::HnlSkimmingTool::getDisplacedMuonCandidates(const xAOD::MuonContainer* muons, +//void DerivationFramework::HnlSkimmingTool::getDisplacedMuonCandidates(const xAOD::MuonContainer* muons, +void DerivationFramework::HnlSkimmingTool::getDisplacedMuonCandidates(SG::ReadHandle<DataVector<xAOD::Muon_v1>>& muons, std::vector<const xAOD::Muon*>& displacedMuonCandidates) const { for (const xAOD::Muon* muon : *muons) { @@ -321,7 +319,8 @@ void DerivationFramework::HnlSkimmingTool::getDisplacedMuonCandidates(const xAOD } } -void DerivationFramework::HnlSkimmingTool::getPromptElectronCandidates(const xAOD::ElectronContainer* electrons, +//void DerivationFramework::HnlSkimmingTool::getPromptElectronCandidates(const xAOD::ElectronContainer* electrons, +void DerivationFramework::HnlSkimmingTool::getPromptElectronCandidates(SG::ReadHandle<DataVector<xAOD::Electron_v1>>& electrons, std::vector<const xAOD::Electron*>& promptElectronCandidates) const { for (const xAOD::Electron* electron : *electrons) { @@ -351,7 +350,8 @@ void DerivationFramework::HnlSkimmingTool::getPromptElectronCandidates(const xAO } } -void DerivationFramework::HnlSkimmingTool::getDisplacedElectronCandidates(const xAOD::ElectronContainer* electrons, +//void DerivationFramework::HnlSkimmingTool::getDisplacedElectronCandidates(const xAOD::ElectronContainer* electrons, +void DerivationFramework::HnlSkimmingTool::getDisplacedElectronCandidates(SG::ReadHandle<DataVector<xAOD::Electron_v1>>& electrons, std::vector<const xAOD::Electron*>& displacedElectronCandidates) const { for (const xAOD::Electron* electron : *electrons) {