1
2 from __future__ import print_function
3 invisible_list = [12,14,16,18]
4 invisible_list += [1000012,1000014,1000016,1000022,1000023,1000024,1000025,1000035]
5
7
8 - def __init__(self,MG_num,pid,fuse=0):
9 if fuse:
10 self.MG=str(MG_num)
11 else:
12 self.MG=int(MG_num)
13 self.pid=int(pid)
14 self.mass=0
15 self.mother=0
16 self.level=0
17 self.twin=0
18 self.neutrino=0
19 self.external=0
20
21
22 - def add_mother(self,obj):
24
26 """ not use anymore: define the twin for the particle if not defined """
27 print('WARNING: Particle.def_twin() is an old routine. This routine hasn\'t been updated since 1/2/08')
28
29
30 if self.twin!=0:
31 return self.twin
32 else:
33 if self.mother:
34 if self.mother.des[0].MG==self.MG:
35 self.twin=self.mother.des[1]
36 self.mother.des[1].twin=self
37 else:
38 self.twin=self.mother.des[0]
39 self.mother.des[0].twin=self
40 else:
41 self.twin=0
42 return self.twin
43
44 - def def_mass(self,info):
45 """definition of the mass of the particle"""
46
47 try:
48 self.mass=float(info['mass'][str(abs(self.pid))])
49 except:
50 self.mass=0
51
52
53 - def def_all_mother(self):
54 "define list containing all mother of the particle"
55 try:
56 if self.all_mother_:
57 return self.all_mother_
58 except:
59 pass
60
61 mother=self.mother
62 if mother==0:
63 self.all_mother_=[]
64
65 else:
66 self.all_mother_=[mother]+mother.def_all_mother()
67
68 return self.all_mother_
69
70
71 - def all_mother(self):
72 """convinient alias"""
73 return self.def_all_mother()
74
76 """ detect the nearest neutrino in the decay branch
77 return this neutrino and its level compare to this particle """
78
79 analyse_list=list(self.des)
80 level_list=[1,1]
81 while analyse_list:
82 particle=analyse_list.pop(0)
83 level=level_list.pop(0)
84
85 if particle.neutrino:
86 return particle,level
87 elif particle.external==0:
88 analyse_list.append(particle.des)
89 level_list.append(level+1)
90 level_list.append(level+1)
91
92 return 0,0
93
94
95
96
97
99 """ print routine """
100
101 text='particle: '+str(self.MG)+'\tpid : '
102 if self.pid<10 and self.pid>0:
103 text+=' '
104 elif self.pid>9:
105 text+=' '
106 text+=str(self.pid)+'\tlevel: '+str(self.level)
107 try:
108 text+='\tmother: '+str(self.mother.MG)
109 except:
110 pass
111 try:
112 text+='\ttwin: '+str(self.twin.MG)
113 except:
114 pass
115 return text
116
117
119
125
126
127
128
129
131 "detect if the external particle is visible in the detector or not"
132
133 if (abs(self.pid) in invisible_list):
134 self.neutrino=1
135 else:
136 self.neutrino=0
137
138 return self.neutrino
139
141 tf_width={}
142 tf_width['p']=float(W_p)
143 tf_width['eta']=float(W_eta)
144 tf_width['phi']=float(W_phi)
145
146 self.tf_width=tf_width
147
149 """ compute the number of propa in common
150 return the total number of propagator before the two particle (default)
151 in addtion it can give the number of uncorelated propagator for the two particle (put total=0)
152 """
153 not_defined_mother=[]
154 if part.mother in self.all_mother():
155 if total:
156 return self.level
157 else:
158 return self.level, self.level-part.level,0
159
160 if self.mother in part.all_mother():
161 if total:
162 return part.level
163 else:
164 print(part.level,self.level)
165 return part.level, 0, part.level-self.level
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 common=0
185 for propa in self.all_mother():
186 if propa in part.all_mother() and propa.channel[0]=='S':
187 common+=1
188
189
190 if total:
191 return self.level+part.level-common
192 else:
193 return self.level+part.level-common,self.level-common,part.level-common
194
196
203
205 "define mother/child/twin relation: the two entry are the child object"
206
207 try:
208 self.des.append(obj)
209
210 obj.twin=self.des[0]
211 self.des[0].twin=obj
212 except:
213 self.des=[obj]
214
215 obj.mother=self
216
217
228
229
230
231
232
233
234
235
237 """ print lot of information """
238
239 text='particle: '+str(self.MG)+'\tpid : '
240 if self.pid<10 and self.pid>0:
241 text+=' '
242 elif self.pid>9:
243 text+=' '
244 text+=str(self.pid)+'\tlevel: '+str(self.level)
245 text+='\tchannel: '+str(self.channel)
246 try:
247 text+='\tdes: '+str(self.des[0].MG)+' '+str(self.des[1].MG)
248 except:
249 try:
250 text+='\tdes: '+str(self.des[0].MG)
251 except:
252 pass
253 try:
254 text+='\tmother: '+str(self.mother.MG)
255 except:
256 text+='\t\t'
257
258 text+='\tmass/width: '+str(self.mass)+'/'+str(self.width)
259 return text
260