def addAntiKt4TruthJets(algseq): ''' Use the standard AntiKt4TruthJets configuration helpers and return the jet finder ''' logger.info('Configuring AntiKt4TruthJets') truthtools = [] from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles truthtools += scheduleCopyTruthParticles() from JetRec.JetRecStandard import jtm truthtools.append(jtm.truthpartcopy) from AthenaCommon import CfgMgr algseq += CfgMgr.JetAlgorithm("jetalgTruthPartCopy", Tools=truthtools) for getter in jtm.gettersMap["truth"]: algseq += getter from JetRec.JetRecStandard import jtm return [ jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin=5000) ]
def reCreatePseudoJets(jetalg, rsize, inputtype): """Return a list of tools (possibly empty) to be run in a jetalg. These tools will make sure PseudoJets will be associated to the container specified by the input arguments. """ from JetRec.JetRecStandard import jtm from JetRec.JetRecUtils import buildJetContName jetContName = buildJetContName(jetalg, rsize, inputtype) # Set default for the arguments to be passd to addJetFinder finderArgs = dict(modifiersin=[], consumers=[], ghostArea=0.01, ptmin=40000) # We do things differently if the container already exists in the input from RecExConfig.ObjKeyStore import cfgKeyStore if cfgKeyStore.isInInputFile("xAOD::JetContainer", jetContName): # yes ! # make sure we don't already have what we need tmpName = "tmp_" + jetContName if tmpName in jtm.tools: return [] # return [jtm.tools[tmpName]] # then we'll have to build a temporary container to re-create the pseudojet # and we recopy this pseudojets to the original collection. This done through # this tool : from JetRec.JetRecConf import JetPseudojetCopier jtm += JetPseudojetCopier( "PJcopierTo" + jetContName, DestinationContainer=jetContName, JetPseudojetRetriever=jtm.jpjretriever ) # prepare args for this case : finderArgs["consumers"] = [jtm.tools["PJcopierTo" + jetContName]] finderArgs["ptmin"] = 20000 else: # no preexisting container # make sure we don't already have what we need tmpName = jetContName if tmpName in jtm.tools: return [] # return [jtm.tools[tmpName]] # no container exist. simply build a new one. if inputtype == "LCTopo": finderArgs["modifiersin"] = "calib" finderArgs["ptmin"] = 2000 finderArgs["ptminFilter"] = 50000 finderArgs["calibOpt"] = "none" finderArgs.pop("modifiersin") # leave the default modifiers. # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo="lctopo", Truth="truth", PV0Track="pv0track") # create the finder for the temporary collection. tmpFinderTool = jtm.addJetFinder( tmpName, jetalg, rsize, getterMap[inputtype], **finderArgs # pass the prepared arguments ) return [tmpFinderTool]
def addPFlowJets(inputtype="EM", rsize=0.4, algseq=None, outputGroup="PFlow"): from JetRec.JetRecStandard import jtm jtm.modifiersMap["mods"] = ["jetfilter", jtm.nsubjettiness, jtm.pull] pflowName = "AntiKt" + str(int( rsize * 10)) + inputtype + "Pflow" # input : EM, EMC, LC algname = "jetalg" + pflowName OutputJets.setdefault(outputGroup, []).append(pflowName) # return if the alg is already scheduled here : if algseq is None: print "No algsequence passed! Will not schedule", algname return elif cfgKeyStore.isInInput("xAOD::JetContainer", pflowName): print "Collection ", algname, "is already in input AOD!" return elif algname in DFJetAlgs: if hasattr(algseq, algname): print " Algsequence", algseq, "already has an instance of", algname else: print " Added", algname, "to sequence", algseq algseq += DFJetAlgs[algname] return DFJetAlgs[algname] if inputtype == "EM": inputName = "empflow" elif inputtype == "EMC": inputName = "emcpflow" elif inputtype == "LC": inputName = "lcpflow" if pflowName in jtm.tools: pflowjet = jtm.tools[pflowName] else: pflowjet = jtm.addJetFinder(pflowName + "Jets", "AntiKt", rsize, inputName, "mods", ghostArea=0.01, ptmin=2000, ptminFilter=7000) from JetRec.JetRecConf import JetAlgorithm print "Adding PFlow jets : ", pflowName alg = JetAlgorithm(algname, Tools=[pflowjet]) print " Added", algname, "to sequence", algseq algseq += alg DFJetAlgs[algname] = alg return alg
def addPFlowJets(inputtype="EM", rsize=0.4, algseq=None, outputGroup="PFlow"): from JetRec.JetRecStandard import jtm jtm.modifiersMap["mods"] = ["jetfilter", jtm.nsubjettiness, jtm.pull] pflowName = "AntiKt" + str(int(rsize * 10)) + inputtype + "Pflow" # input : EM, EMC, LC algname = "jetalg" + pflowName OutputJets.setdefault(outputGroup, []).append(pflowName) # return if the alg is already scheduled here : if algseq is None: print "No algsequence passed! Will not schedule", algname return elif cfgKeyStore.isInInput("xAOD::JetContainer", pflowName): print "Collection ", algname, "is already in input AOD!" return elif algname in DFJetAlgs: if hasattr(algseq, algname): print " Algsequence", algseq, "already has an instance of", algname else: print " Added", algname, "to sequence", algseq algseq += DFJetAlgs[algname] return DFJetAlgs[algname] if inputtype == "EM": inputName = "empflow" elif inputtype == "EMC": inputName = "emcpflow" elif inputtype == "LC": inputName = "lcpflow" if pflowName in jtm.tools: pflowjet = jtm.tools[pflowName] else: pflowjet = jtm.addJetFinder( pflowName + "Jets", "AntiKt", rsize, inputName, "mods", ghostArea=0.01, ptmin=2000, ptminFilter=7000 ) from JetRec.JetRecConf import JetAlgorithm print "Adding PFlow jets : ", pflowName alg = JetAlgorithm(algname, Tools=[pflowjet]) print " Added", algname, "to sequence", algseq algseq += alg DFJetAlgs[algname] = alg return alg
def addAntiKt4TruthJets(algseq): ''' Use the standard AntiKt4TruthJets configuration helpers and return the jet finder ''' logger.info('Configuring AntiKt4TruthJets') jtools = [] from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles jtools += scheduleCopyTruthParticles() from JetRec.JetRecStandard import jtm jtools.append(jtm.truthpartcopy) from JetRec.JetRecStandard import jtm jtools.append( jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin=5000)) return jtools
def buildTOPQCA15jets(algseq): if not cfgKeyStore.isInInput("xAOD::JetContainer", "CamKt15LCTopoJets"): from JetRec.JetRecConf import JetAlgorithm jtm.modifiersMap["lctopoCA15"] = list(jtm.modifiersMap["lctopo"]) if globalflags.DataSource() == 'geant4': jtm.modifiersMap["lctopoCA15"].remove('truthassoc') if hasattr(jtm, "CamKt15LCTopoJets"): TOPQCA15LC = getattr(jtm, "CamKt15LCTopoJets") else: TOPQCA15LC = jtm.addJetFinder("CamKt15LCTopoJets", "CamKt", 1.5, "lctopo", "lctopoCA15", ghostArea=0.01, ptmin=2000, ptminFilter=100000, calibOpt="aro") if not hasattr(algseq, "jetalgCamKt15LCTopo"): TOPQCA15LCalg = JetAlgorithm("jetalgCamKt15LCTopo", Tools=[TOPQCA15LC]) algseq += TOPQCA15LCalg print "Running jet finding algorithm for CamKt15LCTopoJets"
def scheduleRTTJetTests(): global containerToRebuild from JetRec.JetRecFlags import jetFlags from RecExConfig.RecFlags import rec jetFlags.useTruth = rec.doTruth() from JetRec.JetRecStandard import jtm from JetRec.JetRecConf import JetAlgorithm from JetRec.JetRecUtils import interpretJetName from JetRec.JetRecStandardToolManager import calib_topo_ungroomed_modifiers, topo_ungroomed_modifiers #calibarg = 'calib' if jetFlags.applyCalibrationName()!="none" else None #calibarg = 'calib' if jetFlags.applyCalibrationName!= "none" else "none" # arguments to give to addJetFinder # format is 'input' : dict_of_args inputArgs = { 'LCTopo': dict( gettersin='lctopo', modifiersin='calib', ghostArea=0.01, ), 'EMTopo': dict( gettersin='emtopo', modifiersin='calib', ghostArea=0.01, ), 'ZTrack': {}, } fullnameArgs = { "AntiKt4LCTopoJetsTest": dict(ptminFilter=7000, calibOpt='ar'), "AntiKt4EMTopoJetsTest": dict(ptminFilter=5000, calibOpt='ar'), "AntiKt10LCTopoJetsTest": dict(ptminFilter=50000, calibOpt='a'), "CamKt12LCTopoJetsTest": dict(ptminFilter=50000, calibOpt='a'), } tools = [] for jname in containerToRebuild: # decompose arg name finder, mainParam, input = interpretJetName(jname) args = fullnameArgs[jname] args.update(inputArgs[input]) # call addJetFinderArgs with the relavant args for this collection t = jtm.addJetFinder(jname, finder, mainParam, ptmin=2000, **args) tools.append(t) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() if jetFlags.useTruth: from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles tools = [jtm.truthpartcopy, jtm.truthpartcopywz ] + scheduleCopyTruthParticles() + tools topSequence += JetAlgorithm("JetAlgorithmTest", Tools=[ jtm.tracksel, jtm.tvassoc, ] + tools)
def addStandardJets(jetalg, rsize, inputtype, ptmin=2000, ptminFilter=5000, mods="calib", calibOpt="none", ghostArea=0.01, algseq=None, outputGroup="CustomJets", exclusiveSubjetBuilderList=[], **extraOptions): ############################################### # supported options in extraOptions: # jetnamebase # variableRMinRadius # variableRMassScale ############################################### # "jetnamebase" can be configured through extraOptions if 'jetnamebase' not in extraOptions.keys(): jetnamebase = "{0}{1}{2}".format(jetalg, int(rsize * 10), inputtype) else: jetnamebase = extraOptions['jetnamebase'] jetname = jetnamebase + "Jets" algname = "jetalg" + jetnamebase OutputJets.setdefault(outputGroup, []).append(jetname) # exclusive kt subjet builder list if type(mods) is str: mods = jtm.modifiersMap[mods] for exclusiveSubjetBuilder in exclusiveSubjetBuilderList: (subjetfinder, SubjetContainerName) = exclusiveSubjetBuilder(jetname) mods += [subjetfinder] # add subjet container to the output OutputJets.setdefault(outputGroup, []).append(SubjetContainerName) # return if the alg is already scheduled here : if algseq is None: print "No algsequence passed! Will not schedule", algname return elif cfgKeyStore.isInInput("xAOD::JetContainer", jetname): print "Collection ", algname, "is already in input AOD!" return elif algname in DFJetAlgs: if hasattr(algseq, algname): print " Algsequence", algseq, "already has an instance of", algname else: print " Added", algname, "to sequence", algseq algseq += DFJetAlgs[algname] return DFJetAlgs[algname] if not jetname in jtm.tools: # Set default for the arguments to be passd to addJetFinder finderArgs = dict(modifiersin=[], consumers=[]) finderArgs['ptmin'] = ptmin finderArgs['ptminFilter'] = ptminFilter finderArgs['ghostArea'] = ghostArea # configs for variable-R if ("variableRMinRadius" in extraOptions.keys()) and ("variableRMassScale" in extraOptions.keys()): print 'INFO: You are running varaible-R jets!' finderArgs['variableRMinRadius'] = extraOptions[ 'variableRMinRadius'] finderArgs['variableRMassScale'] = extraOptions[ 'variableRMassScale'] # no container exist. simply build a new one. if inputtype == "LCTopo": finderArgs['modifiersin'] = mods finderArgs['calibOpt'] = "none" else: # be careful here -- when inputtype is not "LCTopo", many modifers in "calib" will not work # therefore, it is highly recommended to set mods=[], or something that you know that will work with non-calo type jet print 'Warning! Make sure you know what you are doing!' print 'Running addStandardJets for', jetname print 'Here is a list of modifiers:', mods finderArgs['modifiersin'] = mods #finderArgs.pop('modifiersin') # leave the default modifiers. # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo='lctopo', Truth='truth', TruthWZ='truthwz', PV0Track='pv0track') # create the finder for the temporary collection. finderTool = jtm.addJetFinder( jetname, jetalg, rsize, getterMap[inputtype], **finderArgs # pass the prepared arguments ) from JetRec.JetRecConf import JetAlgorithm alg = JetAlgorithm(algname, Tools=[finderTool]) print " Added", algname, "to sequence", algseq algseq += alg DFJetAlgs[algname] = alg
from DerivationFrameworkCore.DerivationFrameworkMaster import * from JetRec.JetRecFlags import jetFlags from AthenaCommon.GlobalFlags import globalflags ################################################################## # Schedule common content for all jet-using derivations ################################################################## jetFlags.eventShapeTools = [] from JetRec.JetRecStandard import jtm from RecExConfig.ObjKeyStore import cfgKeyStore if not cfgKeyStore.isInInput("xAOD::JetContainer", "AntiKt2PV0TrackJets"): jtm.addJetFinder("AntiKt2PV0TrackJets", "AntiKt", 0.2, "pv0track", ptmin=2000) from JetRec.JetAlgorithm import addJetRecoToAlgSequence addJetRecoToAlgSequence(DerivationFrameworkJob, eventShapeTools=None) DFJetAlgs = {} ################################################################## # Definitions of helper functions ################################################################## def defineEDAlg(R=0.4, inputtype="LCTopo"): from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg from AthenaCommon.AppMgr import ToolSvc
def _getJetBuildTool(merge_param, ptmin, ptminFilter, jet_calib, cluster_calib, do_minimalist_setup, do_substructure, name='', trkopt='', secondary_label='', outputLabel=''): """Set up offline tools. do_minimalist_setup controls whether jetRecTool is set up with the minimum required jet modifiers. The code can be exercised with do_minimalist_setup=False to ensure that it possible to run with with a more complex set of modifiers.""" # declare jtm as global as this function body may modify it # with the += operator global jtm msg = 'Naming convention breaks with merge param %d' % merge_param int_merge_param = int(10 * merge_param) assert 10 * merge_param == int_merge_param, msg assert merge_param > 0. # Ensure the calibration is valid _is_calibration_supported(int_merge_param, jet_calib, cluster_calib) if secondary_label == '': mygetters = [_getTriggerPseudoJetGetter(cluster_calib)] else: mygetters = [ _getTriggerPseudoJetGetter(cluster_calib), _getTriggerPseudoJetGetter(secondary_label) ] jtm.gettersMap["mygetters"] = mygetters print "my getters are " print mygetters print "printing gettersMap keys..." print jtm.gettersMap.keys() # in situ calibration step is only for data, not MC # this string here allows the following code to be data/MC unaware inSitu = 'i' if _getIsData() else '' # tell the offline code which calibration is requested calib_str = { 'jes': 'calib:j:triggerNoPileup:HLTKt4', 'subjes': 'calib:aj:trigger:HLTKt4', 'sub': 'calib:a:trigger:HLTKt4', 'subjesIS': 'calib:ajg%s:trigger2016:HLTKt4' % (inSitu) }.get(jet_calib, '') # with S Schramm very early 18/4/2016 mymods = [jtm.jetens] if calib_str: mymods.append(calib_str) mymods.append(jtm.caloqual_cluster) if outputLabel != 'triggerTowerjets': #towers don't have cluster moments mymods.append(jtm.clsmoms) if secondary_label == 'GhostTrack': # ghost track association expected, will want track moments. if not hasattr(jtm, 'trkmoms_' + trkopt): print "In TrigHLTJetRecConfig._getJetBuildTool: Something went wrong. GhostTrack label set but no track moment tools configured. Continuing without trkmodifers." else: trkmoms_ghosttrack = getattr(jtm, 'trkmoms_' + trkopt) trkmoms_ghosttrack.unlock() trkmoms_ghosttrack.AssociatedTracks = secondary_label trkmoms_ghosttrack.lock() mymods.append(trkmoms_ghosttrack) if not hasattr(jtm, 'jvf_' + trkopt): print "In TrigHLTJetRecConfig._getJetBuildTool: Something went wrong. GhostTrack label set but no JVF tool configured. Continuing without jvf calculations." else: jvf_ghosttrack = getattr(jtm, 'jvf_' + trkopt) jvf_ghosttrack.unlock() jvf_ghosttrack.AssociatedTracks = secondary_label jvf_ghosttrack.lock() mymods.append(jvf_ghosttrack) if not do_minimalist_setup: # add in extra modofiers. This allows monitoring the ability # to run with the extra modifiers, which may be required in the # future. mymods.extend([ jtm.nsubjettiness, jtm.jetens, jtm.caloqual_cluster, jtm.bchcorrclus, jtm.width ]) if do_substructure: # this set of moments will be reduced once we've run once to evaluate costs # don't want to include nsubjettiness and width twice if do_minimalist_setup: mymods.extend([jtm.nsubjettiness, jtm.width]) mymods.extend([ # jtm.nsubjettiness, jtm.ktdr, jtm.ktsplitter, jtm.encorr, jtm.charge, jtm.angularity, jtm.comshapes, jtm.ktmassdrop, jtm.dipolarity, jtm.pull, jtm.planarflow, # jtm.width, jtm.qw, # jtm.trksummoms # this needs tracks and vertices which we don't have by default ]) # DEBUG DEBUG DEBUG # mymods = [] # DEBUG DEBUG DEBUG # Add jet calo width always if do_minimalist_setup and not do_substructure: mymods.append(jtm.width) jtm.modifiersMap["mymods"] = mymods # name = 'TrigAntiKt%d%sTopoJets' % (int_merge_param, cluster_calib) if not name: name = 'TrigAntiKt%d%s%sTopoJets' % (int_merge_param, cluster_calib, jet_calib) def findjetBuildTool(): for jr in jtm.trigjetrecs: if jr.OutputContainer == name: # jr.OutputContainer is a string, here used to identify the # object return jr return None jetBuildTool = findjetBuildTool() if jetBuildTool is None: print 'adding new jet finder ', name try: jetBuildTool = jtm.addJetFinder( name, "AntiKt", merge_param, "mygetters", "mymods", # non-zero ghostArea: calcjet area # for pileup subtraction. ghostArea=0.01, rndseed=1, isTrigger=True, ptmin=ptmin, ptminFilter=ptminFilter) if not hasattr(jtm, "jbldTrigger"): jtm.addJetBuilderWithArea( JetFromPseudojet( "jbldTrigger", Attributes=["ActiveArea", "ActiveArea4vec"], IsTrigger= True, # )) )) if merge_param == 0.4: from AthenaCommon.AppMgr import ToolSvc getattr(ToolSvc, name + "Finder").unlock() getattr(ToolSvc, name + "Finder").JetBuilder = jtm.jbldTrigger getattr(ToolSvc, name + "Finder").lock() # # For debugging # getattr(ToolSvc,"jconretriever").unlock() # getattr(ToolSvc,"jconretriever").OutputLevel = 1 # getattr(ToolSvc,"jconretriever").lock() # print "FS scan Builder looks like.." # print getattr(ToolSvc,name+"Finder").JetBuilder # getattr(ToolSvc,name+"Finder").unlock() # getattr(ToolSvc,name+"Finder").OutputLevel = 1 # getattr(ToolSvc,name+"Finder").JetBuilder.setOutputLevel = 1 # getattr(ToolSvc,name+"Finder").lock() # getattr(ToolSvc,"jbldTrigger").unlock() # getattr(ToolSvc,"jbldTrigger").OutputLevel = 1 # getattr(ToolSvc,"jbldTrigger").lock() except Exception, e: print 'error adding new jet finder %s' % name for jr in jtm.trigjetrecs: print jr raise e
jetFlags.truthFlavorTags = [ "BHadronsInitial", "BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "Partons", ] # Standard truth jets # To recover jet constituents remove the last modifier. akt4 = jtm.addJetFinder( "AntiKt4TruthJets", "AntiKt", 0.4, "truth", modifiersin=[jtm.truthpartondr, jtm.partontruthlabel, jtm.removeconstit], ptmin=5000) akt4alg = JetAlgorithm("jetalgAntiKt4TruthJets", Tools=[akt4]) DerivationFrameworkJob += akt4alg # WZ Truth Jets #jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin= 5000) #jtm.addJetFinder("AntiKt6TruthWZJets", "AntiKt", 0.6, "truthwz", ptmin= 5000) # Other jets #akt6 = jtm.addJetFinder("AntiKt6TruthJets", "AntiKt", 0.6, "truth", ptmin= 5000) #akt10 = jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin= 5000) #akt10trim = jtm.addJetTrimmer("TrimmedAntiKt10TruthJets", rclus=0.3, ptfrac=0.05, input='AntiKt10TruthJets') # Add truth-based MET algorithm here
# jetFlags.timeJetToolRunner.set_Value(2) # Import the jet tool manager. from JetRec.JetRecStandard import jtm #-------------------------------------------------------------- # Define the finders and groomers. # Each line configures a finder or groomer and its associated jetrec tool. # The first argument is the name of the output collection and the jetrec tool. # The fifth argument is the list of modifiers. # Non-zero ghostArea enables calculation of active area. #-------------------------------------------------------------- # Finders. if jetFlags.useTruth(): jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin= 5000) jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin= 5000) jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin=40000) jtm.addJetFinder("AntiKt10TruthWZJets", "AntiKt", 1.0, "truthwz", ptmin=40000) # jtm.addJetFinder("CamKt12TruthJets", "CamKt", 1.2, "truth", ptmin=40000) # jtm.addJetFinder("CamKt12TruthWZJets", "CamKt", 1.2, "truthwz", ptmin=40000) if jetFlags.useTracks(): jtm.addJetFinder("AntiKt2PV0TrackJets", "AntiKt", 0.2, "pv0track", ptmin= 2000) # jtm.addJetFinder("AntiKt3PV0TrackJets", "AntiKt", 0.3, "pv0track", ptmin= 2000) jtm.addJetFinder("AntiKt4PV0TrackJets", "AntiKt", 0.4, "pv0track", ptmin= 2000) if jetFlags.useTopo(): jtm.addJetFinder("AntiKt4EMTopoJets", "AntiKt", 0.4, "emtopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter= 5000, calibOpt="ar") jtm.addJetFinder("AntiKt4LCTopoJets", "AntiKt", 0.4, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter= 7000, calibOpt="ar") jtm.addJetFinder("AntiKt10LCTopoJets", "AntiKt", 1.0, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter=50000, calibOpt="none") # jtm.addJetFinder("CamKt12LCTopoJets", "CamKt", 1.2, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter=50000, calibOpt="none") if jetFlags.usePFlow():
## Configure jet container for anti-kT R=0.4 truth jets evgenConfig.findJets = True ## Turn off ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = [] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", modifiersin="none", ptmin=7000.)
# jtm.modifiersMap["mycalib"] = jtm.modifiersMap["calib"] # if jtm.haveShowerDeconstructionTool: # jtm.modifiersMap["mycalib"] # Finders. # Calibration for topo jets: calibOpt = # a - area corrn # r - residual pileup corrn # j - GES # g - GSC # i - Insitu gatopo = 0.01 gatruth = 0.00 gatrack = 0.00 if jetFlags.useTruth: jtm.addJetFinder("Run2AntiKt4TruthJets", "AntiKt", 0.4, "truth", ghostArea=gatruth, ptmin= 5000) jtm.addJetFinder("Run2AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ghostArea=gatruth, ptmin= 5000) jtm.addJetFinder("Run2AntiKt10TruthJets", "AntiKt", 0.4, "truth", ghostArea=gatruth, ptmin=40000) jtm.addJetFinder("Run2AntiKt10TruthWZJets", "AntiKt", 1.0, "truth", ghostArea=gatruth, ptmin=40000) jtm.addJetFinder("Run2CamKt12TruthJets", "CamKt", 1.2, "truth", ghostArea=gatruth, ptmin=40000) jtm.addJetFinder("Run2CamKt12TruthWZJets", "CamKt", 1.2, "truth", ghostArea=gatruth, ptmin=40000) if jetFlags.useTracks: jtm.addJetFinder("Run2AntiKt2PV0TrackJets", "AntiKt", 0.2, "pv0track", ghostArea=gatrack, ptmin= 2000) jtm.addJetFinder("Run2AntiKt3PV0TrackJets", "AntiKt", 0.3, "pv0track", ghostArea=gatrack, ptmin= 2000) jtm.addJetFinder("Run2AntiKt4TrackJets", "AntiKt", 0.4, "track", ghostArea=gatrack, ptmin= 2000) #jtm.addJetFinder("Run2AntiKt4ZTrackJets", "AntiKt", 0.4, "ztrack", ghostArea=gatrack, ptmin= 2000) jtm.addJetFinder("Run2AntiKt4PV0TrackJets", "AntiKt", 0.4, "pv0track", ghostArea=gatrack, ptmin= 2000) jtm.addJetFinder( "Run2AntiKt4EMTopoJets", "AntiKt", 0.4, "emtopo", "emtopo_ungroomed", ptmin=2000, ptminFilter= 5000, ghostArea=gatopo, calibOpt="ar") jtm.addJetFinder( "Run2AntiKt4LCTopoJets", "AntiKt", 0.4, "lctopo", "lctopo_ungroomed", ptmin=2000, ptminFilter= 7000, ghostArea=gatopo, calibOpt="ar") jtm.addJetFinder( "Run2AntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow", "pflow_ungroomed", ptmin=2000, ptminFilter= 5000, ghostArea=gatopo, calibOpt="ar:pflow") jtm.addJetFinder( "Run2AntiKt10LCTopoJets", "AntiKt", 1.0, "lctopo", "lctopo_ungroomed", ptmin=2000, ptminFilter=50000, ghostArea=gatopo, calibOpt="none")
DerivationFrameworkJob += xAODMaker__xAODTruthCnvAlg( "GEN_EVNT2xAOD", AODContainerName="GEN_EVENT") from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles scheduleCopyTruthParticles(DerivationFrameworkJob) # Set jet flags from JetRec.JetRecFlags import jetFlags jetFlags.useTruth = True jetFlags.useTracks = False # Add jet algorithms from JetRec.JetRecStandard import jtm from JetRec.JetRecConf import JetAlgorithm # Standard truth jets akt4 = jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin=25000) akt4alg = JetAlgorithm("jetalgAntiKt4TruthJets", Tools=[akt4]) DerivationFrameworkJob += akt4alg # WZ Truth Jets #jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin= 5000) #jtm.addJetFinder("AntiKt6TruthWZJets", "AntiKt", 0.6, "truthwz", ptmin= 5000) # Other jets #akt6 = jtm.addJetFinder("AntiKt6TruthJets", "AntiKt", 0.6, "truth", ptmin= 5000) akt10 = jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin=100000)
jtm.width ] # Add tools to find or groom jets. # Each call to addJetFinder adds one JetRecTool so that one jet # container will be added to the event. # The first argument is the name of that container. # The next two are the jet algorithm (Kt, AntiKt, CamKt) and # size parameter. # The next two are the names of the input and modifier lists. # The following optional, named arguments may also be provided: # ghostArea: Size in eta-phi for area ghosts # ptmin: pT threshold in MeV applied in jet finding # ptminFilter: pT threshold applied by the jet modifier "jetfilter" jtm.addJetFinder("MyAntiKtVRLCTopoJets", "AntiKt", 0.4, "mygetters", "mymods", ghostArea=0.01 , ptmin=2000, ptminFilter=7000, variableRMinRadius=0.2, variableRMassScale=60000) #-------------------------------------------------------------- # Configure the jet algorithm. # The current configuration of the jet tool manager is used. #-------------------------------------------------------------- from JetRec.JetAlgorithm import jetalg #-------------------------------------------------------------- # Add tool to dump the new jet container to the log. #-------------------------------------------------------------- from JetRec.JetRecConf import JetDumper ToolSvc += JetDumper("jetdumper0") jetdumper0 = ToolSvc.jetdumper0
def addStandardJets(jetalg, rsize, inputtype, ptmin=0., ptminFilter=0., mods="default", calibOpt="none", ghostArea=0.01, algseq=None, namesuffix="", outputGroup="CustomJets", customGetters=None, pretools=[], constmods=[], overwrite=False): jetnamebase = "{0}{1}{2}{3}".format(jetalg, int(rsize * 10), inputtype, namesuffix) jetname = jetnamebase + "Jets" algname = "jetalg" + jetnamebase OutputJets.setdefault(outputGroup, []).append(jetname) # return if the alg is already scheduled here : from RecExConfig.AutoConfiguration import IsInInputFile if algseq is None: dfjetlog.warning("No algsequence passed! Will not schedule " + algname) return elif IsInInputFile("xAOD::JetContainer", jetname) and not overwrite: dfjetlog.warning("Collection " + jetname + " is already in input AOD!") return elif algname in DFJetAlgs: if hasattr(algseq, algname): dfjetlog.warning("Algsequence " + algseq.name() + " already has an instance of " + algname) else: dfjetlog.info("Added " + algname + " to sequence " + algseq.name()) algseq += DFJetAlgs[algname] return DFJetAlgs[algname] from JetRec.JetRecStandard import jtm if not jetname in jtm.tools: # no container exist. simply build a new one. # Set default for the arguments to be passd to addJetFinder defaultmods = { "EMTopo": "emtopo_ungroomed", "LCTopo": "lctopo_ungroomed", "EMPFlow": "pflow_ungroomed", "EMCPFlow": "pflow_ungroomed", "Truth": "truth_ungroomed", "TruthWZ": "truth_ungroomed", "PV0Track": "track_ungroomed", } if mods == "default": mods = defaultmods[inputtype] if inputtype in defaultmods else [] finderArgs = dict(modifiersin=mods, consumers=[]) finderArgs['ptmin'] = ptmin finderArgs['ptminFilter'] = ptminFilter finderArgs['ghostArea'] = ghostArea finderArgs['modifiersin'] = mods finderArgs['calibOpt'] = calibOpt print("mods in:", finderArgs['modifiersin']) if overwrite: dfjetlog.info("Will overwrite AOD version of " + jetname) finderArgs['overwrite'] = True # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo='lctopo', EMTopo='emtopo', EMPFlow='empflow', EMCPFlow='emcpflow', Truth='truth', TruthWZ='truthwz', TruthDressedWZ='truthdressedwz', TruthCharged='truthcharged', PV0Track='pv0track') # create the finder for the temporary collection. if customGetters is None: inGetter = getterMap[inputtype] for getter in jtm.gettersMap[inGetter]: if not hasattr(algseq, getter.name()): algseq += getter else: inGetter = customGetters for getter in customGetters: if not hasattr(algseq, getter.name()): algseq += getter finderTool = jtm.addJetFinder( jetname, jetalg, rsize, inGetter, constmods=constmods, **finderArgs # pass the prepared arguments ) from JetRec.JetRecConf import JetAlgorithm alg = JetAlgorithm(algname, Tools=pretools + [finderTool]) dfjetlog.info("Added " + algname + " to sequence " + algseq.name()) algseq += alg DFJetAlgs[algname] = alg
def reCreatePseudoJets(jetalg, rsize, inputtype, variableRMassScale=-1.0, variableRMinRadius=-1.0, algseq=None, constmods=[]): """Return a list of tools (possibly empty) to be run in a jetalg. These tools will make sure PseudoJets will be associated to the container specified by the input arguments. """ from JetRec.JetRecStandard import jtm from JetRec.JetRecUtils import buildJetContName constmodstr = "".join(constmods) inputname = inputtype + constmodstr label = inputtype + constmodstr jetContName = buildJetContName(jetalg, rsize, inputname, variableRMassScale, variableRMinRadius) # Set default for the arguments to be passd to addJetFinder finderArgs = dict( modifiersin=[], consumers=[], ghostArea=0.01, ptmin=40000, constmods=constmods, ) # We do things differently if the container already exists in the input from RecExConfig.AutoConfiguration import IsInInputFile if IsInInputFile("xAOD::JetContainer", jetContName): # yes ! # make sure we don't already have what we need tmpName = "tmp_" + jetContName if tmpName in jtm.tools: return [jtm.tools[tmpName]] # then we'll have to build a temporary container to re-create the pseudojet # and we recopy this pseudojets to the original collection. This done through # this tool : from JetRec.JetRecConf import JetPseudojetCopier jtm += JetPseudojetCopier("PJcopierTo" + jetContName, DestinationContainer=jetContName, JetPseudojetRetriever=jtm.jpjretriever) # prepare args for this case : finderArgs['consumers'] = [jtm.tools["PJcopierTo" + jetContName]] finderArgs['ptmin'] = 20000 else: # no preexisting container # make sure we don't already have what we need tmpName = jetContName if tmpName in jtm.tools: # return [] return [jtm.tools[tmpName]] # no container exist. simply build a new one. if inputtype == "LCTopo" or inputtype == "EMTopo" or inputtype == "EMPFlow" or inputtype == "EMCPFlow": defaultmods = { "EMTopo": "emtopo_ungroomed", "LCTopo": "lctopo_ungroomed", "EMPFlow": "pflow_ungroomed", "EMCPFlow": "pflow_ungroomed", "Truth": "truth_ungroomed", "TruthWZ": "truth_ungroomed", "PV0Track": "track_ungroomed" } finderArgs['modifiersin'] = defaultmods[inputtype] finderArgs['ptmin'] = 2000 finderArgs['ptminFilter'] = 50000 finderArgs['calibOpt'] = "none" elif inputtype == "PV0Track": finderArgs['modifiersin'] = None finderArgs['ptmin'] = 2000 finderArgs['ptminFilter'] = 40000 finderArgs['calibOpt'] = "none" #if not "PFlow" in inputtype: finderArgs.pop('modifiersin') # leave the default modifiers. if (variableRMassScale > 0): finderArgs['variableRMassScale'] = variableRMassScale finderArgs['variableRMinRadius'] = variableRMinRadius #finderArgs['ghostArea'] =0 ## Cannot afford ghost area calculation for variable-R jets (for now) # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo='lctopo', EMTopo='emtopo', EMPFlow='empflow', EMCPFlow='emcpflow', Truth='truth', TruthWZ='truthwz', TruthDressedWZ='truthdressedwz', TruthCharged='truthcharged', PV0Track='pv0track') # create the finder for the temporary collection. getters = getterMap[inputtype] for getter in jtm.gettersMap[getters]: if not hasattr(algseq, getter.name()): algseq += getter if len(constmods) > 0: finderArgs['modifiersin'] = [] from JetRecConfig import ConstModHelpers from JetRecConfig.JetDefinition import xAODType, JetConstit if inputtype == "EMTopo": constit = JetConstit(xAODType.CaloCluster, ["EM", "Origin"]) elif inputtype == "LCTopo": constit = JetConstit(xAODType.CaloCluster, ["LC", "Origin"]) elif inputtype == "EMPFlow": constit = JetConstit(xAODType.ParticleFlow) constit.modifiers += constmods constitalg = ConstModHelpers.getConstitModAlg(constit) if not hasattr(algseq, constitalg.name()): algseq += constitalg from JetRecConfig import JetRecConfig constitpjalg = JetRecConfig.getConstitPJGAlg(constit) if not hasattr(algseq, constitpjalg.name()): algseq += constitpjalg getterbase = inputtype.lower() getters = [constitpjalg] + list(jtm.gettersMap[getterbase])[1:] tmpFinderTool = jtm.addJetFinder( tmpName, jetalg, rsize, getters, **finderArgs # pass the prepared arguments ) return [tmpFinderTool]
## Configure jet container for anti-kT R=0.6 truth jets evgenConfig.findJets = True ## Turn off ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = [] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt6TruthJets", "AntiKt", 0.6, "truth", modifiersin="none", ptmin=7000.)
jetlog.info( "Skipped tools: %s", jetFlags.skipTools()) # Import the jet tool manager. from JetRec.JetRecStandard import jtm #-------------------------------------------------------------- # Define the finders and groomers. # Each line configures a finder or groomer and its associated jetrec tool. # The first argument is the name of the output collection and the jetrec tool. # The fifth argument is the list of modifiers. # Non-zero ghostArea enables calculation of active area. #-------------------------------------------------------------- # Finders. if jetFlags.useTruth(): jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin= 5000) jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin= 5000) jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin=40000) jtm.addJetFinder("AntiKt10TruthWZJets", "AntiKt", 1.0, "truthwz", ptmin=40000) jtm.addJetFinder("CamKt12TruthJets", "AntiKt", 1.2, "truth", ptmin=40000) jtm.addJetFinder("CamKt12TruthWZJets", "AntiKt", 1.2, "truthwz", ptmin=40000) if jetFlags.useTracks(): jtm.addJetFinder("AntiKt3PV0TrackJets", "AntiKt", 0.3, "pv0track", ptmin= 2000) jtm.addJetFinder("AntiKt4PV0TrackJets", "AntiKt", 0.4, "pv0track", ptmin= 2000) if jetFlags.useTopo(): jtm.addJetFinder("AntiKt4EMTopoJets", "AntiKt", 0.4, "emtopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter= 5000, calibOpt="ar") jtm.addJetFinder("AntiKt4LCTopoJets", "AntiKt", 0.4, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter= 7000, calibOpt="ar") jtm.addJetFinder("AntiKt10LCTopoJets", "AntiKt", 1.0, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter=50000, calibOpt="a") jtm.addJetFinder("CamKt12LCTopoJets", "CamKt", 1.2, "lctopo", "calib", ghostArea=0.01, ptmin= 2000, ptminFilter=50000, calibOpt="a") #--------------------------------------------------------------
# ******************************************************************** from DerivationFrameworkCore.DerivationFrameworkMaster import * from JetRec.JetRecFlags import jetFlags from AthenaCommon.GlobalFlags import globalflags ################################################################## # Schedule common content for all jet-using derivations ################################################################## jetFlags.eventShapeTools = [] from JetRec.JetRecStandard import jtm from RecExConfig.ObjKeyStore import cfgKeyStore if not cfgKeyStore.isInInput("xAOD::JetContainer", "AntiKt2PV0TrackJets"): jtm.addJetFinder("AntiKt2PV0TrackJets", "AntiKt", 0.2, "pv0track", ptmin=2000) from JetRec.JetAlgorithm import addJetRecoToAlgSequence addJetRecoToAlgSequence(DerivationFrameworkJob, eventShapeTools=None) DFJetAlgs = {} ################################################################## # Definitions of helper functions ################################################################## def defineEDAlg(R=0.4, inputtype="LCTopo"): from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg from AthenaCommon.AppMgr import ToolSvc
# Define the finders and groomers. # Each line configures a finder or groomer and its associated jetrec tool. # The first argument is the name of the output collection and the jetrec tool. # The fifth argument is the list of modifiers. # Non-zero ghostArea enables calculation of active area. #-------------------------------------------------------------- calibopt = "arj" if not jetFlags.useVertices(): calibopt = "aj" jetlog.info(myname + "No vertices -- switch calibopt to " + calibopt) # Finders. if jetFlags.detailLevel()==JetContentDetail.Reduced: if jetFlags.useTopo(): jtm.addJetFinder("AntiKt4EMTopoJets", "AntiKt", 0.4, "emtopo_reduced", "emtopo_ungroomed", ghostArea=0.01, ptmin= 5000, ptminFilter= 15000, calibOpt=calibopt) jtm.addJetFinder("AntiKt4LCTopoJets", "AntiKt", 0.4, "lctopo_reduced", "lctopo_ungroomed", ghostArea=0.01, ptmin= 5000, ptminFilter= 15000, calibOpt=calibopt) jtm.addJetFinder("AntiKt10LCTopoJets", "AntiKt", 1.0, "lctopo_reduced", "lctopo_ungroomed", ghostArea=0.01, ptmin= 40000, ptminFilter=50000, calibOpt="none") if jetFlags.usePFlow(): jtm.addJetFinder("AntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow_reduced", "pflow_ungroomed", ghostArea=0.01, ptmin= 5000, ptminFilter= 10000, calibOpt=calibopt+":pflow") # if jetFlags.useTruth(): # jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin= 5000) elif jetFlags.detailLevel()>=JetContentDetail.Full: if jetFlags.useTruth(): jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", ptmin= 5000) jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin= 5000) jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", ptmin=40000) jtm.addJetFinder("AntiKt10TruthWZJets", "AntiKt", 1.0, "truthwz", ptmin=40000) if jetFlags.useTracks(): jtm.addJetFinder("AntiKt2PV0TrackJets", "AntiKt", 0.2, "pv0track", ptmin= 2000) jtm.addJetFinder("AntiKt4PV0TrackJets", "AntiKt", 0.4, "pv0track", ptmin= 2000)
OutputContainer="PUPPI", InputType="ParticleFlow", Modifiers=[correctPFOTool, puppiWeightTool, CHSTool], SaveAsShallow=False, ) ToolSvc += PUPPISequence from JetRec.JetRecStandardToolManager import empfgetters, pflow_ungroomed_modifiers myPUPPIgetters = listReplace(empfgetters, jtm.empflowget, jtm.PUPPIGetter) pflow_ungroomed_modifiers.remove('calib') pflow_ungroomed_modifiers.remove('truthassoc') jtm.addJetFinder("AntiKt4EMPFlowPUPPIJets", "AntiKt", 0.4, myPUPPIgetters, pflow_ungroomed_modifiers, ghostArea=0.01, ptmin=5000, ptminFilter=10000, calibOpt="") ############################################################################################ from JetRec.JetAlgorithm import addJetRecoToAlgSequence addJetRecoToAlgSequence(job=topSequence, separateJetAlgs=True) if hasattr(topSequence, "jetalgAntiKt4EMPFlowPUPPIJets"): topSequence.jetalgAntiKt4EMPFlowPUPPIJets.Tools.insert(0, PUPPISequence) ############################################################################################
def addStandardJets( jetalg, rsize, inputtype, ptmin=2000, ptminFilter=5000, mods="calib", calibOpt="none", ghostArea=0.01, algseq=None, outputGroup="CustomJets", exclusiveSubjetBuilderList=[], **extraOptions ): ############################################### # supported options in extraOptions: # jetnamebase # variableRMinRadius # variableRMassScale ############################################### # "jetnamebase" can be configured through extraOptions if "jetnamebase" not in extraOptions.keys(): jetnamebase = "{0}{1}{2}".format(jetalg, int(rsize * 10), inputtype) else: jetnamebase = extraOptions["jetnamebase"] jetname = jetnamebase + "Jets" algname = "jetalg" + jetnamebase OutputJets.setdefault(outputGroup, []).append(jetname) # exclusive kt subjet builder list if type(mods) is str: mods = jtm.modifiersMap[mods] for exclusiveSubjetBuilder in exclusiveSubjetBuilderList: (subjetfinder, SubjetContainerName) = exclusiveSubjetBuilder(jetname) mods += [subjetfinder] # add subjet container to the output OutputJets.setdefault(outputGroup, []).append(SubjetContainerName) # return if the alg is already scheduled here : if algseq is None: print "No algsequence passed! Will not schedule", algname return elif cfgKeyStore.isInInput("xAOD::JetContainer", jetname): print "Collection ", algname, "is already in input AOD!" return elif algname in DFJetAlgs: if hasattr(algseq, algname): print " Algsequence", algseq, "already has an instance of", algname else: print " Added", algname, "to sequence", algseq algseq += DFJetAlgs[algname] return DFJetAlgs[algname] if not jetname in jtm.tools: # Set default for the arguments to be passd to addJetFinder finderArgs = dict(modifiersin=[], consumers=[]) finderArgs["ptmin"] = ptmin finderArgs["ptminFilter"] = ptminFilter finderArgs["ghostArea"] = ghostArea # configs for variable-R if ("variableRMinRadius" in extraOptions.keys()) and ("variableRMassScale" in extraOptions.keys()): print "INFO: You are running varaible-R jets!" finderArgs["variableRMinRadius"] = extraOptions["variableRMinRadius"] finderArgs["variableRMassScale"] = extraOptions["variableRMassScale"] # no container exist. simply build a new one. if inputtype == "LCTopo": finderArgs["modifiersin"] = mods finderArgs["calibOpt"] = "none" else: # be careful here -- when inputtype is not "LCTopo", many modifers in "calib" will not work # therefore, it is highly recommended to set mods=[], or something that you know that will work with non-calo type jet print "Warning! Make sure you know what you are doing!" print "Running addStandardJets for", jetname print "Here is a list of modifiers:", mods finderArgs["modifiersin"] = mods # finderArgs.pop('modifiersin') # leave the default modifiers. # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo="lctopo", Truth="truth", TruthWZ="truthwz", PV0Track="pv0track") # create the finder for the temporary collection. finderTool = jtm.addJetFinder( jetname, jetalg, rsize, getterMap[inputtype], **finderArgs # pass the prepared arguments ) from JetRec.JetRecConf import JetAlgorithm alg = JetAlgorithm(algname, Tools=[finderTool]) print " Added", algname, "to sequence", algseq algseq += alg DFJetAlgs[algname] = alg
from METReconstruction.METRecoFlags import metFlags ############################################################################## from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() ############################################################################## from JetRec.JetRecFlags import jetFlags jetFlags.useTruth = False jetFlags.usePFlow=True from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow", "pflow", ghostArea=0.01, ptmin= 2000, ptminFilter= 5000, calibOpt="a:pflow") from JetRec.JetAlgorithm import addJetRecoToAlgSequence addJetRecoToAlgSequence() ############################################################################## #from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg #from JetRec.JetRecStandard import jtm #edTool=configEventDensityTool("EDTool40", jtm.lcget, 0.4) #edTool.OutputLevel = VERBOSE #ToolSvc += edTool #edAlg = EventDensityAlg( "EventDensityAlg"+edTool.name(), EventDensityTool = edTool , OutputLevel=VERBOSE) #topSequence += edAlg #
def _getHIJetBuildTool(merge_param, ptmin=20000., ptminFilter=20000., jet_calib='jes', cluster_calib='EM', hicluster_name='HLTHICluster', name=''): global jtm msg = 'Naming convention breaks with merge param %d' % merge_param int_merge_param = int(10 * merge_param) assert 10 * merge_param == int_merge_param, msg assert merge_param > 0. if not name: name = 'TrigAntiKt%dHIJets' % int_merge_param EventShapeKey = "HLT_xAOD__HIEventShapeContainer_TrigHIEventShape" #jobproperties.HIGlobalFlags.EventShapeKey() #EventShapeKey = "HIEventShapeContainer_HIUE" #EventShapeKey = "TrigHIEventShape" ClusterKey = hicluster_name # Plug in directly tools from HIJetTools.py e.g. to avoid PseudoJetGetter which is different at HLT and for other reasons # ------------------------------------------------------------------------------------------------------------------------- #jet filters from JetRec.JetRecConf import JetFilterTool jetfil5 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil5", PtMin=5000) jtm.add(jetfil5) jetfil8 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil8", PtMin=8000) jtm.add(jetfil8) jetfil20 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil20", PtMin=20000) jtm.add(jetfil20) jetfil25 = JetFilterTool("HLT_a" + str(int_merge_param) + "jetfil25", PtMin=25000) jtm.add(jetfil25) #DR association- form element links for all clusters w/in DR of each jet # DR=HIJetFlags.ClusterDRAssociation() # from HIJetRec.HIJetRecConf import HIJetDRAssociationTool # assoc=HIJetDRAssociationTool("HLT_a"+str(int_merge_param)+"HIJetDRAssociation") # assoc.ContainerKey=ClusterKey # assoc.DeltaR=DR # #assoc.AssociationName="%s_DR%dAssoc" % (ClusterKey,int(10*DR)) # assoc.AssociationName="HLT_a"+str(int_merge_param)+"HIClDR%dAssoc" % (int(10*DR)) # #assoc.AssociationName="GhostTrack" # jtm.add(assoc) # # assoc_name=assoc.AssociationName #calculate discriminants as moments from HIJetRec.HIJetRecConf import HIJetMaxOverMeanTool max_over_mean = HIJetMaxOverMeanTool("HLT_a" + str(int_merge_param) + "HIJetMaxOverMean") jtm.add(max_over_mean) #discriminants for jet filtering from HIJetRec.HIJetRecConf import HIJetDiscriminatorTool discrim = HIJetDiscriminatorTool("HLT_a" + str(int_merge_param) + "HIJetDiscriminator") discrim.MaxOverMeanCut = HIJetFlags.DCutMaxOverMean() discrim.MinimumETMaxCut = HIJetFlags.DCutMax() jtm.add(discrim) #jtm.trigjetrecs += [discr] #null modulator #tname="HLT_a"+str(int_merge_param)+"NullUEModulator" #if hasattr(jtm,tname) : return getattr(jtm,tname) from HIJetRec.HIJetRecConf import HIUEModulatorTool mod_tool = HIUEModulatorTool("HLT_a" + str(int_merge_param) + "NullUEModulator") mod_tool.EventShapeKey = 'NULL' for n in [2, 3, 4]: setattr(mod_tool, 'DoV%d' % n, False) jtm.add(mod_tool) # subtraction from HIJetRec.HIJetRecConf import HIJetCellSubtractorTool cell_subtr = HIJetCellSubtractorTool("HLT_a" + str(int_merge_param) + "HIJetSubtractor") jtm.add(cell_subtr) # calibration from JetCalibTools.JetCalibToolsConf import JetCalibrationTool calib_seq = 'EtaJES_Insitu' JES_is_data = True #if not _getIsData(): # calib_seq='EtaJES' # JES_is_data=False calib_tool = JetCalibrationTool("HLT_a" + str(int_merge_param) + "HICalibTool", JetCollection="AntiKt4HI", ConfigFile="JES_MC15c_HI_Nov2016.config", CalibSequence=calib_seq, IsData=JES_is_data) jtm.add(calib_tool) from TrigHLTJetRec.TrigHLTJetRecConfig import _getTriggerPseudoJetGetter # ------------------------------------------------------------------------------------------------- a2_unsubtracted_name = "TrigAntiKt2HIJets_Unsubtracted_a" + str( int_merge_param) seed_finder = jtm.addJetFinder( a2_unsubtracted_name, "AntiKt", 0.2, #gettersin=[_getTriggerHIPseudoJetGetter(hicluster_name)], gettersin=[_getTriggerPseudoJetGetter(cluster_calib)], #modifiersin=[assoc,max_over_mean,jetfil5], # jtm.modifiersMap['HI_Unsubtr'], # may think about TrigHI_Unsubtracted with just max_over_mean modifiersin=[ max_over_mean, jetfil5 ], # jtm.modifiersMap['HI_Unsubtr'], # may think about TrigHI_Unsubtracted with just max_over_mean #modifiersin=[assoc,max_over_mean,jetfil5,discrim], # jtm.modifiersMap['HI_Unsubtr'], # may think about TrigHI_Unsubtracted with just max_over_mean #consumers=None, ivtxin=None, ghostArea=0.0, isTrigger=True, ptmin=5000, ptminFilter=5000) seeds0_name = "TrigAntiKt2HIJets_seeds0_a" + str(int_merge_param) seeds0 = jtm.addJetCopier(seeds0_name, a2_unsubtracted_name, [discrim], isTrigger=True, shallow=False) #seeds0 = seed_finder #from HIJetRec.HIJetRecConf import HIEventShapeJetIterationHLT from TrigHIRec.TrigHIRecConf import TrigHIEventShapeJetIteration iter0_name = "a" + str(int_merge_param) + "iter0" iter0 = TrigHIEventShapeJetIteration(iter0_name) iter0.InputEventShapeKey = EventShapeKey iter0.OutputEventShapeKey = EventShapeKey + "_" + iter0_name #iter0.AssociationKey=assoc_name iter0.InputClustersKey = ClusterKey iter0.Trigger = True iter0.OutputContainer = EventShapeKey + "_" + iter0_name #iter0.SeedContainerKeys=[seeds0.OutputContainer] iter0.SeedContainerKey = seeds0.OutputContainer #if not hasattr(jtm,"HLT_a"+str(int_merge_param)+"HIJetSubtractor") : # from HIJetRec.HIJetRecConf import HIJetCellSubtractorTool # cell_subtr=HIJetCellSubtractorTool("HLT_a"+str(int_merge_param)+"HIJetSubtractor") # jtm.add(cell_subtr) #iter0.Subtractor=jtm.HIJetSubtractor iter0.Subtractor = cell_subtr jtm.add(iter0) jtm.trigjetrecs += [iter0] #subtr1=MakeSubtractionTool(iter0.OutputEventShapeKey,moment_name="subtr1") from HIJetRec.HIJetRecConf import HIJetConstituentSubtractionTool subtr1 = HIJetConstituentSubtractionTool("HIConstituentSubtractor_%s" % iter0.OutputEventShapeKey) subtr1.EventShapeKey = iter0.OutputEventShapeKey subtr1.SetMomentOnly = False subtr1.MomentName = "JetSubtractedScaleMomentum" #"subtr1" #subtr1.Subtractor=jtm.HIJetSubtractor subtr1.Subtractor = cell_subtr subtr1.Modulator = mod_tool jtm.add(subtr1) seeds1_name = "TrigAntiKt2HIJets_seeds1_a" + str(int_merge_param) seeds1 = jtm.addJetCopier(seeds1_name, a2_unsubtracted_name, [subtr1, calib_tool, jetfil25], isTrigger=True, shallow=False) #add calib tool iter1_name = "a" + str(int_merge_param) + "iter1" iter1 = TrigHIEventShapeJetIteration(iter1_name) iter1.InputEventShapeKey = EventShapeKey iter1.OutputEventShapeKey = EventShapeKey + "_" + iter1_name #iter1.AssociationKey=assoc_name iter1.InputClustersKey = ClusterKey iter1.Trigger = True iter1.OutputContainer = EventShapeKey + "_" + iter1_name #iter1.SeedContainerKeys=[seeds1.OutputContainer] iter1.SeedContainerKey = seeds1.OutputContainer #iter1.Subtractor=jtm.HIJetSubtractor iter1.Subtractor = cell_subtr #iter1.ModulationScheme=1; #iter1.RemodulateUE=remodulate #iter1.Modulator=mod_tool #iter1.ModulationEventShapeKey=mod_tool.EventShapeKey jtm.add(iter1) jtm.trigjetrecs += [iter1] #subtr2=MakeSubtractionTool(iter1.OutputEventShapeKey,moment_name="subtr2") from HIJetRec.HIJetRecConf import HIJetConstituentSubtractionTool subtr2 = HIJetConstituentSubtractionTool("HIConstituentSubtractor_%s" % iter1.OutputEventShapeKey) subtr2.EventShapeKey = iter1.OutputEventShapeKey subtr2.MomentName = "JetSubtractedScaleMomentum" subtr2.SetMomentOnly = False #subtr2.Subtractor=jtm.HIJetSubtractor subtr2.Subtractor = cell_subtr subtr2.Modulator = mod_tool jtm.add(subtr2) finder = jtm.addJetFinder( name + "_finder", "AntiKt", merge_param, #gettersin=[_getTriggerHIPseudoJetGetter(hicluster_name)], gettersin=[_getTriggerPseudoJetGetter(cluster_calib)], modifiersin=[subtr2, calib_tool], #consumers=None, ivtxin=None, ghostArea=0.0, rndseed=0, isTrigger=True, ptmin=ptmin, ptminFilter=ptminFilter) exe_tools = [seed_finder, seeds0, iter0, seeds1, iter1, finder] from JetRec.JetRecConf import JetToolRunner runner = JetToolRunner("jetrunHI_a" + str(int_merge_param), Tools=exe_tools) jtm.add(runner) builder = jtm.addJetCopier(name, name + "_finder", [], isTrigger=True, shallow=False) builder.unlock() builder.InputTool = runner builder.lock() jetBuildTool = builder ## we could also add to hi_modifiers the calibration as defined below: #_is_calibration_supported(int_merge_param, jet_calib, cluster_calib) # # tell the offline code which calibration is requested #calib_str = {'jes': 'calib:j:triggerNoPileup:HLTKt4', # 'subjes': 'calib:aj:trigger:HLTKt4', # 'sub': 'calib:a:trigger:HLTKt4'}.get(jet_calib, '') #myMods = [calib_str] if calib_str else [] return jetBuildTool
## Configure jet container for anti-kT R=0.4 truth jets with flavour labels ## Note: this cannot be used simultaneously with a non-labelled jet container ## since jetFlags.truthFlavorTags is a global variable evgenConfig.findJets = True ## Turn on ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = ["BHadronsInitial", "BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "Partons", ] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False ## truthpartondr => adds cone-based label ## partontruthlabel => adds ghost-based label ## removeconstit => empties container of jet constituents to reduce filesize from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", modifiersin=[jtm.truthpartondr, jtm.partontruthlabel, jtm.removeconstit], ptmin=7000.)
def buildVRJets(sequence, do_ghost, logger=None, doFlipTagger=False, training='201810'): from AthenaCommon import Logging if logger is None: logger = Logging.logging.getLogger('VRLogger') supported_trainings = ['201810', '201903'] # Check allowed trainings # Is there a better way to do this with a central DB? if training not in ['201810', '201903']: logger.warning( "WARNING: Using an unsupported training tag! This is UNDEFINED and will probably break. Please choose a training tag from" ) logger.warning(supported_trainings) from JetRec.JetRecStandard import jtm # Making Chris Happy: all VR track-jet b-tagging should have the training campaign label trainingTag = '_BTagging%s' % (training) VRJetName = "AntiKtVR30Rmax4Rmin02Track%s" % (trainingTag) VRGhostLabel = "GhostVR30Rmax4Rmin02TrackJet%s" % (trainingTag) VRJetAlg = "AntiKt" VRJetRadius = 0.4 VRJetInputs = 'pv0track' VRJetOptions = dict(ghostArea=0, ptmin=4000, variableRMinRadius=0.02, variableRMassScale=30000, calibOpt="none") # Change some options if we have do_ghost set to true. Hopefully # this will be the only VR collection in the future. if do_ghost: ghost_suffix = "GhostTag" VRJetName += ghost_suffix VRGhostLabel += ghost_suffix #========================================================== # Build VR jets #========================================================== from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg VRJetRecToolName = nameJetsFromAlg(VRJetName) VRJetAlgName = "jfind_%s" % (VRJetRecToolName) VRJetBTagName = "BTagging_%s" % (VRJetName.replace('BTagging', '')) logger.info("VR Btag name: %s" % VRJetBTagName) logger.info("VR jet name: %s" % VRJetRecToolName) from AthenaCommon.AppMgr import ToolSvc #make the btagging tool for VR jets from BTagging.BTaggingFlags import BTaggingFlags BTaggingFlags.CalibrationChannelAliases += [ "AntiKtVR30Rmax4Rmin02Track->AntiKtVR30Rmax4Rmin02Track,AntiKt4EMTopo" ] BTaggingFlags.CalibrationChannelAliases += [ "%s->AntiKtVR30Rmax4Rmin02Track,AntiKt4EMTopo" % (VRJetName) ] btag_vrjets = ConfInst.setupJetBTaggerTool( ToolSvc, JetCollection=VRJetRecToolName, AddToToolSvc=True, Verbose=True, options={ "name": VRJetBTagName.lower(), "BTagName": VRJetBTagName, "BTagJFVtxName": "JFVtx", "BTagSVName": "SecVtx", }, SetupScheme="", TaggerList=BTaggingFlags.ExpertTaggers if doFlipTagger else BTaggingFlags.StandardTaggers, TrackAssociatorName="GhostTrack" if do_ghost else "MatchedTracks", ) # add Ghost label id from ParticleJetTools.ParticleJetToolsConf import ( ParticleJetGhostLabelTool as GhostLabelTool) gl_tool = GhostLabelTool(name=VRJetRecToolName + "_GhostLabeling") ToolSvc += gl_tool from BTagging.BTaggingConfiguration import defaultTrackAssoc, defaultMuonAssoc # Slice the array - this forces a copy so that if we modify it we don't also # change the array in jtm. pseudoJetGetters = jtm.gettersMap[VRJetInputs][:] # We want to include ghost associated tracks in the pv0 tracks so that # we can use the looser ghost association criteria for b-tagging. if VRJetInputs == "pv0track": pseudoJetGetters.append(jtm["gtrackget"]) if VRJetAlgName in DFJetAlgs: logger.info("Algorithm %s already built before" % VRJetAlgName) if hasattr(sequence, VRJetAlgName): logger.info("Sequence %s already has an instance of algorithm %s" % (sequence, VRJetAlgName)) else: logger.info("Add algorithm %s to sequence %s" % (VRJetAlgName, sequence)) sequence += DFJetAlgs[VRJetAlgName] else: logger.info("Create algorithm %s" % VRJetAlgName) if hasattr(jtm, VRJetRecToolName): logger.info("JetRecTool %s is alredy in jtm.tools in sequence %s" % (VRJetRecToolName, sequence)) else: logger.info("Create JetRecTool %s" % VRJetRecToolName) #can only run trackjetdrlabeler with truth labels, so MC only mods = [defaultTrackAssoc, defaultMuonAssoc, btag_vrjets] if isMC: mods += [jtm.trackjetdrlabeler, gl_tool] jtm.addJetFinder(VRJetRecToolName, VRJetAlg, VRJetRadius, pseudoJetGetters, modifiersin=mods, ivtxin=0, **VRJetOptions) from JetRec.JetRecConf import JetAlgorithm jetalg_smallvr30_track = JetAlgorithm(VRJetAlgName, Tools=[jtm[VRJetRecToolName]]) sequence += jetalg_smallvr30_track DFJetAlgs[VRJetAlgName] = jetalg_smallvr30_track #========================================================== # Build PseudoJet Getter #========================================================== pjgettername = VRGhostLabel.lower() from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg if hasattr(jtm, pjgettername): logger.info("Found %s in jtm in sequence %s" % (pjgettername, sequence)) else: logger.info("Add %s to jtm in sequence %s" % (pjgettername, sequence)) inputContainerName = jetFlags.containerNamePrefix() + nameJetsFromAlg( VRJetName) from JetRec.JetRecConf import PseudoJetGetter jtm += PseudoJetGetter( pjgettername, # give a unique name InputContainer=inputContainerName, # SG key Label= VRGhostLabel, # this is the name you'll use to retrieve ghost associated VR track jets OutputContainer="PseudoJet" + VRGhostLabel, SkipNegativeEnergy=True, GhostScale= 1.e-20, # this makes the PseudoJet Ghosts, and thus the reco flow will treat them as such ) return VRJetName, VRGhostLabel
from AthenaCommon.AthenaCommonFlags import jobproperties as jp jp.AthenaCommonFlags.EvtMax.set_Value_and_Lock(-1) #=================================================================== # Variable R track jets #=================================================================== from DerivationFrameworkExotics.JetDefinitions import * from JetRec.JetRecStandard import jtm FTAG5Seq = CfgMgr.AthSequencer("FTAG5Sequence") jtm.modifiersMap["smallvr_track_modifiers"] = jtm.modifiersMap["pv0track"] jtm.modifiersMap["largevr_track_modifiers"] = [jtm.ktsplitter] # (nikola: what is this used for?) jfind_smallvr_track = jtm.addJetFinder("AntiKtVR50Rmax4Rmin0TrackJets", "AntiKt", 0.4, "pv0track", "smallvr_track_modifiers", ghostArea = 0 , ptmin = 2000, ptminFilter = 7000, variableRMinRadius = 0, variableRMassScale = 50000, calibOpt = "none") from JetRec.JetRecConf import JetAlgorithm jetalg_smallvr_track= JetAlgorithm("jfind_smallvr_track", Tools = [jfind_smallvr_track]) FTAG5Seq += jetalg_smallvr_track from JetRec.JetRecConf import PseudoJetGetter jtm += PseudoJetGetter( "gvr50rmax4rmin0trackget", # give a unique name InputContainer = jetFlags.containerNamePrefix() + "AntiKtVR50Rmax4Rmin0TrackJets", # SG key Label = "GhostVR50Rmax4Rmin0TrackJet", # this is the name you'll use to retrieve ghost associated VR track jets OutputContainer = "PseudoJetGhostVR50Rmax4Rmin0TrackJet", SkipNegativeEnergy = True, GhostScale = 1.e-20, # this makes the PseudoJet Ghosts, and thus the reco flow will treat them as such
def linkVRJetsToLargeRJets(sequence, collection, getters): """Re-run jet finding for a jet collection using a new list of PseudoJetGetters. These PseudoJetGetters should already have been loaded into jtm. collection should be the name of the jet collection, which should already have been sequenced, so it's jet rec tool will exist in jtm. getters should be a map of PseudoJetGetters, each key being the name of the (non ghost) collection, with the value being the name of the PseudoJetGetter in jtm. Returns the name of the ungroomed collection that is the parent of 'collection' (this will be the same as 'collection' if this isn't groomed) *and* the list of ghost labels (these are the element link names). """ from JetRec.JetRecStandardToolManager import jtm import DerivationFrameworkJetEtMiss.JetCommon as JetCommon from DerivationFrameworkJetEtMiss.ExtendedJetCommon import nameJetsFromAlg logger = Logging.logging.getLogger('HbbTaggerLog') # First, retrieve the original JetRecTool - this is the one that made the # *ungroomed* jets, not the groomed ones. Ghost association is done to # ungroomed objects originalJetRecTool = getJetRecTool(collection, getParent=True) originalUngroomedName = originalJetRecTool.name() ungroomedJetAlg = originalUngroomedName if ungroomedJetAlg.endswith("Jets"): ungroomedJetAlg = ungroomedJetAlg[:-4] originalFinder = jtm[originalJetRecTool.JetFinder.getName()] originalGetters = [ jtm[g.getName()] for g in originalJetRecTool.PseudoJetGetters ] newGetters = [jtm[g] for g in getters.values()] # Next, prepare the names of the new objects we'll need from jtm comb_name = "_".join(getters.keys()) LargeRJetFindingAlg = "jfind_{0}_{1}".format(collection, comb_name).lower() LargeRJetPrefix = "{0}_{1}".format(collection, comb_name) LargeRJets = nameJetsFromAlg(LargeRJetPrefix) LinkTransferAlg = "LinkTransfer_{0}_{1}".format(collection, comb_name) # Check to see if this large R jet collection is already known to JetCommon if LargeRJetFindingAlg in JetCommon.DFJetAlgs: logger.info("Found {0} in DFJetAlgs".format(LargeRJetFindingAlg)) # Is it in our sequence? if hasattr(sequence, LargeRJetFindingAlg): logger.info( "Algorithm already exists in the input sequence. Will not " "add again") else: logger.info( "Adding algorithm into the sequence {0}".format(sequence)) sequence += JetCommon.DFJetAlgs[LargeRJetFindingAlg] else: # Check to see if the corresponding JetRecTool already exists if hasattr(jtm, LargeRJets): logger.info( "JetRecTool {0} already exists in jtm".format(LargeRJets)) else: logger.info("Create a new JetRecTool {0}".format(LargeRJets)) JetCommon.OutputJets.setdefault("CustomJets", []).append(LargeRJets) originalModifiers = [ jtm[m.getName()] for m in originalJetRecTool.JetModifiers ] jtm.addJetFinder( output=LargeRJets, alg=originalFinder.JetAlgorithm, radius=originalFinder.JetRadius, gettersin=originalGetters + newGetters, modifiersin=originalModifiers, ghostArea=0, ptmin=originalFinder.PtMin, variableRMinRadius=originalFinder.VariableRMinRadius, variableRMassScale=originalFinder.VariableRMassScale, calibOpt="none") # Note that we don't need ptminFilter as this was included in the original # list of JetModifiers logger.info( "Creating new jet algorithm {0} and adding it to sequence {1}". format(LargeRJetFindingAlg, sequence)) theJetAlg = JetAlgorithm(LargeRJetFindingAlg, Tools=[jtm[LargeRJets]]) sequence += theJetAlg JetCommon.DFJetAlgs[LargeRJetFindingAlg] = theJetAlg # Everything so far has been to create the links on a copy of the ungroomed # collection. Now we need to copy those links over to the original ungroomed # collection. from DerivationFrameworkJetEtMiss.ExtendedJetCommon import getJetExternalAssocTool, applyJetAugmentation assocTool = getJetExternalAssocTool( ungroomedJetAlg, LargeRJetPrefix, MomentPrefix='', ListOfOldLinkNames=[g.Label for g in newGetters]) applyJetAugmentation(ungroomedJetAlg, LinkTransferAlg, sequence, assocTool) return originalUngroomedName, [g.Label for g in newGetters]
jtm.modifiersMap["largevr_track_modifiers"] = [ jtm.ktsplitter, ] # Small VR lctopo jets # WARNING: Set ghostArea to 0 (should be 0.01) # this ssaves a lot of memory in Grid job # also requires commenting out jet calibration # Large VR lctopo jets jfind_largevr_lctopo = jtm.addJetFinder("AntiKtVR600Rmax10Rmin2LCTopoJets", "AntiKt", 1.0, "lctopo", "largevr_lctopo_modifiers", ghostArea=0, ptmin=50000, ptminFilter=50000, variableRMinRadius=0.2, variableRMassScale=600000, calibOpt="none") jfind_smallvr_lctopo = jtm.addJetFinder( "AntiKtVR60Rmax4Rmin2LCTopoJets", "AntiKt", 0.4, "lctopo", "smallvr_lctopo_modifiers", # ghostArea=0.01 , ptmin=7000, ptminFilter=7000, # ~45s for each ttbar MC event... ghostArea=0, ptmin=7000,
# Add tools to find or groom jets. # Each call to addJetFinder adds one JetRecTool so that one jet # container will be added to the event. # The first argument is the name of that container. # The next two are the jet algorithm (Kt, AntiKt, CamKt) and # size parameter. # The next two are the names of the input and modifier lists. # The following optional, named arguments may also be provided: # ghostArea: Size in eta-phi for area ghosts # ptmin: pT threshold in MeV applied in jet finding # ptminFilter: pT threshold applied by the jet modifier "jetfilter" # Making an extra set of jets fixes problems with invisible attributes. makeMyJets = True if makeMyJets: jtm.addJetFinder("MyAntiKt4LCTopoJets", "AntiKt", 0.4, "mygetters", "mymods", ghostArea=0.01 , ptmin=2000, ptminFilter=7000) # Copy and calibrate jets. jtm.addJetCopier("NewAntiKt4LCTopoJets", "AntiKt4LCTopoJets", "cpmods", ptminFilter=10000, alg="AntiKt", radius=0.4, inp ="LCTopo") #-------------------------------------------------------------- # Configure the jet algorithm. # The current configuration of the jet tool manager is used. #-------------------------------------------------------------- from JetRec.JetAlgorithm import jetalg #-------------------------------------------------------------- # Add tool to dump the new jet container to the log. #-------------------------------------------------------------- from JetRec.JetRecConf import JetDumper
"BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "Partons", ] if dfInputIsEVNT: # Standard truth jets # To recover jet constituents remove the last modifier. akt4 = jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", modifiersin=[ jtm.truthpartondr, jtm.partontruthlabel, jtm.removeconstit, jtm.jetdrlabeler, jtm.trackjetdrlabeler ], ptmin=5000) akt4alg = JetAlgorithm("jetalgAntiKt4TruthJets", Tools=[akt4]) DerivationFrameworkJob += akt4alg # WZ Truth Jets akt4wz = jtm.addJetFinder("AntiKt4TruthWZJets", "AntiKt", 0.4, "truthwz", ptmin=5000, modifiersin=[ jtm.truthpartondr, jtm.partontruthlabel,
## Turn on ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = [ "BHadronsInitial", "BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "Partons", ] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False ## truthpartondr => adds cone-based label ## partontruthlabel => adds ghost-based label ## removeconstit => empties container of jet constituents to reduce filesize from JetRec.JetRecStandard import jtm jtm.addJetFinder( "AntiKt6TruthJets", "AntiKt", 0.6, "truth", modifiersin=[jtm.truthpartondr, jtm.partontruthlabel, jtm.removeconstit], ptmin=7000.)
def reCreatePseudoJets(jetalg, rsize, inputtype): """Return a list of tools (possibly empty) to be run in a jetalg. These tools will make sure PseudoJets will be associated to the container specified by the input arguments. """ from JetRec.JetRecStandard import jtm from JetRec.JetRecUtils import buildJetContName jetContName = buildJetContName(jetalg, rsize, inputtype) # Set default for the arguments to be passd to addJetFinder finderArgs = dict( modifiersin=[], consumers=[], ghostArea=0.01, ptmin=40000, ) # We do things differently if the container already exists in the input from RecExConfig.ObjKeyStore import cfgKeyStore if cfgKeyStore.isInInputFile("xAOD::JetContainer", jetContName): # yes ! # make sure we don't already have what we need tmpName = "tmp_" + jetContName if tmpName in jtm.tools: return [] # return [jtm.tools[tmpName]] # then we'll have to build a temporary container to re-create the pseudojet # and we recopy this pseudojets to the original collection. This done through # this tool : from JetRec.JetRecConf import JetPseudojetCopier jtm += JetPseudojetCopier("PJcopierTo" + jetContName, DestinationContainer=jetContName, JetPseudojetRetriever=jtm.jpjretriever) # prepare args for this case : finderArgs['consumers'] = [jtm.tools["PJcopierTo" + jetContName]] finderArgs['ptmin'] = 20000 else: # no preexisting container # make sure we don't already have what we need tmpName = jetContName if tmpName in jtm.tools: return [] # return [jtm.tools[tmpName]] # no container exist. simply build a new one. if inputtype == "LCTopo": finderArgs['modifiersin'] = "calib" finderArgs['ptmin'] = 2000 finderArgs['ptminFilter'] = 50000 finderArgs['calibOpt'] = "none" finderArgs.pop('modifiersin') # leave the default modifiers. # map the input to the jtm code for PseudoJetGetter getterMap = dict(LCTopo='lctopo', Truth='truth', PV0Track='pv0track') # create the finder for the temporary collection. tmpFinderTool = jtm.addJetFinder( tmpName, jetalg, rsize, getterMap[inputtype], **finderArgs # pass the prepared arguments ) return [tmpFinderTool]
def addTruthJetsIfNotExising(truth_jets_name): ''' Add algorithm to create the truth jets collection unless the collection exists already, or a truth jet finder is already running ''' from RecExConfig.AutoConfiguration import IsInInputFile # the jet collection name does not exist in the input file # add a jet finder algorithm in front of the monitoring if the algorithm # does not yet exist. if not IsInInputFile('xAOD::JetContainer', truth_jets_name): try: from AthenaCommon.Logging import logging log = logging.getLogger('InDetPhysValMonitoring/addTruthJets.py') from PyUtils.MetaReaderPeeker import convert_itemList, metadata eventdata_itemsDic = convert_itemList(layout='dict') log.info( 'DEBUG addTruthJetsIfNotExising {} not in {} [file_type={}]'. format(truth_jets_name, eventdata_itemsDic, metadata['file_type'])) if truth_jets_name in eventdata_itemsDic: return except: pass # Access the algorithm sequence: from AthenaCommon.AlgSequence import AlgSequence, AthSequencer topSequence = AlgSequence() # extract the jet finder type and main parameter import re extract_alg = re.search('^([^0-9]+)([0-9]+)TruthJets', truth_jets_name) if extract_alg != None: alg_type = extract_alg.group(1) alg_param_str = extract_alg.group(2) else: alg_type = 'AntiKt' alg_param_str = 4 jet_finder_alg_name = "jetalg" + alg_type + alg_param_str + 'TruthJets' # add the jet finder unless it exists already in the alg sequence from InDetPhysValDecoration import findAlg, findMonMan alg_pos = findAlg([jet_finder_alg_name]) if alg_pos == None: from JetRec.JetRecStandard import jtm mon_man_index = findMonMan() # configure truth jet finding ? from JetRec.JetRecFlags import jetFlags jetFlags.useTruth = True jetFlags.useTracks = False jetFlags.truthFlavorTags = [ "BHadronsInitial", "BHadronsFinal", "BQuarksFinal", "CHadronsInitial", "CHadronsFinal", "CQuarksFinal", "TausFinal", "Partons", ] # tool to create truth jet finding inputs truth_part_copy_name = 'truthpartcopy' dir(jtm) create_truth_jet_input = None if not hasattr(jtm, truth_part_copy_name): from MCTruthClassifier.MCTruthClassifierConfig import firstSimCreatedBarcode from MCTruthClassifier.MCTruthClassifierConf import MCTruthClassifier truth_classifier_name = 'JetMCTruthClassifier' if not hasattr(jtm, truth_classifier_name): from AthenaCommon.AppMgr import ToolSvc if not hasattr(ToolSvc, truth_classifier_name): truthClassifier = MCTruthClassifier( name=truth_classifier_name, barcodeG4Shift=firstSimCreatedBarcode(), ParticleCaloExtensionTool="") else: truthClassifier = getattr(ToolSvc, truth_classifier_name) truthClassifier.barcodeG4Shift = firstSimCreatedBarcode( ) jtm += truthClassifier else: truthClassifier = getattr(jtm, truth_classifier_name) truthClassifier.barcodeG4Shift = firstSimCreatedBarcode() from ParticleJetTools.ParticleJetToolsConf import CopyTruthJetParticles create_truth_jet_input = CopyTruthJetParticles( truth_part_copy_name, OutputName="JetInputTruthParticles", MCTruthClassifier=truthClassifier) jtm += create_truth_jet_input else: create_truth_jet_input = getattr(jtm, truth_part_copy_name) jet_finder_tool = jtm.addJetFinder(truth_jets_name, alg_type, float(alg_param_str) / 10., "truth", ptmin=5000) jet_tools = [] from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles jet_tools += scheduleCopyTruthParticles() jet_tools += [create_truth_jet_input] jet_tools += jtm.jetrecs # add the jet finder in front of the monitoring from JetRec.JetRecConf import JetAlgorithm from JetRec.JetRecConf import JetToolRunner jtm += JetToolRunner( "jetrun", Tools=jet_tools, EventShapeTools=[], # OutputLevel = 1, Timer=jetFlags.timeJetToolRunner()) # jet_finder_alg = JetAlgorithm(jet_finder_alg_name, jet_tools) jet_finder_alg = JetAlgorithm(jet_finder_alg_name) # jet_finder_alg.OutputLevel = 1 jet_finder_alg.Tools = [jtm.jetrun] if mon_man_index != None: topSequence.insert(mon_man_index, jet_finder_alg) else: topSequence += jet_finder_alg
# Add tools to find or groom jets. # Each call to addJetFinder adds one JetRecTool so that one jet # container will be added to the event. # The first argument is the name of that container. # The next two are the jet algorithm (Kt, AntiKt, CamKt) and # size parameter. # The next two are the names of the input and modifier lists. # The following optional, named arguments may also be provided: # ghostArea: Size in eta-phi for area ghosts # ptmin: pT threshold in MeV applied in jet finding # ptminFilter: pT threshold applied by the jet modifier "jetfilter" jtm.addJetFinder("MyAntiKt4TruthJets", "AntiKt", 0.4, "truth", "truth", ghostArea=0.01, ptmin=2000, ptminFilter=3000) ############################################################################################ #Reconstruct PF jets with standard tools (PFlowPseudoJetGetter, etc) for comparison jtm.addJetFinder("MyAntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow_reduced", "pflow_ungroomed", ghostArea=0.01, ptmin=5000, ptminFilter=10000,
#Run PFlow jet finding from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow_reduced", "pflow_ungroomed", ghostArea=0.01, ptmin=5000, ptminFilter=10000, calibOpt="arj:pflow") from JetRec.JetAlgorithm import addJetRecoToAlgSequence addJetRecoToAlgSequence(eventShapeTools=["empflow"]) if not hasattr(topSequence, "LumiBlockMuWriter"): include("LumiBlockComps/LumiBlockMuWriter_jobOptions.py")
## Configure jet container for anti-kT R=1.0 truth jets evgenConfig.findJets = True ## Turn off ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = [] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt10TruthJets", "AntiKt", 1.0, "truth", modifiersin="none", ptmin=50000.)
## Configure jet container for anti-kT R=0.4 truth jets evgenConfig.findJets = True ## Turn off ghost association algorithms from JetRec.JetRecFlags import jetFlags jetFlags.truthFlavorTags = [] # Turning off tracks which are otherwise on by default # If you wish to use tracks, simply add the following two lines to you JOs BEFORE including this fragment, do not alter this fragment. # from JetRec.JetRecFlags import jetFlags # jetFlags.useTracks.set_Value_and_Lock(True) jetFlags.useTracks = False from JetRec.JetRecStandard import jtm jtm.addJetFinder("AntiKt4TruthJets", "AntiKt", 0.4, "truth", modifiersin="none", ptmin=7000.)
if 'FitterType' in dir(): InDetFlags.trackFitterType.set_Value_and_Lock(FitterType) if FitterType == "KalmanDNAFitter" or FitterType == "GaussianSumFilter": InDetFlags.materialInteractionsType.set_Value_and_Lock(1) if 'LowPt' in dir(): InDetFlags.doLowPt.set_Value_and_Lock(LowPt) # IMPORTANT NOTE: initialization of the flags and locking them is done in InDetRec_jobOptions.py! # This way RecExCommon just needs to import the properties without doing anything else! # DO NOT SET JOBPROPERTIES AFTER THIS LINE! The change will be ignored! # --- Truth jet creation from JetRec.JetRecStandard import jtm jtm.addJetFinder("Run2AntiKt4TruthJets", "AntiKt", 0.4, "truth", ghostArea=0.0) #-------------------------------------------------------------- # load master joboptions file #-------------------------------------------------------------- #from AthenaMonitoring.DQMonFlags import DQMonFlags #DQMonFlags.doTRTElectronMon.set_Value_and_Lock (False) #DQMonFlags.doLArMon.set_Value_and_Lock (False) include("RecExCommon/RecExCommon_topOptions.py") # Turn off TRT validity gate, which is not configured for 50ns RDOs ToolSvc.InDetTRT_DriftCircleTool.ValidityGateSuppression = False ToolSvc.InDetTRT_DriftCircleTool.SimpleOutOfTimePileupSupression = True
jtm.nsubjettiness, jtm.pull ] # Add tools to find or groom jets. # Each call to addJetFinder adds one JetRecTool so that one jet # container will be added to the event. # The first argument is the name of that container. # The next two are the jet algorithm (Kt, AntiKt, CamKt) and # size parameter. # The next two are the names of the input and modifier lists. # The following optional, named arguments may also be provided: # ghostArea: Size in eta-phi for area ghosts # ptmin: pT threshold in MeV applied in jet finding # ptminFilter: pT threshold applied by the jet modifier "jetfilter" jtm.addJetFinder("MyAntiKt4EMPFlowJets", "AntiKt", 0.4, "empflow", "mymods", ghostArea=0.01 , ptmin=2000, ptminFilter=7000) jtm.addJetFinder("MyAntiKt4EMCPFlowJets", "AntiKt", 0.4, "emcpflow", "mymods", ghostArea=0.01 , ptmin=2000, ptminFilter=7000) jtm.addJetFinder("MyAntiKt4LCPFlowJets", "AntiKt", 0.4, "lcpflow", "mymods", ghostArea=0.01 , ptmin=2000, ptminFilter=7000) #-------------------------------------------------------------- # Configure the jet algorithm. # The current configuration of the jet tool manager is used. #-------------------------------------------------------------- from JetRec.JetAlgorithm import jetalg #-------------------------------------------------------------- # Add tool to dump the new jet container to the log. #-------------------------------------------------------------- from JetRec.JetRecConf import JetDumper