4 __date__ =
'02 Aug 2012'
5 __author__ =
'olivier.mattelaer@uclouvain.be'
7 from function_library
import *
13 """######################################################################\n""" \
14 +
"""## PARAM_CARD AUTOMATICALY GENERATED BY THE UFO #####################\n""" \
15 +
"""######################################################################\n"""
20 list_of_parameters=None,
23 """write a valid param_card.dat"""
25 if not list_of_parameters:
26 from parameters
import all_parameters
27 list_of_parameters = [param
for param
in all_parameters
28 if param.nature ==
'external']
34 self.
fsockfsock = open(filename,
'w')
38 self.
fsockfsock.close()
41 """define self.dep_mass and self.dep_width in case that they are
42 requested in the param_card.dat"""
44 from particles
import all_particles
46 self.
dep_massdep_mass = [(part, part.mass)
for part
in all_particles
47 if part.pdg_code > 0
and part.mass
48 not in list_of_parameters]
49 self.
dep_widthdep_width = [(part, part.width)
for part
in all_particles
50 if part.pdg_code > 0
and part.width
51 not in list_of_parameters]
55 """ order parameter of a given block """
57 maxlen = min([len(obj1.lhacode), len(obj2.lhacode)])
59 for i
in range(maxlen):
60 if obj1.lhacode[i] < obj2.lhacode[i]:
62 elif obj1.lhacode[i] == obj2.lhacode[i]:
67 if len(obj1.lhacode) > len(obj2.lhacode):
69 elif len(obj1.lhacode) == len(obj2.lhacode):
78 all_lhablock = set([param.lhablock
for param
in all_ext_param])
81 all_lhablock = sorted(all_lhablock)
83 for name
in [
'DECAY',
'MASS',
'SMINPUTS']:
84 if name
in all_lhablock:
85 all_lhablock.remove(name)
86 all_lhablock.insert(0, name)
88 for lhablock
in all_lhablock:
90 need_writing = [param
for param
in all_ext_param
if param.lhablock
93 [self.
write_paramwrite_param(param, lhablock)
for param
in need_writing]
96 if lhablock
in [
'MASS',
'DECAY']:
103 """ write a comment for a block"""
105 self.
fsockfsock.writelines(
"""\n###################################"""
106 +
"""\n## INFORMATION FOR %s""" % name.upper()
108 ###################################
111 self.
fsockfsock.write(
"""Block %s \n""" % name)
113 def write_param(self, param, lhablock):
115 lhacode =
""" """.join([
'%3s' % key
for key
in param.lhacode])
116 if lhablock !=
'DECAY':
117 text =
""" %s %e # %s \n""" % (lhacode,
118 complex(param.value).real, param.name)
120 text =
'''DECAY %s %e \n''' % (lhacode, complex(param.value).real)
121 self.
fsockfsock.write(text)
123 def write_dep_param_block(self, lhablock):
125 from parameters
import all_parameters
126 from particles
import all_particles
127 for parameter
in all_parameters:
128 exec
'%s = %s' % (parameter.name, parameter.value)
129 text =
'## Not dependent paramater.\n'
130 text +=
'## Those values should be edited following analytical the \n'
132 '## analytical expression. Some generator could simply ignore \n'
133 text +=
'## those values and use the analytical expression\n'
135 if lhablock ==
'MASS':
142 for (part, param)
in data:
143 if isinstance(param.value, str):
144 value = complex(
eval(param.value)).real
148 text +=
"""%s %s %f # %s : %s \n""" % (prefix, part.pdg_code,
149 value, part.name, param.value)
152 if lhablock ==
'MASS':
154 done = [part
for (part, param)
in self.
dep_massdep_mass]
157 done = [part
for (part, param)
in self.
dep_widthdep_width]
158 for particle
in all_particles:
159 if particle.pdg_code < 0:
162 if particle
not in done:
163 if getattr(particle, arg).lhacode[0] != particle.pdg_code:
166 value = float(particle.get(arg).value)
167 name = particle.get(arg).name
168 text +=
"""%s %s %f # %s : %s \n""" % (prefix,
169 particle.pdg_code, value, particle.name, name)
171 self.
fsockfsock.write(text)
194 """Block QNUMBERS %(pdg)d # %(name)s
195 1 %(charge)d # 3 times electric charge
196 2 %(spin)d # number of spin states (2S+1)
197 3 %(color)d # colour rep (1: singlet, 3: triplet, 8: octet)
198 4 %(antipart)d # Particle/Antiparticle distinction (0=own anti)
202 """ write qnumber """
204 from particles
import all_particles
206 print particles.__file__
208 """#===========================================================\n"""
209 text +=
"""# QUANTUM NUMBERS OF NEW STATE(S) (NON SM PDG CODE)\n"""
211 """#===========================================================
215 for part
in all_particles:
216 if part.pdg_code
in self.
sm_pdgsm_pdg
or part.pdg_code < 0:
218 text += self.
datadata % {
219 'pdg': part.pdg_code,
221 'charge': 3 * part.charge,
224 'antipart': part.name != part.antiname
and 1
or 0,
227 self.
fsockfsock.write(text)
230 if '__main__' == __name__:
232 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.