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

Source Code for Module madgraph.madweight.particle_class

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