~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to Template/NLO/bin/calculate_xsect

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
################################################################################
 
3
#
 
4
# Copyright (c) 2011 The MadGraph5_aMC@NLO Development team and Contributors
 
5
#
 
6
# This file is a part of the MadGraph5_aMC@NLO project, an application which 
 
7
# automatically generates Feynman diagrams and matrix elements for arbitrary
 
8
# high-energy processes in the Standard Model and beyond.
 
9
#
 
10
# It is subject to the MadGraph5_aMC@NLO license which should accompany this 
 
11
# distribution.
 
12
#
 
13
# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch
 
14
#
 
15
################################################################################
 
16
""" This is the main script in order to generate events in MadEvent """
 
17
 
 
18
import logging
 
19
import logging.config
 
20
import os
 
21
import re
 
22
import shutil
 
23
import subprocess
 
24
import sys
 
25
import time
 
26
root_path = os.path.split(os.path.dirname(os.path.realpath( __file__ )))[0]
 
27
pjoin = os.path.join
 
28
sys.path.append(pjoin(root_path,'bin','internal'))
 
29
import amcatnlo_run_interface as run      
 
30
 
 
31
if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
 
32
    sys.exit('MadEvent works with python 2.6 or higher (but not python 3.X).\n\
 
33
               Please upgrade your version of python.')
 
34
 
 
35
 
 
36
def set_configuration():
 
37
    import coloring_logging
 
38
    logging.config.fileConfig(os.path.join(root_path, 'bin', 'internal', 'me5_logging.conf'))
 
39
    logging.root.setLevel(logging.INFO)
 
40
    logging.getLogger('amcatnlo').setLevel(logging.INFO)
 
41
    logging.getLogger('madgraph').setLevel(logging.INFO)    
 
42
 
 
43
 
 
44
def treat_old_argument(argument):
 
45
    """Have the MG4 behavior for this script"""
 
46
 
 
47
    try:
 
48
        mode = int(argument[1])
 
49
    except:
 
50
        mode = int(raw_input('Enter 2 for multi-core, 1 for parallel, 0 for serial run\n'))
 
51
    if mode == 0:
 
52
        try:
 
53
            name = argument[2]
 
54
        except:
 
55
            name = raw_input('Enter run name\n')
 
56
    else:
 
57
        try:
 
58
            opt = argument[2]
 
59
        except:
 
60
            if mode == 1: 
 
61
                opt = raw_input('Enter name for jobs on pbs queue\n')
 
62
            else:
 
63
                opt = int(raw_input('Enter number of cores\n'))
 
64
        
 
65
        try:
 
66
            name = argument[3]
 
67
        except:
 
68
            name = raw_input('enter run name\n')
 
69
 
 
70
#    launch = ME.MadEventCmd(me_dir=root_path)
 
71
        
 
72
 
 
73
    if mode == 1:
 
74
        argument = ['fake','-f', str(name), '--cluster']
 
75
    elif mode == 2:
 
76
        argument = ['fake','-f', '--multicore', str(name), '--nb_core=%s' % opt]
 
77
    else:
 
78
        argument = ['fake','-f', name]
 
79
 
 
80
    return argument
 
81
 
 
82
 
 
83
 
 
84
 
 
85
 
 
86
 
 
87
 
 
88
################################################################################  
 
89
##   EXECUTABLE
 
90
################################################################################                                
 
91
if '__main__' == __name__:
 
92
    # Check that python version is valid
 
93
 
 
94
    set_configuration()
 
95
    argument = sys.argv
 
96
    try:
 
97
        if '-h' in argument or '--help' in argument:
 
98
            launch = run.aMCatNLOCmd(me_dir=root_path)
 
99
            launch.exec_cmd('help calculate_xsect')
 
100
            sys.exit()
 
101
        elif len(argument) > 1 and argument[1] in ['0', '1', '2']:
 
102
            argument = treat_old_argument(argument)
 
103
        
 
104
        launch = run.aMCatNLOCmd(me_dir=root_path)
 
105
        launch.run_cmd('calculate_xsect %s' % ' '.join(argument[1:]))
 
106
        launch.run_cmd('quit')
 
107
    except KeyboardInterrupt:
 
108
        try:
 
109
            launch.run_cmd('quit')
 
110
        except:
 
111
            pass
 
112
                          
 
113
    if os.path.exists(pjoin(root_path, 'RunWeb')):  
 
114
        os.remove(pjoin(root_path, 'RunWeb'))      
 
115
            
 
116
    # reconfigure path for the web 
 
117
    #if len(argument) == 5:
 
118
    #    ME.pass_in_web_mode()
 
119
 
 
120
             
 
121
        
 
122
 
 
123
        
 
124
    
 
125
    
 
126
    
 
127
    
 
128
    
 
129
    
 
130