ATLAS Offline Software
Loading...
Searching...
No Matches
python.HLT.Tau.TauConfigurationTools Namespace Reference

Functions

list[strgetMenuAlgs (AthConfigFlags flags, str|None key=None, str|None alt_key=None, dict[str, list[str]]|list[str]|None algs=None, dict[str, list[str]]|list[str]|None mc_algs=None, dict[str, list[str]]|list[str]|None dev_algs=None)
 Global helper functions.
bool useBuiltInTauJetRNNScore (str tau_id)
tuple[str, strgetTauIDScoreVariables (str tau_id)
str getTauIDAlgorithm (AthConfigFlags flags, str selection, tuple[tuple[str, str],...]|None name_mapping=None)
list[strgetHitZAlgs (AthConfigFlags flags, str precision_sequence, str|None alt_precision_sequence=None)
 CaloHits sequence algorithms.
tuple[str, float]|None getHitZConfig (AthConfigFlags flags, dict[str, Any] chainPart)
tuple[str, strgetHitZVariables (str alg)
list[strgetCaloHitsPreselAlgs (AthConfigFlags flags, str precision_sequence, str|None alt_precision_sequence=None)
str getChainCaloHitsPreselConfigName (AthConfigFlags flags, dict[str, Any] chainPart)
str|None getChainCaloHitsSeqName (dict[str, Any] chainPart)
list[strgetPrecisionSequenceTauIDs (AthConfigFlags flags, str precision_sequence, str|None alt_precision_sequence=None)
 Precision sequence TauIDs.
str getChainIDConfigName (AthConfigFlags flags, dict[str, Any] chainPart)
str getChainPrecisionSeqName (dict[str, Any] chainPart, bool include_calohits_seq_name=False)
str getChainSequenceConfigName (dict[str, Any] chainPart)
 Global Tau menu sequence.

Variables

 log = logging.getLogger(__name__)
list rnn_wps = ['verylooseRNN', 'looseRNN', 'mediumRNN', 'tightRNN']
list noid_selections = ['perf', 'idperf']
list meson_selections = ['kaonpi1', 'kaonpi2', 'dipion1', 'dipion2', 'dipion3', 'dipion4', 'dikaonmass', 'singlepion']

Function Documentation

◆ getCaloHitsPreselAlgs()

list[str] python.HLT.Tau.TauConfigurationTools.getCaloHitsPreselAlgs ( AthConfigFlags flags,
str precision_sequence,
str | None alt_precision_sequence = None )
Get the list of CaloHits preselection TauID inferences to be executed for the CaloHits reco sequence.
The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.

Definition at line 132 of file TauConfigurationTools.py.

132def getCaloHitsPreselAlgs(flags: AthConfigFlags, precision_sequence: str, alt_precision_sequence: str | None = None) -> list[str]:
133 '''
134 Get the list of CaloHits preselection TauID inferences to be executed for the CaloHits reco sequence.
135 The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.
136 '''
137 return getMenuAlgs(
138 flags,
139 key=precision_sequence,
140 alt_key=alt_precision_sequence,
141
142 # Default inferences to run in all menus
143 algs=[],
144
145 # Additional inferences to run ONLY if we're using the MC (or Dev) menu
146 mc_algs=[],
147
148 # Additional inferences to run ONLY if we're using the Dev menu
149 dev_algs=[],
150 )
151
152

◆ getChainCaloHitsPreselConfigName()

str python.HLT.Tau.TauConfigurationTools.getChainCaloHitsPreselConfigName ( AthConfigFlags flags,
dict[str, Any] chainPart )
Clean the CaloHits preselection configuration for a chainPart dict

Definition at line 153 of file TauConfigurationTools.py.

153def getChainCaloHitsPreselConfigName(flags: AthConfigFlags, chainPart: dict[str, Any]) -> str:
154 '''Clean the CaloHits preselection configuration for a chainPart dict'''
155 sel = chainPart['calohitsPresel']
156
157 if not sel or sel == 'idperfCHP': return 'idperf' # No preselection
158
159 return getTauIDAlgorithm(
160 flags,
161 sel,
162 name_mapping=(('CHTP', 'GNCaloHitsTauPresel')),
163 )
164
165

◆ getChainCaloHitsSeqName()

str | None python.HLT.Tau.TauConfigurationTools.getChainCaloHitsSeqName ( dict[str, Any] chainPart)
Get the HLT Tau CaloHits sequence name suffix

Definition at line 166 of file TauConfigurationTools.py.

166def getChainCaloHitsSeqName(chainPart: dict[str, Any]) -> str | None:
167 '''Get the HLT Tau CaloHits sequence name suffix'''
168 if not chainPart['hitz'] and not chainPart['calohitsPresel']: return None
169
170 parts = []
171
172 # HitZ RoI updating selection
173 if chainPart['hitz']: parts.append(chainPart['hitz'])
174
175 if not parts: parts = ['CaloHitsBase']
176 return '_'.join(parts)
177
178
179

◆ getChainIDConfigName()

str python.HLT.Tau.TauConfigurationTools.getChainIDConfigName ( AthConfigFlags flags,
dict[str, Any] chainPart )
Clean the ID configuration for a chainPart dict

Definition at line 218 of file TauConfigurationTools.py.

218def getChainIDConfigName(flags: AthConfigFlags, chainPart: dict[str, Any]) -> str:
219 '''Clean the ID configuration for a chainPart dict'''
220 sel = chainPart['selection']
221
222 # Support for the Legacy trigger names:
223 if chainPart['reconstruction'] == 'tracktwoMVA':
224 if sel in rnn_wps:
225 return 'DeepSet'
226 elif sel in meson_selections:
227 return 'MesonCuts'
228 elif chainPart['reconstruction'] in ['tracktwoLLP', 'trackLRT'] and sel in rnn_wps:
229 return 'RNNLLP'
230
231 return getTauIDAlgorithm(
232 flags,
233 sel,
234 )
235
236 return sel
237
238

◆ getChainPrecisionSeqName()

str python.HLT.Tau.TauConfigurationTools.getChainPrecisionSeqName ( dict[str, Any] chainPart,
bool include_calohits_seq_name = False )
Get the HLT Tau Precision sequence name suffix.
This is also used for the HLT_TrigTauRecMerged_... and HLT_tautrack_... EDM collection names.

Definition at line 239 of file TauConfigurationTools.py.

239def getChainPrecisionSeqName(chainPart: dict[str, Any], include_calohits_seq_name: bool = False) -> str:
240 '''
241 Get the HLT Tau Precision sequence name suffix.
242 This is also used for the HLT_TrigTauRecMerged_... and HLT_tautrack_... EDM collection names.
243 '''
244 ret = chainPart['reconstruction']
245
246 # Support for the Legacy trigger names:
247 if ret == 'tracktwoMVA': return 'MVA'
248 elif ret == 'tracktwoLLP': return 'LLP'
249 elif ret == 'trackLRT': return 'LRT'
250
251 if include_calohits_seq_name:
252 calohits_seq = getChainCaloHitsSeqName(chainPart)
253 ret += f'_{calohits_seq}' if calohits_seq else ''
254
255 return ret
256
257
258

◆ getChainSequenceConfigName()

str python.HLT.Tau.TauConfigurationTools.getChainSequenceConfigName ( dict[str, Any] chainPart)

Global Tau menu sequence.

Get the HLT Tau signature global menu sequence name (e.g. ptonly, tracktwo, trackLRT, etc...)

Definition at line 263 of file TauConfigurationTools.py.

263def getChainSequenceConfigName(chainPart: dict[str, Any]) -> str:
264 '''Get the HLT Tau signature global menu sequence name (e.g. ptonly, tracktwo, trackLRT, etc...)'''
265 name = []
266
267 if chainPart['hitz'] or chainPart['calohitsPresel']:
268 name.append('CaloHits')
269
270 name.append(chainPart['reconstruction'])
271
272 return '_'.join(name)
273

◆ getHitZAlgs()

list[str] python.HLT.Tau.TauConfigurationTools.getHitZAlgs ( AthConfigFlags flags,
str precision_sequence,
str | None alt_precision_sequence = None )

CaloHits sequence algorithms.

Get the list of HitZ algorithms for the CaloHits reco sequence.
The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.

Definition at line 81 of file TauConfigurationTools.py.

81def getHitZAlgs(flags: AthConfigFlags, precision_sequence: str, alt_precision_sequence: str | None = None) -> list[str]:
82 '''
83 Get the list of HitZ algorithms for the CaloHits reco sequence.
84 The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.
85 '''
86 return getMenuAlgs(
87 flags,
88 key=precision_sequence,
89 alt_key=alt_precision_sequence,
90
91 # Default HitZ algorithms to run in all menus
92 algs=['HitZ'],
93
94 # Additional HitZ algorithms to run ONLY if we're using the MC (or Dev) menu
95 mc_algs={},
96
97 # Additional HitZ algorithms to run ONLY if we're using the Dev menu
98 dev_algs={},
99 )
100
101

◆ getHitZConfig()

tuple[str, float] | None python.HLT.Tau.TauConfigurationTools.getHitZConfig ( AthConfigFlags flags,
dict[str, Any] chainPart )
Get the HLT HitZ configuration tuple: (algorithm name, sigma cut value in mm)

Definition at line 102 of file TauConfigurationTools.py.

102def getHitZConfig(flags: AthConfigFlags, chainPart: dict[str, Any]) -> tuple[str, float] | None:
103 '''
104 Get the HLT HitZ configuration tuple: (algorithm name, sigma cut value in mm)
105 '''
106 if not chainPart['hitz']: return None
107
108 import re
109 # Match strings of the form: '10mmX5mmHitZ', '5mmHitZ', 'HitZ', etc...
110 match = re.match(r'((?P<sigma>(\d|p)+)mm)?(X(\d|p)+mm)?(?P<alg>.+)', chainPart['hitz'])
111 if match:
112 alg = match.group('alg')
113
114 alg_flags = getattr(flags.Trigger.Offline.Tau, alg, None)
115 if alg_flags is None:
116 raise ValueError(f'HitZ algorithm "{alg}" configuration not found in flags.Trigger.Offline.Tau.{alg}')
117
118 sigma = match.group('sigma')
119 if sigma is None: sigma = alg_flags.DefaultMaxZ0Sigma # mm (default value)
120 else: sigma = float(sigma.replace('p', '.')) # mm
121
122 return (alg, sigma)
123
124 raise ValueError(f'Invalid HitZ configuration string: {chainPart["hitz"]}')
125
126

◆ getHitZVariables()

tuple[str, str] python.HLT.Tau.TauConfigurationTools.getHitZVariables ( str alg)
Return the (z, sigma) variable name pair for a given HitZ algorithm

Definition at line 127 of file TauConfigurationTools.py.

127def getHitZVariables(alg: str) -> tuple[str, str]:
128 '''Return the (z, sigma) variable name pair for a given HitZ algorithm'''
129 return (f'{alg}_z0', f'{alg}_z0_sigma')
130
131

◆ getMenuAlgs()

list[str] python.HLT.Tau.TauConfigurationTools.getMenuAlgs ( AthConfigFlags flags,
str | None key = None,
str | None alt_key = None,
dict[str, list[str]] | list[str] | None algs = None,
dict[str, list[str]] | list[str] | None mc_algs = None,
dict[str, list[str]] | list[str] | None dev_algs = None )

Global helper functions.

Get the list of algorithms for a specific menu key; if not found, the alternate key will be tried if provided.

Definition at line 16 of file TauConfigurationTools.py.

23) -> list[str]:
24 '''Get the list of algorithms for a specific menu key; if not found, the alternate key will be tried if provided.'''
25 def _getAlgs(key: str | None):
26 if algs is None: ret = None
27 elif isinstance(algs, dict): ret = algs[key] if key in algs else None
28 else: ret = algs # list
29 if any(pfx in flags.Trigger.triggerMenuSetup for pfx in ['MC_', 'Dev_']) and mc_algs and (isinstance(mc_algs, list) or key in mc_algs):
30 if ret is None: ret = []
31 ret += mc_algs[key] if isinstance(mc_algs, dict) else mc_algs
32 if 'Dev_' in flags.Trigger.triggerMenuSetup and dev_algs and (isinstance(dev_algs, list) or key in dev_algs):
33 if ret is None: ret = []
34 ret += dev_algs[key] if isinstance(dev_algs, dict) else dev_algs
35 return ret
36
37 ret_algs = _getAlgs(key)
38 if ret_algs is None and alt_key is not None:
39 ret_algs = _getAlgs(alt_key)
40 return ret_algs
41
42
43

◆ getPrecisionSequenceTauIDs()

list[str] python.HLT.Tau.TauConfigurationTools.getPrecisionSequenceTauIDs ( AthConfigFlags flags,
str precision_sequence,
str | None alt_precision_sequence = None )

Precision sequence TauIDs.

Get the list of precision TauID inferences to be executed for each HLT tau trigger reco sequence
The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.

Definition at line 184 of file TauConfigurationTools.py.

184def getPrecisionSequenceTauIDs(flags: AthConfigFlags, precision_sequence: str, alt_precision_sequence: str | None = None) -> list[str]:
185 '''
186 Get the list of precision TauID inferences to be executed for each HLT tau trigger reco sequence
187 The configuration for each algorithm is contained in flags.Trigger.Offline.Tau.<alg>.
188 '''
189 return getMenuAlgs(
190 flags,
191 key=precision_sequence,
192 alt_key=alt_precision_sequence,
193
194 # Default Tau ID algorithms to run in all menus
195 algs={
196 'MVA': ['GNTau', 'MesonCuts', 'GNTauDev1'],
197 'LLP': ['RNNLLP'],
198 'LRT': ['RNNLLP'],
199 },
200
201 # Additional Tau ID algorithms to run ONLY if we're using the MC (or Dev) menu
202 mc_algs={
203 'MVA': ['DeepSet'],
204 },
205
206 # Additional Tau ID algorithms to run ONLY if we're using the Dev menu
207 dev_algs={
208 }
209 )
210
211
212# The following functions are only required while we still have triggers
213# with the RNN/DeepSet naming scheme in the Menu (e.g. mediumRNN_tracktwoMVA/LLP)

◆ getTauIDAlgorithm()

str python.HLT.Tau.TauConfigurationTools.getTauIDAlgorithm ( AthConfigFlags flags,
str selection,
tuple[tuple[str, str], ...] | None name_mapping = None )

Definition at line 59 of file TauConfigurationTools.py.

60 name_mapping: tuple[tuple[str, str], ...] | None = None) -> str:
61
62 # Sort ID names from longest to shortest, to check for a full match
63 tau_ids = sorted(flags.Trigger.Offline.Tau, key=len, reverse=True)
64 for tau_id in tau_ids:
65 if selection.endswith(tau_id): return tau_id
66
67 # Remap names (e.g. DS -> DeepSet)
68 if name_mapping:
69 name_mapping = sorted(name_mapping, key=lambda p: len(p[0]), reverse=True)
70 for short_name, long_name in name_mapping:
71 if selection.endswith(short_name): return long_name
72
73 return selection
74
75
76

◆ getTauIDScoreVariables()

tuple[str, str] python.HLT.Tau.TauConfigurationTools.getTauIDScoreVariables ( str tau_id)
Return the (score, score_sig_trans) variable name pair for a given TauID/Sequence configuration

Definition at line 50 of file TauConfigurationTools.py.

50def getTauIDScoreVariables(tau_id: str) -> tuple[str, str]:
51 '''Return the (score, score_sig_trans) variable name pair for a given TauID/Sequence configuration'''
52 # Support for "legacy" algorithms, where the scores are stored in the built-in TauJet aux variables
53 if useBuiltInTauJetRNNScore(tau_id): return ('RNNJetScore', 'RNNJetScoreSigTrans')
54
55 return (f'{tau_id}_Score', f'{tau_id}_ScoreSigTrans')
56
57
58@AccumulatorCache # called many times and looping over flags is slow

◆ useBuiltInTauJetRNNScore()

bool python.HLT.Tau.TauConfigurationTools.useBuiltInTauJetRNNScore ( str tau_id)
Check if the TauJet's built-in RNN score and WP variables have to be used, instead of the decorator-based variables

Definition at line 44 of file TauConfigurationTools.py.

44def useBuiltInTauJetRNNScore(tau_id: str) -> bool:
45 '''Check if the TauJet's built-in RNN score and WP variables have to be used, instead of the decorator-based variables'''
46 # Support for "legacy" algorithms, where the scores are stored in the built-in TauJet aux variables
47 return tau_id in ['DeepSet', 'RNNLLP']
48
49

Variable Documentation

◆ log

python.HLT.Tau.TauConfigurationTools.log = logging.getLogger(__name__)

Definition at line 8 of file TauConfigurationTools.py.

◆ meson_selections

list python.HLT.Tau.TauConfigurationTools.meson_selections = ['kaonpi1', 'kaonpi2', 'dipion1', 'dipion2', 'dipion3', 'dipion4', 'dikaonmass', 'singlepion']

Definition at line 216 of file TauConfigurationTools.py.

◆ noid_selections

list python.HLT.Tau.TauConfigurationTools.noid_selections = ['perf', 'idperf']

Definition at line 215 of file TauConfigurationTools.py.

◆ rnn_wps

list python.HLT.Tau.TauConfigurationTools.rnn_wps = ['verylooseRNN', 'looseRNN', 'mediumRNN', 'tightRNN']

Definition at line 214 of file TauConfigurationTools.py.