From 5cb7302c576e8cbb5cd6c973a05652ec6d17214c Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Wed, 10 Nov 2021 10:45:00 +0100
Subject: [PATCH] TriggerMenuMT: remove slice-independence tests and code

Slice independence is now tested during menu generation. Remove the unit
tests and the code required for this check.

Relates to ATR-23624.
---
 .../python/TriggerConfigFlags.py               |  3 ---
 .../TriggerCommon/TriggerMenuMT/CMakeLists.txt | 16 ++--------------
 .../Menu/ChainConfigurationBase.py             | 14 ++------------
 .../python/HLTMenuConfig/Menu/ChainMerging.py  |  5 +----
 .../HLTMenuConfig/Menu/GenerateMenuMT.py       | 14 +++-----------
 .../scripts/test_slice_independence.sh         | 18 ------------------
 6 files changed, 8 insertions(+), 62 deletions(-)
 delete mode 100755 Trigger/TriggerCommon/TriggerMenuMT/scripts/test_slice_independence.sh

diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py
index 82bde93dd85c..5895a8dad195 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfigFlags.py
@@ -273,9 +273,6 @@ def createTriggerFlags():
     # Switch on MC20 EOverP maps for the jet slice
     flags.addFlag("Trigger.Jet.doMC20_EOverP", True)
 
-    # Return dummy chain configurations for fast slice independence checks
-    flags.addFlag("Trigger.Test.doDummyChainConfig", False)
-
     return flags
 
     
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt
index 876746b073ce..f74e77a2ac0a 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt
+++ b/Trigger/TriggerCommon/TriggerMenuMT/CMakeLists.txt
@@ -60,7 +60,7 @@ function( atlas_test_lvl1_trigger_menu menu )
    atlas_add_test( "L1_${menu}"
                    SCRIPT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/generateL1MenuRun3.py ${menu}
                    PRIVATE_WORKING_DIRECTORY
-                   POST_EXEC_SCRIPT nopost.sh )
+                   POST_EXEC_SCRIPT "check_log.py --errors --config checklogTriggerTest.conf ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unitTestRun_L1_${menu}/L1_${menu}.log" )
 endfunction()
 
 function( atlas_test_hlt_trigger_menu menu )
@@ -68,7 +68,7 @@ function( atlas_test_hlt_trigger_menu menu )
                    SCRIPT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_HLTmenu.sh ${menu}
                    PROPERTIES TIMEOUT 500
                    PRIVATE_WORKING_DIRECTORY
-                   POST_EXEC_SCRIPT "check_log.py --errors ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unitTestRun_HLT_${menu}/HLT_${menu}.log" )
+                   POST_EXEC_SCRIPT "check_log.py --errors --config checklogTriggerTest.conf ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unitTestRun_HLT_${menu}/HLT_${menu}.log" )
 endfunction()
 
 # Test all L1 menus (as this is fast):
@@ -85,18 +85,6 @@ atlas_test_hlt_trigger_menu( LS2_v1 )
 atlas_test_hlt_trigger_menu( Cosmic_run3_v1 )
 atlas_test_hlt_trigger_menu( Dev_HI_run3_v1 )
 
-# Slice tests:
-function( atlas_test_slice_independence slice )
-   atlas_add_test( slice_independence_${slice}
-                  SCRIPT scripts/test_slice_independence.sh ${slice}
-                  PRIVATE_WORKING_DIRECTORY
-                  POST_EXEC_SCRIPT nopost.sh )
-endfunction()
-
-foreach( slice Egamma Muon Tau MET Jet Bjet Bphysics MinBias UnconventionalTracking Calib Beamspot Cosmic Monitor Streaming EnhancedBias)
-   atlas_test_slice_independence( ${slice} )
-endforeach()
-
 # New job options test:
 atlas_add_test( generateMenuMT_newJO
                 SCRIPT python -m TriggerMenuMT.HLTMenuConfig.Menu.LS2_v1_newJO
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py
index e186e66e1710..9c3b1f4d4951 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainConfigurationBase.py
@@ -1,12 +1,11 @@
-# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 
 
 from AthenaCommon.Logging import logging
 log = logging.getLogger(__name__)
 
 import abc
-from AthenaConfiguration.AllConfigFlags import ConfigFlags
-from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep, EmptyMenuSequence, RecoFragmentsPool
+from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep, RecoFragmentsPool
 from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg
 
 #----------------------------------------------------------------
@@ -96,13 +95,4 @@ class ChainConfigurationBase(metaclass=abc.ABCMeta):
         return
 
     def assembleChain(self):
-        if ConfigFlags.Trigger.Test.doDummyChainConfig:
-            if isinstance(self.chainPart,list):
-                # Jets have >1 chainSteps
-                agroups = list(set([cp['alignmentGroup'] for cp in self.chainPart]))
-            else:
-                agroups = [self.chainPart['alignmentGroup']]
-            dummyseq = RecoFragmentsPool.retrieve(lambda flags, the_name: EmptyMenuSequence(the_name), None, the_name="DummySeq_"+self.chainName)
-            dummystep = ChainStep("DummyChainStep_"+self.chainName, Sequences=[dummyseq], chainDicts=[self.dict])
-            return Chain(self.chainName, ChainSteps = [dummystep], L1Thresholds=[self.L1Threshold], nSteps=[0], alignmentGroups=agroups)
         return self.assembleChainImpl()
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py
index d500371802a1..c459c2ce64a1 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/ChainMerging.py
@@ -6,7 +6,6 @@ from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep, Em
 from AthenaCommon.Logging import logging
 from DecisionHandling.DecisionHandlingConfig import ComboHypoCfg
 from TrigCompositeUtils.TrigCompositeUtils import legName
-from AthenaConfiguration.AllConfigFlags import ConfigFlags
 
 from collections import OrderedDict
 from copy import deepcopy
@@ -192,7 +191,7 @@ def getCurrentAG(chainStep):
     filled_seq_ag = []
     for iseq,seq in enumerate(chainStep.sequences):
         # In the case of dummy configs, they are all empty
-        if type(seq).__name__ == 'EmptyMenuSequence' and not ConfigFlags.Trigger.Test.doDummyChainConfig:
+        if type(seq).__name__ == 'EmptyMenuSequence':
             continue
         else:
             # get the alignment group of the leg that is running a non-empty sequence
@@ -419,8 +418,6 @@ def makeCombinedStep(parallel_steps, stepNumber, chainDefList, allSteps = [], cu
     if not hasNonEmptyStep:
         for chain_index, step in enumerate(parallel_steps):
             # every step is empty but some might have empty sequences and some might not
-            if ConfigFlags.Trigger.Test.doDummyChainConfig and not step:
-                continue
             if len(step.sequences) == 0:
                 new_stepDicts = deepcopy(chainDefList[chain_index].steps[-1].stepDicts)
                 currentStepName = 'Empty' + chainDefList[chain_index].alignmentGroups[0]+'Align'+str(stepNumber)+'_'+new_stepDicts[0]['chainParts'][0]['multiplicity']+new_stepDicts[0]['signature']
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py
index 017f883c5d62..d98891c4afc9 100755
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Menu/GenerateMenuMT.py
@@ -1,7 +1,6 @@
 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 
 import importlib
-import itertools
 import string
 
 from .TriggerConfigHLT  import TriggerConfigHLT
@@ -12,7 +11,6 @@ from .MenuPrescaleConfig import MenuPrescaleConfig, applyHLTPrescale
 from .ChainMerging import mergeChainDefs
 from .MenuAlignmentTools import MenuAlignment
 from ..CommonSequences import EventBuildingSequences
-from AthenaConfiguration.AllConfigFlags import ConfigFlags
 from .ComboHypoHandling import addTopoInfo, comboConfigurator, topoLegIndices
 
 from AthenaCommon.Logging import logging
@@ -212,11 +210,6 @@ class GenerateMenuMT(object, metaclass=Singleton):
         log.info("Will now generate the chain configuration for each chain")
         self.generateChains()
 
-        if ConfigFlags.Trigger.Test.doDummyChainConfig:
-            log.info("[GenerateMenuMT] Dummy chain configuration active, will not proceed with menu generation")
-            import sys
-            sys.exit(0)
-
         log.info("Will now calculate the alignment parameters")
         #dict of signature: set it belongs to
         #e.g. {'Electron': ['Electron','Muon','Photon']}        
@@ -381,10 +374,9 @@ class GenerateMenuMT(object, metaclass=Singleton):
             else:
                 theChainConfig = listOfChainConfigs[0]
             
-            if not ConfigFlags.Trigger.Test.doDummyChainConfig:
-                for topoID in range(len(mainChainDict['extraComboHypos'])):
-                    thetopo = mainChainDict['extraComboHypos'][topoID].strip(string.digits).rstrip(topoLegIndices)
-                    theChainConfig.addTopo((comboConfigurator[thetopo],thetopo))
+            for topoID in range(len(mainChainDict['extraComboHypos'])):
+                thetopo = mainChainDict['extraComboHypos'][topoID].strip(string.digits).rstrip(topoLegIndices)
+                theChainConfig.addTopo((comboConfigurator[thetopo],thetopo))
 
             # Now we know where the topos should go, we can insert them in the right steps
             if len(theChainConfig.topoMap) > 0:
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_slice_independence.sh b/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_slice_independence.sh
deleted file mode 100755
index f15eda9acf20..000000000000
--- a/Trigger/TriggerCommon/TriggerMenuMT/scripts/test_slice_independence.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# This is not an ART test, but a unit test
-
-# This is a unit test checking that chains are assigned to 
-# the correct slice. Configuration will fail if e.g.
-# an egamma chain is placed in the muon slice.
-#
-# Combined slice is not handled because it has to import
-# all the others anyway
-#
-# The configuration will exit early, just after attempting to
-# generate a dummy config for each chain in the tested slice
-
-# Fail if any command fails:
-set -e
-
-athena.py -c "setMenu='LS2_v1';doWriteBS=False;doWriteRDOTrigger=True;fpeAuditor=True; doEmptyMenu=True; do${1}Slice=True; from AthenaConfiguration.AllConfigFlags import ConfigFlags; ConfigFlags.Trigger.Test.doDummyChainConfig=True" --filesInput=/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TriggerTest/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.RDO.e4993_s3214_r11315/RDO.17533168._000001.pool.root.1 --threads=1 TriggerJobOpts/runHLT_standalone.py --config-only=config.pkl
-- 
GitLab