From 47beb61be2f690e1f4557a6ebedec7f716b33d47 Mon Sep 17 00:00:00 2001
From: Oleh Kivernyk <oleh.kivernyk@cern.ch>
Date: Mon, 20 Jul 2020 18:00:19 +0200
Subject: [PATCH 1/2] Adding EGamma part to PHYS

---
 .../DerivationFrameworkEGamma/python/EGammaCommon.py  |  2 ++
 .../DerivationFrameworkPhys/share/PHYS.py             | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
index 1dbe056b965c..a440392809b7 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
@@ -445,11 +445,13 @@ if  rec.doTruth():
     )                             
     ToolSvc += tf
 
+    """
     # Schedule the two energy density tools for running
     from AthenaCommon.AlgSequence import AlgSequence
     topSequence = AlgSequence()
     topSequence += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc )
     topSequence += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf )
+    """
 
 #=======================================
 # CREATE THE DERIVATION KERNEL ALGORITHM   
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
index 2519c8ce238c..c23b7d779c4f 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
@@ -13,6 +13,8 @@ from DerivationFrameworkInDet.InDetCommon import *
 from DerivationFrameworkJetEtMiss.JetCommon import *
 from DerivationFrameworkJetEtMiss.ExtendedJetCommon import *
 from DerivationFrameworkJetEtMiss.METCommon import *
+from DerivationFrameworkEGamma.EGammaCommon import *
+from DerivationFrameworkEGamma.ElectronsCPDetailedContent import *
 from DerivationFrameworkMuons.MuonsCommon import *
 from TriggerMenu.api.TriggerAPI import TriggerAPI
 from TriggerMenu.api.TriggerEnums import TriggerPeriod, TriggerType
@@ -186,6 +188,15 @@ addQGTaggerTool(jetalg="AntiKt4EMPFlow",sequence=SeqPHYS,algname="QGTaggerToolPF
 # fJVT
 # getPFlowfJVT(jetalg='AntiKt4EMPFlow',sequence=SeqPHYS, algname='PHYSJetForwardPFlowJvtToolAlg')
 
+#====================================================================
+# EGAMMA
+#====================================================================
+if DerivationFrameworkIsMonteCarlo:
+
+   # Schedule the two energy density tools for running. Must follow after the pseudojets are created.
+   SeqPHYS += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc )
+   SeqPHYS += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf )
+
 #====================================================================
 # Add our sequence to the top sequence
 #====================================================================
-- 
GitLab


From dd5cef46a21cee59eff1000166ab4c13c204819a Mon Sep 17 00:00:00 2001
From: Oleh Kivernyk <oleh.kivernyk@cern.ch>
Date: Tue, 21 Jul 2020 18:14:48 +0200
Subject: [PATCH 2/2] Fixed scheduling of the EventDensity algorithms

---
 .../DerivationFrameworkEGamma/python/EGammaCommon.py  |  2 --
 .../DerivationFrameworkPhys/share/PHYS.py             | 11 +++++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
index a440392809b7..1dbe056b965c 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py
@@ -445,13 +445,11 @@ if  rec.doTruth():
     )                             
     ToolSvc += tf
 
-    """
     # Schedule the two energy density tools for running
     from AthenaCommon.AlgSequence import AlgSequence
     topSequence = AlgSequence()
     topSequence += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc )
     topSequence += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf )
-    """
 
 #=======================================
 # CREATE THE DERIVATION KERNEL ALGORITHM   
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
index c23b7d779c4f..d605a59b3d5d 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkPhys/share/PHYS.py
@@ -191,11 +191,14 @@ addQGTaggerTool(jetalg="AntiKt4EMPFlow",sequence=SeqPHYS,algname="QGTaggerToolPF
 #====================================================================
 # EGAMMA
 #====================================================================
-if DerivationFrameworkIsMonteCarlo:
 
-   # Schedule the two energy density tools for running. Must follow after the pseudojets are created.
-   SeqPHYS += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc )
-   SeqPHYS += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf )
+if DerivationFrameworkIsMonteCarlo:
+   # Schedule the two energy density tools for running after the pseudojets are created.
+   for alg in ['EDTruthCentralAlg', 'EDTruthForwardAlg']:
+      if hasattr(topSequence, alg):
+         edtalg = getattr(topSequence, alg)
+         delattr(topSequence, alg)
+         SeqPHYS += edtalg
 
 #====================================================================
 # Add our sequence to the top sequence
-- 
GitLab