From e0cac9bc95dc89f1dac6b6c09b247e4e2694f977 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Fri, 3 Jul 2020 19:17:35 +0200
Subject: [PATCH] TriggerJobOpts: extend flake8 checks and clean up code

---
 .../share/RecExCommon_topOptions.py           |  4 +-
 .../TriggerJobOpts/CMakeLists.txt             | 10 +--
 .../TriggerJobOpts/python/TriggerFlags.py     |  1 -
 .../TriggerJobOpts/share/BStoBS_post.py       | 10 ++-
 .../BStoESD_Tier0_HLTConfig_jobOptions.py     |  1 -
 .../share/TransientBS_DetFlags.py             |  7 +-
 .../TriggerOutputItemListAOD_jobOptions.py    | 18 -----
 .../share/TriggerOutputItemList_jobOptions.py | 16 ----
 .../share/Trigger_topOptions_standalone.py    | 69 ++++++++++-------
 .../share/Trigger_topOptions_writeBS.py       | 74 -------------------
 .../share/dbmod_BFieldAutoConfig.py           |  6 +-
 .../share/dbmod_chronoAuditor.py              |  1 +
 .../TriggerJobOpts/share/dbmod_nameAuditor.py |  1 +
 .../share/jobOfragment_TransBS_standalone.py  |  8 +-
 .../TriggerJobOpts/share/runHLT_standalone.py | 39 ++++------
 .../share/runHLT_standalone_run2.py           |  2 +
 .../share/test_hltConditions.py               | 23 ++++--
 .../test/test_TriggerFlags_autoconf.py        |  3 +-
 18 files changed, 104 insertions(+), 189 deletions(-)
 delete mode 100644 Trigger/TriggerCommon/TriggerJobOpts/share/BStoESD_Tier0_HLTConfig_jobOptions.py
 delete mode 100755 Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemListAOD_jobOptions.py
 delete mode 100755 Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemList_jobOptions.py
 delete mode 100755 Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_writeBS.py

diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
index 9e67abc9d9f..1c556f7298b 100644
--- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
+++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
@@ -557,9 +557,9 @@ if rec.readESD() and rec.doESD():
 if rec.doTrigger:
     if globalflags.DataSource() == 'data'and globalflags.InputFormat == 'bytestream':
         try:
-            include("TriggerJobOpts/BStoESD_Tier0_HLTConfig_jobOptions.py")
+            include("TrigTier0/BStoESD_Tier0_HLTConfig_jobOptions.py")
         except Exception:
-            treatException("Could not import TriggerJobOpts/BStoESD_Tier0_HLTConfig_jobOptions.py . Switching trigger off !" )
+            treatException("Could not import TrigTier0/BStoESD_Tier0_HLTConfig_jobOptions.py . Switching trigger off !" )
             recAlgs.doTrigger=False
     else:
         try:
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/CMakeLists.txt b/Trigger/TriggerCommon/TriggerJobOpts/CMakeLists.txt
index 83b7754a549..bccc718fe22 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/CMakeLists.txt
+++ b/Trigger/TriggerCommon/TriggerJobOpts/CMakeLists.txt
@@ -11,9 +11,9 @@ atlas_depends_on_subdirs( PUBLIC
                           Trigger/TriggerCommon/TrigTier0 )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
-atlas_install_scripts( test/*.py )
-atlas_install_joboptions( share/*.py )
+atlas_install_python_modules( python/*.py ${ATLAS_FLAKE8} )
+atlas_install_scripts( test/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
+atlas_install_joboptions( share/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 
 atlas_add_test( TriggerConfigFlagsTest
    SCRIPT python -m unittest TriggerJobOpts.TriggerConfigFlags
@@ -26,7 +26,3 @@ atlas_add_test( TriggerMenuFlagsTest
 atlas_add_test( TriggerConfigTest
    SCRIPT python -m TriggerJobOpts.TriggerConfig
    POST_EXEC_SCRIPT nopost.sh )
-
-atlas_add_test( flake8
-   SCRIPT flake8 --select=ATL,F,E7,E9,W6 --enable-extension=ATL900,ATL901 ${CMAKE_CURRENT_SOURCE_DIR}/python
-   POST_EXEC_SCRIPT nopost.sh )
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerFlags.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerFlags.py
index 193b34e9fa4..f84b0849ca2 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerFlags.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerFlags.py
@@ -954,7 +954,6 @@ def sync_Trigger2Reco():
     if  recAlgs.doTrigger() and rec.readRDO() and not globalflags.InputFormat()=='bytestream':
         include( "TriggerJobOpts/TransientBS_DetFlags.py" )
 
-    from RecExConfig.RecFlags import rec
     if globalflags.InputFormat() == 'bytestream':
         TriggerFlags.readBS = True
         TriggerFlags.doLVL1 = False
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/BStoBS_post.py b/Trigger/TriggerCommon/TriggerJobOpts/share/BStoBS_post.py
index b81266317c4..4895494e231 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/BStoBS_post.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/BStoBS_post.py
@@ -1,8 +1,8 @@
-##
-## Job option fragment to merge input bytestream with HLT result
-##
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+#
+# Job option fragment to merge input bytestream with HLT result
+#
 
-from RecExConfig.RecFlags import rec
 from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf
 from TriggerJobOpts.TriggerFlags import TriggerFlags
 
@@ -23,6 +23,8 @@ from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamMergeOutputSvc
 mergeSvc=ByteStreamMergeOutputSvc(ByteStreamOutputSvc='ByteStreamEventStorageOutputSvc',
                                   ByteStreamInputSvc='ByteStreamInputSvc',
                                   overWriteHeader=True)
+
+from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 svcMgr+=mergeSvc
 
 StreamBSFileOutput.OutputFile = "ByteStreamMergeOutputSvc"
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/BStoESD_Tier0_HLTConfig_jobOptions.py b/Trigger/TriggerCommon/TriggerJobOpts/share/BStoESD_Tier0_HLTConfig_jobOptions.py
deleted file mode 100644
index c32f7e62cf7..00000000000
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/BStoESD_Tier0_HLTConfig_jobOptions.py
+++ /dev/null
@@ -1 +0,0 @@
-include("TrigTier0/BStoESD_Tier0_HLTConfig_jobOptions.py")
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/TransientBS_DetFlags.py b/Trigger/TriggerCommon/TriggerJobOpts/share/TransientBS_DetFlags.py
index 3cc81603c25..d27dd7f1230 100755
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/TransientBS_DetFlags.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/TransientBS_DetFlags.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
 from AthenaCommon.DetFlags import DetFlags
 from RecExConfig.RecFlags import rec
 from TriggerJobOpts.TriggerFlags import TriggerFlags
@@ -32,6 +34,7 @@ if (not rec.readESD()) and jobproperties.Global.InputFormat() == "pool" and DetF
 # Switch off direct formation of Cells from hits
 #    
 if not rec.readESD() and TriggerFlags.doCalo():
+    from AthenaCommon.Include import include
     include ("CaloRec/CaloCellMaker_config.py")
-    CaloCellMakerFlags.doLArHitToCellDirect=False
-    CaloCellMakerFlags.doTileHitToRawChannelDirect=False
+    CaloCellMakerFlags.doLArHitToCellDirect=False  # noqa: F821 old job options, flags from include above
+    CaloCellMakerFlags.doTileHitToRawChannelDirect=False  # noqa: F821 old job options, flags from include above
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemListAOD_jobOptions.py b/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemListAOD_jobOptions.py
deleted file mode 100755
index a7b6b91acee..00000000000
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemListAOD_jobOptions.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# This is TriggerOutputItemListAOD_joboptions.py
-# It is included from ParticleBuilderOptions/share/AOD_OutputList_jobOptions.py
-# when doWriteAOD=True and doTrigger=True
-
-# add LVL1 and HLT output objects for AOD
-
-def TriggerOutputItemListAOD():
-    from RecExConfig.RecFlags import rec
-    from AthenaCommon.Logging import logging
-    log = logging.getLogger( 'TriggerOutputItemListAOD_joboptions' )
-    log.error("this file is deprecated by the Object Key Store and should no longer be used")
-    TriggerAODList = []
-    if rec.doWriteAOD():
-        print "TriggerAODList: "
-        print TriggerAODList
-
-TriggerOutputItemListAOD()
-
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemList_jobOptions.py b/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemList_jobOptions.py
deleted file mode 100755
index 49459029978..00000000000
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/TriggerOutputItemList_jobOptions.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# This is TriggerOutputItemListESD_joboptions.py
-# It is included from RecoOutputItemList_jobOptions.py
-# when doWriteESD=True and doTrigger=True
-
-def TriggerOutputItemListESD():
-        from RecExConfig.RecFlags import rec
-        from AthenaCommon.Logging import logging
-        log = logging.getLogger( 'TriggerOutputItemList_joboptions' )
-        log.error("this file is deprecated by the Object Key Store and should no longer be used")
-        if rec.doWriteESD():
-            print "TriggerESDList: "
-            print TriggerESDList
-
-# empty list to avoid breaking RecExPers/RecoOutputESDList_jobOptions.py
-TriggerESDList = [] 
-TriggerOutputItemListESD()
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_standalone.py b/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_standalone.py
index f14c6944862..1c3cfe8f908 100755
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_standalone.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_standalone.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
 from AthenaCommon.Logging import logging
 log = logging.getLogger( 'Trigger_topOptions_standalone.py' )
 
@@ -10,6 +12,7 @@ if globalflags.InputFormat() == 'bytestream':
     TriggerFlags.doLVL1=False
 
 # Common alias for online EventLoopMgr used below
+from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 if hasattr(svcMgr,"HltEventLoopMgr"):
     onlEventLoopMgr = svcMgr.HltEventLoopMgr
 else:
@@ -37,15 +40,17 @@ else:
     DetFlags.Calo_setOff()
 
 # Always enable AtlasFieldSvc
-if hasattr(DetFlags,'BField_on'): DetFlags.BField_setOn()
+if hasattr(DetFlags,'BField_on'):
+    DetFlags.BField_setOn()
 
 # Setup IOVDbSvc
-from IOVDbSvc.CondDB import conddb
+from IOVDbSvc.CondDB import conddb  # noqa: F401 configuration by import, old Run-2 job options
 svcMgr.IOVDbSvc.GlobalTag=globalflags.ConditionsTag()
 
 # ----------------------------------------------------------------
 # Setting detector geometry 
 # ----------------------------------------------------------------
+from AthenaCommon.Include import include
 include ("RecExCond/AllDet_detDescr.py")
 
 #we have to reset these flags since the muons do a sync of flags in above fragment
@@ -64,13 +69,14 @@ svcMgr.AtlasFieldSvc.LockMapCurrents = True  # no field scaling
 svcMgr.AtlasFieldSvc.SoleMinCurrent = 160  # Standby current is 150A
 svcMgr.AtlasFieldSvc.ToroMinCurrent = 210  # Standby current is 200A
 # Read currents from IS if available
-if onlEventLoopMgr: onlEventLoopMgr.setMagFieldFromPtree = True
+if onlEventLoopMgr:
+    onlEventLoopMgr.setMagFieldFromPtree = True
             
 # ----------------------------------------------------------------
 # Pool input
 # ----------------------------------------------------------------
 if globalflags.InputFormat()=='pool':
-    import AthenaPoolCnvSvc.ReadAthenaPool
+    import AthenaPoolCnvSvc.ReadAthenaPool  # noqa: F401 configuration by import, old Run-2 job options
     svcMgr.AthenaPoolCnvSvc.PoolAttributes = [ "DEFAULT_BUFFERSIZE = '2048'" ]
     svcMgr.EventSelector.InputCollections = athenaCommonFlags.PoolRDOInput()
     svcMgr.PoolSvc.AttemptCatalogPatch=True 
@@ -85,9 +91,10 @@ if globalflags.InputFormat()=='bytestream':
 
     # This is only needed running athena (as opposed to athenaMT/PT)
     if not hasattr(svcMgr,"ByteStreamCnvSvc"):
-        from ByteStreamCnvSvc import ReadByteStream
+        from ByteStreamCnvSvc import ReadByteStream  # noqa: F401 configuration by import, old Run-2 job options
         # Define the input
         svcMgr.EventSelector.Input = athenaCommonFlags.BSRDOInput()
+        from AthenaCommon.AppMgr import theApp
         theApp.ExtSvc += [ "ByteStreamCnvSvc"]
 
 
@@ -119,8 +126,8 @@ if TriggerFlags.doCalo():
 
 if TriggerFlags.doMuon():
     # load services needed for converters
-    import MuonCnvExample.MuonCablingConfig
-    import MuonRecExample.MuonReadCalib
+    import MuonCnvExample.MuonCablingConfig  # noqa: F401 configuration by import, old Run-2 job options
+    import MuonRecExample.MuonReadCalib  # noqa: F401 configuration by import, old Run-2 job options
     if (TriggerFlags.doEF() or TriggerFlags.doHLT()) and 'forceMuonDataPrep' in dir():
         if (TriggerFlags.MuonSlice.doEFRoIDrivenAccess()):
             include("MuonRdoToPrepData/CscRdoToCscPrepData_jobOptions.py")
@@ -186,13 +193,13 @@ else:
 
 try:
     svc.SetStates( ["xml"] )
-except:
-    log.error( 'failed to set state of TrigConfigSvc ...')
+except Exception as ex:
+    log.error('failed to set state of TrigConfigSvc, %s', str(ex))
 
 try:
     svc.InitialiseSvc()
-except:
-    log.error( 'failed to activate TrigConfigSvc ...')
+except Exception as ex:
+    log.error('failed to activate TrigConfigSvc, %s', str(ex))
 
 # Enable PSK/LB monitoring
 if 'doMonitoring' in svcMgr.HLTConfigSvc.getProperties():
@@ -203,19 +210,19 @@ from TriggerJobOpts.HLTTriggerGetter import HLTSimulationGetter
 hlt = HLTSimulationGetter(g)
 
 
-if 'stopAfterMenuGeneration' in dir() and stopAfterMenuGeneration is True:
+if 'stopAfterMenuGeneration' in globals() and globals()['stopAfterMenuGeneration'] is True:
     theApp.exit()
 
 
 # setup writing of temporary cool db for a possible reco-step afterwards
-log.info("Will create temporary cool file, sources are '%s' and '%s'" % (svc.l1XmlFile,svc.hltXmlFile) )
+log.info("Will create temporary cool file, sources are '%s' and '%s'", svc.l1XmlFile, svc.hltXmlFile )
 from TrigConfigSvc.TrigConf2COOL import theConfCOOLWriter
 theConfCOOLWriter.lvl1menu = svc.l1XmlFile
 theConfCOOLWriter.hltmenu  = svc.hltXmlFile
 theConfCOOLWriter.isWritingNeeded = True
 import re
 TrigCoolDbConnection = re.match(".*;schema=(.*);dbname=.*",theConfCOOLWriter.dbConnection).group(1)
-log.info("Start writing with TrigCoolDbConnection %s" % TrigCoolDbConnection )
+log.info("Start writing with TrigCoolDbConnection %s", TrigCoolDbConnection )
 theConfCOOLWriter.writeConf2COOL()
 f = open("MenuCoolDbLocation.txt","w")
 f.write(TrigCoolDbConnection)
@@ -225,37 +232,44 @@ del f
 # -------------------------------------------------------------
 # Message formatting and OutputLevel
 # -------------------------------------------------------------
-MessageSvc.Format = "% F%48W%S%7W%R%T %0W%M"
+msgSvc = svcMgr.MessageSvc
+msgSvc.Format = "% F%48W%S%7W%R%T %0W%M"
 
 if TriggerFlags.Online.doValidation():
     TriggerFlags.enableMonitoring = TriggerFlags.enableMonitoring.get_Value()+['Log']
 else:
-    MessageSvc.Format = "%t  " + MessageSvc.Format   # add time stamp
-    if hasattr(MessageSvc,'useErsError'):   # ERS forwarding with TrigMessageSvc
-        MessageSvc.useErsError = ['*']
+    msgSvc.Format = "%t  " + msgSvc.Format   # add time stamp
+    if hasattr(msgSvc,'useErsError'):   # ERS forwarding with TrigMessageSvc
+        msgSvc.useErsError = ['*']
 
 # ----------------------------------------------------------------
 # Setting individual OutputLevel 
 # ----------------------------------------------------------------
 trigSteerConf = []
-if TriggerFlags.doHLT(): trigSteerConf += [topSequence.TrigSteer_HLT]
-    
+if TriggerFlags.doHLT():
+    trigSteerConf += [topSequence.TrigSteer_HLT]
+
+HLTOutputLevel = globals()['HLTOutputLevel'] if 'HLTOutputLevel' in globals() else msgSvc.OutputLevel
 for s in trigSteerConf:
     s.OutputLevel = HLTOutputLevel
-    for algo in s.getChildren(): algo.OutputLevel = HLTOutputLevel
+    for algo in s.getChildren():
+        algo.OutputLevel = HLTOutputLevel
+
+if onlEventLoopMgr:
+    onlEventLoopMgr.OutputLevel = HLTOutputLevel
 
-if onlEventLoopMgr: onlEventLoopMgr.OutputLevel = HLTOutputLevel
+from AthenaCommon import Constants
 
 if hasattr(topSequence,'CTPSimulation'):
-    topSequence.CTPSimulation.OutputLevel = INFO
+    topSequence.CTPSimulation.OutputLevel = Constants.INFO
 
 # Special settings of random number service for online
-svcMgr.AtRanluxGenSvc.OutputLevel = WARNING
+svcMgr.AtRanluxGenSvc.OutputLevel = Constants.WARNING
 svcMgr.AtRanluxGenSvc.SaveToFile = False
 
 # Re-seed the RNG on every event
-if hasattr(ToolSvc,'HLT::RandomScaler'):
-    rng = getattr(ToolSvc,'HLT::RandomScaler')
+if hasattr(svcMgr.ToolSvc,'HLT::RandomScaler'):
+    rng = getattr(svcMgr.ToolSvc,'HLT::RandomScaler')
     rng.useEventSeed = True
     rng.config(seed=0, luxury=2)
 
@@ -270,7 +284,8 @@ if TriggerFlags.doHLT():
 
     # Enable timing except for hypos
     for alg in topSequence.TrigSteer_HLT.getChildren():
-        if not 'forceAccept' in alg.properties(): alg.doTiming = True
+        if 'forceAccept' not in alg.properties():
+            alg.doTiming = True
 
     steertime = topSequence.TrigSteer_HLT.MonTools['HLTSteeringTime']
     steertime.NumberOfHistBins = 200
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_writeBS.py b/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_writeBS.py
deleted file mode 100755
index aa5dd473539..00000000000
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/Trigger_topOptions_writeBS.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Trigger_topOptions_writeBS.py
-# simple jO based on rdotobs.py for doing RDO->BS with just Level-1 trigger
-
-from RecExConfig.RecFlags import rec
-from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as acf
-from AthenaCommon.GlobalFlags import globalflags
-    
-if not ('EvtMax' in dir()):
-    acf.EvtMax=-1
-if (not "doFiltering" in dir()):
-    doFiltering=True
-if (not "OutputLevel" in dir()):
-    rec.OutputLevel=INFO
-
-if not "PhysicsLArFormat" in dir():
-    PhysicsLArFormat=False
-
-if (not "setLVL1XML" in dir()):
-    setLVL1XML=None 
-if (not "myBSRDOOutput" in dir()):
-    acf.BSRDOOutput='AppName='+setMenu+', OutputDirectory=./, Run=105200'
-else:
-    acf.BSRDOOutput=myBSRDOOutput
-    
-if 'PoolRDOInput' in dir():
-    acf.PoolRDOInput = PoolRDOInput
-    del PoolRDOInput
-
-if 'setDetDescr' in dir():
-    globalflags.DetDescrVersion = setDetDescr
-else:
-    rec.AutoConfiguration += ['Geo']
-    
-if "setGlobalTag" in dir():
-    globalflags.ConditionsTag = setGlobalTag
-else:
-    rec.AutoConfiguration += ['ConditionsTag']
-   
-doTrigger=True
-rec.doESD=False
-rec.doCBNT=False
-rec.doWriteRDO=False
-rec.doTruth=False
-rec.doESD=False
-rec.doWriteESD=False 
-rec.doWriteAOD=False 
-rec.doAOD=False 
-rec.doWriteTAG=False 
-rec.doPerfMon=False
-rec.doWriteBS=True # enable BS writing
-
-#Set trigger menu
-from TriggerJobOpts.TriggerFlags import TriggerFlags
-TriggerFlags.triggerMenuSetup = setMenu
-if setLVL1XML:
-    TriggerFlags.readLVL1configFromXML=True
-    TriggerFlags.inputLVL1configFile=setLVL1XML
-    TriggerFlags.outputLVL1configFile=None
-else:
-    TriggerFlags.readLVL1configFromXML=False
-TriggerFlags.doLVL2=False
-TriggerFlags.doEF=False
-TriggerFlags.doHLT=False
-
-# main jobOption
-include ("RecExCommon/RecExCommon_topOptions.py")
-
-if PhysicsLArFormat:
-    ToolSvc.LArRawDataContByteStreamTool.DSPRunMode=4
-    ToolSvc.LArRawDataContByteStreamTool.RodBlockVersion=10
-    ToolSvc.LArRawDataContByteStreamTool.IncludeDigits=True
-
-if doFiltering:
-    StreamBSFileOutput.AcceptAlgs = ["RoIBuilder"]
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_BFieldAutoConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_BFieldAutoConfig.py
index becf76d8d5f..6c7555464af 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_BFieldAutoConfig.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_BFieldAutoConfig.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 # TrigDB modifier
 # Usage: athenaHLT.py --postcommand 'include("TriggerJobOpts/dbmod_BFieldAutoConfig.py")' ...
 #
@@ -8,10 +9,11 @@ from AthenaCommon.Logging import logging
 log = logging.getLogger('dbmod_BFieldAutoConfig.py')
 
 db = 'CONDBR2'
-if '_run_number' in dir() and _run_number<222222: db = 'COMP200'
+if '_run_number' in globals() and globals()['_run_number']<222222:
+  db = 'COMP200'
 
 # Add the DCS folder (note the double-use of quotes)
 f = "'<db>COOLOFL_DCS/%s</db> /EXT/DCS/MAGNETS/SENSORDATA'" % db
-log.info("Adding folder %s to IOVDbSvc" % f)
+log.info("Adding folder %s to IOVDbSvc", f)
 iProperty('IOVDbSvc').Folders.push_back(f)
 iProperty('AtlasFieldSvc').UseDCS = True
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_chronoAuditor.py b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_chronoAuditor.py
index e5e311509e3..a9eb508d288 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_chronoAuditor.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_chronoAuditor.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 # TrigDB modifier
 # Usage: athenaMT/PT -C 'include("TriggerJobOpts/dbmod_chronoAuditor.py")' ...
 #
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_nameAuditor.py b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_nameAuditor.py
index 6e3dfbb0cd5..2aa04bbc37a 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_nameAuditor.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/dbmod_nameAuditor.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 # TrigDB modifier
 # Usage: athenaMT/PT -C 'include("TriggerJobOpts/dbmod_nameAuditor.py")' ...
 #
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/jobOfragment_TransBS_standalone.py b/Trigger/TriggerCommon/TriggerJobOpts/share/jobOfragment_TransBS_standalone.py
index e7c7ecb009f..ba3154fe4be 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/jobOfragment_TransBS_standalone.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/jobOfragment_TransBS_standalone.py
@@ -1,6 +1,13 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 #--------------------------------------------------------------
 # Write to Transient BS
 #--------------------------------------------------------------
+
+from AthenaCommon.AppMgr import theApp, ServiceMgr
+from AthenaCommon.Include import include
+from AthenaServices.AthenaServicesConf import AthenaOutputStream
+from TriggerJobOpts.TriggerFlags import TriggerFlags
+
 include( "ByteStreamCnvSvc/RDP_ByteStream_jobOptions.py" )
 
 # Configure Transient BS Output Stream. ExtraInputs make sure all data (e.g. conditions)
@@ -13,7 +20,6 @@ StreamBS = AthenaOutputStream("StreamBS",
 transTypeKey = ("TransientBSOutType","StoreGateSvc+TransientBSOutKey")
 StreamBS.ExtraOutputs += [transTypeKey]
 
-
 if not TriggerFlags.fakeLVL1():
    from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1ByteStreamEncodersRecExSetup
    L1ByteStreamEncodersRecExSetup()
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py
index 120161eec1b..cba0667f190 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone.py
@@ -70,6 +70,7 @@ from TriggerJobOpts.TriggerFlags import TriggerFlags
 from AthenaConfiguration.AllConfigFlags import ConfigFlags
 from AthenaConfiguration.ComponentAccumulator import CAtoGlobalWrapper, conf2toConfigurable
 from AthenaCommon.AppMgr import theApp, ServiceMgr as svcMgr
+from AthenaCommon.Include import include
 from AthenaCommon.Logging import logging
 log = logging.getLogger('runHLT_standalone.py')
 
@@ -242,13 +243,14 @@ from TrigConfigSvc.TrigConfMetaData import TrigConfMetaData
 meta = TrigConfMetaData()
     
 for mod in dir(TriggerJobOpts.Modifiers):
-    if not hasattr(getattr(TriggerJobOpts.Modifiers,mod),'preSetup'): continue
+    if not hasattr(getattr(TriggerJobOpts.Modifiers,mod),'preSetup'):
+        continue
     if mod in dir():  #allow turning on and off modifiers by variable of same name
         if globals()[mod]:
             if mod not in setModifiers:
                 setModifiers+=[mod]
-        else:
-            if mod in setModifiers: setModifiers.remove(mod)
+        elif mod in setModifiers:
+                setModifiers.remove(mod)
     if mod in setModifiers:
         modifierList+=[getattr(TriggerJobOpts.Modifiers,mod)()]
         meta.Modifiers += [mod]    # store in trig conf meta data
@@ -384,7 +386,6 @@ if TriggerFlags.doMuon():
 # ---------------------------------------------------------------
 # ID conditions
 # ---------------------------------------------------------------
-
 if TriggerFlags.doID:
     from InDetTrigRecExample.InDetTrigFlags import InDetTrigFlags
     InDetTrigFlags.doPixelClusterSplitting = False
@@ -393,10 +394,6 @@ if TriggerFlags.doID:
     from AthenaCommon.Include import include
     include("InDetRecExample/InDetRecConditionsAccess.py")
 
-
-
-isPartition = len(ConfigFlags.Trigger.Online.partitionName) > 0
-
 # ----------------------------------------------------------------
 # Pool input
 # ----------------------------------------------------------------
@@ -433,10 +430,8 @@ from TrigConfigSvc.TrigConfigSvcCfg import generateL1Menu, createL1PrescalesFile
 generateL1Menu()
 createL1PrescalesFileFromMenu()
 
-from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc,L1ConfigSvcCfg
+from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
 CAtoGlobalWrapper(L1ConfigSvcCfg,None)
-#svcMgr += getL1ConfigSvc()
-
 
 # ---------------------------------------------------------------
 # Level 1 simulation
@@ -445,9 +440,6 @@ if opt.doL1Sim:
     from TriggerJobOpts.Lvl1SimulationConfig import Lvl1SimulationSequence
     topSequence += Lvl1SimulationSequence(ConfigFlags)
 
-
-
-
 # ---------------------------------------------------------------
 # HLT prep: RoIBResult and L1Decoder
 # ---------------------------------------------------------------
@@ -476,11 +468,9 @@ if opt.doL1Unpacking:
         from TrigUpgradeTest.TestUtils import L1EmulationTest
         topSequence += L1EmulationTest()
 
-
 # ---------------------------------------------------------------
 # HLT generation
 # ---------------------------------------------------------------
-
 if not opt.createHLTMenuExternally:
 
     from TriggerMenuMT.HLTMenuConfig.Menu.GenerateMenuMT import GenerateMenuMT
@@ -544,19 +534,16 @@ if len(opt.condOverride)>0:
         log.warning('Overriding folder %s with tag %s', folder, tag)
         conddb.addOverride(folder,tag)
 
-if svcMgr.MessageSvc.OutputLevel<INFO:
+if svcMgr.MessageSvc.OutputLevel < logging.INFO:
     from AthenaCommon.JobProperties import jobproperties
     jobproperties.print_JobProperties('tree&value')
     print(svcMgr)
 
 #-------------------------------------------------------------
-# Use parts of NewJO
-#-------------------------------------------------------------
-from AthenaCommon.Configurable import Configurable
-
 # Output flags
+#-------------------------------------------------------------
 if opt.doWriteRDOTrigger:
-    if isPartition:
+    if ConfigFlags.Trigger.Online.isPartition:
         log.error('Cannot use doWriteRDOTrigger in athenaHLT or partition')
         theApp.exit(1)
     rec.doWriteRDO = False  # RecExCommon flag
@@ -568,14 +555,16 @@ if opt.doWriteBS:
     ConfigFlags.Output.doWriteBS = True  # new JO flag
     ConfigFlags.Trigger.writeBS = True  # new JO flag
 
-ConfigFlags.Input.Files = athenaCommonFlags.FilesInput()
+#-------------------------------------------------------------
 # ID Cache Creators
+#-------------------------------------------------------------
 ConfigFlags.lock()
 from TriggerJobOpts.TriggerConfig import triggerIDCCacheCreatorsCfg
 CAtoGlobalWrapper(triggerIDCCacheCreatorsCfg,ConfigFlags)
 
-
-# Trigger output
+#-------------------------------------------------------------
+# Output configuration
+#-------------------------------------------------------------
 if opt.doWriteBS or opt.doWriteRDOTrigger:
     from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectDecisionObjects, collectHypoDecisionObjects, triggerOutputCfg
     from AthenaCommon.CFElements import findAlgorithm,findSubSequence
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone_run2.py b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone_run2.py
index 1c03c7fb755..0a92e0bc364 100755
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone_run2.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/runHLT_standalone_run2.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+# flake8: noqa (obsolete Run-2 job options)
 ##############################################################
 # TriggerJobOpts/runHLT_standalone.py
 #
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/share/test_hltConditions.py b/Trigger/TriggerCommon/TriggerJobOpts/share/test_hltConditions.py
index 84f9076dbdf..550b02b03a1 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/share/test_hltConditions.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/share/test_hltConditions.py
@@ -1,3 +1,4 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 ###########################################################################
 # Job options to test HLT conditions updates based on local sqlite file
 #
@@ -13,21 +14,25 @@
 
 
 # Update these values to your need:
-if 'sqlite' not in dir(): sqlite = 'noise.db'
-if 'onldb' not in dir(): onldb = 'ATLAS_COOLONL_CALO'
-if 'folder' not in dir(): folder = '/CALO/Noise/CellNoise'
+if 'sqlite' not in dir():
+   sqlite = 'noise.db'
+if 'onldb' not in dir():
+   onldb = 'ATLAS_COOLONL_CALO'
+if 'folder' not in dir():
+   folder = '/CALO/Noise/CellNoise'
 
 # No updates required past this point
 testCurrentMenu=True
 EvtMax=10
 BSRDOInput='/afs/cern.ch/atlas/project/trigger/pesa-sw/validation/atn-test/data16_13TeV.00307126.physics_eb_zmm_egz.merged.RAW.selected._0001.data'
 
-myfolder = folder     # 'folder' seesm to be overwritten somwhere in the include
+from AthenaCommon.Include import include
+myfolder = folder  # 'folder' seems to be overwritten somewhere in the include
 include('TriggerJobOpts/runHLT_standalone.py')
 folder = myfolder
 
 from AthenaCommon.AppMgr import ServiceMgr as svcMgr
-from IOVDbSvc.CondDB import conddb
+from IOVDbSvc.CondDB import conddb  # noqa: F401 configuration by import, old Run-2 job options
 svcMgr.IOVDbSvc.forceRunNumber = 9999999
 
 sqlite_tmp = 'cool_tmp.db'
@@ -39,13 +44,15 @@ import sys
 # Delete temporary file
 try:
    os.remove(sqlite_tmp)
-except:
+except Exception:
    pass
 
 # Copy folder from online DB
 rc = os.system("AtlCoolCopy 'oracle://ATLAS_COOLPROD;schema=%s;dbname=CONDBR2' 'sqlite://;schema=%s;dbname=CONDBR2' -create -tag %s -hitag -prunetags -folder %s -r 9999999" % (onldb,sqlite_tmp,tag,folder))
-if rc!=0: sys.exit(rc)
+if rc!=0:
+   sys.exit(rc)
 
 # Merge with user given sqlite file (in case only some channels have been updated)
 rc = os.system("AtlCoolCopy 'sqlite://;schema=%s;dbname=CONDBR2' 'sqlite://;schema=%s;dbname=CONDBR2' -folder %s -r 9999999" % (sqlite,sqlite_tmp,folder))
-if rc!=0: sys.exit(rc)
+if rc!=0:
+   sys.exit(rc)
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/test/test_TriggerFlags_autoconf.py b/Trigger/TriggerCommon/TriggerJobOpts/test/test_TriggerFlags_autoconf.py
index 3e422d56011..56c6284a376 100755
--- a/Trigger/TriggerCommon/TriggerJobOpts/test/test_TriggerFlags_autoconf.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/test/test_TriggerFlags_autoconf.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 # Test of Trigger config flags autoconfiguration
 # Exercised on BS data and MC POOL file formats
@@ -25,7 +26,7 @@ inputfiles = {
     "Run2_Data": "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data18_13TeV.00360026.physics_EnhancedBias.merge.RAW._lb0151._SFO-1._0001.1",
     "Run3_Data": nightlydir+"/TrigP1Test/test_trigP1_v1PhysP1_T0Mon_build/data18_13TeV.00360026.physics_Main.unknown.RAW._lb0151._athenaHLT._0001.data",
     #
-    "Run2_MC_r21": nightlydir+"TrigAnalysisTest/test_trigAna_RDOtoAOD_build/AOD.pool.root",
+    "Run2_MC_r22": nightlydir+"TrigAnalysisTest/test_trigAna_RDOtoAOD_build/AOD.pool.root",
     "Run2_MC_r21": getRun2MCFile(),
     #
     "Run3_MC": nightlydir+"TrigAnalysisTest/test_trigAna_RDOtoAOD_mt1_build/AOD.pool.root",
-- 
GitLab