From e8958106c98d53f9897f0e5cc6311e4e3a7498d0 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste De Vivie De Regie <devivie@lpsc.in2p3.fr>
Date: Wed, 24 Nov 2021 09:45:53 +0100
Subject: [PATCH] ATLASRECTS-6700  ATLASRECTS-6701 : Fix for heavy ion reco and
 ESD to AOD  tests

---
 .../InDetRecExample/python/InDetKeys.py        |  2 +-
 .../SubtractedEgammaTopoClusterCopier.py       | 18 ------------------
 .../HIJetRec/share/HIegamma_jobOptions.py      | 18 +++++-------------
 .../share/RecExCommon_topOptions.py            | 13 ++++++++-----
 .../RecExCommon/share/SystemRec_config.py      |  2 +-
 5 files changed, 15 insertions(+), 38 deletions(-)
 delete mode 100644 Reconstruction/HeavyIonRec/HIJetRec/python/SubtractedEgammaTopoClusterCopier.py

diff --git a/InnerDetector/InDetExample/InDetRecExample/python/InDetKeys.py b/InnerDetector/InDetExample/InDetRecExample/python/InDetKeys.py
index 010f426d1d3..a5213db0c89 100644
--- a/InnerDetector/InDetExample/InDetRecExample/python/InDetKeys.py
+++ b/InnerDetector/InDetExample/InDetRecExample/python/InDetKeys.py
@@ -868,7 +868,7 @@ class CaloClusterContainer(JobProperty):
     """Brem Reco: Container of EM clusters"""
     statusOn     = True
     allowedTypes = ['str']
-    StoredValue  = 'egammaTopoCluster'
+    StoredValue  = 'egammaTopoClusters'
 
 class CaloCellContainer(JobProperty):
     """Brem Reco: Container of calo cell"""
diff --git a/Reconstruction/HeavyIonRec/HIJetRec/python/SubtractedEgammaTopoClusterCopier.py b/Reconstruction/HeavyIonRec/HIJetRec/python/SubtractedEgammaTopoClusterCopier.py
deleted file mode 100644
index 31e39587463..00000000000
--- a/Reconstruction/HeavyIonRec/HIJetRec/python/SubtractedEgammaTopoClusterCopier.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-
-__doc__ = """
-ToolFactory to instantiate egammaTopoClusterCopier with default configuration"""
-__author__ = "Jovan Mitrevski"
-
-from egammaAlgs import egammaAlgsConf
-from egammaRec.Factories import AlgFactory
-from egammaRec.egammaRecFlags import jobproperties
-
-SubtractedEgammaTopoClusterCopier = AlgFactory(
-    egammaAlgsConf.egammaTopoClusterCopier,
-    name='SubtractedEgammaTopoClusterCopier',
-    InputTopoCollection=jobproperties.egammaRecFlags.inputTopoClusterCollection(),
-    OutputTopoCollection=jobproperties.egammaRecFlags.egammaTopoClusterCollection(),
-    OutputTopoCollectionShallow="tmp_" +
-    jobproperties.egammaRecFlags.egammaTopoClusterCollection()
-)
diff --git a/Reconstruction/HeavyIonRec/HIJetRec/share/HIegamma_jobOptions.py b/Reconstruction/HeavyIonRec/HIJetRec/share/HIegamma_jobOptions.py
index dad87051dc6..c908211f1f7 100644
--- a/Reconstruction/HeavyIonRec/HIJetRec/share/HIegamma_jobOptions.py
+++ b/Reconstruction/HeavyIonRec/HIJetRec/share/HIegamma_jobOptions.py
@@ -23,12 +23,6 @@ jobproperties.CaloRecFlags.clusterCellGetterName='HIJetRec.SubtractedCellGetter.
 
 rec.doEgamma = True
 
-from egammaRec.egammaRecFlags import jobproperties
-jobproperties.egammaRecFlags.inputTopoClusterCollection='SubtractedCaloTopoCluster'
-jobproperties.egammaRecFlags.egammaTopoClusterCollection='SubtractedEgammaTopoCluster'
-jobproperties.egammaRecFlags.cellContainerName='SubtractedCells'
-
-
 from AthenaCommon.AlgSequence import AlgSequence
 topSequence = AlgSequence()
 
@@ -70,14 +64,12 @@ if DetFlags.haveRIO.Calo_on() :
             treatException("Problem with EMTopoCluster. Switched off")
             jobproperties.CaloRecFlags.doCaloEMTopoCluster=False
 
-
     #EgammaTopoCluster
-    try:
-        from HIJetRec.SubtractedEgammaTopoClusterCopier import SubtractedEgammaTopoClusterCopier
-        SubtractedEgammaTopoClusterCopier()
-    except Exception:
-        treatException("Problem with egammaTopoClusterCopier in HIJetRec")
-
+    from AthenaConfiguration.ComponentAccumulator import CAtoGlobalWrapper
+    from AthenaConfiguration.AllConfigFlags import ConfigFlags
+    from egammaAlgs.egammaTopoClusterCopierConfig import egammaTopoClusterCopierCfg
+    CAtoGlobalWrapper(egammaTopoClusterCopierCfg,ConfigFlags,
+                          name='SubtractedEgammaTopoClusterCopier')
 
     #Run CaloExtension
     if (rec.doESD()) and (rec.doEgamma()) :
diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
index 1221138087b..afe3fe4d3a5 100644
--- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
+++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
@@ -448,11 +448,7 @@ if recAlgs.doEFlow():
         ConfigFlags.PF.useElPhotLinks = False
         ConfigFlags.PF.useMuLinks = False
 
-if rec.doEgamma():
-    # C.A uses Clusters RecExCommom Cluster (rm the "s")
-    ConfigFlags.Egamma.Keys.Internal.EgammaTopoClusters = 'egammaTopoCluster'
-    ConfigFlags.Egamma.Keys.Input.TopoClusters = 'CaloTopoClusters'
-
+HIDict = {}
 if rec.doHeavyIon():
     # This is copy from the old style to the new
     # We need to have HI flags to do it nicer
@@ -461,6 +457,13 @@ if rec.doHeavyIon():
     ConfigFlags.Egamma.Keys.Input.CaloCells = 'SubtractedCells'
     ConfigFlags.Egamma.doCentral = True
     ConfigFlags.Egamma.doForward = False
+    # This is a trick : in HeavyIon, egammaTopoClusterCopier is run two times
+    # one on the unsubtracted clusters (in SystemRec_config.py),
+    # the other on subtracted clusters (in HIegamma_jobO).
+    # Why is the first followed by InDetCaloClusterROISelector needed in Heavy Ion reco ?
+    HIDict['InputTopoCollection'] = 'CaloTopoClusters'
+    HIDict['OutputTopoCollection'] = 'egammaTopoClusters'
+    HIDict['OutputTopoCollectionShallow'] = 'tmp_egammaTopoClusters'
 
 # Lock the flags
 logRecExCommon_topOptions.info("Locking ConfigFlags")
diff --git a/Reconstruction/RecExample/RecExCommon/share/SystemRec_config.py b/Reconstruction/RecExample/RecExCommon/share/SystemRec_config.py
index 0e24aac02f9..a5ab1979d7e 100755
--- a/Reconstruction/RecExample/RecExCommon/share/SystemRec_config.py
+++ b/Reconstruction/RecExample/RecExCommon/share/SystemRec_config.py
@@ -25,7 +25,7 @@ AODFix_postCaloRec()
 if jobproperties.CaloRecFlags.doCaloTopoCluster():
     from AthenaConfiguration.AllConfigFlags import ConfigFlags
     from egammaAlgs.egammaTopoClusterCopierConfig import egammaTopoClusterCopierCfg
-    CAtoGlobalWrapper(egammaTopoClusterCopierCfg,ConfigFlags)
+    CAtoGlobalWrapper(egammaTopoClusterCopierCfg,ConfigFlags,**HIDict)
 
 #then run ID reco:
 
-- 
GitLab