aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-09-04add a function to return the kahan sum of an arraytlatorre
For some reason the fit seems to have trouble with the kinetic energy. Basically, it seems to "converge" even though when you run the minimization again it finds a better minimum with a lower energy. I think this is likely due to the fact that for muons the kinetic energy only really affects the range of the muon and this is subject to error in the numerical integration. I also thought that maybe it could be due to roundoff error in the likelihood calculation, so I implemented the Kahan summation to try and reduce that. No idea if it's actually improving things, but I should benchmark it later to see.
2018-09-04update fit to guess energy, direction, and t0tlatorre
This commit updates the initial guess for the energy using a simple heuristic of ~6 hits/MeV. I also updated the initial phase where we do a bunch of "quick" minimizations to loop over a series of starting positions and automatically calculate the approximate direction and t0 for the event.
2018-08-31add muon critical energy for D2Otlatorre
2018-08-31start by doing a series of "quick" minimizationstlatorre
This commit updates the fit_event function to first do a series of "quick" minimizations to try and find a good set of starting parameters for the "real" fit. I also updated the bounds on theta and phi since having hard bounds on these angle coordinates could prevent the fitter from finding the minimum.
2018-08-31add epsrel argument to likelihood functiontlatorre
2018-08-31update the lower bound for the energy in the fittlatorre
2018-08-31update the criterion for the fit convergencetlatorre
2018-08-31update likelihood check to 1e-5 since that's what we pass to nlopttlatorre
2018-08-31fit in a do while loop until the fit converges to the same likelihood valuetlatorre
2018-08-31add option to save fit results to a text filetlatorre
2018-08-31update printf arguments to keep output alignedtlatorre
2018-08-31switch back to calling cquad just once to speed things uptlatorre
I found when simulating high energy muons that the expected charge for some PMTs which should be getting hit was zero. The reason for this is that the integrand was very sharply peaked at the Cerenkov angle which makes it difficult to integrate for numerical integration routines like cquad. To solve this I split up the integral at the point when the track was at the Cerenkov angle from the PMT to make sure that cquad didn't miss the peak. However, calling cquad twice takes a lot of time so it's not necessarily good to do this for all fits. Also, it's not obvious if it is necessary any more now that the angular distribution calculation was fixed. I think the real reason that cquad was missing those integrals was that for a high energy muon the range is going to be very large (approximately 40 meters for a 10 GeV muon). In this case, I should really only integrate up to the edge of the cavity or PSUP and hopefully cquad picks enough points in there to get a non zero value. I also added a check to only compute tmean when at least one PMT has a valid time. This prevents a divide by zero which causes the likelihood function to return nan.
2018-08-31use interp1d() to interpolate path to speed things uptlatorre
2018-08-31add interp1d function to do fast interpolation when the x values are evenly ↵tlatorre
spaced
2018-08-31compile with -O2 to speed things uptlatorre
2018-08-31rotate and translate the path in path_init to speed things uptlatorre
2018-08-31add theta0 argument to path_eval in test-path.ctlatorre
2018-08-31print out how long the likelihood function takestlatorre
2018-08-31update the TODO listtlatorre
2018-08-28add path to the likelihood fittlatorre
This commit updates the likelihood fit to use the KL path expansion. Currently, I'm just using one coefficient for the path in both x and y.
2018-08-27update tests since I switched to using the D2O muon tables from the PDGtlatorre
2018-08-27update code to use get_index_snoman* functions to calculate the index of ↵tlatorre
refraction
2018-08-27fix how multiple Coulomb scattering is treatedtlatorre
Previously I had been assuming that a particle undergoing many small angle Coulomb scatters had a track direction whose polar angle was a Gaussian. However, this was just due to a misunderstanding of the PDG section "Multiple scattering through small angles" in the "Passage of particles through matter" article. In fact, what is described by a Gaussian is the polar angle projected onto a plane. Therefore the distribution of the polar angle is actually: (1/(sqrt(2*pi)*theta0**2))*theta*exp(-theta**2/(2*theta0)) This commit updates the code in scattering.c to correctly calculate the probability that a photon is emitted at a particular angle. I also updated test-likelihood.c to simulate a track correctly.
2018-08-27add code to expand the track of a particle using a KL expansiontlatorre
To fit the path of muons and electrons I use the Karhunen-Loeve expansion of a random 2D walk in the polar angle in x and y. This allows you to decompose the path into a sum over sine functions whose coefficients become random variables. The nice thing about fitting the path in this way is that you can capture *most* of the variation in the path using a small number of variables by only summing over the first N terms in the expansion and it is easy to calculate the probability of the coefficients since they are all uncorrelated.
2018-08-14fix ev pointer bugtlatorre
2018-08-14update pmt hit array in event struct to be MAX_PMTS longtlatorre
2018-08-14add lower and upper bounds for the fit parameterstlatorre
2018-08-14add function to fit event and clear event after each fittlatorre
2018-08-14set stopping criteratlatorre
2018-08-14use the index of refraction from snoman when computing the angular PDF for ↵tlatorre
photons
2018-08-14update the printf format string for the fit parameterstlatorre
2018-08-14update fit to use nlopt for minimizationtlatorre
The GSL library only has the Nelder Mead Simplex algorithm for doing multidimensional minimization without gradient information. The nlopt library has lots of different minimization algorithms so it's easier to switch between them to see which one works best.
2018-08-14fix how the RMS scattering angle is calculatedtlatorre
The RMS scattering angle calculation comes from Equation 33.15 in the PDG article on the passage of particles through matter. It's not entirely obvious if this equation is correct for a long track. It seems like it should be integrated along the track to add up the contributions at different energies, but it's not obvious how to do that with the log term. In any case, the way I was previously calculating it (by using the momentum and velocity at each point along the track) was definitely wrong. I will try this out and perhaps try to integrate it later.
2018-08-14add refractive index for heavy and light water from snomantlatorre
2018-08-14update muon.c to use the new table for heavy watertlatorre
2018-08-14add a table for muon dE/dx and range for D2Otlatorre
There was no entry for heavy water at http://pdg.lbl.gov/2018/AtomicNuclearProperties/index.html, so I emailed Don Groom who maintains the website. Amazingly he agreed to rerun the code to add an entry for D2O. Apparently all of the old Fortran code was not set up to deal with isotopes, but he updated everything and reran the code for heavy water! The new results are at http://pdgprod.lbl.gov/~deg/AtomicNuclearProperties/ but they should make it to the main page soon.
2018-08-14move everything to src directorytlatorre
2018-08-14initial commit of likelihood fit for muonstlatorre
This commit contains code to fit for the energy, position, and direction of muons in the SNO detector. Currently, we read events from SNOMAN zebra files and fill an event struct containing the PMT hits and fit it with the Nelder Mead simplex algorithm from GSL. I've also added code to read in ZEBRA title bank files to read in the DQXX files for a specific run. Any problems with channels in the DQCH and DQCR banks are flagged in the event struct by masking in a bit in the flags variable and these PMT hits are not included in the likelihood calculation. The likelihood for an event is calculated by integrating along the particle track for each PMT and computing the expected number of PE. The charge likelihood is then calculated by looping over all possible number of PE and computing: P(q|n)*P(n|mu) where q is the calibrated QHS charge, n is the number of PE, and mu is the expected number of photoelectrons. The latter is calculated assuming the distribution of PE at a given PMT follows a Poisson distribution (which I think should be correct given the track, but is probably not perfect for tracks which scatter a lot). The time part of the likelihood is calculated by integrating over the track for each PMT and calculating the average time at which the PMT is hit. We then assume the PDF for the photons to arrive is approximately a delta function and compute the first order statistic for a given time to compute the probability that the first photon arrived at a given time. So far I've only tested this with single tracks but the method was designed to be easy to use when you are fitting for multiple particles.
2018-07-05analyze_genie_mc.py -> analyze-genie-mctlatorre
2018-07-05refractive_index.c -> optics.ctlatorre
2018-07-05add a function to compute the energy along a muon tracktlatorre
2018-07-05add a simple test for the various muon functionstlatorre
2018-07-05add some comments and divide by the densitytlatorre
2018-07-05add functions to compute the range and dE/dx for muons in watertlatorre
2018-07-05add a text file with values for dE/dx and ranges for muons in watertlatorre
2018-07-04only require a 1% agreement, because I don't know how Schiebener converted ↵tlatorre
temperature and pressure to density in his tables
2018-07-04add a function to compute the refractive index of water as a function of ↵tlatorre
wavelength
2018-07-04updatetlatorre
2018-07-04initial commit of a file to calculate the quantum efficiencytlatorre
2018-07-04add a file with the measured quantum efficiency of the sno PMTs from snomantlatorre