aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-05-01 10:53:49 -0400
committertlatorre <tlatorre@uchicago.edu>2018-05-01 10:53:49 -0400
commitea7686ac0f4426d0b3ddefbcdeda0178bf988361 (patch)
tree7192b608d2ba4cc6fd01661b9f72382d28bc6f46
downloadsddm-ea7686ac0f4426d0b3ddefbcdeda0178bf988361.tar.gz
sddm-ea7686ac0f4426d0b3ddefbcdeda0178bf988361.tar.bz2
sddm-ea7686ac0f4426d0b3ddefbcdeda0178bf988361.zip
initial commit
-rw-r--r--.gitignore2
-rw-r--r--Makefile3
-rw-r--r--calculate_limits.c59
3 files changed, 64 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d17415b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.swp
+calculate_limits
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..8f1188a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+LDLIBS=-lm
+
+calculate_limits: calculate_limits.c
diff --git a/calculate_limits.c b/calculate_limits.c
new file mode 100644
index 0000000..8815324
--- /dev/null
+++ b/calculate_limits.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <gsl/gsl_integration.h>
+#include <math.h> /* For M_PI */
+
+/* From Google maps. Probably not very accurate, but should be good enough for
+ * this calculation. */
+double latitude = 46.471857;
+double longitude = -81.186755;
+
+/* Radius of the earth in mm. */
+double radius_earth = 6.371e9;
+
+/* Depth of the SNO detector in mm. Don't be fooled by all the digits. I just
+ * converted 6800 feet -> mm. */
+double sno_depth = 2072640;
+
+/* Fiducial volume in mm. */
+double radius_fiducial = 5000;
+
+double deg2rad(double deg)
+{
+ return deg*M_PI/180.0;
+}
+
+double rad2deg(double rad)
+{
+ return rad*180.0/M_PI;
+}
+
+/* Convert spherical coordinates to cartesian coordinates.
+ *
+ * See https://en.wikipedia.org/wiki/Spherical_coordinate_system. */
+void sphere2cartesian(double r, double theta, double phi, double *x, double *y, double *z)
+{
+ *x = r*sin(theta)*cos(phi);
+ *y = r*sin(theta)*sin(phi);
+ *z = r*cos(theta);
+}
+
+/* Convert cartesian coordinates to spherical coordinates.
+ *
+ * See https://en.wikipedia.org/wiki/Spherical_coordinate_system. */
+void cartesian2sphere(double x, double y, double z, double *r, double *theta, double *phi)
+{
+ *r = sqrt(x*x + y*y + z*z);
+ *theta = acos(z/(*r));
+ *phi = atan2(y,x);
+}
+
+int main(int argc, char **argv)
+{
+ /* Spherical angles for the SNO detector in the earth frame which has z
+ * along the north and south poles and the x axis passing through Greenwich.
+ * Should double check this. */
+ double sno_theta = deg2rad(latitude + 90.0);
+ double sno_phi = deg2rad(longitude);
+
+ return 0;
+}