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.
fsock = open(filename,
'w')
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_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_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 = list(all_lhablock)
84 for name
in [
'DECAY',
'MASS',
'SMINPUTS']:
85 if name
in all_lhablock:
86 all_lhablock.remove(name)
87 all_lhablock.insert(0, name)
89 for lhablock
in all_lhablock:
91 need_writing = [param
for param
in all_ext_param
if param.lhablock
94 [self.
write_param(param, lhablock)
for param
in need_writing]
97 if lhablock
in [
'MASS',
'DECAY']:
104 """ write a comment for a block"""
106 self.
fsock.writelines(
"""\n###################################"""
107 +
"""\n## INFORMATION FOR %s""" % name.upper()
109 ###################################
112 self.
fsock.write(
"""Block %s \n""" % name)
114 def write_param(self, param, lhablock):
116 lhacode =
""" """.join([
'%3s' % key
for key
in param.lhacode])
117 if lhablock !=
'DECAY':
118 text =
""" %s %e # %s \n""" % (lhacode,
119 complex(param.value).real, param.name)
121 text =
'''DECAY %s %e \n''' % (lhacode, complex(param.value).real)
122 self.
fsock.write(text)
124 def write_dep_param_block(self, lhablock):
126 from parameters
import all_parameters
127 from particles
import all_particles
128 for parameter
in all_parameters:
129 exec
'%s = %s' % (parameter.name, parameter.value)
130 text =
'## Not dependent paramater.\n'
131 text +=
'## Those values should be edited following analytical the \n'
133 '## analytical expression. Some generator could simply ignore \n'
134 text +=
'## those values and use the analytical expression\n'
136 if lhablock ==
'MASS':
143 for (part, param)
in data:
144 if isinstance(param.value, str):
145 value = complex(
eval(param.value)).real
149 text +=
"""%s %s %f # %s : %s \n""" % (prefix, part.pdg_code,
150 value, part.name, param.value)
153 if lhablock ==
'MASS':
155 done = [part
for (part, param)
in self.
dep_mass]
158 done = [part
for (part, param)
in self.
dep_width]
159 for particle
in all_particles:
160 if particle.pdg_code < 0:
163 if particle
not in done:
164 if getattr(particle, arg).lhacode[0] != particle.pdg_code:
167 value = float(particle.get(arg).value)
168 name = particle.get(arg).name
169 text +=
"""%s %s %f # %s : %s \n""" % (prefix,
170 particle.pdg_code, value, particle.name, name)
172 self.
fsock.write(text)
195 """Block QNUMBERS %(pdg)d # %(name)s
196 1 %(charge)d # 3 times electric charge
197 2 %(spin)d # number of spin states (2S+1)
198 3 %(color)d # colour rep (1: singlet, 3: triplet, 8: octet)
199 4 %(antipart)d # Particle/Antiparticle distinction (0=own anti)
203 """ write qnumber """
205 from particles
import all_particles
207 print particles.__file__
209 """#===========================================================\n"""
210 text +=
"""# QUANTUM NUMBERS OF NEW STATE(S) (NON SM PDG CODE)\n"""
212 """#===========================================================
216 for part
in all_particles:
217 if part.pdg_code
in self.
sm_pdg or part.pdg_code < 0:
219 text += self.
data % {
220 'pdg': part.pdg_code,
222 'charge': 3 * part.charge,
225 'antipart': part.name != part.antiname
and 1
or 0,
228 self.
fsock.write(text)
231 if '__main__' == __name__:
233 print 'write ./param_card.dat'