]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenBase/EvtVector3R.cxx
New plots for trending injector efficiencies (Melinda)
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtVector3R.cxx
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: EvtVector3R.cc
12 //
13 // Description: Real implementation of 3-vectors
14 //
15 // Modification history:
16 //
17 //    RYD       September 5, 1997       Module created
18 //
19 //------------------------------------------------------------------------
20 // 
21 #include "EvtGenBase/EvtPatches.hh"
22 #include <iostream>
23 #include <math.h>
24 #include "EvtGenBase/EvtVector3R.hh"
25 using std::ostream;
26
27
28
29 EvtVector3R::~EvtVector3R(){}
30
31 EvtVector3R::EvtVector3R(){
32   
33   v[0]=v[1]=v[2]=0.0;
34 }
35
36
37 EvtVector3R::EvtVector3R(double x,double y, double z){
38   
39   v[0]=x; v[1]=y; v[2]=z;
40 }
41
42 EvtVector3R rotateEuler(const EvtVector3R& v,
43                         double alpha,double beta,double gamma){
44
45   EvtVector3R tmp(v);
46   tmp.applyRotateEuler(alpha,beta,gamma);
47   return tmp;
48
49 }
50
51
52 void EvtVector3R::applyRotateEuler(double phi,double theta,double ksi){
53
54   double temp[3];
55   double sp,st,sk,cp,ct,ck;
56
57   sp=sin(phi);
58   st=sin(theta);
59   sk=sin(ksi);
60   cp=cos(phi);
61   ct=cos(theta);
62   ck=cos(ksi);
63
64   temp[0]=( ck*ct*cp-sk*sp)*v[0]+( -sk*ct*cp-ck*sp)*v[1]+st*cp*v[2];
65   temp[1]=( ck*ct*sp+sk*cp)*v[0]+(-sk*ct*sp+ck*cp)*v[1]+st*sp*v[2];
66   temp[2]=-ck*st*v[0]+sk*st*v[1]+ct*v[2];
67
68
69   v[0]=temp[0];
70   v[1]=temp[1];
71   v[2]=temp[2];
72 }
73
74 ostream& operator<<(ostream& s,const EvtVector3R& v){
75  
76   s<<"("<<v.v[0]<<","<<v.v[1]<<","<<v.v[2]<<")";
77
78   return s;
79
80 }
81
82
83 EvtVector3R cross( const EvtVector3R& p1,const EvtVector3R& p2 ){
84
85   //Calcs the cross product.  Added by djl on July 27, 1995.
86   //Modified for real vectros by ryd Aug 28-96
87
88   return EvtVector3R(p1.v[1]*p2.v[2] - p1.v[2]*p2.v[1],
89                      p1.v[2]*p2.v[0] - p1.v[0]*p2.v[2],
90                      p1.v[0]*p2.v[1] - p1.v[1]*p2.v[0]);
91
92 }
93
94 double EvtVector3R::d3mag() const
95
96 // returns the 3 momentum mag.
97 {
98   double temp;
99
100   temp = v[0]*v[0]+v[1]*v[1]+v[2]*v[2];
101   temp = sqrt( temp );
102
103   return temp;
104 } // r3mag
105
106 double EvtVector3R::dot ( const EvtVector3R& p2 ){
107
108   double temp;
109
110   temp = v[0]*p2.v[0];
111   temp += v[0]*p2.v[0];
112   temp += v[0]*p2.v[0];
113  
114   return temp;
115 } //dot
116
117
118
119
120