evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtTensor4C.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 
23 #include "EvtGenBase/EvtComplex.hh"
24 #include "EvtGenBase/EvtPatches.hh"
26 
27 #include <assert.h>
28 #include <iostream>
29 #include <math.h>
30 using std::endl;
31 using std::ostream;
32 
34 {
35  int i, j;
36 
37  for ( i = 0; i < 4; i++ ) {
38  for ( j = 0; j < 4; j++ ) {
39  t[i][j] = t1.t[i][j];
40  }
41  }
42 }
43 
45 {
46  static EvtTensor4C g_metric( 1.0, -1.0, -1.0, -1.0 );
47 
48  return g_metric;
49 }
50 
52 {
53  int i, j;
54 
55  for ( i = 0; i < 4; i++ ) {
56  for ( j = 0; j < 4; j++ ) {
57  t[i][j] = t1.t[i][j];
58  }
59  }
60  return *this;
61 }
62 
64 {
65  EvtTensor4C temp;
66 
67  int i, j;
68 
69  for ( i = 0; i < 4; i++ ) {
70  for ( j = 0; j < 4; j++ ) {
71  temp.set( j, i, ::conj( t[i][j] ) );
72  }
73  }
74  return temp;
75 }
76 
77 EvtTensor4C rotateEuler( const EvtTensor4C& rs, double alpha, double beta,
78  double gamma )
79 {
80  EvtTensor4C tmp( rs );
81  tmp.applyRotateEuler( alpha, beta, gamma );
82  return tmp;
83 }
84 
86 {
87  EvtTensor4C tmp( rs );
88  tmp.applyBoostTo( p4 );
89  return tmp;
90 }
91 
92 EvtTensor4C boostTo( const EvtTensor4C& rs, const EvtVector3R boost )
93 {
94  EvtTensor4C tmp( rs );
95  tmp.applyBoostTo( boost );
96  return tmp;
97 }
98 
100 {
101  double e = p4.get( 0 );
102 
103  EvtVector3R boost( p4.get( 1 ) / e, p4.get( 2 ) / e, p4.get( 3 ) / e );
104 
105  applyBoostTo( boost );
106 
107  return;
108 }
109 
111 {
112  double bx, by, bz, gamma, b2;
113  double lambda[4][4];
114  EvtComplex tt[4][4];
115 
116  bx = boost.get( 0 );
117  by = boost.get( 1 );
118  bz = boost.get( 2 );
119 
120  double bxx = bx * bx;
121  double byy = by * by;
122  double bzz = bz * bz;
123 
124  b2 = bxx + byy + bzz;
125 
126  if ( b2 == 0.0 ) {
127  return;
128  }
129 
130  assert( b2 < 1.0 );
131 
132  gamma = 1.0 / sqrt( 1 - b2 );
133 
134  int i, j, k;
135 
136  if ( b2 == 0.0 ) {
137  return;
138  }
139 
140  lambda[0][0] = gamma;
141  lambda[0][1] = gamma * bx;
142  lambda[1][0] = gamma * bx;
143  lambda[0][2] = gamma * by;
144  lambda[2][0] = gamma * by;
145  lambda[0][3] = gamma * bz;
146  lambda[3][0] = gamma * bz;
147 
148  lambda[1][1] = 1.0 + ( gamma - 1.0 ) * bx * bx / b2;
149  lambda[2][2] = 1.0 + ( gamma - 1.0 ) * by * by / b2;
150  lambda[3][3] = 1.0 + ( gamma - 1.0 ) * bz * bz / b2;
151 
152  lambda[1][2] = ( gamma - 1.0 ) * bx * by / b2;
153  lambda[2][1] = ( gamma - 1.0 ) * bx * by / b2;
154 
155  lambda[1][3] = ( gamma - 1.0 ) * bx * bz / b2;
156  lambda[3][1] = ( gamma - 1.0 ) * bx * bz / b2;
157 
158  lambda[3][2] = ( gamma - 1.0 ) * bz * by / b2;
159  lambda[2][3] = ( gamma - 1.0 ) * bz * by / b2;
160 
161  for ( i = 0; i < 4; i++ ) {
162  for ( j = 0; j < 4; j++ ) {
163  tt[i][j] = EvtComplex( 0.0 );
164  for ( k = 0; k < 4; k++ ) {
165  tt[i][j] = tt[i][j] + lambda[j][k] * t[i][k];
166  }
167  }
168  }
169 
170  for ( i = 0; i < 4; i++ ) {
171  for ( j = 0; j < 4; j++ ) {
172  t[i][j] = EvtComplex( 0.0 );
173  for ( k = 0; k < 4; k++ ) {
174  t[i][j] = t[i][j] + lambda[i][k] * tt[k][j];
175  }
176  }
177  }
178 }
179 
181 {
182  int i, j;
183  for ( i = 0; i < 4; i++ ) {
184  for ( j = 0; j < 4; j++ ) {
185  t[i][j] = EvtComplex( 0.0, 0.0 );
186  }
187  }
188 }
189 
190 ostream& operator<<( ostream& s, const EvtTensor4C& t )
191 {
192  int i, j;
193  s << endl;
194  for ( i = 0; i < 4; i++ ) {
195  for ( j = 0; j < 4; j++ ) {
196  s << t.t[i][j];
197  }
198  s << endl;
199  }
200  return s;
201 }
202 
203 void EvtTensor4C::setdiag( double g00, double g11, double g22, double g33 )
204 {
205  t[0][0] = EvtComplex( g00 );
206  t[1][1] = EvtComplex( g11 );
207  t[2][2] = EvtComplex( g22 );
208  t[3][3] = EvtComplex( g33 );
209  t[0][1] = EvtComplex( 0.0 );
210  t[0][2] = EvtComplex( 0.0 );
211  t[0][3] = EvtComplex( 0.0 );
212  t[1][0] = EvtComplex( 0.0 );
213  t[1][2] = EvtComplex( 0.0 );
214  t[1][3] = EvtComplex( 0.0 );
215  t[2][0] = EvtComplex( 0.0 );
216  t[2][1] = EvtComplex( 0.0 );
217  t[2][3] = EvtComplex( 0.0 );
218  t[3][0] = EvtComplex( 0.0 );
219  t[3][1] = EvtComplex( 0.0 );
220  t[3][2] = EvtComplex( 0.0 );
221 }
222 
224 {
225  int i, j;
226 
227  for ( i = 0; i < 4; i++ ) {
228  for ( j = 0; j < 4; j++ ) {
229  t[i][j] += t2.get( i, j );
230  }
231  }
232  return *this;
233 }
234 
236 {
237  int i, j;
238 
239  for ( i = 0; i < 4; i++ ) {
240  for ( j = 0; j < 4; j++ ) {
241  t[i][j] -= t2.get( i, j );
242  }
243  }
244  return *this;
245 }
246 
248 {
249  int i, j;
250 
251  for ( i = 0; i < 4; i++ ) {
252  for ( j = 0; j < 4; j++ ) {
253  t[i][j] *= c;
254  }
255  }
256  return *this;
257 }
258 
260 {
261  return EvtTensor4C( t1 ) *= c;
262 }
263 
265 {
266  return EvtTensor4C( t1 ) *= c;
267 }
268 
270 {
271  int i, j;
272 
273  for ( i = 0; i < 4; i++ ) {
274  for ( j = 0; j < 4; j++ ) {
275  t[i][j] *= EvtComplex( d, 0.0 );
276  }
277  }
278  return *this;
279 }
280 
281 EvtTensor4C operator*( const EvtTensor4C& t1, double d )
282 {
283  return EvtTensor4C( t1 ) *= EvtComplex( d, 0.0 );
284 }
285 
286 EvtTensor4C operator*( double d, const EvtTensor4C& t1 )
287 {
288  return EvtTensor4C( t1 ) *= EvtComplex( d, 0.0 );
289 }
290 
291 EvtComplex cont( const EvtTensor4C& t1, const EvtTensor4C& t2 )
292 {
293  EvtComplex sum( 0.0, 0.0 );
294  int i, j;
295 
296  for ( i = 0; i < 4; i++ ) {
297  for ( j = 0; j < 4; j++ ) {
298  if ( ( i == 0 && j != 0 ) || ( j == 0 && i != 0 ) ) {
299  sum -= t1.t[i][j] * t2.t[i][j];
300  } else {
301  sum += t1.t[i][j] * t2.t[i][j];
302  }
303  }
304  }
305 
306  return sum;
307 }
308 
310  const EvtVector4C& c2 )
311 {
312  EvtTensor4C temp;
313  int i, j;
314 
315  for ( i = 0; i < 4; i++ ) {
316  for ( j = 0; j < 4; j++ ) {
317  temp.set( i, j, c1.get( i ) * c2.get( j ) );
318  }
319  }
320  return temp;
321 }
322 
324  const EvtVector4R& c2 )
325 {
326  EvtTensor4C temp;
327  int i, j;
328 
329  for ( i = 0; i < 4; i++ ) {
330  for ( j = 0; j < 4; j++ ) {
331  temp.set( i, j, c1.get( i ) * c2.get( j ) );
332  }
333  }
334  return temp;
335 }
336 
338  const EvtVector4R& c2 )
339 {
340  EvtTensor4C temp;
341  int i, j;
342 
343  for ( i = 0; i < 4; i++ ) {
344  for ( j = 0; j < 4; j++ ) {
345  temp.t[i][j] = EvtComplex( c1.get( i ) * c2.get( j ), 0.0 );
346  }
347  }
348  return temp;
349 }
350 
352  const EvtVector4R& p2 )
353 {
354  int i, j;
355 
356  for ( i = 0; i < 4; i++ ) {
357  for ( j = 0; j < 4; j++ ) {
358  t[i][j] += p1.get( i ) * p2.get( j );
359  }
360  }
361  return *this;
362 }
363 
365 {
366  EvtTensor4C temp;
367 
368  temp.set( 0, 0, EvtComplex( 0.0, 0.0 ) );
369  temp.set( 1, 1, EvtComplex( 0.0, 0.0 ) );
370  temp.set( 2, 2, EvtComplex( 0.0, 0.0 ) );
371  temp.set( 3, 3, EvtComplex( 0.0, 0.0 ) );
372 
373  temp.set( 0, 1, t2.get( 3, 2 ) - t2.get( 2, 3 ) );
374  temp.set( 0, 2, -t2.get( 3, 1 ) + t2.get( 1, 3 ) );
375  temp.set( 0, 3, t2.get( 2, 1 ) - t2.get( 1, 2 ) );
376 
377  temp.set( 1, 2, -t2.get( 3, 0 ) + t2.get( 0, 3 ) );
378  temp.set( 1, 3, t2.get( 2, 0 ) - t2.get( 0, 2 ) );
379 
380  temp.set( 2, 3, -t2.get( 1, 0 ) + t2.get( 0, 1 ) );
381 
382  temp.set( 1, 0, -temp.get( 0, 1 ) );
383  temp.set( 2, 0, -temp.get( 0, 2 ) );
384  temp.set( 3, 0, -temp.get( 0, 3 ) );
385 
386  temp.set( 2, 1, -temp.get( 1, 2 ) );
387  temp.set( 3, 1, -temp.get( 1, 3 ) );
388 
389  temp.set( 3, 2, -temp.get( 2, 3 ) );
390 
391  return temp;
392 }
393 
395 {
396  EvtTensor4C temp;
397 
398  int i, j;
399 
400  for ( i = 0; i < 4; i++ ) {
401  for ( j = 0; j < 4; j++ ) {
402  temp.set( i, j, ::conj( ( t2.get( i, j ) ) ) );
403  }
404  }
405 
406  return temp;
407 }
408 
409 EvtTensor4C cont22( const EvtTensor4C& t1, const EvtTensor4C& t2 )
410 {
411  EvtTensor4C temp;
412 
413  int i, j;
414  EvtComplex c;
415 
416  for ( i = 0; i < 4; i++ ) {
417  for ( j = 0; j < 4; j++ ) {
418  c = t1.get( i, 0 ) * t2.get( j, 0 ) -
419  t1.get( i, 1 ) * t2.get( j, 1 ) -
420  t1.get( i, 2 ) * t2.get( j, 2 ) - t1.get( i, 3 ) * t2.get( j, 3 );
421  temp.set( i, j, c );
422  }
423  }
424 
425  return temp;
426 }
427 
428 EvtTensor4C cont11( const EvtTensor4C& t1, const EvtTensor4C& t2 )
429 {
430  EvtTensor4C temp;
431 
432  int i, j;
433  EvtComplex c;
434 
435  for ( i = 0; i < 4; i++ ) {
436  for ( j = 0; j < 4; j++ ) {
437  c = t1.get( 0, i ) * t2.get( 0, j ) -
438  t1.get( 1, i ) * t2.get( 1, j ) -
439  t1.get( 2, i ) * t2.get( 2, j ) - t1.get( 3, i ) * t2.get( 3, j );
440  temp.set( i, j, c );
441  }
442  }
443 
444  return temp;
445 }
446 
448 {
449  EvtVector4C temp;
450 
451  int i;
452 
453  for ( i = 0; i < 4; i++ ) {
454  temp.set( i, t[0][i] * v4.get( 0 ) - t[1][i] * v4.get( 1 ) -
455  t[2][i] * v4.get( 2 ) - t[3][i] * v4.get( 3 ) );
456  }
457 
458  return temp;
459 }
460 
462 {
463  EvtVector4C temp;
464 
465  int i;
466 
467  for ( i = 0; i < 4; i++ ) {
468  temp.set( i, t[i][0] * v4.get( 0 ) - t[i][1] * v4.get( 1 ) -
469  t[i][2] * v4.get( 2 ) - t[i][3] * v4.get( 3 ) );
470  }
471 
472  return temp;
473 }
474 
476 {
477  EvtVector4C temp;
478 
479  int i;
480 
481  for ( i = 0; i < 4; i++ ) {
482  temp.set( i, t[0][i] * v4.get( 0 ) - t[1][i] * v4.get( 1 ) -
483  t[2][i] * v4.get( 2 ) - t[3][i] * v4.get( 3 ) );
484  }
485 
486  return temp;
487 }
488 
490 {
491  EvtVector4C temp;
492 
493  int i;
494 
495  for ( i = 0; i < 4; i++ ) {
496  temp.set( i, t[i][0] * v4.get( 0 ) - t[i][1] * v4.get( 1 ) -
497  t[i][2] * v4.get( 2 ) - t[i][3] * v4.get( 3 ) );
498  }
499 
500  return temp;
501 }
502 
503 void EvtTensor4C::applyRotateEuler( double phi, double theta, double ksi )
504 {
505  EvtComplex tt[4][4];
506  double sp, st, sk, cp, ct, ck;
507  double lambda[4][4];
508 
509  sp = sin( phi );
510  st = sin( theta );
511  sk = sin( ksi );
512  cp = cos( phi );
513  ct = cos( theta );
514  ck = cos( ksi );
515 
516  lambda[0][0] = 1.0;
517  lambda[0][1] = 0.0;
518  lambda[1][0] = 0.0;
519  lambda[0][2] = 0.0;
520  lambda[2][0] = 0.0;
521  lambda[0][3] = 0.0;
522  lambda[3][0] = 0.0;
523 
524  lambda[1][1] = ck * ct * cp - sk * sp;
525  lambda[1][2] = -sk * ct * cp - ck * sp;
526  lambda[1][3] = st * cp;
527 
528  lambda[2][1] = ck * ct * sp + sk * cp;
529  lambda[2][2] = -sk * ct * sp + ck * cp;
530  lambda[2][3] = st * sp;
531 
532  lambda[3][1] = -ck * st;
533  lambda[3][2] = sk * st;
534  lambda[3][3] = ct;
535 
536  int i, j, k;
537 
538  for ( i = 0; i < 4; i++ ) {
539  for ( j = 0; j < 4; j++ ) {
540  tt[i][j] = EvtComplex( 0.0 );
541  for ( k = 0; k < 4; k++ ) {
542  tt[i][j] += lambda[j][k] * t[i][k];
543  }
544  }
545  }
546 
547  for ( i = 0; i < 4; i++ ) {
548  for ( j = 0; j < 4; j++ ) {
549  t[i][j] = EvtComplex( 0.0 );
550  for ( k = 0; k < 4; k++ ) {
551  t[i][j] += lambda[i][k] * tt[k][j];
552  }
553  }
554  }
555 }
EvtTensor3C directProd(const EvtVector3C &c1, const EvtVector3C &c2)
EvtTensor4C conj() const
Definition: EvtTensor4C.cpp:63
EvtTensor4C cont11(const EvtTensor4C &t1, const EvtTensor4C &t2)
void set(int i, int j, const EvtComplex &c)
Definition: EvtTensor4C.hh:107
EvtTensor4C & operator *=(const EvtComplex &c)
double get(int i) const
Definition: EvtVector3R.hh:121
EvtTensor4C rotateEuler(const EvtTensor4C &rs, double alpha, double beta, double gamma)
Definition: EvtTensor4C.cpp:77
void setdiag(double t00, double t11, double t22, double t33)
static const EvtTensor4C & g()
Definition: EvtTensor4C.cpp:44
void set(int, const EvtComplex &)
Definition: EvtVector4C.hh:98
EvtTensor4C dual(const EvtTensor4C &t2)
void applyBoostTo(const EvtVector4R &p4)
Definition: EvtTensor4C.cpp:99
EvtComplex cont(const EvtTensor4C &t1, const EvtTensor4C &t2)
EvtVector4C cont2(const EvtVector4C &v4) const
EvtVector4C cont1(const EvtVector4C &v4) const
void applyRotateEuler(double alpha, double beta, double gamma)
EvtTensor4C & operator-=(const EvtTensor4C &t2)
double get(int i) const
Definition: EvtVector4R.hh:162
ostream & operator<<(ostream &s, const EvtTensor4C &t)
EvtComplex t[4][4]
Definition: EvtTensor4C.hh:94
EvtTensor4C boostTo(const EvtTensor4C &rs, const EvtVector4R p4)
Definition: EvtTensor4C.cpp:85
double lambda(double q, double m1, double m2)
Definition: EvtFlatQ2.cpp:31
EvtTensor4C & operator=(const EvtTensor4C &t1)
Definition: EvtTensor4C.cpp:51
const EvtComplex & get(int) const
Definition: EvtVector4C.hh:125
EvtTensor4C operator *(const EvtTensor4C &t1, const EvtComplex &c)
EvtTensor4C cont22(const EvtTensor4C &t1, const EvtTensor4C &t2)
EvtTensor4C & operator+=(const EvtTensor4C &t2)
EvtTensor4C conj(const EvtTensor4C &t2)
const EvtComplex & get(int i, int j) const
Definition: EvtTensor4C.hh:112
EvtTensor4C & addDirProd(const EvtVector4R &p1, const EvtVector4R &p2)