From 02232575701c73097c9b7ec221d43839bab46de1 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Mon, 13 May 2024 09:41:06 +0200
Subject: [PATCH] Fix and improve quantum efficiency interpolation

---
 src/pmt.jl       |  2 --
 test/runtests.jl | 28 +++++++++++++++++++++++-----
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/src/pmt.jl b/src/pmt.jl
index 6489933..5781bfa 100644
--- a/src/pmt.jl
+++ b/src/pmt.jl
@@ -17,8 +17,6 @@ end
 const KM3NeTPMT = PMTModel(
     45.4e-4,
     # The quantum efficiency includes absorption in glass and gel.
-    # Yields slightly different values compared to the Jpp getQE() function,
-    # very probably due to the interpolation implementation.
     LinearInterpolator(
         [
             0,
diff --git a/test/runtests.jl b/test/runtests.jl
index b06e1b9..7559138 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -2,26 +2,44 @@ using LumenManufaktur
 using Test
 
 @testset "direct light from muon" begin
-    params = LMParameters(dispersion_model = DispersionARCA)
+    params = LMParameters(dispersion_model = DispersionORCA)
     pmt = LumenManufaktur.KM3NeTPMT
 
     # The relative tolerances are based on comparisons between
-    # LumenManufaktur.jl v01.1.1 and Jpp v18.6.0-rc.1-26-g83ce39ff1
+    # LumenManufaktur.jl v0.5.1 and Jpp v18.6.0-rc.1-26-g83ce39ff1
     @test isapprox(
         0.0304415,
         directlightfrommuon(params, pmt, 30, 2.33319, π),
-        rtol = 0.017,
+        rtol = 0.000001,
     )
     @test isapprox(
         0.00152972,
         directlightfrommuon(params, pmt, 23, 4.78319, π / 2),
-        rtol = 0.017,
+        rtol = 0.0001,
     )
     @test isapprox(
         2.63515e-05,
         directlightfrommuon(params, pmt, 42, 1.78319, π / 3),
-        rtol = 0.025,
+        rtol = 0.0001,
+    )
+    @test isapprox(
+        13.0251,
+        directlightfrommuon(params, pmt, 1.15, 2.85599, π / 2, 0.01),
+        rtol = 0.000001,
     )
     @test 0 ≈ directlightfrommuon(params, pmt, 5, 0.78319, 0.5708)
 
+
+    @test isapprox(
+        0.00414637,
+        scatteredlightfrommuon(params, pmt, 2.0, 0.5, π / 2, π, 1.23),
+        rtol = 0.000001,
+    )
+#
+    @test isapprox(
+        0.00432646,
+        directlightfromdeltarays(params, pmt, 1.5, π/2, π/3, 1.23),
+        rtol = 0.000001
+    )
+
 end
-- 
GitLab