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',
'Bjet']
39 if not any(signature
in chain_dict[
'signatures']
for signature
in jet_signature_identifiers):
40 raise Exception(
"[trigJetHypoToolFromDict] No {} in {} for chain {}. Please update this list of jet signatures.".
format(tuple(jet_signature_identifiers),tuple(chain_dict[
'signatures']),chain_name))
45 for entry
in chain_dict[
'signatures']:
46 if status == 0
and entry
in jet_signature_identifiers:
48 elif status == 1
and entry
not in jet_signature_identifiers:
50 elif status == 2
and entry
in jet_signature_identifiers:
51 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_dict[
'signatures'])))
55 if not any(signature
in chain_dict[
'signatures'][leg_id]
for signature
in jet_signature_identifiers):
56 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_dict[
'signatures'])))
60 for signature
in jet_signature_identifiers:
61 if signature
in chain_dict[
'signatures']:
62 first_leg_index =
min(first_leg_index, chain_dict[
'signatures'].
index(signature))
64 if leg_id > first_leg_index:
65 logger.debug(
"Not returning a HypoTool for %s as this is not the first leg "
66 "with any of %s (leg signatures are %s)",
67 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict[
'signatures']))
68 raise NoHypoToolCreated(
"No HypoTool created for %s" % chain_name)
70 logger.debug(
"Returning a HypoTool for %s as this is the first leg with any of %s (leg signatures are %s)",
71 chain_name, tuple(jet_signature_identifiers), tuple(chain_dict[
'signatures']))
76 if any(
'jetMon:online' in group
for group
in chain_mg):
77 cpl = chain_dict[
"chainParts"]
80 histFlags += [ cp[
'recoAlg'] ] + [ cp[
'hypoScenario']]
86 return CompFactory.TrigJetTLAHypoTool(chain_dict[
'chainName'])
89 if len(chain_dict[
'chainParts']) > 1:
90 raise Exception(
"misconfiguration of emerging jet chain")
92 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
93 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
95 raise Exception(
"Unable to extract exotHypo emerging jet configuration from chain dict")
97 if 'emerging' in exot_hypo:
101 elif 'trackless' in exot_hypo:
106 raise Exception(
"misconfiguration of emerging jet chain")
108 chain_name = chain_dict[
'chainName']
110 hypo = CompFactory.TrigJetEJsHypoTool(chain_name)
113 hypo.Trackless = trackless
118 chain_name = chain_dict[
'chainName']
122 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
123 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
124 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][0][
'exotHypo'][0])
125 if calratioX_matched:
127 ExoCalCut = calratioX_matched.groupdict()[
'cut']
129 if len(chain_dict[
'chainParts'][1][
'exotHypo']) > 0:
130 exot_hypo = chain_dict[
'chainParts'][1][
'exotHypo'][0]
131 logger.warning(chain_dict)
132 calratioX_matched = re.match(
r'.*calratiovar(?P<cut>\d{1,3}[\d\D]*)', chain_dict[
'chainParts'][1][
'exotHypo'][0])
133 if calratioX_matched:
135 ExoCalCut = calratioX_matched.groupdict()[
'cut']
137 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
138 if 'calratiovar' in exot_hypo:
139 if 'calratiovarrmbib' in exot_hypo:
142 raise Exception(
"misconfiguration of new calratio jet chain")
144 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][0][
'trkpresel'])
146 emf_cut = presel_matched.groupdict()[
'cut']
147 elif len(chain_dict[
'chainParts'])>1:
148 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][1][
'trkpresel'])
150 emf_cut = presel_matched.groupdict()[
'cut']
151 elif len(chain_dict[
'chainParts'])>3:
152 presel_matched = re.match(
r'.*emf(?P<cut>\d?\d?[\d\D]+)', chain_dict[
'chainParts'][3][
'trkpresel'])
154 emf_cut = presel_matched.groupdict()[
'cut']
156 raise Exception(
"misconfiguration of Exotic jet chain")
158 raise Exception(
"misconfiguration of Exotic jet chain")
161 hypo = CompFactory.TrigJetCRVARHypoTool(chain_name)
162 hypo.MpufixLogRatio = math.log10(1./(
float(emf_cut)*0.01) - 1.)
163 hypo.MinjetlogR = 1.2
165 hypo.MinjetlogR = (
float(ExoCalCut)*0.01) - 1.
166 hypo.MintrackPt = 2*GeV
168 hypo.countBIBcells = 4
169 hypo.doBIBremoval = doBIBrm
174 chain_name = chain_dict[
'chainName']
177 if len(chain_dict[
'chainParts'][0][
'exotHypo']) > 0:
178 exot_hypo = chain_dict[
'chainParts'][0][
'exotHypo'][0]
180 raise Exception(
"Unable to extract exotHypo calratio jet configuration from chain dict")
181 if 'calratio' in exot_hypo
and (
'calratiovar' not in exot_hypo):
182 if 'calratiormbib' in exot_hypo:
185 raise Exception(
"misconfiguration of new calratio jet chain")
187 hypo = CompFactory.TrigJetCRHypoTool(chain_name)
188 hypo.MinjetlogR = 1.2
189 hypo.MintrackPt = 2*GeV
191 hypo.countBIBcells = 4
192 hypo.doBIBremoval = doBIBrm
199 from TriggerMenuMT.HLT.Config.Utility.DictFromChainName
import (
203 'HLT_j0_FBDJNOSHARED10etXX20etXX34massXX50fbet_L1J20',)
205 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
207 flags.Input.Files = []
211 wid =
max(len(c)
for c
in chain_names)
212 for chain_name
in chain_names:
215 self.assertIsNotNone(tool)
216 logger.debug(chain_name.rjust(wid),
str(tool))
220 if __name__ ==
'__main__':