Package models
[hide private]
[frames] | no frames]

Source Code for Package models

 1  ################################################################################ 
 2  # 
 3  # Copyright (c) 2009 The MadGraph5_aMC@NLO Development team and Contributors 
 4  # 
 5  # This file is a part of the MadGraph5_aMC@NLO project, an application which  
 6  # automatically generates Feynman diagrams and matrix elements for arbitrary 
 7  # high-energy processes in the Standard Model and beyond. 
 8  # 
 9  # It is subject to the MadGraph5_aMC@NLO license which should accompany this  
10  # distribution. 
11  # 
12  # For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch 
13  # 
14  ################################################################################ 
15  """All models for MG5, in particular UFO models (by FeynRules)""" 
16   
17  import os 
18  import sys 
19   
20 -def load_model(name, decay=False):
21 22 # avoid final '/' in the path 23 if name.endswith('/'): 24 name = name[:-1] 25 26 27 path_split = name.split(os.sep) 28 if len(path_split) == 1: 29 model_pos = 'models.%s' % name 30 __import__(model_pos) 31 return sys.modules[model_pos] 32 elif path_split[-1] in sys.modules: 33 model_path = os.path.realpath(os.sep.join(path_split)) 34 sys_path = os.path.realpath(os.path.dirname(sys.modules[path_split[-1]].__file__)) 35 if sys_path != model_path: 36 raise Exception, 'name %s already consider as a python library cann\'t be reassigned(%s!=%s)' % \ 37 (path_split[-1], model_path, sys_path) 38 39 sys.path.insert(0, os.sep.join(path_split[:-1])) 40 __import__(path_split[-1]) 41 output = sys.modules[path_split[-1]] 42 if decay: 43 dec_name = '%s.decays' % path_split[-1] 44 try: 45 __import__(dec_name) 46 except ImportError: 47 pass 48 else: 49 output.all_decays = sys.modules[dec_name].all_decays 50 51 sys.path.pop(0) 52 53 54 55 return sys.modules[path_split[-1]]
56