73def scenario_dijet(scenario, chainPartInd):
74 """ original dijet scenario work by J. Bossio.
75
76 produce a singe element list containing a HelperToolConfigTool.
77
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.
80
81 Currently supported cuts:
82 - dijet mass
83 - dijet phi
84 - dijet eta
85 - jet1 et, eta
86 - jet2 et, eta
87
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
91
92
93 example scenarios:
94 DIJET50j1etXX80j2etXX0j1eta240XX0j2eta320XX700djmass
95 mixed j1/j2 et/eta values
96
97 DIJET80j12etXX0j12eta240XX700djmass
98 same et/eta cuts for j1 and j2
99
100 DIJET80j12etXX700djmassXX26djdphi
101 including delta phi cut
102
103 DIJET70j12etXX1000djmassXX20djdphiXX40djdeta
104 including delta eta cut
105
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'"""
108
109 assert scenario.startswith('DIJET'), \
110 'routing error, module %s: bad scenario %s' % (__name__, scenario)
111
112
113
114
115
116
117
118
119
120
121 threshold_var = 'pt'
122 m = rgx_pt.match(scenario)
123
124 if m is None:
125 threshold_var = 'et'
126 m = rgx_et.match(scenario)
127
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)
131
132 groupdict = m.groupdict()
133
134 to_delete = [k for k in groupdict if groupdict[k] is None]
135 for k in to_delete: del groupdict[k]
136
137 def massage_thresh(threshold_var, gdict):
138 to_delete = []
139 for k in ('j12'+threshold_var+'lo',
140 'j12'+threshold_var+'hi',
141 'j12etalo',
142 'j12etahi'):
143 if k in gdict:
144 to_delete.append(k)
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]
149
150 for k in to_delete:
151 del gdict[k]
152
153 return gdict
154
155 groupdict = massage_thresh(threshold_var, groupdict)
156
157
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'
162
163
164
165 keystubs =
set([k[:-2]
for k
in groupdict
if k.startswith(
'dj')])
166 condargs = get_dijet_args_from_matchdict(groupdict, keystubs)
167
168
169
170 repcondargs = [RepeatedConditionParams(tree_id = 1,
171 tree_pid=0,
172 chainPartInd=-1,
173 condargs=condargs)]
174
175
176
177
178 condargs1 = get_singlejet_args_from_matchdict(groupdict,
179 threshold_var,
180 'j1')
181
182 condargs2 = get_singlejet_args_from_matchdict(groupdict,
183 threshold_var,
184 'j2')
185
186
187 twins = condargs1 == condargs2
188 if twins:
189 repcondargs.append(RepeatedConditionParams(tree_id = 2,
190 tree_pid=1,
191 multiplicity=2,
192 chainPartInd=chainPartInd,
193 condargs=condargs1))
194 else:
195
196 repcondargs.append(RepeatedConditionParams(tree_id = 2,
197 tree_pid=1,
198 chainPartInd=chainPartInd,
199 condargs=condargs1))
200
201 repcondargs.append(RepeatedConditionParams(tree_id = 3,
202 tree_pid=1,
203 chainPartInd=chainPartInd,
204 condargs=condargs1))
205
206
207
208
209 nconds = len(repcondargs)
210 filterparams = []
211 filterparam_inds = [-1 for i in range(nconds)]
212
213
214
215
216
217
218 treevec = make_treevec(repcondargs)
219 if twins:
220 assert treevec == [0, 0, 1]
221 else:
222 assert treevec == [0, 0, 1, 1]
223
224 assert len(repcondargs) == len(filterparam_inds)
225
226 helper_params = HelperConfigToolParams(treevec=treevec,
227 repcondargs=repcondargs,
228 filterparams=filterparams,
229 filterparam_inds=filterparam_inds)
230
231 return [helper_params]
232
233
234