3
################################################################################
5
# Copyright (c) 2009 The MadGraph Development team and Contributors
7
# This file is a part of the MadGraph 5 project, an application which
8
# automatically generates Feynman diagrams and matrix elements for arbitrary
9
# high-energy processes in the Standard Model and beyond.
11
# It is subject to the MadGraph license which should accompany this
14
# For more information, please visit: http://madgraph.phys.ucl.ac.be
16
################################################################################
18
"""This is the main executable, a simple frontend to set up the PYTHONPATH
19
and call immediately the command line interface scripts"""
22
if not sys.version_info[0] == 2 or sys.version_info[1] < 6:
23
sys.exit('MadGraph/MadEvent 5 works only with python 2.6 or later (but not python 3.X).\n\
24
Please upgrate your version of python.')
29
# Get the directory of the script real path (bin)
30
# and add it to the current PYTHONPATH
32
root_path = os.path.dirname(os.path.dirname(os.path.realpath( __file__ )))
33
sys.path.insert(0, root_path)
36
# Write out nice usage message if called with -h or --help
37
usage = "usage: %prog [options] [FILE] "
38
parser = optparse.OptionParser(usage=usage)
39
parser.add_option("-l", "--logging", default='INFO',
40
help="logging level (DEBUG|INFO|WARNING|ERROR|CRITICAL) [%default]")
41
parser.add_option("","--debug", action="store_true", default=False, dest='debug', \
42
help='force to launch debug mode')
43
(options, args) = parser.parse_args()
49
# Check if optimize mode is (and should be) activated
50
if __debug__ and not options.debug and \
51
(not os.path.exists(os.path.join(root_path,'../..', 'bin','create_release.py'))):
52
subprocess.call([sys.executable] + ['-O'] + sys.argv)
65
print 'Running MG5 in debug mode'
68
# Set logging level according to the logging level given by options
69
#logging.basicConfig(level=vars(logging)[options.logging])
71
if __debug__ and options.logging == 'INFO':
72
options.logging = 'DEBUG'
73
logging.config.fileConfig(os.path.join(root_path, 'internal', 'me5_logging.conf'))
74
logging.root.setLevel(eval('logging.' + options.logging))
75
logging.getLogger('madgraph').setLevel(eval('logging.' + options.logging))
79
import internal.madevent_interface as cmd_interface
81
# Call the cmd interface main loop
84
cmd_line = cmd_interface.GridPackCmd(me_dir=root_path, nb_event=args[0], seed=args[1])
85
except KeyboardInterrupt:
86
print 'Quit on KeyboardInterrupt'
92
os.remove(os.path.join(root_path, 'RunWeb'))
93
if cmd_line.history[-1] not in ['EOF','quit','exit']:
94
cmd_line.results.store_result()