diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-09-26 09:14:10 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-09-26 09:14:10 -0500 |
commit | 6f2ee27f80b8275e3ea7c4e284689fd16c868288 (patch) | |
tree | 00a47001f2121eb18e955f43df6018824de4a437 /src | |
parent | e5c270c8c442136c7fd44751e1ccac887f49bd06 (diff) | |
download | sddm-6f2ee27f80b8275e3ea7c4e284689fd16c868288.tar.gz sddm-6f2ee27f80b8275e3ea7c4e284689fd16c868288.tar.bz2 sddm-6f2ee27f80b8275e3ea7c4e284689fd16c868288.zip |
speed up fast likelihood calculation
This commit updates the fast likelihood calculation to use the identity
sin(a-b) = sin(a)*cos(b) - cos(a)*sin(b)
to speed up the fast likelihood calculation.
Diffstat (limited to 'src')
-rw-r--r-- | src/likelihood.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/likelihood.c b/src/likelihood.c index f78eee8..99258a9 100644 --- a/src/likelihood.c +++ b/src/likelihood.c @@ -146,7 +146,7 @@ double get_total_charge_approx(double T0, double *pos, double *dir, muon_energy * * `smax` is currently calculated as the point where the particle velocity * drops to 0.8 times the speed of light. */ - double pmt_dir[3], tmp[3], R, cos_theta, theta, x, z, s, a, b, beta, E, p, T, omega, cos_theta_cerenkov, theta_cerenkov, n_d2o, n_h2o, sin_theta, E0, p0, beta0, f, cos_theta_pmt, absorption_length_h2o, absorption_length_d2o, l_h2o, l_d2o, wavelength0; + double pmt_dir[3], tmp[3], R, cos_theta, x, z, s, a, b, beta, E, p, T, omega, cos_theta_cerenkov, sin_theta_cerenkov, n_d2o, n_h2o, sin_theta, E0, p0, beta0, f, cos_theta_pmt, absorption_length_h2o, absorption_length_d2o, l_h2o, l_d2o, wavelength0; /* Calculate beta at the start of the track. */ E0 = T0 + MUON_MASS; @@ -163,15 +163,14 @@ double get_total_charge_approx(double T0, double *pos, double *dir, muon_energy /* Calculate the cosine of the angle between the track direction and the * vector to the PMT at the start of the track. */ cos_theta = DOT(dir,pmt_dir); - /* Compute the angle between the track direction and the PMT. */ - theta = acos(cos_theta); + sin_theta = sqrt(1-pow(cos_theta,2)); /* Compute the Cerenkov angle at the start of the track. */ wavelength0 = 400.0; n_d2o = get_index_snoman_d2o(wavelength0); n_h2o = get_index_snoman_h2o(wavelength0); cos_theta_cerenkov = 1/(n_d2o*beta0); - theta_cerenkov = acos(cos_theta_cerenkov); + sin_theta_cerenkov = sqrt(1-pow(cos_theta_cerenkov,2)); /* Now, we compute the distance along the track where the PMT is at the * Cerenkov angle. @@ -179,7 +178,7 @@ double get_total_charge_approx(double T0, double *pos, double *dir, muon_energy * Note: This formula comes from using the "Law of sines" where the three * vertices of the triangle are the starting position of the track, the * point along the track that we want to find, and the PMT position. */ - s = R*sin(theta_cerenkov-theta)/sqrt(1-pow(cos_theta_cerenkov,2)); + s = R*(sin_theta_cerenkov*cos_theta - cos_theta_cerenkov*sin_theta)/sin_theta_cerenkov; /* Make sure that the point is somewhere along the track between 0 and * `smax`. */ |