diff --git a/Reconstruction/Jet/JetRecTools/JetRecTools/ChargedHadronSubtractionTool.h b/Reconstruction/Jet/JetRecTools/JetRecTools/ChargedHadronSubtractionTool.h index e7a2f6aab33508f3e374e83040de56cb360c1f01..1bf258f572c5c8a76c206fd498a1e1d17021d599 100644 --- a/Reconstruction/Jet/JetRecTools/JetRecTools/ChargedHadronSubtractionTool.h +++ b/Reconstruction/Jet/JetRecTools/JetRecTools/ChargedHadronSubtractionTool.h @@ -25,7 +25,7 @@ #include "xAODPFlow/FlowElementContainer.h" #include "AsgDataHandles/ReadHandleKey.h" - +#include "StoreGate/WriteDecorHandle.h" class ChargedHadronSubtractionTool : public JetConstituentModifierBase{ ASG_TOOL_CLASS(ChargedHadronSubtractionTool, IJetConstituentModifier) @@ -50,6 +50,9 @@ class ChargedHadronSubtractionTool : public JetConstituentModifierBase{ SG::ReadHandleKey<xAOD::VertexContainer> m_vertexContainer_key; SG::ReadHandleKey<jet::TrackVertexAssociation> m_trkVtxAssoc_key; + + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfomatchedToPVWriteDecorKey {this,"pfomatchedToPVWriteDecorKey","CHSParticleFlowObjects.matchedToPV", "Matched to PV"}; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_fematchedToPVWriteDecorKey {this,"fematchedToPVWriteDecorKey","CHSParticleFlowObjects.matchedToPV", "Matched to PV"}; }; #endif diff --git a/Reconstruction/Jet/JetRecTools/Root/ChargedHadronSubtractionTool.cxx b/Reconstruction/Jet/JetRecTools/Root/ChargedHadronSubtractionTool.cxx index 79a88c10cc147a661e680ca8931c07c0e7526182..84639a1a04a58dd04261aaf001e40942067104f3 100644 --- a/Reconstruction/Jet/JetRecTools/Root/ChargedHadronSubtractionTool.cxx +++ b/Reconstruction/Jet/JetRecTools/Root/ChargedHadronSubtractionTool.cxx @@ -34,6 +34,8 @@ StatusCode ChargedHadronSubtractionTool::initialize() { } else { ATH_CHECK( m_vertexContainer_key.initialize() ); } + if(m_inputType==xAOD::Type::ParticleFlow){ ATH_CHECK( m_pfomatchedToPVWriteDecorKey.initialize() );} + else if(m_inputType==xAOD::Type::FlowElement){ ATH_CHECK( m_fematchedToPVWriteDecorKey.initialize() );} return StatusCode::SUCCESS; } @@ -94,8 +96,8 @@ const xAOD::Vertex* ChargedHadronSubtractionTool::getPrimaryVertex() const { } StatusCode ChargedHadronSubtractionTool::matchToPrimaryVertex(xAOD::PFOContainer& cont) const { - const static SG::AuxElement::Accessor<char> PVMatchedAcc("matchedToPV"); - + SG::WriteDecorHandle<xAOD::PFOContainer, char> dec_matchedToPV (m_pfomatchedToPVWriteDecorKey); + // Use only one of TVA or PV const jet::TrackVertexAssociation* trkVtxAssoc = nullptr; const xAOD::Vertex* vtx = nullptr; @@ -150,14 +152,15 @@ StatusCode ChargedHadronSubtractionTool::matchToPrimaryVertex(xAOD::PFOContainer } } // TVA vs PV decision } - PVMatchedAcc(*ppfo) = matchedToPrimaryVertex; + dec_matchedToPV(*ppfo) = matchedToPrimaryVertex; } return StatusCode::SUCCESS; } StatusCode ChargedHadronSubtractionTool::matchToPrimaryVertex(xAOD::FlowElementContainer& cont) const { - const static SG::AuxElement::Accessor<char> PVMatchedAcc("matchedToPV"); + SG::WriteDecorHandle<xAOD::FlowElementContainer, char> dec_matchedToPV (m_fematchedToPVWriteDecorKey); + // Use only one of TVA or PV const jet::TrackVertexAssociation* trkVtxAssoc = nullptr; @@ -213,7 +216,7 @@ StatusCode ChargedHadronSubtractionTool::matchToPrimaryVertex(xAOD::FlowElementC } } // TVA vs PV decision } - PVMatchedAcc(*ppfo) = matchedToPrimaryVertex; + dec_matchedToPV(*ppfo) = matchedToPrimaryVertex; } return StatusCode::SUCCESS; diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h index 1aac914218e14aa4cf446d73f69532d7059af027..5b190257f880d6226b0514220b1206c4ece7ab12 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METEgammaAssociator.h @@ -20,6 +20,7 @@ #include "xAODEgamma/EgammaFwd.h" #include "StoreGate/ReadDecorHandle.h" +#include "StoreGate/WriteDecorHandle.h" #include <set> @@ -119,6 +120,17 @@ namespace met{ SG::ReadDecorHandleKey<xAOD::ElectronContainer> m_electronNeutralFEReadDecorKey{this,"electronNeutralFEReadDecorKey","", "Neutral FE links key"}; SG::ReadDecorHandleKey<xAOD::ElectronContainer> m_electronChargedFEReadDecorKey{this,"electronCargedFEReadDecorKey","", "Charged FE links key"}; + SG::ReadDecorHandleKey<xAOD::PFOContainer> m_pfomatchedToPVReadDecorKey{this,"pfomatchedToPVReadDecorKey","matchedToPV", "PFO matched to PV key"}; + SG::ReadDecorHandleKey<xAOD::FlowElementContainer> m_fematchedToPVReadDecorKey{this,"fematchedToPVReadDecorKey","matchedToPV", "FE matched to PV key"}; + + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracWriteDecorKey {this,"pfounmatchedFracWriteDecorKey","unmatchedFrac", "Unmatched fraction PFO decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracSumptWriteDecorKey {this,"pfounmatchedFracSumptWriteDecorKey","unmatchedFracSumpt", "Unmatched fraction sum pT PFO decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracPtWriteDecorKey {this,"pfounmatchedFracPtWriteDecorKey","unmatchedFracPt", "Unmatched fraction pT PFO decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracEWriteDecorKey {this,"pfounmatchedFracEWriteDecorKey","unmatchedFracE", "Unmatched fraction E PFO decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracEClusterPFOWriteDecorKey {this,"pfounmatchedFracEClusterPFOWriteDecorKey","unmatchedFracEClusterPFO", "Unmatched fraction ECluster decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedFracPtClusterPFOWriteDecorKey {this,"pfounmatchedFracPtClusterPFOWriteDecorKey","unmatchedFracPtClusterPFO", "Unmatched fraction PtCluster PFO decorator"}; + SG::WriteDecorHandleKey<xAOD::PFOContainer> m_pfounmatchedTotEMFracWriteDecorKey {this,"pfounmatchedTotEMFracWriteDecorKey","unmatchedTotEMFrac", "Unmatched total EM fraction PFO decorator"}; + bool m_usePFOElectronLinks; bool m_usePFOPhotonLinks; bool m_useFEElectronLinks; diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METSoftAssociator.h b/Reconstruction/MET/METReconstruction/METReconstruction/METSoftAssociator.h index d833630d07dfb8e40bdcb1fb91c0647c4caf101f..93d6797da5b6fe932b6fda15423d9b163c0a9d4f 100644 --- a/Reconstruction/MET/METReconstruction/METReconstruction/METSoftAssociator.h +++ b/Reconstruction/MET/METReconstruction/METReconstruction/METSoftAssociator.h @@ -17,6 +17,8 @@ // METReconstruction includes #include "METReconstruction/METAssociator.h" +#include "StoreGate/ReadDecorHandle.h" + namespace met{ class METSoftAssociator final : public METAssociator @@ -82,7 +84,8 @@ namespace met{ SG::ReadHandleKey<xAOD::CaloClusterContainer> m_lcmodclus_key; SG::ReadHandleKey<xAOD::CaloClusterContainer> m_emmodclus_key; - + SG::ReadDecorHandleKey<xAOD::PFOContainer> m_pfomatchedToPVReadDecorKey{this,"pfomatchedToPVReadDecorKey","matchedToPV", "PFO matched to PV key"}; + SG::ReadDecorHandleKey<xAOD::FlowElementContainer> m_fematchedToPVReadDecorKey{this,"fematchedToPVReadDecorKey","matchedToPV", "FE matched to PV key"}; }; } diff --git a/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx index 47f0c3fbb00c5fdf78382e9162ac680ef3092a6d..3936945f80456fc54da4b4a8ee094ce8e041a253 100644 --- a/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METEgammaAssociator.cxx @@ -75,7 +75,34 @@ namespace met { ATH_MSG_WARNING( "Invalid topocluster match method configured!" ); return StatusCode::FAILURE; } - + if(m_usePFOElectronLinks || m_usePFOPhotonLinks || m_usePFOLinks){ + if(!m_fecollKey.key().empty()){ + m_fematchedToPVReadDecorKey=m_pfcollKey.key()+"."+m_fematchedToPVReadDecorKey.key(); + ATH_CHECK( m_fematchedToPVReadDecorKey.initialize() ); + } + else if(m_pflow){ + m_pfomatchedToPVReadDecorKey=m_pfcollKey.key()+"."+m_pfomatchedToPVReadDecorKey.key(); + ATH_CHECK( m_pfomatchedToPVReadDecorKey.initialize() ); + } + } + + if(m_checkUnmatched){ + // Prepend container name + m_pfounmatchedFracWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracWriteDecorKey.key(); + m_pfounmatchedFracPtWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracPtWriteDecorKey.key(); + m_pfounmatchedFracSumptWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracSumptWriteDecorKey.key(); + m_pfounmatchedFracEWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracEWriteDecorKey.key(); + m_pfounmatchedFracEClusterPFOWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracEClusterPFOWriteDecorKey.key(); + m_pfounmatchedFracPtClusterPFOWriteDecorKey=m_input_data_key+"."+m_pfounmatchedFracPtClusterPFOWriteDecorKey.key(); + m_pfounmatchedTotEMFracWriteDecorKey=m_input_data_key+"."+m_pfounmatchedTotEMFracWriteDecorKey.key(); + ATH_CHECK( m_pfounmatchedFracWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedFracSumptWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedFracPtWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedFracEWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedFracEClusterPFOWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedFracPtClusterPFOWriteDecorKey.initialize() ); + ATH_CHECK( m_pfounmatchedTotEMFracWriteDecorKey.initialize() ); + } return StatusCode::SUCCESS; } @@ -197,14 +224,13 @@ namespace met { cPFOLinks=chargedPFOReadDecorHandle(*eg); } - + SG::ReadDecorHandle<xAOD::PFOContainer, char> PVMatchedAcc(m_pfomatchedToPVReadDecorKey); // Charged PFOs for (PFOLink_t pfoLink : cPFOLinks) { if (pfoLink.isValid()){ const xAOD::PFO* pfo_init = *pfoLink; for (const auto pfo : *constits.pfoCont){ if (pfo->index() == pfo_init->index() && pfo->isCharged()){ //index-based match between JetETmiss and CHSParticleFlow collections - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if( pfo->isCharged() && PVMatchedAcc(*pfo)&& ( !m_cleanChargedPFO || isGoodEoverP(pfo->track(0)) ) ) { ATH_MSG_DEBUG("Accept cPFO with pt " << pfo->pt() << ", e " << pfo->e() << ", eta " << pfo->eta() << ", phi " << pfo->phi() ); if (!m_checkUnmatched) {pfolist.push_back(pfo);} @@ -257,11 +283,11 @@ namespace met { // Preselect PFOs based on proximity: dR<0.4 std::vector<const xAOD::PFO*> nearbyPFO; nearbyPFO.reserve(20); + SG::ReadDecorHandle<xAOD::PFOContainer, char> PVMatchedAcc(m_pfomatchedToPVReadDecorKey); for(const auto pfo : *constits.pfoCont) { if(P4Helpers::isInDeltaR(*pfo, *swclus, 0.4, m_useRapidity)) { // We set a small -ve pt for cPFOs that were rejected // by the ChargedHadronSubtractionTool - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if( ( !pfo->isCharged() && pfo->e() > FLT_MIN ) || ( pfo->isCharged() && PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfo->track(0)) ) ) @@ -365,12 +391,12 @@ namespace met { // Charged FEs + SG::ReadDecorHandle<xAOD::FlowElementContainer, char> PVMatchedAcc(m_fematchedToPVReadDecorKey); for (FELink_t feLink : cFELinks) { if (feLink.isValid()){ const xAOD::FlowElement* fe_init = *feLink; for (const auto fe : *constits.feCont){ if (fe->index() == fe_init->index() && fe->isCharged()){ //index-based match between JetETmiss and CHSFlowElements collections - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if( fe->isCharged() && PVMatchedAcc(*fe)&& ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(fe->chargedObject(0))) ) ) { ATH_MSG_DEBUG("Accept cFE with pt " << fe->pt() << ", e " << fe->e() << ", eta " << fe->eta() << ", phi " << fe->phi() ); felist.push_back(fe); @@ -419,6 +445,7 @@ namespace met { // Preselect PFOs based on proximity: dR<0.4 std::vector<const xAOD::FlowElement*> nearbyFE; nearbyFE.reserve(20); + SG::ReadDecorHandle<xAOD::FlowElementContainer, char> PVMatchedAcc(m_fematchedToPVReadDecorKey); for(const xAOD::FlowElement* fe : *constits.feCont) { if(!(fe->signalType() & xAOD::FlowElement::PFlow)){ ATH_MSG_ERROR("Attempted to extract non-PFlow FlowElements. This is not supported!"); @@ -427,7 +454,6 @@ namespace met { if(P4Helpers::isInDeltaR(*fe, *swclus, 0.4, m_useRapidity)) { // We set a small -ve pt for cPFOs that were rejected // by the ChargedHadronSubtractionTool - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if( ( !fe->isCharged() && fe->e() > FLT_MIN ) || ( fe->isCharged() && PVMatchedAcc(*fe) && ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(fe->chargedObject(0))) ) ) @@ -598,14 +624,14 @@ namespace met { float unmatchedE=0; float unmatchedTotEMFrac=0; double emfrac=0; - - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFrac("unmatchedFrac"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFracSumpt("unmatchedFracSumpt"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFracPt("unmatchedFracPt"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFracE("unmatchedFracE"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFracEClusterPFO("unmatchedFracEClusterPFO"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedFracPtClusterPFO("unmatchedFracPtClusterPFO"); - static SG::AuxElement::Decorator<Float_t> dec_unmatchedTotEMFrac("unmatchedTotEMFrac"); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFrac (m_pfounmatchedFracWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFracSumpt (m_pfounmatchedFracSumptWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFracPt (m_pfounmatchedFracPtWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFracE (m_pfounmatchedFracEWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFracEClusterPFO (m_pfounmatchedFracEClusterPFOWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedFracPtClusterPFO (m_pfounmatchedFracEClusterPFOWriteDecorKey); + SG::WriteDecorHandle<xAOD::PFOContainer, Float_t> dec_unmatchedTotEMFrac (m_pfounmatchedTotEMFracWriteDecorKey); + TLorentzVector totVec(0.,0.,0.,0.), unmatchedVec(0.,0.,0.,0.); const std::vector<const xAOD::CaloCluster*> egClusters = xAOD::EgammaHelpers::getAssociatedTopoClusters(eg->caloCluster()); diff --git a/Reconstruction/MET/METReconstruction/Root/METSoftAssociator.cxx b/Reconstruction/MET/METReconstruction/Root/METSoftAssociator.cxx index d34613a6ee66c670e5ae7e45e6e9b707df23c793..7107664139ad9bec9cb3518ad6353afc21729be4 100644 --- a/Reconstruction/MET/METReconstruction/Root/METSoftAssociator.cxx +++ b/Reconstruction/MET/METReconstruction/Root/METSoftAssociator.cxx @@ -48,7 +48,14 @@ namespace met { ATH_MSG_VERBOSE ("Initializing " << name() << "..."); ATH_CHECK( m_lcmodclus_key.initialize()); ATH_CHECK( m_emmodclus_key.initialize()); - + if(!m_fecollKey.key().empty()){ + m_fematchedToPVReadDecorKey=m_fecollKey.key()+"."+m_fematchedToPVReadDecorKey.key(); + ATH_CHECK( m_fematchedToPVReadDecorKey.initialize() ); + } + else if(m_pflow){ + m_pfomatchedToPVReadDecorKey=m_pfcollKey.key()+"."+m_pfomatchedToPVReadDecorKey.key(); + ATH_CHECK( m_pfomatchedToPVReadDecorKey.initialize() ); + } return StatusCode::SUCCESS; } @@ -92,6 +99,7 @@ namespace met { if(m_pflow){ if(!m_fecollKey.key().empty()){ // PFOs have been provided as FlowElements + SG::ReadDecorHandle<xAOD::FlowElementContainer, char> PVMatchedAcc(m_fematchedToPVReadDecorKey); const IParticleContainer* uniquePFOs = metMap->getUniqueSignals(constits.feCont,MissingETBase::UsageHandler::Policy::ParticleFlow); if(m_decorateSoftTermConst) { dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >(); @@ -104,7 +112,6 @@ namespace met { if (pfo->isCharged()) { // Charged PFOs // We set a small -ve pt for cPFOs that were rejected // by the ChargedHadronSubtractionTool - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(static_cast<const xAOD::TrackParticle*>(pfo->chargedObject(0))) ) ) { // For the TST, we add the track pt, as this need not be // corrected for nearby energy in the calo @@ -129,6 +136,7 @@ namespace met { delete uniquePFOs; } else{ + SG::ReadDecorHandle<xAOD::PFOContainer, char> PVMatchedAcc(m_pfomatchedToPVReadDecorKey); const IParticleContainer* uniquePFOs = metMap->getUniqueSignals(constits.pfoCont,MissingETBase::UsageHandler::Policy::ParticleFlow); if(m_decorateSoftTermConst) { dec_softConst(*metCoreTrk) = std::vector<ElementLink<IParticleContainer> >(); @@ -141,7 +149,6 @@ namespace met { if (pfo->isCharged()) { // Charged PFOs // We set a small -ve pt for cPFOs that were rejected // by the ChargedHadronSubtractionTool - const static SG::AuxElement::ConstAccessor<char> PVMatchedAcc("matchedToPV"); if (PVMatchedAcc(*pfo) && ( !m_cleanChargedPFO || isGoodEoverP(pfo->track(0)) ) ) { // For the TST, we add the track pt, as this need not be // corrected for nearby energy in the calo