6from AthenaConfiguration.AthConfigFlags
import AthConfigFlags
8from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainIDConfigName
9from .TrigTauHypoMonitoring
import getTrigTauPrecisionIDHypoToolMonitoring, getTrigTauPrecisionDiKaonHypoToolMonitoring
11from AthenaCommon.Logging
import logging
12log = logging.getLogger(
'TrigHLTTauHypoTool')
19 chainPart = chainDict[
'chainParts'][0]
21 identification = getChainIDConfigName(flags, chainPart)
23 if identification ==
'MesonCuts':
35 def __init__(self, flags, chain_part: dict[str, Any]):
36 self.
_id = getChainIDConfigName(flags, chain_part)
46 if self.
_id in [
'idperf',
'noperf',
'perfcore',
'perfiso',
'perf']:
51 if self.
_id in [
'DeepSet',
'RNNLLP']
and self.
_chain_part[
'selection'].endswith(
'RNN'):
58 id_wp = self.
_chain_part[
'selection'].removesuffix(self.
_id).lower()
62 if sfx
in [
'np',
'pc',
'pi']: id_wp = id_wp[:-2]
67 def find_wp(wp: str, fail: bool =
True) -> str:
68 for twp
in getattr(flags.Trigger.Offline.Tau, self.
_id).TargetWPs.keys():
69 if twp.lower() == wp:
return twp
71 if fail: ValueError(f
'Cannot find the "{self._id}" WP "{wp}"')
75 self.
_id_wp = find_wp(id_wp)
78 if id_wp.startswith(
'medium'): self.
_highpt_id_wp = find_wp(f
'loose{id_wp[6:]}',
True)
79 elif id_wp.startswith(
'tight'): self.
_highpt_id_wp = find_wp(f
'loose{id_wp[5:]}',
True)
94 if not self.
_id_wp:
return ''
96 return f
'{self._id}_{self._id_wp}'
102 return f
'{self._id}_{self._highpt_id_wp}'
106 '''TrigTauPrecisionIDHypoTool configuration for the standard Tau triggers'''
107 name = chainDict[
'chainName']
108 chainPart = chainDict[
'chainParts'][0]
109 cuts =
TauCuts(flags, chainPart)
112 from AthenaConfiguration.ComponentFactory
import CompFactory
113 currentHypo = CompFactory.TrigTauPrecisionIDHypoTool(
116 NTracksMax=cuts.n_track_max,
117 NIsoTracksMax=cuts.n_iso_track_max,
118 IDWP=cuts.id_wp_decor,
119 HighPtIDWP=cuts.highpt_id_wp_decor,
122 from TriggerMenuMT.HLT.Tau.TauConfigurationTools
import getChainPrecisionSeqName, useBuiltInTauJetRNNScore, getPrecisionSequenceTauIDs, getTauIDScoreVariables
124 id_score_monitoring = {}
126 precision_seq_name = getChainPrecisionSeqName(chainPart)
127 identification = getChainIDConfigName(flags, chainPart)
128 if identification
in [
'idperf',
'noperf',
'perf',
'perfcore',
'perfiso']:
129 if identification ==
'idperf':
131 currentHypo.AcceptAll =
True
134 used_builtin_rnnscore =
False
135 for tau_id
in getPrecisionSequenceTauIDs(flags, precision_seq_name):
137 if tau_id
in [
'MesonCuts']:
continue
140 if useBuiltInTauJetRNNScore(tau_id, precision_seq_name):
141 if used_builtin_rnnscore:
142 raise ValueError(
'Cannot have two TauID algorithms with scores stored in the built-in TauJet RNN score variables')
143 used_builtin_rnnscore =
True
145 id_score_monitoring[tau_id] = getTauIDScoreVariables(tau_id, precision_seq_name)
148 if useBuiltInTauJetRNNScore(identification, precision_seq_name):
151 currentHypo.IDMethod = 1
154 currentHypo.IDMethod = 2
157 id_score_monitoring[identification] = getTauIDScoreVariables(identification, precision_seq_name)
160 if chainPart[
'reconstruction'] ==
'tracktwoMVA':
161 currentHypo.TrackPtCut = 1.5*GeV
162 currentHypo.HighPtSelectionIDThr = 200*GeV
163 currentHypo.HighPtSelectionJetThr = 430*GeV
166 if 'tauMon:online' in chainDict[
'monGroups']:
167 currentHypo.MonTool = getTrigTauPrecisionIDHypoToolMonitoring(flags, name, id_score_monitoring.keys())
170 currentHypo.MonitoredIDScores = id_score_monitoring
178from collections
import namedtuple
180DiKaonCuts = namedtuple(
'DiKaonCuts',
'massTrkSysMin massTrkSysMax massTrkSysKaonMin massTrkSysKaonMax massTrkSysKaonPiMin massTrkSysKaonPiMax targetMassTrkSysKaonPi leadTrkPtMin PtMin EMPOverTrkSysPMax')
182 (
'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),
183 (
'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),
185 (
'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),
186 (
'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),
188 (
'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),
189 (
'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),
191 (
'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),
192 (
'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),
193 (
'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),
194 (
'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),
197SinglePionCuts = namedtuple(
'SinglePionCuts',
'leadTrkPtMin PtMin NTracksMax NIsoTracksMax dRmaxMax etOverPtLeadTrkMin etOverPtLeadTrkMax')
198thresholds_singlepion = {
199 (
'singlepion', 25):
SinglePionCuts(30.0*GeV, 25.0*GeV, 1, 0, 0.06, 0.4, 0.85),
203 '''TrigTauPrecisionDiKaonHypoTool configuration for the meson cut-based Tau triggers (ATR-22644)'''
204 name = chainDict[
'chainName']
205 chainPart = chainDict[
'chainParts'][0]
208 from AthenaConfiguration.ComponentFactory
import CompFactory
209 currentHypo = CompFactory.TrigTauPrecisionDiKaonHypoTool(name)
211 key = (chainPart[
'selection'], int(chainPart[
'threshold']))
212 if key
in thresholds_dikaon:
213 thr = thresholds_dikaon[key]
214 currentHypo.PtMin = thr.PtMin
215 currentHypo.leadTrkPtMin = thr.leadTrkPtMin
216 currentHypo.massTrkSysMin = thr.massTrkSysMin
217 currentHypo.massTrkSysMax = thr.massTrkSysMax
218 currentHypo.massTrkSysKaonMin = thr.massTrkSysKaonMin
219 currentHypo.massTrkSysKaonMax = thr.massTrkSysKaonMax
220 currentHypo.massTrkSysKaonPiMin = thr.massTrkSysKaonPiMin
221 currentHypo.massTrkSysKaonPiMax = thr.massTrkSysKaonPiMax
222 currentHypo.targetMassTrkSysKaonPi = thr.targetMassTrkSysKaonPi
223 currentHypo.EMPOverTrkSysPMax = thr.EMPOverTrkSysPMax
225 elif key
in thresholds_singlepion:
226 thr = thresholds_singlepion[key]
227 currentHypo.PtMin = thr.PtMin
228 currentHypo.NTracksMax = thr.NTracksMax
229 currentHypo.NIsoTracksMax = thr.NIsoTracksMax
230 currentHypo.leadTrkPtMin = thr.leadTrkPtMin
231 currentHypo.dRmaxMax = thr.dRmaxMax
232 currentHypo.etOverPtLeadTrkMin = thr.etOverPtLeadTrkMin
233 currentHypo.etOverPtLeadTrkMax = thr.etOverPtLeadTrkMax
235 currentHypo.MonTool = getTrigTauPrecisionDiKaonHypoToolMonitoring(flags, name)
245 name = chainDict[
'chainName']
247 from AthenaConfiguration.ComponentFactory
import CompFactory
248 currentHypo = CompFactory.TrigTauTrackingHypoTool(name)
258 name = chainDict[
'chainName']
259 threshold = float(chainDict[
'chainParts'][0][
'threshold'])
261 from AthenaConfiguration.ComponentFactory
import CompFactory
262 currentHypo = CompFactory.TrigTauCaloHypoTool(name)
263 currentHypo.PtMin = threshold * GeV