aboutsummaryrefslogtreecommitdiff
path: root/src/solid_angle.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-10-21 11:32:40 -0500
committertlatorre <tlatorre@uchicago.edu>2018-10-21 11:32:40 -0500
commit04656e730d1f0a1c55fdee48e8ea9f34552c03d8 (patch)
tree3714efc8ccad7e2317f6e63d83bb81dcb9d6d60b /src/solid_angle.c
parentb6af7f268dcd7b7508ab7c5a6b1ba5c3384b9c5d (diff)
downloadsddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.tar.gz
sddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.tar.bz2
sddm-04656e730d1f0a1c55fdee48e8ea9f34552c03d8.zip
add a fast solid angle approximation to speed up the fast likelihood calculation
Diffstat (limited to 'src/solid_angle.c')
-rw-r--r--src/solid_angle.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/solid_angle.c b/src/solid_angle.c
index a929938..dbac045 100644
--- a/src/solid_angle.c
+++ b/src/solid_angle.c
@@ -3,6 +3,7 @@
#include <math.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_spline2d.h>
+#include "vector.h"
static double hd[11] = {0.1,0.125,0.150,0.175,0.2,0.3,0.4,0.5,0.6,0.8,1.0};
static double Rd[13] = {0.1,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,2.0};
@@ -23,6 +24,24 @@ static double lookupTable[13][11] = {
{1.0041,1.0051,1.0061,1.0070,1.0078,1.0106,1.0120,1.0122,1.0116,1.0097,1.0084}
};
+double get_solid_angle_fast(double *pos, double *pmt, double *n, double r)
+{
+ /* Returns a *very* fast approximation of the solid angle subtended by a
+ * circular disk of radius r at a position `pmt` with a normal vector `n` from
+ * a position `pos`. */
+ double dir[3];
+ double R, cos_theta_pmt;
+
+ SUB(dir,pos,pmt);
+
+ /* Distance to the PMT. */
+ R = NORM(dir);
+
+ cos_theta_pmt = fabs(DOT(dir,n)/R);
+
+ return pow(r,2)*cos_theta_pmt/pow(R,2);
+}
+
static double A(double u, double a, double h)
{
return atan(((a*a-h*h)*u - 2*a*a*h*h)/(2*a*h*sqrt((u-h*h)*(u+a*a))));