2
from __future__ import absolute_import
3
from __future__ import print_function
4
__date__ = "3 june 2010"
5
__author__ = 'olivier.mattelaer@uclouvain.be'
7
class ParamCardWriter(object):
10
"""######################################################################\n""" + \
11
"""## PARAM_CARD AUTOMATICALY GENERATED BY THE UFO #####################\n""" + \
12
"""######################################################################\n"""
14
def __init__(self, filename, list_of_parameters=None):
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']
22
self.fsock = open(filename, 'w')
23
self.fsock.write(self.header)
25
self.write_card(list_of_parameters)
28
def write_card(self, all_ext_param):
34
all_lhablock = set([param.lhablock for param in all_ext_param])
36
# ordonate lhablock alphabeticaly
37
list(all_lhablock).sort()
39
for lhablock in all_lhablock:
40
self.write_block(lhablock)
41
[self.write_param(param, lhablock) for param in all_ext_param if \
42
param.lhablock == lhablock]
43
def write_block(self, name):
44
""" write a comment for a block"""
46
self.fsock.writelines(
47
"""\n###################################""" + \
48
"""\n## INFORMATION FOR %s""" % name.upper() +\
49
"""\n###################################\n"""
52
self.fsock.write("""Block %s \n""" % name)
54
def write_param(self, param, lhablock):
56
lhacode=' '.join(['%3s' % key for key in param.lhacode])
57
if lhablock != 'DECAY':
58
text = """ %s %e # %s \n""" % (lhacode, param.value, param.name )
60
text = '''DECAY %s %e \n''' % (lhacode, param.value)
61
self.fsock.write(text)
64
if '__main__' == __name__:
65
ParamCardWriter('./param_card.dat')