From 9a2ddc9c2f7d68e24b7606260b6945bf15142ade Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:54:46 +0200 Subject: [PATCH 01/10] Made parabolic and hyperbolic mirrors infinite --- source/framework/tools/src/TRestPhysics.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index 5b6dc3098..9ae66481c 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -87,12 +87,12 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, co /// This method will find the intersection between a vector and a parabolic shape where `alpha` is the angle /// between the optical axis and the paraboloid at the plane where the paraboloid has a radius of `R3`. /// The paraboloid is rotationally symmetric around the optical axis. `alpha` in rad. -/// The region in which the intersection can happen here is between `-lMirr` and 0 on the z (optical) axis +/// The region in which the intersection can happen here is in negative direction on the z (optical) axis /// /// In case no intersection is found this method returns the unmodified input position /// TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, - const Double_t R3, const Double_t lMirr) { + const Double_t R3) { Double_t e = 2 * R3 * TMath::Tan(alpha); Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y(); Double_t b = 2 * (pos.X() * dir.X() + pos.Y() * dir.Y()) + e * dir.Z(); @@ -101,9 +101,9 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir if (a != 0) { Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a; Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a; - if (pos.Z() + root1 * dir.Z() > -lMirr and pos.Z() + root1 * dir.Z() < 0) { + if (pos.Z() + root1 * dir.Z() < 0) { return pos + root1 * dir; - } else if (pos.Z() + root2 * dir.Z() > -lMirr and pos.Z() + root2 * dir.Z() < 0) { + } else if (pos.Z() + root2 * dir.Z() < 0) { return pos + root2 * dir; } return pos; @@ -115,12 +115,12 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir /// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the /// angle between the optical axis and the hyperboloid at the plane where the hyperboloid has a radius of /// `R3`. The hyperboloid is rotationally symmetric around the optical axis. `alpha` in rad. The region in -/// which the intersection can happen here is between 0 and `lMirr` on the `z` (optical) axis +/// which the intersection can happen here is in positive direction on the `z` (optical) axis /// /// In case no intersection is found this method returns the unmodified input position /// TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, - const Double_t R3, const Double_t lMirr, const Double_t focal) { + const Double_t R3, const Double_t focal) { Double_t beta = 3 * alpha; Double_t e = 2 * R3 * TMath::Tan(beta); /// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues @@ -131,9 +131,9 @@ TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& di Double_t c = pos.X() * pos.X() + pos.Y() * pos.Y() - R3 * R3 + e * pos.Z() - g * pos.Z() * pos.Z(); Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a; Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a; - if (pos.Z() + root1 * dir.Z() > 0 and pos.Z() + root1 * dir.Z() < lMirr) { + if (pos.Z() + root1 * dir.Z() > 0) { return pos + root1 * dir; - } else if (pos.Z() + root2 * dir.Z() > 0 and pos.Z() + root2 * dir.Z() < lMirr) { + } else if (pos.Z() + root2 * dir.Z() > 0) { return pos + root2 * dir; } From 631e79f06ef1fc675fa6da5c68e0255d635d19c8 Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Mon, 28 Aug 2023 12:58:14 +0200 Subject: [PATCH 02/10] Removed lMirror --- source/framework/tools/inc/TRestPhysics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/framework/tools/inc/TRestPhysics.h b/source/framework/tools/inc/TRestPhysics.h index dca1f0637..de4311a82 100644 --- a/source/framework/tools/inc/TRestPhysics.h +++ b/source/framework/tools/inc/TRestPhysics.h @@ -76,10 +76,10 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, TV TVector3 const& a); TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, - const Double_t R3, const Double_t lMirr); + const Double_t R3); TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, - const Double_t R3, const Double_t lMirr, const Double_t focal); + const Double_t R3, const Double_t focal); TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t R = 0); From 9e5c4403572439d352ec59261eb812eb7edf6910 Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:24:08 +0200 Subject: [PATCH 03/10] Changed optical into z-axis --- source/framework/tools/src/TRestPhysics.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index 9ae66481c..cade788ce 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -85,9 +85,9 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, co ////////////////////////////////////////////// /// This method will find the intersection between a vector and a parabolic shape where `alpha` is the angle -/// between the optical axis and the paraboloid at the plane where the paraboloid has a radius of `R3`. -/// The paraboloid is rotationally symmetric around the optical axis. `alpha` in rad. -/// The region in which the intersection can happen here is in negative direction on the z (optical) axis +/// between the z-axis and the paraboloid at the plane where the paraboloid has a radius of `R3`. +/// The paraboloid is rotationally symmetric around the z-axis. `alpha` in rad. +/// The region in which the intersection can happen here is in negative direction on the z-axis /// /// In case no intersection is found this method returns the unmodified input position /// @@ -113,9 +113,9 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir ////////////////////////////////////////////// /// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the -/// angle between the optical axis and the hyperboloid at the plane where the hyperboloid has a radius of -/// `R3`. The hyperboloid is rotationally symmetric around the optical axis. `alpha` in rad. The region in -/// which the intersection can happen here is in positive direction on the `z` (optical) axis +/// angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of +/// `R3`. The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in +/// which the intersection can happen here is in positive direction on the z-axis /// /// In case no intersection is found this method returns the unmodified input position /// @@ -199,7 +199,7 @@ TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t /////////////////////////////////////////////// /// \brief This method returns the normal vector on a parabolic surface pointing towards the inside /// of the paraboloid. `pos` is the origin point of the normal vector on the parabolic plane and -/// `alpha` is the angle between the paraboloid and the optical (z) axis at the plane where the +/// `alpha` is the angle between the paraboloid and the z-axis at the plane where the /// paraboloid has the radius `R3`. /// TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3) { @@ -214,7 +214,7 @@ TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Dou /////////////////////////////////////////////// /// \brief This method returns the normal vector on a hyperbolic surface pointing towards the inside /// of the hyperboloid. `pos` is the origin point of the normal vector on the hyperbolic plane and -/// `beta` is the angle between the hyperboloid and the optical (z) axis at the plane where the +/// `beta` is the angle between the hyperboloid and the z-axis at the plane where the /// hyperboloid has the radius `R3`. /// TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3, From b420709b2092328b4bcf31d72b56e2fc3446c01c Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:44:11 +0200 Subject: [PATCH 04/10] Cosmetic changes --- source/framework/tools/src/TRestPhysics.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index cade788ce..48624f3ea 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -87,9 +87,9 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, co /// This method will find the intersection between a vector and a parabolic shape where `alpha` is the angle /// between the z-axis and the paraboloid at the plane where the paraboloid has a radius of `R3`. /// The paraboloid is rotationally symmetric around the z-axis. `alpha` in rad. -/// The region in which the intersection can happen here is in negative direction on the z-axis +/// The region in which the intersection can happen here is in negative direction on the z-axis. /// -/// In case no intersection is found this method returns the unmodified input position +/// In case no intersection is found this method returns the unmodified input position. /// TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, const Double_t R3) { @@ -115,9 +115,9 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir /// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the /// angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of /// `R3`. The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in -/// which the intersection can happen here is in positive direction on the z-axis +/// which the intersection can happen here is in positive direction on the z-axis. /// -/// In case no intersection is found this method returns the unmodified input position +/// In case no intersection is found this method returns the unmodified input position. /// TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, const Double_t R3, const Double_t focal) { From 94396a0362e95101029f954904f748a80e74a34a Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:55:38 +0200 Subject: [PATCH 05/10] Update documentation --- source/framework/tools/src/TRestPhysics.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index 48624f3ea..f7178b80e 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -112,7 +112,7 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir } ////////////////////////////////////////////// -/// This method will find the intersection between a vector and a hyperbolic shape where 3 * `alpha` is the +/// This method will find the intersection between a vector and a hyperbolic shape where beta = 3 * `alpha` is the /// angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of /// `R3`. The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in /// which the intersection can happen here is in positive direction on the z-axis. From c7fdff330c6139c6fa50300c86ec88c060aa0878 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 30 Aug 2023 09:55:55 +0000 Subject: [PATCH 06/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/framework/tools/src/TRestPhysics.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index f7178b80e..a728388d1 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -112,10 +112,10 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir } ////////////////////////////////////////////// -/// This method will find the intersection between a vector and a hyperbolic shape where beta = 3 * `alpha` is the -/// angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of -/// `R3`. The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in -/// which the intersection can happen here is in positive direction on the z-axis. +/// This method will find the intersection between a vector and a hyperbolic shape where beta = 3 * `alpha` is +/// the angle between the z-axis and the hyperboloid at the plane where the hyperboloid has a radius of `R3`. +/// The hyperboloid is rotationally symmetric around the z-axis. `alpha` in rad. The region in which the +/// intersection can happen here is in positive direction on the z-axis. /// /// In case no intersection is found this method returns the unmodified input position. /// From 5b7b44d9550773120ec3a90b18764773f7761925 Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Tue, 20 Feb 2024 21:24:59 +0100 Subject: [PATCH 07/10] Fix problem with mirror intersections --- source/framework/tools/src/TRestPhysics.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index a728388d1..ecb514652 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -101,9 +101,11 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir if (a != 0) { Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a; Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a; - if (pos.Z() + root1 * dir.Z() < 0) { + Double_t int1 = pos.Z() + root1 * dir.Z(); + Double_t int2 = pos.Z() + root2 * dir.Z(); + if (int1 < 0 and int2 < 0 and int1 > int2) { return pos + root1 * dir; - } else if (pos.Z() + root2 * dir.Z() < 0) { + } else if (int1 < 0 and int2 < 0 and int1 < int2) { return pos + root2 * dir; } return pos; @@ -131,12 +133,13 @@ TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& di Double_t c = pos.X() * pos.X() + pos.Y() * pos.Y() - R3 * R3 + e * pos.Z() - g * pos.Z() * pos.Z(); Double_t root1 = (-half_b - TMath::Sqrt(half_b * half_b - a * c)) / a; Double_t root2 = (-half_b + TMath::Sqrt(half_b * half_b - a * c)) / a; - if (pos.Z() + root1 * dir.Z() > 0) { + Double_t int1 = pos.Z() + root1 * dir.Z(); + Double_t int2 = pos.Z() + root2 * dir.Z(); + if (int1 > 0 and int2 > 0 and int1 < int2) { return pos + root1 * dir; - } else if (pos.Z() + root2 * dir.Z() > 0) { + } else if (int1 > 0 and int2 > 0 and int1 > int2) { return pos + root2 * dir; } - return pos; } From b9aed0980ff2ef8ac235485758e823b047a616d3 Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:50:56 +0100 Subject: [PATCH 08/10] Change alpha to beta in hyperbolic fuctions --- source/framework/tools/src/TRestPhysics.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index ecb514652..f3b1fb3ad 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -121,9 +121,8 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir /// /// In case no intersection is found this method returns the unmodified input position. /// -TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, +TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta, const Double_t R3, const Double_t focal) { - Double_t beta = 3 * alpha; Double_t e = 2 * R3 * TMath::Tan(beta); /// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues Double_t g = 2 * R3 * TMath::Tan(beta) / (focal + R3 / TMath::Tan(2 * alpha)); @@ -220,10 +219,9 @@ TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Dou /// `beta` is the angle between the hyperboloid and the z-axis at the plane where the /// hyperboloid has the radius `R3`. /// -TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3, +TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3, const Double_t focal) { TVector3 normalVec = pos; - Double_t beta = 3 * alpha; /// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues Double_t m = 1 / (R3 * TMath::Tan(beta) * (1 - 2 * pos.Z() / (focal + R3 / TMath::Tan(2 * alpha))) / TMath::Sqrt(R3 * R3 - R3 * 2 * TMath::Tan(beta) * pos.Z() * From 1936885a20a628450da4ad2b764cfc3abc191e76 Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:07:50 +0100 Subject: [PATCH 09/10] Change alpha to beta in hyperbolic functions --- source/framework/tools/inc/TRestPhysics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/framework/tools/inc/TRestPhysics.h b/source/framework/tools/inc/TRestPhysics.h index 1104210e1..cd4fc365c 100644 --- a/source/framework/tools/inc/TRestPhysics.h +++ b/source/framework/tools/inc/TRestPhysics.h @@ -78,14 +78,14 @@ TVector3 GetPlaneVectorIntersection(const TVector3& pos, const TVector3& dir, TV TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, const Double_t R3); -TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t alpha, +TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta, const Double_t R3, const Double_t focal); TVector3 GetConeNormal(const TVector3& pos, const Double_t alpha, const Double_t R = 0); TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3); -TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t alpha, const Double_t R3, +TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3, const Double_t focal); TMatrixD GetConeMatrix(const TVector3& d, const Double_t cosTheta); From a512f93ab9c0560df170b93345cf5a9b3aff75eb Mon Sep 17 00:00:00 2001 From: jovoy <50204158+jovoy@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:18:36 +0100 Subject: [PATCH 10/10] Fixed hyperbolic functions --- source/framework/tools/src/TRestPhysics.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/framework/tools/src/TRestPhysics.cxx b/source/framework/tools/src/TRestPhysics.cxx index f3b1fb3ad..ab272147f 100644 --- a/source/framework/tools/src/TRestPhysics.cxx +++ b/source/framework/tools/src/TRestPhysics.cxx @@ -124,6 +124,7 @@ TVector3 GetParabolicVectorIntersection(const TVector3& pos, const TVector3& dir TVector3 GetHyperbolicVectorIntersection(const TVector3& pos, const TVector3& dir, const Double_t beta, const Double_t R3, const Double_t focal) { Double_t e = 2 * R3 * TMath::Tan(beta); + Double_t alpha = beta / 3; /// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues Double_t g = 2 * R3 * TMath::Tan(beta) / (focal + R3 / TMath::Tan(2 * alpha)); Double_t a = dir.X() * dir.X() + dir.Y() * dir.Y() - g * dir.Z() * dir.Z(); @@ -222,6 +223,7 @@ TVector3 GetParabolicNormal(const TVector3& pos, const Double_t alpha, const Dou TVector3 GetHyperbolicNormal(const TVector3& pos, const Double_t beta, const Double_t R3, const Double_t focal) { TVector3 normalVec = pos; + Double_t alpha = beta / 3; /// Just replaced here *TMath::Cot by /TMath::Tan to fix compilation issues Double_t m = 1 / (R3 * TMath::Tan(beta) * (1 - 2 * pos.Z() / (focal + R3 / TMath::Tan(2 * alpha))) / TMath::Sqrt(R3 * R3 - R3 * 2 * TMath::Tan(beta) * pos.Z() *