3 """Configuration sequences for the MET input reconstruction
5 By convention all of these functions return two values: first a defaultdict mapping from
6 reco step to the component accumulators containing the reconstruction sequences and
7 second the name(s) of the key outputs created. The names can either be a single string
8 if there is only one output or a tuple otherwise. Which outputs are returned and their
9 order should be clearly documented in the method documentation
12 from typing
import Any
14 from AthenaConfiguration.AccumulatorCache
import AccumulatorCache
15 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
16 from AthenaConfiguration.ComponentFactory
import CompFactory
17 from eflowRec.PFHLTConfig
import PFCfg
18 from JetRecConfig.JetRecConfig
import getConstitModAlg_nojetdef
19 from TrigCaloRec.TrigCaloRecConfig
import (
21 jetmetTopoClusteringCfg,
22 jetmetTopoClusteringCfg_LC,
24 from ..CommonSequences.FullScanDefs
import em_clusters, lc_clusters, trkFSRoI
25 from ..Jet.JetRecoCommon
import (
28 from ..Jet.JetRecoSequencesConfig
import JetRecoDataDeps, JetRecoCfg
29 from ..Jet.JetTrackingConfig
import JetFSTrackingCfg
30 from .StepOutput
import StepOutput
31 from TrackVertexAssociationTool.TrackVertexAssociationToolConfig
import CVF_TTVAToolCfg
35 """Get a jet reco dict that's usable for the MET slice"""
36 from ..Jet.JetRecoCommon
import getJetCalibDefaultString, jetRecoDictToString
37 from ..Jet.JetRecoCommon
import recoKeys
as jetRecoKeys
38 from ..Menu.SignatureDicts
import JetChainParts_Default
40 jrd = {k: recoDict.get(k, JetChainParts_Default[k])
for k
in jetRecoKeys}
43 jrd[
"clusterCalib"] = recoDict[
"calib"]
47 jrd[
"constitMod"] = recoDict.get(
"constitmod",
"")
49 if jrd[
"constitType"] ==
"pf":
50 jrd[
"clusterCalib"] =
"em"
52 if jrd[
"jetCalib"] ==
"default":
54 if jrd[
"constitType"] !=
"tc" or "gsc" in jrd[
"jetCalib"]:
62 """Create the cell inputs"""
64 return StepOutput.create(acc, Cells=acc.getPrimary().CellsName)
69 """Create the cluster inputs"""
70 if recoDict[
"calib"] ==
"em":
72 clusters = em_clusters
73 elif recoDict[
"calib"] ==
"lcw":
75 clusters = lc_clusters
77 raise ValueError(f
"Invalid cluster calibration '{recoDict['calib']}'")
79 if recoDict.get(
"constitmod"):
85 constit, flags, context=jetRecoDict.get(
"trkopt",
"default"),
88 clusters = constit.containername
90 return StepOutput.create(acc, Clusters=clusters)
95 """Get the tracking inputs"""
96 return StepOutput.create(
99 **flags.Jet.Context.ftf,
105 """Get the PFO inputs"""
106 inputs = StepOutput.merge(
114 clustersin=inputs[
"Clusters"],
116 tracksin=inputs[
"Tracks"],
117 verticesin=inputs[
"Vertices"],
118 cellsin=inputs[
"Cells"],
125 **(recoDict | {
"trkopt":
"ftf",
"constitType":
"pf"})
131 pfoPrefix = constit.containername
132 if pfoPrefix.endswith(
"ParticleFlowObjects"):
133 pfoPrefix = pfoPrefix[:-19]
134 return StepOutput.create(
138 cPFOs=pfoPrefix +
"ChargedParticleFlowObjects",
139 nPFOs=pfoPrefix +
"NeutralParticleFlowObjects",
145 """Create the merged PFO inputs"""
147 alg = CompFactory.HLT.MET.FlowElementPrepAlg(
148 f
"{pfos['PFOPrefix']}METTrigPFOPrepAlg",
149 InputNeutralKey=pfos[
"nPFOs"],
150 InputChargedKey=pfos[
"cPFOs"],
151 OutputKey=f
"{pfos['PFOPrefix']}METTrigCombinedParticleFlowObjects",
152 OutputCategoryKey=
"PUClassification",
155 acc.addEventAlgo(alg, primary=
True)
156 return StepOutput.create(
157 acc, pfos, MergedPFOs=alg.OutputKey, PUCategory=alg.OutputCategoryKey
163 """Create the clusters with CVF decorated"""
164 inputs = StepOutput.merge(
170 CompFactory.HLT.MET.CVFAlg(
171 f
"{recoDict['calib']}ftfClusterCVFAlg",
172 InputClusterKey=inputs[
"Clusters"],
173 InputTrackKey=inputs[
"Tracks"],
174 InputVertexKey=inputs[
"Vertices"],
176 TrackSelectionTool=CompFactory.InDet.InDetTrackSelectionTool(
177 CutLevel=
"TightPrimary"
179 TVATool=acc.popToolsAndMerge(
182 TrackContName=inputs[
"Tracks"],
183 VertexContName=inputs[
"Vertices"]
186 ExtensionTool=CompFactory.ApproximateTrackToLayerTool(),
190 CompFactory.HLT.MET.CVFPrepAlg(
191 f
"{recoDict['calib']}ftfClusterCVFPrepAlg",
192 InputClusterKey=inputs[
"Clusters"],
194 OutputCategoryKey=
"PUClassification",
197 return StepOutput.create(acc, inputs, CVF=
"CVF", PUCategory=
"PUClassification")
201 def jetInputCfg(flags, force_tracks: bool =
False, **recoDict) -> StepOutput:
202 """Create the input jets
204 Set force_tracks to True to require tracks and ensure that they are ghost-associated
207 Returns the accumulators and (jets, jetDef)
210 recoDict[
"trkopt"] =
"ftf"
220 if jrd[
"trkopt"] ==
"ftf":
222 if jrd[
"constitType"] ==
"pf":
230 jetName, jetDef = jetDefDict[
'final']
233 return StepOutput.create(
234 acc, inputs, Jets=jetName, JetDef=jetDef, **jetDef._contextDic