From 05baabee22cf60a3429f80660c0471c7a9eb761e Mon Sep 17 00:00:00 2001 From: manthony <matthew.thomas.anthony@cern.ch> Date: Thu, 27 Aug 2020 11:39:07 +0200 Subject: [PATCH 01/23] Start writing muon association algo --- .../eflowRec/PFMuonFlowElementAssoc.h | 49 +++++++++ .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 99 +++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h create mode 100644 Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h new file mode 100644 index 000000000000..c571daf5f62b --- /dev/null +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/* + * PFMuonFlowElementAssoc.h + * Header file for class PFEGammaPFOAssoc + * + * Created by M.T. Anthony + */ + + +#ifndef PFMUONFLOWELEMENTASSOC_H +#define PFMUONFLOWELEMENTASSOC_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODPFlow/FlowElementContainer.h" +#include "StoreGate/WriteDecorHandle.h" + +/* + AthAlgorithm to associate Flow Elements (PFOs) to Muons. + Associates tracks from charged flow elements to Muons only (otherwise links to NULL) + */ + + +class PFMuonFlowElementAssoc : public AthAlgorithm { + +public: + + PFMuonFlowElementAssoc(const std::string& name, ISvcLocator* pSvcLocator); + + virtual ~PFMuonFlowElementAssoc(); + + virtual StatusCode initialize() override final; + virtual StatusCode execute() override final; + virtual StatusCode finalize() override final; + +private: + + /* Write key for adding charged Flow Element link decorations to muons */ + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteDecorKey; + /* Write key for adding Muon link decorations to charged Flow Elements */ + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteDecorKey; + + +}; + +#endif // PFMUONFLOWELEMENTASSOC.H diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx new file mode 100644 index 000000000000..09a392d73fdf --- /dev/null +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -0,0 +1,99 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "eflowRec/PFMuonFlowElementAssoc.h" +#include "StoreGate/WriteDecorHandle.h" +#include "xAODMuon/MuonContainer.h" +#include "xAODMuon/Muon.h" +#include "xAODPFlow/FlowElementContainer.h" +#include "xAODPFlow/FlowElement.h" + +typedef ElementLink<xAOD::MuonContainer> MuonLink_t; +typedef ElementLink<xAOD::FlowElement> FlowElementLink_t; +// +// Algorithm created by M.T. Anthony +// +// ============================================================= +PFMuonFlowElementAssoc::PFMuonFlowElementAssoc(const std::string& name, + ISvcLocator* pSvcLocator): + AthAlgorithm(name, pSvcLocator) +{ + // Declare the decoration keys + declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.neutralfeLinks"); // updated muon container with the new link + declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.fe_MuonLinks"); // updated Charge +} +PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} + +// ============================================================= +StatusCode PFMuonFlowElementAssoc::initialize() { + + ATH_MSG_DEBUG("Initializing " << name() << "..."); + + // Initialise the decoration keys + ATH_CHECK(m_muonChargedFEWriteDecorKey.initialize()); + ATH_CHECK(m_ChargedFEmuonWriteDecorKey.initialize()); + + ATH_MSG_DEBUG("Initialization completed successfully"); + + return StatusCode::SUCCESS; +} + +// ========================================================================= +StatusCode PFMuonFlowElementAssoc::finalize() { + return StatusCode::SUCCESS; +} + +// ========================================================================= +StatusCode PFMuonFlowElementAssoc::execute() { + + // WriteDecorHandles for the charged Flow Elements and Muons + // Links a Muon that has a track to a charged flow element if possible + + ATH_MSG_DEBUG("Started execute step"); + + // Get container for muons + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey); + // get container for charged flow elements + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorHandle); + + + //store readhandles for muon and charged flow elements + SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonChargedFEWriteDecorKey.contHandleKey()); // readhandle for muon + SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_ChargedFEmuonWriteDecorKey.contHandleKey()); + + //Loop over the Flow Elements + + ////////////////////////////// + // CHARGED LOOP + ////////////////////////////// + for (const xAOD::FlowElement* FE: *ChargedFEmuonWriteDecorHandle){ + //get the track associated to the charged flow element (or at least the index of said track + size_t FETrackIndex=FE->chargedObjects().at(0)->index(); + // Init a vector of element links to muons + std::vector<MuonLink_t> feMuonLinks; + + //loop over muons in container + for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ + // retrieve a link to an ID track where possible + const ElementLink<xAOD::TrackParticleContainer> muonTrackContLink=muon->inDetTrackParticleLink(); + //catch for case where muon does not contain an ID track + if(muonTrackContLink->size()>0){ + // loop over tracks: should be one element at most + for (xAOD::TrackParticle* muontrack: *muonTrackContLink){ + size_t muontrackindex=muontrack->index(); + if(muontrackindex==FETrackIndex){ + + }//end of matching block + }// end of loop over tracks + }// end of size check on muonTrackContLink + }// end of muon loop + + + } // end of charged Flow Element loop + + ATH_MSG_DEBUG("Execute completed successfully"); + + return StatusCode::SUCCESS; +} + -- GitLab From c9c82cd180fde2447f9679e09147738f9c5540d0 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Wed, 9 Sep 2020 10:59:31 +0100 Subject: [PATCH 02/23] add muon linker algorithm. Still hits the same Q431 violating error again --- .../eflowRec/share/PFlowMTConfig.py | 6 +++ .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 44 +++++++++++++------ .../src/components/eflowRec_entries.cxx | 2 + 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index bf6780e54b77..e889e232ef30 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -250,6 +250,8 @@ if jobproperties.eflowRecFlags.usePFEGammaPFOAssoc: PFEGammaPFOAssoc=PFEGammaPFOAssoc("PFEGammaPFOAssoc") topSequence += PFEGammaPFOAssoc +jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) +print("RUN_FE_NOW_PLS") #Add new FlowElement creators if jobproperties.eflowRecFlags.useFlowElements: from eflowRec.eflowRecConf import PFChargedFlowElementCreatorAlgorithm @@ -263,3 +265,7 @@ if jobproperties.eflowRecFlags.useFlowElements: from eflowRec.eflowRecConf import PFLCNeutralFlowElementCreatorAlgorithm PFLCNeutralFlowElementCreatorAlgorithm = PFLCNeutralFlowElementCreatorAlgorithm("PFLCNeutralFlowElementCreatorAlgorithm") topSequence += PFLCNeutralFlowElementCreatorAlgorithm + + from eflowRec.eflowRecConf import PFMuonFlowElementAssoc + PFMuonFlowElementAssoc=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") + topSequence += PFMuonFlowElementAssoc diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 09a392d73fdf..d20c0f08b45f 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -8,9 +8,10 @@ #include "xAODMuon/Muon.h" #include "xAODPFlow/FlowElementContainer.h" #include "xAODPFlow/FlowElement.h" +#include <typeinfo> // temp debug to check object typedef ElementLink<xAOD::MuonContainer> MuonLink_t; -typedef ElementLink<xAOD::FlowElement> FlowElementLink_t; +typedef ElementLink<xAOD::FlowElementContainer> FlowElementLink_t; // // Algorithm created by M.T. Anthony // @@ -55,13 +56,16 @@ StatusCode PFMuonFlowElementAssoc::execute() { // Get container for muons SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey); // get container for charged flow elements - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorHandle); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonChargedFEWriteDecorKey.contHandleKey()); // readhandle for muon SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_ChargedFEmuonWriteDecorKey.contHandleKey()); + //now init some Flow element link containers + std::vector<std::vector<FlowElementLink_t> > muonChargedFEVec(muonReadHandle->size()); + //Loop over the Flow Elements ////////////////////////////// @@ -77,21 +81,35 @@ StatusCode PFMuonFlowElementAssoc::execute() { for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ // retrieve a link to an ID track where possible const ElementLink<xAOD::TrackParticleContainer> muonTrackContLink=muon->inDetTrackParticleLink(); - //catch for case where muon does not contain an ID track - if(muonTrackContLink->size()>0){ - // loop over tracks: should be one element at most - for (xAOD::TrackParticle* muontrack: *muonTrackContLink){ - size_t muontrackindex=muontrack->index(); - if(muontrackindex==FETrackIndex){ - - }//end of matching block - }// end of loop over tracks - }// end of size check on muonTrackContLink + const xAOD::TrackParticleContainer* TrkCont=muonTrackContLink.getDataPtr(); + if(TrkCont->size()>0){ + for(const xAOD::TrackParticle* MuonTrkParticle: *TrkCont){ + size_t MuonTrkIndex=MuonTrkParticle->index(); + if(MuonTrkIndex==FETrackIndex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + feMuonLinks.push_back( MuonLink_t(*muonReadHandle, muon->index())); + // Add flow element link to a vector + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonChargedFEVec.at(muon->index()).push_back(FlowElementLink_t(*ChargedFEReadHandle,FE->index())); + } // matching block + } // TrkCont loop + } // Size check }// end of muon loop - + // Add vector of muon element links as decoration to FlowElement container + ChargedFEmuonWriteDecorHandle(*FE) = feMuonLinks; } // end of charged Flow Element loop + + ////////////////////////////////////////////////// + // WRITE OUTPUT: ADD HANDLES TO MUON CONTAINERS + ////////////////////////////////////////////////// + // Add the vectors of the Flow Element Links as decoations to the muon container + for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ + muonChargedFEWriteDecorHandle(*muon)=muonChargedFEVec.at(muon->index()); + } // end of muon loop + ATH_MSG_DEBUG("Execute completed successfully"); return StatusCode::SUCCESS; diff --git a/Reconstruction/eflowRec/src/components/eflowRec_entries.cxx b/Reconstruction/eflowRec/src/components/eflowRec_entries.cxx index 3667e06ebd95..9cbc83a6b94e 100644 --- a/Reconstruction/eflowRec/src/components/eflowRec_entries.cxx +++ b/Reconstruction/eflowRec/src/components/eflowRec_entries.cxx @@ -20,6 +20,7 @@ #include "eflowRec/PFOChargedCreatorAlgorithm.h" #include "eflowRec/PFONeutralCreatorAlgorithm.h" #include "eflowRec/PFEGammaPFOAssoc.h" +#include "eflowRec/PFMuonFlowElementAssoc.h" DECLARE_COMPONENT( eflowOverlapRemoval ) DECLARE_COMPONENT( PFLeptonSelector ) @@ -43,3 +44,4 @@ DECLARE_COMPONENT( PFTrackClusterMatchingTool ) DECLARE_COMPONENT( eflowCellEOverPTool_mc12_JetETMiss) DECLARE_COMPONENT( eflowCellEOverPTool_mc12_HLLHC) DECLARE_COMPONENT( eflowCellEOverPTool_mc12_LC) +DECLARE_COMPONENT( PFMuonFlowElementAssoc ) -- GitLab From 6efa90300a40da8c7c0c9187b254d602d0cf9a08 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Tue, 15 Sep 2020 14:25:27 +0100 Subject: [PATCH 03/23] add handles for neutral muons --- .../eflowRec/eflowRec/PFMuonFlowElementAssoc.h | 7 +++++++ .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index c571daf5f62b..772a1f7f1301 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -43,6 +43,13 @@ private: /* Write key for adding Muon link decorations to charged Flow Elements */ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteDecorKey; + /* Write key for adding neutral Flow Element link decorations to muons */ + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteDecorKey; + /* Write key for adding Muon link decorations to neutral Flow Elements */ + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; + + + }; diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index d20c0f08b45f..7e61085fa39c 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -21,8 +21,10 @@ PFMuonFlowElementAssoc::PFMuonFlowElementAssoc(const std::string& name, AthAlgorithm(name, pSvcLocator) { // Declare the decoration keys - declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.neutralfeLinks"); // updated muon container with the new link + declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.chargedfeLinks"); // updated muon container with the new link declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.fe_MuonLinks"); // updated Charge + declareProperty ("MuonNeutralFlowElementDecorKey", m_muonNeutralFEWriteDecorKey = "Muons.neutralfeLinks"); + declareProperty ("NeutralFlowElementMuonDecorKey",m_NeutralFEmuonWriteDecorKey = "JetETMissNeutralFlowElements.fe_MuonLinks"); } PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} @@ -33,7 +35,11 @@ StatusCode PFMuonFlowElementAssoc::initialize() { // Initialise the decoration keys ATH_CHECK(m_muonChargedFEWriteDecorKey.initialize()); + ATH_CHECK(m_muonNeutralFEWriteDecorKey.initialize()); + ATH_CHECK(m_ChargedFEmuonWriteDecorKey.initialize()); + ATH_CHECK(m_NeutralFEmuonWriteDecorKey.initialize()); + ATH_MSG_DEBUG("Initialization completed successfully"); @@ -57,14 +63,16 @@ StatusCode PFMuonFlowElementAssoc::execute() { SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey); // get container for charged flow elements SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey); - + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<FlowElementLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonChargedFEWriteDecorKey.contHandleKey()); // readhandle for muon SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_ChargedFEmuonWriteDecorKey.contHandleKey()); + SG::ReadHandle<xAOD::FlowElementContainer> NeutralFEReadHandle(m_NeutralFEmuonWriteDecorKey.contHandleKey()); //now init some Flow element link containers std::vector<std::vector<FlowElementLink_t> > muonChargedFEVec(muonReadHandle->size()); + std::vector<std::vector<FlowElementLink_t> > muonNeutralFEVec(muonReadHandle->size()); //Loop over the Flow Elements -- GitLab From e7898dfbc316e499f8ddbddbdbd7f7fd71b9b07a Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Tue, 15 Sep 2020 15:25:53 +0100 Subject: [PATCH 04/23] add cluster links to muons --- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 7e61085fa39c..88cc058e6a8d 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -61,9 +61,10 @@ StatusCode PFMuonFlowElementAssoc::execute() { // Get container for muons SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonNeutralFEWriteDecorHandle (m_muonNeutralFEWriteDecorKey); // get container for charged flow elements SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey); - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<FlowElementLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonChargedFEWriteDecorKey.contHandleKey()); // readhandle for muon @@ -109,6 +110,35 @@ StatusCode PFMuonFlowElementAssoc::execute() { ChargedFEmuonWriteDecorHandle(*FE) = feMuonLinks; } // end of charged Flow Element loop + ////////////////////////////////////////////////// + // Loop over Neutral FlowElements + ////////////////////////////////////////////////// + for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ + //get the index of the cluster corresponding to the Neutral FlowElements + size_t FEclusterindex=FE->otherObjects().at(0)->index(); + + //design the vector of ElementLinks + std::vector<MuonLink_t> feMuonLinks; + for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ + //Retrieve the ElementLink vector of clusters + const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); + + //access object from element link + const xAOD::CaloClusterContainer* clustercont = ClusterLink.getDataPtr(); + for (const xAOD::CaloCluster* cluster: *clustercont){ + size_t cluster_index=cluster->index(); + if(cluster_index==FEclusterindex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + feMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + } // end of matching cluster index block + } // loop over elementlink vector + } // loop over muons + NeutralFEmuonWriteDecorHandle(*FE)=feMuonLinks; + } // loop over neutral FE + ////////////////////////////////////////////////// // WRITE OUTPUT: ADD HANDLES TO MUON CONTAINERS -- GitLab From 8b58439d54ae636917af37c9682a49607bdccb11 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Wed, 16 Sep 2020 15:46:16 +0100 Subject: [PATCH 05/23] add Gaudi property --- .../eflowRec/PFMuonFlowElementAssoc.h | 2 +- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 58 ++++++++++--------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 772a1f7f1301..a75d195d22d2 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -48,7 +48,7 @@ private: /* Write key for adding Muon link decorations to neutral Flow Elements */ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; - + Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default"}; }; diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 88cc058e6a8d..7492f9fa9ba8 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -113,41 +113,45 @@ StatusCode PFMuonFlowElementAssoc::execute() { ////////////////////////////////////////////////// // Loop over Neutral FlowElements ////////////////////////////////////////////////// - for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ - //get the index of the cluster corresponding to the Neutral FlowElements - size_t FEclusterindex=FE->otherObjects().at(0)->index(); - - //design the vector of ElementLinks - std::vector<MuonLink_t> feMuonLinks; - for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ - //Retrieve the ElementLink vector of clusters - const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); - - //access object from element link - const xAOD::CaloClusterContainer* clustercont = ClusterLink.getDataPtr(); - for (const xAOD::CaloCluster* cluster: *clustercont){ - size_t cluster_index=cluster->index(); - if(cluster_index==FEclusterindex){ - // Add Muon element link to a vector - // index() is the unique index of the muon in the muon container - feMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); - // index() is the unique index of the cFlowElement in the cFlowElementcontaine - muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); - } // end of matching cluster index block - } // loop over elementlink vector - } // loop over muons - NeutralFEmuonWriteDecorHandle(*FE)=feMuonLinks; - } // loop over neutral FE + if(m_LinkNeutralFEClusters){ + for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ + //get the index of the cluster corresponding to the Neutral FlowElements + size_t FEclusterindex=FE->otherObjects().at(0)->index(); + + //design the vector of ElementLinks + std::vector<MuonLink_t> feMuonLinks; + for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ + //Retrieve the ElementLink vector of clusters + const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); + + //access object from element link + const xAOD::CaloClusterContainer* clustercont = ClusterLink.getDataPtr(); + for (const xAOD::CaloCluster* cluster: *clustercont){ + size_t cluster_index=cluster->index(); + if(cluster_index==FEclusterindex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + feMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + } // end of matching cluster index block + } // loop over elementlink vector + } // loop over muons + NeutralFEmuonWriteDecorHandle(*FE)=feMuonLinks; + } // loop over neutral FE + }// end of the Gaudi check block - ////////////////////////////////////////////////// // WRITE OUTPUT: ADD HANDLES TO MUON CONTAINERS ////////////////////////////////////////////////// // Add the vectors of the Flow Element Links as decoations to the muon container for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ muonChargedFEWriteDecorHandle(*muon)=muonChargedFEVec.at(muon->index()); - } // end of muon loop + } // end of muon loop + for(const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle){ + muonNeutralFEWriteDecorHandle(*muon)=muonNeutralFEVec.at(muon->index()); + } ATH_MSG_DEBUG("Execute completed successfully"); return StatusCode::SUCCESS; -- GitLab From 7e5cc31aea072cde781a9be412738b3f1640f95e Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Mon, 21 Sep 2020 18:06:50 +0100 Subject: [PATCH 06/23] Made sure Gaudi Bool works for neutral flowelems works properly --- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 7492f9fa9ba8..1f82a60b439d 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -114,6 +114,7 @@ StatusCode PFMuonFlowElementAssoc::execute() { // Loop over Neutral FlowElements ////////////////////////////////////////////////// if(m_LinkNeutralFEClusters){ + ATH_MSG_DEBUG("Experimental: Cluster Linkers between neutral FEs and Muons are used"); for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ //get the index of the cluster corresponding to the Neutral FlowElements size_t FEclusterindex=FE->otherObjects().at(0)->index(); @@ -146,11 +147,14 @@ StatusCode PFMuonFlowElementAssoc::execute() { ////////////////////////////////////////////////// // Add the vectors of the Flow Element Links as decoations to the muon container for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ - muonChargedFEWriteDecorHandle(*muon)=muonChargedFEVec.at(muon->index()); - + muonChargedFEWriteDecorHandle(*muon)=muonChargedFEVec.at(muon->index()); } // end of muon loop - for(const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle){ - muonNeutralFEWriteDecorHandle(*muon)=muonNeutralFEVec.at(muon->index()); + if(m_LinkNeutralFEClusters){ + for(const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle){ + if(muonNeutralFEVec.size()>0){ + muonNeutralFEWriteDecorHandle(*muon)=muonNeutralFEVec.at(muon->index()); + } + } } ATH_MSG_DEBUG("Execute completed successfully"); -- GitLab From 44a32f834efdf06104b3fe7427b4b0e52d82ddfa Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Wed, 23 Sep 2020 12:09:48 +0100 Subject: [PATCH 07/23] Added Readhandle configuration to PFMuonFlowElementAssoc --- .../eflowRec/PFMuonFlowElementAssoc.h | 35 ++++++++----- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 50 ++++++++++--------- 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index a75d195d22d2..1c8c8c86e24a 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -1,10 +1,10 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /* * PFMuonFlowElementAssoc.h - * Header file for class PFEGammaPFOAssoc + * Header file for class PFEMuonFlowElementAssoc * * Created by M.T. Anthony */ @@ -14,30 +14,41 @@ #define PFMUONFLOWELEMENTASSOC_H #include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "GaudiKernel/ToolHandle.h" +#include "StoreGate/DataHandle.h" #include "xAODMuon/MuonContainer.h" #include "xAODPFlow/FlowElementContainer.h" #include "StoreGate/WriteDecorHandle.h" -/* - AthAlgorithm to associate Flow Elements (PFOs) to Muons. - Associates tracks from charged flow elements to Muons only (otherwise links to NULL) - */ - +/** + AthReentrantAlgorithm to associate Flow Elements (FEs) to Muons. + Associates tracks from charged flow elements to Muons only (otherwise links to NULL) +**/ -class PFMuonFlowElementAssoc : public AthAlgorithm { +class PFMuonFlowElementAssoc : public AthReentrantAlgorithm { public: + using AthReentrantAlgorithm::AthReentrantAlgorithm; PFMuonFlowElementAssoc(const std::string& name, ISvcLocator* pSvcLocator); - + virtual ~PFMuonFlowElementAssoc(); - virtual StatusCode initialize() override final; - virtual StatusCode execute() override final; - virtual StatusCode finalize() override final; + virtual StatusCode initialize(); + virtual StatusCode execute(const EventContext & ctx ) const; + virtual StatusCode finalize(); private: + // ReadHandleKeys + SG::ReadHandleKey<xAOD::MuonContainer>m_muonReadHandleKey{this,"MuonContainer","Muons","ReadHandleKey for Muons"}; + + SG::ReadHandleKey<xAOD::FlowElementContainer>m_neutralFEReadHandleKey{this,"JetEtMissNeutralFlowElementContainer","JetETMissNeutralFlowElements","ReadHandleKey for neutral FlowElements"}; + + SG::ReadHandleKey<xAOD::FlowElementContainer>m_chargedFEReadHandleKey{this,"JetEtMissChargedFlowElementContainer","JetETMissChargedFlowElements","ReadHandleKey for charged FlowElements"}; + + /* Write key for adding charged Flow Element link decorations to muons */ SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteDecorKey; /* Write key for adding Muon link decorations to charged Flow Elements */ diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 1f82a60b439d..23eb76617da0 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "eflowRec/PFMuonFlowElementAssoc.h" @@ -8,7 +8,6 @@ #include "xAODMuon/Muon.h" #include "xAODPFlow/FlowElementContainer.h" #include "xAODPFlow/FlowElement.h" -#include <typeinfo> // temp debug to check object typedef ElementLink<xAOD::MuonContainer> MuonLink_t; typedef ElementLink<xAOD::FlowElementContainer> FlowElementLink_t; @@ -18,13 +17,13 @@ typedef ElementLink<xAOD::FlowElementContainer> FlowElementLink_t; // ============================================================= PFMuonFlowElementAssoc::PFMuonFlowElementAssoc(const std::string& name, ISvcLocator* pSvcLocator): - AthAlgorithm(name, pSvcLocator) + AthReentrantAlgorithm(name, pSvcLocator) { // Declare the decoration keys - declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.chargedfeLinks"); // updated muon container with the new link - declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.fe_MuonLinks"); // updated Charge - declareProperty ("MuonNeutralFlowElementDecorKey", m_muonNeutralFEWriteDecorKey = "Muons.neutralfeLinks"); - declareProperty ("NeutralFlowElementMuonDecorKey",m_NeutralFEmuonWriteDecorKey = "JetETMissNeutralFlowElements.fe_MuonLinks"); + declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.chargedFELinks"); // updated muon container with the new link + declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.FE_MuonLinks"); // updated Charge + declareProperty ("MuonNeutralFlowElementDecorKey", m_muonNeutralFEWriteDecorKey = "Muons.neutralFELinks"); + declareProperty ("NeutralFlowElementMuonDecorKey",m_NeutralFEmuonWriteDecorKey = "JetETMissNeutralFlowElements.FE_MuonLinks"); } PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} @@ -40,6 +39,10 @@ StatusCode PFMuonFlowElementAssoc::initialize() { ATH_CHECK(m_ChargedFEmuonWriteDecorKey.initialize()); ATH_CHECK(m_NeutralFEmuonWriteDecorKey.initialize()); + //init ReadHandleKeys + ATH_CHECK(m_muonReadHandleKey.initialize()); + ATH_CHECK(m_chargedFEReadHandleKey.initialize()); + ATH_CHECK(m_neutralFEReadHandleKey.initialize()); ATH_MSG_DEBUG("Initialization completed successfully"); @@ -52,24 +55,25 @@ StatusCode PFMuonFlowElementAssoc::finalize() { } // ========================================================================= -StatusCode PFMuonFlowElementAssoc::execute() { +StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const +{ - // WriteDecorHandles for the charged Flow Elements and Muons + // WriteDecorHandles for the charged/neutral Flow Elements and Muons // Links a Muon that has a track to a charged flow element if possible ATH_MSG_DEBUG("Started execute step"); // Get container for muons - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey); - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonNeutralFEWriteDecorHandle (m_muonNeutralFEWriteDecorKey); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonNeutralFEWriteDecorHandle (m_muonNeutralFEWriteDecorKey,ctx); // get container for charged flow elements - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey); - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey,ctx); //store readhandles for muon and charged flow elements - SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonChargedFEWriteDecorKey.contHandleKey()); // readhandle for muon - SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_ChargedFEmuonWriteDecorKey.contHandleKey()); - SG::ReadHandle<xAOD::FlowElementContainer> NeutralFEReadHandle(m_NeutralFEmuonWriteDecorKey.contHandleKey()); + SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon + SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_chargedFEReadHandleKey,ctx); + SG::ReadHandle<xAOD::FlowElementContainer> NeutralFEReadHandle(m_neutralFEReadHandleKey,ctx); //now init some Flow element link containers std::vector<std::vector<FlowElementLink_t> > muonChargedFEVec(muonReadHandle->size()); @@ -81,10 +85,10 @@ StatusCode PFMuonFlowElementAssoc::execute() { // CHARGED LOOP ////////////////////////////// for (const xAOD::FlowElement* FE: *ChargedFEmuonWriteDecorHandle){ - //get the track associated to the charged flow element (or at least the index of said track + //get the track associated to the charged flow element (or at least the index of said track) size_t FETrackIndex=FE->chargedObjects().at(0)->index(); // Init a vector of element links to muons - std::vector<MuonLink_t> feMuonLinks; + std::vector<MuonLink_t> FEMuonLinks; //loop over muons in container for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ @@ -97,7 +101,7 @@ StatusCode PFMuonFlowElementAssoc::execute() { if(MuonTrkIndex==FETrackIndex){ // Add Muon element link to a vector // index() is the unique index of the muon in the muon container - feMuonLinks.push_back( MuonLink_t(*muonReadHandle, muon->index())); + FEMuonLinks.push_back( MuonLink_t(*muonReadHandle, muon->index())); // Add flow element link to a vector // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonChargedFEVec.at(muon->index()).push_back(FlowElementLink_t(*ChargedFEReadHandle,FE->index())); @@ -107,7 +111,7 @@ StatusCode PFMuonFlowElementAssoc::execute() { }// end of muon loop // Add vector of muon element links as decoration to FlowElement container - ChargedFEmuonWriteDecorHandle(*FE) = feMuonLinks; + ChargedFEmuonWriteDecorHandle(*FE) = FEMuonLinks; } // end of charged Flow Element loop ////////////////////////////////////////////////// @@ -120,7 +124,7 @@ StatusCode PFMuonFlowElementAssoc::execute() { size_t FEclusterindex=FE->otherObjects().at(0)->index(); //design the vector of ElementLinks - std::vector<MuonLink_t> feMuonLinks; + std::vector<MuonLink_t> FEMuonLinks; for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ //Retrieve the ElementLink vector of clusters const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); @@ -132,13 +136,13 @@ StatusCode PFMuonFlowElementAssoc::execute() { if(cluster_index==FEclusterindex){ // Add Muon element link to a vector // index() is the unique index of the muon in the muon container - feMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); } // end of matching cluster index block } // loop over elementlink vector } // loop over muons - NeutralFEmuonWriteDecorHandle(*FE)=feMuonLinks; + NeutralFEmuonWriteDecorHandle(*FE)=FEMuonLinks; } // loop over neutral FE }// end of the Gaudi check block -- GitLab From bb57c06523fa2d887227e753d4cba0f7995a4beb Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Thu, 24 Sep 2020 12:26:43 +0100 Subject: [PATCH 08/23] code cleanup --- .../eflowRec/PFMuonFlowElementAssoc.h | 2 +- .../eflowRec/share/PFlowMTConfig.py | 6 ++++- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 26 +++++++------------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 1c8c8c86e24a..6f7d74f4a505 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -59,7 +59,7 @@ private: /* Write key for adding Muon link decorations to neutral Flow Elements */ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; - Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default"}; + Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default"}; }; diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index e889e232ef30..37b69be3c0c2 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -251,7 +251,7 @@ if jobproperties.eflowRecFlags.usePFEGammaPFOAssoc: topSequence += PFEGammaPFOAssoc jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) -print("RUN_FE_NOW_PLS") + #Add new FlowElement creators if jobproperties.eflowRecFlags.useFlowElements: from eflowRec.eflowRecConf import PFChargedFlowElementCreatorAlgorithm @@ -268,4 +268,8 @@ if jobproperties.eflowRecFlags.useFlowElements: from eflowRec.eflowRecConf import PFMuonFlowElementAssoc PFMuonFlowElementAssoc=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") + #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements + print(PFMuonFlowElementAssoc.m_LinkNeutralFEClusters) + + print("RUN_MUONFLOWELEMS_PLS") topSequence += PFMuonFlowElementAssoc diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 23eb76617da0..91858ee5259e 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -92,22 +92,16 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //loop over muons in container for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ - // retrieve a link to an ID track where possible - const ElementLink<xAOD::TrackParticleContainer> muonTrackContLink=muon->inDetTrackParticleLink(); - const xAOD::TrackParticleContainer* TrkCont=muonTrackContLink.getDataPtr(); - if(TrkCont->size()>0){ - for(const xAOD::TrackParticle* MuonTrkParticle: *TrkCont){ - size_t MuonTrkIndex=MuonTrkParticle->index(); - if(MuonTrkIndex==FETrackIndex){ - // Add Muon element link to a vector - // index() is the unique index of the muon in the muon container - FEMuonLinks.push_back( MuonLink_t(*muonReadHandle, muon->index())); - // Add flow element link to a vector - // index() is the unique index of the cFlowElement in the cFlowElementcontaine - muonChargedFEVec.at(muon->index()).push_back(FlowElementLink_t(*ChargedFEReadHandle,FE->index())); - } // matching block - } // TrkCont loop - } // Size check + const xAOD::TrackParticle* muon_trk=muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle); + size_t MuonTrkIndex=muon_trk->index(); + if(MuonTrkIndex==FETrackIndex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + FEMuonLinks.push_back( MuonLink_t(*muonReadHandle, muon->index())); + // Add flow element link to a vector + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonChargedFEVec.at(muon->index()).push_back(FlowElementLink_t(*ChargedFEReadHandle,FE->index())); + } // matching block }// end of muon loop // Add vector of muon element links as decoration to FlowElement container -- GitLab From cccf1c5523230b7fed355295efe53d642d4245dd Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 25 Sep 2020 18:01:03 +0100 Subject: [PATCH 09/23] added a topocluster link to muons --- .../eflowRec/PFMuonFlowElementAssoc.h | 5 +- .../eflowRec/share/PFlowMTConfig.py | 8 ++-- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 48 +++++++++++++++---- 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 6f7d74f4a505..3c998c3c9c89 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -59,9 +59,8 @@ private: /* Write key for adding Muon link decorations to neutral Flow Elements */ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; - Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default"}; - + Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; + Gaudi::Property<bool> m_UseMuonTopoClusters{this,"m_UseMuonTopoClusters",false,"Toggle usage of linker of muon associated topoclusters to flow elements - false by default (EXPERIMENTAL)"}; }; - #endif // PFMUONFLOWELEMENTASSOC.H diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index 37b69be3c0c2..52ec5cdc541a 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -267,9 +267,7 @@ if jobproperties.eflowRecFlags.useFlowElements: topSequence += PFLCNeutralFlowElementCreatorAlgorithm from eflowRec.eflowRecConf import PFMuonFlowElementAssoc - PFMuonFlowElementAssoc=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") + PFMuonFlowElementAssocAlg=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements - print(PFMuonFlowElementAssoc.m_LinkNeutralFEClusters) - - print("RUN_MUONFLOWELEMS_PLS") - topSequence += PFMuonFlowElementAssoc + PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=True + topSequence += PFMuonFlowElementAssocAlg diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 91858ee5259e..59f59d816aeb 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -111,6 +111,15 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const ////////////////////////////////////////////////// // Loop over Neutral FlowElements ////////////////////////////////////////////////// + /** + In short, this feature is an experimental linker between neutral FEs and Muons either by the following: + Case 1) Retrieve the CaloCluster(s) from the muon, and get any topocluster(s) associated to those, then link the topoclusters to the neutral FEs + Case 2) Retrieve the CaloCluster(s) from the muon then link to the neutral FEs + + This code is switched using two switches: + m_LinkNeutralFEClusters (turns on the experimental feature) + m_UseMuonTopoClusters (True= Case 1, False = Case 2) + **/ if(m_LinkNeutralFEClusters){ ATH_MSG_DEBUG("Experimental: Cluster Linkers between neutral FEs and Muons are used"); for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ @@ -125,16 +134,37 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //access object from element link const xAOD::CaloClusterContainer* clustercont = ClusterLink.getDataPtr(); + for (const xAOD::CaloCluster* cluster: *clustercont){ - size_t cluster_index=cluster->index(); - if(cluster_index==FEclusterindex){ - // Add Muon element link to a vector - // index() is the unique index of the muon in the muon container - FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); - // index() is the unique index of the cFlowElement in the cFlowElementcontaine - muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); - } // end of matching cluster index block - } // loop over elementlink vector + if(m_UseMuonTopoClusters){ + // get the linker to the topo clusters + std::vector<ElementLink<xAOD::CaloClusterContainer>> linksToTopoClusters=cluster->auxdata<std::vector<ElementLink<xAOD::CaloClusterContainer>> >("constituentClusterLinks"); + for (ElementLink<xAOD::CaloClusterContainer> TopoClusterLink: linksToTopoClusters){ + const xAOD::CaloClusterContainer* MuonTopoClusters=TopoClusterLink.getDataPtr(); + for (const xAOD::CaloCluster* MuonTopoCluster: *MuonTopoClusters){ + size_t MuonTopoCluster_index=MuonTopoCluster->index(); + if(MuonTopoCluster_index==FEclusterindex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + } // check block of index matching + } // loop over list of topoclusters + } // end of loop over element links + } //end of TopoCluster specific block + else{ // case when we don't use Topoclusters, just match the caloclusters to the flow element + size_t cluster_index=cluster->index(); + if(cluster_index==FEclusterindex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + } // end of matching cluster index block + } // end of calocluster specific block + + } // loop over caloclusters } // loop over muons NeutralFEmuonWriteDecorHandle(*FE)=FEMuonLinks; } // loop over neutral FE -- GitLab From b9a51a68b5a1e378b3d8c68dffa8b91fb37fafc9 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 25 Sep 2020 18:04:00 +0100 Subject: [PATCH 10/23] add Gaudi switch for the topocluster matching --- Reconstruction/eflowRec/share/PFlowMTConfig.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index 52ec5cdc541a..8aff70bc3cf3 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -268,6 +268,7 @@ if jobproperties.eflowRecFlags.useFlowElements: from eflowRec.eflowRecConf import PFMuonFlowElementAssoc PFMuonFlowElementAssocAlg=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") - #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements - PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=True + #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements (FE) + PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=False + PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=False # second switch combined with first implies Muon topoclusters are linked to neutral Flow Elements topSequence += PFMuonFlowElementAssocAlg -- GitLab From 44a65c230dfc2c6f749abf0597cd3ce4d8881b53 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Mon, 28 Sep 2020 17:54:56 +0100 Subject: [PATCH 11/23] Reworked the cluster matching to be cell based matching if we're not matching TopoClusters to FE Topoclusters --- .../eflowRec/PFMuonFlowElementAssoc.h | 14 ++++-- .../eflowRec/share/PFlowMTConfig.py | 6 +-- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 45 +++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 3c998c3c9c89..614b28467316 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -49,18 +49,24 @@ private: SG::ReadHandleKey<xAOD::FlowElementContainer>m_chargedFEReadHandleKey{this,"JetEtMissChargedFlowElementContainer","JetETMissChargedFlowElements","ReadHandleKey for charged FlowElements"}; - /* Write key for adding charged Flow Element link decorations to muons */ + /** Write key for adding charged Flow Element link decorations to muons **/ SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteDecorKey; - /* Write key for adding Muon link decorations to charged Flow Elements */ + /** Write key for adding Muon link decorations to charged Flow Elements **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteDecorKey; - /* Write key for adding neutral Flow Element link decorations to muons */ + /* Write key for adding neutral Flow Element link decorations to muons **/ SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteDecorKey; - /* Write key for adding Muon link decorations to neutral Flow Elements */ + /** Write key for adding Muon link decorations to neutral Flow Elements **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; + /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; + /** + (EXPERIMENTAL) Gaudi Property to configure linkage of Neutral FEs to TopoClusters associated to Muons. Only works with previous option set to True (m_LinkNeutralFEClusters). + True: Link FEs to Topoclusters associated to Muons + False: Link FEs to CaloClusters associated to Muons + **/ Gaudi::Property<bool> m_UseMuonTopoClusters{this,"m_UseMuonTopoClusters",false,"Toggle usage of linker of muon associated topoclusters to flow elements - false by default (EXPERIMENTAL)"}; }; #endif // PFMUONFLOWELEMENTASSOC.H diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index 5e057f617a33..93ab416343a7 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -245,7 +245,7 @@ if True == jobproperties.eflowRecFlags.provideShowerSubtractedClusters: topSequence += PFONeutralCreatorAlgorithm from eflowRec.eflowRecFlags import jobproperties # set reco flags for eFlowRec algorithms jobproperties.eflowRecFlags.usePFEGammaPFOAssoc.set_Value_and_Lock(True) -jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) + if jobproperties.eflowRecFlags.usePFEGammaPFOAssoc: @@ -272,13 +272,13 @@ if jobproperties.eflowRecFlags.useFlowElements: # Electron/Photon linkers to flow elements from eflowRec.eflowRecConf import PFEGamFlowElementAssoc PFEGamFlowElementAssocAlg=PFEGamFlowElementAssoc("PFEGamFlowElementAssoc") - topSequence +=PFEGamFlowElementAssoc + topSequence +=PFEGamFlowElementAssocAlg # Muon linker to flow elements from eflowRec.eflowRecConf import PFMuonFlowElementAssoc PFMuonFlowElementAssocAlg=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements (FE) - PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=False + PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=True PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=False # second switch combined with first implies Muon topoclusters are linked to neutral Flow Elements topSequence += PFMuonFlowElementAssocAlg diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 59f59d816aeb..5aa4d8925fb7 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -9,6 +9,11 @@ #include "xAODPFlow/FlowElementContainer.h" #include "xAODPFlow/FlowElement.h" +//includes for CaloCluster algo +#include "CaloEvent/CaloCell.h" +#include "xAODCaloEvent/CaloClusterKineHelper.h" +#include "Identifier/Identifier.h" + typedef ElementLink<xAOD::MuonContainer> MuonLink_t; typedef ElementLink<xAOD::FlowElementContainer> FlowElementLink_t; // @@ -126,6 +131,18 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //get the index of the cluster corresponding to the Neutral FlowElements size_t FEclusterindex=FE->otherObjects().at(0)->index(); + // FE->otherObjects returns a vector of IParticles. We only want the first one + const xAOD::IParticle* FE_Iparticle=FE->otherObjects().at(0); + //dynamic cast to CaloCluster + const xAOD::CaloCluster* FE_cluster=dynamic_cast<const xAOD::CaloCluster*>(FE_Iparticle); //cast to CaloCluster + + // retrieve the link to cells + const CaloClusterCellLink* CellLink = FE_cluster->getCellLinks(); + // build the iterator(s) for the looping over the elements inside the CellLink + CaloClusterCellLink::const_iterator FE_FirstCell=CellLink->begin(); + CaloClusterCellLink::const_iterator FE_LastCell=CellLink->end(); + + //design the vector of ElementLinks std::vector<MuonLink_t> FEMuonLinks; for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ @@ -154,14 +171,36 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const } // end of loop over element links } //end of TopoCluster specific block else{ // case when we don't use Topoclusters, just match the caloclusters to the flow element - size_t cluster_index=cluster->index(); - if(cluster_index==FEclusterindex){ + //if we don't match topoclusters, do something more complex: + // Retrieve cells in both the FE cluster and muon cluster + // Define the link as where at least one calo cell is shared between the FE cluster and the Muon Cluster + + //retrieve cells associated to Muon cluster + const CaloClusterCellLink* Muon_Clus_CellLink=cluster->getCellLinks(); + //get the iterator on the links + CaloClusterCellLink::const_iterator Muon_Clus_FirstCell=Muon_Clus_CellLink->begin(); + CaloClusterCellLink::const_iterator Muon_Clus_LastCell=Muon_Clus_CellLink->end(); + + //Now we check if any match. Current algo allows for at least one match. + bool isCellMatched=false; + for(; Muon_Clus_FirstCell != Muon_Clus_LastCell; ++Muon_Clus_FirstCell){ + Identifier index_muoncell=Muon_Clus_FirstCell->ID(); + for (; FE_FirstCell != FE_LastCell; FE_FirstCell++){ + Identifier index_FEcell=FE_FirstCell->ID(); + if(index_FEcell==index_muoncell){ + isCellMatched=true; + } + } + } // end of double loop block for cell matching + if(isCellMatched){ // cell matched => Link the two objects. // Add Muon element link to a vector // index() is the unique index of the muon in the muon container FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); - } // end of matching cluster index block + } + + } // end of calocluster specific block } // loop over caloclusters -- GitLab From ce9a2128a81b9d73db808243cfde64c5d1bd476d Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Wed, 30 Sep 2020 17:49:39 +0100 Subject: [PATCH 12/23] Adding the energy fraction in the FE clusters used for matching in cell matching algorithm --- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 5aa4d8925fb7..45dcad87a475 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -145,6 +145,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //design the vector of ElementLinks std::vector<MuonLink_t> FEMuonLinks; + std::vector<double> FE_efrac_clustermatch; for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ //Retrieve the ElementLink vector of clusters const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); @@ -181,23 +182,35 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const CaloClusterCellLink::const_iterator Muon_Clus_FirstCell=Muon_Clus_CellLink->begin(); CaloClusterCellLink::const_iterator Muon_Clus_LastCell=Muon_Clus_CellLink->end(); - //Now we check if any match. Current algo allows for at least one match. + //Now we check if any match and sum the energy of the cells that are matched. Current algo allows for at least one match. bool isCellMatched=false; - for(; Muon_Clus_FirstCell != Muon_Clus_LastCell; ++Muon_Clus_FirstCell){ - Identifier index_muoncell=Muon_Clus_FirstCell->ID(); - for (; FE_FirstCell != FE_LastCell; FE_FirstCell++){ - Identifier index_FEcell=FE_FirstCell->ID(); - if(index_FEcell==index_muoncell){ + double FE_sum_matched_cellEnergy=0; + for(;FE_FirstCell != FE_LastCell; ++FE_FirstCell){ + Identifier index_FECell=FE_FirstCell->ID(); + for(; Muon_Clus_FirstCell != Muon_Clus_LastCell; ++Muon_Clus_FirstCell){ + Identifier index_muoncell=Muon_Clus_FirstCell->ID(); + if(index_FECell==index_muoncell){ isCellMatched=true; + double FE_cell_energy=FE_FirstCell->e(); + FE_sum_matched_cellEnergy=FE_sum_matched_cellEnergy+FE_cell_energy; } } - } // end of double loop block for cell matching + } // end of cell matching double loop + double frac_FE_cluster_energy_matched=0; + //retrieve total cluster energy from the FE cluster + double tot_FE_cluster_energy=FE_cluster->e(); + if(tot_FE_cluster_energy!=0){ // ! div 0 + frac_FE_cluster_energy_matched=FE_sum_matched_cellEnergy / tot_FE_cluster_energy ; + } + if(isCellMatched){ // cell matched => Link the two objects. // Add Muon element link to a vector // index() is the unique index of the muon in the muon container FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + // save the energy fraction used in the cluster matching + FE_efrac_clustermatch.push_back(frac_FE_cluster_energy_matched); } -- GitLab From f9954e2f7f0e664266d08272af6c1b9e607606b5 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Thu, 1 Oct 2020 18:34:11 +0100 Subject: [PATCH 13/23] added IO for the fraction of energy used in the WriteHandle --- .../eflowRec/eflowRec/PFMuonFlowElementAssoc.h | 5 ++++- Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 614b28467316..df78e9cd954d 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -54,11 +54,14 @@ private: /** Write key for adding Muon link decorations to charged Flow Elements **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteDecorKey; - /* Write key for adding neutral Flow Element link decorations to muons **/ + /** Write key for adding neutral Flow Element link decorations to muons **/ SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteDecorKey; /** Write key for adding Muon link decorations to neutral Flow Elements **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; + /** Write key for adding fraction of energy used in cell matching decorations to muons **/ + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteDecorKey; + /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 45dcad87a475..16ac967d19b5 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -29,7 +29,9 @@ PFMuonFlowElementAssoc::PFMuonFlowElementAssoc(const std::string& name, declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.FE_MuonLinks"); // updated Charge declareProperty ("MuonNeutralFlowElementDecorKey", m_muonNeutralFEWriteDecorKey = "Muons.neutralFELinks"); declareProperty ("NeutralFlowElementMuonDecorKey",m_NeutralFEmuonWriteDecorKey = "JetETMissNeutralFlowElements.FE_MuonLinks"); -} + declareProperty ("NeutralFlowElement_efrac_matched_MuonDecorKey",m_NeutralFE_efrac_match_muonWriteDecorKey= "JetETMissNeutralFlowElements.FE_efrac_matched_muon"); +} + PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} // ============================================================= @@ -48,6 +50,7 @@ StatusCode PFMuonFlowElementAssoc::initialize() { ATH_CHECK(m_muonReadHandleKey.initialize()); ATH_CHECK(m_chargedFEReadHandleKey.initialize()); ATH_CHECK(m_neutralFEReadHandleKey.initialize()); + ATH_CHECK(m_NeutralFE_efrac_match_muonWriteDecorKey.initialize()); ATH_MSG_DEBUG("Initialization completed successfully"); @@ -75,6 +78,9 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey,ctx); SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey,ctx); + //extra container handle with frac_e matched between neutral FE cluster and Muon CaloCluster + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteDecorKey,ctx); + //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_chargedFEReadHandleKey,ctx); @@ -219,6 +225,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const } // loop over caloclusters } // loop over muons NeutralFEmuonWriteDecorHandle(*FE)=FEMuonLinks; + NeutralFE_efrac_match_muonWriteDecorHandle(*FE)=FE_efrac_clustermatch; } // loop over neutral FE }// end of the Gaudi check block -- GitLab From bcd1615d33a20c856a8fffef969fe857a4cb2260 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 2 Oct 2020 16:32:53 +0100 Subject: [PATCH 14/23] Use writehandle configuration on the output --- .../eflowRec/PFMuonFlowElementAssoc.h | 12 +++++---- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 27 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index df78e9cd954d..9afe4167cd65 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -50,17 +50,19 @@ private: /** Write key for adding charged Flow Element link decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteDecorKey; + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteHandleKey{this,"MuonContainer","Muons.chargedFELinks","WriteHandleKey for muon link to charged FlowElements"}; + /** Write key for adding Muon link decorations to charged Flow Elements **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteDecorKey; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteHandleKey{this,"FlowElementOutputName","JetETMissChargedFlowElements.FE_MuonLinks","WriteHandleKey for Charged Flow Elements coupled to muons"}; /** Write key for adding neutral Flow Element link decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteDecorKey; + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteHandleKey{this,"MuonContainer","Muons.neutralFELinks","WriteHandleKey for muon links to neutral FlowElement"}; + /** Write key for adding Muon link decorations to neutral Flow Elements **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteDecorKey; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteHandleKey{this,"FlowElementContainer","JetETMissNeutralFlowElements.MuonLinks","WriteHandleKey for neutral flow Elements to Muons"}; /** Write key for adding fraction of energy used in cell matching decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteDecorKey; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteHandleKey{this,"FlowElementContainer","JetETMissNeutralFlowElements.FE_efrac_matched_muon","WriteHandleKey for neutral FlowElements to Muons"}; /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 16ac967d19b5..6b687ab1d6a7 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -25,11 +25,7 @@ PFMuonFlowElementAssoc::PFMuonFlowElementAssoc(const std::string& name, AthReentrantAlgorithm(name, pSvcLocator) { // Declare the decoration keys - declareProperty ("MuonChargedFlowElementDecorKey", m_muonChargedFEWriteDecorKey = "Muons.chargedFELinks"); // updated muon container with the new link - declareProperty("ChargedFlowElementMuonDecorKey", m_ChargedFEmuonWriteDecorKey="JetETMissChargedFlowElements.FE_MuonLinks"); // updated Charge - declareProperty ("MuonNeutralFlowElementDecorKey", m_muonNeutralFEWriteDecorKey = "Muons.neutralFELinks"); - declareProperty ("NeutralFlowElementMuonDecorKey",m_NeutralFEmuonWriteDecorKey = "JetETMissNeutralFlowElements.FE_MuonLinks"); - declareProperty ("NeutralFlowElement_efrac_matched_MuonDecorKey",m_NeutralFE_efrac_match_muonWriteDecorKey= "JetETMissNeutralFlowElements.FE_efrac_matched_muon"); + } PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} @@ -40,17 +36,18 @@ StatusCode PFMuonFlowElementAssoc::initialize() { ATH_MSG_DEBUG("Initializing " << name() << "..."); // Initialise the decoration keys - ATH_CHECK(m_muonChargedFEWriteDecorKey.initialize()); - ATH_CHECK(m_muonNeutralFEWriteDecorKey.initialize()); + ATH_CHECK(m_muonChargedFEWriteHandleKey.initialize()); + ATH_CHECK(m_muonNeutralFEWriteHandleKey.initialize()); - ATH_CHECK(m_ChargedFEmuonWriteDecorKey.initialize()); - ATH_CHECK(m_NeutralFEmuonWriteDecorKey.initialize()); + ATH_CHECK(m_ChargedFEmuonWriteHandleKey.initialize()); + ATH_CHECK(m_NeutralFEmuonWriteHandleKey.initialize()); + ATH_CHECK(m_NeutralFE_efrac_match_muonWriteHandleKey.initialize()); //init ReadHandleKeys ATH_CHECK(m_muonReadHandleKey.initialize()); ATH_CHECK(m_chargedFEReadHandleKey.initialize()); ATH_CHECK(m_neutralFEReadHandleKey.initialize()); - ATH_CHECK(m_NeutralFE_efrac_match_muonWriteDecorKey.initialize()); + ATH_MSG_DEBUG("Initialization completed successfully"); @@ -72,14 +69,14 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const ATH_MSG_DEBUG("Started execute step"); // Get container for muons - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteDecorKey,ctx); - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonNeutralFEWriteDecorHandle (m_muonNeutralFEWriteDecorKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonNeutralFEWriteDecorHandle (m_muonNeutralFEWriteHandleKey,ctx); // get container for charged flow elements - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteDecorKey,ctx); - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteDecorKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteHandleKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteHandleKey,ctx); //extra container handle with frac_e matched between neutral FE cluster and Muon CaloCluster - SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteDecorKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteHandleKey,ctx); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon -- GitLab From ac38bb6f93ca67e4e506b7aa7487488f984aec23 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Wed, 7 Oct 2020 16:21:15 +0100 Subject: [PATCH 15/23] unique gaudi names for writedecorhandles --- .../eflowRec/eflowRec/PFMuonFlowElementAssoc.h | 10 +++++----- Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 9afe4167cd65..a192b9b376fa 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -50,19 +50,19 @@ private: /** Write key for adding charged Flow Element link decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteHandleKey{this,"MuonContainer","Muons.chargedFELinks","WriteHandleKey for muon link to charged FlowElements"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonChargedFEWriteHandleKey{this,"MuonContainer_chargedFELinks","Muons.chargedFELinks","WriteHandleKey for muon link to charged FlowElements"}; /** Write key for adding Muon link decorations to charged Flow Elements **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteHandleKey{this,"FlowElementOutputName","JetETMissChargedFlowElements.FE_MuonLinks","WriteHandleKey for Charged Flow Elements coupled to muons"}; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_ChargedFEmuonWriteHandleKey{this,"JetETMissChargedFlowElements_FE_MuonLinks","JetETMissChargedFlowElements.FE_MuonLinks","WriteHandleKey for Charged Flow Elements coupled to muons"}; /** Write key for adding neutral Flow Element link decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteHandleKey{this,"MuonContainer","Muons.neutralFELinks","WriteHandleKey for muon links to neutral FlowElement"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFEWriteHandleKey{this,"MuonContainer_neutralFELinks","Muons.neutralFELinks","WriteHandleKey for muon links to neutral FlowElement"}; /** Write key for adding Muon link decorations to neutral Flow Elements **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteHandleKey{this,"FlowElementContainer","JetETMissNeutralFlowElements.MuonLinks","WriteHandleKey for neutral flow Elements to Muons"}; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteHandleKey{this,"JetETMissNeutralFlowElementContainer_FE_MuonLinks","JetETMissNeutralFlowElements.FE_MuonLinks","WriteHandleKey for neutral flow Elements to Muons"}; /** Write key for adding fraction of energy used in cell matching decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteHandleKey{this,"FlowElementContainer","JetETMissNeutralFlowElements.FE_efrac_matched_muon","WriteHandleKey for neutral FlowElements to Muons"}; + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteHandleKey{this,"FlowElementContainer_FE_efrac_matched_muon","JetETMissNeutralFlowElements.FE_efrac_matched_muon","WriteHandleKey for neutral FlowElements to Muons"}; /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 6b687ab1d6a7..609fd7fc7f0c 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -205,7 +205,8 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const if(tot_FE_cluster_energy!=0){ // ! div 0 frac_FE_cluster_energy_matched=FE_sum_matched_cellEnergy / tot_FE_cluster_energy ; } - + if(frac_FE_cluster_energy_matched>0){ + ATH_MSG_INFO("Fraction of energy used in match: "<<frac_FE_cluster_energy_matched<<", ismatched? "<<isCellMatched<<"");} if(isCellMatched){ // cell matched => Link the two objects. // Add Muon element link to a vector // index() is the unique index of the muon in the muon container -- GitLab From bc98783094515dfdd1e0423dc8b77be93f28fc6f Mon Sep 17 00:00:00 2001 From: manthony <matthew.thomas.anthony@cern.ch> Date: Wed, 14 Oct 2020 12:41:37 +0200 Subject: [PATCH 16/23] patch clids --- Event/xAOD/xAODPFlow/CMakeLists.txt | 2 ++ Event/xAOD/xAODPFlow/Root/clids.cxx | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 Event/xAOD/xAODPFlow/Root/clids.cxx diff --git a/Event/xAOD/xAODPFlow/CMakeLists.txt b/Event/xAOD/xAODPFlow/CMakeLists.txt index aad1df5cc882..d5a3754372bf 100644 --- a/Event/xAOD/xAODPFlow/CMakeLists.txt +++ b/Event/xAOD/xAODPFlow/CMakeLists.txt @@ -25,3 +25,5 @@ atlas_add_dictionary( xAODPFlowDict ${_selectionFile} LINK_LIBRARIES AthLinks xAODCore xAODPFlow EXTRA_FILES Root/dict/*.cxx ) + +atlas_generate_cliddb( xAODPFlow) \ No newline at end of file diff --git a/Event/xAOD/xAODPFlow/Root/clids.cxx b/Event/xAOD/xAODPFlow/Root/clids.cxx new file mode 100644 index 000000000000..2c9289573aec --- /dev/null +++ b/Event/xAOD/xAODPFlow/Root/clids.cxx @@ -0,0 +1,11 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +// Ensure that the headers for the interface classes get included +// by some object in this library, so that CLID registration will take +// place properly. + +#include "xAODPFlow/FlowElementContainer.h" +#include "xAODPFlow/PFOContainer.h" +#include "xAODPFlow/TrackCaloClusterContainer.h" -- GitLab From 2f493c74fa3076f7dd5b9be03258367f61e1768a Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Thu, 22 Oct 2020 15:33:27 +0100 Subject: [PATCH 17/23] include additional studies discussed at MCP meeting 22.10.2020 --- .../eflowRec/PFMuonFlowElementAssoc.h | 16 ++++- .../share/run_ESDStandardReco_FlowElements.py | 40 +++++++++++++ .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 58 ++++++++++++++++--- 3 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index a192b9b376fa..756635c62ecb 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -61,8 +61,20 @@ private: /** Write key for adding Muon link decorations to neutral Flow Elements **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuonWriteHandleKey{this,"JetETMissNeutralFlowElementContainer_FE_MuonLinks","JetETMissNeutralFlowElements.FE_MuonLinks","WriteHandleKey for neutral flow Elements to Muons"}; - /** Write key for adding fraction of energy used in cell matching decorations to muons **/ - SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteHandleKey{this,"FlowElementContainer_FE_efrac_matched_muon","JetETMissNeutralFlowElements.FE_efrac_matched_muon","WriteHandleKey for neutral FlowElements to Muons"}; + /** Write key for adding fraction of nFlowElement cluster energy used in cell matching decoration of FlowElementContainer - EXPERIMENTAL **/ + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFE_efrac_match_muonWriteHandleKey{this,"FlowElementContainer_FE_efrac_matched_muon","JetETMissNeutralFlowElements.FE_efrac_matched_muon","WriteHandleKey for the fraction of neutral FlowElements cluster energy used to match to Muons"}; + + /** Write key for adding fraction of Muon cluster energy used in cell matching decoration of MuonContainer -EXPERIMENTAL **/ + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muonNeutralFE_muon_efrac_WriteDecorHandleKey{this,"MuonContainer_muon_efrac_matched_FE","Muons.muon_efrac_matched_FE","WriteHandleKey for the fraction of muon cluster energy used to match to neutral Flow Elements"}; + + /** Write key to count number of muons matched to a given neutral FE - EXPERIMENTAL **/ + SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuon_nMatches_WriteDecorHandleKey{this,"FlowElementContainer_nMatchedMuons","JetETMissNeutralFlowElements.FE_nMatchedMuons","WriteHandleKey for the number of muons matched to a given neutral flow element"}; + + /** Write key to count number of calo clusters a given muon actually has **/ + SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muon_ClusterInfo_nCluster_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_nClusters","Muons.ClusterInfo_nClusters","WriteHandleKey for the number of calo clusters associated to each muon"}; + + /** Write key to measure dR between calo clusters and the muon **/ + SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaRVec","Muons.ClusterInfo_deltaRVec","WriteHandleKey for the delta R between the muon and it's associated calocluster(s)"}; /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; diff --git a/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py b/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py new file mode 100644 index 000000000000..be2b490533ec --- /dev/null +++ b/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py @@ -0,0 +1,40 @@ +#This file is to run standard reconstruction + Flow Elements on an ESD file (Primarily the Flow Element configuration) + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +#athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/mc16_13TeV.426327.ParticleGun_single_piminus_logE5to2000.recon.ESD.e5661_s3170_r9857/mc16_13TeV/ESD.11980044._002219.pool.root.1'] +#athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/ttbar_nonallhad_10788/mc16_13TeV/ESD.15852896._000467.pool.root.1'] +athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/mc16_13TeV.410470.PhPy8EG_A14_ttbar_hdamp258p75_nonallhad.recon.ESD.e6337_e5984_s3170_r11596/mc16_13TeV/ESD.19439305._000011.pool.root.1'] +#athenaCommonFlags.FilesInput=["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/RecExRecoTest/mc16_13TeV.361022.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ2W.recon.ESD.e3668_s3170_r10572_homeMade.pool.root"] +doDumpProperties=True + +from RecExConfig.RecAlgsFlags import recAlgs +recAlgs.doEFlow.set_Value_and_Lock(True) + +from eflowRec.eflowRecFlags import jobproperties +jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) + +from RecExConfig.RecFlags import rec +rec.doTrigger.set_Value_and_Lock(False) + +#change some calo flags +#from CaloRec.CaloRecFlags import jobproperties +#jobproperties.CaloRecFlags.Enabled.set_Value_and_Lock(True) +#jobproperties.CaloRecFlags.doCaloCluster.set_Value_and_Lock(True) +#jobproperties.CaloRecFlags.doEmCluster.set_Value_and_Lock(False) +#jobproperties.CaloRecFlags.doCaloTopoCluster.set_Value_and_Lock(True) + +#Turn of TAG +rec.doWriteTAG.set_Value_and_Lock(False) + +include("LArConditionsCommon/LArIdMap_MC_jobOptions.py") +from CaloRec import CaloClusterTopoCoolFolder +from CaloTools.CaloNoiseCondAlg import CaloNoiseCondAlg +CaloNoiseCondAlg() +CaloNoiseCondAlg(noisetype="electronicNoise") +athenaCommonFlags.EvtMax=100 +#Run pflopw jet finding - this cannot be enabled via reconstruction flags currently! (without enabling other things we don't want) +UserAlgs = ["eflowRec/jetAlgs.py"] +include ("RecExCommon/RecExCommon_topOptions.py") + +ServiceMgr.MessageSvc.defaultLimit = 9999999 +include ("METReconstruction/METReconstruction_jobOptions.py") diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 609fd7fc7f0c..b299d543e408 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -75,9 +75,13 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > ChargedFEmuonWriteDecorHandle (m_ChargedFEmuonWriteHandleKey,ctx); SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<MuonLink_t> > NeutralFEmuonWriteDecorHandle(m_NeutralFEmuonWriteHandleKey,ctx); - //extra container handle with frac_e matched between neutral FE cluster and Muon CaloCluster + //extra container handles between neutral FE cluster and Muon CaloCluster - these are all for studies based on neutral Flow Element matching - All of these handles are experimental SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteHandleKey,ctx); - + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<double> >muonNeutralFE_muon_efrac_WriteDecorHandle(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer,int> NeutralFEmuon_nMatches_WriteDecorHandle(m_NeutralFEmuon_nMatches_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<double> > muon_ClusterInfo_deltaRVec_WriteDecorHandle(m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,int> muon_ClusterInfo_nCluster_WriteDecorHandle(m_muon_ClusterInfo_nCluster_WriteDecorHandleKey,ctx); + //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon SG::ReadHandle<xAOD::FlowElementContainer> ChargedFEReadHandle(m_chargedFEReadHandleKey,ctx); @@ -86,6 +90,9 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //now init some Flow element link containers std::vector<std::vector<FlowElementLink_t> > muonChargedFEVec(muonReadHandle->size()); std::vector<std::vector<FlowElementLink_t> > muonNeutralFEVec(muonReadHandle->size()); + + //for neutral flow element studies + std::vector<std::vector<double> >muonNeutralFE_frac_cluster_energy_matched_Vec(muonReadHandle->size()); //Loop over the Flow Elements @@ -131,6 +138,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const if(m_LinkNeutralFEClusters){ ATH_MSG_DEBUG("Experimental: Cluster Linkers between neutral FEs and Muons are used"); for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ + int nMatchedFE=0; //get the index of the cluster corresponding to the Neutral FlowElements size_t FEclusterindex=FE->otherObjects().at(0)->index(); @@ -149,6 +157,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //design the vector of ElementLinks std::vector<MuonLink_t> FEMuonLinks; std::vector<double> FE_efrac_clustermatch; + std::vector<double> Muon_efrac_clustermatch; for (const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle ){ //Retrieve the ElementLink vector of clusters const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); @@ -170,6 +179,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + nMatchedFE++; // count number of matches between FE and muons } // check block of index matching } // loop over list of topoclusters } // end of loop over element links @@ -188,6 +198,8 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //Now we check if any match and sum the energy of the cells that are matched. Current algo allows for at least one match. bool isCellMatched=false; double FE_sum_matched_cellEnergy=0; + double Muon_sum_matched_cellEnergy=0; + for(;FE_FirstCell != FE_LastCell; ++FE_FirstCell){ Identifier index_FECell=FE_FirstCell->ID(); for(; Muon_Clus_FirstCell != Muon_Clus_LastCell; ++Muon_Clus_FirstCell){ @@ -196,6 +208,8 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const isCellMatched=true; double FE_cell_energy=FE_FirstCell->e(); FE_sum_matched_cellEnergy=FE_sum_matched_cellEnergy+FE_cell_energy; + double Muon_cell_energy=Muon_Clus_FirstCell->e(); + Muon_sum_matched_cellEnergy= Muon_sum_matched_cellEnergy+Muon_cell_energy; } } } // end of cell matching double loop @@ -205,16 +219,26 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const if(tot_FE_cluster_energy!=0){ // ! div 0 frac_FE_cluster_energy_matched=FE_sum_matched_cellEnergy / tot_FE_cluster_energy ; } + double tot_muon_cluster_energy=cluster->e(); + double frac_muon_cluster_energy_matched=0; + if(tot_muon_cluster_energy!=0){ + frac_muon_cluster_energy_matched=Muon_sum_matched_cellEnergy/tot_muon_cluster_energy; + } if(frac_FE_cluster_energy_matched>0){ - ATH_MSG_INFO("Fraction of energy used in match: "<<frac_FE_cluster_energy_matched<<", ismatched? "<<isCellMatched<<"");} + ATH_MSG_INFO("Fraction of FE cluster energy used in match: "<<frac_FE_cluster_energy_matched<<", ismatched? "<<isCellMatched<<""); + ATH_MSG_INFO("Fraction of Muon cluster energy used in match: "<<frac_muon_cluster_energy_matched<<""); + } + if(isCellMatched){ // cell matched => Link the two objects. // Add Muon element link to a vector // index() is the unique index of the muon in the muon container FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); - // index() is the unique index of the cFlowElement in the cFlowElementcontaine + // index() is the unique index of the nFlowElement in the nFlowElementcontainer muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); - // save the energy fraction used in the cluster matching - FE_efrac_clustermatch.push_back(frac_FE_cluster_energy_matched); + // save the energy fraction used in the cluster matching - mostly for debug/extension studies + FE_efrac_clustermatch.push_back(frac_FE_cluster_energy_matched); // fraction of FE cluster energy matched + muonNeutralFE_frac_cluster_energy_matched_Vec.at(muon->index()).push_back(frac_muon_cluster_energy_matched);//fraction of Muon cluster energy matched + nMatchedFE++; // count number of matches incrementally } @@ -222,6 +246,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const } // loop over caloclusters } // loop over muons + NeutralFEmuon_nMatches_WriteDecorHandle(*FE)=nMatchedFE; NeutralFEmuonWriteDecorHandle(*FE)=FEMuonLinks; NeutralFE_efrac_match_muonWriteDecorHandle(*FE)=FE_efrac_clustermatch; } // loop over neutral FE @@ -234,13 +259,30 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const for(const xAOD::Muon* muon: *muonChargedFEWriteDecorHandle){ muonChargedFEWriteDecorHandle(*muon)=muonChargedFEVec.at(muon->index()); } // end of muon loop - if(m_LinkNeutralFEClusters){ + if(m_LinkNeutralFEClusters){// Experimental for(const xAOD::Muon* muon: *muonNeutralFEWriteDecorHandle){ if(muonNeutralFEVec.size()>0){ muonNeutralFEWriteDecorHandle(*muon)=muonNeutralFEVec.at(muon->index()); + muonNeutralFE_muon_efrac_WriteDecorHandle(*muon)=muonNeutralFE_frac_cluster_energy_matched_Vec.at(muon->index()); + } + // For debug of the muon clusters used, add also: dR between caloclusters and number of caloclusters associated to each muon. + //retrieve element link again to cluster container + const ElementLink<xAOD::CaloClusterContainer> ClusterContLink=muon->clusterLink(); + // use elem link to retrieve container + const xAOD::CaloClusterContainer* MuonClusterContainer=ClusterContLink.getDataPtr(); + int nClusters=MuonClusterContainer->size(); + TLorentzVector muon_fourvec=muon->p4(); + std::vector<double> vec_deltaR_muon_cluster; + // retrieve the vector of delta R between muon and its associated calo cluster(s). + for (const xAOD::CaloCluster* muon_cluster: *MuonClusterContainer){ + TLorentzVector cluster_fourvec=muon_cluster->p4(); + double deltaR_muon_cluster=cluster_fourvec.DeltaR(muon_fourvec); + vec_deltaR_muon_cluster.push_back(deltaR_muon_cluster); } + muon_ClusterInfo_deltaRVec_WriteDecorHandle(*muon)=vec_deltaR_muon_cluster; + muon_ClusterInfo_nCluster_WriteDecorHandle(*muon)=nClusters; } - } + }// end of experimental block ATH_MSG_DEBUG("Execute completed successfully"); return StatusCode::SUCCESS; -- GitLab From 70b82713f11ec9893eb50c59bc768a4e27a31224 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Thu, 22 Oct 2020 17:15:04 +0100 Subject: [PATCH 18/23] fixing initialization to run properly --- Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h | 8 +++++--- Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 756635c62ecb..dc63ed672c3c 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -70,13 +70,15 @@ private: /** Write key to count number of muons matched to a given neutral FE - EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuon_nMatches_WriteDecorHandleKey{this,"FlowElementContainer_nMatchedMuons","JetETMissNeutralFlowElements.FE_nMatchedMuons","WriteHandleKey for the number of muons matched to a given neutral flow element"}; - /** Write key to count number of calo clusters a given muon actually has **/ + /** Write key to count number of calo clusters a given muon actually has - EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muon_ClusterInfo_nCluster_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_nClusters","Muons.ClusterInfo_nClusters","WriteHandleKey for the number of calo clusters associated to each muon"}; - /** Write key to measure dR between calo clusters and the muon **/ + /** Write key to measure dR between calo clusters and the muon -EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaRVec","Muons.ClusterInfo_deltaRVec","WriteHandleKey for the delta R between the muon and it's associated calocluster(s)"}; - /***Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ + + + /** Gaudi Property to configure linkage of Neutral Flow Elements to Muon clusters (EXPERIMENTAL - default = False/OFF) **/ Gaudi::Property<bool> m_LinkNeutralFEClusters{this,"m_LinkNeutralFEClusters",false,"Toggle usage of linkage of Neutral FlowElements - false by default (EXPERIMENTAL)"}; /** diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index b299d543e408..cd0f9b7e8758 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -42,6 +42,12 @@ StatusCode PFMuonFlowElementAssoc::initialize() { ATH_CHECK(m_ChargedFEmuonWriteHandleKey.initialize()); ATH_CHECK(m_NeutralFEmuonWriteHandleKey.initialize()); ATH_CHECK(m_NeutralFE_efrac_match_muonWriteHandleKey.initialize()); + + //init the experimental keys + ATH_CHECK(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey.initialize()); + ATH_CHECK(m_NeutralFEmuon_nMatches_WriteDecorHandleKey.initialize()); + ATH_CHECK(m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey.initialize()); + ATH_CHECK(m_muon_ClusterInfo_nCluster_WriteDecorHandleKey.initialize()); //init ReadHandleKeys ATH_CHECK(m_muonReadHandleKey.initialize()); @@ -179,6 +185,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + ATH_MSG_INFO("Got a match between NFE and Muon"); nMatchedFE++; // count number of matches between FE and muons } // check block of index matching } // loop over list of topoclusters -- GitLab From f59eeed0294de3b289b1c3102c7a6683d36985fd Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 23 Oct 2020 15:34:39 +0100 Subject: [PATCH 19/23] fix ElementLink Retrieve of CaloCluster for NFE --- .../eflowRec/PFMuonFlowElementAssoc.h | 4 +- .../eflowRec/share/PFlowMTConfig.py | 2 +- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 67 ++++++++----------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index dc63ed672c3c..05417cb10217 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -70,11 +70,9 @@ private: /** Write key to count number of muons matched to a given neutral FE - EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuon_nMatches_WriteDecorHandleKey{this,"FlowElementContainer_nMatchedMuons","JetETMissNeutralFlowElements.FE_nMatchedMuons","WriteHandleKey for the number of muons matched to a given neutral flow element"}; - /** Write key to count number of calo clusters a given muon actually has - EXPERIMENTAL **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer> m_muon_ClusterInfo_nCluster_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_nClusters","Muons.ClusterInfo_nClusters","WriteHandleKey for the number of calo clusters associated to each muon"}; /** Write key to measure dR between calo clusters and the muon -EXPERIMENTAL **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaRVec","Muons.ClusterInfo_deltaRVec","WriteHandleKey for the delta R between the muon and it's associated calocluster(s)"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaR_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaRVec","Muons.ClusterInfo_deltaRVec","WriteHandleKey for the delta R between the muon and it's associated calocluster(s)"}; diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index f47e5e1aa725..a314c60c7d66 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -281,7 +281,7 @@ if jobproperties.eflowRecFlags.useFlowElements: PFMuonFlowElementAssocAlg=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements (FE) PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=True - PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=False # second switch combined with first implies Muon topoclusters are linked to neutral Flow Elements + PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=True # second switch combined with first implies Muon topoclusters are linked to neutral Flow Elements topSequence += PFMuonFlowElementAssocAlg diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index cd0f9b7e8758..fe061c1f39bb 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -33,7 +33,7 @@ PFMuonFlowElementAssoc::~PFMuonFlowElementAssoc() {} // ============================================================= StatusCode PFMuonFlowElementAssoc::initialize() { - ATH_MSG_DEBUG("Initializing " << name() << "..."); + ATH_MSG_INFO("Initializing " << name() << "..."); // Initialise the decoration keys ATH_CHECK(m_muonChargedFEWriteHandleKey.initialize()); @@ -46,8 +46,7 @@ StatusCode PFMuonFlowElementAssoc::initialize() { //init the experimental keys ATH_CHECK(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey.initialize()); ATH_CHECK(m_NeutralFEmuon_nMatches_WriteDecorHandleKey.initialize()); - ATH_CHECK(m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey.initialize()); - ATH_CHECK(m_muon_ClusterInfo_nCluster_WriteDecorHandleKey.initialize()); + ATH_CHECK(m_muon_ClusterInfo_deltaR_WriteDecorHandleKey.initialize()); //init ReadHandleKeys ATH_CHECK(m_muonReadHandleKey.initialize()); @@ -55,7 +54,7 @@ StatusCode PFMuonFlowElementAssoc::initialize() { ATH_CHECK(m_neutralFEReadHandleKey.initialize()); - ATH_MSG_DEBUG("Initialization completed successfully"); + ATH_MSG_INFO("Initialization completed successfully"); return StatusCode::SUCCESS; } @@ -72,7 +71,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const // WriteDecorHandles for the charged/neutral Flow Elements and Muons // Links a Muon that has a track to a charged flow element if possible - ATH_MSG_DEBUG("Started execute step"); + ATH_MSG_INFO("Started execute step"); // Get container for muons SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteHandleKey,ctx); @@ -85,8 +84,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteHandleKey,ctx); SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<double> >muonNeutralFE_muon_efrac_WriteDecorHandle(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey,ctx); SG::WriteDecorHandle<xAOD::FlowElementContainer,int> NeutralFEmuon_nMatches_WriteDecorHandle(m_NeutralFEmuon_nMatches_WriteDecorHandleKey,ctx); - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<double> > muon_ClusterInfo_deltaRVec_WriteDecorHandle(m_muon_ClusterInfo_deltaRVec_WriteDecorHandleKey,ctx); - SG::WriteDecorHandle<xAOD::MuonContainer,int> muon_ClusterInfo_nCluster_WriteDecorHandle(m_muon_ClusterInfo_nCluster_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer,double > muon_ClusterInfo_deltaR_WriteDecorHandle(m_muon_ClusterInfo_deltaR_WriteDecorHandleKey,ctx); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon @@ -142,7 +140,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const m_UseMuonTopoClusters (True= Case 1, False = Case 2) **/ if(m_LinkNeutralFEClusters){ - ATH_MSG_DEBUG("Experimental: Cluster Linkers between neutral FEs and Muons are used"); + ATH_MSG_INFO("Experimental: Cluster Linkers between neutral FEs and Muons are used"); for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ int nMatchedFE=0; //get the index of the cluster corresponding to the Neutral FlowElements @@ -169,26 +167,22 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const const ElementLink<xAOD::CaloClusterContainer> ClusterLink=muon->clusterLink(); //access object from element link - const xAOD::CaloClusterContainer* clustercont = ClusterLink.getDataPtr(); - - for (const xAOD::CaloCluster* cluster: *clustercont){ + const xAOD::CaloCluster* cluster = *ClusterLink; // de-ref the element link to retrieve the pointer to the original object if(m_UseMuonTopoClusters){ // get the linker to the topo clusters std::vector<ElementLink<xAOD::CaloClusterContainer>> linksToTopoClusters=cluster->auxdata<std::vector<ElementLink<xAOD::CaloClusterContainer>> >("constituentClusterLinks"); for (ElementLink<xAOD::CaloClusterContainer> TopoClusterLink: linksToTopoClusters){ - const xAOD::CaloClusterContainer* MuonTopoClusters=TopoClusterLink.getDataPtr(); - for (const xAOD::CaloCluster* MuonTopoCluster: *MuonTopoClusters){ - size_t MuonTopoCluster_index=MuonTopoCluster->index(); - if(MuonTopoCluster_index==FEclusterindex){ - // Add Muon element link to a vector - // index() is the unique index of the muon in the muon container - FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); - // index() is the unique index of the cFlowElement in the cFlowElementcontaine - muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); - ATH_MSG_INFO("Got a match between NFE and Muon"); - nMatchedFE++; // count number of matches between FE and muons - } // check block of index matching - } // loop over list of topoclusters + const xAOD::CaloCluster* MuonTopoCluster=*TopoClusterLink; // de-ref the link to get the topo-cluster + size_t MuonTopoCluster_index=MuonTopoCluster->index(); + if(MuonTopoCluster_index==FEclusterindex){ + // Add Muon element link to a vector + // index() is the unique index of the muon in the muon container + FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); + // index() is the unique index of the cFlowElement in the cFlowElementcontaine + muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); + ATH_MSG_INFO("Got a match between NFE and Muon"); + nMatchedFE++; // count number of matches between FE and muons + } // check block of index matching } // end of loop over element links } //end of TopoCluster specific block else{ // case when we don't use Topoclusters, just match the caloclusters to the flow element @@ -250,8 +244,8 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const } // end of calocluster specific block - - } // loop over caloclusters + + // loop over caloclusters } // loop over muons NeutralFEmuon_nMatches_WriteDecorHandle(*FE)=nMatchedFE; NeutralFEmuonWriteDecorHandle(*FE)=FEMuonLinks; @@ -273,24 +267,19 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const muonNeutralFE_muon_efrac_WriteDecorHandle(*muon)=muonNeutralFE_frac_cluster_energy_matched_Vec.at(muon->index()); } // For debug of the muon clusters used, add also: dR between caloclusters and number of caloclusters associated to each muon. - //retrieve element link again to cluster container + //retrieve element link again to cluster const ElementLink<xAOD::CaloClusterContainer> ClusterContLink=muon->clusterLink(); // use elem link to retrieve container - const xAOD::CaloClusterContainer* MuonClusterContainer=ClusterContLink.getDataPtr(); - int nClusters=MuonClusterContainer->size(); + const xAOD::CaloCluster* MuonCluster=*ClusterContLink; TLorentzVector muon_fourvec=muon->p4(); - std::vector<double> vec_deltaR_muon_cluster; - // retrieve the vector of delta R between muon and its associated calo cluster(s). - for (const xAOD::CaloCluster* muon_cluster: *MuonClusterContainer){ - TLorentzVector cluster_fourvec=muon_cluster->p4(); - double deltaR_muon_cluster=cluster_fourvec.DeltaR(muon_fourvec); - vec_deltaR_muon_cluster.push_back(deltaR_muon_cluster); - } - muon_ClusterInfo_deltaRVec_WriteDecorHandle(*muon)=vec_deltaR_muon_cluster; - muon_ClusterInfo_nCluster_WriteDecorHandle(*muon)=nClusters; + TLorentzVector muon_cluster_fourvec=MuonCluster->p4(); + double deltaR_muon_cluster=0; + deltaR_muon_cluster=muon_fourvec.DeltaR(muon_cluster_fourvec); + // retrieve the vector of delta R between muon and its associated calo cluster. + muon_ClusterInfo_deltaR_WriteDecorHandle(*muon)=deltaR_muon_cluster; } }// end of experimental block - ATH_MSG_DEBUG("Execute completed successfully"); + ATH_MSG_INFO("Execute completed successfully"); return StatusCode::SUCCESS; } -- GitLab From b5a393bc6ee51eaa21bae2dcd11cb98fd08a6445 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 23 Oct 2020 16:55:30 +0100 Subject: [PATCH 20/23] Reset PFlowMTConfig JO back to default --- Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h | 2 +- Reconstruction/eflowRec/share/PFlowMTConfig.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 05417cb10217..5a7ff40f33f9 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -72,7 +72,7 @@ private: /** Write key to measure dR between calo clusters and the muon -EXPERIMENTAL **/ - SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaR_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaRVec","Muons.ClusterInfo_deltaRVec","WriteHandleKey for the delta R between the muon and it's associated calocluster(s)"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaR_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaR","Muons.ClusterInfo_deltaR","WriteHandleKey for the delta R between the muon and it's associated calocluster"}; diff --git a/Reconstruction/eflowRec/share/PFlowMTConfig.py b/Reconstruction/eflowRec/share/PFlowMTConfig.py index a314c60c7d66..cf4ffd01ab9a 100644 --- a/Reconstruction/eflowRec/share/PFlowMTConfig.py +++ b/Reconstruction/eflowRec/share/PFlowMTConfig.py @@ -255,7 +255,6 @@ if jobproperties.eflowRecFlags.usePFEGammaPFOAssoc: PFEGammaPFOAssoc=PFEGammaPFOAssoc("PFEGammaPFOAssoc") topSequence += PFEGammaPFOAssoc -jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) #Add new FlowElement creators if jobproperties.eflowRecFlags.useFlowElements: @@ -281,7 +280,7 @@ if jobproperties.eflowRecFlags.useFlowElements: PFMuonFlowElementAssocAlg=PFMuonFlowElementAssoc("PFMuonFlowElementAssocAlgorithm") #Gaudi switch to add the experimental linker between muon clusters and neutral flow elements (FE) PFMuonFlowElementAssocAlg.m_LinkNeutralFEClusters=True - PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=True # second switch combined with first implies Muon topoclusters are linked to neutral Flow Elements + PFMuonFlowElementAssocAlg.m_UseMuonTopoClusters=False # requires m_LinkNeutralFEClusters=True and if set to True= Retrieves TopoClusters from Aux. If not, cell-match muon calocluster to NFE topocluster. topSequence += PFMuonFlowElementAssocAlg -- GitLab From d129397c744897a33f6a1b5e7b64ee26274c7306 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Fri, 23 Oct 2020 18:12:18 +0100 Subject: [PATCH 21/23] code cleanup for final review --- .../eflowRec/PFMuonFlowElementAssoc.h | 2 - .../share/run_ESDStandardReco_FlowElements.py | 40 ------------------- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 13 +++--- 3 files changed, 6 insertions(+), 49 deletions(-) delete mode 100644 Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py diff --git a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h index 5a7ff40f33f9..0ff99f896cca 100644 --- a/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h +++ b/Reconstruction/eflowRec/eflowRec/PFMuonFlowElementAssoc.h @@ -37,7 +37,6 @@ public: virtual StatusCode initialize(); virtual StatusCode execute(const EventContext & ctx ) const; - virtual StatusCode finalize(); private: @@ -70,7 +69,6 @@ private: /** Write key to count number of muons matched to a given neutral FE - EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::FlowElementContainer> m_NeutralFEmuon_nMatches_WriteDecorHandleKey{this,"FlowElementContainer_nMatchedMuons","JetETMissNeutralFlowElements.FE_nMatchedMuons","WriteHandleKey for the number of muons matched to a given neutral flow element"}; - /** Write key to measure dR between calo clusters and the muon -EXPERIMENTAL **/ SG::WriteDecorHandleKey<xAOD::MuonContainer>m_muon_ClusterInfo_deltaR_WriteDecorHandleKey{this,"MuonContainer_ClusterInfo_deltaR","Muons.ClusterInfo_deltaR","WriteHandleKey for the delta R between the muon and it's associated calocluster"}; diff --git a/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py b/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py deleted file mode 100644 index be2b490533ec..000000000000 --- a/Reconstruction/eflowRec/share/run_ESDStandardReco_FlowElements.py +++ /dev/null @@ -1,40 +0,0 @@ -#This file is to run standard reconstruction + Flow Elements on an ESD file (Primarily the Flow Element configuration) - -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -#athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/mc16_13TeV.426327.ParticleGun_single_piminus_logE5to2000.recon.ESD.e5661_s3170_r9857/mc16_13TeV/ESD.11980044._002219.pool.root.1'] -#athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/ttbar_nonallhad_10788/mc16_13TeV/ESD.15852896._000467.pool.root.1'] -athenaCommonFlags.FilesInput=['/atlas/shatlas/ParticleFlow/mc16_13TeV.410470.PhPy8EG_A14_ttbar_hdamp258p75_nonallhad.recon.ESD.e6337_e5984_s3170_r11596/mc16_13TeV/ESD.19439305._000011.pool.root.1'] -#athenaCommonFlags.FilesInput=["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/RecExRecoTest/mc16_13TeV.361022.Pythia8EvtGen_A14NNPDF23LO_jetjet_JZ2W.recon.ESD.e3668_s3170_r10572_homeMade.pool.root"] -doDumpProperties=True - -from RecExConfig.RecAlgsFlags import recAlgs -recAlgs.doEFlow.set_Value_and_Lock(True) - -from eflowRec.eflowRecFlags import jobproperties -jobproperties.eflowRecFlags.useFlowElements.set_Value_and_Lock(True) - -from RecExConfig.RecFlags import rec -rec.doTrigger.set_Value_and_Lock(False) - -#change some calo flags -#from CaloRec.CaloRecFlags import jobproperties -#jobproperties.CaloRecFlags.Enabled.set_Value_and_Lock(True) -#jobproperties.CaloRecFlags.doCaloCluster.set_Value_and_Lock(True) -#jobproperties.CaloRecFlags.doEmCluster.set_Value_and_Lock(False) -#jobproperties.CaloRecFlags.doCaloTopoCluster.set_Value_and_Lock(True) - -#Turn of TAG -rec.doWriteTAG.set_Value_and_Lock(False) - -include("LArConditionsCommon/LArIdMap_MC_jobOptions.py") -from CaloRec import CaloClusterTopoCoolFolder -from CaloTools.CaloNoiseCondAlg import CaloNoiseCondAlg -CaloNoiseCondAlg() -CaloNoiseCondAlg(noisetype="electronicNoise") -athenaCommonFlags.EvtMax=100 -#Run pflopw jet finding - this cannot be enabled via reconstruction flags currently! (without enabling other things we don't want) -UserAlgs = ["eflowRec/jetAlgs.py"] -include ("RecExCommon/RecExCommon_topOptions.py") - -ServiceMgr.MessageSvc.defaultLimit = 9999999 -include ("METReconstruction/METReconstruction_jobOptions.py") diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index fe061c1f39bb..ea9ceb582c39 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -59,10 +59,8 @@ StatusCode PFMuonFlowElementAssoc::initialize() { return StatusCode::SUCCESS; } -// ========================================================================= -StatusCode PFMuonFlowElementAssoc::finalize() { - return StatusCode::SUCCESS; -} + + // ========================================================================= StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const @@ -82,9 +80,9 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //extra container handles between neutral FE cluster and Muon CaloCluster - these are all for studies based on neutral Flow Element matching - All of these handles are experimental SG::WriteDecorHandle<xAOD::FlowElementContainer,std::vector<double> > NeutralFE_efrac_match_muonWriteDecorHandle(m_NeutralFE_efrac_match_muonWriteHandleKey,ctx); - SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<double> >muonNeutralFE_muon_efrac_WriteDecorHandle(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey,ctx); - SG::WriteDecorHandle<xAOD::FlowElementContainer,int> NeutralFEmuon_nMatches_WriteDecorHandle(m_NeutralFEmuon_nMatches_WriteDecorHandleKey,ctx); - SG::WriteDecorHandle<xAOD::MuonContainer,double > muon_ClusterInfo_deltaR_WriteDecorHandle(m_muon_ClusterInfo_deltaR_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer ,std::vector<double> >muonNeutralFE_muon_efrac_WriteDecorHandle(m_muonNeutralFE_muon_efrac_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::FlowElementContainer ,int> NeutralFEmuon_nMatches_WriteDecorHandle(m_NeutralFEmuon_nMatches_WriteDecorHandleKey,ctx); + SG::WriteDecorHandle<xAOD::MuonContainer ,double > muon_ClusterInfo_deltaR_WriteDecorHandle(m_muon_ClusterInfo_deltaR_WriteDecorHandleKey,ctx); //store readhandles for muon and charged flow elements SG::ReadHandle<xAOD::MuonContainer> muonReadHandle (m_muonReadHandleKey,ctx); // readhandle for muon @@ -98,6 +96,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const //for neutral flow element studies std::vector<std::vector<double> >muonNeutralFE_frac_cluster_energy_matched_Vec(muonReadHandle->size()); + //Loop over the Flow Elements ////////////////////////////// -- GitLab From 7abd56feb58e8c5198894de88b6ecef4ba240e5f Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Tue, 10 Nov 2020 14:25:56 +0000 Subject: [PATCH 22/23] fix more merge conflict fragments - oops --- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 06ca8cca99d9..300ea12ed742 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -70,11 +70,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const // WriteDecorHandles for the charged/neutral Flow Elements and Muons // Links a Muon that has a track to a charged flow element if possible -<<<<<<< HEAD - ATH_MSG_INFO("Started execute step"); -======= ATH_MSG_VERBOSE("Started execute step"); ->>>>>>> 16dcd6681161618ad85fd66f5a7d2ceaf5635609 // Get container for muons SG::WriteDecorHandle<xAOD::MuonContainer,std::vector<FlowElementLink_t> > muonChargedFEWriteDecorHandle (m_muonChargedFEWriteHandleKey,ctx); @@ -147,11 +143,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const m_UseMuonTopoClusters (True= Case 1, False = Case 2) **/ if(m_LinkNeutralFEClusters){ -<<<<<<< HEAD - ATH_MSG_INFO("Experimental: Cluster Linkers between neutral FEs and Muons are used"); -======= ATH_MSG_VERBOSE("Experimental: Cluster Linkers between neutral FEs and Muons are used"); ->>>>>>> 16dcd6681161618ad85fd66f5a7d2ceaf5635609 for (const xAOD::FlowElement* FE: *NeutralFEmuonWriteDecorHandle){ int nMatchedFE=0; //get the index of the cluster corresponding to the Neutral FlowElements @@ -204,11 +196,7 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const FEMuonLinks.push_back(MuonLink_t(*muonReadHandle,muon->index())); // index() is the unique index of the cFlowElement in the cFlowElementcontaine muonNeutralFEVec.at(muon->index()).push_back(FlowElementLink_t(*NeutralFEReadHandle,FE->index())); -<<<<<<< HEAD - ATH_MSG_INFO("Got a match between NFE and Muon"); -======= ATH_MSG_VERBOSE("Got a match between NFE and Muon"); ->>>>>>> 16dcd6681161618ad85fd66f5a7d2ceaf5635609 nMatchedFE++; // count number of matches between FE and muons } // check block of index matching } // end of loop over element links @@ -259,13 +247,8 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const frac_muon_cluster_energy_matched=Muon_sum_matched_cellEnergy/tot_muon_cluster_energy; } if(frac_FE_cluster_energy_matched>0){ -<<<<<<< HEAD - ATH_MSG_INFO("Fraction of FE cluster energy used in match: "<<frac_FE_cluster_energy_matched<<", ismatched? "<<isCellMatched<<""); - ATH_MSG_INFO("Fraction of Muon cluster energy used in match: "<<frac_muon_cluster_energy_matched<<""); -======= ATH_MSG_VERBOSE("Fraction of FE cluster energy used in match: "<<frac_FE_cluster_energy_matched<<", ismatched? "<<isCellMatched<<""); ATH_MSG_VERBOSE("Fraction of Muon cluster energy used in match: "<<frac_muon_cluster_energy_matched<<""); ->>>>>>> 16dcd6681161618ad85fd66f5a7d2ceaf5635609 } if(isCellMatched){ // cell matched => Link the two objects. -- GitLab From 40d4d6a9452b3e90d63a777d8054ecf02734257e Mon Sep 17 00:00:00 2001 From: Matthew Thomas Anthony <matthew.thomas.anthony@cern.ch> Date: Tue, 10 Nov 2020 15:03:02 +0000 Subject: [PATCH 23/23] add muon catches as recommended by MCP --- .../eflowRec/src/PFMuonFlowElementAssoc.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx index 300ea12ed742..d61b6eff0d94 100644 --- a/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx +++ b/Reconstruction/eflowRec/src/PFMuonFlowElementAssoc.cxx @@ -114,7 +114,16 @@ StatusCode PFMuonFlowElementAssoc::execute(const EventContext & ctx) const const xAOD::TrackParticle* muon_trk=muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle); if(muon_trk==nullptr) // not all muons have a track. catch the nullptrs in this case and skip continue; - + // skip muon matching if the following cases occur + int MuonType=muon->muonType(); + int MuonAuthor=muon->author(); + if(MuonType==4) {// if muon is a forward muon, skip. Basically the tracks associated to this are the wrong type (InDetForwardTrackParticle instead of InDetTrackParticle), so the indices used would be wrong/generate spurious matches + ATH_MSG_DEBUG("Muon is identified as a forward muon, skipping"); + continue;} + if(MuonAuthor==2){ // remove muons primarily authored by STACO algorithm. + ATH_MSG_DEBUG("Muon is authored by STACO algorithm, skip"); + continue; + } size_t MuonTrkIndex=muon_trk->index(); if(MuonTrkIndex==FETrackIndex){ // Add Muon element link to a vector -- GitLab