EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
EvtGammaMatrix.cpp
Go to the documentation of this file.
1
2/***********************************************************************
3* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4* *
5* This file is part of EvtGen. *
6* *
7* EvtGen is free software: you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation, either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* EvtGen is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19***********************************************************************/
20
22
28
29#include <assert.h>
30#include <iostream>
31#include <math.h>
32#include <stdlib.h>
33using std::endl;
34using std::ostream;
35
37{
38 int i, j;
39
40 static const EvtComplex zero( 0.0, 0.0 );
41
42 for ( i = 0; i < 4; i++ ) {
43 for ( j = 0; j < 4; j++ ) {
44 m_gamma[i][j] = zero;
45 }
46 }
47}
48
50{
51 return c * g;
52}
53
55{
56 int i, j;
57
58 EvtGammaMatrix temp;
59
60 for ( i = 0; i < 4; i++ ) {
61 for ( j = 0; j < 4; j++ ) {
62 temp.m_gamma[i][j] = g.m_gamma[i][j] * c;
63 }
64 }
65
66 return temp;
67}
68
69ostream& operator<<( ostream& s, const EvtGammaMatrix& g )
70{
71 s << "[" << g.m_gamma[0][0] << "," << g.m_gamma[0][1] << ","
72 << g.m_gamma[0][2] << "," << g.m_gamma[0][3] << "]" << endl;
73 s << "[" << g.m_gamma[1][0] << "," << g.m_gamma[1][1] << ","
74 << g.m_gamma[1][2] << "," << g.m_gamma[1][3] << "]" << endl;
75 s << "[" << g.m_gamma[2][0] << "," << g.m_gamma[2][1] << ","
76 << g.m_gamma[2][2] << "," << g.m_gamma[2][3] << "]" << endl;
77 s << "[" << g.m_gamma[3][0] << "," << g.m_gamma[3][1] << ","
78 << g.m_gamma[3][2] << "," << g.m_gamma[3][3] << "]" << endl;
79
80 return s;
81}
82
84{
85 int i, j;
86
87 for ( i = 0; i < 4; i++ ) {
88 for ( j = 0; j < 4; j++ ) {
89 m_gamma[i][j] = gm.m_gamma[i][j];
90 }
91 }
92}
93
95{
96 int i, j;
97
98 for ( i = 0; i < 4; i++ ) {
99 for ( j = 0; j < 4; j++ ) {
100 m_gamma[i][j] = gm.m_gamma[i][j];
101 }
102 }
103 return *this;
104}
105
107{
108 int i, j;
109
110 static const EvtComplex zero( 0.0, 0.0 );
111
112 for ( i = 0; i < 4; i++ ) {
113 for ( j = 0; j < 4; j++ ) {
114 m_gamma[i][j] = zero;
115 }
116 }
117}
118
120{
121 static thread_local EvtGammaMatrix g;
122 static thread_local int first = 1;
123
124 if ( first ) {
125 first = 0;
126 g.m_gamma[0][0] = EvtComplex( 1.0, 0.0 );
127 g.m_gamma[0][1] = EvtComplex( 0.0, 0.0 );
128 g.m_gamma[0][2] = EvtComplex( -1.0, 0.0 );
129 g.m_gamma[0][3] = EvtComplex( 0.0, 0.0 );
130 g.m_gamma[1][0] = EvtComplex( 0.0, 0.0 );
131 g.m_gamma[1][1] = EvtComplex( 1.0, 0.0 );
132 g.m_gamma[1][2] = EvtComplex( 0.0, 0.0 );
133 g.m_gamma[1][3] = EvtComplex( -1.0, 0.0 );
134 g.m_gamma[2][0] = EvtComplex( -1.0, 0.0 );
135 g.m_gamma[2][1] = EvtComplex( 0.0, 0.0 );
136 g.m_gamma[2][2] = EvtComplex( 1.0, 0.0 );
137 g.m_gamma[2][3] = EvtComplex( 0.0, 0.0 );
138 g.m_gamma[3][0] = EvtComplex( 0.0, 0.0 );
139 g.m_gamma[3][1] = EvtComplex( -1.0, 0.0 );
140 g.m_gamma[3][2] = EvtComplex( 0.0, 0.0 );
141 g.m_gamma[3][3] = EvtComplex( 1.0, 0.0 );
142 }
143
144 return g;
145}
146
148{
149 static thread_local EvtGammaMatrix g;
150 static thread_local int first = 1;
151
152 if ( first ) {
153 first = 0;
154 g.m_gamma[0][0] = EvtComplex( 0.0, 0.0 );
155 g.m_gamma[0][1] = EvtComplex( -1.0, 0.0 );
156 g.m_gamma[0][2] = EvtComplex( 0.0, 0.0 );
157 g.m_gamma[0][3] = EvtComplex( 1.0, 0.0 );
158 g.m_gamma[1][0] = EvtComplex( -1.0, 0.0 );
159 g.m_gamma[1][1] = EvtComplex( 0.0, 0.0 );
160 g.m_gamma[1][2] = EvtComplex( 1.0, 0.0 );
161 g.m_gamma[1][3] = EvtComplex( 0.0, 0.0 );
162 g.m_gamma[2][0] = EvtComplex( 0.0, 0.0 );
163 g.m_gamma[2][1] = EvtComplex( 1.0, 0.0 );
164 g.m_gamma[2][2] = EvtComplex( 0.0, 0.0 );
165 g.m_gamma[2][3] = EvtComplex( -1.0, 0.0 );
166 g.m_gamma[3][0] = EvtComplex( 1.0, 0.0 );
167 g.m_gamma[3][1] = EvtComplex( 0.0, 0.0 );
168 g.m_gamma[3][2] = EvtComplex( -1.0, 0.0 );
169 g.m_gamma[3][3] = EvtComplex( 0.0, 0.0 );
170 }
171
172 return g;
173}
174
176{
177 static thread_local EvtGammaMatrix g;
178 static thread_local int first = 1;
179
180 if ( first ) {
181 first = 0;
182 g.m_gamma[0][0] = EvtComplex( 0.0, 0.0 );
183 g.m_gamma[0][1] = EvtComplex( 0.0, 1.0 );
184 g.m_gamma[0][2] = EvtComplex( 0.0, 0.0 );
185 g.m_gamma[0][3] = EvtComplex( 0.0, -1.0 );
186 g.m_gamma[1][0] = EvtComplex( 0.0, -1.0 );
187 g.m_gamma[1][1] = EvtComplex( 0.0, 0.0 );
188 g.m_gamma[1][2] = EvtComplex( 0.0, 1.0 );
189 g.m_gamma[1][3] = EvtComplex( 0.0, 0.0 );
190 g.m_gamma[2][0] = EvtComplex( 0.0, 0.0 );
191 g.m_gamma[2][1] = EvtComplex( 0.0, -1.0 );
192 g.m_gamma[2][2] = EvtComplex( 0.0, 0.0 );
193 g.m_gamma[2][3] = EvtComplex( 0.0, 1.0 );
194 g.m_gamma[3][0] = EvtComplex( 0.0, 1.0 );
195 g.m_gamma[3][1] = EvtComplex( 0.0, 0.0 );
196 g.m_gamma[3][2] = EvtComplex( 0.0, -1.0 );
197 g.m_gamma[3][3] = EvtComplex( 0.0, 0.0 );
198 }
199
200 return g;
201}
202
204{
205 static thread_local EvtGammaMatrix g;
206 static thread_local int first = 1;
207
208 if ( first ) {
209 first = 0;
210 g.m_gamma[0][0] = EvtComplex( -1.0, 0.0 );
211 g.m_gamma[0][1] = EvtComplex( 0.0, 0.0 );
212 g.m_gamma[0][2] = EvtComplex( 1.0, 0.0 );
213 g.m_gamma[0][3] = EvtComplex( 0.0, 0.0 );
214 g.m_gamma[1][0] = EvtComplex( 0.0, 0.0 );
215 g.m_gamma[1][1] = EvtComplex( 1.0, 0.0 );
216 g.m_gamma[1][2] = EvtComplex( 0.0, 0.0 );
217 g.m_gamma[1][3] = EvtComplex( -1.0, 0.0 );
218 g.m_gamma[2][0] = EvtComplex( 1.0, 0.0 );
219 g.m_gamma[2][1] = EvtComplex( 0.0, 0.0 );
220 g.m_gamma[2][2] = EvtComplex( -1.0, 0.0 );
221 g.m_gamma[2][3] = EvtComplex( 0.0, 0.0 );
222 g.m_gamma[3][0] = EvtComplex( 0.0, 0.0 );
223 g.m_gamma[3][1] = EvtComplex( -1.0, 0.0 );
224 g.m_gamma[3][2] = EvtComplex( 0.0, 0.0 );
225 g.m_gamma[3][3] = EvtComplex( 1.0, 0.0 );
226 }
227
228 return g;
229}
230
232{
233 static thread_local EvtGammaMatrix g;
234 static thread_local int first = 1;
235
236 if ( first ) {
237 first = 0;
238
239 int i, j;
240
241 for ( i = 0; i < 4; i++ ) {
242 for ( j = 0; j < 4; j++ ) {
243 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
244 }
245 }
246
247 g.m_gamma[0][0] = EvtComplex( 1.0, 0.0 );
248 g.m_gamma[1][1] = EvtComplex( 1.0, 0.0 );
249 g.m_gamma[2][2] = EvtComplex( -1.0, 0.0 );
250 g.m_gamma[3][3] = EvtComplex( -1.0, 0.0 );
251 }
252
253 return g;
254}
255
257{
258 static thread_local EvtGammaMatrix g;
259 static thread_local int first = 1;
260
261 if ( first ) {
262 first = 0;
263 int i, j;
264
265 for ( i = 0; i < 4; i++ ) {
266 for ( j = 0; j < 4; j++ ) {
267 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
268 }
269 }
270
271 g.m_gamma[0][3] = EvtComplex( 1.0, 0.0 );
272 g.m_gamma[1][2] = EvtComplex( 1.0, 0.0 );
273 g.m_gamma[2][1] = EvtComplex( -1.0, 0.0 );
274 g.m_gamma[3][0] = EvtComplex( -1.0, 0.0 );
275 }
276
277 return g;
278}
279
281{
282 static thread_local EvtGammaMatrix g;
283 static thread_local int first = 1;
284
285 if ( first ) {
286 first = 0;
287 int i, j;
288
289 for ( i = 0; i < 4; i++ ) {
290 for ( j = 0; j < 4; j++ ) {
291 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
292 }
293 }
294
295 g.m_gamma[0][3] = EvtComplex( 0.0, -1.0 );
296 g.m_gamma[1][2] = EvtComplex( 0.0, 1.0 );
297 g.m_gamma[2][1] = EvtComplex( 0.0, 1.0 );
298 g.m_gamma[3][0] = EvtComplex( 0.0, -1.0 );
299 }
300
301 return g;
302}
303
305{
306 static thread_local EvtGammaMatrix g;
307 static thread_local int first = 1;
308
309 if ( first ) {
310 first = 0;
311 int i, j;
312
313 for ( i = 0; i < 4; i++ ) {
314 for ( j = 0; j < 4; j++ ) {
315 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
316 }
317 }
318
319 g.m_gamma[0][2] = EvtComplex( 1.0, 0.0 );
320 g.m_gamma[1][3] = EvtComplex( -1.0, 0.0 );
321 g.m_gamma[2][0] = EvtComplex( -1.0, 0.0 );
322 g.m_gamma[3][1] = EvtComplex( 1.0, 0.0 );
323 }
324
325 return g;
326}
327
329{
330 static thread_local EvtGammaMatrix g;
331 static thread_local int first = 1;
332
333 if ( first ) {
334 first = 0;
335 int i, j;
336
337 for ( i = 0; i < 4; i++ ) {
338 for ( j = 0; j < 4; j++ ) {
339 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
340 }
341 }
342
343 g.m_gamma[0][2] = EvtComplex( 1.0, 0.0 );
344 g.m_gamma[1][3] = EvtComplex( 1.0, 0.0 );
345 g.m_gamma[2][0] = EvtComplex( 1.0, 0.0 );
346 g.m_gamma[3][1] = EvtComplex( 1.0, 0.0 );
347 }
348
349 return g;
350}
351
353{
354 switch ( index ) {
355 case 0:
356 return g0();
357 case 1:
358 return g1();
359 case 2:
360 return g2();
361 case 3:
362 return g3();
363 case 5:
364 return g5();
365 default:
366 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
367 << "Invalid index for four vector: " << index << endl;
368 exit( -2 );
369 }
370}
371
373{
374 static thread_local EvtGammaMatrix g;
375 static thread_local int first = 1;
376
377 if ( first ) {
378 first = 0;
379 int i, j;
380
381 for ( i = 0; i < 4; i++ ) {
382 for ( j = 0; j < 4; j++ ) {
383 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
384 }
385 }
386
387 g.m_gamma[0][0] = EvtComplex( 1.0, 0.0 );
388 g.m_gamma[1][1] = EvtComplex( 1.0, 0.0 );
389 g.m_gamma[2][2] = EvtComplex( 1.0, 0.0 );
390 g.m_gamma[3][3] = EvtComplex( 1.0, 0.0 );
391 }
392
393 return g;
394}
395
397{
398 static thread_local EvtGammaMatrix g;
399 static thread_local int first = 1;
400
401 if ( first ) {
402 first = 0;
403 int i, j;
404
405 for ( i = 0; i < 4; i++ ) {
406 for ( j = 0; j < 4; j++ ) {
407 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
408 }
409 }
410
411 g.m_gamma[0][3] = EvtComplex( 1.0, 0.0 );
412 g.m_gamma[1][2] = EvtComplex( 1.0, 0.0 );
413 g.m_gamma[2][1] = EvtComplex( 1.0, 0.0 );
414 g.m_gamma[3][0] = EvtComplex( 1.0, 0.0 );
415 }
416
417 return g;
418}
419
421{
422 static thread_local EvtGammaMatrix g;
423 static thread_local int first = 1;
424
425 if ( first ) {
426 first = 0;
427 int i, j;
428
429 for ( i = 0; i < 4; i++ ) {
430 for ( j = 0; j < 4; j++ ) {
431 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
432 }
433 }
434
435 g.m_gamma[0][3] = EvtComplex( 0.0, -1.0 );
436 g.m_gamma[1][2] = EvtComplex( 0.0, 1.0 );
437 g.m_gamma[2][1] = EvtComplex( 0.0, -1.0 );
438 g.m_gamma[3][0] = EvtComplex( 0.0, 1.0 );
439 }
440
441 return g;
442}
443
445{
446 static thread_local EvtGammaMatrix g;
447 static thread_local int first = 1;
448
449 if ( first ) {
450 first = 0;
451 int i, j;
452
453 for ( i = 0; i < 4; i++ ) {
454 for ( j = 0; j < 4; j++ ) {
455 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
456 }
457 }
458
459 g.m_gamma[0][2] = EvtComplex( 1.0, 0.0 );
460 g.m_gamma[1][3] = EvtComplex( -1.0, 0.0 );
461 g.m_gamma[2][0] = EvtComplex( 1.0, 0.0 );
462 g.m_gamma[3][1] = EvtComplex( -1.0, 0.0 );
463 }
464
465 return g;
466}
467
469{
470 static thread_local EvtGammaMatrix g;
471 static thread_local int first = 1;
472
473 if ( first ) {
474 first = 0;
475 int i, j;
476
477 for ( i = 0; i < 4; i++ ) {
478 for ( j = 0; j < 4; j++ ) {
479 g.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
480 }
481 }
482
483 g.m_gamma[0][0] = EvtComplex( 1.0, 0.0 );
484 g.m_gamma[1][1] = EvtComplex( 1.0, 0.0 );
485 g.m_gamma[2][2] = EvtComplex( 1.0, 0.0 );
486 g.m_gamma[3][3] = EvtComplex( 1.0, 0.0 );
487 }
488
489 return g;
490}
491
493{
494 int i, j;
495
496 for ( i = 0; i < 4; i++ ) {
497 for ( j = 0; j < 4; j++ ) {
498 m_gamma[i][j] += g.m_gamma[i][j];
499 }
500 }
501 return *this;
502}
503
505{
506 int i, j;
507
508 for ( i = 0; i < 4; i++ ) {
509 for ( j = 0; j < 4; j++ ) {
510 m_gamma[i][j] -= g.m_gamma[i][j];
511 }
512 }
513 return *this;
514}
515
517{
518 int i, j, k;
519 EvtGammaMatrix temp;
520
521 for ( i = 0; i < 4; i++ ) {
522 for ( j = 0; j < 4; j++ ) {
523 temp.m_gamma[i][j] = EvtComplex( 0.0, 0.0 );
524 for ( k = 0; k < 4; k++ ) {
525 temp.m_gamma[i][j] += m_gamma[i][k] * g.m_gamma[k][j];
526 }
527 }
528 }
529
530 for ( i = 0; i < 4; i++ ) {
531 for ( j = 0; j < 4; j++ ) {
532 m_gamma[i][j] = temp.m_gamma[i][j];
533 }
534 }
535
536 return *this;
537}
538
540{
541 int i, j;
542 EvtDiracSpinor temp;
543
544 for ( i = 0; i < 4; i++ ) {
545 temp.set_spinor( i, EvtComplex( 0.0, 0.0 ) );
546 for ( j = 0; j < 4; j++ ) {
547 temp.set_spinor( i, temp.get_spinor( i ) +
548 g.m_gamma[i][j] * d.get_spinor( j ) );
549 }
550 }
551
552 return temp;
553}
554
555// upper index
557 unsigned int nu )
558{
559 static thread_local EvtGammaMatrix sigma[4][4];
560 static thread_local bool hasBeenCalled = false;
561 if ( !hasBeenCalled ) {
562 EvtComplex I( 0, 1 );
563 for ( int i = 0; i < 4; ++i )
564 sigma[i][i].init(); // set to 0
565
566 EvtGammaMatrix s01 = I / 2 * ( g0() * g1() - g1() * g0() );
567 EvtGammaMatrix s02 = I / 2 * ( g0() * g2() - g2() * g0() );
568 EvtGammaMatrix s03 = I / 2 * ( g0() * g3() - g3() * g0() );
569 EvtGammaMatrix s12 = I / 2 * ( g1() * g2() - g2() * g1() );
570 EvtGammaMatrix s13 = I / 2 * ( g1() * g3() - g3() * g1() );
571 EvtGammaMatrix s23 = I / 2 * ( g2() * g3() - g3() * g2() );
572 sigma[0][1] = s01;
573 sigma[1][0] = -1 * s01;
574 sigma[0][2] = s02;
575 sigma[2][0] = -1 * s02;
576 sigma[0][3] = s03;
577 sigma[3][0] = -1 * s03;
578 sigma[1][2] = s12;
579 sigma[2][1] = -1 * s12;
580 sigma[1][3] = s13;
581 sigma[3][1] = -1 * s13;
582 sigma[2][3] = s23;
583 sigma[3][2] = -1 * s23;
584 }
585 hasBeenCalled = true;
586
587 if ( mu > 3 || nu > 3 ) {
588 EvtGenReport( EVTGEN_ERROR, "EvtSigmaTensor" )
589 << "Expected index between 0 and 3, but found " << nu << "!" << endl;
590 assert( 0 );
591 }
592 return sigma[mu][nu];
593}
594
596 unsigned int nu )
597{
598 const EvtComplex I( 0, 1 );
599 EvtGammaMatrix a, b;
600 static thread_local EvtGammaMatrix sigma[4][4];
601 static thread_local bool hasBeenCalled = false;
602 static const EvtTensor4C eta = EvtTensor4C::g();
603
604 if ( !hasBeenCalled ) // has to be initialized only at the first call
605 {
606 // lower index
607 for ( int i = 0; i < 4; ++i ) {
608 a = eta.get( i, 0 ) * g0() + eta.get( i, 1 ) * g1() +
609 eta.get( i, 2 ) * g2() + eta.get( i, 3 ) * g3();
610 for ( int j = 0; j < 4; ++j ) {
611 b = eta.get( j, 0 ) * g0() + eta.get( j, 1 ) * g1() +
612 eta.get( j, 2 ) * g2() + eta.get( j, 3 ) * g3();
613 sigma[i][j] = I / 2 * ( a * b - b * a );
614 }
615 }
616 }
617 return sigma[mu][nu];
618}
619
621{
622 return EvtGammaMatrix::g0() * p.get( 0 ) + EvtGammaMatrix::g1() * p.get( 1 ) +
623 EvtGammaMatrix::g2() * p.get( 2 ) + EvtGammaMatrix::g3() * p.get( 3 );
624}
625
627{
628 return EvtGammaMatrix::g0() * p.get( 0 ) + EvtGammaMatrix::g1() * p.get( 1 ) +
629 EvtGammaMatrix::g2() * p.get( 2 ) + EvtGammaMatrix::g3() * p.get( 3 );
630}
const EvtComplex I
ostream & operator<<(ostream &s, const EvtGammaMatrix &g)
EvtGammaMatrix operator*(const EvtGammaMatrix &g, const EvtComplex &c)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition EvtReport.cpp:32
@ EVTGEN_ERROR
Definition EvtReport.hh:49
const EvtComplex & get_spinor(int i) const
void set_spinor(int i, const EvtComplex &sp)
EvtComplex m_gamma[4][4]
static const EvtGammaMatrix & sigmaLower(unsigned int mu, unsigned int nu)
static const EvtGammaMatrix & va1()
static const EvtGammaMatrix & v0()
static const EvtGammaMatrix & id()
static const EvtGammaMatrix & sigmaUpper(unsigned int mu, unsigned int nu)
static const EvtGammaMatrix & g0()
static const EvtGammaMatrix & g2()
EvtGammaMatrix & operator-=(const EvtGammaMatrix &g)
static const EvtGammaMatrix & g(int)
static const EvtGammaMatrix & g1()
static const EvtGammaMatrix & va3()
static const EvtGammaMatrix & g3()
static const EvtGammaMatrix & v2()
static const EvtGammaMatrix & va0()
static const EvtGammaMatrix & va2()
static const EvtGammaMatrix & g5()
static const EvtGammaMatrix & v1()
static const EvtGammaMatrix & v3()
EvtGammaMatrix & operator*=(const EvtGammaMatrix &g)
EvtGammaMatrix & operator=(const EvtGammaMatrix &gm)
EvtGammaMatrix & operator+=(const EvtGammaMatrix &g)
const EvtComplex & get(int i, int j) const
static const EvtTensor4C & g()
const EvtComplex & get(int) const
double get(int i) const
EvtGammaMatrix slash(const EvtVector4C &p)