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.hh
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 
21 #ifndef EVTVECTOR3R_HH
22 #define EVTVECTOR3R_HH
23 
24 #include <iosfwd>
25 
26 class EvtVector3R final {
27  friend EvtVector3R rotateEuler( const EvtVector3R& v, double phi,
28  double theta, double ksi );
29 
30  inline friend EvtVector3R operator*( double c, const EvtVector3R& v2 );
31  inline friend double operator*( const EvtVector3R& v1, const EvtVector3R& v2 );
32  inline friend EvtVector3R operator+( const EvtVector3R& v1,
33  const EvtVector3R& v2 );
34  inline friend EvtVector3R operator-( const EvtVector3R& v1,
35  const EvtVector3R& v2 );
36  inline friend EvtVector3R operator*( const EvtVector3R& v1, double c );
37  inline friend EvtVector3R operator/( const EvtVector3R& v1, double c );
38  friend EvtVector3R cross( const EvtVector3R& v1, const EvtVector3R& v2 );
39 
40  public:
41  EvtVector3R();
42  EvtVector3R( double x, double y, double z );
43  inline EvtVector3R& operator*=( const double c );
44  inline EvtVector3R& operator/=( const double c );
45  inline EvtVector3R& operator+=( const EvtVector3R& v2 );
46  inline EvtVector3R& operator-=( const EvtVector3R& v2 );
47  inline void set( int i, double d );
48  inline void set( double x, double y, double z );
49  void applyRotateEuler( double phi, double theta, double ksi );
50  inline double get( int i ) const;
51  friend std::ostream& operator<<( std::ostream& s, const EvtVector3R& v );
52  double dot( const EvtVector3R& v2 );
53  double d3mag() const;
54 
55  private:
56  double v[3];
57 };
58 
59 inline EvtVector3R& EvtVector3R::operator*=( const double c )
60 {
61  v[0] *= c;
62  v[1] *= c;
63  v[2] *= c;
64  return *this;
65 }
66 
67 inline EvtVector3R& EvtVector3R::operator/=( const double c )
68 {
69  v[0] /= c;
70  v[1] /= c;
71  v[2] /= c;
72  return *this;
73 }
74 
76 {
77  v[0] += v2.v[0];
78  v[1] += v2.v[1];
79  v[2] += v2.v[2];
80  return *this;
81 }
82 
84 {
85  v[0] -= v2.v[0];
86  v[1] -= v2.v[1];
87  v[2] -= v2.v[2];
88  return *this;
89 }
90 
91 inline EvtVector3R operator*( double c, const EvtVector3R& v2 )
92 {
93  return EvtVector3R( v2 ) *= c;
94 }
95 
96 inline EvtVector3R operator*( const EvtVector3R& v1, double c )
97 {
98  return EvtVector3R( v1 ) *= c;
99 }
100 
101 inline EvtVector3R operator/( const EvtVector3R& v1, double c )
102 {
103  return EvtVector3R( v1 ) /= c;
104 }
105 
106 inline double operator*( const EvtVector3R& v1, const EvtVector3R& v2 )
107 {
108  return v1.v[0] * v2.v[0] + v1.v[1] * v2.v[1] + v1.v[2] * v2.v[2];
109 }
110 
111 inline EvtVector3R operator+( const EvtVector3R& v1, const EvtVector3R& v2 )
112 {
113  return EvtVector3R( v1 ) += v2;
114 }
115 
116 inline EvtVector3R operator-( const EvtVector3R& v1, const EvtVector3R& v2 )
117 {
118  return EvtVector3R( v1 ) -= v2;
119 }
120 
121 inline double EvtVector3R::get( int i ) const
122 {
123  return v[i];
124 }
125 
126 inline void EvtVector3R::set( int i, double d )
127 {
128  v[i] = d;
129 }
130 
131 inline void EvtVector3R::set( double x, double y, double z )
132 {
133  v[0] = x;
134  v[1] = y;
135  v[2] = z;
136 }
137 
138 #endif
EvtVector3R & operator *=(const double c)
Definition: EvtVector3R.hh:59
double get(int i) const
Definition: EvtVector3R.hh:121
friend EvtVector3R cross(const EvtVector3R &v1, const EvtVector3R &v2)
Definition: EvtVector3R.cpp:79
EvtVector3R & operator/=(const double c)
Definition: EvtVector3R.hh:67
EvtVector3R operator *(double c, const EvtVector3R &v2)
Definition: EvtVector3R.hh:91
friend EvtVector3R operator/(const EvtVector3R &v1, double c)
Definition: EvtVector3R.hh:101
double d3mag() const
Definition: EvtVector3R.cpp:89
EvtVector3R operator+(const EvtVector3R &v1, const EvtVector3R &v2)
Definition: EvtVector3R.hh:111
double dot(const EvtVector3R &v2)
friend EvtVector3R operator+(const EvtVector3R &v1, const EvtVector3R &v2)
Definition: EvtVector3R.hh:111
friend EvtVector3R rotateEuler(const EvtVector3R &v, double phi, double theta, double ksi)
Definition: EvtVector3R.cpp:41
double v[3]
Definition: EvtVector3R.hh:56
void applyRotateEuler(double phi, double theta, double ksi)
Definition: EvtVector3R.cpp:49
EvtVector3R operator-(const EvtVector3R &v1, const EvtVector3R &v2)
Definition: EvtVector3R.hh:116
EvtVector3R operator/(const EvtVector3R &v1, double c)
Definition: EvtVector3R.hh:101
friend EvtVector3R operator-(const EvtVector3R &v1, const EvtVector3R &v2)
Definition: EvtVector3R.hh:116
friend std::ostream & operator<<(std::ostream &s, const EvtVector3R &v)
EvtVector3R & operator+=(const EvtVector3R &v2)
Definition: EvtVector3R.hh:75
EvtVector3R & operator-=(const EvtVector3R &v2)
Definition: EvtVector3R.hh:83
void set(int i, double d)
Definition: EvtVector3R.hh:126
friend EvtVector3R operator *(double c, const EvtVector3R &v2)
Definition: EvtVector3R.hh:91