def GetFlowMomentTools(key, mod_key): mtools = [] #only compute no flow moment if subtraction actually used flow if len(HIJetFlags.HarmonicsForSubtraction()) > 0: null_mod_tool = GetNullModulator() mtools += [ MakeSubtractionTool(key, moment_name='NoVn', momentOnly=True, modulator=null_mod_tool) ] if not HIJetFlags.ExtraFlowMoments(): return mtools #only add these tools if requested by package flag for n in [2]: #if flow subtraction only used one harmonic #then extra moment for that harmonic is redundant, skip it if len(HIJetFlags.HarmonicsForSubtraction()) == 1: if n == HIJetFlags.HarmonicsForSubtraction()[0]: continue mod_tool = MakeModulatorTool(mod_key, harmonics=[n]) subtr_tool = MakeSubtractionTool(key, moment_name='V%dOnly' % n, momentOnly=True, modulator=mod_tool) mtools += [subtr_tool] return mtools
def AppendOutputList(HIAODItemList=[]): """Adds HIJetOutputList to the list passed in as an argument""" if HIJetFlags.WriteClusters(): AddToOutputList(HIJetFlags.HIClusterKey(), "xAOD::CaloClusterContainer") from RecExConfig.RecFlags import rec if not rec.doESD(): for R in HIJetFlags.AntiKtRValues(): AddToOutputList("AntiKt%dHIJets" % int(10 * R)) if jetFlags.useTruth(): AddToOutputList("AntiKt%dTruthJets" % int(10 * R)) AddToOutputList(HIJetFlags.TrackJetContainerName()) HIAODItemList += HIJetFlags.HIJetOutputList()
def ApplySubtractionToClusters(**kwargs): if 'event_shape_key' in kwargs.keys(): event_shape_key = kwargs['event_shape_key'] else: from HIGlobal.HIGlobalFlags import jobproperties event_shape_key = jobproperties.HIGlobalFlags.EventShapeKey() if 'cluster_key' in kwargs.keys(): cluster_key = kwargs['cluster_key'] else: cluster_key = HIJetFlags.HIClusterKey() if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator'] else: mod_tool = GetNullModulator() from HIJetRec.HIJetRecConf import HIClusterSubtraction toolName = 'HIClusterSubtraction' if 'name' in kwargs.keys(): toolName = kwargs['name'] theAlg = HIClusterSubtraction(toolName) theAlg.ClusterKey = cluster_key theAlg.EventShapeKey = event_shape_key theAlg.Subtractor = GetSubtractorTool(**kwargs) theAlg.Modulator = mod_tool do_cluster_moments = False if 'CalculateMoments' in kwargs.keys(): do_cluster_moments = kwargs['CalculateMoments'] if do_cluster_moments: from CaloRec.CaloRecConf import CaloClusterMomentsMaker from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault theCaloNoiseTool = CaloNoiseToolDefault() from AthenaCommon.AppMgr import ToolSvc ToolSvc += theCaloNoiseTool HIClusterMoments = CaloClusterMomentsMaker("HIClusterMoments") #HIClusterMoments.MaxAxisAngle = 20*deg HIClusterMoments.CaloNoiseTool = theCaloNoiseTool HIClusterMoments.UsePileUpNoise = False HIClusterMoments.MinBadLArQuality = 4000 HIClusterMoments.MomentsNames = [ "CENTER_MAG", "LONGITUDINAL", "FIRST_ENG_DENS", "SECOND_ENG_DENS", "ENG_FRAC_EM", "ENG_FRAC_MAX", "ENG_FRAC_CORE", "ENG_BAD_CELLS", "N_BAD_CELLS", "N_BAD_CELLS_CORR", "BAD_CELLS_CORR_E", "BADLARQ_FRAC", "ENG_POS", "SIGNIFICANCE", "CELL_SIGNIFICANCE", "CELL_SIG_SAMPLING", "AVG_LAR_Q", "AVG_TILE_Q" ] from IOVDbSvc.CondDB import conddb if not conddb.isOnline: from LArRecUtils.LArHVScaleRetrieverDefault import LArHVScaleRetrieverDefault HIClusterMoments.LArHVScaleRetriever = LArHVScaleRetrieverDefault() HIClusterMoments.MomentsNames += [ "ENG_BAD_HV_CELLS", "N_BAD_HV_CELLS" ] theAlg.ClusterCorrectionTools = [HIClusterMoments] jtm.add(theAlg) jtm.jetrecs += [theAlg] jtm.HIJetRecs += [theAlg]
def AddToOutputList(tname, objType='xAOD::JetContainer'): #filter container based on package flags if HIJetFlags.UnsubtractedSuffix( ) in tname and not HIJetFlags.WriteUnsubtracted(): return if HIJetFlags.SeedSuffix() in tname and not HIJetFlags.WriteSeeds(): return has_key = False for k in HIJetFlags.HIJetOutputList(): if tname == k.split('#')[1]: has_key = True break if not has_key: aux_suffix = 'Aux.' if 'CaloCluster' in objType: HIJetFlags.HIJetOutputList += [ objType.replace("Container", "CellLinkContainer") + "#" + tname + "_links" ] if not HIJetFlags.WriteClusterMoments(): aux_suffix += '-' else: for k in HIJetFlags.MomentsSkipped(): if 'ScaleMomentum' in k: for var in ['pt', 'eta', 'phi', 'm']: aux_suffix += '-%s_%s.' % (k, var) else: aux_suffix += '-%s.' % k HIJetFlags.HIJetOutputList += [objType + "#" + tname] HIJetFlags.HIJetOutputList += [ objType.replace("Container", "AuxContainer") + "#" + tname + aux_suffix ]
def AddIteration(seed_container, shape_name, **kwargs): out_shape_name = shape_name if 'suffix' in kwargs.keys(): out_shape_name += '_%s' % kwargs['suffix'] mod_shape_key = out_shape_name + '_Modulate' remodulate = True if 'remodulate' in kwargs.keys(): if not kwargs['remodulate']: mod_tool = GetNullModulator() remodulate = False if remodulate: if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator'] else: #mod_shape_name=BuildHarmonicName(out_shape_name,**kwargs) mod_tool = MakeModulatorTool(mod_shape_key, **kwargs) if 'map_tool' in kwargs.keys(): map_tool = kwargs['map_tool'] else: from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool map_tool = HIEventShapeMapTool() assoc_name = jtm.HIJetDRAssociation.AssociationName HIEventShapeJetIteration = CompFactory.HIEventShapeJetIteration iter_tool = HIEventShapeJetIteration('HIJetIteration_%s' % out_shape_name) iter_tool.InputEventShapeKey = shape_name iter_tool.OutputEventShapeKey = out_shape_name iter_tool.AssociationKey = assoc_name iter_tool.CaloJetSeedContainerKey = seed_container iter_tool.Subtractor = GetSubtractorTool(**kwargs) iter_tool.ModulationScheme = HIJetFlags.ModulationScheme() iter_tool.RemodulateUE = HIJetFlags.Remodulate() iter_tool.Modulator = mod_tool iter_tool.ShallowCopy = False iter_tool.ModulationEventShapeKey = mod_shape_key iter_tool.EventShapeMapTool = map_tool if 'track_jet_seeds' in kwargs.keys(): iter_tool.TrackJetSeedContainerKey = kwargs['track_jet_seeds'] jtm.add(iter_tool) jtm.jetrecs += [iter_tool] jtm.HIJetRecs += [iter_tool] return iter_tool
def GetConstituentsModifierTool(**kwargs): #For the cluster key, same exact logic as used for ApplySubtractionToClusters if 'cluster_key' in kwargs.keys(): cluster_key = kwargs['cluster_key'] else: cluster_key = HIJetFlags.HIClusterKey() if 'apply_origin_correction' in kwargs.keys(): apply_origin_correction = kwargs['apply_origin_correction'] else: apply_origin_correction = HIJetFlags.ApplyOriginCorrection() HIJetConstituentModifierTool = CompFactory.HIJetConstituentModifierTool toolName = 'HIJetConstituentModifierTool' if 'name' in kwargs.keys(): toolName = kwargs['name'] cmod = HIJetConstituentModifierTool(toolName) cmod.ClusterKey = cluster_key cmod.Subtractor = GetSubtractorTool(**kwargs) cmod.ApplyOriginCorrection = apply_origin_correction jtm.add(cmod) return cmod
def HIClusterGetter(tower_key="CombinedTower", cell_key="AllCalo", cluster_key=""): """Function to equip HI cluster builder from towers and cells, adds to output AOD stream""" if cluster_key == "": cluster_key = HIJetFlags.HIClusterKey() HIClusterMaker = CompFactory.HIClusterMaker theAlg = HIClusterMaker() theAlg.InputTowerKey = tower_key theAlg.CaloCellContainerKey = cell_key theAlg.OutputContainerKey = cluster_key from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() topSequence += theAlg if HIJetFlags.WriteClusters(): AddToOutputList(HIJetFlags.HIClusterKey(), "xAOD::CaloClusterContainer") return theAlg
def GetSubtractorTool(**kwargs): useClusters = False if 'useClusters' in kwargs.keys(): useClusters = kwargs['useClusters'] elif HIJetFlags.DoCellBasedSubtraction(): useClusters = False else: useClusters = True if useClusters: if not hasattr(jtm, "HIJetClusterSubtractor"): HIJetClusterSubtractorTool = CompFactory.HIJetClusterSubtractorTool jtm.add(HIJetClusterSubtractorTool("HIJetClusterSubtractor")) return jtm.HIJetClusterSubtractor else: if not hasattr(jtm, "HIJetCellSubtractor"): HIJetCellSubtractorTool = CompFactory.HIJetCellSubtractorTool jtm.add(HIJetCellSubtractorTool("HIJetCellSubtractor")) return jtm.HIJetCellSubtractor
def MakeSubtractionTool(shapeKey, moment_name='', momentOnly=False, **kwargs): from HIJetRec.HIJetRecConf import HIJetConstituentSubtractionTool suffix = shapeKey if momentOnly: suffix += '_' + moment_name if 'modulator' in kwargs.keys(): mod_tool = kwargs['modulator'] else: mod_tool = GetNullModulator() subtr = HIJetConstituentSubtractionTool("HICS_" + suffix) subtr.EventShapeKey = shapeKey subtr.Modulator = mod_tool subtr.MomentName = 'JetSubtractedScale%sMomentum' % moment_name subtr.SetMomentOnly = momentOnly subtr.ApplyOriginCorrection = HIJetFlags.ApplyOriginCorrection() subtr.Subtractor = GetSubtractorTool(**kwargs) jtm.add(subtr) return subtr
def AddHIJetFinder(R=0.4): unsubtr_suffix = HIJetFlags.UnsubtractedSuffix() cname = "AntiKt%dHIJets_%s" % (int(10 * R), unsubtr_suffix) #'HI' is not allowed 'Label' #Name parsing for JetPtAssociationTool in JetToolSupport.buildModifiers will break #when building PtAssociations, build and add them manually myMods = jtm.modifiersMap["HI_Unsubtr"] #myMods += AddPtAssociationTools(R) finder = jtm.addJetFinder(cname, "AntiKt", R, "HI", myMods, consumers=None, ivtxin=None, ghostArea=0.0, ptmin=0., ptminFilter=5000) jtm.HIJetRecs += [finder]
def MakeModulatorTool(mod_key, **kwargs): harmonics = [] if 'harmonics' in kwargs.keys(): harmonics = kwargs['harmonics'] else: harmonics = HIJetFlags.HarmonicsForSubtraction() tname = "Modulator_%s" % BuildHarmonicName(mod_key, harmonics=harmonics) if 'suffix' in kwargs.keys(): tname += '_%s' % kwargs['suffix'] if (len(harmonics) == 0): return GetNullModulator() if hasattr(jtm, tname): return getattr(jtm, tname) HIUEModulatorTool = CompFactory.HIUEModulatorTool mod = HIUEModulatorTool(tname) mod.EventShapeKey = mod_key for n in [2, 3, 4]: val = (n in harmonics) attr_name = 'DoV%d' % n setattr(mod, attr_name, val) jtm.add(mod) return mod
def configure(self): from CaloRec.CaloRecConf import CaloCellMaker cellMaker = CaloCellMaker("HICaloCellCopier", CaloCellsOutputName="SubtractedCells", OwnPolicy=0) from CaloRec.CaloRecConf import CaloCellFastCopyTool cellCopyTool = CaloCellFastCopyTool("HICellCopyTool") cellCopyTool.InputName = "AllCalo" cellCopyTool.IncludeSamplings = [ "PreSamplerB", "EMB1", "EMB2", "EMB3", "PreSamplerE", "EME1", "EME2", "EME3", "HEC0", "HEC1", "HEC2", "HEC3", "TileBar0", "TileBar1", "TileBar2", "TileGap1", "TileGap2", "TileGap3", "TileExt0", "TileExt1", "TileExt2", "FCal1", "FCal2", "FCal3" ] from AthenaCommon.AppMgr import ToolSvc ToolSvc += cellCopyTool from HIJetRec.HIJetRecConf import HISubtractedCellMakerTool cellSubtrTool = HISubtractedCellMakerTool() from HIJetRec.HIJetRecFlags import HIJetFlags cellSubtrTool.EventShapeKey = HIJetFlags.IteratedEventShapeKey() from HIJetRec.HIJetRecTools import jtm cellSubtrTool.Modulator = jtm.modulator ToolSvc += cellSubtrTool from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool cellFinalizerTool = CaloCellContainerFinalizerTool( "HICaloCellFinalizerTool") ToolSvc += cellFinalizerTool cellMaker.CaloCellMakerToolNames = [ cellCopyTool, cellSubtrTool, cellFinalizerTool ] from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() topSequence += cellMaker return True
def AddPtAssociationTools(R, doTracks=True): tlist = [] if doTracks and jetFlags.useTracks(): cname = HIJetFlags.TrackJetContainerName() tname = 'hitrackassoc_04' if tname not in jtm.tools: JetPtAssociationTool = CompFactory.JetPtAssociationTool jtm.add( JetPtAssociationTool(tname, InputContainer=cname, AssociationName="GhostTrack")) tlist += [jtm.tools[tname]] if jetFlags.useTruth(): cname = 'AntiKt%dTruthJets' % int(10 * R) tname = 'truthassoc_0%d' % int(10 * R) if tname not in jtm.tools: JetPtAssociationTool = CompFactory.JetPtAssociationTool jtm.add( JetPtAssociationTool(tname, InputContainer=cname, AssociationName="GhostTruth")) tlist += [jtm.tools[tname]] return tlist
def JetAlgFromTools(rtools, suffix="HI", persistify=True): #insert exe tools at front of list, e.g. tracksel and tvassoc for HI etc. HIJet_exe_tools = [] from JetRec.JetRecFlags import jetFlags if jetFlags.useTruth() and not jetFlags.Enabled(): HIJet_exe_tools += HITruthParticleCopy() #if jetFlags.useCells(): HIJet_exe_tools += [jtm.missingcells] if HIJetFlags.UseHITracks(): HIJet_exe_tools += [jtm.tracksel_HI, jtm.gtracksel_HI, jtm.tvassoc_HI] rtools = HIJet_exe_tools + rtools from JetRec.JetRecConf import JetToolRunner runner = JetToolRunner("jetrun" + suffix, Tools=rtools, Timer=jetFlags.timeJetToolRunner()) jtm.add(runner) from JetRec.JetRecConf import JetAlgorithm theAlg = JetAlgorithm("jetalg" + suffix) theAlg.Tools = [runner] from AthenaCommon.AlgSequence import AlgSequence topsequence = AlgSequence() topsequence += theAlg from GaudiKernel.Constants import DEBUG if jetFlags.debug > 0: jtm.setOutputLevel(runner, DEBUG) theAlg.OutputLevel = DEBUG if jetFlags.debug > 3: jtm.setOutputLevel(jtm.jetBuilderWithoutArea, DEBUG) if persistify: for t in rtools: if hasattr(t, "OutputContainer"): AddToOutputList(t.OutputContainer) return theAlg
from HIJetRec.HIJetRecUtils import * theSubtrTool=jtm.HIJetClusterSubtractor theSubtrTool.unlock() theSubtrTool.UseSamplings=False theSubtrTool.lock() if is_mc_or_overlay : for theCalibTool in jtm.HICalibMap.values() : theCalibTool.unlock() theCalibTool.IsData=False theCalibTool.CalibSequence='EtaJES' theCalibTool.lock() #use existing R=0.2 jets from previous reco, only making use of discriminant seed_prefix='AntiKt%dHIJets' % int(10*HIJetFlags.SeedRValue()) seeds0=jtm.addJetCopier("%s_%s0" % (seed_prefix, HIJetFlags.SeedSuffix()),seed_prefix,[jtm.discrim],shallow=False) jtm.HIJetRecs+=[seeds0] iter0=AddIteration(seed_container=seeds0.OutputContainer,shape_name=EventShapeKey,suffix="iter0") modulator0=iter0.Modulator subtr1=MakeSubtractionTool(iter0.OutputEventShapeKey,modulator=modulator0) #now iterate seeds1=jtm.addJetCopier("%s_%s1" % (seed_prefix,HIJetFlags.SeedSuffix()),seed_prefix,[subtr1,jtm.HICalibMap[seed_prefix],jtm.jetfilHISeeds],shallow=False) jtm.HIJetRecs+=[seeds1] iteration_dict=dict(suffix="iter1") if jetFlags.useTracks() and HIJetFlags.TrackJetSeeds() : iteration_dict['track_jet_seeds']=HIJetFlags.TrackJetContainerName() iter1=AddIteration(seed_container=seeds1.OutputContainer,shape_name=EventShapeKey,**iteration_dict) HIJetFlags.IteratedEventShapeKey=iter1.OutputEventShapeKey modulator1=iter1.Modulator
def _getHIJetBuildTool(merge_param, ptmin=20000., ptminFilter=20000., jet_calib='jes', cluster_calib='EM', hicluster_name='HICluster', 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" 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) #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_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4TopoEM",ConfigFile="JES_Full2012dataset_Preliminary_Jan13.config",CalibSequence="AbsoluteEtaJES") #calib_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4EMTopo",ConfigFile="JES_Full2012dataset_May2014.config",CalibSequence="JetArea_Residual_Origin_EtaJES_GSC",IsData=False) #calib_tool=JetCalibrationTool("HLT_a"+str(int_merge_param)+"HICalibTool",JetCollection="AntiKt4EMTopo",ConfigFile="JES_MC15Prerecommendation_April2015.config",CalibSequence="EtaJES", IsData=False) calib_tool = JetCalibrationTool( "HLT_a" + str(int_merge_param) + "HICalibTool", JetCollection="AntiKt4EMTopo", ConfigFile="JES_Full2012dataset_Preliminary_Jan13.config", CalibSequence="AbsoluteEtaJES", IsData=False) 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=[_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 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.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 from HIEventUtils.HIEventUtilsConf import HIEventShapeMapTool iter0.EventShapeMapTool = HIEventShapeMapTool() jtm.add(iter0) jtm.jetrecs += [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, jetfil8], 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.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.jetrecs += [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=[_getTriggerPseudoJetGetter(cluster_calib)], modifiersin=[subtr2, calib_tool], 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
from HIJetRec.HIJetRecFlags import HIJetFlags from HIGlobal.HIGlobalFlags import jobproperties from JetRec.JetRecFlags import jetFlags jetFlags.useCells.set_Value(True) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from CaloRec.CaloTowerCmbGetter import CaloTowerCmbGetter CaloTowerCmbGetter() #check for event shape #if hasattr(topSequence,"HIEventShapeAlgorithm") EventShapeKey = jobproperties.HIGlobalFlags.EventShapeKey() ClusterKey = HIJetFlags.HIClusterKey() #import utility functions from HIJetRec.HIJetRecUtils import * HIClusterGetter() #equip basic tools from HIJetRec.HIJetRecTools import jtm ### ##truth jets if jetFlags.useTruth(): for R in HIJetFlags.AntiKtRValues(): tname = "AntiKt%dTruthJets" % int(10 * R) collExists = False if tname in jtm.tools: continue if rec.readESD():
from HIJetRec.HIJetRecFlags import HIJetFlags from HIGlobal.HIGlobalFlags import jobproperties from JetRec.JetRecFlags import jetFlags from HIJetRec.HIJetRecConfig import * jetFlags.useCells.set_Value(True) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from CaloRec.CaloTowerCmbGetter import CaloTowerCmbGetter CaloTowerCmbGetter() #check for event shape #if hasattr(topSequence,"HIEventShapeAlgorithm") EventShapeKey = jobproperties.HIGlobalFlags.EventShapeKey() ClusterKey = HIJetFlags.HIClusterKey() #import utility functions from HIJetRec.HIJetRecUtils import * HIClusterGetter() #equip basic tools from HIJetRec.HIJetRecTools import jtm #------------------------------ #set flags, keys and configure new event shape algorithm #>check if is MC or overlay and configure calibration tool properly from JetRec.JetRecFlags import jetFlags is_mc_or_overlay = False is_pp_mc = False if not jetFlags.useTruth():
def JetAlgFromTools(rtools, suffix="HI", persistify=True): from HIJetRec.HIJetRecTools import jtm #insert exe tools at front of list, e.g. tracksel and tvassoc for HI etc. HIJet_exe_tools = [] from JetRec.JetRecFlags import jetFlags if jetFlags.useTruth() and not jetFlags.Enabled(): HIJet_exe_tools += HITruthParticleCopy() #if jetFlags.useCells(): HIJet_exe_tools += [jtm.missingcells] if HIJetFlags.UseHITracks(): HIJet_exe_tools += [jtm.tracksel_HI, jtm.gtracksel_HI, jtm.tvassoc_HI] #Now we split in two algorithms to provide input to PseudoJetAlgorithm #rtools=HIJet_exe_tools+rtools from AthenaCommon.AlgSequence import AlgSequence topsequence = AlgSequence() JetToolRunner = CompFactory.JetToolRunner JetAlgorithm = CompFactory.JetAlgorithm if len(HIJet_exe_tools) > 0: jtm += JetToolRunner("jetrunconstit" + suffix, Tools=HIJet_exe_tools, Timer=jetFlags.timeJetToolRunner()) topsequence += JetAlgorithm("jetalgconstit" + suffix, Tools=[jtm.jetrunconstitHI]) # Add the PseudoJetAlgorithm # To avoid massive refactoring and to preserve familiarity, # jet guys kept calling things "getters", but these are already # PseudoJetAlgorithms as they eliminated the wrappers for getter in jtm.allGetters: print('Adding PseudoJetAlgorithm %s' % getter.name) print('Input Container %s' % getter.InputContainer) print('Output Container %s' % getter.OutputContainer) print('Label %s' % getter.Label) topsequence += getter runner = JetToolRunner("jetrun" + suffix, Tools=rtools, Timer=jetFlags.timeJetToolRunner()) jtm.add(runner) theAlg = JetAlgorithm("jetalg" + suffix) theAlg.Tools = [runner] topsequence += theAlg from GaudiKernel.Constants import DEBUG if jetFlags.debug > 0: jtm.setOutputLevel(runner, DEBUG) theAlg.OutputLevel = DEBUG if jetFlags.debug > 3: jtm.setOutputLevel(jtm.jetBuilderWithoutArea, DEBUG) if persistify: for t in rtools: if hasattr(t, "OutputContainer"): AddToOutputList(t.OutputContainer) return theAlg
from JetRec.JetRecStandard import jtm import AthenaCommon.SystemOfUnits as Units #configuring getter tools #selection for track jets from InDetTrackSelectionTool.InDetTrackSelectionToolConf import InDet__InDetTrackSelectionTool from JetRecTools.JetRecToolsConf import TrackPseudoJetGetter from JetRecTools.JetRecToolsConf import JetTrackSelectionTool from JetRecTools.JetRecToolsConf import SimpleJetTrackSelectionTool from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool from JetMomentTools.JetMomentToolsConf import JetCaloQualityTool from JetMomentTools.JetMomentToolsConf import JetCaloCellQualityTool #select the tracks if jetFlags.Enabled() : HIJetFlags.UseHITracks.set_Value_and_Lock(False) if HIJetFlags.UseHITracks() : jtm += InDet__InDetTrackSelectionTool("trk_tracksel_HI", minPt = HIJetFlags.TrackInputPtMin(), maxAbsEta = 2.5, minNSiHits = 7, maxNSiSharedModules = 100, maxNSiHoles = 2, maxNPixelHoles = 1) #select the tracks for jet finding jtm += JetTrackSelectionTool( "tracksel_HI", InputContainer = jtm.trackContainer, OutputContainer = "JetSelectedTracks_HI", Selector = jtm.trk_tracksel_HI) #vertex association tool
from HIJetRec.HIJetRecUtils import * theSubtrTool = jtm.HIJetClusterSubtractor theSubtrTool.unlock() theSubtrTool.UseSamplings = False theSubtrTool.lock() if is_mc_or_overlay: for theCalibTool in jtm.HICalibMap.values(): theCalibTool.unlock() theCalibTool.IsData = False theCalibTool.CalibSequence = 'EtaJES' theCalibTool.lock() #use existing R=0.2 jets from previous reco, only making use of discriminant seed_prefix = 'AntiKt%dHIJets' % int(10 * HIJetFlags.SeedRValue()) seeds0 = jtm.addJetCopier("%s_%s0" % (seed_prefix, HIJetFlags.SeedSuffix()), seed_prefix, [jtm.discrim], shallow=False) jtm.HIJetRecs += [seeds0] iter0 = AddIteration(seed_container=seeds0.OutputContainer, shape_name=EventShapeKey, suffix="iter0") modulator0 = iter0.Modulator subtr1 = MakeSubtractionTool(iter0.OutputEventShapeKey, modulator=modulator0) #now iterate seeds1 = jtm.addJetCopier( "%s_%s1" % (seed_prefix, HIJetFlags.SeedSuffix()), seed_prefix, [subtr1, jtm.HICalibMap[seed_prefix], jtm.jetfilHISeeds], shallow=False)