ATLAS Offline Software
Loading...
Searching...
No Matches
TauMenuSequences.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from TriggerMenuMT.HLT.Config.MenuComponents import MenuSequence, SelectionCA, InViewRecoCA
4from AthenaConfiguration.AthConfigFlags import AthConfigFlags
5from AthenaConfiguration.ComponentFactory import CompFactory
6from AthenaConfiguration.AccumulatorCache import AccumulatorCache
7from TrigEDMConfig.TriggerEDM import recordable
8from TrigInDetConfig.utils import getFlagsForActiveConfig
9
10from AthenaCommon.Logging import logging
11log = logging.getLogger(__name__)
12
13
14# Check the ATLAS Software Docs for more details about the different sub-sequences, CAs, and details
15# about the step configuration.
16
17
18#================================================================
19# CaloMVA sequences
20#================================================================
21@AccumulatorCache
22def tauCaloMVASequenceGenCfg(flags: AthConfigFlags, is_probe_leg: bool = False) -> MenuSequence:
23 '''Calorimeter-only reconstruction and hypothesis (BRT-calibrated pT cut)'''
24
25 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
26 # in parallel whenever possible, according to their data dependencies.
27 # Create the EventViews based on the HLTSeeding RoIs (from the input L1 TOBs)
28 recoAcc = InViewRecoCA(name='tauCaloMVA', InViewRoIs='CaloMVA_RoIs', isProbe=is_probe_leg)
29 RoIs = recoAcc.inputMaker().InViewRoIs
30
31
32 # VDV with all the required collections/objects in the View
33 # (the VDV checks are disabled unless running with -l DEBUG)
34 Objects={
35 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
36 ('xAOD::EventInfo', 'StoreGateSvc+EventInfo'),
37 ('SG::AuxElement', 'StoreGateSvc+EventInfo.actualInteractionsPerCrossing'),
38 ('SG::AuxElement', 'StoreGateSvc+EventInfo.averageInteractionsPerCrossing'),
39 ('CaloBCIDAverage', 'StoreGateSvc+CaloBCIDAverage')
40 }
41 if ( not flags.Input.isMC ):
42 Objects.add( ('LArDeadOTXFromSC' , 'StoreGateSvc+DeadOTXFromSC' ) )
43 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
44 name=f'{recoAcc.name}RecoVDV',
45 DataObjects=Objects
46 ))
47
48
49 # Reconstruction tools/algorithms:
50
51 # Topo-clustering
52 from TrigCaloRec.TrigCaloRecConfig import tauTopoClusteringCfg
53 recoAcc.mergeReco(tauTopoClusteringCfg(flags, RoIs=RoIs))
54
55 # Create new RoIs with an updated position, based on the central axis of the clusters
56 from TrigTauRec.TrigTauRoIToolsConfig import tauCaloRoiUpdaterCfg
57 recoAcc.mergeReco(tauCaloRoiUpdaterCfg(flags, inputRoIs=RoIs, clusters='HLT_TopoCaloClustersLC'))
58
59 # Construct the calo-only TauJet (with BRT calibration)
60 from TrigTauRec.TrigTauRecConfig import trigTauRecMergedCaloMVACfg
61 recoAcc.mergeReco(trigTauRecMergedCaloMVACfg(flags))
62
63
64 # Calo ROB prefetching, to reduce number of calls to the readout
65 from TrigGenericAlgs.TrigGenericAlgsConfig import ROBPrefetchingAlgCfg_Calo
66 robPrefetchAlg = ROBPrefetchingAlgCfg_Calo(flags, nameSuffix=f'IM_{recoAcc.name}_probe' if is_probe_leg else f'IM_{recoAcc.name}')
67
68
69 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first, the rob prefetching alg. second,
70 # the reco CA (with all the reco algs) after, and the Hypo alg. at last
71 selAcc = SelectionCA('tauCalo', isProbe=is_probe_leg)
72 selAcc.mergeReco(recoAcc, robPrefetchCA=robPrefetchAlg)
73
74
75 # Hypothesis:
76 # The Hypotools in the Hypo algorithm will execute the BRT-calibrated Tau pT cut
77 selAcc.addHypoAlgo(CompFactory.TrigTauJetHypoAlg('TauCaloMVAHypoAlg', TauJetsKey='HLT_TrigTauRecMerged_CaloMVAOnly'))
78
79
80 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
81 # based on the partDict for each chain tau leg
82 from TrigTauHypo.TrigTauHypoTool import TrigTauCaloMVAHypoToolFromDict
83 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauCaloMVAHypoToolFromDict)
84
85 return menuSeq
86
87
88
89#================================================================
90# Calo + Hits step: HitZ + Calo+Hits preselection
91#================================================================
92@AccumulatorCache
93def tauCaloHitsSequenceGenCfg(orig_flags: AthConfigFlags, seq_name: str, precision_seq_name: str, hitz_config: tuple[str, float] | None = None, is_probe_leg: bool = False) -> MenuSequence:
94 '''Calorimeter+Hits RoI updating and preselection hypothesis'''
95
96 tracking_cfg = f'tauHits{seq_name}'
97 next_tracking_cfg = f'tauCore{seq_name}'
98
99 flags = getFlagsForActiveConfig(orig_flags, tracking_cfg, log)
100
101 # Create new RoIs from 'UpdatedCaloRoI', resized to the HitZ RoI before running the HitZ and other inference algorithms
102 newRoITool = CompFactory.ViewCreatorFetchFromViewROITool(
103 RoisWriteHandleKey=recordable(flags.Tracking.ActiveConfig.roi),
104 InViewRoIs='UpdatedCaloRoI',
105 doResize=True,
106 RoIEtaWidth=flags.Tracking.ActiveConfig.etaHalfWidth,
107 RoIPhiWidth=flags.Tracking.ActiveConfig.phiHalfWidth,
108 RoIZedWidth=flags.Tracking.ActiveConfig.zedHalfWidth,
109 )
110
111
112 # If we're running on small RoIs, we will optionally prefetch ROBs for the larger 'tauIso' RoIs ahead of time,
113 # to avoid retrieving more detector information again later in the next step
114 from TriggerJobOpts.TriggerConfigFlags import ROBPrefetching
115 if doExtraPrefetching := ROBPrefetching.TauCoreLargeRoI in flags.Trigger.ROBPrefetchingOptions:
116 prefetch_flags = getFlagsForActiveConfig(orig_flags, f'tauIso{seq_name}', log)
117 prefetchRoIUpdater = CompFactory.RoiUpdaterTool(
118 useBeamSpot=True,
119 NSigma=1.5,
120 EtaWidth=prefetch_flags.Tracking.ActiveConfig.etaHalfWidth,
121 PhiWidth=prefetch_flags.Tracking.ActiveConfig.phiHalfWidth,
122 ZedWidth=prefetch_flags.Tracking.ActiveConfig.zedHalfWidth, # Shouldn't this be the larger tauCore RoI z width?
123 )
124
125 prefetchRoITool = CompFactory.ViewCreatorExtraPrefetchROITool(
126 RoiCreator=newRoITool,
127 RoiUpdater=prefetchRoIUpdater,
128 ExtraPrefetchRoIsKey=f'{newRoITool.RoisWriteHandleKey}_forPrefetching',
129 PrefetchRoIsLinkName='prefetchRoI',
130 MergeWithOriginal=True,
131 )
132
133
134 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
135 # in parallel whenever possible, according to their data dependencies.
136 # Create the EventViews from the resized RoIs, based on the 'UpdatedCaloRoI' created in the CaloMVA step
137 recoAcc = InViewRecoCA(
138 name=f'tauCaloHits_{seq_name}',
139 RoITool=prefetchRoITool if doExtraPrefetching else newRoITool,
140 ViewFallThrough=True,
141 RequireParentView=True,
142 mergeUsingFeature=True,
143 isProbe=is_probe_leg
144 )
145 RoIs = recoAcc.inputMaker().InViewRoIs
146
147
148 # VDV with all the required collections/objects in the View
149 # (the VDV checks are disabled unless running with -l DEBUG)
150 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
151 name=f'{recoAcc.name}RecoVDV',
152 DataObjects={
153 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
154 ('xAOD::EventInfo', 'StoreGateSvc+EventInfo'),
155 ('xAOD::TauJetContainer', 'StoreGateSvc+HLT_TrigTauRecMerged_CaloMVAOnly'),
156 ('xAOD::TauTrackContainer', 'StoreGateSvc+HLT_tautrack_dummy'),
157 }
158 ))
159
160
161 # Reconstruction tools/algorithms:
162
163 # Construct ID space-points in the View
164 from TrigInDetConfig.TrigInDetConfig import trigInDetSPFormationCfg
165 recoAcc.mergeReco(trigInDetSPFormationCfg(flags, roisKey=RoIs, signatureName=tracking_cfg))
166
167 # Create the high-level xAOD::TrackParticleValidation container from the SPs
168 if flags.Detector.GeometryITk:
169 from InDetConfig.InDetPrepRawDataToxAODConfig import ITkPixelPrepDataToxAODCfg as PixelPrepDataToxAODCfg
170 pixel_cluster_container = 'ITkTrigPixelClusters'
171 else:
172 from InDetConfig.InDetPrepRawDataToxAODConfig import InDetPixelPrepDataToxAODCfg as PixelPrepDataToxAODCfg
173 pixel_cluster_container = 'PixelTrigClusters'
174
175 recoAcc.mergeReco(PixelPrepDataToxAODCfg(
176 flags,
177 SiClusterContainer=pixel_cluster_container, # From the FTF SP reco
178 OutputClusterContainer='PixelClusters', # Output xAOD::TrackParticleValidation container
179 WriteNNinformation=False,
180 UseTruthInfo=False,
181 ))
182
183 # Get the BeamSpot from the conditions database
184 from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
185 recoAcc.mergeReco(BeamSpotCondAlgCfg(flags))
186
187 # Construct the calo+hits TauJet, and run the HitZ inference algorithms
188 from TrigTauRec.TrigTauRecConfig import trigTauRecMergedCaloHitsCfg
189 from .TauConfigurationTools import getHitZAlgs, getCaloHitsPreselAlgs
190 recoAcc.mergeReco(trigTauRecMergedCaloHitsCfg(
191 flags,
192 seq_name,
193 hitz_algs=getHitZAlgs(flags, f'{precision_seq_name}_{seq_name}', precision_seq_name),
194 presel_algs=getCaloHitsPreselAlgs(flags, f'{precision_seq_name}_{seq_name}', precision_seq_name),
195 input_rois=RoIs,
196 ))
197
198
199 if hitz_config:
200 # Create new RoIs with an updated position, based on the central axis of the clusters
201 from TrigTauRec.TrigTauRoIToolsConfig import tauHitZRoiUpdaterCfg
202 recoAcc.mergeReco(tauHitZRoiUpdaterCfg(
203 flags,
204 inputRoIs=RoIs,
205 outputRoIs=f'UpdatedCaloHits{seq_name}RoI',
206 taus='HLT_TrigTauRecMerged_CaloHits',
207 hitz_alg=hitz_config[0],
208 max_pt=1000e3,
209 max_sigma=hitz_config[1],
210 tracking_cfg=next_tracking_cfg,
211 ))
212
213
214 # ROB prefetching for the Pixel and SCT data
215 from TrigGenericAlgs.TrigGenericAlgsConfig import ROBPrefetchingAlgCfg_Si
216 sfx = '_probe' if is_probe_leg else ''
217 robPrefetchAlg = ROBPrefetchingAlgCfg_Si(flags, nameSuffix=f'IM_{recoAcc.name}{sfx}')
218 if doExtraPrefetching:
219 robPrefetchAlg.RoILinkName = prefetchRoITool.PrefetchRoIsLinkName
220
221
222 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first, the rob prefetching alg. second,
223 # the reco CA (with all the reco algs) after, and the Hypo alg. at last
224 selAcc = SelectionCA(f'tauCaloHits_{seq_name}', isProbe=is_probe_leg)
225 selAcc.mergeReco(recoAcc, robPrefetchCA=robPrefetchAlg)
226
227
228 # Hypothesis:
229 # The Hypotools in the Hypo algorithm will execute the BRT-calibrated Tau pT cut
230 selAcc.addHypoAlgo(CompFactory.TrigTauJetHypoAlg(f'TauCaloHitsHypoAlg_{seq_name}', TauJetsKey='HLT_TrigTauRecMerged_CaloHits'))
231
232
233 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
234 # based on the partDict for each chain tau leg
235 from TrigTauHypo.TrigTauHypoTool import TrigTauCaloHitsHypoToolFromDict
236 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauCaloHitsHypoToolFromDict)
237
238 return menuSeq
239
240
241
242#================================================================
243# 1st FTF step: FTFCore / FTFLRT
244#================================================================
245
246@AccumulatorCache
247def tauFTFCoreSequenceGenCfg(orig_flags: AthConfigFlags, calohits_seq_name: str | None = None, do_lrt: bool = False, is_probe_leg: bool = False) -> MenuSequence:
248 '''1st FTF step sequence, for both the tauCore(Hits) and tauLRT RoIs'''
249
250 if do_lrt:
251 name = 'LRT'
252 tracking_cfg = next_tracking_cfg = 'tauLRT'
253 output_rois = 'UpdatedTrackLRTRoI'
254 else:
255 name = 'Core'
256 tracking_cfg = 'tauCore'
257 next_tracking_cfg = 'tauIso'
258 output_rois = 'UpdatedTrackRoI'
259
260 if calohits_seq_name:
261 tracking_cfg += calohits_seq_name
262 next_tracking_cfg += calohits_seq_name
263
264 # Retrieve tracking configuration
265 flags = getFlagsForActiveConfig(orig_flags, tracking_cfg, log)
266
267 # Source-dependent configuration
268 if calohits_seq_name:
269 name += f'_{calohits_seq_name}'
270 input_rois = f'UpdatedCaloHits{calohits_seq_name}RoI'
271 output_rois = f'{output_rois[:-3]}{calohits_seq_name}RoI'
272 else:
273 input_rois = 'UpdatedCaloRoI'
274
275
276 # Create new RoIs from 'UpdatedCaloRoI' or 'UpdatedCaloHitsRoI, resized to 'tauCore/LRT'
277 # before running the FTF algorithms.
278 newRoITool = CompFactory.ViewCreatorFetchFromViewROITool(
279 RoisWriteHandleKey=recordable(flags.Tracking.ActiveConfig.roi),
280 InViewRoIs=input_rois,
281 doResize=not calohits_seq_name, # Do not resize if we're using the CaloHits RoI, which is already resized to the correct size for the FTF step
282 RoIEtaWidth=flags.Tracking.ActiveConfig.etaHalfWidth,
283 RoIPhiWidth=flags.Tracking.ActiveConfig.phiHalfWidth,
284 RoIZedWidth=flags.Tracking.ActiveConfig.zedHalfWidth,
285 )
286
287
288 # If we're running on tauCore RoIs, we will optionally prefetch ROBs for the larger 'tauIso' RoIs ahead of time,
289 # to avoid retrieving more detector information again later in the next step
290 from TriggerJobOpts.TriggerConfigFlags import ROBPrefetching
291 if doExtraPrefetching := not calohits_seq_name and tracking_cfg == 'tauCore' and ROBPrefetching.TauCoreLargeRoI in flags.Trigger.ROBPrefetchingOptions:
292 prefetch_flags = getFlagsForActiveConfig(orig_flags, 'tauIso', log)
293 prefetchRoIUpdater = CompFactory.RoiUpdaterTool(
294 useBeamSpot=True,
295 NSigma=1.5,
296 EtaWidth=prefetch_flags.Tracking.ActiveConfig.etaHalfWidth,
297 PhiWidth=prefetch_flags.Tracking.ActiveConfig.phiHalfWidth,
298 ZedWidth=prefetch_flags.Tracking.ActiveConfig.zedHalfWidth,
299 )
300
301 prefetchRoITool = CompFactory.ViewCreatorExtraPrefetchROITool(
302 RoiCreator=newRoITool,
303 RoiUpdater=prefetchRoIUpdater,
304 ExtraPrefetchRoIsKey=f'{newRoITool.RoisWriteHandleKey}_forPrefetching',
305 PrefetchRoIsLinkName='prefetchRoI',
306 MergeWithOriginal=True,
307 )
308
309
310 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
311 # in parallel whenever possible, according to their data dependencies.
312 # Create the EventViews from the resized RoIs, based on the upstream RoI created in the CaloMVA or CaloHits steps
313 recoAcc = InViewRecoCA(
314 f'tauFastTrack{name}',
315 RoITool=prefetchRoITool if doExtraPrefetching else newRoITool,
316 ViewFallThrough=True,
317 RequireParentView=True,
318 mergeUsingFeature=True,
319 isProbe=is_probe_leg
320 )
321 RoIs = recoAcc.inputMaker().InViewRoIs
322
323
324 # VDV with all the required collections/objects in the View
325 # (the VDV checks are disabled unless running with -l DEBUG)
326 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
327 name=f'{recoAcc.name}RecoVDV',
328 DataObjects={
329 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
330 }
331 ))
332
333
334 # Reconstruction tools/algorithms:
335
336 # Fast Track Finder (FTF) sequence (the main point of this step)
337 from TrigInDetConfig.TrigInDetConfig import trigInDetFastTrackingCfg
338 recoAcc.mergeReco(trigInDetFastTrackingCfg(flags, roisKey=RoIs, signatureName=tracking_cfg))
339
340 # Create new RoIs for the next tracking steps (FTFIso and PrecTrack), based on the found tracks
341 TrackCollection = flags.Tracking.ActiveConfig.tracks_FTF
342
343
344 from TrigTauRec.TrigTauRoIToolsConfig import tauTrackRoiUpdaterCfg
345 recoAcc.mergeReco(tauTrackRoiUpdaterCfg(
346 flags,
347 inputRoIs=RoIs,
348 outputRoIs=output_rois,
349 tracks=TrackCollection,
350
351 # Only pass the next tracking config if it's different from the current one (ActiveConfig),
352 tracking_cfg=next_tracking_cfg if next_tracking_cfg != tracking_cfg else None,
353 ))
354
355
356 # ROB prefetching for the Pixel and SCT data
357 from TrigGenericAlgs.TrigGenericAlgsConfig import ROBPrefetchingAlgCfg_Si
358 robPrefetchAlg = ROBPrefetchingAlgCfg_Si(flags, nameSuffix=f'IM_{recoAcc.name}')
359 if doExtraPrefetching:
360 robPrefetchAlg.RoILinkName = prefetchRoITool.PrefetchRoIsLinkName
361
362
363 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first, the rob prefetching alg. second,
364 # the reco CA (with all the reco algs) after, and the Hypo alg. at last
365 selAcc = SelectionCA(f'tauFTF{name}', isProbe=is_probe_leg)
366 selAcc.mergeReco(recoAcc, robPrefetchCA=robPrefetchAlg)
367
368
369 # Hypothesis:
370 # The hypothesis algorithm/tool does not perform any action (online monitoring of tracks only)
371 selAcc.addHypoAlgo(CompFactory.TrigTauTrackingHypoAlg(
372 f'TauFastTrackHypoAlg_PassBy{name}',
373 RoIKey='UpdatedTrackLRTRoI' if do_lrt else '',
374 TracksKey=TrackCollection,
375 ))
376
377
378 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
379 # based on the partDict for each chain tau leg
380 from TrigTauHypo.TrigTauHypoTool import TrigTauTrackingHypoToolFromDict
381 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauTrackingHypoToolFromDict)
382
383 return menuSeq
384
385
386
387#================================================================
388# 2nd FTF step: FTFIso
389#================================================================
390
391@AccumulatorCache
392def tauFTFIsoSequenceGenCfg(orig_flags: AthConfigFlags, calohits_seq_name: str | None = None, is_probe_leg: bool = False):
393 '''2nd FTF step sequence, for the tauIso RoI'''
394
395 name = 'Iso'
396
397 # Retrieve tracking configuration
398 previous_tracking_cfg = 'tauCore'
399 tracking_cfg = 'tauIso'
400 if calohits_seq_name:
401 tracking_cfg += calohits_seq_name
402 previous_tracking_cfg += calohits_seq_name
403
404 flags = getFlagsForActiveConfig(orig_flags, tracking_cfg, log)
405
406
407 # Source-dependent configuration
408 if calohits_seq_name:
409 name += f'_{calohits_seq_name}'
410 input_rois = f'UpdatedTrack{calohits_seq_name}RoI'
411 else:
412 input_rois = 'UpdatedTrackRoI'
413
414
415 # Create new RoIs from , resized to 'tauCore/LRT' before running the FTF algorithms
416 newRoITool = CompFactory.ViewCreatorFetchFromViewROITool(
417 RoisWriteHandleKey=recordable(flags.Tracking.ActiveConfig.roi),
418 InViewRoIs=input_rois,
419 )
420
421
422 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
423 # in parallel whenever possible, according to their data dependencies.
424 # Create the EventViews based on the RoIs created in the previous step
425 recoAcc = InViewRecoCA(
426 f'tauFastTrack{name}',
427 RoITool=newRoITool,
428 RequireParentView=True,
429 ViewFallThrough=True,
430 isProbe=is_probe_leg
431 )
432 RoIs = recoAcc.inputMaker().InViewRoIs
433
434
435 # VDV with all the required collections/objects in the View
436 # (the VDV checks are disabled unless running with -l DEBUG)
437 previous_step_flags = getFlagsForActiveConfig(orig_flags, previous_tracking_cfg, log)
438 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
439 name=f'{recoAcc.name}RecoVDV',
440 DataObjects={
441 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
442 ('xAOD::TrackParticleContainer', f'StoreGateSvc+{previous_step_flags.Tracking.ActiveConfig.tracks_FTF}'),
443 }
444 ))
445
446
447 # Reconstruction tools/algorithms:
448
449 # Fast Track Finder (FTF) sequence (the main point of this step)
450 from TrigInDetConfig.TrigInDetConfig import trigInDetFastTrackingCfg
451 recoAcc.mergeReco(trigInDetFastTrackingCfg(flags, roisKey=RoIs, signatureName=tracking_cfg))
452
453
454 # ROB prefetching for the Pixel and SCT data
455 # Note: if enabled in the config flags, the tauIso RoI would have already been prefetched in the previous step
456 # through the 'extra prefetching' procedure, so we can skip it
457 from TriggerJobOpts.TriggerConfigFlags import ROBPrefetching
458 if ROBPrefetching.TauCoreLargeRoI in flags.Trigger.ROBPrefetchingOptions:
459 robPrefetchAlg = None
460 else:
461 from TrigGenericAlgs.TrigGenericAlgsConfig import ROBPrefetchingAlgCfg_Si
462 robPrefetchAlg = ROBPrefetchingAlgCfg_Si(flags, nameSuffix=f'IM_{recoAcc.name}')
463
464 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first, the rob prefetching alg. second (if enabled),
465 # the reco CA (with all the reco algs) after, and the Hypo alg. at last
466 selAcc = SelectionCA(f'tauFTF{name}', isProbe=is_probe_leg)
467 selAcc.mergeReco(recoAcc, robPrefetchCA=robPrefetchAlg)
468
469
470 # Hypothesis:
471 # The hypothesis algorithm/tool does not perform any action (debug logging of number of tracks only)
472 selAcc.addHypoAlgo(CompFactory.TrigTauTrackingHypoAlg(
473 f'TauFastTrackHypoAlg_PassBy{name}',
474 TracksKey=flags.Tracking.ActiveConfig.tracks_FTF,
475 ))
476
477
478 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
479 # based on the partDict for each chain tau leg
480 from TrigTauHypo.TrigTauHypoTool import TrigTauTrackingHypoToolFromDict
481 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauTrackingHypoToolFromDict)
482
483 return menuSeq
484
485
486
487#================================================================
488# Precision Tracking step
489#================================================================
490
491@AccumulatorCache
492def tauPrecTrackSequenceGenCfg(orig_flags: AthConfigFlags, calohits_seq_name: str | None = None, do_lrt: bool = False, is_probe_leg: bool = False) -> MenuSequence:
493 '''Precision Tracking step sequence, for both the tauIso and tauLRT RoIs'''
494
495 if do_lrt:
496 name = 'LRT'
497 tracking_cfg = 'tauLRT'
498 else:
499 name = 'Iso'
500 tracking_cfg = 'tauIso'
501
502 if calohits_seq_name:
503 name += f'_{calohits_seq_name}'
504 tracking_cfg += calohits_seq_name
505 input_rois = f'tauFastTrack{name}_{calohits_seq_name}'
506 else:
507 input_rois = f'tauFastTrack{name}'
508
509 # Retrieve tracking configuration
510 flags = getFlagsForActiveConfig(orig_flags, tracking_cfg, log)
511
512
513 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
514 # in parallel whenever possible, according to their data dependencies.
515 # Create the EventViews based on the RoIs created in the previous steps (tauIso and tauLRT)
516 recoAcc = InViewRecoCA(
517 name=f'tauPrecTrack{name}',
518 RoITool=CompFactory.ViewCreatorPreviousROITool(),
519 InViewRoIs=input_rois,
520 RequireParentView=True,
521 ViewFallThrough=True,
522 isProbe=is_probe_leg,
523 )
524 RoIs = recoAcc.inputMaker().InViewRoIs
525
526
527 # VDV with all the required collections/objects in the View
528 # (the VDV checks are disabled unless running with -l DEBUG)
529 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
530 name=f'{recoAcc.name}RecoVDV',
531 DataObjects={
532 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
533 ('SG::AuxElement', 'StoreGateSvc+EventInfo.averageInteractionsPerCrossing'),
534 }
535 ))
536
537
538 # Reconstruction tools/algorithms:
539
540 # Precision Tracking sequence (track extension to the TRT and refitting)
541 from TrigInDetConfig.TrigInDetConfig import trigInDetPrecisionTrackingCfg
542 recoAcc.mergeReco(trigInDetPrecisionTrackingCfg(flags, rois=RoIs, signatureName=tracking_cfg))
543
544 # Vertexing sequence
545 from TrigInDetConfig.TrigInDetConfig import trigInDetVertexingCfg
546 recoAcc.mergeReco(trigInDetVertexingCfg(flags, flags.Tracking.ActiveConfig.tracks_IDTrig, flags.Tracking.ActiveConfig.vertex))
547
548
549 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first,
550 # the reco CA (with all the reco algs) after, and the Hypo alg. at last
551 # Note: no need to prefetch anything from Pixel or SCT, since we already prefetched
552 # all the necesary information in the previous step
553 selAcc = SelectionCA(f'tauPT{name}', isProbe=is_probe_leg)
554 selAcc.mergeReco(recoAcc)
555
556
557 # Hypothesis:
558 # The hypothesis algorithm/tool does not perform any action (debug logging of number of tracks only)
559 selAcc.addHypoAlgo(CompFactory.TrigTauTrackingHypoAlg(
560 f'TauPrecTrackHypoAlg_PassBy{name}',
561 TracksKey=flags.Tracking.ActiveConfig.tracks_IDTrig,
562 ))
563
564
565 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
566 # based on the partDict for each chain tau leg
567 from TrigTauHypo.TrigTauHypoTool import TrigTauTrackingHypoToolFromDict
568 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauTrackingHypoToolFromDict)
569
570 return menuSeq
571
572
573
574#================================================================
575# Precision Tau step
576#================================================================
577
578@AccumulatorCache
579def tauPrecisionSequenceGenCfg(orig_flags: AthConfigFlags, seq_name: str, calohits_seq_name: str | None = None, output_name: str | None = None, do_lrt: bool = False, is_probe_leg: bool = False) -> MenuSequence:
580 '''Precision Tau step sequence, for all ID and reconstruction settings'''
581
582 orig_seq_name = seq_name
583 if output_name is None: output_name = orig_seq_name
584
585 if do_lrt:
586 tracking_cfg = 'tauLRT'
587 input_rois = 'tauFastTrackLRT'
588 else:
589 tracking_cfg = 'tauIso'
590 input_rois = 'tauFastTrackIso'
591
592 if calohits_seq_name:
593 seq_name += f'_{calohits_seq_name}'
594 tracking_cfg += calohits_seq_name
595 input_rois += f'_{calohits_seq_name}'
596 input_taus = 'HLT_TrigTauRecMerged_CaloHits'
597 input_tau_tracks = 'HLT_tautrack_CaloHits_dummy'
598 else:
599 input_taus = 'HLT_TrigTauRecMerged_CaloMVAOnly'
600 input_tau_tracks = 'HLT_tautrack_dummy'
601
602 # Retrieve tracking configuration
603 flags = getFlagsForActiveConfig(orig_flags, tracking_cfg, log)
604
605
606 # Get the list of TauIDs to execute
607 from TriggerMenuMT.HLT.Tau.TauConfigurationTools import getPrecisionSequenceTauIDs
608 tau_ids = getPrecisionSequenceTauIDs(flags, seq_name, orig_seq_name)
609
610
611 # Get the list of the decorated variables from the previous step taus to be copied to the new precision taus
612 decors_to_copy = []
613 from .TauConfigurationTools import getHitZAlgs, getHitZVariables, getCaloHitsPreselAlgs, getTauIDScoreVariables
614 if calohits_seq_name:
615 decors_to_copy += [var for alg in getHitZAlgs(flags, seq_name, orig_seq_name) for var in getHitZVariables(alg)]
616 decors_to_copy += [var for alg in getCaloHitsPreselAlgs(flags, seq_name, orig_seq_name) for var in getTauIDScoreVariables(alg)]
617
618
619 # Reconstruction sequence CA (parOR), executting all reco algorithms within the View (from the RoI)
620 # in parallel whenever possible, according to their data dependencies.
621 # Create the EventViews based on the RoIs created in the previous steps (tauIso and tauLRT)
622 recoAcc = InViewRecoCA(
623 name=f'tauPrecisionReco_{seq_name}',
624 RoITool=CompFactory.ViewCreatorPreviousROITool(),
625 InViewRoIs=input_rois,
626 RequireParentView=True,
627 ViewFallThrough=True,
628 isProbe=is_probe_leg,
629 )
630 RoIs = recoAcc.inputMaker().InViewRoIs
631
632
633 # VDV with all the required collections/objects in the View
634 # (the VDV checks are disabled unless running with -l DEBUG)
635 recoAcc.addRecoAlgo(CompFactory.AthViews.ViewDataVerifier(
636 name=f'{recoAcc.name}RecoVDV',
637 DataObjects={
638 ('TrigRoiDescriptorCollection', f'StoreGateSvc+{RoIs}'),
639 ('SG::AuxElement', 'StoreGateSvc+EventInfo.averageInteractionsPerCrossing'),
640 ('xAOD::VertexContainer', f'StoreGateSvc+{flags.Tracking.ActiveConfig.vertex}'),
641 ('xAOD::TrackParticleContainer', f'StoreGateSvc+{flags.Tracking.ActiveConfig.tracks_IDTrig}'),
642 ('xAOD::TauTrackContainer', f'StoreGateSvc+{input_tau_tracks}'),
643 ('xAOD::TauJetContainer', f'StoreGateSvc+{input_taus}'),
644 } | {
645 ('xAOD::TauJetContainer', f'StoreGateSvc+{input_taus}.{var}')
646 for var in decors_to_copy
647 }
648 ))
649
650
651 # Reconstruction tools/algorithms:
652
653 # Precision TauJet reconstruction sequence
654 from TrigTauRec.TrigTauRecConfig import trigTauRecMergedPrecisionMVACfg
655 recoAcc.mergeReco(trigTauRecMergedPrecisionMVACfg(
656 flags,
657 seq_name,
658 tau_ids=tau_ids,
659 input_rois=RoIs,
660 input_tracks=flags.Tracking.ActiveConfig.tracks_IDTrig,
661 input_taus=input_taus,
662 input_tau_tracks=input_tau_tracks,
663 output_name=output_name,
664 decors_to_copy=decors_to_copy,
665 ))
666
667
668 # Selection sequence CA (seqAND), executing the recoAcc view creation alg. first,
669 # the reco CA (with all the reco algs) after, and the Hypo alg. at last (no ROB prefetching)
670 selAcc = SelectionCA(f'tauPrecision_{seq_name}', isProbe=is_probe_leg)
671 selAcc.mergeReco(recoAcc)
672
673
674 # Hypothesis:
675 # The Hypotools in the Hypo algorithm will execute the calibrated Tau pT cut,
676 # NTrack cut, NWideTrack cut, and ID WP selections (or meson variable cuts)
677 selAcc.addHypoAlgo(CompFactory.TrigTauJetHypoAlg(
678 f'TauPrecisionHypoAlg_{seq_name}',
679 TauJetsKey=f'HLT_TrigTauRecMerged_{output_name}'
680 ))
681
682
683 # Menu sequence, connecting everything internally for the step, and configuring the tools for the Hypo alg.
684 # based on the partDict for each chain tau leg
685 from TrigTauHypo.TrigTauHypoTool import TrigTauPrecisionHypoToolFromDict
686 menuSeq = MenuSequence(flags, selAcc, HypoToolGen=TrigTauPrecisionHypoToolFromDict)
687
688 return menuSeq
MenuSequence tauCaloMVASequenceGenCfg(AthConfigFlags flags, bool is_probe_leg=False)
MenuSequence tauPrecisionSequenceGenCfg(AthConfigFlags orig_flags, str seq_name, str|None calohits_seq_name=None, str|None output_name=None, bool do_lrt=False, bool is_probe_leg=False)
tauFTFIsoSequenceGenCfg(AthConfigFlags orig_flags, str|None calohits_seq_name=None, bool is_probe_leg=False)
MenuSequence tauFTFCoreSequenceGenCfg(AthConfigFlags orig_flags, str|None calohits_seq_name=None, bool do_lrt=False, bool is_probe_leg=False)
MenuSequence tauPrecTrackSequenceGenCfg(AthConfigFlags orig_flags, str|None calohits_seq_name=None, bool do_lrt=False, bool is_probe_leg=False)
MenuSequence tauCaloHitsSequenceGenCfg(AthConfigFlags orig_flags, str seq_name, str precision_seq_name, tuple[str, float]|None hitz_config=None, bool is_probe_leg=False)