13
class UFOBaseClass(object):
14
"""The class from which all FeynRules classes are derived."""
18
def __init__(self, *args, **options):
19
assert(len(self.require_args) == len (args))
21
for i, name in enumerate(self.require_args):
22
setattr(self, name, args[i])
24
for (option, value) in options.items():
25
setattr(self, option, value)
28
return getattr(self, name)
30
def set(self, name, value):
31
setattr(self, name, value)
34
"""Return a dictionary containing all the information of the object"""
40
def nice_string(self):
41
""" return string with the full information """
42
return '\n'.join(['%s \t: %s' %(name, value) for name, value in self.__dict__.items()])
55
for orig,sub in replacements:
56
text = text.replace(orig,sub)
65
class Particle(UFOBaseClass):
66
"""A standard Particle"""
68
require_args=['pdg_code', 'name', 'antiname', 'spin', 'color', 'mass', 'width', 'texname', 'antitexname', 'charge']
70
require_args_all = ['pdg_code', 'name', 'antiname', 'spin', 'color', 'mass', 'width', 'texname', 'antitexname', 'charge', 'line', 'propagating', 'goldstoneboson']
72
def __init__(self, pdg_code, name, antiname, spin, color, mass, width, texname,
73
antitexname, charge , line=None, propagating=True, goldstoneboson=False, **options):
75
args= (pdg_code, name, antiname, spin, color, mass, width, texname,
76
antitexname, float(charge))
78
UFOBaseClass.__init__(self, *args, **options)
81
all_particles.append(self)
83
self.propagating = propagating
84
self.goldstoneboson= goldstoneboson
86
self.selfconjugate = (name == antiname)
88
self.line = self.find_line_type()
95
def find_line_type(self):
96
""" find how we draw a line if not defined
97
valid output: dashed/straight/wavy/curly/double/swavy/scurly
107
if not self.selfconjugate:
124
return 'dashed' # not supported yet
127
if self.selfconjugate:
128
raise Exception('%s has no anti particle.' % self.name)
130
for k,v in self.__dict__.iteritems():
131
if k not in self.require_args_all:
133
if self.color in [1,8]:
134
newcolor = self.color
136
newcolor = -self.color
138
return Particle(-self.pdg_code, self.antiname, self.name, self.spin, newcolor, self.mass, self.width,
139
self.antitexname, self.texname, -self.charge, self.line, self.propagating, self.goldstoneboson, **outdic)
145
class Parameter(UFOBaseClass):
147
require_args=['name', 'nature', 'type', 'value', 'texname']
149
def __init__(self, name, nature, type, value, texname, lhablock=None, lhacode=None):
151
args = (name,nature,type,value,texname)
153
UFOBaseClass.__init__(self, *args)
155
args=(name,nature,type,value,texname)
157
global all_parameters
158
all_parameters.append(self)
160
if (lhablock is None or lhacode is None) and nature == 'external':
161
raise Exception('Need LHA information for external parameter "%s".' % name)
162
self.lhablock = lhablock
163
self.lhacode = lhacode
167
class Vertex(UFOBaseClass):
169
require_args=['name', 'particles', 'color', 'lorentz', 'couplings']
171
def __init__(self, name, particles, color, lorentz, couplings, **opt):
173
args = (name, particles, color, lorentz, couplings)
175
UFOBaseClass.__init__(self, *args, **opt)
177
args=(particles,color,lorentz,couplings)
180
all_vertices.append(self)
184
class Coupling(UFOBaseClass):
186
require_args=['name', 'value', 'order']
188
def __init__(self, name, value, order, **opt):
190
args =(name, value, order)
191
UFOBaseClass.__init__(self, *args, **opt)
193
all_couplings.append(self)
199
class Lorentz(UFOBaseClass):
201
require_args=['name','spins','structure']
203
def __init__(self, name, spins, structure='external', **opt):
204
args = (name, spins, structure)
205
UFOBaseClass.__init__(self, *args, **opt)
208
all_lorentz.append(self)
213
class Function(object):
215
def __init__(self, name, arguments, expression):
218
all_functions.append(self)
221
self.arguments = arguments
222
self.expr = expression
224
def __call__(self, *opt):
226
for i, arg in enumerate(self.arguments):
227
exec('%s = %s' % (arg, opt[i] ))
229
return eval(self.expr)
233
class CouplingOrder(object):
235
def __init__(self, name, expansion_order, hierarchy, perturbative_expansion = 0):
238
all_orders.append(self)
241
self.expansion_order = expansion_order
242
self.hierarchy = hierarchy