]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TEvtGen/EvtGenBase/EvtTensor3C.cpp
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtTensor3C.cpp
CommitLineData
da0e9ce3 1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtTensor3C.cc
12//
13// Description: Implementation of 3 tensors.
14//
15// Modification history:
16//
17// RYD September 14, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtGenBase/EvtPatches.hh"
22#include <iostream>
23#include <math.h>
24#include "EvtGenBase/EvtComplex.hh"
25#include "EvtGenBase/EvtVector3C.hh"
26#include "EvtGenBase/EvtTensor3C.hh"
27#include "EvtGenBase/EvtReport.hh"
28using std::endl;
29using std::ostream;
30
31
32EvtTensor3C::~EvtTensor3C(){}
33
34
35EvtTensor3C::EvtTensor3C( const EvtTensor3C& t1 ) {
36
37 int i,j;
38
39 for(i=0;i<3;i++) {
40 for(j=0;j<3;j++) {
41 t[i][j] = t1.t[i][j];
42 }
43 }
44}
45
46EvtTensor3C::EvtTensor3C(double d11, double d22, double d33) {
47
48 int i,j;
49
50 for(i=0;i<3;i++) {
51 for(j=0;j<3;j++) {
52 t[i][j] = 0.0;
53 }
54 }
55
56 t[0][0]=d11;
57 t[1][1]=d22;
58 t[2][2]=d33;
59
60}
61
62
63
64EvtTensor3C& EvtTensor3C::operator=(const EvtTensor3C& t1) {
65 int i,j;
66
67 for(i=0;i<3;i++) {
68 for(j=0;j<3;j++) {
69 t[i][j] = t1.t[i][j];
70 }
71 }
72 return *this;
73}
74
75EvtTensor3C EvtTensor3C::conj() const {
76 EvtTensor3C temp;
77
78 int i,j;
79
80 for(i=0;i<3;i++) {
81 for(j=0;j<3;j++) {
82 temp.set(j,i,::conj(t[i][j]));
83 }
84 }
85 return temp;
86}
87
88void EvtTensor3C::zero(){
89 int i,j;
90 for(i=0;i<3;i++){
91 for(j=0;j<3;j++){
92 t[i][j]=EvtComplex(0.0,0.0);
93 }
94 }
95}
96
97
98EvtTensor3C::EvtTensor3C(){
99
100 int i,j;
101
102 for(i=0;i<3;i++){
103 for(j=0;j<3;j++){
104 t[i][j]=EvtComplex(0.0,0.0);
105 }
106 }
107
108}
109
110EvtTensor3C EvtTensor3C::operator+=(const EvtTensor3C& t2) {
111
112 int i,j;
113
114 for (i=0;i<3;i++) {
115 for (j=0;j<3;j++) {
116 t[i][j]+=t2.t[i][j];
117 }
118 }
119 return *this;
120}
121
122
123EvtTensor3C EvtTensor3C::operator-=(const EvtTensor3C& t2) {
124
125 int i,j;
126
127 for (i=0;i<3;i++) {
128 for (j=0;j<3;j++) {
129 t[i][j]-=t2.t[i][j];
130 }
131 }
132 return *this;
133}
134
135
136
137EvtTensor3C EvtTensor3C::operator*=(const EvtComplex& c) {
138
139 int i,j;
140
141 for (i=0;i<3;i++) {
142 for (j=0;j<3;j++) {
143 t[i][j]*=c;
144 }
145 }
146 return *this;
147}
148
149
0ca57c2f 150EvtTensor3C EvtTensor3C::operator*=(const double c){
da0e9ce3 151
152 int i,j;
153
154 for (i=0;i<3;i++) {
155 for (j=0;j<3;j++) {
156 t[i][j]*=EvtComplex(c);
157 }
158 }
159 return *this;
160}
161
162
163
164
0ca57c2f 165EvtTensor3C EvtGenFunctions::directProd(const EvtVector3C& c1,const EvtVector3C& c2){
da0e9ce3 166 EvtTensor3C temp;
167 int i,j;
168
169 for (i=0;i<3;i++) {
170 for (j=0;j<3;j++) {
171 temp.set(i,j,c1.get(i)*c2.get(j));
172 }
173 }
174 return temp;
175}
176
177
0ca57c2f 178EvtTensor3C EvtGenFunctions::directProd(const EvtVector3C& c1,const EvtVector3R& c2){
da0e9ce3 179 EvtTensor3C temp;
180 int i,j;
181
182 for (i=0;i<3;i++) {
183 for (j=0;j<3;j++) {
184 temp.set(i,j,c1.get(i)*c2.get(j));
185 }
186 }
187 return temp;
188}
189
190
0ca57c2f 191EvtTensor3C EvtGenFunctions::directProd(const EvtVector3R& c1,const EvtVector3R& c2){
da0e9ce3 192 EvtTensor3C temp;
193 int i,j;
194
195 for (i=0;i<3;i++) {
196 for (j=0;j<3;j++) {
197 temp.t[i][j]=EvtComplex(c1.get(i)*c2.get(j),0.0);
198 }
199 }
200 return temp;
201}
202
203
204EvtTensor3C conj(const EvtTensor3C& t2) {
205 EvtTensor3C temp;
206
207 int i,j;
208
209 for(i=0;i<3;i++){
210 for(j=0;j<3;j++){
211 temp.set(i,j,::conj((t2.get(i,j))));
212 }
213 }
214
215 return temp;
216}
217
218
219EvtTensor3C cont22(const EvtTensor3C& t1,const EvtTensor3C& t2){
220 EvtTensor3C temp;
221
222 int i,j;
223 EvtComplex c;
224
225 for(i=0;i<3;i++){
226 for(j=0;j<3;j++){
227 c=t1.get(i,0)*t2.get(j,0)+t1.get(i,1)*t2.get(j,1)
228 +t1.get(i,2)*t2.get(j,2);
229 temp.set(i,j,c);
230 }
231 }
232
233 return temp;
234}
235
236EvtTensor3C cont11(const EvtTensor3C& t1,const EvtTensor3C& t2){
237 EvtTensor3C temp;
238
239 int i,j;
240 EvtComplex c;
241
242 for(i=0;i<3;i++){
243 for(j=0;j<3;j++){
244 c=t1.get(0,i)*t2.get(0,j)+t1.get(1,i)*t2.get(1,j)
245 +t1.get(2,i)*t2.get(2,j);
246 temp.set(i,j,c);
247 }
248 }
249
250 return temp;
251}
252
253
254EvtVector3C EvtTensor3C::cont1(const EvtVector3C& v) const {
255 EvtVector3C temp;
256
257 int i;
258
259 for(i=0;i<3;i++){
260 temp.set(i,t[0][i]*v.get(0)+t[1][i]*v.get(1)
261 +t[2][i]*v.get(2));
262 }
263
264 return temp;
265}
266
267EvtVector3C EvtTensor3C::cont2(const EvtVector3C& v) const {
268 EvtVector3C temp;
269
270 int i;
271
272 for(i=0;i<3;i++){
273 temp.set(i,t[i][0]*v.get(0)+t[i][1]*v.get(1)
274 +t[i][2]*v.get(2));
275 }
276
277 return temp;
278}
279
280EvtVector3C EvtTensor3C::cont1(const EvtVector3R& v) const {
281 EvtVector3C temp;
282
283 int i;
284
285 for(i=0;i<3;i++){
286 temp.set(i,t[0][i]*v.get(0)+t[1][i]*v.get(1)
287 +t[2][i]*v.get(2));
288 }
289
290 return temp;
291}
292
293EvtVector3C EvtTensor3C::cont2(const EvtVector3R& v) const {
294 EvtVector3C temp;
295
296 int i;
297
298 for(i=0;i<3;i++){
299 temp.set(i,t[i][0]*v.get(0)+t[i][1]*v.get(1)
300 +t[i][2]*v.get(2));
301 }
302
303 return temp;
304}
305
306
0ca57c2f 307EvtTensor3C EvtGenFunctions::eps(const EvtVector3R& v){
da0e9ce3 308
309 EvtTensor3C temp;
310
311 temp.t[0][0]=0.0;
312 temp.t[1][1]=0.0;
313 temp.t[2][2]=0.0;
314
315 temp.t[0][1]=v.get(2);
316 temp.t[0][2]=-v.get(1);
317
318 temp.t[1][0]=-v.get(2);
319 temp.t[1][2]=v.get(0);
320
321 temp.t[2][0]=v.get(1);
322 temp.t[2][1]=-v.get(0);
323
324 return temp;
325
326}
327
328
329
330const EvtTensor3C& EvtTensor3C::id(){
331
332 static EvtTensor3C identity(1.0,1.0,1.0);
333
334 return identity;
335
336}
337
338ostream& operator<<(ostream& s,const EvtTensor3C& v){
339
340 s<<endl<<"("<<v.t[0][0]<<","<<v.t[0][1]<<","<<v.t[0][2]<<")";
341 s<<endl<<"("<<v.t[1][0]<<","<<v.t[1][1]<<","<<v.t[1][2]<<")";
342 s<<endl<<"("<<v.t[2][0]<<","<<v.t[2][1]<<","<<v.t[2][2]<<")"<<endl;
343
344 return s;
345}
346
347
0ca57c2f 348EvtTensor3C EvtGenFunctions::rotateEuler(const EvtTensor3C& v,
da0e9ce3 349 double alpha,double beta,double gamma){
350
351 EvtTensor3C tmp(v);
352 tmp.applyRotateEuler(alpha,beta,gamma);
353 return tmp;
354
355}
356
357
358void EvtTensor3C::applyRotateEuler(double phi,double theta,double ksi){
359
360 EvtComplex temp[3][3];
361 double sp,st,sk,cp,ct,ck;
362 double r[3][3];
363 int i,j,k;
364
365 sp=sin(phi);
366 st=sin(theta);
367 sk=sin(ksi);
368 cp=cos(phi);
369 ct=cos(theta);
370 ck=cos(ksi);
371
372 r[0][0]=ck*ct*cp-sk*sp;
373 r[0][1]=ck*ct*sp+sk*cp;
374 r[0][2]=-ck*st;
375
376 r[1][0]=-sk*ct*cp-ck*sp;
377 r[1][1]=-sk*ct*sp+ck*cp;
378 r[1][2]=sk*st;
379
380 r[2][0]=st*cp;
381 r[2][1]=st*sp;
382 r[2][2]=ct;
383
384 for(i=0;i<3;i++){
385 for(j=0;j<3;j++){
386 temp[i][j]=0.0;
387 for(k=0;k<3;k++){
388 temp[i][j]+=r[i][k]*t[k][j];
389 }
390 }
391 }
392
393 for(i=0;i<3;i++){
394 for(j=0;j<3;j++){
395 t[i][j]=0.0;
396 for(k=0;k<3;k++){
397 t[i][j]+=r[i][k]*temp[j][k];
398 }
399 }
400 }
401
402
403}
404
405