~alifson/chiralityflow/trunk

« back to all changes in this revision

Viewing changes to tests/input_files/full_sm_UFO/write_param_card.py

  • Committer: andrew.lifson at lu
  • Date: 2021-09-01 15:34:39 UTC
  • Revision ID: andrew.lifson@thep.lu.se-20210901153439-7fasjhav4cp4m88r
testing a new repository of a madgraph folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from __future__ import absolute_import
 
3
from __future__ import print_function
 
4
__date__ = "3 june 2010"
 
5
__author__ = 'olivier.mattelaer@uclouvain.be'
 
6
 
 
7
class ParamCardWriter(object):
 
8
    
 
9
    header = \
 
10
    """######################################################################\n""" + \
 
11
    """## PARAM_CARD AUTOMATICALY GENERATED BY THE UFO  #####################\n""" + \
 
12
    """######################################################################\n"""   
 
13
    
 
14
    def __init__(self, filename, list_of_parameters=None):
 
15
        """write a valid param_card.dat"""
 
16
        
 
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']
 
21
        
 
22
        self.fsock = open(filename, 'w')
 
23
        self.fsock.write(self.header)
 
24
        
 
25
        self.write_card(list_of_parameters)
 
26
    
 
27
    
 
28
    def write_card(self, all_ext_param):
 
29
        """ """
 
30
        
 
31
      
 
32
        
 
33
        # list all lhablock
 
34
        all_lhablock = set([param.lhablock for param in all_ext_param])
 
35
        
 
36
        # ordonate lhablock alphabeticaly
 
37
        list(all_lhablock).sort()
 
38
        
 
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"""
 
45
        
 
46
        self.fsock.writelines(
 
47
        """\n###################################""" + \
 
48
        """\n## INFORMATION FOR %s""" % name.upper() +\
 
49
        """\n###################################\n"""
 
50
         )
 
51
        if name!='DECAY':
 
52
            self.fsock.write("""Block %s \n""" % name)
 
53
 
 
54
    def write_param(self, param, lhablock):
 
55
        
 
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 ) 
 
59
        else:
 
60
            text = '''DECAY %s %e \n''' % (lhacode, param.value)
 
61
        self.fsock.write(text) 
 
62
            
 
63
            
 
64
if '__main__' == __name__:
 
65
    ParamCardWriter('./param_card.dat')
 
66
    print('done')
 
67