Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
FourVector.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file FourVector.h
1
/*******************************************************************************
2
* Copyright (c) The JETSCAPE Collaboration, 2018
3
*
4
* Modular, task-based framework for simulating all aspects of heavy-ion collisions
5
*
6
* For the list of contributors see AUTHORS.
7
*
8
* Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9
*
10
* or via email to bugs.jetscape@gmail.com
11
*
12
* Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13
* See COPYING for details.
14
******************************************************************************/
15
16
#ifndef FOURVECTOR_H
17
#define FOURVECTOR_H
18
19
#include <iostream>
20
#include <cmath>
21
#include <vector>
22
#include <cstdlib>
23
#include <climits>
24
25
using
std::cout;
26
using
std::cerr;
27
using
std::endl;
28
29
namespace
Jetscape {
30
31
class
FourVector
{
32
// the class of four vectors
33
34
public
:
35
FourVector
()
//default constructor
36
{
37
tv
=
xv
=
yv
=
zv
= 0.0;
38
};
39
40
FourVector
(
const
FourVector
&srv)
41
:
xv
(srv.
xv
),
yv
(srv.
yv
),
zv
(srv.
zv
),
tv
(srv.
tv
){};
// copy constructor
42
43
FourVector
(
double
a
[4])
// constructor with array input
44
{
45
tv
= a[0];
46
xv
= a[1];
47
yv
= a[2];
48
zv
= a[3];
49
};
50
51
FourVector
(
double
x_in,
double
y_in,
double
z_in,
52
double
t_in)
// constructor with component input
53
{
54
tv
= t_in;
55
xv
= x_in;
56
yv
= y_in;
57
zv
= z_in;
58
};
59
60
void
clear
() {
tv
=
xv
=
yv
=
zv
= 0.0; }
61
62
// constructors do all sets
63
64
void
Set
(
double
x_in,
double
y_in,
double
z_in,
double
t_in) {
65
tv
= t_in;
66
xv
= x_in;
67
yv
= y_in;
68
zv
= z_in;
69
}
70
71
void
Set
(
double
a
[4]) {
72
tv
= a[0];
73
xv
= a[1];
74
yv
= a[2];
75
zv
= a[3];
76
};
77
78
// all gets are done with name calls e.g., vec.x()
79
double
x
()
const
{
return
(
xv
); };
80
81
double
y
()
const
{
return
(
yv
); };
82
83
double
z
()
const
{
return
(
zv
); };
84
85
double
t
()
const
{
return
(
tv
); };
86
87
const
double
comp
(
int
i
)
const
{
88
switch
(i) {
89
case
0:
90
return
(
tv
);
91
break
;
92
case
1:
93
return
(
xv
);
94
break
;
95
case
2:
96
return
(
yv
);
97
break
;
98
case
3:
99
return
(
zv
);
100
break
;
101
default
:
102
cout <<
" component index beyond 0-3! Returning garbage ..."
<< endl;
103
return
(
a_very_large_number
);
104
break
;
105
}
106
}
107
108
double
plus
() {
return
((
zv
+
tv
) / sqrt(2.0)); };
109
110
double
minus
() {
return
((
tv
-
zv
) / sqrt(2.0)); };
111
112
double
rapidity
() {
113
if
(this->
minus
() > 0.0)
114
return
(std::log(this->
plus
() / this->
minus
()) / 2.0);
115
cout << endl
116
<<
"ERROR: z component exceeds t component, cannot calculate rapidity"
117
<< endl;
118
return
(0);
119
};
120
121
double
phi
() {
122
if
(fabs(
x
()) <
rounding_error
&& fabs(
y
()) <
rounding_error
) {
123
return
0;
124
}
125
double
phi
= atan2(
y
(),
x
());
126
while
(phi < 0)
127
phi += 2.0 *
pi
;
128
return
phi
;
129
};
130
131
double
operator*
(
FourVector
&
c
) {
132
return
(
tv
* c.
t
() -
xv
* c.
x
() -
yv
* c.
y
() -
zv
* c.
z
());
133
};
134
135
FourVector
&
operator+=
(
FourVector
&
c
) {
136
tv
+= c.
t
();
137
xv
+= c.
x
();
138
yv
+= c.
y
();
139
zv
+= c.
z
();
140
141
return
(*
this
);
142
};
143
144
FourVector
&
operator-=
(
FourVector
&
c
) {
145
tv
-= c.
t
();
146
xv
-= c.
x
();
147
yv
-= c.
y
();
148
zv
-= c.
z
();
149
150
return
(*
this
);
151
};
152
153
FourVector
&
operator=
(
FourVector
&
c
) {
154
tv
= c.
t
();
155
xv
= c.
x
();
156
yv
= c.
y
();
157
zv
= c.
z
();
158
return
(*
this
);
159
};
160
161
FourVector
&
operator=
(
const
FourVector
&
c
) {
162
tv
= c.
tv
;
163
xv
= c.
xv
;
164
yv
= c.
yv
;
165
zv
= c.
zv
;
166
return
(*
this
);
167
};
168
169
void
rotate_around_z
(
double
theta
) {
170
double
new_xv, new_yv;
171
172
new_xv =
xv
* cos(theta) -
yv
* sin(theta);
173
174
new_yv =
yv
* cos(theta) +
xv
* sin(theta);
175
176
xv
= new_xv;
177
yv
= new_yv;
178
};
179
180
private
:
181
// the v is for vector, we call the private variables, xv, tv etc., so that get function
182
// calls will be called x, t etc.
183
double
xv
,
yv
,
zv
,
tv
;
184
};
185
186
};
// namespace Jetscape
187
188
#endif // FOURVECTOR_H
JETSCAPE
blob
main
src
framework
FourVector.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:24
using
1.8.2 with
sPHENIX GitHub integration