3 from TrigHLTJetHypo.RepeatedConditionParams
import RepeatedConditionParams
4 from TrigHLTJetHypo.HelperConfigToolParams
import HelperConfigToolParams
5 from TrigHLTJetHypo.ConditionDefaults
import defaults
6 from TrigHLTJetHypo.make_treevec
import make_treevec
10 pattern_thresh_pt =
r'^DIJET'\
11 r'((?P<j12ptlo>\d*)j12pt(?P<j12pthi>\d*)XX|'\
12 r'(?P<j1ptlo>\d*)j1pt(?P<j1pthi>\d*)XX'\
13 r'(?P<j2ptlo>\d*)j2pt(?P<j2pthi>\d*)XX)'
16 pattern_thresh_et =
r'^DIJET'\
17 r'((?P<j12etlo>\d*)j12et(?P<j12ethi>\d*)XX|'\
18 r'(?P<j1etlo>\d*)j1et(?P<j1ethi>\d*)XX'\
19 r'(?P<j2etlo>\d*)j2et(?P<j2ethi>\d*)XX)'
22 pattern_common =
r'((?P<j12etalo>\d*)j12eta(?P<j12etahi>\d*)XX|'\
23 r'((?P<j1etalo>\d*)j1eta(?P<j1etahi>\d*)XX)?'\
24 r'((?P<j2etalo>\d*)j2eta(?P<j2etahi>\d*)XX)?)?'\
25 r'(?P<djmasslo>\d*)djmass(?P<djmasshi>\d*)'\
26 r'(XX(?P<djdphilo>\d*)djdphi(?P<djdphihi>\d*))?'\
27 r'(XX(?P<djdetalo>\d*)djdeta(?P<djdetahi>\d*))?$'
30 pattern_pt = pattern_thresh_pt + pattern_common
31 rgx_pt = re.compile(pattern_pt)
33 pattern_et = pattern_thresh_et + pattern_common
34 rgx_et = re.compile(pattern_et)
44 dj_keystubs =
set([k[:-2]
for k
in groupdict
if k.startswith(
'dj')])
47 vals =
defaults(k, groupdict[k+
'lo'], groupdict[k+
'hi'])
48 condargs.append((k, vals))
54 """obtain the single jet cuts."""
56 assert jstr
in (
'j1',
'j2')
57 assert threshold_var
in (
'pt',
'et')
62 groupdict[jstr+threshold_var+
'lo'],
63 groupdict[jstr+threshold_var+
'hi'])
65 condargs.append((threshold_var, vals))
67 vals =
defaults(
'eta', groupdict[jstr+
'etalo'], groupdict[jstr+
'etahi'],)
68 condargs.append((
'eta', vals))
74 """ original dijet scenario work by J. Bossio.
76 produce a singe element list containing a HelperToolConfigTool.
78 Decodes the dijet scenario to form aConditions to select jet pairs
79 with Conditions on the jet pair, and each of the two jets separately.
81 Currently supported cuts:
88 - default values are used for unspecified cuts, except for delta phi and
89 delta eta for which no cut is applied if not requested
90 The cut set can be extended according to the pattern
94 DIJET50j1etXX80j2etXX0j1eta240XX0j2eta320XX700djmass
95 mixed j1/j2 et/eta values
97 DIJET80j12etXX0j12eta240XX700djmass
98 same et/eta cuts for j1 and j2
100 DIJET80j12etXX700djmassXX26djdphi
101 including delta phi cut
103 DIJET70j12etXX1000djmassXX20djdphiXX40djdeta
104 including delta eta cut
106 The tree vector is [0, 0, 1, 1]
107 # pos 0: root; pos 1 dijet cuts; pos 2: j1 cuts; pos 3: j2 cuts'"""
109 assert scenario.startswith(
'DIJET'), \
110 'routing error, module %s: bad scenario %s' % (__name__, scenario)
122 m = rgx_pt.match(scenario)
126 m = rgx_et.match(scenario)
128 assert m
is not None, \
129 'scenario_dijet.py - regex pat %s or %s do not match scenario %s' % (
130 pattern_pt, pattern_et, scenario)
132 groupdict = m.groupdict()
134 to_delete = [k
for k
in groupdict
if groupdict[k]
is None]
135 for k
in to_delete: del groupdict[k]
137 def massage_thresh(threshold_var, gdict):
139 for k
in (
'j12'+threshold_var+
'lo',
140 'j12'+threshold_var+
'hi',
145 new_key =
'j1' + k[len(
'j12'):]
146 gdict[new_key] = gdict[k]
147 new_key =
'j2' + k[len(
'j12'):]
148 gdict[new_key] = gdict[k]
155 groupdict = massage_thresh(threshold_var, groupdict)
158 if 'j1etalo' not in groupdict: groupdict[
'j1etalo'] =
'0'
159 if 'j1etahi' not in groupdict: groupdict[
'j1etahi'] =
'490'
160 if 'j2etalo' not in groupdict: groupdict[
'j2etalo'] =
'0'
161 if 'j2etahi' not in groupdict: groupdict[
'j2etahi'] =
'490'
165 keystubs =
set([k[:-2]
for k
in groupdict
if k.startswith(
'dj')])
170 repcondargs = [RepeatedConditionParams(tree_id = 1,
187 twins = condargs1 == condargs2
189 repcondargs.append(RepeatedConditionParams(tree_id = 2,
192 chainPartInd=chainPartInd,
196 repcondargs.append(RepeatedConditionParams(tree_id = 2,
198 chainPartInd=chainPartInd,
201 repcondargs.append(RepeatedConditionParams(tree_id = 3,
203 chainPartInd=chainPartInd,
209 nconds = len(repcondargs)
211 filterparam_inds = [-1
for i
in range(nconds)]
220 assert treevec == [0, 0, 1]
222 assert treevec == [0, 0, 1, 1]
224 assert len(repcondargs) == len(filterparam_inds)
226 helper_params = HelperConfigToolParams(treevec=treevec,
227 repcondargs=repcondargs,
228 filterparams=filterparams,
229 filterparam_inds=filterparam_inds)
231 return [helper_params]