Belle II Software development
ReadTSIMInfo.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import ROOT
13import math
14from ROOT import Belle2
15import modularAnalysis as ma
16from array import array
17import sys # get argv
18
19from heapq import nlargest
20from effCalculation import EffCalculation
21
22RadToDeg = 180.0 / math.pi
23
24
25argvs = sys.argv
26argn = len(argvs)
27if argn != 3:
28 sys.exit("ztsim02.py> # of arg is strange. Exit.")
29
30
31def Count_mcpart(parts):
32 npart = [0, 0]
33 dec_cdc = [17, 150]
34 dec_ecl = [14.1, 155]
35 for part in parts:
36 pdglist = [11, 13, 2212, 321, 211]
37 pdg = math.fabs(part.getPDG())
38 theta = part.getMomentum().Theta() * RadToDeg
39 if theta > dec_cdc[0] and theta < dec_cdc[1]:
40 if pdg in pdglist:
41 npart[0] += 1
42
43 if math.fabs(pdg) == 22:
44 if theta > dec_ecl[0] and theta < dec_ecl[1]:
45 npart[1] += 1
46 return npart
47
48
49def Count_part_inDetector(parts):
50 npart = [0, 0]
51 for part in parts:
52 pdg = part.getPDG()
53 charge = part.getCharge()
54 indec = part.hasSeenInDetector(Belle2.Const.DetectorSet(Belle2.Const.ECL))
55 if indec:
56 if math.fabs(charge) > 0:
57 npart[0] += 1
58 elif math.fabs(pdg) == 22:
59 npart[1] += 1
60 return npart
61
62
63def Theta_MCTruth(part):
64 theta = part.getMomentum().Theta() * RadToDeg
65 return theta
66
67
68def NeutralCluster(clusters):
69 neutral_cluster = []
70 for cluster in clusters:
71 if cluster.getRelatedFrom('TRGNNTracks'):
72 continue
73 else:
74 neutral_cluster.append(cluster)
75 return neutral_cluster
76
77
78def Vec_Cluster(cluster):
79 x = cluster.getPositionX()
80 y = cluster.getPositionY()
81 z = cluster.getPositionZ()
82 e = cluster.getEnergyDep()
83 vec = ROOT.TVector3(x, y, z)
84 v_mom = e * ROOT.Math.PxPyPzEVector(x / vec.Mag(), y / vec.Mag(), z / vec.Mag(), 1)
85 new_theta = v_mom.Theta() * RadToDeg
86 new_phi = v_mom.Phi() * RadToDeg
87 if(new_phi < 0):
88 new_phi += 2 * math.pi
89 new_e = v_mom.E()
90 NVC = [new_e, new_theta, new_phi]
91 return NVC
92
93
94def Max_Cluster(neuclus, CMS, n):
95 E = []
96 for neuclu in neuclus:
97 NV = Vec_Cluster(neuclu)
98 E.append(NV)
99 if E and len(E) >= (n + 1):
100 seqen = nlargest(n + 1, E, key=lambda item: item[0])
101 return seqen[n]
102 else:
103 return [-1, -999, -999]
104
105
106def Etot_Cluster(eclcluster):
107 Elist = []
108 for clu in eclcluster:
109 e = clu.getEnergyDep()
110 Elist.append(e)
111 return sum(Elist)
112
113
114def Max_DeltPhi_trk(trk_2d_list):
115 Delt = []
116 for i, trk in enumerate(trk_2d_list):
117 phi1 = (trk.getPhi0()) * RadToDeg
118 for j, trk2 in enumerate(trk_2d_list):
119 if j <= i:
120 continue
121 else:
122 phi2 = (trk2.getPhi0()) * RadToDeg
123 Delt_phi = math.fabs(phi1 - phi2)
124 Delt.append(Delt_phi)
125 return max(Delt or [-100.0])
126
127
128def BhabhaVeto1(matchtrks):
129 Delt = []
130 if len(matchtrks) <= 1:
131 return Delt
132 for i, matchtrk1 in enumerate(matchtrks):
133 if i == len(matchtrks) - 1:
134 continue
135 cdctrk1 = matchtrk1.getRelatedTo('TRGNNTracks')
136 cluster1 = matchtrk1.getRelatedTo('TRGECLClusters')
137 if cdctrk1 and cluster1:
138 tanLam1 = cdctrk1.getTanLambda()
139 theta1 = math.acos(tanLam1 / math.sqrt(1. + tanLam1 * tanLam1)) * RadToDeg
140 phi1 = (cdctrk1.getPhi0()) * RadToDeg
141 if phi1 < 0.:
142 phi1 += 2 * math.pi
143 e1 = cluster1.getEnergyDep()
144 for j, matchtrk2 in enumerate(matchtrks):
145 if j <= i:
146 continue
147 else:
148 cdctrk2 = matchtrk2.getRelatedTo('TRGNNTracks')
149 cluster2 = matchtrk2.getRelatedTo('TRGECLClusters')
150 if cdctrk2 and cluster2:
151 tanLam2 = cdctrk2.getTanLambda()
152 theta2 = math.acos(tanLam2 / math.sqrt(1. + tanLam2 * tanLam2)) * RadToDeg
153 phi2 = (cdctrk2.getPhi0()) * RadToDeg
154 if phi2 < 0.:
155 phi2 += 2 * math.pi
156 e2 = cluster2.getEnergyDep()
157 Delt_theta = theta1 + theta2 - 180
158 Delt_phi = math.fabs(phi1 - phi2) - 180
159 DeltArray = [Delt_theta, Delt_phi, e1, e2, e1 + e2]
160 Delt.append(DeltArray)
161 if len(Delt) >= 1:
162 return Delt
163 else:
164 return [-999., -999., -999., -999., -999]
165
166
167def SBhabhaVeto(matchtrks):
168 Elist = []
169 if len(matchtrks) <= 1:
170 return Elist
171 for i, matchtrk1 in enumerate(matchtrks):
172 cdctrk1 = matchtrk1.getRelatedTo('TRGNNTracks')
173 cluster1 = matchtrk1.getRelatedTo('TRGECLClusters')
174 if cdctrk1 and cluster1:
175 e1 = cluster1.getEnergyDep()
176 Elist.append([e1])
177 if len(Elist) >= 1:
178 return Elist
179 else:
180 return [-999.]
181
182
183def eclBhabhaVeto(eclclusters):
184 neclBhabha = []
185 for i, cluster1 in enumerate(eclclusters):
186 if i == len(eclclusters) - 1:
187 continue
188 e1 = cluster1.getEnergyDep()
189 x1 = cluster1.getPositionX()
190 y1 = cluster1.getPositionY()
191 z1 = cluster1.getPositionZ()
192 vec1 = ROOT.TVector3(x1, y1, z1)
193 theta1 = vec1.Theta()
194 phi1 = vec1.Phi()
195 if(phi1 < 0):
196 phi1 += 2 * math.pi
197 for j, cluster2 in enumerate(eclclusters):
198 e2 = cluster2.getEnergyDep()
199 if j <= i:
200 continue
201 x2 = cluster2.getPositionX()
202 y2 = cluster2.getPositionY()
203 z2 = cluster2.getPositionZ()
204 vec2 = ROOT.TVector3(x2, y2, z2)
205 theta2 = vec2.Theta()
206 phi2 = vec2.Phi()
207 if phi2 < 0.0:
208 phi2 += 2 * math.pi
209 delt_theta = math.fabs((theta1 + theta2) * RadToDeg - 180.0)
210 delt_phi = math.fabs(phi1 - phi2) * RadToDeg - 180.0
211 if theta1 < theta2:
212 efr = e1
213 ebr = e2
214 else:
215 efr = e2
216 ebr = e1
217 bhacl = [delt_theta, delt_phi, efr, ebr, efr + ebr]
218 neclBhabha.append(bhacl)
219 return neclBhabha
220
221
222def Max_DeltPhi_cluster(eclclusters):
223 eclphi_col = []
224 for i, cluster1 in enumerate(eclclusters):
225 e1 = cluster1.getEnergyDep()
226 if e1 < 0.1:
227 continue
228 x1 = cluster1.getPositionX()
229 y1 = cluster1.getPositionY()
230 z1 = cluster1.getPositionZ()
231 vec1 = ROOT.TVector3(x1, y1, z1)
232 phi1 = vec1.Phi()
233 if(phi1 < 0):
234 phi1 += 2 * math.pi
235 for j, cluster2 in enumerate(eclclusters):
236 e2 = cluster2.getEnergyDep()
237 if j <= i:
238 continue
239 if e2 < 0.1:
240 continue
241 x2 = cluster2.getPositionX()
242 y2 = cluster2.getPositionY()
243 z2 = cluster2.getPositionZ()
244 vec2 = ROOT.TVector3(x2, y2, z2)
245 phi2 = vec2.Phi()
246 if phi2 < 0.0:
247 phi2 += 2 * math.pi
248 delt_phi = math.fabs(phi1 - phi2) * RadToDeg
249 eclphi_col.append(delt_phi)
250 return max(eclphi_col or [-1.0])
251
252
253def Time_Window(clusters, eventtime):
254 new_clusters = []
255 energy = []
256 for ev in eventtime:
257 event_time = ev.m_eventtiming
258 event_tot = ev.m_etot
259 energy.append([event_time, event_tot])
260 if energy:
261 tmp = max(energy, key=lambda item: item[1])
262 event_time = tmp[0]
263 else:
264 event_time = -999999.
265 for cluster in clusters:
266 ctime_ori = cluster.getTimeAve()
267 ctime = ctime_ori - event_time
268 if math.fabs(ctime) < 100:
269 new_clusters.append(cluster)
270 return new_clusters
271
272
273def Cluster_Threshold(clusters, threshold, CMS):
274 new_clusters = []
275 for cluster in clusters:
276 eng = 0
277 if CMS:
278 newv = Vec_Cluster(cluster)
279 eng = newv[0]
280 else:
281 eng = cluster.getEnergyDep()
282 if eng > threshold:
283 new_clusters.append(cluster)
284 return new_clusters
285
286
287def Back_to_Back(clusters1, clusters2):
288 npai = 0
289 for cluster1 in clusters1:
290 cid1 = cluster1.getClusterId()
291 vec1 = Vec_Cluster(cluster1)
292 theta1 = vec1[1]
293 phi1 = vec1[2]
294 for cluster2 in clusters2:
295 cid2 = cluster2.getClusterId()
296 if cid1 == cid2:
297 continue
298 vec2 = Vec_Cluster(cluster2)
299 theta2 = vec2[1]
300 phi2 = vec2[2]
301 delttheta = math.fabs(theta1 + theta2 - 180)
302 deltphi = math.fabs(math.fabs(phi1 - phi2) - 180)
303 if delttheta < 100 and deltphi < 100:
304 npai += 1
305 return npai
306
307
308def Time_Cluster(clusters, eventtime):
309 time_list = []
310 energy = []
311 event_time = 0.
312 for ev in eventtime:
313 event_time = ev.m_eventtiming
314 event_tot = ev.m_etot
315 energy.append([event_time, event_tot])
316 if energy:
317 tmp = max(energy, key=lambda item: item[1])
318 event_time = tmp[0]
319 for cluster in clusters:
320 ctime_ori = cluster.getTimeAve()
321 ctime = ctime_ori - event_time
322 time_list.append(ctime)
323 return time_list
324
325
326def PrintBranchDef():
327 print('\n')
328 print('ntrk_2dfinder: # 2d finder track')
329 print('ntrk_2dfitter: # 2d fitter track')
330 print('ntrk_3dfitter: # 3d fitter track')
331 print('ntrk_NN : # Neuro network track')
332 print('ntrk_2Dmatch : # 2d finder track w/ associated ecl cluster')
333 print('ntrk_3Dmatch : # 3d finder track w/ associated ecl cluster')
334 print('ntrk_klm : # KLM track')
335 print('nhit_klm : # KLM hit', '\n')
336
337 print('ncluster: # ecl cluster')
338 print('ncluster_1000b: # ecl cluster with threshold >1.0GeV, exclude TC ID 1,2, 17')
339 print('ncluster_2000e: # ecl cluster with threshold >2.0GeV in TC ID 1, 17')
340 print('max_cluster[3]: [energy, theta, phi] of the largest energetic ecl cluster')
341 print('smax_cluster[3]: [energy, theta, phi] of the secondary energetic ecl cluster')
342 print('ncluster_neutral: # ecl cluster w/o associated cdc track')
343 print('max_cluster_neutral[3]: [energy, theta, phi] of the largest energetic ecl neutral cluster')
344 print('smax_cluster_neutral[3]: [energy, theta, phi] of the secondary energetic ecl neutral cluster')
345 print('time_cluster: the cluster timing obtained with cluster.timing-event.timing', '\n')
346
347 print('nbbc: # back to back cluster pairs')
348 print('nbbtc: # back to back track and cluster pairs')
349 print('bhabha: bhabha veto logic, 1: bhabha, 0: non bhabha')
350 print('sbhabha: bhabha with single track veto logic, 1: bhabha, 0: non bhabha')
351 print('eclbhabha: eclbhabha veto logic, 1: bhabha, 0: non bhabha')
352 print('bhabha_var[5]: variables used in bhabha logic, [Delt_theta, Delt_phi, E1, E2, E1+E2]')
353 print(' For two tracks: Delt_theta: theta1+theta2-180, Delt_phi: |phi1-phi2|-180')
354 print(' E1, E2 are the ecl clusters energy accociated with the two tracks')
355 print('eclbhabha_var[5]: variables used in eclbhabha logic, [Delt_theta, Delt_phi, E1, E2, E1+E2]')
356 print(' For two eclclusers: Delt_theta: theta1+theta2-180, Delt_phi: |phi1-phi2|-180')
357 print(' E1, E2 are the ecl clusters energy')
358 print('\n')
359
360
361class CreateLogics(b2.Module):
362 """This module is to calculate some variables which are useful for the trigger development"""
363
364 file = ROOT.TFile(argvs[2], 'recreate')
365
366 tgrl = ROOT.TTree('tgrl', 'tree with GRL_Logic')
367
368 ntrk_2dfinder_t = array('i', [-1])
369
370 ntrk_2dfitter_t = array('i', [-1])
371
372 ntrk_3dfitter_t = array('i', [-1])
373
374 ntrk_NN_t = array('i', [-1])
375
376 ntrk_2Dmatch_t = array('i', [-1])
377
378 ntrk_3Dmatch_t = array('i', [-1])
379
380 max_deltphi_2dfinder_t = array('f', [0.0])
381
382 cpair_t = array('i', 8 * [0])
383
384 ncomp_clu = 3
385
386 etot_t = array('f', [0.0])
387
388 ncluster_1000b_t = array('i', [-1])
389
390 ncluster_2000e_t = array('i', [-1])
391
392 ncluster_t = array('i', [-1])
393
394 ncluster_neutral_t = array('i', [-1])
395
396 max_cluster_neutral_t = array('f', ncomp_clu * [0.0])
397
398 max_cms_cluster_neutral_t = array('f', ncomp_clu * [0.0])
399
400 max_cluster_t = array('f', ncomp_clu * [0.0])
401
402 max_cms_cluster_t = array('f', ncomp_clu * [0.0])
403
404 smax_cluster_neutral_t = array('f', ncomp_clu * [0.0])
405
406 smax_cms_cluster_neutral_t = array('f', ncomp_clu * [0.0])
407
408 smax_cluster_t = array('f', ncomp_clu * [0.0])
409
410 smax_cms_cluster_t = array('f', ncomp_clu * [0.0])
411
412 max_deltphi_cluster_t = array('f', [0.0])
413
414 time_cluster_t = array('f', 100 * [-99999.])
415
416 ntrk_klm_t = array('i', [-1])
417
418 nhit_klm_t = array('i', [-1])
419
420 npair_tc_t = array('i', [-1])
421
422 npair_cc_t = array('i', [-1])
423
424 nbha_var = 5
425
426 bhabha_t = array('i', [0])
427
428 sbhabha_t = array('i', [0])
429
430 eclbhabha_t = array('i', [0])
431
432 bhabha_var_t = array('f', nbha_var * [0.0])
433
434 eclbhabha_var_t = array('f', nbha_var * [0.0])
435
436 # track
437 tgrl.Branch('ntrk_2dfinder', ntrk_2dfinder_t, 'ntrk_2dfinder/i')
438 tgrl.Branch('ntrk_2dfitter', ntrk_2dfitter_t, 'ntrk_2dfitter/i')
439 tgrl.Branch('ntrk_3dfitter', ntrk_3dfitter_t, 'ntrk_3dfitter/i')
440 tgrl.Branch('ntrk_NN', ntrk_NN_t, 'ntrk_NN/i')
441 tgrl.Branch('ntrk_2Dmatch', ntrk_2Dmatch_t, 'ntrk_2Dmatch/i')
442 tgrl.Branch('ntrk_3Dmatch', ntrk_3Dmatch_t, 'ntrk_3Dmatch/i')
443 tgrl.Branch('npair_tc', npair_tc_t, 'npair_tc/i')
444 tgrl.Branch('npair_cc', npair_cc_t, 'npair_cc/i')
445 tgrl.Branch('max_deltphi_2dfinder', max_deltphi_2dfinder_t, 'max_deltphi_2dfinder/f')
446
447 # cluster
448 tgrl.Branch('etot', etot_t, 'etot/f')
449 tgrl.Branch('ncluster', ncluster_t, 'ncluster/i')
450 tgrl.Branch('ncluster_1000b', ncluster_1000b_t, 'ncluster_1000b/i')
451 tgrl.Branch('ncluster_2000e', ncluster_2000e_t, 'ncluster_2000e/i')
452 tgrl.Branch('ncluster_neutral', ncluster_neutral_t, 'ncluster_neutral/i')
453 tgrl.Branch('max_cluster_neutral', max_cluster_neutral_t, 'max_cluster_neutral[3]/f')
454 # tgrl.Branch('max_cms_cluster_neutral', max_cms_cluster_neutral_t, 'max_cms_cluster_neutral[3]/f')
455 tgrl.Branch('max_cluster', max_cluster_t, 'max_cluster[3]/f')
456 # tgrl.Branch('max_cms_cluster', max_cms_cluster_t, 'max_cms_cluster[3]/f')
457 tgrl.Branch('smax_cluster_neutral', smax_cluster_neutral_t, 'smax_cluster_neutral[3]/f')
458 # tgrl.Branch('smax_cms_cluster_neutral', smax_cms_cluster_neutral_t, 'smax_cms_cluster_neutral[3]/f')
459 tgrl.Branch('smax_cluster', smax_cluster_t, 'smax_cluster[3]/f')
460 # tgrl.Branch('smax_cms_cluster', smax_cms_cluster_t, 'smax_cms_cluster[3]/f')
461 tgrl.Branch('max_deltphi_cluster', max_deltphi_cluster_t, 'max_deltphi_cluster/f')
462 tgrl.Branch('time_cluster', time_cluster_t, 'time_cluster[100]/f')
463
464 # klm
465 tgrl.Branch('ntrk_klm', ntrk_klm_t, 'ntrk_klm/i')
466 tgrl.Branch('nhit_klm', nhit_klm_t, 'nhit_klm/i')
467
468 # bhabha
469 tgrl.Branch('bhabha', bhabha_t, 'bhabha/i')
470 tgrl.Branch('sbhabha', sbhabha_t, 'sbhabha/i')
471 tgrl.Branch('eclbhabha', eclbhabha_t, 'eclbhabha/i')
472 tgrl.Branch('bhabha_var', bhabha_var_t, 'bhabha_var[5]/f')
473 tgrl.Branch('eclbhabha_var', eclbhabha_var_t, 'eclbhabha_var[5]/f')
474
475 tgrl.Branch('cpair', cpair_t, 'cpair[8]/i')
476
477 def event(self):
478 """
479 MCPart = Belle2.PyStoreArray('MCParticles')
480 if len(MCPart)>=4:
481 self.eplus_t[0]=Theta_MCTruth(MCPart[2])
482 self.eminus_t[0]=Theta_MCTruth(MCPart[3])
483 if self.eplus_t[0] > self.eminus_t[0]:
484 self.efrd_t[0]=self.eminus_t[0]
485 self.ebkd_t[0]=self.eplus_t[0]
486 else:
487 self.efrd_t[0]=self.eplus_t[0]
488 self.ebkd_t[0]=self.eminus_t[0]
489 count_part = Count_part_inDetector(MCPart)
490 self.n_par_t[0]=count_part[0]
491 self.n_par_t[1]=count_part[1]
492 count_mcpart = Count_mcpart(MCPart)
493 self.n_mcpar_t[0]=count_mcpart[0]
494 self.n_mcpar_t[1]=count_mcpart[1]
495 """
496 trk_2d_finder = Belle2.PyStoreArray('TRG2DFinderTracks')
497 self.ntrk_2dfinder_t[0] = len(trk_2d_finder)
498 trk_2d_fitter = Belle2.PyStoreArray('TRG2DFitterTracks')
499 self.ntrk_2dfitter_t[0] = len(trk_2d_fitter)
500 trk_3d_fitter = Belle2.PyStoreArray('TRG3DFitterTracks')
501 self.ntrk_3dfitter_t[0] = len(trk_3d_fitter)
502 tracks = Belle2.PyStoreArray('TRGNNTracks')
503 self.ntrk_NN_t[0] = len(tracks)
504
505 # clusters
506 clusters_original = Belle2.PyStoreArray('TRGECLClusters')
507 eventtime = Belle2.PyStoreArray('TRGECLTrgs')
508 # get clusters list in time window [-100,100]
509 clusters = Time_Window(clusters_original, eventtime)
510 self.ncluster_t[0] = len(clusters)
511 # get the cluster timing before time window requirement
512 time_clu_list = Time_Cluster(clusters_original, eventtime)
513 for i in range(len(time_clu_list)):
514 if i < 100:
515 self.time_cluster_t[i] = time_clu_list[i]
516
517 clusters_300_cms = Cluster_Threshold(clusters, 0.3, False)
518 clusters_400_cms = Cluster_Threshold(clusters, 0.4, False)
519 clusters_500_cms = Cluster_Threshold(clusters, 0.5, False)
520 clusters_700_cms = Cluster_Threshold(clusters, 0.7, False)
521 clusters_1000_cms = Cluster_Threshold(clusters, 1.0, False)
522 clusters_2000_cms = Cluster_Threshold(clusters, 2.0, False)
523 clusters_2500_cms = Cluster_Threshold(clusters, 2.5, False)
524 self.cpair_t[0] = Back_to_Back(clusters, clusters)
525 self.cpair_t[1] = Back_to_Back(clusters_300_cms, clusters)
526 self.cpair_t[2] = Back_to_Back(clusters_400_cms, clusters)
527 self.cpair_t[3] = Back_to_Back(clusters_500_cms, clusters)
528 self.cpair_t[4] = Back_to_Back(clusters_700_cms, clusters)
529 self.cpair_t[5] = Back_to_Back(clusters_1000_cms, clusters)
530 self.cpair_t[6] = Back_to_Back(clusters_2000_cms, clusters)
531 self.cpair_t[7] = Back_to_Back(clusters_2500_cms, clusters)
532
533 klmtrkcol = Belle2.PyStoreArray('TRGKLMTracks')
534 self.ntrk_klm_t[0] = len(klmtrkcol)
535 klmhitcol = Belle2.PyStoreArray('TRGKLMHits')
536 self.nhit_klm_t[0] = len(klmhitcol)
537
538 matchlist = Belle2.PyStoreArray('TRG3DMatchTracks')
539 self.ntrk_3Dmatch_t[0] = len(matchlist)
540
541 trginfo = Belle2.PyStoreObj('TRGGRLObjects')
542 self.npair_tc_t[0] = trginfo.getNbbTrkCluster()
543 self.npair_cc_t[0] = trginfo.getNbbCluster()
544 self.ncluster_1000b_t[0] = trginfo.getNhighcluster2()
545 self.ncluster_2000e_t[0] = trginfo.getNhighcluster4()
546 self.max_deltphi_2dfinder_t[0] = Max_DeltPhi_trk(trk_2d_finder)
547
548 neutral_clusters = NeutralCluster(clusters)
549 self.ncluster_neutral_t[0] = len(neutral_clusters)
550 max_cluster_neu = Max_Cluster(neutral_clusters, 0)
551 max_cluster = Max_Cluster(clusters, 0)
552 # max_cms_cluster_neu = Max_Cluster(neutral_clusters, 0)
553 # max_cms_cluster = Max_Cluster(clusters, 0)
554 smax_cluster_neu = Max_Cluster(neutral_clusters, 1)
555 smax_cluster = Max_Cluster(clusters, 1)
556 # smax_cms_cluster_neu = Max_Cluster(neutral_clusters, 1)
557 # smax_cms_cluster = Max_Cluster(clusters, 1)
558 for i in range(self.ncomp_clu):
559 self.max_cluster_neutral_t[i] = max_cluster_neu[i]
560 # self.max_cms_cluster_neutral_t[i] = max_cms_cluster_neu[i]
561 self.max_cluster_t[i] = max_cluster[i]
562 # self.max_cms_cluster_t[i] = max_cms_cluster[i]
563 self.smax_cluster_neutral_t[i] = smax_cluster_neu[i]
564 # self.smax_cms_cluster_neutral_t[i] = smax_cms_cluster_neu[i]
565 self.smax_cluster_t[i] = smax_cluster[i]
566 # self.smax_cms_cluster_t[i] = smax_cms_cluster[i]
567
568 self.etot_t[0] = Etot_Cluster(clusters)
569
570 # bhabha
571 bhabhaveto_1 = BhabhaVeto1(matchlist)
572 bha_logic = 0
573 for bha in bhabhaveto_1:
574 if math.fabs(bha[0]) < 50 and math.fabs(bha[0]) > 10 and math.fabs(bha[1]) < 20:
575 if bha[2] > 2.0 and bha[3] > 2.0 and bha[4] > 6.0:
576 if bha[2] > 3.0 or bha[3] > 3.0:
577 if len(trk_2d_finder) == 2:
578 bha_logic = 1
579 self.bhabha_t[0] = bha_logic
580
581 if len(bhabhaveto_1) >= 1:
582 for i in range(self.nbha_var):
583 self.bhabha_var_t[i] = bhabhaveto_1[0][i]
584
585 # eclbhabha
586 eclbhabhaveto = eclBhabhaVeto(clusters)
587 eclbha_logic = 0
588 for eclbha in eclbhabhaveto:
589 if math.fabs(eclbha[0]) < 50 and math.fabs(eclbha[1]) < 50:
590 if eclbha[2] > 2.0 and eclbha[3] > 2.0 and eclbha[4] > 6.0:
591 if eclbha[2] > 3.0 or eclbha[3] > 3.0:
592 eclbha_logic = 1
593 self.eclbhabha_t[0] = eclbha_logic
594
595 # sbhahba
596 sbha_logic = 0
597 if len(trk_2d_finder) == 1:
598 if eclbha_logic == 1:
599 ecol = SBhabhaVeto(matchlist)
600 for i, etr in ecol:
601 if etr[i] > 1.0:
602 sbha_logic = 1
603 self.sbhabha_t[0] = sbha_logic
604
605 self.max_deltphi_cluster_t[0] = Max_DeltPhi_cluster(clusters)
606 if len(eclbhabhaveto) >= 1:
607 for i in range(self.nbha_var):
608 self.eclbhabha_var_t[i] = eclbhabhaveto[0][i]
609 self.tgrl.Fill()
610
611 def terminate(self):
612 """Write and close the file"""
613 self.file.cd()
614 self.file.Write()
615 self.file.Close()
616 PrintBranchDef()
617
618
619if __name__ == "__main__":
620 main = b2.create_path()
621 ma.inputMdst(argvs[1], main)
622 main.add_module(CreateLogics())
623 EffCalculation(main)
624 b2.process(main)
The DetectorSet class for sets of detector IDs in the form of EDetector values.
Definition: Const.h:80
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67
array bhabha_t
bhabha veto logic, 1: bhabha, 0: non bhabha
array smax_cluster_t
[energy, theta, phi] of the secondary energetic ecl cluster
array smax_cluster_neutral_t
[energy, theta, phi] of the secondary energetic ecl neutral cluster
array nhit_klm_t
number of KLM hits
array ntrk_2dfinder_t
#2d finder tracks
array max_cluster_neutral_t
[energy, theta, phi] of the largest energetic ecl neutral cluster
ROOT tgrl
the tree in the output file
array eclbhabha_t
eclbhabha veto logic, 1: bhabha, 0: non bhabha
array cpair_t
number of cluster pairs with different energy threshold
array eclbhabha_var_t
variables used in eclbhabha logic, [Delt_theta, Delt_phi, E1, E2, E1+E2]
array max_deltphi_2dfinder_t
max phi angle between two 2d finder tracks
array ntrk_klm_t
number of KLM tracks
ROOT file
the output file
array ntrk_2dfitter_t
#2d fitter tracks
array bhabha_var_t
variables used in bhabha logic, [Delt_theta, Delt_phi, E1, E2, E1+E2]
array ntrk_3dfitter_t
#3d fitter tracks
int ncomp_clu
number of array components
array max_deltphi_cluster_t
max delt phi angle between two clusters
array sbhabha_t
bhabha with single track veto logic, 1: bhabha, 0: non bhabha
array max_cluster_t
[energy, theta, phi] of the largest energetic ecl cluster
array time_cluster_t
the timing of clusters
array etot_t
the total deposited cluster energy in ecl
array ntrk_3Dmatch_t
#3d matched tracks
int nbha_var
number of array components
array ntrk_NN_t
number of NN tracks
array ncluster_1000b_t
number of ecl cluster with threshold >1.0GeV, exclude TC ID 1,2, 17