42 from DecisionHandling.TrigCompositeUtils
import isLegId, getLegIndexInt
43 chain_name = chain_dict[
'chainName']
44 chain_mg = chain_dict[
'monGroups']
45 jet_signature_identifiers = [
'Jet:Jet',
'Bjet:Bjet',
'Tau:Ditau']
57 leg_id = getLegIndexInt(chain_name)
58 chain_sig_w_sub_sig = [f
'{sig}:{subsig}' for sig, subsigs
in chain_dict[
'sigDicts'].items()
for subsig
in subsigs]
60 if not any(signature
in chain_sig_w_sub_sig
for signature
in jet_signature_identifiers):
61 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))
66 for entry
in chain_sig_w_sub_sig:
67 if status == 0
and entry
in jet_signature_identifiers:
69 elif status == 1
and entry
not in jet_signature_identifiers:
71 elif status == 2
and entry
in jet_signature_identifiers:
72 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)))
76 if not any(signature
in chain_sig_w_sub_sig[leg_id]
for signature
in jet_signature_identifiers):
77 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)))
81 for signature
in jet_signature_identifiers:
82 if signature
in chain_sig_w_sub_sig:
83 first_leg_index =
min(first_leg_index, chain_sig_w_sub_sig.index(signature))
85 if leg_id > first_leg_index:
86 logger.debug(
"Not returning a HypoTool for %s as this is not the first leg "
87 "with any of %s (leg signatures are %s)",
88 chain_name, tuple(jet_signature_identifiers), tuple(chain_sig_w_sub_sig))
89 raise NoHypoToolCreated(
"No HypoTool created for %s" % chain_name)
91 logger.debug(
"Returning a HypoTool for %s as this is the first leg with any of %s (leg signatures are %s)",
92 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict[
'signatures']))
94 hypo_tool = hypotool_from_chaindict(chain_dict, debug)
97 if any(
'jetMon:online' in group
for group
in chain_mg):
98 cpl = chain_dict[
"chainParts"]
101 histFlags += [ cp[
'recoAlg'] ] + [ cp[
'hypoScenario']]
102 hypo_tool.MonTool = TrigJetHypoToolMonitoring(flags,
"HLTJetHypo/"+chain_name, histFlags)
110 if len(chain_dict[
'chainParts']) > 1:
111 raise Exception(
"misconfiguration of emerging jet chain")
113 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
114 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
116 raise Exception(
"Unable to extract exotHypo emerging jet configuration from chain dict")
118 if 'emerging' in exot_hypo:
120 ptf = float(exot_hypo.split(
'PTF')[1].
split(
'dR')[0].
replace(
'p',
'.'))
121 dr = float(exot_hypo.split(
'dR')[1].
split(
'_')[0].
replace(
'p',
'.'))
122 elif 'trackless' in exot_hypo:
125 dr = float(exot_hypo.split(
'dR')[1].
split(
'_')[0].
replace(
'p',
'.'))
127 raise Exception(
"misconfiguration of emerging jet chain")
129 chain_name = chain_dict[
'chainName']
131 hypo = CompFactory.TrigJetEJsHypoTool(chain_name)
134 hypo.Trackless = trackless
139 chain_name = chain_dict[
'chainName']
143 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
144 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
145 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][0][
'exotHypo'][0])
146 if calratioX_matched:
148 ExoCalCut = calratioX_matched.groupdict()[
'cut']
150 if len(chain_dict[
'chainParts'][1][
'exotHypo']) > 0:
151 exot_hypo = chain_dict[
'chainParts'][1][
'exotHypo'][0]
152 logger.warning(chain_dict)
153 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][1][
'exotHypo'][0])
154 if calratioX_matched:
156 ExoCalCut = calratioX_matched.groupdict()[
'cut']
158 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
159 if 'calratiovar' in exot_hypo:
160 if 'calratiovarrmbib' in exot_hypo:
163 raise Exception(
"misconfiguration of new calratio jet chain")
165 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][0][
'trkpresel'])
167 emf_cut = presel_matched.groupdict()[
'cut']
168 elif len(chain_dict[
'chainParts'])>1:
169 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][1][
'trkpresel'])
171 emf_cut = presel_matched.groupdict()[
'cut']
172 elif len(chain_dict[
'chainParts'])>3:
173 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][3][
'trkpresel'])
175 emf_cut = presel_matched.groupdict()[
'cut']
177 raise Exception(
"misconfiguration of Exotic jet chain")
179 raise Exception(
"misconfiguration of Exotic jet chain")
182 hypo = CompFactory.TrigJetCRVARHypoTool(chain_name)
183 hypo.MpufixLogRatio = math.log10(1./(float(emf_cut)*0.01) - 1.)
184 hypo.MinjetlogR = 1.2
186 hypo.MinjetlogR = (float(ExoCalCut)*0.01) - 1.
187 hypo.MintrackPt = 2*GeV
189 hypo.countBIBcells = 4
190 hypo.doBIBremoval = doBIBrm
195 chain_name = chain_dict[
'chainName']
198 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
199 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
201 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
202 if 'calratio' in exot_hypo
and (
'calratiovar' not in exot_hypo):
203 if 'calratiormbib' in exot_hypo:
206 raise Exception(
"misconfiguration of new calratio jet chain")
208 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
211 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
212 hypo.MinjetlogR = 1.2
219 emf_val = int(emf_cut) / 100.0
220 except (TypeError, ValueError):
222 "Invalid emf_cut '%s' for chain %s; using default MinjetlogR=%s",
223 emf_cut, chain_name, 1.2,
226 if not (0.0 < emf_val < 1.0):
228 "emf_cut '%s' -> %s out of (0,1) range for chain %s; using default MinjetlogR=%s",
229 emf_cut, emf_val, chain_name, 1.2,
233 hypo.MinjetlogR = math.log10(1.0 / emf_val - 1.0)
234 except (ValueError, OverflowError):
236 "Computed MinjetlogR invalid for emf_cut='%s' (emf_val=%s) in chain %s; using default %s",
237 emf_cut, emf_val, chain_name, 1.2,
240 hypo.MintrackPt = 2*GeV
242 hypo.countBIBcells = 4
243 hypo.doBIBremoval = doBIBrm