Skip to content

Commit 2002d9c

Browse files
authored
Merge pull request #469 from rest-for-physics/jovoy-mirror_fix
Remove Parabolic and Hyperbolic mirror restrictions
2 parents 64bc2fc + a512f93 commit 2002d9c

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

source/framework/tools/inc/TRestPhysics.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, TV
7676
TVector3 const& a);
7777

7878
TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
79-
const Double_t R3, const Double_t lMirr);
79+
const Double_t R3);
8080

81-
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
82-
const Double_t R3, const Double_t lMirr, const Double_t focal);
81+
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta,
82+
const Double_t R3, const Double_t focal);
8383

8484
TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t R = 0);
8585

8686
TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3);
8787

88-
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3,
88+
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3,
8989
const Double_t focal);
9090

9191
TMatrixD GetConeMatrix(const TVector3& d, const Double_t cosTheta);

source/framework/tools/src/TRestPhysics.cxx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, co
8585

8686
//////////////////////////////////////////////
8787
/// This method will find the intersection between a vector and a parabolic shape where `alpha` is the angle
88-
/// between the optical axis and the paraboloid at the plane where the paraboloid has a radius of `R3`.
89-
/// The paraboloid is rotationally symmetric around the optical axis. `alpha` in rad.
90-
/// The region in which the intersection can happen here is between `-lMirr` and 0 on the z (optical) axis
88+
/// between the z-axis and the paraboloid at the plane where the paraboloid has a radius of `R3`.
89+
/// The paraboloid is rotationally symmetric around the z-axis. `alpha` in rad.
90+
/// The region in which the intersection can happen here is in negative direction on the z-axis.
9191
///
92-
/// In case no intersection is found this method returns the unmodified input position
92+
/// In case no intersection is found this method returns the unmodified input position.
9393
///
9494
TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
95-
const Double_t R3, const Double_t lMirr) {
95+
const Double_t R3) {
9696
Double_t e = 2 * R3 * TMath::Tan(alpha);
9797
Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y();
9898
Double_t b = 2 * (pos.X() * dir.X() + pos.Y() * dir.Y()) + e * dir.Z();
@@ -101,9 +101,11 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir
101101
if (a != 0) {
102102
Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a;
103103
Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a;
104-
if (pos.Z() + root1 * dir.Z() > -lMirr and pos.Z() + root1 * dir.Z() < 0) {
104+
Double_t int1 = pos.Z() + root1 * dir.Z();
105+
Double_t int2 = pos.Z() + root2 * dir.Z();
106+
if (int1 < 0 and int2 < 0 and int1 > int2) {
105107
return pos + root1 * dir;
106-
} else if (pos.Z() + root2 * dir.Z() > -lMirr and pos.Z() + root2 * dir.Z() < 0) {
108+
} else if (int1 < 0 and int2 < 0 and int1 < int2) {
107109
return pos + root2 * dir;
108110
}
109111
return pos;
@@ -112,17 +114,17 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir
112114
}
113115

114116
//////////////////////////////////////////////
115-
/// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the
116-
/// angle between the optical axis and the hyperboloid at the plane where the hyperboloid has a radius of
117-
/// `R3`. The hyperboloid is rotationally symmetric around the optical axis. `alpha` in rad. The region in
118-
/// which the intersection can happen here is between 0 and `lMirr` on the `z` (optical) axis
117+
/// This method will find the intersection between a vector and a hyperbolic shape where beta = 3 * `alpha` is
118+
/// the angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of `R3`.
119+
/// The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in which the
120+
/// intersection can happen here is in positive direction on the z-axis.
119121
///
120-
/// In case no intersection is found this method returns the unmodified input position
122+
/// In case no intersection is found this method returns the unmodified input position.
121123
///
122-
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha,
123-
const Double_t R3, const Double_t lMirr, const Double_t focal) {
124-
Double_t beta = 3 * alpha;
124+
TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta,
125+
const Double_t R3, const Double_t focal) {
125126
Double_t e = 2 * R3 * TMath::Tan(beta);
127+
Double_t alpha = beta / 3;
126128
/// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues
127129
Double_t g = 2 * R3 * TMath::Tan(beta) / (focal + R3 / TMath::Tan(2 * alpha));
128130
Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y() - g * dir.Z() * dir.Z();
@@ -131,12 +133,13 @@ TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& di
131133
Double_t c = pos.X() * pos.X() + pos.Y() * pos.Y() - R3 * R3 + e * pos.Z() - g * pos.Z() * pos.Z();
132134
Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a;
133135
Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a;
134-
if (pos.Z() + root1 * dir.Z() > 0 and pos.Z() + root1 * dir.Z() < lMirr) {
136+
Double_t int1 = pos.Z() + root1 * dir.Z();
137+
Double_t int2 = pos.Z() + root2 * dir.Z();
138+
if (int1 > 0 and int2 > 0 and int1 < int2) {
135139
return pos + root1 * dir;
136-
} else if (pos.Z() + root2 * dir.Z() > 0 and pos.Z() + root2 * dir.Z() < lMirr) {
140+
} else if (int1 > 0 and int2 > 0 and int1 > int2) {
137141
return pos + root2 * dir;
138142
}
139-
140143
return pos;
141144
}
142145

@@ -199,7 +202,7 @@ TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t
199202
///////////////////////////////////////////////
200203
/// \brief This method returns the normal vector on a parabolic surface pointing towards the inside
201204
/// of the paraboloid. `pos` is the origin point of the normal vector on the parabolic plane and
202-
/// `alpha` is the angle between the paraboloid and the optical (z) axis at the plane where the
205+
/// `alpha` is the angle between the paraboloid and the z-axis at the plane where the
203206
/// paraboloid has the radius `R3`.
204207
///
205208
TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3) {
@@ -214,13 +217,13 @@ TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Dou
214217
///////////////////////////////////////////////
215218
/// \brief This method returns the normal vector on a hyperbolic surface pointing towards the inside
216219
/// of the hyperboloid. `pos` is the origin point of the normal vector on the hyperbolic plane and
217-
/// `beta` is the angle between the hyperboloid and the optical (z) axis at the plane where the
220+
/// `beta` is the angle between the hyperboloid and the z-axis at the plane where the
218221
/// hyperboloid has the radius `R3`.
219222
///
220-
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3,
223+
TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3,
221224
const Double_t focal) {
222225
TVector3 normalVec = pos;
223-
Double_t beta = 3 * alpha;
226+
Double_t alpha = beta / 3;
224227
/// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues
225228
Double_t m = 1 / (R3 * TMath::Tan(beta) * (1 - 2 * pos.Z() / (focal + R3 / TMath::Tan(2 * alpha))) /
226229
TMath::Sqrt(R3 * R3 - R3 * 2 * TMath::Tan(beta) * pos.Z() *

0 commit comments

Comments
 (0)