BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EventDisplay/BesVisLib/include/BesVisLib/vector3.h
Go to the documentation of this file.
1typedef struct {
2 float x;
3 float y;
4 float z;
5} vector3;
6
7// initialize the vector to (x,y,z)
8vector3 InitV( float x, float y, float z ) {
10 v.x = x;
11 v.y = y;
12 v.z = z;
13 return v;
14}
15
16// initialize the vector to (x,y,z)
17vector3 InitV1( float phi, float cosTheta, float magnitude ) {
18 vector3 v;
19 float sinTheta = sqrt( 1.0 - cosTheta * cosTheta );
20 v.z = magnitude * cosTheta;
21 v.y = magnitude * sinTheta * sin( phi );
22 v.x = magnitude * sinTheta * cos( phi );
23 return v;
24}
25
26// the magnitude of vector v
27float Mag( vector3 v ) { return sqrt( v.x * v.x + v.y * v.y + v.z * v.z ); }
28
29// the squared magnitude of vector v
30float Mag2( vector3 v ) { return v.x * v.x + v.y * v.y + v.z * v.z; }
31
32// Scalar product of vector v1 and v2
33float Dot( vector3 v1, vector3 v2 ) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; }
34
35// Cross product of vector v1 and v2
37 vector3 v;
38 v.x = v1.y * v2.z - v1.z * v2.y;
39 v.y = v1.z * v2.x - v1.x * v2.z;
40 v.z = v1.x * v2.y - v1.y * v2.x;
41 return v;
42}
43
44// Unit vector parallel to vector v
46 vector3 vv;
47 float p = Mag( v );
48 vv.x = v.x / p;
49 vv.y = v.y / p;
50 vv.z = v.z / p;
51 return vv;
52}
53
54// Calculate the intersection piont with z0 = c plane
55// for vector vec which pass point pos
57 vector3 vz0;
58 vz0.z = z0;
59 vz0.x = ( vz0.z - pos.z ) * vec.x / vec.z + pos.x;
60 vz0.y = ( vz0.z - pos.z ) * vec.y / vec.z + pos.y;
61 return vz0;
62}
63
64// vector v times with a constant a
65vector3 TimesA( float a, vector3 v ) {
66 vector3 vv;
67 vv.x = a * v.x;
68 vv.y = a * v.y;
69 vv.z = a * v.z;
70 return vv;
71}
72
73// vector v1 + vector v2
75 vector3 v;
76 v.x = v1.x + v2.x;
77 v.y = v1.y + v2.y;
78 v.z = v1.z + v2.z;
79 return v;
80}
81
82// vector v1 - vector v2
84 vector3 v;
85 v.x = v1.x - v2.x;
86 v.y = v1.y - v2.y;
87 v.z = v1.z - v2.z;
88 return v;
89}
90
91// Transform v from ux, uy, uz frame to (1,0,0),(0,1,0),(0,0,1) frame
93 ux = TimesA( v.x, ux );
94 uy = TimesA( v.y, uy );
95 uz = TimesA( v.z, uz );
96 v = AddV( AddV( ux, uy ), uz );
97 return v;
98}
99
100// Transform v to ux, uy, uz frame from (1,0,0),(0,1,0),(0,0,1) frame
102 vector3 vv;
103 vv.x = Dot( v, ux );
104 vv.y = Dot( v, uy );
105 vv.z = Dot( v, uz );
106 return vv;
107}
108
109const float pi = 3.1415926536;
110const float rad = 57.29578;
111
112/*typedef struct{
113 float r;
114 float theta;
115 float phi;
116} polar;
117
118polar XYZ2Polar(vector3 v)
119{
120 polar s;
121 float rxy;
122
123 s.r = sqrt(v.x*v.x+v.y*v.y+v.z*v.z);
124 if(s.r==0.0){
125 s.theta = 0.0;
126 }
127 else{
128 s.theta = acos(v.z/s.r);
129 }
130
131 rxy = sqrt(v.x*v.x+v.y*v.y);
132 if(rxy==0.0){
133 s.phi = 0.0;
134 }
135 else{
136 if(v.y>=0.0) s.phi = acos(v.x/rxy);
137 else{
138 s.phi = 2.0*pi-acos(v.x/rxy);
139 }
140 }
141
142 return s;
143}*/
dble_vec_t vec[12]
float Dot(vector3 v1, vector3 v2)
vector3 TransformTo(vector3 v, vector3 ux, vector3 uy, vector3 uz)
vector3 TransformFrom(vector3 v, vector3 ux, vector3 uy, vector3 uz)
vector3 InitV1(float phi, float cosTheta, float magnitude)
vector3 AddV(vector3 v1, vector3 v2)
vector3 Intersection(float z0, vector3 vec, vector3 pos)
vector3 TimesA(float a, vector3 v)
vector3 SubV(vector3 v1, vector3 v2)
vector3 Cross(vector3 v1, vector3 v2)
vector3 InitV(float x, float y, float z)
double pi
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35