11 flags: AthConfigFlags,
13 tau_ids: list[str] |
None =
None,
15 input_tracks: str =
'',
17 input_tau_tracks: str =
'',
18 output_name: str =
'',
19 decors_to_copy: list[str] |
None =
None,
20) -> ComponentAccumulator:
22 Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.
24 :param flags: Config flags.
25 :param name: Suffix for the main TrigTauRecMerged algorithm name.
26 :param tau_ids: List of inference algorithms to execute.
27 The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>)
28 Currently, only the `DeepSet` and `RNNLLP` algorithms will use the LVNN inference setup (json config files);
29 all other ID algorithms will use the ONNX inference setup by default.
30 If the algorithm name (`name` input variable) is `MVA`, `LLP` or `LRT`, and `tau_ids=['DeepSet', 'MesonCuts']` or `tau_ids=['RNNLLP']`,
31 then the default TauJet RNN score and WP `isTau` decorators will be used (for the legacy
32 `mediumRNN/tightRNN_tracktwoMVA/tracktwoLLP/trackLRT` triggers).
33 Otherwise, all scores and WPs will be stored as `{tau_id}_Score`, `{tau_id}_ScoreSigTrans`, and `{tau_id}_{wp_name}`.
34 :param input_rois: RoIs container, where the reconstruction will be run.
35 :param input_tracks: TrackParticle container, with the refitted precision tracks.
36 :param input_taus: TauJet container, with the input tau jets.
37 :param input_tau_tracks: TauTrack container, with the input tau tracks (usually dummies from the CaloMVA or CaloHits steps).
38 :param output_name: Suffix for the output TauJet and TauTrack collections. If empty, `name` will be used.
39 :param decors_to_copy: List of decorated/aux variables to copy from the input to the output TauJet container.
41 :return: CA with the TauJet Precision reconstruction sequence.
45 if not output_name: output_name = name
46 from TrigEDMConfig.TriggerEDM
import recordable
47 trigTauJetOutputContainer = recordable(f
'HLT_TrigTauRecMerged_{output_name}')
48 trigTauTrackOutputContainer = recordable(f
'HLT_tautrack_{output_name}')
51 acc = ComponentAccumulator()
63 from TrigTauRec.TrigTauRecToolsConfig
import trigTauVertexFinderCfg, trigTauTrackFinderCfg, tauVertexVariablesCfg
64 from AthenaConfiguration.ComponentFactory
import CompFactory
67 vftools.append(acc.popToolsAndMerge(trigTauVertexFinderCfg(flags, name=
'TrigTau_TauVertexFinder')))
70 tools_beforetf.append(CompFactory.TauAxisSetter(name=
'TrigTau_TauAxis', VertexCorrection=
False))
73 tftools.append(acc.popToolsAndMerge(trigTauTrackFinderCfg(flags, name=
'TrigTauTightDZ_TauTrackFinder', TrackParticlesContainer=input_tracks)))
76 tools.append(CompFactory.TauClusterFinder(name=
'TrigTau_TauClusterFinder', UseOriginalCluster=
False))
77 tools.append(CompFactory.TauVertexedClusterDecorator(name=
'TrigTau_TauVertexedClusterDecorator', SeedJet=
''))
80 tools.append(CompFactory.TauCellVariables(name=
'TrigTau_CellVariables', VertexCorrection=
False))
83 tools.append(CompFactory.MvaTESVariableDecorator(name=
'TrigTau_MvaTESVariableDecorator', Key_vertexInputContainer=
'', EventShapeKey=
'', VertexCorrection=
False))
84 acc.addPublicTool(tools[-1])
85 tools.append(CompFactory.MvaTESEvaluator(name=
'TrigTau_MvaTESEvaluator', WeightFileName=flags.Trigger.Offline.Tau.MvaTESConfig))
86 acc.addPublicTool(tools[-1])
89 vvtools.append(acc.popToolsAndMerge(tauVertexVariablesCfg(flags, name=
'TrigTau_TauVertexVariables')))
92 idtools.append(CompFactory.TauCommonCalcVars(name=
'TrigTau_TauCommonCalcVars'))
95 idtools.append(CompFactory.TauSubstructureVariables(name=
'TrigTau_TauSubstructure', VertexCorrection=
False))
104 tau_ids = sorted(list(
set(tau_ids
if tau_ids
else []) - {
'perf',
'idperf',
'MesonCuts'}))
106 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getTauIDScoreVariables
107 id_score_monitoring = {}
110 used_builtin_rnnscore =
False
112 for tau_id
in tau_ids:
114 try: id_flags = getattr(flags.Trigger.Offline.Tau, tau_id)
115 except NameError:
raise ValueError(f
'Missing TauID ConfigFlags: Trigger.Offline.Tau.{tau_id}')
118 is_onnx = hasattr(id_flags,
'ONNXConfig')
121 log.debug(
'Configuring TrigTauRecMerged with the ONNX Tau ID score inference: %s', tau_id)
124 idtools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(flags, tau_id=tau_id)))
125 acc.addPublicTool(idtools[-1])
128 idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=tau_id, precision_seq_name=name, tauContainerName=trigTauJetOutputContainer)))
129 acc.addPublicTool(idtools[-1])
133 log.debug(
'Configuring TrigTauRecMerged %s with the LVNN Tau ID score inference: %s', name, tau_id)
135 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import useBuiltInTauJetRNNScore
139 use_builtin_rnnscore = useBuiltInTauJetRNNScore(tau_id)
140 if use_builtin_rnnscore:
141 if used_builtin_rnnscore:
142 log.error(
'Cannot store more than one TauID score in the built-in TauJet RNN score variables')
144 used_builtin_rnnscore =
True
147 from TrigTauRec.TrigTauRecToolsConfig
import trigTauJetLVNNEvaluatorCfg
148 idtools.append(acc.popToolsAndMerge(trigTauJetLVNNEvaluatorCfg(flags, tau_id=tau_id, use_taujet_rnnscore=use_builtin_rnnscore)))
149 acc.addPublicTool(idtools[-1])
152 if use_builtin_rnnscore:
153 from TrigTauRec.TrigTauRecToolsConfig
import trigTauWPDecoratorRNNCfg
154 idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorRNNCfg(flags, tau_id=tau_id, precision_seq_name=name)))
155 acc.addPublicTool(idtools[-1])
157 idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=tau_id, precision_seq_name=name, tauContainerName=trigTauJetOutputContainer)))
158 acc.addPublicTool(idtools[-1])
160 id_score_monitoring[tau_id] = getTauIDScoreVariables(tau_id)
164 for tool
in vftools + tools_beforetf + tftools + tools + vvtools + idtools:
165 tool.inTrigger =
True
166 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
169 from TrigTauRec.TrigTauRecMonitoring
import tauMonitoringPrecision
170 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
171 name=f
'TrigTauRecMerged_Precision_{name}',
172 VertexFinderTools=vftools,
173 CommonToolsBeforeTF=tools_beforetf,
174 TrackFinderTools=tftools,
176 VertexVarsTools=vvtools,
178 MonTool=tauMonitoringPrecision(flags, RoI_name=
'tauLRT' if 'LRT' in name
else 'tauIso', tau_ids=id_score_monitoring.keys(), alg_name=name),
179 MonitoredIDScores=id_score_monitoring,
180 InputRoIs=input_rois,
181 InputVertexContainer=flags.Tracking.ActiveConfig.vertex,
182 InputTauTrackContainer=input_tau_tracks,
183 InputTauJetContainer=input_taus,
184 InputTauJetCopyDecorKeys=decors_to_copy
if decors_to_copy
else [],
185 OutputTauTrackContainer=trigTauTrackOutputContainer,
186 OutputTauJetContainer=trigTauJetOutputContainer,
194 flags: AthConfigFlags,
196 hitz_algs: list[str] |
None =
None,
197 presel_algs: list[str] |
None =
None,
198 input_rois: str =
'',
199) -> ComponentAccumulator:
201 Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.
203 :param flags: Config flags.
204 :param name: Suffix for the main TrigTauRecMerged algorithm name.
205 :param hitz_algs: List of hitz inference algorithms to execute, using the ONNX inference setup.
206 The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>)
207 :param presel_algs: List of preselection inference algorithms to execute, using the ONNX inference setup.
208 The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>).
209 For these algorithms, the score flattening and WP decorator tools will be used.
210 :param input_rois: RoIs container, where the reconstruction will be run.
212 :return: CA with the TauJet Precision reconstruction sequence.
214 from TrigEDMConfig.TriggerEDM
import recordable
215 output_taus = recordable(
'HLT_TrigTauRecMerged_CaloHits')
216 output_tau_tracks =
'HLT_tautrack_CaloHits_dummy'
219 acc = ComponentAccumulator()
221 from AthenaConfiguration.ComponentFactory
import CompFactory
224 acc.addEventAlgo(CompFactory.FlavorTagDiscriminants.HitBeamSpotDataDecoratorAlg(
225 name=
'TrigTauPixelHitsDecoratorAlg',
226 hitContainer=
'PixelClusters',
227 beamSpotKey=
'BeamSpotData',
238 if hitz_algs
is None: hitz_algs = []
239 if presel_algs
is None: presel_algs = []
240 for alg
in hitz_algs + presel_algs:
242 try: alg_flags = getattr(flags.Trigger.Offline.Tau, alg)
243 except NameError:
raise ValueError(f
'Missing algorithm ConfigFlags: Trigger.Offline.Tau.{alg}')
245 if hasattr(alg_flags,
'MaxHits')
and alg_flags.MaxHits > max_hits:
246 max_hits = alg_flags.MaxHits
249 hits_decoration = f
'associatedHits_{name}'
250 acc.addEventAlgo(CompFactory.FlavorTagDiscriminants.JetHitAssociationAlg(
251 name=f
'TrigTauJetHitAssociationAlg_{name}',
252 jetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
253 hitContainer=
'PixelClusters',
254 hitAssociation=hits_decoration,
255 useWedgeSelection=
True,
256 dphiHitToJet=flags.Tracking.ActiveConfig.phiHalfWidth,
257 detaHitToJet=flags.Tracking.ActiveConfig.etaHalfWidth,
260 removeBadIDPixelHits=
False,
274 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getTauIDScoreVariables
276 id_score_monitoring = {}
278 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getHitZVariables
279 for alg
in hitz_algs + presel_algs:
280 log.debug(
'Configuring TrigTauRecMerged with the ONNX Tau inference: %s', alg)
283 tools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(
286 tau_container=output_taus,
287 hits_decoration_container=hits_decoration,
289 acc.addPublicTool(tools[-1])
292 hitz_monitoring[alg] = getHitZVariables(alg)
294 if alg
in presel_algs:
296 tools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=alg, precision_seq_name=name)))
297 acc.addPublicTool(tools[-1])
299 id_score_monitoring[alg] = getTauIDScoreVariables(alg)
304 tool.inTrigger =
True
305 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
308 from TrigTauRec.TrigTauRecMonitoring
import tauMonitoringCaloHits
309 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
310 name=f
'TrigTauRecMerged_CaloHits_{name}',
312 MonTool=tauMonitoringCaloHits(
315 hitz_algs=hitz_monitoring.keys(),
316 tau_ids=id_score_monitoring.keys(),
318 MonitoredHitZRegressions=hitz_monitoring,
319 MonitoredIDScores=id_score_monitoring,
320 InputRoIs=input_rois,
321 InputTauJetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
322 InputTauJetHitsKey=hits_decoration,
323 OutputTauTrackContainer=output_tau_tracks,
324 OutputTauJetContainer=output_taus,
333 Reconstruct the CaloMVA TauJet from the calo-clusters.
335 :param flags: Config flags.
336 :return: CA with the TauJet CaloMVA reconstruction sequence.
339 acc = ComponentAccumulator()
343 from AthenaConfiguration.ComponentFactory
import CompFactory
346 tools.append(CompFactory.JetSeedBuilder())
349 tools.append(CompFactory.TauAxisSetter(ClusterCone=0.2, VertexCorrection=
False))
352 tools.append(CompFactory.TauClusterFinder(UseOriginalCluster=
False))
353 tools.append(CompFactory.TauVertexedClusterDecorator(SeedJet=
''))
356 tools.append(CompFactory.TauCellVariables(CellCone=0.2, VertexCorrection =
False))
359 tools.append(CompFactory.MvaTESVariableDecorator(Key_vertexInputContainer=
'', EventShapeKey=
'', VertexCorrection=
False))
360 acc.addPublicTool(tools[-1])
361 tools.append(CompFactory.MvaTESEvaluator(WeightFileName=flags.Trigger.Offline.Tau.MvaTESConfig))
362 acc.addPublicTool(tools[-1])
367 tool.inTrigger =
True
368 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
371 from TrigEDMConfig.TriggerEDM
import recordable
372 from TrigTauRec.TrigTauRecMonitoring
import tauMonitoringCaloOnlyMVA
373 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
374 name=
'TrigTauRecMerged_TauCaloOnlyMVA',
376 MonTool=tauMonitoringCaloOnlyMVA(flags),
377 InputRoIs=
'UpdatedCaloRoI',
378 InputCaloClusterContainer=
'HLT_TopoCaloClustersLC',
379 OutputTauTrackContainer=
'HLT_tautrack_dummy',
380 OutputTauJetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
381 OutputJetSeed=recordable(
'HLT_jet_seed'),