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] 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