ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTauRecConfig Namespace Reference

Functions

ComponentAccumulator trigTauRecMergedPrecisionMVACfg (AthConfigFlags flags, str name, list[str]|None tau_ids=None, str input_rois='', str input_tracks='', str input_taus='', str input_tau_tracks='', str output_name='', list[str]|None decors_to_copy=None)
ComponentAccumulator trigTauRecMergedCaloHitsCfg (AthConfigFlags flags, str name, list[str]|None hitz_algs=None, list[str]|None presel_algs=None, str input_rois='')
ComponentAccumulator trigTauRecMergedCaloMVACfg (AthConfigFlags flags)

Variables

 log = logging.getLogger('TrigTauRecConfig')
 flags = initConfigFlags()
 Files
ComponentAccumulator acc = trigTauRecMergedCaloMVACfg(flags)
 withDetails
 True
 summariseProps

Function Documentation

◆ trigTauRecMergedCaloHitsCfg()

ComponentAccumulator TrigTauRecConfig.trigTauRecMergedCaloHitsCfg ( AthConfigFlags flags,
str name,
list[str] | None hitz_algs = None,
list[str] | None presel_algs = None,
str input_rois = '' )
Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.

:param flags: Config flags.
:param name: Suffix for the main TrigTauRecMerged algorithm name.
:param hitz_algs: List of hitz inference algorithms to execute, using the ONNX inference setup.
                The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>)
:param presel_algs: List of preselection inference algorithms to execute, using the ONNX inference setup.
                The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>).
                For these algorithms, the score flattening and WP decorator tools will be used.
:param input_rois: RoIs container, where the reconstruction will be run.

:return: CA with the TauJet Precision reconstruction sequence.

Definition at line 193 of file TrigTauRecConfig.py.

199) -> ComponentAccumulator:
200 '''
201 Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.
202
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.
211
212 :return: CA with the TauJet Precision reconstruction sequence.
213 '''
214 from TrigEDMConfig.TriggerEDM import recordable
215 output_taus = recordable('HLT_TrigTauRecMerged_CaloHits')
216 output_tau_tracks = 'HLT_tautrack_CaloHits_dummy'
217
218 # Main CA
219 acc = ComponentAccumulator()
220
221 from AthenaConfiguration.ComponentFactory import CompFactory
222
223 # Decorate pixel hits with their local position relative to the beamspot
224 acc.addEventAlgo(CompFactory.FlavorTagDiscriminants.HitBeamSpotDataDecoratorAlg(
225 name='TrigTauPixelHitsDecoratorAlg',
226 hitContainer='PixelClusters',
227 beamSpotKey='BeamSpotData', # Online beamspot conditions
228 ))
229
230
231 # Associate hits to the HLT TauJets
232 # We use the previous step's TauJets as input, because we will use the hits in the tools
233 # executed within TrigTauRecMerged
234
235 # We first need to figure out how many hits we'll need to associate
236 max_hits = 0
237
238 if hitz_algs is None: hitz_algs = []
239 if presel_algs is None: presel_algs = []
240 for alg in hitz_algs + presel_algs:
241 # First check that the algorithm has the necesary config flags defined
242 try: alg_flags = getattr(flags.Trigger.Offline.Tau, alg)
243 except NameError: raise ValueError(f'Missing algorithm ConfigFlags: Trigger.Offline.Tau.{alg}')
244
245 if hasattr(alg_flags, 'MaxHits') and alg_flags.MaxHits > max_hits:
246 max_hits = alg_flags.MaxHits
247
248 if max_hits > 0:
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,
258 dzHitToVertex=180, # Upper bound, still ok if the RoI is smaller
259 maxHits=max_hits,
260 removeBadIDPixelHits=False, # TODO: Test difference if enabled
261 ))
262 else:
263 hits_decoration = '' # Disabled
264
265
266 # The TauJet reconstruction is handled by a set of tools, executed in the following order:
267 tools = [] # Common tools
268
269 #---------------------------------------------------------------
270 # HitZ + CaloHits preselection inference
271 #---------------------------------------------------------------
272 # We can run multiple inferences at once. Each will be stored on different decorated variables
273
274 from TriggerMenuMT.HLT.Tau.TauConfigurationTools import getTauIDScoreVariables
275 hitz_monitoring = {}
276 id_score_monitoring = {}
277
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)
281
282 # ONNX inference
283 tools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(
284 flags,
285 tau_id=alg,
286 tau_container=output_taus,
287 hits_decoration_container=hits_decoration,
288 )))
289 acc.addPublicTool(tools[-1])
290
291 if alg in hitz_algs:
292 hitz_monitoring[alg] = getHitZVariables(alg)
293
294 if alg in presel_algs:
295 # ID score flattening and WPs
296 tools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=alg, precision_seq_name=name)))
297 acc.addPublicTool(tools[-1])
298
299 id_score_monitoring[alg] = getTauIDScoreVariables(alg)
300
301
302 # Set trigger-specific configuration for all the reconstruction tools
303 for tool in tools:
304 tool.inTrigger = True
305 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
306
307
308 from TrigTauRec.TrigTauRecMonitoring import tauMonitoringCaloHits
309 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
310 name=f'TrigTauRecMerged_CaloHits_{name}',
311 CommonTools=tools,
312 MonTool=tauMonitoringCaloHits(
313 flags,
314 f'CaloHits_{name}',
315 hitz_algs=hitz_monitoring.keys(),
316 tau_ids=id_score_monitoring.keys(),
317 ),
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,
325 ))
326
327 return acc
328
329
330

◆ trigTauRecMergedCaloMVACfg()

ComponentAccumulator TrigTauRecConfig.trigTauRecMergedCaloMVACfg ( AthConfigFlags flags)
Reconstruct the CaloMVA TauJet from the calo-clusters.

:param flags: Config flags.
:return: CA with the TauJet CaloMVA reconstruction sequence.

Definition at line 331 of file TrigTauRecConfig.py.

331def trigTauRecMergedCaloMVACfg(flags: AthConfigFlags) -> ComponentAccumulator:
332 '''
333 Reconstruct the CaloMVA TauJet from the calo-clusters.
334
335 :param flags: Config flags.
336 :return: CA with the TauJet CaloMVA reconstruction sequence.
337 '''
338 # Main CA
339 acc = ComponentAccumulator()
340
341 tools = []
342
343 from AthenaConfiguration.ComponentFactory import CompFactory
344
345 # Set seedcalo energy scale (Full RoI)
346 tools.append(CompFactory.JetSeedBuilder())
347
348 # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
349 tools.append(CompFactory.TauAxisSetter(ClusterCone=0.2, VertexCorrection=False))
350
351 # Decorate the clusters
352 tools.append(CompFactory.TauClusterFinder(UseOriginalCluster=False)) # TODO: use JetRec.doVertexCorrection once available
353 tools.append(CompFactory.TauVertexedClusterDecorator(SeedJet=''))
354
355 # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
356 tools.append(CompFactory.TauCellVariables(CellCone=0.2, VertexCorrection = False))
357
358 # Compute MVA TES (ATR-17649), stores MVA TES as the default tau pt
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])
363
364
365 # Set trigger-specific configuration for all the reconstruction tools
366 for tool in tools:
367 tool.inTrigger = True
368 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
369
370
371 from TrigEDMConfig.TriggerEDM import recordable
372 from TrigTauRec.TrigTauRecMonitoring import tauMonitoringCaloOnlyMVA
373 acc.addEventAlgo(CompFactory.TrigTauRecMerged(
374 name='TrigTauRecMerged_TauCaloOnlyMVA',
375 CommonTools=tools,
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'),
382 ))
383
384 return acc
385
386
387

◆ trigTauRecMergedPrecisionMVACfg()

ComponentAccumulator TrigTauRecConfig.trigTauRecMergedPrecisionMVACfg ( AthConfigFlags flags,
str name,
list[str] | None tau_ids = None,
str input_rois = '',
str input_tracks = '',
str input_taus = '',
str input_tau_tracks = '',
str output_name = '',
list[str] | None decors_to_copy = None )
Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.

:param flags: Config flags.
:param name: Suffix for the main TrigTauRecMerged algorithm name.
:param tau_ids: List of inference algorithms to execute.
                The specific configuration will be loaded from the matching ConfigFlags (Trigger.Offline.Tau.<alg-name>)
                Currently, only the `DeepSet` and `RNNLLP` algorithms will use the LVNN inference setup (json config files);
                all other ID algorithms will use the ONNX inference setup by default.
                If the algorithm name (`name` input variable) is `MVA`, `LLP` or `LRT`, and `tau_ids=['DeepSet', 'MesonCuts']` or `tau_ids=['RNNLLP']`,
                then the default TauJet RNN score and WP `isTau` decorators will be used (for the legacy
                `mediumRNN/tightRNN_tracktwoMVA/tracktwoLLP/trackLRT` triggers).
                Otherwise, all scores and WPs will be stored as `{tau_id}_Score`, `{tau_id}_ScoreSigTrans`, and `{tau_id}_{wp_name}`.
:param input_rois: RoIs container, where the reconstruction will be run.
:param input_tracks: TrackParticle container, with the refitted precision tracks.
:param input_taus: TauJet container, with the input tau jets.
:param input_tau_tracks: TauTrack container, with the input tau tracks (usually dummies from the CaloMVA or CaloHits steps).
:param output_name: Suffix for the output TauJet and TauTrack collections. If empty, `name` will be used.
:param decors_to_copy: List of decorated/aux variables to copy from the input to the output TauJet container.

:return: CA with the TauJet Precision reconstruction sequence.

Definition at line 10 of file TrigTauRecConfig.py.

20) -> ComponentAccumulator:
21 '''
22 Reconstruct the precision TauJet, from the first-step CaloMVA TauJet and precision-refitted tracks.
23
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.
40
41 :return: CA with the TauJet Precision reconstruction sequence.
42 '''
43
44 # Output collections
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}')
49
50 # Main CA
51 acc = ComponentAccumulator()
52
53
54 # The TauJet reconstruction is handled by a set of tools, executed in the following order:
55 vftools = [] # Vertex Finder tools
56 tools_beforetf = [] # Common tools, ran before the Track Finder tools
57 tftools = [] # Track Finder tools
58 tools = [] # Common tools
59 vvtools = [] # Vertex Vars tools
60 idtools = [] # ID tools
61
62
63 from TrigTauRec.TrigTauRecToolsConfig import trigTauVertexFinderCfg, trigTauTrackFinderCfg, tauVertexVariablesCfg
64 from AthenaConfiguration.ComponentFactory import CompFactory
65
66 # Associate RoI vertex or Beamspot to the tau - don't use TJVA
67 vftools.append(acc.popToolsAndMerge(trigTauVertexFinderCfg(flags, name='TrigTau_TauVertexFinder')))
68
69 # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
70 tools_beforetf.append(CompFactory.TauAxisSetter(name='TrigTau_TauAxis', VertexCorrection=False))
71
72 # Associate tracks to the tau
73 tftools.append(acc.popToolsAndMerge(trigTauTrackFinderCfg(flags, name='TrigTauTightDZ_TauTrackFinder', TrackParticlesContainer=input_tracks)))
74
75 # Decorate the clusters
76 tools.append(CompFactory.TauClusterFinder(name='TrigTau_TauClusterFinder', UseOriginalCluster=False))
77 tools.append(CompFactory.TauVertexedClusterDecorator(name='TrigTau_TauVertexedClusterDecorator', SeedJet=''))
78
79 # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
80 tools.append(CompFactory.TauCellVariables(name='TrigTau_CellVariables', VertexCorrection=False))
81
82 # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt
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])
87
88 # Vertex variables
89 vvtools.append(acc.popToolsAndMerge(tauVertexVariablesCfg(flags, name='TrigTau_TauVertexVariables')))
90
91 # Variables combining tracking and calorimeter information
92 idtools.append(CompFactory.TauCommonCalcVars(name='TrigTau_TauCommonCalcVars'))
93
94 # Cluster-based sub-structure, with dRMax
95 idtools.append(CompFactory.TauSubstructureVariables(name='TrigTau_TauSubstructure', VertexCorrection=False))
96
97 #---------------------------------------------------------------
98 # Tau ID and score flattenning
99 #---------------------------------------------------------------
100 # We can run multiple inferences at once. Each will be stored on different decorated variables
101 # (or isTau(...) flags in the case of the legacy RNN/DeepSet tracktwoMVA/LLP/LRT triggers
102
103 # We first "remove" the "ids" that don't require any inference, and any duplicates
104 tau_ids = sorted(list(set(tau_ids if tau_ids else []) - {'perf', 'idperf', 'MesonCuts'}))
105
106 from TriggerMenuMT.HLT.Tau.TauConfigurationTools import getTauIDScoreVariables
107 id_score_monitoring = {}
108
109 # We can only have at most one TauID algorithm score/WPs being stored in the built-in TauJet RNN variables
110 used_builtin_rnnscore = False
111
112 for tau_id in tau_ids:
113 # First check that the TauID algorithm has the necesary config flags defined
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}')
116
117 # Now check if it's an ONNX-based TauID, or an LVNN-based TauID
118 is_onnx = hasattr(id_flags, 'ONNXConfig')
119
120 if is_onnx: # ONNX inference
121 log.debug('Configuring TrigTauRecMerged with the ONNX Tau ID score inference: %s', tau_id)
122
123 # ONNX (GNTau) inference
124 idtools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(flags, tau_id=tau_id)))
125 acc.addPublicTool(idtools[-1])
126
127 # ID score flattening and WPs
128 idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=tau_id, precision_seq_name=name, tauContainerName=trigTauJetOutputContainer)))
129 acc.addPublicTool(idtools[-1])
130
131
132 else: # LVNN inference
133 log.debug('Configuring TrigTauRecMerged %s with the LVNN Tau ID score inference: %s', name, tau_id)
134
135 from TriggerMenuMT.HLT.Tau.TauConfigurationTools import useBuiltInTauJetRNNScore
136
137 # To support the legacy tracktwoMVA/LLP/LRT chains, only in those cases we store the
138 # passed WPs in the built-in TauJet variables
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')
143 raise ValueError()
144 used_builtin_rnnscore = True
145
146 # LVNN (RNN/DeepSet) inference
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])
150
151 # ID score flattening and WPs
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])
156 else:
157 idtools.append(acc.popToolsAndMerge(trigTauWPDecoratorCfg(flags, tau_id=tau_id, precision_seq_name=name, tauContainerName=trigTauJetOutputContainer)))
158 acc.addPublicTool(idtools[-1])
159
160 id_score_monitoring[tau_id] = getTauIDScoreVariables(tau_id)
161
162
163 # Set trigger-specific configuration for all the reconstruction tools
164 for tool in vftools + tools_beforetf + tftools + tools + vvtools + idtools:
165 tool.inTrigger = True
166 tool.calibFolder = flags.Trigger.Offline.Tau.tauRecToolsCVMFSPath
167
168
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,
175 CommonTools=tools,
176 VertexVarsTools=vvtools,
177 IDTools=idtools,
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,
187 ))
188
189 return acc
190
191
192
STL class.

Variable Documentation

◆ acc

ComponentAccumulator TrigTauRecConfig.acc = trigTauRecMergedCaloMVACfg(flags)

Definition at line 395 of file TrigTauRecConfig.py.

◆ Files

TrigTauRecConfig.Files

Definition at line 392 of file TrigTauRecConfig.py.

◆ flags

TrigTauRecConfig.flags = initConfigFlags()

Definition at line 391 of file TrigTauRecConfig.py.

◆ log

TrigTauRecConfig.log = logging.getLogger('TrigTauRecConfig')

Definition at line 8 of file TrigTauRecConfig.py.

◆ summariseProps

TrigTauRecConfig.summariseProps

Definition at line 396 of file TrigTauRecConfig.py.

◆ True

TrigTauRecConfig.True

Definition at line 396 of file TrigTauRecConfig.py.

◆ withDetails

TrigTauRecConfig.withDetails

Definition at line 396 of file TrigTauRecConfig.py.