From f4803f473a78a90acda4b1109207f3c0e14a146d Mon Sep 17 00:00:00 2001
From: Ruggero Turra <ruggero.turra@cern.ch>
Date: Wed, 12 Feb 2020 18:50:08 +0100
Subject: [PATCH] first working implementation

---
 .../egammaAlgs/python/topoEgammaBuilder.py    |  4 ++-
 .../egammaAlgs/src/topoEgammaBuilder.cxx      | 35 ++++++++++++++-----
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/Reconstruction/egamma/egammaAlgs/python/topoEgammaBuilder.py b/Reconstruction/egamma/egammaAlgs/python/topoEgammaBuilder.py
index f4cd3ce4ce2b..1ec174a8d194 100644
--- a/Reconstruction/egamma/egammaAlgs/python/topoEgammaBuilder.py
+++ b/Reconstruction/egamma/egammaAlgs/python/topoEgammaBuilder.py
@@ -10,12 +10,14 @@ from egammaRec import egammaKeys
 
 from egammaTools.egammaToolsFactories import EGammaAmbiguityTool
 
+print(">>>>>>>>>> I AM RUNNING in " + __file__)
+
 topoEgammaBuilder = AlgFactory( egammaAlgsConf.topoEgammaBuilder,
                                 name = 'topoEgammaBuilder',
                                 SuperElectronRecCollectionName=egammaKeys.ElectronSuperRecKey(),
                                 SuperPhotonRecCollectionName=egammaKeys.PhotonSuperRecKey(),
                                 ElectronOutputName = egammaKeys.outputElectronKey(),
                                 PhotonOutputName = egammaKeys.outputPhotonKey(),  
-                                AmbiguityTool = EGammaAmbiguityTool
+                                AmbiguityTool = None # TODO: change back to EGammaAmbiguityTool
                                 )
 
diff --git a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx
index 398fa1ec5b0d..5bc7cadd44a9 100644
--- a/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx
+++ b/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx
@@ -65,7 +65,14 @@ StatusCode topoEgammaBuilder::initialize()
   }
 
   if ( m_doElectrons && m_doPhotons ){
-    ATH_CHECK( m_ambiguityTool.retrieve() );
+    ATH_MSG_INFO("<<<<<<<< Retrieving ambiguity tool <<<<<<<<<");
+    if (m_ambiguityTool.empty()) {
+      ATH_MSG_INFO("<<<<<<< Ambiguity tool IS empty");
+    }
+    else { 
+      ATH_MSG_INFO("<<<<<<< Ambituity tool is NOT empty");
+      ATH_CHECK( m_ambiguityTool.retrieve() );
+    }
   }
  
   // retrieve timing profile
@@ -129,10 +136,15 @@ StatusCode topoEgammaBuilder::execute(const EventContext& ctx) const{
           const xAOD::CaloCluster *const phClus = photonRec->caloCluster();
           //See if they have the same hottest cell
           if (elEta0 == phClus->eta0() && elPhi0 == phClus->phi0()) {
-            author = m_ambiguityTool->ambiguityResolve(elClus,
-                                                       photonRec->vertex(),
-                                                       electronRec->trackParticle(),
-                                                       type);
+            if (!m_ambiguityTool.empty()) {  // should be the default
+              author = m_ambiguityTool->ambiguityResolve(elClus,
+                                                        photonRec->vertex(),
+                                                        electronRec->trackParticle(),
+                                                        type);
+            }
+            else {  // in case the ambiguity tool is not set ambiguity is not resolved
+              author = xAOD::EgammaParameters::AuthorAmbiguous;
+            }
             break;
           }
         }
@@ -160,10 +172,15 @@ StatusCode topoEgammaBuilder::execute(const EventContext& ctx) const{
           const xAOD::CaloCluster *const elClus = electronRec->caloCluster();
           //See if they have the same hottest cell
           if (phEta0 == elClus->eta0() && phPhi0 == elClus->phi0()) {
-            author = m_ambiguityTool->ambiguityResolve(elClus,
-                                                       photonRec->vertex(),
-                                                       electronRec->trackParticle(),
-                                                       type);
+            if (!m_ambiguityTool.empty()) {  // should be the default
+              author = m_ambiguityTool->ambiguityResolve(elClus,
+                                                        photonRec->vertex(),
+                                                        electronRec->trackParticle(),
+                                                        type);
+            }
+            else {  // in case the ambiguity tool is not set ambiguity is not resolved
+              author = xAOD::EgammaParameters::AuthorAmbiguous;
+            }
             break;
           }
         }
-- 
GitLab