From beb1ca34a209e4dab17b7212b9ac6276d75a335a Mon Sep 17 00:00:00 2001
From: Ryan Mackenzie White <ryan.white@cern.ch>
Date: Thu, 30 Mar 2017 19:28:04 +0200
Subject: [PATCH] Swtich to fastElectronFex sequence via doFastElectronFex
 flag. Fix Heg triggers, moved to combined menu code.

Former-commit-id: 309894dbda333115b778e14b8ebf02d62a03eb9a
---
 .../combined/generateCombinedChainDefs.py     | 25 +++++++++++++
 .../python/egamma/EgammaSliceFlags.py         |  2 +-
 .../TriggerMenu/python/egamma/ElectronDef.py  | 13 ++++---
 .../egamma/generateElectronChainDefs.py       |  9 -----
 .../python/egamma/generatePhotonChainDefs.py  | 12 +++----
 .../TriggerMenu/python/menu/Physics_pp_v7.py  |  6 ++--
 .../TriggerMenuXML/CMakeLists.txt             | 36 +++++++++----------
 7 files changed, 61 insertions(+), 42 deletions(-)

diff --git a/Trigger/TriggerCommon/TriggerMenu/python/combined/generateCombinedChainDefs.py b/Trigger/TriggerCommon/TriggerMenu/python/combined/generateCombinedChainDefs.py
index 7718e0d1c2d8..ef328dd377e9 100644
--- a/Trigger/TriggerCommon/TriggerMenu/python/combined/generateCombinedChainDefs.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/combined/generateCombinedChainDefs.py
@@ -26,6 +26,31 @@ def _addTopoInfo(theChainDef,chainDicts,listOfChainDefs,doAtL2AndEF=True):
             
     topoAlgs = chainDicts[0]["topo"]
 
+    if any("Heg" in alg for alg in topoAlgs):
+        hegInputTEsEF=[]
+        # First TE: electron merged
+        for cD in listOfChainDefs:
+            if [x for x in cD.signatureList[-1]['listOfTriggerElements'] if 'EF_e' in x]:
+                hegInputTEsEF +=[deepcopy(cD.signatureList[-1]['listOfTriggerElements'])] 
+                break
+
+        # Second TE: electron
+        for cD in listOfChainDefs:
+            if [x for x in cD.signatureList[-1]['listOfTriggerElements'] if 'EF_g' in x]:
+                hegInputTEsEF +=[deepcopy(cD.signatureList[-1]['listOfTriggerElements'])] 
+                break
+
+        from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Heg, TrigEFDielectronMassHypo_Heg
+
+        EFFex = TrigEFDielectronMassFex_Heg()
+        EFHypo = TrigEFDielectronMassHypo_Heg()
+        
+        EFChainName = "EF_" + chainDicts[0]['chainName']
+        if (len(EFChainName) > 99):
+            EFChainName = EFChainName[:-(len(EFChainName)-99)]
+        theChainDef.addSequence([EFFex, EFHypo],hegInputTEsEF,EFChainName)
+        theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1, [EFChainName])
+   
     if any("dphi" in alg for alg in topoAlgs):
         ##Check that we only have a MET and JET chain
         inputChains=[]
diff --git a/Trigger/TriggerCommon/TriggerMenu/python/egamma/EgammaSliceFlags.py b/Trigger/TriggerCommon/TriggerMenu/python/egamma/EgammaSliceFlags.py
index 830bc2f9e623..6787caca86cc 100755
--- a/Trigger/TriggerCommon/TriggerMenu/python/egamma/EgammaSliceFlags.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/egamma/EgammaSliceFlags.py
@@ -49,7 +49,7 @@ class doFastElectronFex(JobProperty):
     '''enable L2ElectronFex cuts and sequence'''
     statusOn=True
     allowedTypes=['bool']
-    StoredValue=False
+    StoredValue=True
 
 _flags.append(doFastElectronFex)
 
diff --git a/Trigger/TriggerCommon/TriggerMenu/python/egamma/ElectronDef.py b/Trigger/TriggerCommon/TriggerMenu/python/egamma/ElectronDef.py
index 6e6b63149624..84a37e0ac63e 100644
--- a/Trigger/TriggerCommon/TriggerMenu/python/egamma/ElectronDef.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/egamma/ElectronDef.py
@@ -196,7 +196,7 @@ class L2EFChain_e(L2EFChainDef):
         name = str(self.chainPart['threshold'])
         name = name.split('.')[0]
         dofastrecseq = TriggerFlags.EgammaSlice.doFastElectronFex
-        if 'perf' in self.chainName: 
+        if 'perf' in self.chainPartName: 
             dofastrecseq=False
         log.debug('setup_electron %s, apply ringer %s for %s',self.chainName,self._ringer_selection,thr )
         # Ringer chains not tuned for low-et
@@ -209,7 +209,7 @@ class L2EFChain_e(L2EFChainDef):
         # but 
         algo = TrigEFCaloHypo_EtCut("TrigEFCaloHypo_e"+name+"_EtCut",thr)
         fastrec_algo = L2ElectronFex_Clean()
-        fastrec_hypo = self.el_sequences['fastrec'].pop()
+        fastrec_hypo = self.el_sequences['fastrec'][-1]
         precisecalocalib =  self.el_sequences['precisecalocalib']
         precisecalocalib.pop()
         precisecalocalib.extend([algo])
@@ -228,14 +228,17 @@ class L2EFChain_e(L2EFChainDef):
         if dofastrecseq:
             seq_dict['fastrec']=[fastrec_algo,fastrec_hypo]
             log.debug('FastRec sequence %s'%seq_dict['fastrec'])
-            
+            # remove track hypo from precisetrack step
+            precisetrack = self.el_sequences['precisetrack']
+            precisetrack.pop()
+            seq_dict['precisetrack']=precisetrack
             seq_te_dict['fastcalorec']=('L2_e_step1','cl')
             seq_te_dict['fastringerhypo']=('L2_e_step2','clhypo')
-            seq_te_dict['fasttrack']=('L2_e_step3','id')
+            seq_te_dict['fasttrack']=('L2_e_step3','ftf')
             seq_te_dict['fastrec']=('L2_e_step4','')
             seq_te_dict['precisecalo']=('EF_e_step1','calo')
             seq_te_dict['precisecalocalib']=('EF_e_step2','calocalib')    
-            seq_te_dict['precisetrack']=('EF_e_step3','id') 
+            seq_te_dict['precisetrack']=('EF_e_step3','idtrig') 
             seq_te_dict['preciserec']=('EF_e_step4','')
         else:    
             seq_te_dict['fastcalorec']=('L2_e_step1','cl')
diff --git a/Trigger/TriggerCommon/TriggerMenu/python/egamma/generateElectronChainDefs.py b/Trigger/TriggerCommon/TriggerMenu/python/egamma/generateElectronChainDefs.py
index 9e1c740eb3cd..73690202fbf4 100755
--- a/Trigger/TriggerCommon/TriggerMenu/python/egamma/generateElectronChainDefs.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/egamma/generateElectronChainDefs.py
@@ -108,15 +108,6 @@ def _addTopoInfo(theChainDef,chainDict,doAtL2AndEF=True):
              theChainDef.addSequence([IDTP],myInputTEsEF,EFChainName+"_monit")
              theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1,[EFChainName+"_monit"])
     
-    elif "Heg" in chainDict["topo"]:
-
-        from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Heg, TrigEFDielectronMassHypo_Heg
-
-        EFFex = TrigEFDielectronMassFex_Heg()
-        EFHypo = TrigEFDielectronMassHypo_Heg()
-        
-        theChainDef.addSequence([EFFex, EFHypo],inputTEsEF,EFChainName)
-        theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1, [EFChainName])
     
     else:
         pass 
diff --git a/Trigger/TriggerCommon/TriggerMenu/python/egamma/generatePhotonChainDefs.py b/Trigger/TriggerCommon/TriggerMenu/python/egamma/generatePhotonChainDefs.py
index ae4990fb8824..6fb3825c5c27 100755
--- a/Trigger/TriggerCommon/TriggerMenu/python/egamma/generatePhotonChainDefs.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/egamma/generatePhotonChainDefs.py
@@ -73,15 +73,15 @@ def _addTopoInfo(theChainDef,chainDict,doAtL2AndEF=True):
         theChainDef.addSequence([EFFex, EFHypo],inputTEsEF,EFChainName)
         theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1, [EFChainName])
     
-    elif "Heg" in chainDict["topo"]:
+    #elif "Heg" in chainDict["topo"]:
 
-        from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Heg, TrigEFDielectronMassHypo_Heg
+    #    from TrigEgammaHypo.TrigEFDielectronMassHypoConfig import TrigEFDielectronMassFex_Heg, TrigEFDielectronMassHypo_Heg
 
-        EFFex = TrigEFDielectronMassFex_Heg()
-        EFHypo = TrigEFDielectronMassHypo_Heg()
+    #    EFFex = TrigEFDielectronMassFex_Heg()
+    #    EFHypo = TrigEFDielectronMassHypo_Heg()
         
-        theChainDef.addSequence([EFFex, EFHypo],inputTEsEF,EFChainName)
-        theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1, [EFChainName])
+    #    theChainDef.addSequence([EFFex, EFHypo],inputTEsEF,EFChainName)
+    #    theChainDef.addSignature(theChainDef.signatureList[-1]['signature_counter']+1, [EFChainName])
     
     else:
         pass 
diff --git a/Trigger/TriggerCommon/TriggerMenu/python/menu/Physics_pp_v7.py b/Trigger/TriggerCommon/TriggerMenu/python/menu/Physics_pp_v7.py
index 7b1a6b2e1ef9..fd778873c681 100644
--- a/Trigger/TriggerCommon/TriggerMenu/python/menu/Physics_pp_v7.py
+++ b/Trigger/TriggerCommon/TriggerMenu/python/menu/Physics_pp_v7.py
@@ -1741,8 +1741,6 @@ def setupMenu():
         #ATR-15259
         ['e25_mergedtight_g35_medium',           'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
         ['e30_mergedtight_g35_medium',           'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
-        ['e25_mergedtight_g35_medium_Heg',       'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
-        ['e30_mergedtight_g35_medium_Heg',       'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
 
         #Diphoton triggers
         ['g35_loose_g25_loose',                      'L1_2EM15VH', [], [PhysicsStream], ['RATE:MultiPhoton', 'BW:Egamma'],-1],
@@ -2576,7 +2574,9 @@ def setupMenu():
         #Performance:
         ['e26_lhtight_idperf',        'L1_EM22VHI',    [], [PhysicsStream, 'express'], ['RATE:IDMonitoring', 'BW:Egamma', 'BW:ID'],-1],
         ['e28_lhtight_idperf',        'L1_EM24VHI',    [], [PhysicsStream], ['RATE:IDMonitoring', 'BW:Egamma', 'BW:ID'],-1],
-
+        # Heg chains
+        ['e25_mergedtight_g35_medium_Heg',       'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
+        ['e30_mergedtight_g35_medium_Heg',       'L1_2EM20VH', [], [PhysicsStream], ['RATE:ElectronPhoton', 'BW:Egamma'], -1,['parallel',-1,[] ]],
 	# COMBINED TAU CHAINS
 
 	# e+tau
diff --git a/Trigger/TriggerCommon/TriggerMenuXML/CMakeLists.txt b/Trigger/TriggerCommon/TriggerMenuXML/CMakeLists.txt
index 26f92fe8fa52..3b04211f9b28 100644
--- a/Trigger/TriggerCommon/TriggerMenuXML/CMakeLists.txt
+++ b/Trigger/TriggerCommon/TriggerMenuXML/CMakeLists.txt
@@ -108,24 +108,24 @@ atlas_install_xmls( data/*.xml )
 
 # List of menus to be created:
 
-#atlas_build_trigger_menu( Physics_pp_v6 )
-#atlas_build_trigger_menu( Physics_pp_v6_tight_physics_prescale )
-#atlas_build_trigger_menu( MC_pp_v6 )
-#atlas_build_trigger_menu( MC_pp_v6_loose_mc_prescale )
-#atlas_build_trigger_menu( MC_pp_v6_tight_mc_prescale )
-#atlas_build_trigger_menu( MC_pp_v6_tightperf_mc_prescale )
-
-#atlas_build_trigger_menu( Physics_pp_v7 )
-#atlas_build_trigger_menu( Physics_pp_v7_tight_physics_prescale )
+atlas_build_trigger_menu( Physics_pp_v6 )
+atlas_build_trigger_menu( Physics_pp_v6_tight_physics_prescale )
+atlas_build_trigger_menu( MC_pp_v6 )
+atlas_build_trigger_menu( MC_pp_v6_loose_mc_prescale )
+atlas_build_trigger_menu( MC_pp_v6_tight_mc_prescale )
+atlas_build_trigger_menu( MC_pp_v6_tightperf_mc_prescale )
+
+atlas_build_trigger_menu( Physics_pp_v7 )
+atlas_build_trigger_menu( Physics_pp_v7_tight_physics_prescale )
 atlas_build_trigger_menu( MC_pp_v7 )
-#atlas_build_trigger_menu( MC_pp_v7_loose_mc_prescale )
-#atlas_build_trigger_menu( MC_pp_v7_tight_mc_prescale )
-#atlas_build_trigger_menu( MC_pp_v7_tightperf_mc_prescale )
+atlas_build_trigger_menu( MC_pp_v7_loose_mc_prescale )
+atlas_build_trigger_menu( MC_pp_v7_tight_mc_prescale )
+atlas_build_trigger_menu( MC_pp_v7_tightperf_mc_prescale )
 
-#atlas_build_trigger_menu( Physics_HI_v3 )
-#atlas_build_trigger_menu( MC_HI_v3 )
-#atlas_build_trigger_menu( MC_HI_v3_tight_mc_prescale )
+atlas_build_trigger_menu( Physics_HI_v3 )
+atlas_build_trigger_menu( MC_HI_v3 )
+atlas_build_trigger_menu( MC_HI_v3_tight_mc_prescale )
 
-#atlas_build_trigger_menu( Physics_HI_v4 )
-#atlas_build_trigger_menu( MC_HI_v4 )
-#atlas_build_trigger_menu( MC_HI_v4_tight_mc_prescale )
+atlas_build_trigger_menu( Physics_HI_v4 )
+atlas_build_trigger_menu( MC_HI_v4 )
+atlas_build_trigger_menu( MC_HI_v4_tight_mc_prescale )
-- 
GitLab