5 """ ComponentAccumulator equivalents for the functions in JetRecoSequences """
7 from .JetRecoCommon
import (
9 cloneAndUpdateJetRecoDict,
12 defineReclusteredJets,
21 getJetCalibDefaultString,
25 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
26 from AthenaConfiguration.ComponentFactory
import CompFactory
27 from AthenaCommon.CFElements
import parOR
28 from ..CommonSequences.FullScanDefs
import fs_cells
29 from ..Bjet.BjetFlavourTaggingConfig
import fastFlavourTaggingCfg
30 from .JetTrackingConfig
import JetRoITrackingCfg
31 from .JetHIConfig
import HeavyIonJetRecoDataDeps
33 from JetRecConfig
import JetRecConfig
34 from JetRecConfig
import JetInputConfig
35 from JetRecConfig.DependencyHelper
import solveDependencies, solveGroomingDependencies
37 from JetRecTools
import OnlineMon
38 from JetRec
import JetOnlineMon
40 from EventShapeTools.EventDensityConfig
import getEventShapeName
42 from AthenaConfiguration.AccumulatorCache
import AccumulatorCache
44 from typing
import Final
47 JET_DEFAULT_VIEW_PT_MIN_GEV : Final[int] = 10
50 return f
"{jetsIn}_pt{int(jetPtMinGeV)}"
60 if jetRecoDict[
'ionopt']==
'ion':
68 jetDefDict[
'final'] = jetDefDict[
'reclustered']
69 elif extra
in [
"t",
"sd"]:
73 jetDefDict[
'final'] = jetDefDict[
'groomed']
78 jetDefDict[
'final'] = jetDefDict[
'calib']
82 assert jetRecoDict[
'jetDefStr'] == gen_jetDefStr, (
83 f
"Expected jetDefStr {jetRecoDict['jetDefStr']} from reco dict, generated {gen_jetDefStr}"
90 """Jet clustering step -- generally only called through StandardJetRecoDataDeps"""
92 trkopt = jetRecoDict[
'trkopt']
100 pfoPrefix=f
"HLT_{trkopt}",
105 jetDef.inputdef.prereqs = [f
'extinput:{clustersKey}']
110 clustersKey=clustersKey,
117 "ConstitFourMom_copy",
119 if jetRecoDict[
"recoAlg"] ==
"a4":
120 jetDef.modifiers += [
"CaloEnergies"]
122 jetDef.modifiers += [
"CaloEnergiesClus"]
124 jetDef.modifiers += [
"TrackMoments",
"JVF",
"JVT"]
126 pj_name = JetRecConfig.getPJContName(jetDef.inputdef)
128 pj_name = f
"{pj_name}MergedWithGhostTracks"
129 jetDef._internalAtt[
"finalPJContainer"] = pj_name
131 jetsOut = jetDef.fullname()
135 return {
'build': (jetsOut, jetDef)}
139 """Jet clustering + calibration (via shallow copy)"""
140 if jetRecoDict[
"jetCalib"] ==
"nojcalib":
145 jetsNoCalib, jetDef = jetDefDict[
'build']
149 jetDefDict.update({
'nojcalib': (jetsNoCalibFiltered, jetDef),
'calib': (jetsNoCalibFiltered, jetDef)})
160 jetsNoCalib, jetDefNoCalib = jetDefDict[
'build']
163 jetDef = jetDefNoCalib.clone()
164 jetDef.suffix = jetDefNoCalib.suffix.replace(
"nojcalib", jetRecoDict[
"jetCalib"])
166 if "sub" in jetRecoDict[
"jetCalib"]:
173 is_pflow =
isPFlow(jetRecoDict)
175 jetDef.modifiers =
getCalibMods(flags, jetRecoDict, rhoKey)
177 jetDef.modifiers += [
"JVT"]
179 if jetRecoDict[
"recoAlg"] ==
"a4":
180 jetDef.modifiers += [
"CaloQuality"]
182 if not is_pflow
and jetRecoDict[
"recoAlg"] ==
"a4":
183 from TriggerMenuMT.HLT.Jet.JetRecoCommon
import cleaningDict
184 jetDef.modifiers += [f
'Cleaning:{clean_wp}' for _,clean_wp
in cleaningDict.items()]
189 jetDefDict.update({
'nojcalib':(jetsViewNoCalib, jetDefNoCalib),
'calib':(jetsOut, jetDef)})
200 flags, **basicJetRecoDict
202 basicJetsName, basicJetDef = jetDefDict[
'calib']
206 rc_suffix = f
"_{jetRecoDict['jetCalib']}" + (f
"_{jetRecoDict['trkopt']}" if doTracking(jetRecoDict)
else "")
211 basicJetDef.inputdef.label,
216 rcConstitPJKey = JetRecConfig.getPJContName(rcJetDef.inputdef, suffix=jetRecoDict[
'jetDefStr'])
217 rcJetDef._internalAtt[
"finalPJContainer"] = rcConstitPJKey
220 rcJetsOut = rcJetDef.fullname()
221 jetDefDict[
'reclustered'] = (rcJetsOut, rcJetDef)
229 recoAlg=jetRecoDict[
"recoAlg"].rstrip(
"tsd"),
231 jetCalib =
"nojcalib",
235 ungroomedJetsName, ungroomedDef = jetDefDict[
'build']
238 groomedJetsName = groomDef.fullname()
240 groomDef.modifiers += [
247 return {
'ungroomed':(ungroomedJetsName, ungroomedDef),
'groomed':(groomedJetsName, groomDef)}
255 """The top-level sequence
257 Forwards arguments to the standard jet reco, grooming or reclustering sequences.
260 if 'reclustered' in jetDefDict:
264 elif 'groomed' in jetDefDict:
281 filteredJetsName = f
"{jetDef.fullname()}_pt{int(jetPtMinGeV)}"
284 CompFactory.JetViewAlg(
285 "jetview_"+filteredJetsName,
286 InputContainer=jetDef.fullname(),
287 OutputContainer=filteredJetsName,
288 PtMin=jetPtMinGeV*1e3,
298 """ Standard jet reconstruction, no reclustering or grooming
300 The clusters (and tracks, if necessary) should be built beforehand,
301 but this config will build the PFOs if they are needed.
303 The reconstruction is configured from the input JetDefinition
307 trackColls = jetDef._contextDic
309 seqname =
"JetBuildSeq_"+jetDefStr
311 acc.addSequence(
parOR(seqname),primary=
True)
314 if 'PFlow' in jetDef.inputdef.label:
315 from eflowRec.PFHLTConfig
import PFCfg
317 clustersKey = jetDef.inputdef.prereqs[0].
split(
':')[1]
322 clustersin=clustersKey,
324 tracksin=trackColls[
"Tracks"],
325 verticesin=trackColls[
"Vertices"],
331 alg = JetRecConfig.getConstitModAlg(
332 jetDef, jetDef.inputdef,
337 acc.addEventAlgo(alg,seqname)
339 pj_alg = JetRecConfig.getConstitPJGAlg(jetDef.inputdef)
340 acc.addEventAlgo(pj_alg,seqname)
342 if jetDef.context==
'ftf':
343 pj_name = pj_alg.OutputContainer.Path
345 merge_alg = CompFactory.PseudoJetMerger(
346 f
"PJMerger_{pj_name}MergedWithGhostTracks",
347 InputPJContainers=[pj_name, trackColls[
"GhostTracks"]],
348 OutputContainer=f
"{pj_name}MergedWithGhostTracks",
351 acc.addEventAlgo(merge_alg,seqname)
354 JetRecConfig.getJetRecAlg(
364 """ Full reconstruction for 'simple' (ungroomed, not reclustered) jets
366 First the uncalibrated jets are built, then (if necessary) the calibrated jets are provided
370 jetsOut, jetDef = jetDefDict[
'calib']
372 seqname =
"JetRecSeq_"+jetDefStr
375 if jetDef.suffix[1:] ==
"nojcalib":
378 reco_acc.addSequence(
parOR(seqname))
380 buildJets, buildJetDef = jetDefDict[
'build']
384 reco_acc.merge(build_acc, seqname)
391 jetPtMinGeV=JET_DEFAULT_VIEW_PT_MIN_GEV,
393 reco_acc.merge(jetViewAcc, seqname)
398 acc.addSequence(
parOR(seqname))
400 buildJets, buildJetDef = jetDefDict[
'build']
404 acc.merge(build_acc,seqname)
406 jetsNoCalib, jetDefNoCalib = jetDefDict[
'nojcalib']
410 jetPtMinGeV=JET_DEFAULT_VIEW_PT_MIN_GEV,
412 acc.merge(jetViewAcc, seqname)
417 if "sub" in jetCalib:
420 eventShapeAlg = JetInputConfig.buildEventShapeAlg(jetDef,
getHLTPrefix(),voronoiRf = 1.0 )
421 acc.addEventAlgo(eventShapeAlg,seqname)
428 JetRecConfig.getJetCopyAlg(
429 jetsin=jetDefNoCalib.fullname(),
431 decorations=decorList,
433 f
"HLTJets/{jetDef.fullname()}/"
440 recoAlg, constitType, _ = jetDefStr.split(
'_',2)
443 flags.Trigger.Jet.fastbtagPFlow
444 and jetDef.basename==
"AntiKt4EMPFlow"
445 and jetCalib==jetCalibDef
448 ftagseqname = f
"jetFtagSeq_{jetDef.context}"
449 acc.addSequence(
parOR(ftagseqname),seqname)
451 trackingColls = jetDef._contextDic
458 trackingColls[
"Vertices"],
459 trackingColls[
"Tracks"],
470 jetPtMinGeV=JET_DEFAULT_VIEW_PT_MIN_GEV,
472 acc.merge(jetViewAcc,seqname)
478 """ Create the groomed jets
480 First the ungroomed jets are created (using the standard configuration), then the grooming
486 ungroomedJetsName, ungroomedDef = jetDefDict[
'ungroomed']
487 groomedJets, groomDef = jetDefDict[
'groomed']
490 seqname =
"JetGroomSeq_"+jetDefStr
492 acc.addSequence(
parOR(seqname),primary=
True)
498 acc.merge(build_acc,seqname)
500 acc.addEventAlgo( JetRecConfig.getJetRecGroomAlg(
507 recoAlg, constitType, _ = jetDefStr.split(
'_',2)
511 groomDef.basename.startswith(
"AntiKt10EMPFlowCSSKSoftDrop")
512 and jetCalib==jetCalibDef
514 trackingColls = groomDef._contextDic
516 ftagseqname = f
"jetFtagSeq_{groomDef.context}_largeR"
517 acc.addSequence(
parOR(ftagseqname), seqname)
523 trackingColls[
'Vertices'],
524 trackingColls[
'Tracks'],
526 doXbbtagLargeRJet =
True,
534 """ Create the reclustered jets
536 First the input jets are built, then the reclustering algorithm is run
539 basicJetsFiltered, basicJetDef = jetDefDict[
'calib']
540 rcJets, rcJetDef = jetDefDict[
'reclustered']
543 seqname =
"JetReclusterSeq_"+jetDefStr
545 acc.addSequence(
parOR(seqname),primary=
True)
550 acc.merge(basic_acc,seqname)
556 jetPtMinGeV=rcJetPtMin,
558 acc.merge(jetViewAcc,seqname)
560 rcConstitPJAlg = JetRecConfig.getConstitPJGAlg(rcJetDef.inputdef, suffix=jetDefStr)
561 acc.addEventAlgo(rcConstitPJAlg,seqname)
564 JetRecConfig.getJetRecAlg(
567 f
"HLTJets/{rcJetDef.fullname()}/"
580 jetsIn = jetDef.fullname()
582 ftagJetDef = jetDef.clone(suffix=jetDef.suffix+
'_fastftag',modifiers=[],lock=
True)
584 acc.addEventAlgo(JetRecConfig.getJetCopyAlg(jetsin=jetsIn,jetsoutdef=ftagJetDef,decorations=decorList))
585 return acc, ftagJetDef