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.
EvtVector3R.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/EvtPatches.hh"
24 
25 #include <iostream>
26 #include <math.h>
27 using std::ostream;
28 
30 {
31  v[0] = v[1] = v[2] = 0.0;
32 }
33 
34 EvtVector3R::EvtVector3R( double x, double y, double z )
35 {
36  v[0] = x;
37  v[1] = y;
38  v[2] = z;
39 }
40 
41 EvtVector3R rotateEuler( const EvtVector3R& v, double alpha, double beta,
42  double gamma )
43 {
44  EvtVector3R tmp( v );
45  tmp.applyRotateEuler( alpha, beta, gamma );
46  return tmp;
47 }
48 
49 void EvtVector3R::applyRotateEuler( double phi, double theta, double ksi )
50 {
51  double temp[3];
52  double sp, st, sk, cp, ct, ck;
53 
54  sp = sin( phi );
55  st = sin( theta );
56  sk = sin( ksi );
57  cp = cos( phi );
58  ct = cos( theta );
59  ck = cos( ksi );
60 
61  temp[0] = ( ck * ct * cp - sk * sp ) * v[0] +
62  ( -sk * ct * cp - ck * sp ) * v[1] + st * cp * v[2];
63  temp[1] = ( ck * ct * sp + sk * cp ) * v[0] +
64  ( -sk * ct * sp + ck * cp ) * v[1] + st * sp * v[2];
65  temp[2] = -ck * st * v[0] + sk * st * v[1] + ct * v[2];
66 
67  v[0] = temp[0];
68  v[1] = temp[1];
69  v[2] = temp[2];
70 }
71 
72 ostream& operator<<( ostream& s, const EvtVector3R& v )
73 {
74  s << "(" << v.v[0] << "," << v.v[1] << "," << v.v[2] << ")";
75 
76  return s;
77 }
78 
79 EvtVector3R cross( const EvtVector3R& p1, const EvtVector3R& p2 )
80 {
81  //Calcs the cross product. Added by djl on July 27, 1995.
82  //Modified for real vectros by ryd Aug 28-96
83 
84  return EvtVector3R( p1.v[1] * p2.v[2] - p1.v[2] * p2.v[1],
85  p1.v[2] * p2.v[0] - p1.v[0] * p2.v[2],
86  p1.v[0] * p2.v[1] - p1.v[1] * p2.v[0] );
87 }
88 
89 double EvtVector3R::d3mag() const
90 
91 // returns the 3 momentum mag.
92 {
93  double temp;
94 
95  temp = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
96  temp = sqrt( temp );
97 
98  return temp;
99 } // r3mag
100 
101 double EvtVector3R::dot( const EvtVector3R& p2 )
102 {
103  double temp;
104 
105  temp = v[0] * p2.v[0];
106  temp += v[0] * p2.v[0];
107  temp += v[0] * p2.v[0];
108 
109  return temp;
110 } //dot
ostream & operator<<(ostream &s, const EvtVector3R &v)
Definition: EvtVector3R.cpp:72
double d3mag() const
Definition: EvtVector3R.cpp:89
double dot(const EvtVector3R &v2)
EvtVector3R rotateEuler(const EvtVector3R &v, double alpha, double beta, double gamma)
Definition: EvtVector3R.cpp:41
double v[3]
Definition: EvtVector3R.hh:56
void applyRotateEuler(double phi, double theta, double ksi)
Definition: EvtVector3R.cpp:49
EvtVector3R cross(const EvtVector3R &p1, const EvtVector3R &p2)
Definition: EvtVector3R.cpp:79