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 =
'',
200) -> ComponentAccumulator:
202 Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.
204 :param flags: Config flags.
205 :param name: Suffix for the main TrigTauRecMerged algorithm name.
206 :param hitz_algs: List of hitz inference algorithms to execute, using the ONNX inference setup.
207 The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>)
208 :param presel_algs: List of preselection inference algorithms to execute, using the ONNX inference setup.
209 The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>).
210 For these algorithms, the score flattening and WP decorator tools will be used.
211 :param input_rois: RoIs container, where the reconstruction will be run.
213 :return: CA with the TauJet Precision reconstruction sequence.
215 from TrigEDMConfig.TriggerEDM
import recordable
216 output_taus = recordable(
'HLT_TrigTauRecMerged_CaloHits')
217 output_tau_tracks =
'HLT_tautrack_CaloHits_dummy'
220 acc = ComponentAccumulator()
222 from AthenaConfiguration.ComponentFactory
import CompFactory
225 acc.addEventAlgo(CompFactory.FlavorTagDiscriminants.HitBeamSpotDataDecoratorAlg(
226 name=
'TrigTauPixelHitsDecoratorAlg',
227 hitContainer=
'PixelClusters',
228 beamSpotKey=
'BeamSpotData',
239 if hitz_algs
is None: hitz_algs = []
240 if presel_algs
is None: presel_algs = []
241 for alg
in hitz_algs + presel_algs:
243 try: alg_flags = getattr(flags.Trigger.Offline.Tau, alg)
244 except NameError:
raise ValueError(f
'Missing algorithm ConfigFlags: Trigger.Offline.Tau.{alg}')
246 if hasattr(alg_flags,
'MaxHits')
and alg_flags.MaxHits > max_hits:
247 max_hits = alg_flags.MaxHits
250 hits_decoration = f
'associatedHits_{name}'
251 acc.addEventAlgo(CompFactory.FlavorTagDiscriminants.JetHitAssociationAlg(
252 name=f
'TrigTauJetHitAssociationAlg_{name}',
253 jetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
254 hitContainer=
'PixelClusters',
255 hitAssociation=hits_decoration,
256 dphiHitToJet=flags.Tracking.ActiveConfig.phiHalfWidth,
257 detaHitToJet=flags.Tracking.ActiveConfig.etaHalfWidth,
273 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getTauIDScoreVariables
275 hitz_shift_to_detector = {}
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)
284 hitz_monitoring[alg] = (z0_var, _) = getHitZVariables(alg)
287 alg_flags = getattr(flags.Trigger.Offline.Tau, alg)
288 if hasattr(alg_flags,
'BeamSpotCoordinates')
and alg_flags.BeamSpotCoordinates:
289 ptau_sfx =
'wrt_beamspot'
290 hitz_shift_to_detector[f
'{z0_var}_{ptau_sfx}'] = z0_var
294 tools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(
297 tau_container=output_taus,
298 hits_decoration_container=hits_decoration,
301 acc.addPublicTool(tools[-1])
303 if alg
in presel_algs:
305 tools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=alg, precision_seq_name=name)))
306 acc.addPublicTool(tools[-1])
308 id_score_monitoring[alg] = getTauIDScoreVariables(alg)
313 tool.inTrigger =
True
314 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
317 from TrigTauRec.TrigTauRecMonitoring
import tauMonitoringCaloHits
318 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
319 name=f
'TrigTauRecMerged_CaloHits_{name}',
321 MonTool=tauMonitoringCaloHits(
324 hitz_algs=hitz_monitoring.keys(),
325 tau_ids=id_score_monitoring.keys(),
328 MonitoredHitZRegressions=hitz_monitoring,
329 MonitoredIDScores=id_score_monitoring,
330 ShiftToDetectorCoordinates=hitz_shift_to_detector,
331 InputRoIs=input_rois,
332 InputTauJetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
333 InputTauJetHitsKey=hits_decoration,
334 OutputTauTrackContainer=output_tau_tracks,
335 OutputTauJetContainer=output_taus,
343 Reconstruct the CaloMVA TauJet from the calo-clusters.
345 :param flags: Config flags, jet: 'lc' or 'em' depending on seed
346 :return: CA with the TauJet CaloMVA reconstruction sequence.
349 acc = ComponentAccumulator()
353 from AthenaConfiguration.ComponentFactory
import CompFactory
356 tools.append(CompFactory.JetSeedBuilder())
359 tools.append(CompFactory.TauAxisSetter(ClusterCone=0.2, VertexCorrection=
False))
362 tools.append(CompFactory.TauClusterFinder(UseOriginalCluster=
False))
363 tools.append(CompFactory.TauVertexedClusterDecorator(SeedJet=
''))
366 tools.append(CompFactory.TauCellVariables(CellCone=0.2, VertexCorrection =
False))
369 tools.append(CompFactory.MvaTESVariableDecorator(Key_vertexInputContainer=
'', EventShapeKey=
'', VertexCorrection=
False))
370 acc.addPublicTool(tools[-1])
371 tools.append(CompFactory.MvaTESEvaluator(WeightFileName=flags.Trigger.Offline.Tau.MvaTESConfig))
372 acc.addPublicTool(tools[-1])
376 tool.inTrigger =
True
377 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
379 from TrigEDMConfig.TriggerEDM
import recordable
380 from TrigTauRec.TrigTauRecMonitoring
import tauMonitoringCaloOnlyMVA
383 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
384 name=
'TrigTauRecMerged_TauCaloOnlyMVA',
386 MonTool=tauMonitoringCaloOnlyMVA(flags, jet=jet),
387 InputRoIs=
'UpdatedCaloLCRoI',
388 InputCaloClusterContainer=
'HLT_TopoCaloClustersLC',
389 OutputTauTrackContainer=
'HLT_tautrack_dummy',
390 OutputTauJetContainer=
'HLT_TrigTauRecMerged_CaloMVAOnly',
391 OutputJetSeed=recordable(
'HLT_jet_seed'),
394 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
395 name=
'TrigTauRecMerged_TauCaloOnlyEM',
397 MonTool=tauMonitoringCaloOnlyMVA(flags, jet=jet),
398 InputRoIs=
'UpdatedCaloEMRoI',
399 InputCaloClusterContainer=
'HLT_TopoCaloClustersEM',
400 OutputTauTrackContainer=
'HLT_tautrack_dummy',
401 OutputTauJetContainer=
'HLT_TrigTauRecMerged_CaloEMOnly',
402 OutputJetSeed=recordable(
'HLT_jet_seed'),