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.
EvtTensor3C.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"
25 #include "EvtGenBase/EvtReport.hh"
27 
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 < 3; i++ ) {
38  for ( j = 0; j < 3; j++ ) {
39  t[i][j] = t1.t[i][j];
40  }
41  }
42 }
43 
44 EvtTensor3C::EvtTensor3C( double d11, double d22, double d33 )
45 {
46  int i, j;
47 
48  for ( i = 0; i < 3; i++ ) {
49  for ( j = 0; j < 3; j++ ) {
50  t[i][j] = 0.0;
51  }
52  }
53 
54  t[0][0] = d11;
55  t[1][1] = d22;
56  t[2][2] = d33;
57 }
58 
60 {
61  int i, j;
62 
63  for ( i = 0; i < 3; i++ ) {
64  for ( j = 0; j < 3; j++ ) {
65  t[i][j] = t1.t[i][j];
66  }
67  }
68  return *this;
69 }
70 
72 {
73  EvtTensor3C temp;
74 
75  int i, j;
76 
77  for ( i = 0; i < 3; i++ ) {
78  for ( j = 0; j < 3; j++ ) {
79  temp.set( j, i, ::conj( t[i][j] ) );
80  }
81  }
82  return temp;
83 }
84 
86 {
87  int i, j;
88  for ( i = 0; i < 3; i++ ) {
89  for ( j = 0; j < 3; j++ ) {
90  t[i][j] = EvtComplex( 0.0, 0.0 );
91  }
92  }
93 }
94 
96 {
97  int i, j;
98 
99  for ( i = 0; i < 3; i++ ) {
100  for ( j = 0; j < 3; j++ ) {
101  t[i][j] = EvtComplex( 0.0, 0.0 );
102  }
103  }
104 }
105 
107 {
108  int i, j;
109 
110  for ( i = 0; i < 3; i++ ) {
111  for ( j = 0; j < 3; j++ ) {
112  t[i][j] += t2.t[i][j];
113  }
114  }
115  return *this;
116 }
117 
119 {
120  int i, j;
121 
122  for ( i = 0; i < 3; i++ ) {
123  for ( j = 0; j < 3; j++ ) {
124  t[i][j] -= t2.t[i][j];
125  }
126  }
127  return *this;
128 }
129 
131 {
132  int i, j;
133 
134  for ( i = 0; i < 3; i++ ) {
135  for ( j = 0; j < 3; j++ ) {
136  t[i][j] *= c;
137  }
138  }
139  return *this;
140 }
141 
143 {
144  int i, j;
145 
146  for ( i = 0; i < 3; i++ ) {
147  for ( j = 0; j < 3; j++ ) {
148  t[i][j] *= EvtComplex( c );
149  }
150  }
151  return *this;
152 }
153 
155  const EvtVector3C& c2 )
156 {
157  EvtTensor3C temp;
158  int i, j;
159 
160  for ( i = 0; i < 3; i++ ) {
161  for ( j = 0; j < 3; j++ ) {
162  temp.set( i, j, c1.get( i ) * c2.get( j ) );
163  }
164  }
165  return temp;
166 }
167 
169  const EvtVector3R& c2 )
170 {
171  EvtTensor3C temp;
172  int i, j;
173 
174  for ( i = 0; i < 3; i++ ) {
175  for ( j = 0; j < 3; j++ ) {
176  temp.set( i, j, c1.get( i ) * c2.get( j ) );
177  }
178  }
179  return temp;
180 }
181 
183  const EvtVector3R& c2 )
184 {
185  EvtTensor3C temp;
186  int i, j;
187 
188  for ( i = 0; i < 3; i++ ) {
189  for ( j = 0; j < 3; j++ ) {
190  temp.t[i][j] = EvtComplex( c1.get( i ) * c2.get( j ), 0.0 );
191  }
192  }
193  return temp;
194 }
195 
197 {
198  EvtTensor3C temp;
199 
200  int i, j;
201 
202  for ( i = 0; i < 3; i++ ) {
203  for ( j = 0; j < 3; j++ ) {
204  temp.set( i, j, ::conj( ( t2.get( i, j ) ) ) );
205  }
206  }
207 
208  return temp;
209 }
210 
211 EvtTensor3C cont22( const EvtTensor3C& t1, const EvtTensor3C& t2 )
212 {
213  EvtTensor3C temp;
214 
215  int i, j;
216  EvtComplex c;
217 
218  for ( i = 0; i < 3; i++ ) {
219  for ( j = 0; j < 3; j++ ) {
220  c = t1.get( i, 0 ) * t2.get( j, 0 ) +
221  t1.get( i, 1 ) * t2.get( j, 1 ) + t1.get( i, 2 ) * t2.get( j, 2 );
222  temp.set( i, j, c );
223  }
224  }
225 
226  return temp;
227 }
228 
229 EvtTensor3C cont11( const EvtTensor3C& t1, const EvtTensor3C& t2 )
230 {
231  EvtTensor3C temp;
232 
233  int i, j;
234  EvtComplex c;
235 
236  for ( i = 0; i < 3; i++ ) {
237  for ( j = 0; j < 3; j++ ) {
238  c = t1.get( 0, i ) * t2.get( 0, j ) +
239  t1.get( 1, i ) * t2.get( 1, j ) + t1.get( 2, i ) * t2.get( 2, j );
240  temp.set( i, j, c );
241  }
242  }
243 
244  return temp;
245 }
246 
248 {
249  EvtVector3C temp;
250 
251  int i;
252 
253  for ( i = 0; i < 3; i++ ) {
254  temp.set( i, t[0][i] * v.get( 0 ) + t[1][i] * v.get( 1 ) +
255  t[2][i] * v.get( 2 ) );
256  }
257 
258  return temp;
259 }
260 
262 {
263  EvtVector3C temp;
264 
265  int i;
266 
267  for ( i = 0; i < 3; i++ ) {
268  temp.set( i, t[i][0] * v.get( 0 ) + t[i][1] * v.get( 1 ) +
269  t[i][2] * v.get( 2 ) );
270  }
271 
272  return temp;
273 }
274 
276 {
277  EvtVector3C temp;
278 
279  int i;
280 
281  for ( i = 0; i < 3; i++ ) {
282  temp.set( i, t[0][i] * v.get( 0 ) + t[1][i] * v.get( 1 ) +
283  t[2][i] * v.get( 2 ) );
284  }
285 
286  return temp;
287 }
288 
290 {
291  EvtVector3C temp;
292 
293  int i;
294 
295  for ( i = 0; i < 3; i++ ) {
296  temp.set( i, t[i][0] * v.get( 0 ) + t[i][1] * v.get( 1 ) +
297  t[i][2] * v.get( 2 ) );
298  }
299 
300  return temp;
301 }
302 
304 {
305  EvtTensor3C temp;
306 
307  temp.t[0][0] = 0.0;
308  temp.t[1][1] = 0.0;
309  temp.t[2][2] = 0.0;
310 
311  temp.t[0][1] = v.get( 2 );
312  temp.t[0][2] = -v.get( 1 );
313 
314  temp.t[1][0] = -v.get( 2 );
315  temp.t[1][2] = v.get( 0 );
316 
317  temp.t[2][0] = v.get( 1 );
318  temp.t[2][1] = -v.get( 0 );
319 
320  return temp;
321 }
322 
324 {
325  static EvtTensor3C identity( 1.0, 1.0, 1.0 );
326 
327  return identity;
328 }
329 
330 ostream& operator<<( ostream& s, const EvtTensor3C& v )
331 {
332  s << endl
333  << "(" << v.t[0][0] << "," << v.t[0][1] << "," << v.t[0][2] << ")";
334  s << endl
335  << "(" << v.t[1][0] << "," << v.t[1][1] << "," << v.t[1][2] << ")";
336  s << endl
337  << "(" << v.t[2][0] << "," << v.t[2][1] << "," << v.t[2][2] << ")" << endl;
338 
339  return s;
340 }
341 
343  double beta, double gamma )
344 {
345  EvtTensor3C tmp( v );
346  tmp.applyRotateEuler( alpha, beta, gamma );
347  return tmp;
348 }
349 
350 void EvtTensor3C::applyRotateEuler( double phi, double theta, double ksi )
351 {
352  EvtComplex temp[3][3];
353  double sp, st, sk, cp, ct, ck;
354  double r[3][3];
355  int i, j, k;
356 
357  sp = sin( phi );
358  st = sin( theta );
359  sk = sin( ksi );
360  cp = cos( phi );
361  ct = cos( theta );
362  ck = cos( ksi );
363 
364  r[0][0] = ck * ct * cp - sk * sp;
365  r[0][1] = ck * ct * sp + sk * cp;
366  r[0][2] = -ck * st;
367 
368  r[1][0] = -sk * ct * cp - ck * sp;
369  r[1][1] = -sk * ct * sp + ck * cp;
370  r[1][2] = sk * st;
371 
372  r[2][0] = st * cp;
373  r[2][1] = st * sp;
374  r[2][2] = ct;
375 
376  for ( i = 0; i < 3; i++ ) {
377  for ( j = 0; j < 3; j++ ) {
378  temp[i][j] = 0.0;
379  for ( k = 0; k < 3; k++ ) {
380  temp[i][j] += r[i][k] * t[k][j];
381  }
382  }
383  }
384 
385  for ( i = 0; i < 3; i++ ) {
386  for ( j = 0; j < 3; j++ ) {
387  t[i][j] = 0.0;
388  for ( k = 0; k < 3; k++ ) {
389  t[i][j] += r[i][k] * temp[j][k];
390  }
391  }
392  }
393 }
EvtTensor3C directProd(const EvtVector3C &c1, const EvtVector3C &c2)
double get(int i) const
Definition: EvtVector3R.hh:121
EvtTensor3C cont22(const EvtTensor3C &t1, const EvtTensor3C &t2)
void set(const int, const EvtComplex &)
Definition: EvtVector3C.hh:79
ostream & operator<<(ostream &s, const EvtTensor3C &v)
const EvtComplex & get(int) const
Definition: EvtVector3C.hh:99
EvtTensor3C cont11(const EvtTensor3C &t1, const EvtTensor3C &t2)
static const EvtTensor3C & id()
EvtTensor3C & operator=(const EvtTensor3C &t1)
Definition: EvtTensor3C.cpp:59
EvtTensor3C rotateEuler(const EvtTensor3C &v, double phi, double theta, double ksi)
EvtVector3C cont1(const EvtVector3C &v) const
EvtTensor3C conj(const EvtTensor3C &t2)
EvtTensor3C operator+=(const EvtTensor3C &t2)
EvtTensor3C operator-=(const EvtTensor3C &t2)
EvtVector3C cont2(const EvtVector3C &v) const
EvtTensor3C operator *=(const double d)
const EvtComplex & get(int i, int j) const
Definition: EvtTensor3C.hh:125
void applyRotateEuler(double phi, double theta, double ksi)
void set(int i, int j, const EvtComplex &c)
Definition: EvtTensor3C.hh:120
EvtTensor3C eps(const EvtVector3R &v)
EvtComplex t[3][3]
Definition: EvtTensor3C.hh:87
EvtTensor3C conj() const
Definition: EvtTensor3C.cpp:71