5from AthenaCommon.SystemOfUnits
import GeV
6from AthenaConfiguration.AthConfigFlags
import AthConfigFlags
8from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainIDConfigName
9from .TrigTauHypoMonitoring
import (
10 getTrigTauPrecisionIDHypoToolMonitoring, getTrigTauPrecisionDiKaonHypoToolMonitoring,
11 getTrigTauCaloHitsIDHypoToolMonitoring
14from AthenaCommon.Logging
import logging
15log = logging.getLogger(
'TrigHLTTauHypoTool')
22 chainPart = chainDict[
'chainParts'][0]
24 identification = getChainIDConfigName(flags, chainPart)
26 if identification ==
'MesonCuts':
38 def __init__(self, flags, chain_part: dict[str, Any]):
39 self.
_id = getChainIDConfigName(flags, chain_part)
49 if self.
_id in [
'idperf',
'noperf',
'perfcore',
'perfiso',
'perf']:
54 if self.
_id in [
'DeepSet',
'RNNLLP']
and self.
_chain_part[
'selection'].endswith(
'RNN'):
61 id_wp = self.
_chain_part[
'selection'].removesuffix(self.
_id).lower()
64 if id_wp.endswith(
'noperf'):
65 id_wp = id_wp.removesuffix(
'noperf')
67 elif id_wp.endswith(
'perfcore'):
68 id_wp = id_wp.removesuffix(
'perfcore')
70 elif id_wp.endswith(
'perfiso'):
71 id_wp = id_wp.removesuffix(
'perfiso')
75 def find_wp(wp: str, fail: bool =
True) -> str:
76 for twp
in getattr(flags.Trigger.Offline.Tau, self.
_id).TargetWPs.keys():
77 if twp.lower() == wp:
return twp
79 if fail: ValueError(f
'Cannot find the "{self._id}" WP "{wp}"')
83 self.
_id_wp = find_wp(id_wp)
86 if id_wp.startswith(
'medium'): self.
_highpt_id_wp = find_wp(f
'loose{id_wp[6:]}',
True)
87 elif id_wp.startswith(
'tight'): self.
_highpt_id_wp = find_wp(f
'loose{id_wp[5:]}',
True)
102 if not self.
_id_wp:
return ''
104 return f
'{self._id}_{self._id_wp}'
110 return f
'{self._id}_{self._highpt_id_wp}'
114 '''TrigTauPrecisionIDHypoTool configuration for the standard Tau triggers'''
115 name = chainDict[
'chainName']
116 chainPart = chainDict[
'chainParts'][0]
117 cuts =
TauCuts(flags, chainPart)
120 from AthenaConfiguration.ComponentFactory
import CompFactory
121 currentHypo = CompFactory.TrigTauPrecisionIDHypoTool(
124 NTracksMax=cuts.n_track_max,
125 NIsoTracksMax=cuts.n_iso_track_max,
126 IDWP=cuts.id_wp_decor,
127 HighPtIDWP=cuts.highpt_id_wp_decor,
130 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainPrecisionSeqName, useBuiltInTauJetRNNScore, getPrecisionSequenceTauIDs, getTauIDScoreVariables
132 id_score_monitoring = {}
134 precision_seq_name = getChainPrecisionSeqName(chainPart)
135 identification = getChainIDConfigName(flags, chainPart)
136 if identification
in [
'idperf',
'noperf',
'perf',
'perfcore',
'perfiso']:
137 if identification ==
'idperf':
139 currentHypo.AcceptAll =
True
142 used_builtin_rnnscore =
False
143 for tau_id
in getPrecisionSequenceTauIDs(flags, precision_seq_name):
145 if tau_id
in [
'MesonCuts']:
continue
148 if useBuiltInTauJetRNNScore(tau_id):
149 if used_builtin_rnnscore:
150 raise ValueError(
'Cannot have two TauID algorithms with scores stored in the built-in TauJet RNN score variables')
151 used_builtin_rnnscore =
True
153 id_score_monitoring[tau_id] = getTauIDScoreVariables(tau_id)
156 if useBuiltInTauJetRNNScore(identification):
159 currentHypo.IDMethod = 1
162 currentHypo.IDMethod = 2
165 id_score_monitoring[identification] = getTauIDScoreVariables(identification)
168 if chainPart[
'reconstruction'] ==
'tracktwoMVA':
169 currentHypo.TrackPtCut = 1.5*GeV
170 currentHypo.HighPtSelectionIDThr = 200*GeV
171 currentHypo.HighPtSelectionJetThr = 430*GeV
174 if 'tauMon:online' in chainDict[
'monGroups']:
175 currentHypo.MonTool = getTrigTauPrecisionIDHypoToolMonitoring(flags, name, id_score_monitoring.keys())
178 currentHypo.MonitoredIDScores = id_score_monitoring
186from collections
import namedtuple
188DiKaonCuts = namedtuple(
'DiKaonCuts',
'massTrkSysMin massTrkSysMax massTrkSysKaonMin massTrkSysKaonMax massTrkSysKaonPiMin massTrkSysKaonPiMax targetMassTrkSysKaonPi leadTrkPtMin PtMin EMPOverTrkSysPMax')
190 (
'dikaonmass', 25):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.987*GeV, 1.060*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 15.0*GeV, 25.0*GeV, 1.5),
191 (
'dikaonmass', 35):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.987*GeV, 1.060*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 25.0*GeV, 35.0*GeV, 1.5),
193 (
'kaonpi1', 25):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.79*GeV, 0.99*GeV, 0.89*GeV, 15.0*GeV, 25.0*GeV, 1.0),
194 (
'kaonpi1', 35):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.79*GeV, 0.99*GeV, 0.89*GeV, 25.0*GeV, 35.0*GeV, 1.0),
196 (
'kaonpi2', 25):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 1.8*GeV, 1.93*GeV, 1.865*GeV, 15.0*GeV, 25.0*GeV, 1.0),
197 (
'kaonpi2', 35):
DiKaonCuts(0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 1.8*GeV, 1.93*GeV, 1.865*GeV, 25.0*GeV, 35.0*GeV, 1.0),
199 (
'dipion1', 25):
DiKaonCuts(0.475*GeV, 1.075*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 15.0*GeV, 25.0*GeV, 1.0),
200 (
'dipion2', 25):
DiKaonCuts(0.460*GeV, 0.538*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 15.0*GeV, 25.0*GeV, 1.0),
201 (
'dipion3', 25):
DiKaonCuts(0.279*GeV, 0.648*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 25.0*GeV, 25.0*GeV, 2.2),
202 (
'dipion4', 25):
DiKaonCuts(0.460*GeV, 1.075*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 1000.0*GeV, 0.0*GeV, 15.0*GeV, 25.0*GeV, 1.0),
205SinglePionCuts = namedtuple(
'SinglePionCuts',
'leadTrkPtMin PtMin NTracksMax NIsoTracksMax dRmaxMax etOverPtLeadTrkMin etOverPtLeadTrkMax')
206thresholds_singlepion = {
207 (
'singlepion', 25):
SinglePionCuts(30.0*GeV, 25.0*GeV, 1, 0, 0.06, 0.4, 0.85),
211 '''TrigTauPrecisionDiKaonHypoTool configuration for the meson cut-based Tau triggers (ATR-22644)'''
212 name = chainDict[
'chainName']
213 chainPart = chainDict[
'chainParts'][0]
216 from AthenaConfiguration.ComponentFactory
import CompFactory
217 currentHypo = CompFactory.TrigTauPrecisionDiKaonHypoTool(name)
219 key = (chainPart[
'selection'], int(chainPart[
'threshold']))
220 if key
in thresholds_dikaon:
221 thr = thresholds_dikaon[key]
222 currentHypo.PtMin = thr.PtMin
223 currentHypo.leadTrkPtMin = thr.leadTrkPtMin
224 currentHypo.massTrkSysMin = thr.massTrkSysMin
225 currentHypo.massTrkSysMax = thr.massTrkSysMax
226 currentHypo.massTrkSysKaonMin = thr.massTrkSysKaonMin
227 currentHypo.massTrkSysKaonMax = thr.massTrkSysKaonMax
228 currentHypo.massTrkSysKaonPiMin = thr.massTrkSysKaonPiMin
229 currentHypo.massTrkSysKaonPiMax = thr.massTrkSysKaonPiMax
230 currentHypo.targetMassTrkSysKaonPi = thr.targetMassTrkSysKaonPi
231 currentHypo.EMPOverTrkSysPMax = thr.EMPOverTrkSysPMax
233 elif key
in thresholds_singlepion:
234 thr = thresholds_singlepion[key]
235 currentHypo.PtMin = thr.PtMin
236 currentHypo.NTracksMax = thr.NTracksMax
237 currentHypo.NIsoTracksMax = thr.NIsoTracksMax
238 currentHypo.leadTrkPtMin = thr.leadTrkPtMin
239 currentHypo.dRmaxMax = thr.dRmaxMax
240 currentHypo.etOverPtLeadTrkMin = thr.etOverPtLeadTrkMin
241 currentHypo.etOverPtLeadTrkMax = thr.etOverPtLeadTrkMax
243 currentHypo.MonTool = getTrigTauPrecisionDiKaonHypoToolMonitoring(flags, name)
253 name = chainDict[
'chainName']
255 from AthenaConfiguration.ComponentFactory
import CompFactory
256 currentHypo = CompFactory.TrigTauTrackingHypoTool(name)
266 name = chainDict[
'chainName']
267 chain_part = chainDict[
'chainParts'][0]
270 from AthenaConfiguration.ComponentFactory
import CompFactory
271 currentHypo = CompFactory.TrigTauPrecisionIDHypoTool(
273 HighPtSelectionIDThr=200*GeV,
274 HighPtSelectionJetThr=430*GeV,
277 id_score_monitoring = {}
279 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainCaloHitsPreselConfigName, getTauIDScoreVariables
280 id = getChainCaloHitsPreselConfigName(flags, chain_part)
282 currentHypo.AcceptAll =
True
285 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainPrecisionSeqName, getCaloHitsPreselAlgs
286 algs = getCaloHitsPreselAlgs(flags, getChainPrecisionSeqName(chain_part,
True), getChainPrecisionSeqName(chain_part))
289 id_score_monitoring[tau_id] = getTauIDScoreVariables(tau_id)
292 currentHypo.IDMethod = 2
294 id_wp = chain_part[
'calohitsPresel'].removesuffix(id).lower()
297 def find_wp(wp: str, fail: bool =
True) -> str:
298 for twp
in getattr(flags.Trigger.Offline.Tau, id).TargetWPs.keys():
299 if twp.lower() == wp:
return twp
301 if fail: ValueError(f
'Cannot find the "{id}" WP "{wp}"')
305 currentHypo.IDWP = find_wp(id_wp)
308 if id_wp.startswith(
'medium'): currentHypo.HighPtIDWP = find_wp(f
'loose{id_wp[6:]}',
True)
309 elif id_wp.startswith(
'tight'): currentHypo.HighPtIDWP = find_wp(f
'loose{id_wp[5:]}',
True)
312 id_score_monitoring[id] = getTauIDScoreVariables(id)
315 if 'tauMon:online' in chainDict[
'monGroups']:
316 currentHypo.MonTool = getTrigTauCaloHitsIDHypoToolMonitoring(flags, name, id_score_monitoring.keys())
319 currentHypo.MonitoredIDScores = id_score_monitoring
329 name = chainDict[
'chainName']
330 threshold = float(chainDict[
'chainParts'][0][
'threshold'])
332 from AthenaConfiguration.ComponentFactory
import CompFactory
333 currentHypo = CompFactory.TrigTauCaloHypoTool(name)
334 currentHypo.PtMin = threshold * GeV