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