Package madgraph :: Package madweight :: Module particle_class
[hide private]
[frames] | no frames]

Source Code for Module madgraph.madweight.particle_class

  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   
6 -class Particle:
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):
23 self.mother=obj
24
25 - def def_twin(self): #this routine is normaly not used any more#
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 #but perhaps no update are needed 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: #this is for unfixed data coming from param_card 48 self.mass=float(info['mass'][str(abs(self.pid))]) 49 except: 50 self.mass=0 #O if not defined in param card
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
75 - def detect_neut_in_decay(self):
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 #no neutrino detected
93 94 95 96 97
98 - def __str__(self):
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
118 -class external_part(Particle):
119
120 - def __init__(self,MG_num,pid):
121 Particle.__init__(self,MG_num,pid) 122 self.external=1 123 self.neutrino=self.is_invisible() 124 self.width=0
125 #self.tf_width={} 126 #self.tf_width['p']=-1 127 #self.tf_width['eta']=-1 128 #self.tf_width['phi']=-1 129
130 - def is_invisible(self):
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
140 - def define_tf_width(self,W_p,W_eta,W_phi):
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
148 - def unaligned_propa(self,part,total=1):
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 # try: 168 # if part.mother in self.all_mother(): 169 # return self.level 170 # except: #self.all_mother not defined 171 # not_defined_mother.append(self) 172 # 173 # try: 174 # if self.mother in part.all_mother(): 175 # return part.level 176 # except: #part.all_mother not defined 177 # not_defined_mother.append(part) 178 # 179 # #define all mother if needed 180 # for ext_part in not_defined_mother: 181 # ext_part.def_all_mother() 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 # print 'propagator in front',self.MG,'-',part.MG,':',self.level,'+',part.level,'-',common,'=',self.level+part.level-common 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
195 -class propagator(Particle):
196
197 - def __init__(self,MG_num,pid,channel):
198 Particle.__init__(self,MG_num,pid) 199 self.external=0 200 self.channel=channel 201 self.mass=0 202 self.width=0
203
204 - def def_desintegation(self,obj):
205 "define mother/child/twin relation: the two entry are the child object" 206 207 try: 208 self.des.append(obj) 209 #create twin relation 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
218 - def def_mass(self,info):
219 "define mass and width of the particle" 220 221 Particle.def_mass(self,info) #definition of the mass 222 223 #definition of the width 224 try: 225 self.width=float(info['decay'][str(abs(self.pid))]) 226 except: 227 self.width=0 #O if not defined in param card
228 229 230 231 232 233 234 235
236 - def __str__(self):
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