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', 'loop_particles', 'counterterm','line', 'propagating', 'goldstoneboson']
72
def __init__(self, pdg_code, name, antiname, spin, color, mass, width, texname,
73
antitexname, charge , loop_particles=None, counterterm=None, 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()
92
def find_line_type(self):
93
""" find how we draw a line if not defined
94
valid output: dashed/straight/wavy/curly/double/swavy/scurly
104
if not self.selfconjugate:
121
return 'dashed' # not supported yet
124
if self.selfconjugate:
125
raise Exception('%s has no anti particle.' % self.name)
127
for k,v in self.__dict__.iteritems():
128
if k not in self.require_args_all:
130
if self.color in [1,8]:
131
newcolor = self.color
133
newcolor = -self.color
135
return Particle(-self.pdg_code, self.antiname, self.name, self.spin, newcolor, self.mass, self.width,
136
self.antitexname, self.texname, -self.charge, self.line, self.propagating, self.goldstoneboson, **outdic)
142
class Parameter(UFOBaseClass):
144
require_args=['name', 'nature', 'type', 'value', 'texname']
146
def __init__(self, name, nature, type, value, texname, lhablock=None, lhacode=None):
148
args = (name,nature,type,value,texname)
150
UFOBaseClass.__init__(self, *args)
152
args=(name,nature,type,value,texname)
154
global all_parameters
155
all_parameters.append(self)
157
if (lhablock is None or lhacode is None) and nature == 'external':
158
raise Exception('Need LHA information for external parameter "%s".' % name)
159
self.lhablock = lhablock
160
self.lhacode = lhacode
162
all_CTparameters = []
164
class CTParameter(UFOBaseClass):
166
require_args=['name', 'type', 'value', 'texname']
168
def __init__(self, name, type, value, texname):
170
args = (name,type,value,texname)
172
UFOBaseClass.__init__(self, *args)
174
args=(name,type,value,texname)
176
self.nature='interal'
178
global all_CTparameters
179
all_CTparameters.append(self)
195
class Vertex(UFOBaseClass):
197
require_args=['name', 'particles', 'color', 'lorentz', 'couplings']
199
def __init__(self, name, particles, color, lorentz, couplings, **opt):
201
args = (name, particles, color, lorentz, couplings)
203
UFOBaseClass.__init__(self, *args, **opt)
205
args=(particles,color,lorentz,couplings)
208
all_vertices.append(self)
212
class CTVertex(UFOBaseClass):
214
require_args=['name', 'particles', 'color', 'lorentz', 'couplings', 'type', 'loop_particles']
216
def __init__(self, name, particles, color, lorentz, couplings, type, loop_particles, **opt):
218
args = (name, particles, color, lorentz, couplings, type, loop_particles)
220
UFOBaseClass.__init__(self, *args, **opt)
222
args=(particles,color,lorentz,couplings, type, loop_particles)
224
global all_CTvertices
225
all_CTvertices.append(self)
229
class Coupling(UFOBaseClass):
231
require_args=['name', 'value', 'order']
233
require_args_all=['name', 'value', 'order', 'loop_particles', 'counterterm']
235
def __init__(self, name, value, order, loop_particles=None, counterterm=None, **opt):
237
args =(name, value, order)
238
UFOBaseClass.__init__(self, *args, **opt)
240
all_couplings.append(self)
246
class Lorentz(UFOBaseClass):
248
require_args=['name','spins','structure']
250
def __init__(self, name, spins, structure='external', **opt):
251
args = (name, spins, structure)
252
UFOBaseClass.__init__(self, *args, **opt)
255
all_lorentz.append(self)
260
class Function(object):
262
def __init__(self, name, arguments, expression):
265
all_functions.append(self)
268
self.arguments = arguments
269
self.expr = expression
271
def __call__(self, *opt):
273
for i, arg in enumerate(self.arguments):
274
exec('%s = %s' % (arg, opt[i] ))
276
return eval(self.expr)
280
class CouplingOrder(object):
282
def __init__(self, name, expansion_order, hierarchy, perturbative_expansion = 0):
285
all_orders.append(self)
288
self.expansion_order = expansion_order
289
self.hierarchy = hierarchy