203def pet_rec_stereo_views(SmearedHits_stereo, short_tracks_y, min_hits=3):
204
205
206 long_tracks_stereo = []
207 short_tracks_stereo = []
208 used_hits = []
209
210
211 for i_track_y in range(len(short_tracks_y)):
212
213 atrack_y = short_tracks_y[i_track_y]
214 k_y = atrack_y['k_y']
215 b_y = atrack_y['b_y']
216
217
218 for ahit in SmearedHits_stereo:
219 y_center = get_zy_projection(ahit['z'], ahit['xtop'], ahit['ytop'], ahit['xbot'], ahit['ybot'], k_y, b_y)
220 ahit['zy_projection'] = y_center
221
222
223 temp_tracks_stereo = []
224
225 for ahit1 in SmearedHits_stereo:
226 for ahit2 in SmearedHits_stereo:
227
228 if ahit1['z'] >= ahit2['z']:
229 continue
230 if ahit1['detID'] == ahit2['detID']:
231 continue
232 if ahit1['digiHit'] in used_hits:
233 continue
234 if ahit2['digiHit'] in used_hits:
235 continue
236
237 y1_center = ahit1['zy_projection']
238 y2_center = ahit2['zy_projection']
239
240 if abs(y1_center ) > 70 or abs(y2_center ) > 70:
241 continue
242
243 y1 = y1_center
244 y2 = y2_center
245 z1 = ahit1['z']
246 z2 = ahit2['z']
247 layer1 = ahit1['detID'] // 10000
248 layer2 = ahit2['detID'] // 10000
249
250 k_bin = 1. * (y2 - y1) / (z2 - z1)
251 b_bin = y1 - k_bin * z1
252
253 atrack = {}
254 atrack['hits_stereo'] = [ahit1, ahit2]
255 atrack['y_stereo'] = [y1, y2]
256 atrack['z_stereo'] = [z1, z2]
257 atrack['layer'] = [layer1, layer2]
258
259 for ahit3 in SmearedHits_stereo:
260
261 if ahit3['digiHit'] == ahit1['digiHit'] or ahit3['digiHit'] == ahit2['digiHit']:
262 continue
263 if ahit3['digiHit'] in used_hits:
264 continue
265
266 y3_center = ahit3['zy_projection']
267 z3 = ahit3['z']
268 layer3 = ahit3['detID'] // 10000
269
270 if abs(y3_center) > 70:
271 continue
272
273 if layer3 in atrack['layer']:
274 continue
275
276 in_bin = hit_in_window(z3, y3_center, k_bin, b_bin, window_width=10.0)
277 if in_bin:
278 atrack['hits_stereo'].append(ahit3)
279 atrack['z_stereo'].append(z3)
280 atrack['y_stereo'].append(y3_center)
281 atrack['layer'].append(layer3)
282
283 if len(atrack['hits_stereo']) >= min_hits:
284 temp_tracks_stereo.append(atrack)
285 long_tracks_stereo.append(atrack)
286
287
288 max_track = None
289 max_n_hits = -999
290
291 for atrack in temp_tracks_stereo:
292 if len(atrack['hits_stereo']) > max_n_hits:
293 max_track = atrack
294 max_n_hits = len(atrack['hits_stereo'])
295
296 if max_track is not None:
297 atrack = {}
298 atrack['hits_y'] = atrack_y['hits_y']
299 atrack['z_y'] = atrack_y['z_y']
300 atrack['x_y'] = atrack_y['x_y']
301 atrack['k_y'] = atrack_y['k_y']
302 atrack['b_y'] = atrack_y['b_y']
303 atrack['hits_stereo'] = max_track['hits_stereo']
304 atrack['z_stereo'] = max_track['z_stereo']
305 atrack['y_stereo'] = max_track['y_stereo']
306
307 short_tracks_stereo.append(atrack)
308 for ahit in max_track['hits_stereo']:
309
310 pass
311
312 return short_tracks_stereo
313
314