DevelopmentPage/BeyondProjects: helasamp_object.py

File helasamp_object.py, 19.9 KB (added by Olivier Mattelaer, 14 years ago)
Line 
1################################################################################
2#
3# Copyright (c) 2010 The MadGraph Development team and Contributors
4#
5# This file is a part of the MadGraph 5 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 MadGraph license which should accompany this
10# distribution.
11#
12# For more information, please visit: http://madgraph.phys.ucl.ac.be
13#
14################################################################################
15## Diagram of Class
16##
17## Variable <--- HelasLib.ScalarVariable
18## |
19## +- LorentzObject <--- Gamma
20## |
21## +- Sigma
22## |
23## +- P
24##
25## list <--- AddVariable
26## |
27## +- MultVariable <--- MultLorentz
28##
29## list <--- LorentzObjectRepresentation <-- ConstantObject
30##
31################################################################################
32
33import madgraph.interface.helasamp_lib as HelasLib
34
35#===============================================================================
36# P (Impulsion)
37#===============================================================================
38class P(HelasLib.LorentzObject):
39 """ Helas Object for an Impulsion """
40
41 def __init__(self, lorentz1, particle, prefactor=1, constant=0):
42
43 self.particle = particle
44 HelasLib.LorentzObject.__init__(self, [lorentz1], [], ['P%s'%particle], \
45 prefactor=prefactor,constant=constant)
46
47
48 def create_representation(self):
49 self.sub0 = HelasLib.ScalarVariable('P%s_0' % self.particle, self.tag)
50 self.sub1 = HelasLib.ScalarVariable('P%s_1' % self.particle, self.tag)
51 self.sub2 = HelasLib.ScalarVariable('P%s_2' % self.particle, self.tag)
52 self.sub3 = HelasLib.ScalarVariable('P%s_3' % self.particle, self.tag)
53
54 self.representation= HelasLib.LorentzObjectRepresentation(
55 [self.sub0, self.sub1, self.sub2, self.sub3],
56 self.lorentz_ind,[],self.tag)
57
58#===============================================================================
59# Mass
60#===============================================================================
61class Mass(HelasLib.LorentzObject):
62 """ Helas Object for a Mass"""
63
64 def __init__(self, particle, prefactor=1, constant=0):
65
66 self.particle = particle
67 HelasLib.LorentzObject.__init__(self, [], [], ['M%s' % particle], \
68 prefactor=prefactor, constant=constant)
69
70
71 def create_representation(self):
72 mass = HelasLib.ScalarVariable('M%s' % self.particle, self.tag)
73
74 self.representation = HelasLib.LorentzObjectRepresentation(
75 mass, self.lorentz_ind, self.spin_ind, self.tag)
76
77#===============================================================================
78# OverMass2
79#===============================================================================
80class OverMass2(HelasLib.LorentzObject):
81 """ Helas Object for 1/M**2 """
82
83 def __init__(self, particle, prefactor=1, constant=0):
84
85 self.particle = particle
86
87 tag= ['mass%s' %particle, 'OM%s' % particle]
88 HelasLib.LorentzObject.__init__(self, [], [], tag, \
89 prefactor=prefactor, constant=constant)
90
91
92 def create_representation(self):
93 mass = HelasLib.ScalarVariable('OM%s' % self.particle, self.tag)
94
95 self.representation = HelasLib.LorentzObjectRepresentation(
96 mass, self.lorentz_ind, self.spin_ind, self.tag)
97
98#===============================================================================
99# Width
100#===============================================================================
101class Width(HelasLib.LorentzObject):
102 """ Helas Object for an Impulsion """
103
104 def __init__(self, particle, prefactor=1, constant=0):
105
106 self.particle = particle
107 HelasLib.LorentzObject.__init__(self, [], [], ['W%s' % particle], \
108 prefactor=prefactor, constant=constant)
109
110 def create_representation(self):
111 width = HelasLib.ScalarVariable('W%s' % self.particle, self.tag)
112
113 self.representation= HelasLib.LorentzObjectRepresentation(
114 width, self.lorentz_ind, self.spin_ind, self.tag)
115
116#===============================================================================
117# Scalar
118#===============================================================================
119class Scalar(HelasLib.LorentzObject):
120 """ Helas Object for a Spinor"""
121
122 def __init__(self, particle, prefactor=1, constant=0):
123
124 self.particle = particle
125 HelasLib.LorentzObject.__init__(self, [], [], ['S%s' % particle], \
126 prefactor=prefactor,constant=constant)
127
128
129 def create_representation(self):
130 rep = HelasLib.ScalarVariable('S%s_1' % self.particle, self.tag)
131 self.representation= HelasLib.LorentzObjectRepresentation(
132 rep,
133 [],[],self.tag)
134
135
136#===============================================================================
137# Spinor
138#===============================================================================
139class Spinor(HelasLib.LorentzObject):
140 """ Helas Object for a Spinor"""
141
142 def __init__(self, spin1, particle, prefactor=1, constant=0):
143
144 self.particle = particle
145 HelasLib.LorentzObject.__init__(self, [], [spin1], ['F%s' % particle], \
146 prefactor=prefactor,constant=constant)
147
148
149 def create_representation(self):
150 self.sub0 = HelasLib.ScalarVariable('F%s_1' % self.particle, self.tag)
151 self.sub1 = HelasLib.ScalarVariable('F%s_2' % self.particle, self.tag)
152 self.sub2 = HelasLib.ScalarVariable('F%s_3' % self.particle, self.tag)
153 self.sub3 = HelasLib.ScalarVariable('F%s_4' % self.particle, self.tag)
154
155 self.representation= HelasLib.LorentzObjectRepresentation(
156 [self.sub0, self.sub1, self.sub2, self.sub3],
157 [],self.spin_ind,self.tag)
158
159#===============================================================================
160# Vector
161#===============================================================================
162class Vector(HelasLib.LorentzObject):
163 """ Helas Object for a Vector"""
164
165 def __init__(self, lorentz, particle, prefactor=1, constant=0):
166
167 self.particle = particle
168 HelasLib.LorentzObject.__init__(self, [lorentz], [], ['V%s' % particle], \
169 prefactor=prefactor,constant=constant)
170
171
172 def create_representation(self):
173 self.sub0 = HelasLib.ScalarVariable('V%s_1' % self.particle, self.tag)
174 self.sub1 = HelasLib.ScalarVariable('V%s_2' % self.particle, self.tag)
175 self.sub2 = HelasLib.ScalarVariable('V%s_3' % self.particle, self.tag)
176 self.sub3 = HelasLib.ScalarVariable('V%s_4' % self.particle, self.tag)
177
178 self.representation= HelasLib.LorentzObjectRepresentation(
179 [self.sub0, self.sub1, self.sub2, self.sub3],
180 self.lorentz_ind, [], self.tag)
181
182#===============================================================================
183# Spin2
184#===============================================================================
185class Spin2(HelasLib.LorentzObject):
186 """ Helas Object for a Spin2"""
187
188 def __init__(self, lorentz1, lorentz2, particle, prefactor=1, constant=0):
189
190 self.particle = particle
191 if lorentz2 < lorentz1:
192 lorentz1, lorentz2 = lorentz2, lorentz1
193
194 HelasLib.LorentzObject.__init__(self, [lorentz1, lorentz2], [], \
195 ['G%s' % particle], prefactor=prefactor, \
196 constant=constant)
197
198 def create_representation(self):
199
200 self.sub00 = HelasLib.ScalarVariable('G%s_00' % self.particle, self.tag)
201 self.sub01 = HelasLib.ScalarVariable('G%s_01' % self.particle, self.tag)
202 self.sub02 = HelasLib.ScalarVariable('G%s_02' % self.particle, self.tag)
203 self.sub03 = HelasLib.ScalarVariable('G%s_03' % self.particle, self.tag)
204
205 self.sub11 = HelasLib.ScalarVariable('G%s_11' % self.particle, self.tag)
206 self.sub22 = HelasLib.ScalarVariable('G%s_12' % self.particle, self.tag)
207 self.sub33 = HelasLib.ScalarVariable('G%s_13' % self.particle, self.tag)
208
209 self.sub22 = HelasLib.ScalarVariable('G%s_22' % self.particle, self.tag)
210 self.sub23 = HelasLib.ScalarVariable('G%s_23' % self.particle, self.tag)
211
212 self.sub33 = HelasLib.ScalarVariable('G%s_33' % self.particle, self.tag)
213
214 rep = [[self.sub00, self.sub01, self.sub02, self.sub03], \
215 [self.sub01, self.sub11, self.sub12, self.sub13], \
216 [self.sub02, self.sub12, self.sub22, self.sub23], \
217 [self.sub03, self.sub13, self.sub22, self.sub23]]
218
219 self.representation= HelasLib.LorentzObjectRepresentation( rep, \
220 self.lorentz_ind, [], self.tag)
221
222#===============================================================================
223# Gamma
224#===============================================================================
225class Gamma(HelasLib.LorentzObject):
226 """ Gamma Matrices """
227
228 gamma0 = [[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]
229 gamma1 = [[0, 0, 0, 1], [0, 0, 1, 0], [0, -1, 0, 0], [-1, 0, 0, 0]]
230 gamma2 = [[0, 0, 0, -complex(0,1)],[0, 0, complex(0,1), 0],
231 [0, complex(0,1), 0, 0], [-complex(0,1), 0, 0, 0]]
232 gamma3 = [[0, 0, 1, 0], [0, 0, 0, -1], [-1, 0, 0, 0], [0, 1, 0, 0]]
233
234 gamma = [gamma0, gamma1, gamma2, gamma3]
235
236
237 def __init__(self, lorentz, spin1, spin2, prefactor=1, constant=0):
238 HelasLib.LorentzObject.__init__(self,[lorentz], [spin1, spin2], [])
239
240 def create_representation(self):
241
242 self.representation = HelasLib.LorentzObjectRepresentation(self.gamma,
243 self.lorentz_ind,self.spin_ind,[])
244
245#===============================================================================
246# Sigma
247#===============================================================================
248class Sigma(HelasLib.LorentzObject):
249 """ Gamma Matrices """
250
251 zero = [[0,0,0,0]]*4
252 i = complex(0,1)
253 sigma01 = [[ 0, -i, 0, 0], [-i, 0, 0, 0], [0, 0, 0, i], [0, 0, i, 0]]
254 sigma02 = [[ 0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, -1, 0]]
255 sigma03 = [[-i, 0, 0, 0], [0, i, 0, 0], [0, 0, i, 0], [0, 0, 0, -i]]
256 sigma12 = [[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, -1]]
257 sigma13 = [[0, i, 0, 0], [-i, 0, 0, 0], [0, 0, 0, i], [0, 0, -i, 0]]
258 sigma23 = [[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]
259
260
261 def inv(matrice):
262 out=[]
263 for i in range(4):
264 out2=[]
265 out.append(out2)
266 for j in range(4):
267 out2.append(-1*matrice[i][j])
268 return out
269
270 sigma =[[zero, sigma01, sigma02, sigma03], \
271 [inv(sigma01), zero, sigma12, sigma13],\
272 [inv(sigma02), inv(sigma12), zero, sigma23],\
273 [inv(sigma03), inv(sigma13), inv(sigma23), zero]]
274
275 def __init__(self, lorentz1, lorentz2, spin1, spin2, prefactor=1, constant=0):
276 if lorentz1 < lorentz2:
277 HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], \
278 [spin1, spin2], [])
279 else:
280 HelasLib.LorentzObject.__init__(self,[lorentz2, lorentz1], [spin1, spin2], \
281 [], prefactor=-1)
282
283 def create_representation(self):
284
285 self.representation = HelasLib.LorentzObjectRepresentation(self.sigma,
286 self.lorentz_ind,self.spin_ind,[])
287
288#===============================================================================
289# Gamma5
290#===============================================================================
291class Gamma5(HelasLib.LorentzObject):
292
293 gamma5 = [[-1, 0, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
294
295 def __init__(self, spin1, spin2, prefactor=1, constant=0):
296 if spin1 < spin2:
297 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
298 else:
299 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
300
301 def create_representation(self):
302
303 self.representation = HelasLib.LorentzObjectRepresentation(self.gamma5,
304 self.lorentz_ind,self.spin_ind,[])
305
306#===============================================================================
307# Metric
308#===============================================================================
309class Metric(HelasLib.LorentzObject):
310
311 metric = [[1, 0, 0,0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]]
312
313 def __init__(self, lorentz1, lorentz2, prefactor=1, constant=0):
314 if lorentz1 < lorentz2:
315 HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
316 else:
317 HelasLib.LorentzObject.__init__(self,[lorentz2, lorentz1], [], [])
318 def create_representation(self):
319
320 self.representation = HelasLib.LorentzObjectRepresentation(self.metric,
321 self.lorentz_ind,self.spin_ind,[])
322
323
324
325#===============================================================================
326# Identity
327#===============================================================================
328class Identity(HelasLib.LorentzObject):
329
330 identity = [[1, 0, 0,0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
331
332 def __init__(self, spin1, spin2, prefactor=1, constant=0):
333 if spin1 < spin2:
334 HelasLib.LorentzObject.__init__(self,[],[spin1, spin2], [])
335 else:
336 HelasLib.LorentzObject.__init__(self,[],[spin2, spin1], [])
337
338 def create_representation(self):
339
340 self.representation = HelasLib.LorentzObjectRepresentation(self.identity,
341 self.lorentz_ind,self.spin_ind,[])
342##===============================================================================
343## IdentityL (Commented since not use)
344##===============================================================================
345#class IdentityL(HelasLib.LorentzObject):
346#
347# identity = [[1, 0, 0,0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
348#
349# def __init__(self, lorentz1, lorentz2, prefactor=1, constant=0):
350# if lorentz1 < lorentz2:
351# HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
352# else:
353# HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
354#
355# def create_representation(self):
356#
357# self.representation = HelasLib.LorentzObjectRepresentation(self.identity,
358# self.lorentz_ind,self.spin_ind,[])
359#
360#===============================================================================
361# ProjM
362#===============================================================================
363class ProjM(HelasLib.LorentzObject):
364 """ A object for (1-gamma5)/2 """
365
366 projm = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
367
368 def __init__(self,spin1, spin2):
369 """Initialize the object"""
370 if spin1 < spin2:
371 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
372 else:
373 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
374
375
376 def create_representation(self):
377
378 self.representation = HelasLib.LorentzObjectRepresentation(self.projm,
379 self.lorentz_ind,self.spin_ind,[])
380
381
382#===============================================================================
383# ProjP
384#===============================================================================
385class ProjP(HelasLib.LorentzObject):
386 """A object for (1+gamma5)/2 """
387
388 projp = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
389
390 def __init__(self,spin1, spin2):
391 """Initialize the object"""
392 if spin1 < spin2:
393 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
394 else:
395 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
396
397
398 def create_representation(self):
399
400 self.representation = HelasLib.LorentzObjectRepresentation(self.projp,
401 self.lorentz_ind, self.spin_ind, [])
402
403#===============================================================================
404# Denominator Propagator
405#===============================================================================
406class DenominatorPropagator(HelasLib.LorentzObject):
407 """The Denominator of the Propagator"""
408
409 def __init__(self, particle):
410 """Initialize the object"""
411
412 self.particle = particle
413 tag=['M%s' % particle,'W%s' % particle, 'P%s' % particle]
414 HelasLib.LorentzObject.__init__(self, [], [], tag)
415
416 def simplify(self):
417 """Return the Denominator in a abstract way"""
418
419 mass = Mass(self.particle)
420 width = Width(self.particle)
421 denominator = P('i1', self.particle) * P('i1', self.particle) - \
422 mass * mass + complex(0,1) * mass* width
423
424 return denominator
425
426 def create_representation(self):
427 """Create the representation for the Vector propagator"""
428
429 object = self.simplify()
430 self.representation = object.expand()
431
432
433
434#===============================================================================
435# Numerator Propagator
436#===============================================================================
437
438
439SpinorPropagator = lambda spin1, spin2, particle: complex(0,1) * (Gamma('mu', spin1, spin2) * \
440 P('mu', particle) + Mass(particle) * Identity(spin1, spin2))
441
442VectorPropagator = lambda l1, l2, part: complex(0,1) * (-1 * Metric(l1, l2) + OverMass2(part) * \
443 Metric(l1,'I3')* P('I3', part) * P(l2, part))
444
445Spin2masslessPropagator = lambda l1, l2, l3, l4: 1/2 *( Metric(l1, l2)* \
446 Metric(l3, l4) + Metric(l1, l4) * Metric(l2, l3) - Metric(l1, l2) * Metric(l3, l4))
447
448
449
450Spin2Propagator = lambda l1, l2, l3, l4, part: Spin2masslessPropagator(l1, l2, l3, l4) + \
451 -1/2 * OverMass2(part) * (Metric(l1,l2)* P(l3, part) * P(l4, part) + \
452 Metric(l3, l4) * P(l1, part) * P(l2, part) + \
453 Metric(l1, l4) * P(l2, part) * P(l3, part) + \
454 Metric(l3, l2) * P(l1, part) * P(l4 , part) )+ \
455 1/6 * (Metric(l1,l3) + 2 * OverMass2(part) * P(l1, part) * P(l3, part)) * \
456 (Metric(l2,l4) + 2 * OverMass2(part) * P(l2, part) * P(l4, part))
457
458
459
460if __name__ == '__main__':
461
462 # Input as coming from FR!!!
463 obj = 1/DenominatorPropagator(2)
464 #Gamma(2,1,2)*Gamma(4,4,6)# * VectorPropagator(2,3,2) #/DenominatorPropagator(3)
465 print type(obj)
466 # Analysis
467 obj = obj.simplify() # -> Simplify sum
468 print obj
469
470 # expand
471
472
473 low_level = obj.expand()
474 print type(low_level)
475 low_level = low_level.simplify()
476
477 print 'all is done'
478 print low_level
479
480 #writing the object in a file
481 #low_level.create_output('Fortran','test.f')
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505