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 path_split = name.split(os.sep) 27 if len(path_split) == 1: 28 model_pos = 'models.%s' % name 29 __import__(model_pos) 30 return sys.modules[model_pos] 31 elif path_split[-1] in sys.modules: 32 model_path = os.path.realpath(os.sep.join(path_split)) 33 sys_path = os.path.realpath(os.path.dirname(sys.modules[path_split[-1]].__file__)) 34 if sys_path != model_path: 35 raise Exception, 'name %s already consider as a python library cann\'t be reassigned' % \ 36 path_split[-1] 37 38 sys.path.insert(0, os.sep.join(path_split[:-1])) 39 __import__(path_split[-1]) 40 output = sys.modules[path_split[-1]] 41 if decay: 42 dec_name = '%s.decays' % path_split[-1] 43 try: 44 __import__(dec_name) 45 except ImportError: 46 pass 47 else: 48 output.all_decays = sys.modules[dec_name].all_decays 49 50 sys.path.pop(0) 51 52 53 54 return sys.modules[path_split[-1]]
55