diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-03-25 14:37:54 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-03-25 14:37:54 -0500 |
commit | fb7b16c521e08d20ac1d10729c333b7496b68210 (patch) | |
tree | 2d6dbbd1fb06989966a2570b341ad38952adba04 /src/optics.c | |
parent | 555429b348c834d795221ce4c1cc90dd856bcaf8 (diff) | |
download | sddm-fb7b16c521e08d20ac1d10729c333b7496b68210.tar.gz sddm-fb7b16c521e08d20ac1d10729c333b7496b68210.tar.bz2 sddm-fb7b16c521e08d20ac1d10729c333b7496b68210.zip |
speed up likelihood function by not calling trapz()
This commit speeds up the likelihood function by integrating the charge along
the track inline instead of creating an array and then calling trapz(). It also
introduces two global variables avg_index_d2o and avg_index_h2o which are the
average indices of refraction for D2O and H2O weighted by the PMT quantum
efficiency and the Cerenkov spectrum.
Diffstat (limited to 'src/optics.c')
-rw-r--r-- | src/optics.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/optics.c b/src/optics.c index 830ada9..6b6d761 100644 --- a/src/optics.c +++ b/src/optics.c @@ -29,6 +29,8 @@ char optics_err[256]; +double avg_index_h2o, avg_index_d2o; + /* Absorption coefficients for H2O, D2O, and acrylic as a function of * wavelength from SNOMAN. * @@ -425,6 +427,28 @@ static double gsl_absorption_length_snoman_acrylic(double wavelength, void *para return qe*exp(-x/get_absorption_length_snoman_acrylic(wavelength))/pow(wavelength,2); } +/* Returns the product of the index of refraction in D2O multiplied by the + * quantum efficiency and the Cerenkov spectrum. */ +static double gsl_index_d2o(double wavelength, void *params) +{ + double qe; + + qe = get_quantum_efficiency(wavelength); + + return qe*get_index_snoman_d2o(wavelength)/pow(wavelength,2); +} + +/* Returns the product of the index of refraction in H2O multiplied by the + * quantum efficiency and the Cerenkov spectrum. */ +static double gsl_index_h2o(double wavelength, void *params) +{ + double qe; + + qe = get_quantum_efficiency(wavelength); + + return qe*get_index_snoman_h2o(wavelength)/pow(wavelength,2); +} + static double gsl_cerenkov(double wavelength, void *params) { /* Returns the quantum efficiency multiplied by the Cerenkov spectrum. */ @@ -458,6 +482,30 @@ int optics_init(dict *db) return -1; } + F.function = &gsl_index_d2o; + F.params = NULL; + + status = gsl_integration_cquad(&F, 200, 800, 0, 1e-2, w, &result, &error, &nevals); + + if (status) { + sprintf(optics_err, "error integrating cerenkov distribution: %s\n", gsl_strerror(status)); + return -1; + } + + avg_index_d2o = result/norm; + + F.function = &gsl_index_h2o; + F.params = NULL; + + status = gsl_integration_cquad(&F, 200, 800, 0, 1e-2, w, &result, &error, &nevals); + + if (status) { + sprintf(optics_err, "error integrating cerenkov distribution: %s\n", gsl_strerror(status)); + return -1; + } + + avg_index_h2o = result/norm; + for (i = 0; i < LEN(fabs_x); i++) { fabs_x[i] = xlo + (xhi-xlo)*i/(LEN(fabs_x)-1); } |