diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/KinkTrkZeeTagTool.h b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/KinkTrkZeeTagTool.h index a9e9b071f2272ec549d23354c706e8c62f2c55f7..00a8661131a884a52f19ba97ac59c889a437b88c 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/KinkTrkZeeTagTool.h +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/LongLivedParticleDPDMaker/KinkTrkZeeTagTool.h @@ -19,6 +19,9 @@ #include "xAODEgamma/ElectronContainer.h" #include "xAODCaloEvent/CaloClusterContainer.h" +#include "xAODMissingET/MissingETContainer.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" #include<string> #include<vector> @@ -59,12 +62,12 @@ namespace DerivationFramework { float m_trigMatchDeltaR; bool m_doTrigMatch; - std::string m_electronSGKey; + SG::ReadHandleKey<xAOD::ElectronContainer> m_electronSGKey { this, "ElectronContainerKey", "ElectronCollection", ""}; std::vector<std::string> m_electronIDKeys; float m_electronPtCut; float m_electronEtaMax; - std::string m_clusterSGKey; + SG::ReadHandleKey<xAOD::CaloClusterContainer> m_clusterSGKey { this, "ClusterContainerKey", "egammaClusters", ""}; float m_clusterEtCut; float m_clusterEtaMax; @@ -73,6 +76,8 @@ namespace DerivationFramework { float m_dPhiMax; std::string m_sgKeyPrefix; + //SG::WriteHandleKey< std::vector<float> > m_DiEleMassKey { this, "KinkTrkDiEleMass", "", "" }; + //SG::WriteHandleKey< std::vector<float> > m_ProbeEleEtKey { this, "KinkTrkProbeEleEt", "", "" }; }; diff --git a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/KinkTrkZeeTagTool.cxx b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/KinkTrkZeeTagTool.cxx index 44988ef6ca1de73702a2e60dcd05be9598390d10..e78503b258aed1c221f37877cbf91b2e93380536 100644 --- a/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/KinkTrkZeeTagTool.cxx +++ b/PhysicsAnalysis/SUSYPhys/LongLivedParticleDPDMaker/src/KinkTrkZeeTagTool.cxx @@ -8,8 +8,6 @@ // Author: Shimpei Yamamoto (shimpei.yamamoto@cern.ch) #include "LongLivedParticleDPDMaker/KinkTrkZeeTagTool.h" -#include "xAODTracking/TrackingPrimitives.h" -#include "xAODMissingET/MissingETContainer.h" #include <vector> #include <string> @@ -23,11 +21,9 @@ DerivationFramework::KinkTrkZeeTagTool::KinkTrkZeeTagTool(const std::string& t, m_trigNames(std::vector<std::string>()), m_trigMatchDeltaR(0.1), m_doTrigMatch(false), - m_electronSGKey("ElectronCollection"), m_electronIDKeys(std::vector<std::string>()), m_electronPtCut(0), m_electronEtaMax(9999), - m_clusterSGKey("egammaClusters"), m_clusterEtCut(0), m_clusterEtaMax(2.8), m_diEleMassLow(50.), @@ -41,16 +37,14 @@ DerivationFramework::KinkTrkZeeTagTool::KinkTrkZeeTagTool(const std::string& t, declareProperty("Triggers", m_trigNames); declareProperty("TriggerMatchDeltaR", m_trigMatchDeltaR); declareProperty("RequireTriggerMatch", m_doTrigMatch); - declareProperty("ElectronContainerKey", m_electronSGKey); declareProperty("ElectronIDKeys", m_electronIDKeys), declareProperty("ElectronPtMin", m_electronPtCut); declareProperty("ElectronEtaMax", m_electronEtaMax); - declareProperty("ClusterContainerKey", m_clusterSGKey); declareProperty("ClusterEtMin", m_clusterEtCut); declareProperty("ClusterEtaMax", m_clusterEtaMax); declareProperty("DiEleMassLow", m_diEleMassLow); declareProperty("DiEleMassHigh", m_diEleMassHigh); - declareProperty("DeltaPhiMax", m_dPhiMax); + declareProperty("DeltaPhiMax", m_dPhiMax); declareProperty("StoreGateKeyPrefix", m_sgKeyPrefix); } @@ -81,6 +75,11 @@ StatusCode DerivationFramework::KinkTrkZeeTagTool::initialize() ATH_MSG_INFO("TrgMatchTool retrived successfully"); } + ATH_CHECK(m_electronSGKey.initialize()); + ATH_CHECK(m_clusterSGKey.initialize()); + //ATH_CHECK(m_DiEleMassKey.initialize() ); + //ATH_CHECK(m_ProbeEleEtKey.initialize() ); + return StatusCode::SUCCESS; } @@ -96,15 +95,15 @@ StatusCode DerivationFramework::KinkTrkZeeTagTool::finalize() // Augmentation StatusCode DerivationFramework::KinkTrkZeeTagTool::addBranches() const { - std::vector<float> *diEleMass = new std::vector<float>(); - std::vector<float> *probeEleEt = new std::vector<float>(); - - const xAOD::ElectronContainer* electrons(0); - ATH_CHECK(evtStore()->retrieve(electrons, m_electronSGKey)); + SG::WriteHandle< std::vector<float> > diEleMass(m_sgKeyPrefix+"DiEleMass"); + ATH_CHECK(diEleMass.record(std::make_unique< std::vector<float> >())); - const xAOD::CaloClusterContainer* clusters(0); - ATH_CHECK(evtStore()->retrieve(clusters, m_clusterSGKey)); + SG::WriteHandle< std::vector<float> > probeEleEt(m_sgKeyPrefix+"ProbeEleEt"); + ATH_CHECK(probeEleEt.record(std::make_unique< std::vector<float> >())); + SG::ReadHandle<xAOD::ElectronContainer> electrons(m_electronSGKey); + SG::ReadHandle<xAOD::CaloClusterContainer> clusters(m_clusterSGKey); + for (const auto ele: *electrons) { if (!checkTagElectron(ele)) continue; for (const auto clu: *clusters) { @@ -115,25 +114,6 @@ StatusCode DerivationFramework::KinkTrkZeeTagTool::addBranches() const } } - // Writing to SG - std::string sgKey1(m_sgKeyPrefix+"DiEleMass"); - if (evtStore()->contains< float >(sgKey1)) { - ATH_MSG_ERROR("StoreGate key " << sgKey1 << "already exists."); - // avoid mem leak - delete probeEleEt; - delete diEleMass; - return StatusCode::FAILURE; - } - CHECK(evtStore()->record(diEleMass, sgKey1)); - - std::string sgKey2(m_sgKeyPrefix+"ProbeEleEt"); - if (evtStore()->contains< float >(sgKey2)) { - ATH_MSG_ERROR("StoreGate key " << sgKey2 << "already exists."); - delete probeEleEt; // avoid mem leak - return StatusCode::FAILURE; - } - CHECK(evtStore()->record(probeEleEt, sgKey2)); - return StatusCode::SUCCESS; }