aboutsummaryrefslogtreecommitdiff
path: root/src/optics.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/optics.c')
-rw-r--r--src/optics.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/optics.c b/src/optics.c
index 89bee66..7782678 100644
--- a/src/optics.c
+++ b/src/optics.c
@@ -29,11 +29,8 @@
char optics_err[256];
/* Index of refraction in water and heavy water averaged over the Cerenkov
- * spectrum and the PMT quantum efficiency.
- *
- * Set these to 0.0 so that it's obvious if someone forgets to call
- * optics_init() before using them. */
-double avg_index_h2o = 0.0, avg_index_d2o = 0.0;
+ * spectrum and the PMT quantum efficiency. */
+static double avg_index_h2o = 0.0, avg_index_d2o = 0.0;
/* Absorption coefficients for H2O, D2O, and acrylic as a function of
* wavelength from SNOMAN.
@@ -113,6 +110,26 @@ static double RIND_ACRYLIC_C3 = 0.32;
* From http://pdg.lbl.gov/2018/reviews/rpp2018-rev-phys-constants.pdf. */
static double HC = 1.239841973976e3;
+double get_avg_index_d2o(void)
+{
+ if (!initialized) {
+ fprintf(stderr, "average index in d2o hasn't been initialized!\n");
+ exit(1);
+ }
+
+ return avg_index_d2o;
+}
+
+double get_avg_index_h2o(void)
+{
+ if (!initialized) {
+ fprintf(stderr, "average index in h2o hasn't been initialized!\n");
+ exit(1);
+ }
+
+ return avg_index_h2o;
+}
+
double get_index(double p, double wavelength, double T)
{
/* Returns the index of refraction of pure water for a given density,