ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
EvgenProdTools
python
physics_parameters.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
#-----------------------------------------------------------------------------
4
#
5
# Script to build dictionary with physics parameters from PDG API:
6
# Dictionary is exported to file (offline_dict.py).
7
# Once a new PDG API is availabe, this file needs to be updated with
8
# the right year and run again with python physics_parameters.py
9
# to update the file offline_dict.py.
10
# All other times, the dictionary created by this file can simply be
11
# integrated in the generator interfaces with
12
# from EvgenProdTools.offline_dict import parameters.
13
#
14
#-----------------------------------------------------------------------------
15
import
os
16
17
# Check if file with PDG values already exists:
18
# The name of the file needs to be altered once a new PDG API is available
19
if
os.path.isfile(
'./mass_width_2019.mcd'
):
20
# Open the existing file (
21
f = open(
'mass_width_2019.mcd'
,
"r"
)
22
print
(
'File mass_width_2019.mcd already exists.'
)
23
else
:
24
# Load the particle data from the PDG API:
25
# The name of the file needs to be altered once a new PDG API is available
26
import
urllib2
27
url =
'http://pdg.lbl.gov/2019/mcdata/mass_width_2019.mcd'
28
response = urllib2.urlopen(url)
29
html = response.read()
30
31
# Write the data in a file
32
file_name = url.split(
'/'
)[-1]
33
f = open(file_name,
'wb'
)
34
f.write(html)
35
f = open(file_name,
"r"
)
36
print
(
'Particle data was fetched from PDG API and put into %s.'
% file_name)
37
38
# Method to extract nonblank lines
39
def
nonblank_lines
(f):
40
for
l
in
f:
41
line = l.rstrip()
42
if
line:
43
yield
line
44
45
# Loop over lines and strip to extract the parameters in a list
46
stripped_list = []
47
48
for
line
in
nonblank_lines
(f):
49
stripped_line = line.strip()
50
if
not
stripped_line.startswith(
'*'
):
51
split_line = line.strip().
split
(
" "
)
52
if
len(split_line) > 1 :
53
for
i
in
split_line:
54
if
i !=
""
:
55
stripped_list.append(i)
56
57
# Function to detect integer
58
def
isint
(value):
59
try
:
60
int(value)
61
if
(int(value) != 12
and
int(value) != 14
and
int(value) != 16):
62
return
value
63
except
ValueError:
64
return
False
65
66
# Function to detect float
67
def
isfloat
(value):
68
try
:
69
float(value)
70
return
value
71
except
ValueError:
72
return
False
73
74
# Write particle dictionary from PDG API:
75
# differenciate between particles with widths and without
76
77
p_dict = dict([])
78
79
for
i
in
range(0,len(stripped_list)):
80
if
(
isint
(stripped_list[i])
and
stripped_list[i] !=
'0'
):
81
# Particle with 4 PIDs
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])])
84
# Particle with 3 PIDs
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])])
87
# Particle with 2 PIDS and width
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])])
90
# Particle with 2 PIDS and no width
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'
)])
93
# Particle with 1 PID and no width
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'
)])
96
# Particle with 1 PID and width
97
else
:
98
p_dict[stripped_list[i]]=dict([(
'name'
,stripped_list[i+7]),(
'mass'
,stripped_list[i+1]),(
'width'
,stripped_list[i+4])])
99
100
# Write EW parameter dictionary
101
102
EW_dict = dict([])
103
104
EW_dict[(
'SIN2THETAW'
,
'sin2thetaW'
,
'Sin2ThetaW'
)]=
'0.23113'
105
EW_dict[(
'SIN2THETAWbar'
,
'sin2thetaWbar'
,
'Sin2ThetaWbar'
)]=
'0.23146'
106
107
EW_dict[(
'SIN2THETAWbar'
,
'sin2thetaWbar'
,
'Sin2ThetaWbar'
)]=
'0.23146'
108
109
# All the following values are taken from and moved here from the file 'atlas_common.py' from Powheg
110
# Branching ratios
111
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
118
119
# CKM matrix
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
129
130
# Coupling constants
131
# EM coupling
132
EW_dict[
'alphaem_0'
] = 0.00729735252
# 1/137.036
133
# EM coupling
134
EW_dict[
'alphaem'
] = 0.00781653039
# 1/127.934
135
# Strong coupling
136
EW_dict[
'alphaqcd'
] = 0.1185
137
# Fermi constant
138
EW_dict[
'G_F'
] = 0.00001166397
139
# sin(theta_Cabibbo) ^ 2
140
EW_dict[
'sin2cabibbo'
] = 0.051
141
142
# Write combined dictionary
143
144
parameters = dict([])
145
parameters[
'particles'
]=p_dict
146
parameters[
'EW_parameters'
]=EW_dict
147
148
149
# Write dictionary in file 'offline_dict.py'
150
with
open(
"offline_dict.py"
,
'wb'
)
as
file:
151
file.write(
"parameters = { \n"
)
152
for
k
in
sorted (parameters.keys()):
153
#if k == 'particles':
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]
158
if
key == lastkey:
159
if
k ==
'EW_parameters'
:
160
file.write(
"%s:%s}, \n"
% (key, parameters[k][key]))
161
else
:
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]))
166
else
:
167
file.write(
"'%s':%s, \n"
% (key, parameters[k][key]))
168
file.write(
"}"
)
169
170
f.close()
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
physics_parameters.nonblank_lines
nonblank_lines(f)
Definition
physics_parameters.py:39
physics_parameters.isfloat
isfloat(value)
Definition
physics_parameters.py:67
physics_parameters.isint
isint(value)
Definition
physics_parameters.py:58
Generated on
for ATLAS Offline Software by
1.17.0