3 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from TriggerMenuMT.HLT.Config.ControlFlow.HLTCFTools
import NoHypoToolCreated
7 from TrigHLTJetHypo.hypoConfigBuilder
import hypotool_from_chaindict
8 from TrigHLTJetHypo.TrigJetHypoMonitoringConfig
import TrigJetHypoToolMonitoring
9 from AthenaCommon.Logging
import logging
10 logger = logging.getLogger(__name__)
14 debug =
'JETHYPODEBUG' in os.environ
17 logger.setLevel(DEBUG)
22 from DecisionHandling.TrigCompositeUtils
import isLegId, getLegIndexInt
23 chain_name = chain_dict[
'chainName']
24 chain_mg = chain_dict[
'monGroups']
25 jet_signature_identifiers = [
'Jet:Jet',
'Bjet:Bjet',
'Tau:Ditau']
38 chain_sig_w_sub_sig = [f
'{sig}:{subsig}' for sig, subsigs
in chain_dict[
'sigDicts'].
items()
for subsig
in subsigs]
40 if not any(signature
in chain_sig_w_sub_sig
for signature
in jet_signature_identifiers):
41 raise Exception(
"[trigJetHypoToolFromDict] No {} in {} for chain {}. Please update this list of jet signatures.".
format(tuple(jet_signature_identifiers),tuple(chain_sig_w_sub_sig),chain_name))
46 for entry
in chain_sig_w_sub_sig:
47 if status == 0
and entry
in jet_signature_identifiers:
49 elif status == 1
and entry
not in jet_signature_identifiers:
51 elif status == 2
and entry
in jet_signature_identifiers:
52 raise Exception(
"[trigJetHypoToolFromDict] All {} legs should be contiguous in the signatures list, modify the ordering of the chain {}. Signatures:{}.".
format(tuple(jet_signature_identifiers),chain_name, tuple(chain_sig_w_sub_sig)))
56 if not any(signature
in chain_sig_w_sub_sig[leg_id]
for signature
in jet_signature_identifiers):
57 raise Exception(
"[trigJetHypoToolFromDict] For this code to work for chain {}, the signature at index {} must be one of {}. But the signature list is: {}".
format(chain_name,leg_id,tuple(jet_signature_identifiers),tuple(chain_sig_w_sub_sig)))
61 for signature
in jet_signature_identifiers:
62 if signature
in chain_sig_w_sub_sig:
63 first_leg_index =
min(first_leg_index, chain_sig_w_sub_sig.index(signature))
65 if leg_id > first_leg_index:
66 logger.debug(
"Not returning a HypoTool for %s as this is not the first leg "
67 "with any of %s (leg signatures are %s)",
68 chain_name, tuple(jet_signature_identifiers), tuple(chain_sig_w_sub_sig))
69 raise NoHypoToolCreated(
"No HypoTool created for %s" % chain_name)
71 logger.debug(
"Returning a HypoTool for %s as this is the first leg with any of %s (leg signatures are %s)",
72 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict[
'signatures']))
77 if any(
'jetMon:online' in group
for group
in chain_mg):
78 cpl = chain_dict[
"chainParts"]
81 histFlags += [ cp[
'recoAlg'] ] + [ cp[
'hypoScenario']]
87 return CompFactory.TrigJetTLAHypoTool(chain_dict[
'chainName'])
90 if len(chain_dict[
'chainParts']) > 1:
91 raise Exception(
"misconfiguration of emerging jet chain")
93 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
94 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
96 raise Exception(
"Unable to extract exotHypo emerging jet configuration from chain dict")
98 if 'emerging' in exot_hypo:
102 elif 'trackless' in exot_hypo:
107 raise Exception(
"misconfiguration of emerging jet chain")
109 chain_name = chain_dict[
'chainName']
111 hypo = CompFactory.TrigJetEJsHypoTool(chain_name)
114 hypo.Trackless = trackless
119 chain_name = chain_dict[
'chainName']
123 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
124 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
125 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][0][
'exotHypo'][0])
126 if calratioX_matched:
128 ExoCalCut = calratioX_matched.groupdict()[
'cut']
130 if len(chain_dict[
'chainParts'][1][
'exotHypo']) > 0:
131 exot_hypo = chain_dict[
'chainParts'][1][
'exotHypo'][0]
132 logger.warning(chain_dict)
133 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][1][
'exotHypo'][0])
134 if calratioX_matched:
136 ExoCalCut = calratioX_matched.groupdict()[
'cut']
138 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
139 if 'calratiovar' in exot_hypo:
140 if 'calratiovarrmbib' in exot_hypo:
143 raise Exception(
"misconfiguration of new calratio jet chain")
145 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][0][
'trkpresel'])
147 emf_cut = presel_matched.groupdict()[
'cut']
148 elif len(chain_dict[
'chainParts'])>1:
149 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][1][
'trkpresel'])
151 emf_cut = presel_matched.groupdict()[
'cut']
152 elif len(chain_dict[
'chainParts'])>3:
153 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][3][
'trkpresel'])
155 emf_cut = presel_matched.groupdict()[
'cut']
157 raise Exception(
"misconfiguration of Exotic jet chain")
159 raise Exception(
"misconfiguration of Exotic jet chain")
162 hypo = CompFactory.TrigJetCRVARHypoTool(chain_name)
163 hypo.MpufixLogRatio = math.log10(1./(
float(emf_cut)*0.01) - 1.)
164 hypo.MinjetlogR = 1.2
166 hypo.MinjetlogR = (
float(ExoCalCut)*0.01) - 1.
167 hypo.MintrackPt = 2*GeV
169 hypo.countBIBcells = 4
170 hypo.doBIBremoval = doBIBrm
175 chain_name = chain_dict[
'chainName']
178 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
179 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
181 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
182 if 'calratio' in exot_hypo
and (
'calratiovar' not in exot_hypo):
183 if 'calratiormbib' in exot_hypo:
186 raise Exception(
"misconfiguration of new calratio jet chain")
188 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
189 hypo.MinjetlogR = 1.2
190 hypo.MintrackPt = 2*GeV
192 hypo.countBIBcells = 4
193 hypo.doBIBremoval = doBIBrm
200 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName
import (
204 'HLT_j0_FBDJNOSHARED10etXX20etXX34massXX50fbet_L1J20',)
206 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
208 flags.Input.Files = []
212 wid =
max(len(c)
for c
in chain_names)
213 for chain_name
in chain_names:
216 self.assertIsNotNone(tool)
217 logger.debug(chain_name.rjust(wid),
str(tool))
221 if __name__ ==
'__main__':