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
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
51 acc = ComponentAccumulator()
52
53
54
55 vftools = []
56 tools_beforetf = []
57 tftools = []
58 tools = []
59 vvtools = []
60 idtools = []
61
62
63 from TrigTauRec.TrigTauRecToolsConfig import trigTauVertexFinderCfg, trigTauTrackFinderCfg, tauVertexVariablesCfg
64 from AthenaConfiguration.ComponentFactory import CompFactory
65
66
67 vftools.append(acc.popToolsAndMerge(trigTauVertexFinderCfg(flags, name='TrigTau_TauVertexFinder')))
68
69
70 tools_beforetf.append(CompFactory.TauAxisSetter(name='TrigTau_TauAxis', VertexCorrection=False))
71
72
73 tftools.append(acc.popToolsAndMerge(trigTauTrackFinderCfg(flags, name='TrigTauTightDZ_TauTrackFinder', TrackParticlesContainer=input_tracks)))
74
75
76 tools.append(CompFactory.TauClusterFinder(name='TrigTau_TauClusterFinder', UseOriginalCluster=False))
77 tools.append(CompFactory.TauVertexedClusterDecorator(name='TrigTau_TauVertexedClusterDecorator', SeedJet=''))
78
79
80 tools.append(CompFactory.TauCellVariables(name='TrigTau_CellVariables', VertexCorrection=False))
81
82
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
89 vvtools.append(acc.popToolsAndMerge(tauVertexVariablesCfg(flags, name='TrigTau_TauVertexVariables')))
90
91
92 idtools.append(CompFactory.TauCommonCalcVars(name='TrigTau_TauCommonCalcVars'))
93
94
95 idtools.append(CompFactory.TauSubstructureVariables(name='TrigTau_TauSubstructure', VertexCorrection=False))
96
97
98
99
100
101
102
103
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
110 used_builtin_rnnscore = False
111
112 for tau_id in tau_ids:
113
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
118 is_onnx = hasattr(id_flags, 'ONNXConfig')
119
120 if is_onnx:
121 log.debug('Configuring TrigTauRecMerged with the ONNX Tau ID score inference: %s', tau_id)
122
123
124 idtools.append(acc.popToolsAndMerge(trigTauJetONNXEvaluatorCfg(flags, tau_id=tau_id)))
125 acc.addPublicTool(idtools[-1])
126
127
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:
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
138
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
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
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
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