diff --git a/Reconstruction/Jet/JetRec/CMakeLists.txt b/Reconstruction/Jet/JetRec/CMakeLists.txt index c551d427310a8cdb17f5ed94374db1972f580ae6..d3c3ae860f858d5c3ff2ef6f3a9dc9841a2923a5 100644 --- a/Reconstruction/Jet/JetRec/CMakeLists.txt +++ b/Reconstruction/Jet/JetRec/CMakeLists.txt @@ -92,5 +92,5 @@ if ( NOT GENERATIONBASE AND NOT XAOD_STANDALONE AND NOT XAOD_ANALYSIS ) endif() # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_joboptions( share/*.py ) diff --git a/Reconstruction/Jet/JetRec/python/FastJetInterfaceConfig.py b/Reconstruction/Jet/JetRec/python/FastJetInterfaceConfig.py index d9641147035eca31a06e7ddc30c70eb43925bc47..26ce5e8a3f2621d6cd0def553a01a39b3a93fe92 100644 --- a/Reconstruction/Jet/JetRec/python/FastJetInterfaceConfig.py +++ b/Reconstruction/Jet/JetRec/python/FastJetInterfaceConfig.py @@ -1,7 +1,7 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.SystemOfUnits import * +from AthenaCommon.SystemOfUnits import GeV from AthenaCommon.Logging import logging from JetRec.JetRecConf import FastJetInterfaceTool @@ -96,10 +96,10 @@ def checkAndUpdate(**options): for k in options.keys(): if k not in defFastJetInterfaceConfigDict : if ignoreUnknown : - _fastjetLog.warning("Option %s unknown - ignoring it!"%(k)) + _fastjetLog.warning("Option %s unknown - ignoring it!",k) options.pop(k) else : - _fastjetLog.error("Option %s unknown - abort configuration!"%(k)) + _fastjetLog.error("Option %s unknown - abort configuration!",k) raise Exception checkedOptions = dict(defFastJetInterfaceConfigDict) @@ -114,7 +114,6 @@ def checkAndUpdate(**options): # check settings for Strategy key = "Strategy" # print checkedOptions - tag = checkedOptions[key] _fastjetLog.info("Test option %s",key) if checkedOptions[key] not in fastjet_conf_tags.Strategy : _fastjetLog.error("Strategy \042%s\042 not recognized - fatal! Allowed values are: ",checkedOptions['Strategy']) diff --git a/Reconstruction/Jet/JetRec/python/JetAlgorithm.py b/Reconstruction/Jet/JetRec/python/JetAlgorithm.py index 24aaf13dddf0b2a13ef2d1ddf59ffb223ca4211f..79ea227347daa777062e3123ea6bb200d2de49d2 100644 --- a/Reconstruction/Jet/JetRec/python/JetAlgorithm.py +++ b/Reconstruction/Jet/JetRec/python/JetAlgorithm.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # JetAlgorithm.py # @@ -40,16 +40,16 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, from JetRec.JetRecStandard import jtm # Set sequence and flags as needed. - if job == None: + if job is None: from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() - if useTruth == None: + if useTruth is None: useTruth = jetFlags.useTruth() - if eventShapeTools == None: + if eventShapeTools is None: eventShapeTools = jetFlags.eventShapeTools() - if eventShapeTools == None: + if eventShapeTools is None: eventShapeTools = [] - if separateJetAlgs == None: + if separateJetAlgs is None: separateJetAlgs = jetFlags.separateJetAlgs() @@ -198,7 +198,7 @@ def addJetRecoToAlgSequence(job =None, useTruth =None, eventShapeTools =None, from JetRec.JetRecConf import JetToolRunner jtm += JetToolRunner("jetrun", EventShapeTools=[], - Tools=rtools+jtm.jetrecs, + Tools=jtm.jetrecs, Timer=jetFlags.timeJetToolRunner() ) runners += [jtm.jetrun] diff --git a/Reconstruction/Jet/JetRec/python/JetFlavorAlgs.py b/Reconstruction/Jet/JetRec/python/JetFlavorAlgs.py index d80bd05895640485e7b7081152baedea8a956cf9..3bc37378ac2120d1e7271ac3ca77c80f3fdbb35b 100644 --- a/Reconstruction/Jet/JetRec/python/JetFlavorAlgs.py +++ b/Reconstruction/Jet/JetRec/python/JetFlavorAlgs.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # JetFlavorAlgs.py # @@ -20,7 +20,6 @@ def scheduleCopyTruthParticles(): from ParticleJetTools.ParticleJetToolsConf import CopyFlavorLabelTruthParticles from ParticleJetTools.ParticleJetToolsConf import CopyBosonTopLabelTruthParticles from ParticleJetTools.ParticleJetToolsConf import CopyTruthPartons - from ParticleJetTools.CopyTruthParticlesAlg import CopyTruthParticlesAlg tools = [] for ptype in jetFlags.truthFlavorTags(): diff --git a/Reconstruction/Jet/JetRec/python/JetRecStandard.py b/Reconstruction/Jet/JetRec/python/JetRecStandard.py index 2773bc56b02f1af4086e9d1f0512253594b822e1..9f8f073385b046c51d0de29bdb2c982be57f9019 100644 --- a/Reconstruction/Jet/JetRec/python/JetRecStandard.py +++ b/Reconstruction/Jet/JetRec/python/JetRecStandard.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # JetRecStandard.py # @@ -23,7 +23,6 @@ jetlog.info( myname + "Begin.") from RecExConfig.RecFlags import rec from InDetRecExample.InDetJobProperties import InDetFlags -from JetRec.JetRecFlags import jetFlags # Function to display flag value and status. def sflagstat(flag): @@ -106,7 +105,7 @@ if not recAlgs.doEFlow(): # Set the list of rho calculations. # If caller has set jetFlags.eventShapeTools(), then we use those values. -if jetFlags.eventShapeTools() == None: +if jetFlags.eventShapeTools() is None: jetFlags.eventShapeTools = [] if jetFlags.useTopo(): jetFlags.eventShapeTools += ['emtopo', 'lctopo'] @@ -117,7 +116,9 @@ if jetFlags.eventShapeTools() == None: # Import the jet tool manager. from JetRec.JetRecStandardToolManager import jtm +jetlog.verbose("Initialised jtm with tools %s", jtm.tools) # Import the constituent tool manager from JetRecTools.ConstitToolManager import ctm +jetlog.verbose("Initialised ctm with modifiers %s", ctm.modifiersMap) jetlog.info( myname + "End." ) diff --git a/Reconstruction/Jet/JetRec/python/JetRecStandardToolManager.py b/Reconstruction/Jet/JetRec/python/JetRecStandardToolManager.py index 4c1f68fb192209aa4b83c269981c2ba01199bbbe..5562d4a2b19c69aa453075b5b7ae3dff2ea77d71 100644 --- a/Reconstruction/Jet/JetRec/python/JetRecStandardToolManager.py +++ b/Reconstruction/Jet/JetRec/python/JetRecStandardToolManager.py @@ -15,8 +15,6 @@ from AthenaCommon import Logging jetlog = Logging.logging.getLogger('JetRec_jobOptions') -import copy - myname = "JetRecStandardToolManager.py: " jetlog.info( myname + "Defining standard tools" ) @@ -73,13 +71,13 @@ jtm.ptminFinder = 2000 jtm.ptminFilter = 0 # Add standard tool definitions to the tool manager. -import JetRec.JetRecStandardTools +import JetRec.JetRecStandardTools as JetRecStandardTools +jetlog.verbose("Use trigger store? %s", JetRecStandardTools.UseTriggerStore) # Function to filter out skipped tools. def filterout(skiptoolnames, tools): outtools = [] remtoolnames = [] - nrem = 0 for tool in tools: keep = True for toolname in skiptoolnames: diff --git a/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py b/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py index 954540ed1059119ad26602d40014d243ce6914a5..186a490c312dca7486c297db0143026739a93ffb 100644 --- a/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py +++ b/Reconstruction/Jet/JetRec/python/JetRecStandardTools.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # JetRecStandardTools.py # @@ -17,12 +17,9 @@ # Import the jet flags. from JetRec.JetRecFlags import jetFlags -if not "UseTriggerStore " in locals(): +if "UseTriggerStore " not in locals(): UseTriggerStore = False -# get levels defined VERBOSE=1 etc. -from GaudiKernel.Constants import * - from eflowRec.eflowRecFlags import jobproperties from JetRec.JetRecStandardToolManager import jtm @@ -38,13 +35,11 @@ from JetRecTools.JetRecToolsConf import SimpleJetTrackSelectionTool from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool try: - from JetRecCalo.JetRecCaloConf import MissingCellListTool jtm.haveJetRecCalo = True except ImportError: jtm.haveJetRecCalo = False from JetRec.JetRecConf import JetPseudojetRetriever from JetRec.JetRecConf import JetConstituentsRetriever -from JetRec.JetRecConf import JetRecTool from JetRec.JetRecConf import JetFromPseudojet from JetRec.JetRecConf import JetConstitRemover from JetRec.JetRecConf import JetSorter @@ -59,7 +54,6 @@ except ImportError: from JetMomentTools.JetMomentToolsConf import JetWidthTool from JetMomentTools.JetMomentToolsConf import JetCaloEnergies try: - from JetMomentTools.JetMomentToolsConf import JetJetBadChanCorrTool jtm.haveJetBadChanCorrTool = True except ImportError: jtm.haveJetBadChanCorrTool = False @@ -96,7 +90,7 @@ except ImportError: try: from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQuarkLabel jtm.haveParticleJetTools = True -except: +except ImportError: jtm.haveParticleJetTools = False if jtm.haveParticleJetTools: from ParticleJetTools.ParticleJetToolsConf import Analysis__JetConeLabeling @@ -295,16 +289,16 @@ jtm += MuonSegmentPseudoJetAlgorithm( ) useVertices = True -if False == jetFlags.useVertices: +if not jetFlags.useVertices: useVertices = False -if True == jobproperties.eflowRecFlags.useUpdated2015ChargedShowerSubtraction: +if jobproperties.eflowRecFlags.useUpdated2015ChargedShowerSubtraction: useChargedWeights = True else: useChargedWeights = False useTrackVertexTool = False -if True == jetFlags.useTrackVertexTool: +if jetFlags.useTrackVertexTool: useTrackVertexTool = True # Weight tool for charged pflow objects. @@ -314,7 +308,7 @@ jtm += WeightPFOTool("pflowweighter") import cppyy try: cppyy.load_library('libxAODBaseObjectTypeDict') -except: +except Exception: pass from ROOT import xAODType xAODType.ObjectType @@ -530,74 +524,6 @@ jtm += JetWidthTool("width") # Calo layer energies. jtm += JetCaloEnergies("jetens") -# Read in missing cell map (needed for the following) -# commented out : incompatible with trigger : ATR-9696 -## if jtm.haveJetRecCalo: -## def missingCellFileReader(): -## import os -## dataPathList = os.environ[ 'DATAPATH' ].split(os.pathsep) -## dataPathList.insert(0, os.curdir) -## from AthenaCommon.Utils.unixtools import FindFile -## RefFileName = FindFile( "JetBadChanCorrTool.root" ,dataPathList, os.R_OK ) -## from AthenaCommon.AppMgr import ServiceMgr -## if not hasattr(ServiceMgr, 'THistSvc'): -## from GaudiSvc.GaudiSvcConf import THistSvc -## ServiceMgr += THistSvc() -## ServiceMgr.THistSvc.Input += ["JetBadChanCorrTool DATAFILE=\'%s\' OPT=\'READ\'" % RefFileName] -## missingCellFileReader.called = True - -## missingCellFileReader() - -## jtm += MissingCellListTool( -## "missingcells", -## AddCellList = [], -## RemoveCellList = [], -## AddBadCells = True, -## DeltaRmax = 1.0, -## AddCellFromTool = False, -## LArMaskBit = 608517, -## TileMaskBit = 1, -## MissingCellMapName = "MissingCaloCellsMap" -## ) - -## # Bad channel corrections from cells -## if jtm.haveJetBadChanCorrTool: -## jtm += JetBadChanCorrTool( -## "bchcorrcell", -## NBadCellLimit = 10000, -## StreamName = "/JetBadChanCorrTool/", -## ProfileName = "JetBadChanCorrTool.root", -## ProfileTag = "", -## UseCone = True, -## UseCalibScale = False, -## MissingCellMap = "MissingCaloCellsMap", -## ForceMissingCellCheck = False, -## UseClusters = False, -## ) - -## # Bad channel corrections from clusters -## jtm += JetBadChanCorrTool( -## "bchcorrclus", -## NBadCellLimit = 0, -## StreamName = "", -## ProfileName = "", -## ProfileTag = "", -## UseCone = True, -## UseCalibScale = False, -## MissingCellMap = "", -## ForceMissingCellCheck = False, -## UseClusters = True -## ) - -# Jet vertex fraction. -# jtm += JetVertexFractionTool( -# "jvfold", -# VertexContainer = jtm.vertexContainer, -# AssociatedTracks = "GhostTrack", -# TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation, -# JVFName = "JVFOld" -# ) - # Jet vertex fraction with selection. jtm += JetVertexFractionTool( "jvf", @@ -616,9 +542,6 @@ jtm += JetVertexFractionTool( jtm += JetVertexTaggerTool( "jvt", VertexContainer = jtm.vertexContainer, - # AssociatedTracks = "GhostTrack", - # TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation, - # TrackSelector = jtm.trackselloose, JVTName = "Jvt", ) diff --git a/Reconstruction/Jet/JetRec/python/JetRecUtils.py b/Reconstruction/Jet/JetRec/python/JetRecUtils.py index 0d0f11efe543734dee97950f2d9084eae0ac978d..9afc11ea29c10a37006c179b20d08d6d25a7ce25 100644 --- a/Reconstruction/Jet/JetRec/python/JetRecUtils.py +++ b/Reconstruction/Jet/JetRec/python/JetRecUtils.py @@ -1,6 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -from AthenaCommon.AppMgr import ToolSvc +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration from AthenaCommon import Logging jetlog = Logging.logging.getLogger('JetRec_jobOptions') @@ -103,7 +101,6 @@ def buildJetContName(finder, mainParam, input, variableRMassScale=0, variableRMi return buildJetAlgName(finder, mainParam, variableRMassScale, variableRMinRadius) +input+"Jets" # could be more elaborated... def interpretJetName(jetcollName, finder = None,input=None, mainParam=None): - myname = "JetRecUtils: " from AthenaCommon import Logging jetlog = Logging.logging.getLogger('JetRecUtils') # first step : guess the finder, input , mainParam, if needed diff --git a/Reconstruction/Jet/JetRec/python/JetToolSupport.py b/Reconstruction/Jet/JetRec/python/JetToolSupport.py index 40c03ce0e71c2b1fdb1211875e1995acb7ffeede..185af2a244b5a8e7f2f12f4a8939891c5a80d676 100644 --- a/Reconstruction/Jet/JetRec/python/JetToolSupport.py +++ b/Reconstruction/Jet/JetRec/python/JetToolSupport.py @@ -40,12 +40,6 @@ jetlog = Logging.logging.getLogger('JetRec_jobOptions') # import the jet flags. from JetRec.JetRecFlags import jetFlags -from GaudiKernel.Constants import (VERBOSE, - DEBUG, - INFO, - WARNING, - ERROR, - FATAL,) # The tool manager class JetToolManager: prefix = "JetToolManager: " @@ -154,7 +148,7 @@ class JetToolManager: # If the argument is a list, a copy is returned directly. # Also configures any necessary container names in the copy. def getModifiers(self, modifiersin, altname =None): - if modifiersin == None: + if modifiersin is None: if altname in ["lctopo","emtopo"]: return self.modifiersMap[altname+"_ungroomed"] elif "pflow" in altname: @@ -170,7 +164,6 @@ class JetToolManager: # the appropriate calibration tool. def buildModifiers(self, modifiersin, finder, getters, altname, output, calibOpt, constmods=[]): from GaudiKernel.Proxy.Configurable import ConfigurableAlgTool - from JetRec.JetRecConf import JetFinder outmods = [] inmods = self.getModifiers(modifiersin, altname) ncalib = 0 @@ -240,11 +233,11 @@ class JetToolManager: jetlog.info( sinp, cname, output ) raise TypeError # Check that the building of the association tool has been scheduled. - if not cname in self.jetcons: + if cname not in self.jetcons: jetlog.info( self.prefix + "Truth association skipped because container is missing: " + cname ) jetlog.info( self.prefix + "Add to jetcons if input stream is expected to have this." ) tname = mod + "_" + salg + srad - if not tname in self.tools: + if tname not in self.tools: from JetMomentTools.JetMomentToolsConf import JetPtAssociationTool self += JetPtAssociationTool(tname, JetContainer=output, MatchingJetContainer=cname, AssociationName="GhostTruth") outmods += [self.tools[tname]] @@ -258,12 +251,12 @@ class JetToolManager: jetlog.info( sinp, cname, output ) raise TypeError # Check that the building of the association tool has been scheduled. - if not cname in self.jetcons: + if cname not in self.jetcons: jetlog.info( self.prefix + "Track association skipped because container is missing: " + cname ) jetlog.info( self.prefix + "Add to jetcons if input stream is expected to have this." ) else: tname = mod + "_" + salg + srad - if not tname in self.tools: + if tname not in self.tools: from JetMomentTools.JetMomentToolsConf import JetPtAssociationTool self += JetPtAssociationTool(tname, JetContainer=output, MatchingJetContainer=cname, AssociationName="GhostTrack") outmods += [self.tools[tname]] @@ -273,7 +266,7 @@ class JetToolManager: jetlog.info( self.prefix + "Jet filter requested without a threshold." ) raise Exception tname = "jetpt" + str(self.ptminFilter) - if not tname in self.tools: + if tname not in self.tools: from JetRec.JetRecConf import JetFilterTool self.add( JetFilterTool(tname, PtMin=self.ptminFilter) ) outmods += [self.tools[tname]] @@ -292,7 +285,7 @@ class JetToolManager: self.add(btagger) outmods += [btagger] elif mod == "largeR": - outmods += jtm.modifiersMap["largeR"] + outmods += self.modifiersMap["largeR"] else: raise TypeError # Check calibration. @@ -336,12 +329,11 @@ class JetToolManager: self.m_jetBuilder = self.jetBuilderWithoutArea else: self.m_jetBuilder = self.jetBuilderWithArea - if self.m_jetBuilder == None: + if self.m_jetBuilder is None: self.msg(0, "Jet builder must be specified") - raise Error + raise Exception from JetRec.JetRecConf import JetFinder - areaSuffix= "Area" if ghostArea>0.0 else "" - finder = JetFinder(toolname); + finder = JetFinder(toolname) finder.JetAlgorithm = alg finder.JetRadius = radius finder.VariableRMinRadius = variableRMinRadius @@ -355,7 +347,7 @@ class JetToolManager: finder.JetBuilder = self.m_jetBuilder self += finder self.finders += [finder] - hifinder = finder; + hifinder = finder if type(ivtx) is int: from JetRec.JetRecConf import JetByVertexFinder vfinder = JetByVertexFinder( @@ -365,7 +357,7 @@ class JetToolManager: ) self += vfinder self.finders += [vfinder] - hifinder = vfinder; + hifinder = vfinder return (finder, hifinder) # Create a jet finder and rectool. @@ -407,10 +399,10 @@ class JetToolManager: # Accumulate all PseudoJetGetters such that we can schedule all # needed PseudoJetAlgorithms before jet building - self.allGetters += [getter for getter in getters if not getter in self.allGetters] + self.allGetters += [getter for getter in getters if getter not in self.allGetters] # If jet finding by vertex is not specified, check for special input type names ivtx = ivtxin - if ivtx == None: + if ivtx is None: if gettersin == "ztrack": ivtx = -1 # Find tracs separatesly for each vertex elif gettersin == "pv0track": ivtx = 0 # Find tracks only for 1st vertex # Retrieve/build the jet finder. @@ -424,14 +416,13 @@ class JetToolManager: if ptminFilter > 0.0: self.ptminFilter = ptminFilter jetrec.JetModifiers = self.buildModifiers(modifiersin, lofinder, getters, gettersin, output, calibOpt, constmods=constmods) self.autoconfigureModifiers(jetrec.JetModifiers, output) - if consumers != None: + if consumers is not None: jetrec.JetConsumers = consumers self.ptminFilter = ptminSave jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() #jetrec.WarnIfDuplicate = warnIfDuplicate #jetrec.Overwrite = overwrite - # JetRecTool.OutputLevel = VERBOSE self += jetrec if isTrigger: self.trigjetrecs += [jetrec] @@ -725,7 +716,7 @@ class JetToolManager: jetrec.JetGroomer = groomer jetrec.JetModifiers = self.getModifiers(modifiersin) self.autoconfigureModifiers(jetrec.JetModifiers, output) - if consumers != None: + if consumers is not None: jetrec.JetConsumers = consumers jetrec.Trigger = isTrigger or useTriggerStore jetrec.Timer = jetFlags.timeJetRecTool() @@ -772,7 +763,6 @@ class JetToolManager: # Change the output level of a tool. def setOutputLevel(self, toolid, level): - from GaudiKernel.Proxy.Configurable import ConfigurableAlgTool if type(toolid) == str: tool = self[toolid] else: @@ -780,11 +770,9 @@ class JetToolManager: locked = tool.isLocked() oldlevel = "undefined" if locked: - dbglvl = 0 slock = "locked" tool.unlock() else: - dbglvl = 1 slock = "unlocked" aname = "OutputLevel" if hasattr(tool, aname):