commonly used functions
More...
|
double | unfold (double x, int nx, double A) |
| unfold a coordinate.
|
|
double | unfold (double kx, int nx) |
| unfold a direction.
|
|
void | fold (double xu, double A, double &x, double &kx, int &nx) |
| fold a coordinate (inverse of unfold).
|
|
double | clip (double x, int Nx, double A, double xmi, double xma) |
| Performs a clip on x w.r.t xmi and xma.
|
|
int | getNumOfEven (int j1, int j2) |
| Returns number of even numbers in the range given by arguments.
|
|
double | within2PI (double angle) |
| Returns angle within 0 and 2PI.
|
|
void | rotateUz (ROOT::Math::XYZVector &vec, const ROOT::Math::XYZVector &z_Axis) |
| Replacement for a function TVector3::RotateUz which is not implemented in GenVector classes.
|
|
◆ clip()
double clip |
( |
double |
x, |
|
|
int |
Nx, |
|
|
double |
A, |
|
|
double |
xmi, |
|
|
double |
xma |
|
) |
| |
|
inline |
Performs a clip on x w.r.t xmi and xma.
- Parameters
-
x | true coordinate |
Nx | signed number of reflections |
A | size for folding/unfolding |
xmi | lower limit on unfolded coordinate x |
xma | upper limit on unfolded coordinate x |
- Returns
- clipped x
Definition at line 78 of file func.h.
79 {
81 x = std::max(std::min(x, xma), xmi) - Nx * A;
82 if (Nx % 2 != 0) x = -x;
83 return x;
84 }
double unfold(double x, int nx, double A)
unfold a coordinate.
◆ fold()
void fold |
( |
double |
xu, |
|
|
double |
A, |
|
|
double & |
x, |
|
|
double & |
kx, |
|
|
int & |
nx |
|
) |
| |
|
inline |
fold a coordinate (inverse of unfold).
- Parameters
-
xu | unfolded coordinate (position of image) |
A | size for folding |
x | true position [out] |
kx | true direction component [in/out] |
nx | signed number of reflections [out] |
Definition at line 59 of file func.h.
60 {
61 nx = lround(xu / A);
62 x = xu - nx * A;
63 if (nx % 2 != 0) {
64 x = -x;
65 kx = -kx;
66 }
67 }
◆ getNumOfEven()
int getNumOfEven |
( |
int |
j1, |
|
|
int |
j2 |
|
) |
| |
|
inline |
Returns number of even numbers in the range given by arguments.
- Parameters
-
j1 | first number |
j2 | last number (exclusive) |
- Returns
- number of even numbers
Definition at line 92 of file func.h.
93 {
94 return (j2 - j1 + 1 - std::abs(j1) % 2) / 2;
95 }
◆ rotateUz()
void rotateUz |
( |
ROOT::Math::XYZVector & |
vec, |
|
|
const ROOT::Math::XYZVector & |
z_Axis |
|
) |
| |
|
inline |
Replacement for a function TVector3::RotateUz which is not implemented in GenVector classes.
- Parameters
-
vec | vector to be rotated from frame S' [in] to frame S [out] |
z_Axis | vector representing z-axis of the frame S' expressed in the coordinates of frame S |
Definition at line 114 of file func.h.
115 {
116 auto zAxis = z_Axis.Unit();
117 double cth = zAxis.Z();
118 double sth =
sqrt(1 - cth * cth);
119 if (sth == 0) {
120 if (cth < 0) vec = -vec;
121 return;
122 }
123 double cfi = zAxis.X() / sth;
124 double sfi = zAxis.Y() / sth;
125
126 double x = cth * vec.X() + sth * vec.Z();
127 double y = vec.Y();
128 double z = -sth * vec.X() + cth * vec.Z();
129 vec.SetX(cfi * x - sfi * y);
130 vec.SetY(sfi * x + cfi * y);
131 vec.SetZ(z);
132 }
double sqrt(double a)
sqrt for double
◆ unfold() [1/2]
double unfold |
( |
double |
kx, |
|
|
int |
nx |
|
) |
| |
|
inline |
unfold a direction.
- Parameters
-
kx | true direction component |
nx | signed number of reflections |
- Returns
- unfolded direction component
Definition at line 44 of file func.h.
45 {
46 if (nx % 2 == 0) return kx;
47 else return -kx;
48 }
◆ unfold() [2/2]
double unfold |
( |
double |
x, |
|
|
int |
nx, |
|
|
double |
A |
|
) |
| |
|
inline |
unfold a coordinate.
- Parameters
-
x | true position |
nx | signed number of reflections |
A | size for unfolding |
- Returns
- unfolded coordinate (position of image)
Definition at line 31 of file func.h.
32 {
33 if (nx % 2 == 0) return (nx * A + x);
34 else return (nx * A - x);
35 }
◆ within2PI()
double within2PI |
( |
double |
angle | ) |
|
|
inline |
Returns angle within 0 and 2PI.
- Parameters
-
- Returns
- angle within 0 and 2PI
Definition at line 102 of file func.h.
103 {
104 angle = fmod(angle, 2 * M_PI);
105 if (angle < 0) angle += 2 * M_PI;
106 return angle;
107 }