44 from DecisionHandling.TrigCompositeUtils
import isLegId, getLegIndexInt
45 chain_name = chain_dict[
'chainName']
46 chain_mg = chain_dict[
'monGroups']
47 jet_signature_identifiers = [
'Jet:Jet',
'Bjet:Bjet',
'Tau:Ditau']
59 leg_id = getLegIndexInt(chain_name)
60 chain_sig_w_sub_sig = [f
'{sig}:{subsig}' for sig, subsigs
in chain_dict[
'sigDicts'].items()
for subsig
in subsigs]
62 if not any(signature
in chain_sig_w_sub_sig
for signature
in jet_signature_identifiers):
63 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))
68 for entry
in chain_sig_w_sub_sig:
69 if status == 0
and entry
in jet_signature_identifiers:
71 elif status == 1
and entry
not in jet_signature_identifiers:
73 elif status == 2
and entry
in jet_signature_identifiers:
74 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)))
78 if not any(signature
in chain_sig_w_sub_sig[leg_id]
for signature
in jet_signature_identifiers):
79 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)))
83 for signature
in jet_signature_identifiers:
84 if signature
in chain_sig_w_sub_sig:
85 first_leg_index =
min(first_leg_index, chain_sig_w_sub_sig.index(signature))
87 if leg_id > first_leg_index:
88 logger.debug(
"Not returning a HypoTool for %s as this is not the first leg "
89 "with any of %s (leg signatures are %s)",
90 chain_name, tuple(jet_signature_identifiers), tuple(chain_sig_w_sub_sig))
91 raise NoHypoToolCreated(
"No HypoTool created for %s" % chain_name)
93 logger.debug(
"Returning a HypoTool for %s as this is the first leg with any of %s (leg signatures are %s)",
94 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict[
'signatures']))
96 hypo_tool = hypotool_from_chaindict(chain_dict, debug)
99 if any(
'jetMon:online' in group
for group
in chain_mg):
100 cpl = chain_dict[
"chainParts"]
103 histFlags += [ cp[
'recoAlg'] ] + [ cp[
'hypoScenario']]
104 hypo_tool.MonTool = TrigJetHypoToolMonitoring(flags,
"HLTJetHypo/"+chain_name, histFlags)
112 if len(chain_dict[
'chainParts']) > 1:
113 raise Exception(
"misconfiguration of emerging jet chain")
115 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
116 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
118 raise Exception(
"Unable to extract exotHypo emerging jet configuration from chain dict")
120 if 'emerging' in exot_hypo:
122 ptf = float(exot_hypo.split(
'PTF')[1].
split(
'dR')[0].
replace(
'p',
'.'))
123 dr = float(exot_hypo.split(
'dR')[1].
split(
'_')[0].
replace(
'p',
'.'))
124 elif 'trackless' in exot_hypo:
127 dr = float(exot_hypo.split(
'dR')[1].
split(
'_')[0].
replace(
'p',
'.'))
129 raise Exception(
"misconfiguration of emerging jet chain")
131 chain_name = chain_dict[
'chainName']
133 hypo = CompFactory.TrigJetEJsHypoTool(chain_name)
136 hypo.Trackless = trackless
141 chain_name = chain_dict[
'chainName']
145 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
146 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
147 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][0][
'exotHypo'][0])
148 if calratioX_matched:
150 ExoCalCut = calratioX_matched.groupdict()[
'cut']
152 if len(chain_dict[
'chainParts'][1][
'exotHypo']) > 0:
153 exot_hypo = chain_dict[
'chainParts'][1][
'exotHypo'][0]
154 logger.warning(chain_dict)
155 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][1][
'exotHypo'][0])
156 if calratioX_matched:
158 ExoCalCut = calratioX_matched.groupdict()[
'cut']
160 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
161 if 'calratiovar' in exot_hypo:
162 if 'calratiovarrmbib' in exot_hypo:
165 raise Exception(
"misconfiguration of new calratio jet chain")
167 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][0][
'trkpresel'])
169 emf_cut = presel_matched.groupdict()[
'cut']
170 elif len(chain_dict[
'chainParts'])>1:
171 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][1][
'trkpresel'])
173 emf_cut = presel_matched.groupdict()[
'cut']
174 elif len(chain_dict[
'chainParts'])>3:
175 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][3][
'trkpresel'])
177 emf_cut = presel_matched.groupdict()[
'cut']
179 raise Exception(
"misconfiguration of Exotic jet chain")
181 raise Exception(
"misconfiguration of Exotic jet chain")
184 hypo = CompFactory.TrigJetCRVARHypoTool(chain_name)
185 hypo.MpufixLogRatio = math.log10(1./(float(emf_cut)*0.01) - 1.)
186 hypo.MinjetlogR = 1.2
188 hypo.MinjetlogR = (float(ExoCalCut)*0.01) - 1.
189 hypo.MintrackPt = 2*GeV
191 hypo.countBIBcells = 4
192 hypo.doBIBremoval = doBIBrm
197 chain_name = chain_dict[
'chainName']
200 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
201 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
203 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
204 if 'calratio' in exot_hypo
and (
'calratiovar' not in exot_hypo):
205 if 'calratiormbib' in exot_hypo:
208 raise Exception(
"misconfiguration of new calratio jet chain")
210 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
213 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
214 hypo.MinjetlogR = 1.2
221 emf_val = int(emf_cut) / 100.0
222 except (TypeError, ValueError):
224 "Invalid emf_cut '%s' for chain %s; using default MinjetlogR=%s",
225 emf_cut, chain_name, 1.2,
228 if not (0.0 < emf_val < 1.0):
230 "emf_cut '%s' -> %s out of (0,1) range for chain %s; using default MinjetlogR=%s",
231 emf_cut, emf_val, chain_name, 1.2,
235 hypo.MinjetlogR = math.log10(1.0 / emf_val - 1.0)
236 except (ValueError, OverflowError):
238 "Computed MinjetlogR invalid for emf_cut='%s' (emf_val=%s) in chain %s; using default %s",
239 emf_cut, emf_val, chain_name, 1.2,
242 hypo.MintrackPt = 2*GeV
244 hypo.countBIBcells = 4
245 hypo.doBIBremoval = doBIBrm