ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
TwoVector.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file TwoVector.h
1
// -*- C++ -*-
2
// CLASSDOC OFF
3
// ---------------------------------------------------------------------------
4
// CLASSDOC ON
5
//
6
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
7
//
8
// Hep2Vector is a general 2-vector class defining vectors in two
9
// dimension using double components. It comes from the ZOOM
10
// PlaneVector class (the PhysicsVectors PlaneVector.h will typedef
11
// PlaneVector to Hep2Vector).
12
//
13
// .SS See Also
14
// ThreeVector.h
15
//
16
// .SS Authors
17
// John Marraffino and Mark Fischler
18
//
19
20
#ifndef HEP_TWOVECTOR_H
21
#define HEP_TWOVECTOR_H
22
23
#ifdef GNUPRAGMA
24
#pragma interface
25
#endif
26
27
#include <iostream>
28
29
#include "
CLHEP/Vector/ThreeVector.h
"
30
31
namespace
CLHEP {
32
33
// Declarations of classes and global methods
34
class
Hep2Vector;
35
std::ostream &
operator <<
(std::ostream &,
const
Hep2Vector &);
36
std::istream &
operator >>
(std::istream &, Hep2Vector &);
37
inline
double
operator *
(
const
Hep2Vector &
a
,
const
Hep2Vector &
b
);
38
inline
Hep2Vector
operator *
(
const
Hep2Vector &
p
,
double
a
);
39
inline
Hep2Vector
operator *
(
double
a
,
const
Hep2Vector &
p
);
40
Hep2Vector
operator /
(
const
Hep2Vector &
p
,
double
a
);
41
inline
Hep2Vector
operator +
(
const
Hep2Vector &
a
,
const
Hep2Vector &
b
);
42
inline
Hep2Vector
operator -
(
const
Hep2Vector &
a
,
const
Hep2Vector &
b
);
43
48
class
Hep2Vector
{
49
50
public
:
51
52
enum
{
X
=0,
Y
=1,
NUM_COORDINATES
=2,
SIZE
=
NUM_COORDINATES
};
53
// Safe indexing of the coordinates when using with matrices, arrays, etc.
54
55
inline
Hep2Vector
(
double
x
= 0.0,
double
y
= 0.0 );
56
// The constructor.
57
58
inline
Hep2Vector
(
const
Hep2Vector
&
p
);
59
inline
Hep2Vector
(
Hep2Vector
&&
p
) =
default
;
60
// The copy and move constructors.
61
62
explicit
Hep2Vector
(
const
Hep3Vector
& );
63
// "demotion" constructor"
64
// WARNING -- THIS IGNORES THE Z COMPONENT OF THE Hep3Vector.
65
// SO IN GENERAL, Hep2Vector(v)==v WILL NOT HOLD!
66
67
inline
~Hep2Vector
();
68
// The destructor.
69
70
inline
double
x
()
const
;
71
inline
double
y
()
const
;
72
// The components in cartesian coordinate system.
73
74
double
operator ()
(
int
i)
const
;
75
inline
double
operator []
(
int
i)
const
;
76
// Get components by index. 0-based.
77
78
double
&
operator ()
(
int
i);
79
inline
double
&
operator []
(
int
i);
80
// Set components by index. 0-based.
81
82
inline
void
setX
(
double
x
);
83
inline
void
setY
(
double
y
);
84
inline
void
set
(
double
x
,
double
y
);
85
// Set the components in cartesian coordinate system.
86
87
inline
double
phi
()
const
;
88
// The azimuth angle.
89
90
inline
double
mag2
()
const
;
91
// The magnitude squared.
92
93
inline
double
mag
()
const
;
94
// The magnitude.
95
96
inline
double
r
()
const
;
97
// r in polar coordinates (r, phi): equal to mag().
98
99
inline
void
setPhi
(
double
phi
);
100
// Set phi keeping mag constant.
101
102
inline
void
setMag
(
double
r
);
103
// Set magnitude keeping phi constant.
104
105
inline
void
setR
(
double
r
);
106
// Set R keeping phi constant. Same as setMag.
107
108
inline
void
setPolar
(
double
r
,
double
phi
);
109
// Set by polar coordinates.
110
111
inline
Hep2Vector
&
operator =
(
const
Hep2Vector
&
p
);
112
inline
Hep2Vector
&
operator =
(
Hep2Vector
&&
p
) =
default
;
113
// The copy and move assignment operators.
114
115
inline
bool
operator ==
(
const
Hep2Vector
&
v
)
const
;
116
inline
bool
operator !=
(
const
Hep2Vector
&
v
)
const
;
117
// Comparisons.
118
119
int
compare
(
const
Hep2Vector
&
v
)
const
;
120
bool
operator >
(
const
Hep2Vector
&
v
)
const
;
121
bool
operator <
(
const
Hep2Vector
&
v
)
const
;
122
bool
operator>=
(
const
Hep2Vector
&
v
)
const
;
123
bool
operator<=
(
const
Hep2Vector
&
v
)
const
;
124
// dictionary ordering according to y, then x component
125
126
static
inline
double
getTolerance
();
127
static
double
setTolerance
(
double
tol);
128
129
double
howNear
(
const
Hep2Vector
&
p
)
const
;
130
bool
isNear
(
const
Hep2Vector
&
p
,
double
epsilon
=
tolerance
)
const
;
131
132
double
howParallel
(
const
Hep2Vector
&
p
)
const
;
133
bool
isParallel
134
(
const
Hep2Vector
&
p
,
double
epsilon
=
tolerance
)
const
;
135
136
double
howOrthogonal
(
const
Hep2Vector
&
p
)
const
;
137
bool
isOrthogonal
138
(
const
Hep2Vector
&
p
,
double
epsilon
=
tolerance
)
const
;
139
140
inline
Hep2Vector
&
operator +=
(
const
Hep2Vector
&
p
);
141
// Addition.
142
143
inline
Hep2Vector
&
operator -=
(
const
Hep2Vector
&
p
);
144
// Subtraction.
145
146
inline
Hep2Vector
operator -
()
const
;
147
// Unary minus.
148
149
inline
Hep2Vector
&
operator *=
(
double
a
);
150
// Scaling with real numbers.
151
152
inline
Hep2Vector
unit
()
const
;
153
// Unit vector parallel to this.
154
155
inline
Hep2Vector
orthogonal
()
const
;
156
// Vector orthogonal to this.
157
158
inline
double
dot
(
const
Hep2Vector
&
p
)
const
;
159
// Scalar product.
160
161
inline
double
angle
(
const
Hep2Vector
&)
const
;
162
// The angle w.r.t. another 2-vector.
163
164
void
rotate
(
double
);
165
// Rotates the Hep2Vector.
166
167
operator
Hep3Vector
()
const
;
168
// Cast a Hep2Vector as a Hep3Vector.
169
170
// The remaining methods are friends, thus defined at global scope:
171
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
172
173
friend
std::ostream &
operator<<
(std::ostream &,
const
Hep2Vector
&);
174
// Output to a stream.
175
176
inline
friend
double
operator *
(
const
Hep2Vector
&
a
,
177
const
Hep2Vector
&
b
);
178
// Scalar product.
179
180
inline
friend
Hep2Vector
operator *
(
const
Hep2Vector
&
p
,
double
a
);
181
// v*c
182
183
inline
friend
Hep2Vector
operator *
(
double
a
,
const
Hep2Vector
&
p
);
184
// c*v
185
186
friend
Hep2Vector
operator /
(
const
Hep2Vector
&
p
,
double
a
);
187
// v/c
188
189
inline
friend
Hep2Vector
operator +
(
const
Hep2Vector
&
a
,
190
const
Hep2Vector
&
b
);
191
// v1+v2
192
193
inline
friend
Hep2Vector
operator -
(
const
Hep2Vector
&
a
,
194
const
Hep2Vector
&
b
);
195
// v1-v2
196
197
enum
{
ZMpvToleranceTicks
= 100 };
198
199
private
:
200
201
double
dx
;
202
double
dy
;
203
// The components.
204
205
static
double
tolerance
;
206
// default tolerance criterion for isNear() to return true.
207
208
};
// Hep2Vector
209
210
static
const
Hep2Vector
X_HAT2
(1.0, 0.0);
211
static
const
Hep2Vector
Y_HAT2
(0.0, 1.0);
212
213
}
// namespace CLHEP
214
215
#include "CLHEP/Vector/TwoVector.icc"
216
217
#endif
/* HEP_TWOVECTOR_H */
geant4
tree
geant4-10.6-release
source
externals
clhep
include
CLHEP
Vector
TwoVector.h
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:14
using
1.8.2 with
ECCE GitHub integration