2 __date__ =
"02 Aug 2012"
3 __author__ =
'olivier.mattelaer@uclouvain.be'
5 from function_library
import *
10 """######################################################################\n""" + \
11 """## PARAM_CARD AUTOMATICALY GENERATED BY THE UFO #####################\n""" + \
12 """######################################################################\n"""
14 def __init__(self, filename, list_of_parameters=None, generic=False):
15 """write a valid param_card.dat"""
17 if not list_of_parameters:
18 from parameters
import all_parameters
19 list_of_parameters = [param
for param
in all_parameters
if \
20 param.nature==
'external']
27 self.
fsockfsock = open(filename,
'w')
31 self.
fsockfsock.close()
34 """define self.dep_mass and self.dep_width in case that they are
35 requested in the param_card.dat"""
36 from particles
import all_particles
38 self.
dep_massdep_mass = [(part, part.mass)
for part
in all_particles \
39 if part.pdg_code > 0
and \
40 part.mass
not in list_of_parameters]
41 self.
dep_widthdep_width = [(part, part.width)
for part
in all_particles\
42 if part.pdg_code > 0
and \
43 part.width
not in list_of_parameters]
47 """ order parameter of a given block """
49 maxlen = min([len(obj1.lhacode), len(obj2.lhacode)])
51 for i
in range(maxlen):
52 if obj1.lhacode[i] < obj2.lhacode[i]:
54 elif obj1.lhacode[i] == obj2.lhacode[i]:
59 if len(obj1.lhacode) > len(obj2.lhacode):
61 elif len(obj1.lhacode) == len(obj2.lhacode):
70 all_lhablock = set([param.lhablock
for param
in all_ext_param])
73 all_lhablock = list(all_lhablock)
76 for name
in [
'DECAY',
'MASS',
'SMINPUTS']:
77 if name
in all_lhablock:
78 all_lhablock.remove(name)
79 all_lhablock.insert(0, name)
81 for lhablock
in all_lhablock:
83 need_writing = [ param
for param
in all_ext_param
if \
84 param.lhablock == lhablock]
86 [self.
write_paramwrite_param(param, lhablock)
for param
in need_writing]
89 if lhablock
in [
'MASS',
'DECAY']:
96 """ write a comment for a block"""
98 self.
fsockfsock.writelines(
99 """\n###################################""" + \
100 """\n## INFORMATION FOR %s""" % name.upper() +\
101 """\n###################################\n"""
104 self.
fsockfsock.write(
"""Block %s \n""" % name)
106 def write_param(self, param, lhablock):
108 lhacode=
' '.join([
'%3s' % key
for key
in param.lhacode])
109 if lhablock !=
'DECAY':
110 text =
""" %s %e # %s \n""" % (lhacode, complex(param.value).real, param.name )
112 text =
'''DECAY %s %e \n''' % (lhacode, complex(param.value).real)
113 self.
fsockfsock.write(text)
118 def write_dep_param_block(self, lhablock):
120 from parameters
import all_parameters
121 from particles
import all_particles
122 for parameter
in all_parameters:
123 exec(
"%s = %s" % (parameter.name, parameter.value))
124 text =
"## Not dependent paramater.\n"
125 text +=
"## Those values should be edited following analytical the \n"
126 text +=
"## analytical expression. Some generator could simply ignore \n"
127 text +=
"## those values and use the analytical expression\n"
129 if lhablock ==
'MASS':
136 for part, param
in data:
137 if isinstance(param.value, str):
138 value = complex(
eval(param.value)).real
142 text +=
"""%s %s %f # %s : %s \n""" %(prefix, part.pdg_code,
143 value, part.name, param.value)
146 if lhablock ==
'MASS':
148 done = [part
for (part, param)
in self.
dep_massdep_mass]
151 done = [part
for (part, param)
in self.
dep_widthdep_width]
152 for particle
in all_particles:
153 if particle.pdg_code <0:
156 if particle
not in done:
157 if getattr(particle, arg).lhacode[0] != particle.pdg_code:
160 value = float(particle.get(arg).value )
161 name = particle.get(arg).name
162 text +=
"""%s %s %f # %s : %s \n""" %(prefix, particle.pdg_code,
163 value, particle.name, name)
168 self.
fsockfsock.write(text)
170 sm_pdg = [1,2,3,4,5,6,11,12,13,13,14,15,16,21,22,23,24,25]
171 data=
"""Block QNUMBERS %(pdg)d # %(name)s
172 1 %(charge)d # 3 times electric charge
173 2 %(spin)d # number of spin states (2S+1)
174 3 %(color)d # colour rep (1: singlet, 3: triplet, 8: octet)
175 4 %(antipart)d # Particle/Antiparticle distinction (0=own anti)\n"""
178 """ write qnumber """
179 from particles
import all_particles
181 print particles.__file__
182 text=
"""#===========================================================\n"""
183 text +=
"""# QUANTUM NUMBERS OF NEW STATE(S) (NON SM PDG CODE)\n"""
184 text +=
"""#===========================================================\n\n"""
186 for part
in all_particles:
187 if part.pdg_code
in self.
sm_pdgsm_pdg
or part.pdg_code < 0:
189 text += self.
datadata % {
'pdg': part.pdg_code,
191 'charge': 3 * part.charge,
194 'antipart': part.name != part.antiname
and 1
or 0}
196 self.
fsockfsock.write(text)
204 if '__main__' == __name__:
206 print 'write ./param_card.dat'
def define_not_dep_param(self, list_of_parameters)
def order_param(obj1, obj2)
def write_card(self, all_ext_param)
def write_param(self, param, lhablock)
def write_dep_param_block(self, lhablock)
def write_block(self, name)
def __init__(self, filename, list_of_parameters=None, generic=False)
double eval(const std::vector< double > &spl, const std::vector< double > &vals, double x)
Evaluate spline (zero order or first order) in point x.