19 if os.path.isfile(
'./mass_width_2019.mcd'):
21 f =
open(
'mass_width_2019.mcd',
"r")
22 print(
'File mass_width_2019.mcd already exists.')
27 url =
'http://pdg.lbl.gov/2019/mcdata/mass_width_2019.mcd'
28 response = urllib2.urlopen(url)
29 html = response.read()
32 file_name = url.split(
'/')[-1]
33 f =
open(file_name,
'wb')
35 f =
open(file_name,
"r")
36 print(
'Particle data was fetched from PDG API and put into %s.' % file_name)
49 stripped_line = line.strip()
50 if not stripped_line.startswith(
'*'):
51 split_line = line.strip().
split(
" ")
52 if len(split_line) > 1 :
55 stripped_list.append(i)
61 if (
int(value) != 12
and int(value) != 14
and int(value) != 16):
79 for i
in range(0,len(stripped_list)):
80 if (
isint(stripped_list[i])
and stripped_list[i] !=
'0'):
82 if (
isint(stripped_list[i])
and isint(stripped_list[i+1])
and isint(stripped_list[i+2])
and isint(stripped_list[i+3])):
83 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+10]),(
'mass',stripped_list[i+4]),(
'width',stripped_list[i+7])])
85 elif (
isint(stripped_list[i])
and isint(stripped_list[i+1])
and isint(stripped_list[i+2])):
86 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+9]),(
'mass',stripped_list[i+3]),(
'width',stripped_list[i+6])])
88 elif (
isint(stripped_list[i])
and isint(stripped_list[i+1])
and isfloat(stripped_list[i+5])):
89 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+8]),(
'mass',stripped_list[i+2]),(
'width',stripped_list[i+5])])
91 elif (
isint(stripped_list[i])
and isint(stripped_list[i+1])
and not isfloat(stripped_list[i+5])):
92 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+5]),(
'mass',stripped_list[i+2]),(
'width',
'0.E+00')])
94 elif (
isint(stripped_list[i])
and not isfloat(stripped_list[i+4])):
95 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+4]),(
'mass',stripped_list[i+1]),(
'width',
'0.E+00')])
98 p_dict[stripped_list[i]]=dict([(
'name',stripped_list[i+7]),(
'mass',stripped_list[i+1]),(
'width',stripped_list[i+4])])
104 EW_dict[(
'SIN2THETAW',
'sin2thetaW',
'Sin2ThetaW')]=
'0.23113'
105 EW_dict[(
'SIN2THETAWbar',
'sin2thetaWbar',
'Sin2ThetaWbar')]=
'0.23146'
107 EW_dict[(
'SIN2THETAWbar',
'sin2thetaWbar',
'Sin2ThetaWbar')]=
'0.23146'
112 EW_dict[
'W_to_enu'] = 0.1082
113 EW_dict[
'W_to_leptons'] = 3*EW_dict[
'W_to_enu']
114 EW_dict[
'W_to_hadrons'] = 1.0 - EW_dict[
'W_to_leptons']
115 EW_dict[
't_to_Wb'] = 1.0
116 EW_dict[
't_to_Ws'] = 0.0
117 EW_dict[
't_to_Wd'] = 0.0
120 EW_dict[
'Vud'] = 0.97428
121 EW_dict[
'Vus'] = 0.2253
122 EW_dict[
'Vub'] = 0.00347
123 EW_dict[
'Vcd'] = 0.2252
124 EW_dict[
'Vcs'] = 0.97345
125 EW_dict[
'Vcb'] = 0.041
126 EW_dict[
'Vtd'] = 0.00862
127 EW_dict[
'Vts'] = 0.0403
128 EW_dict[
'Vtb'] = 0.999152
132 EW_dict[
'alphaem_0'] = 0.00729735252
134 EW_dict[
'alphaem'] = 0.00781653039
136 EW_dict[
'alphaqcd'] = 0.1185
138 EW_dict[
'G_F'] = 0.00001166397
140 EW_dict[
'sin2cabibbo'] = 0.051
144 parameters = dict([])
145 parameters[
'particles']=p_dict
146 parameters[
'EW_parameters']=EW_dict
150 with open(
"offline_dict.py",
'wb')
as file:
151 file.write(
"parameters = { \n")
152 for k
in sorted (parameters.keys()):
154 file.write(
"'%s':{ \n" % k)
155 for key
in sorted (parameters[k].
keys()):
156 lastkey = sorted (parameters[k].
keys())[-1]
157 secondtolastkey = sorted (parameters[k].
keys())[-2]
159 if k ==
'EW_parameters':
160 file.write(
"%s:%s}, \n" % (key, parameters[k][key]))
162 file.write(
"'%s':%s} \n" % (key, parameters[k][key]))
163 elif key == secondtolastkey:
164 if k ==
'EW_parameters':
165 file.write(
"%s:%s, \n" % (key, parameters[k][key]))
167 file.write(
"'%s':%s, \n" % (key, parameters[k][key]))