DevelopmentPage/BeyondProjects: helasamp_object.2.py

File helasamp_object.2.py, 20.3 KB (added by Will Link, 14 years ago)

changed convention of spin2

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 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 ['T%s' % particle], prefactor=prefactor, \
196 constant=constant)
197
198 def create_representation(self):
199
200 self.sub00 = HelasLib.ScalarVariable('T%s_1' % self.particle, self.tag)
201 self.sub01 = HelasLib.ScalarVariable('T%s_2' % self.particle, self.tag)
202 self.sub02 = HelasLib.ScalarVariable('T%s_3' % self.particle, self.tag)
203 self.sub03 = HelasLib.ScalarVariable('T%s_4' % self.particle, self.tag)
204
205 self.sub10 = HelasLib.ScalarVariable('T%s_5' % self.particle, self.tag)
206 self.sub11 = HelasLib.ScalarVariable('T%s_6' % self.particle, self.tag)
207 self.sub12 = HelasLib.ScalarVariable('T%s_7' % self.particle, self.tag)
208 self.sub13 = HelasLib.ScalarVariable('T%s_8' % self.particle, self.tag)
209
210 self.sub20 = HelasLib.ScalarVariable('T%s_9' % self.particle, self.tag)
211 self.sub21 = HelasLib.ScalarVariable('T%s_10' % self.particle, self.tag)
212 self.sub22 = HelasLib.ScalarVariable('T%s_11' % self.particle, self.tag)
213 self.sub23 = HelasLib.ScalarVariable('T%s_12' % self.particle, self.tag)
214
215 self.sub30 = HelasLib.ScalarVariable('T%s_13' % self.particle, self.tag)
216 self.sub31 = HelasLib.ScalarVariable('T%s_14' % self.particle, self.tag)
217 self.sub32 = HelasLib.ScalarVariable('T%s_15' % self.particle, self.tag)
218 self.sub33 = HelasLib.ScalarVariable('T%s_16' % self.particle, self.tag)
219
220 rep = [[self.sub00, self.sub01, self.sub02, self.sub03], \
221 [self.sub10, self.sub11, self.sub12, self.sub13], \
222 [self.sub20, self.sub21, self.sub22, self.sub23], \
223 [self.sub30, self.sub31, self.sub32, self.sub33]]
224
225 self.representation= HelasLib.LorentzObjectRepresentation( rep, \
226 self.lorentz_ind, [], self.tag)
227
228#===============================================================================
229# Gamma
230#===============================================================================
231class Gamma(HelasLib.LorentzObject):
232 """ Gamma Matrices """
233
234 gamma0 = [[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]
235 gamma1 = [[0, 0, 0, 1], [0, 0, 1, 0], [0, -1, 0, 0], [-1, 0, 0, 0]]
236 gamma2 = [[0, 0, 0, -complex(0,1)],[0, 0, complex(0,1), 0],
237 [0, complex(0,1), 0, 0], [-complex(0,1), 0, 0, 0]]
238 gamma3 = [[0, 0, 1, 0], [0, 0, 0, -1], [-1, 0, 0, 0], [0, 1, 0, 0]]
239
240 gamma = [gamma0, gamma1, gamma2, gamma3]
241
242
243 def __init__(self, lorentz, spin1, spin2, prefactor=1, constant=0):
244 HelasLib.LorentzObject.__init__(self,[lorentz], [spin1, spin2], [])
245
246 def create_representation(self):
247
248 self.representation = HelasLib.LorentzObjectRepresentation(self.gamma,
249 self.lorentz_ind,self.spin_ind,[])
250
251#===============================================================================
252# Sigma
253#===============================================================================
254class Sigma(HelasLib.LorentzObject):
255 """ Gamma Matrices """
256
257 zero = [[0,0,0,0]]*4
258 i = complex(0,1)
259 sigma01 = [[ 0, -i, 0, 0], [-i, 0, 0, 0], [0, 0, 0, i], [0, 0, i, 0]]
260 sigma02 = [[ 0, -1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, -1, 0]]
261 sigma03 = [[-i, 0, 0, 0], [0, i, 0, 0], [0, 0, i, 0], [0, 0, 0, -i]]
262 sigma12 = [[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, -1]]
263 sigma13 = [[0, i, 0, 0], [-i, 0, 0, 0], [0, 0, 0, i], [0, 0, -i, 0]]
264 sigma23 = [[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]
265
266
267 def inv(matrice):
268 out=[]
269 for i in range(4):
270 out2=[]
271 out.append(out2)
272 for j in range(4):
273 out2.append(-1*matrice[i][j])
274 return out
275
276 sigma =[[zero, sigma01, sigma02, sigma03], \
277 [inv(sigma01), zero, sigma12, sigma13],\
278 [inv(sigma02), inv(sigma12), zero, sigma23],\
279 [inv(sigma03), inv(sigma13), inv(sigma23), zero]]
280
281 def __init__(self, lorentz1, lorentz2, spin1, spin2, prefactor=1, constant=0):
282 if lorentz1 < lorentz2:
283 HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], \
284 [spin1, spin2], [])
285 else:
286 HelasLib.LorentzObject.__init__(self,[lorentz2, lorentz1], [spin1, spin2], \
287 [], prefactor=-1)
288
289 def create_representation(self):
290
291 self.representation = HelasLib.LorentzObjectRepresentation(self.sigma,
292 self.lorentz_ind,self.spin_ind,[])
293
294#===============================================================================
295# Gamma5
296#===============================================================================
297class Gamma5(HelasLib.LorentzObject):
298
299 gamma5 = [[-1, 0, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
300
301 def __init__(self, spin1, spin2, prefactor=1, constant=0):
302 if spin1 < spin2:
303 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
304 else:
305 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
306
307 def create_representation(self):
308
309 self.representation = HelasLib.LorentzObjectRepresentation(self.gamma5,
310 self.lorentz_ind,self.spin_ind,[])
311
312#===============================================================================
313# Metric
314#===============================================================================
315class Metric(HelasLib.LorentzObject):
316
317 metric = [[1, 0, 0,0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]]
318
319 def __init__(self, lorentz1, lorentz2, prefactor=1, constant=0):
320 if lorentz1 < lorentz2:
321 HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
322 else:
323 HelasLib.LorentzObject.__init__(self,[lorentz2, lorentz1], [], [])
324 def create_representation(self):
325
326 self.representation = HelasLib.LorentzObjectRepresentation(self.metric,
327 self.lorentz_ind,self.spin_ind,[])
328
329
330
331#===============================================================================
332# Identity
333#===============================================================================
334class Identity(HelasLib.LorentzObject):
335
336 identity = [[1, 0, 0,0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
337
338 def __init__(self, spin1, spin2, prefactor=1, constant=0):
339 if spin1 < spin2:
340 HelasLib.LorentzObject.__init__(self,[],[spin1, spin2], [])
341 else:
342 HelasLib.LorentzObject.__init__(self,[],[spin2, spin1], [])
343
344 def create_representation(self):
345
346 self.representation = HelasLib.LorentzObjectRepresentation(self.identity,
347 self.lorentz_ind,self.spin_ind,[])
348##===============================================================================
349## IdentityL (Commented since not use)
350##===============================================================================
351#class IdentityL(HelasLib.LorentzObject):
352#
353# identity = [[1, 0, 0,0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
354#
355# def __init__(self, lorentz1, lorentz2, prefactor=1, constant=0):
356# if lorentz1 < lorentz2:
357# HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
358# else:
359# HelasLib.LorentzObject.__init__(self,[lorentz1, lorentz2], [], [])
360#
361# def create_representation(self):
362#
363# self.representation = HelasLib.LorentzObjectRepresentation(self.identity,
364# self.lorentz_ind,self.spin_ind,[])
365#
366#===============================================================================
367# ProjM
368#===============================================================================
369class ProjM(HelasLib.LorentzObject):
370 """ A object for (1-gamma5)/2 """
371
372 projm = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
373
374 def __init__(self,spin1, spin2):
375 """Initialize the object"""
376 if spin1 < spin2:
377 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
378 else:
379 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
380
381
382 def create_representation(self):
383
384 self.representation = HelasLib.LorentzObjectRepresentation(self.projm,
385 self.lorentz_ind,self.spin_ind,[])
386
387
388#===============================================================================
389# ProjP
390#===============================================================================
391class ProjP(HelasLib.LorentzObject):
392 """A object for (1+gamma5)/2 """
393
394 projp = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
395
396 def __init__(self,spin1, spin2):
397 """Initialize the object"""
398 if spin1 < spin2:
399 HelasLib.LorentzObject.__init__(self,[], [spin1, spin2], [])
400 else:
401 HelasLib.LorentzObject.__init__(self,[], [spin2, spin1], [])
402
403
404 def create_representation(self):
405
406 self.representation = HelasLib.LorentzObjectRepresentation(self.projp,
407 self.lorentz_ind, self.spin_ind, [])
408
409#===============================================================================
410# Denominator Propagator
411#===============================================================================
412class DenominatorPropagator(HelasLib.LorentzObject):
413 """The Denominator of the Propagator"""
414
415 def __init__(self, particle):
416 """Initialize the object"""
417
418 self.particle = particle
419 tag=['M%s' % particle,'W%s' % particle, 'P%s' % particle]
420 HelasLib.LorentzObject.__init__(self, [], [], tag)
421
422 def simplify(self):
423 """Return the Denominator in a abstract way"""
424
425 mass = Mass(self.particle)
426 width = Width(self.particle)
427 denominator = P('i1', self.particle) * P('i1', self.particle) - \
428 mass * mass + complex(0,1) * mass* width
429
430 return denominator
431
432 def create_representation(self):
433 """Create the representation for the Vector propagator"""
434
435 object = self.simplify()
436 self.representation = object.expand()
437
438
439
440#===============================================================================
441# Numerator Propagator
442#===============================================================================
443
444
445SpinorPropagator = lambda spin1, spin2, particle: complex(0,1) * (Gamma('mu', spin1, spin2) * \
446 P('mu', particle) + Mass(particle) * Identity(spin1, spin2))
447
448VectorPropagator = lambda l1, l2, part: complex(0,1) * (-1 * Metric(l1, l2) + OverMass2(part) * \
449 Metric(l1,'I3')* P('I3', part) * P(l2, part))
450
451Spin2masslessPropagator = lambda l1, l2, l3, l4: 1/2 *( Metric(l1, l2)* \
452 Metric(l3, l4) + Metric(l1, l4) * Metric(l2, l3) - Metric(l1, l2) * Metric(l3, l4))
453
454
455
456Spin2Propagator = lambda l1, l2, l3, l4, part: Spin2masslessPropagator(l1, l2, l3, l4) + \
457 -1/2 * OverMass2(part) * (Metric(l1,l2)* P(l3, part) * P(l4, part) + \
458 Metric(l3, l4) * P(l1, part) * P(l2, part) + \
459 Metric(l1, l4) * P(l2, part) * P(l3, part) + \
460 Metric(l3, l2) * P(l1, part) * P(l4 , part) )+ \
461 1/6 * (Metric(l1,l3) + 2 * OverMass2(part) * P(l1, part) * P(l3, part)) * \
462 (Metric(l2,l4) + 2 * OverMass2(part) * P(l2, part) * P(l4, part))
463
464
465
466if __name__ == '__main__':
467
468 # Input as coming from FR!!!
469 obj = 1/DenominatorPropagator(2)
470 #Gamma(2,1,2)*Gamma(4,4,6)# * VectorPropagator(2,3,2) #/DenominatorPropagator(3)
471 print type(obj)
472 # Analysis
473 obj = obj.simplify() # -> Simplify sum
474 print obj
475
476 # expand
477
478
479 low_level = obj.expand()
480 print type(low_level)
481 low_level = low_level.simplify()
482
483 print 'all is done'
484 print low_level
485
486 #writing the object in a file
487 #low_level.create_output('Fortran','test.f')
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511