aboutsummaryrefslogtreecommitdiff
path: root/src/fit.c
AgeCommit message (Collapse)Author
2018-11-30sizeof()/sizeof() -> LEN()tlatorre
2018-11-30nll_muon -> nll and nll -> nopt_nlltlatorre
2018-11-30add ability to fit for multiple verticestlatorre
2018-11-28update sno_charge.ctlatorre
This commit adds lots of comments to sno_charge.c and makes a couple of other changes: - use interp1d() instead of the GSL interpolation routines - increase MAX_PE to 100 I increased MAX_PE because I determined that it had a rather large impact on the likelihood function for 500 MeV electrons. This unfortunately slows down the initialization by a lot. I think I could speed this up by convolving the single PE charge distribution with a gaussian *before* convolving the charge distributions to compute the charge distributions for multiple PE.
2018-11-27add rayleigh scatteringtlatorre
This commit adds Rayleigh scattering to the likelihood function. The Rayleigh scattering lengths come from rsp_rayleigh.dat from SNOMAN which only includes photons which scattered +/- 10 ns around the prompt peak. The fraction of light which scatters is treated the same in the likelihood as reflected light, i.e. it is uniform across all the PMTs in the detector and the time PDF is assumed to be a constant for a fixed amount of time after the prompt peak.
2018-11-27update dx_shower to 10 cm to speed things uptlatorre
2018-11-25add a separate `dx_shower` parameter for the spacing of the shower track ↵tlatorre
integral
2018-11-17speed up likelihood function and switch to using fixed dxtlatorre
This commit speeds up the likelihood function by about ~20% by using the precomputed track positions, directions, times, etc. instead of interpolating them on the fly. It also switches to computing the number of points to integrate along the track by dividing the track length by a specified distance, currently set to 1 cm. This should hopefully speed things up for lower energies and result in more stable fits at high energies.
2018-11-14update yaml format to store fit results as a dictionary indexed by the ↵tlatorre
particle id
2018-11-11update likelihood function to fit electrons!tlatorre
To characterize the angular distribution of photons from an electromagnetic shower I came up with the following functional form: f(cos_theta) ~ exp(-abs(cos_theta-mu)^alpha/beta) and fit this to data simulated using RAT-PAC at several different energies. I then fit the alpha and beta coefficients as a function of energy to the functional form: alpha = c0 + c1/log(c2*T0 + c3) beta = c0 + c1/log(c2*T0 + c3). where T0 is the initial energy of the electron in MeV and c0, c1, c2, and c3 are parameters which I fit. The longitudinal distribution of the photons generated from an electromagnetic shower is described by a gamma distribution: f(x) = x**(a-1)*exp(-x/b)/(Gamma(a)*b**a). This parameterization comes from the PDG "Passage of particles through matter" section 32.5. I also fit the data from my RAT-PAC simulation, but currently I am not using it, and instead using a simpler form to calculate the coefficients from the PDG (although I estimated the b parameter from the RAT-PAC data). I also sped up the calculation of the solid angle by making a lookup table since it was taking a significant fraction of the time to compute the likelihood function.
2018-10-21set default number of points to 500tlatorre
2018-10-19epsrel -> npointstlatorre
2018-10-18update fit to fit for electrons and protonstlatorre
2018-10-12skip PMTs which weren't hit for the fast likelihood calculationtlatorre
2018-10-06prune output of mcvx and mctk bankstlatorre
2018-10-05epsrel = 1e-2 to speed up fittlatorre
2018-10-02update optics to use LETA constants for the D2O phasetlatorre
This commit updates the PMT response bank and absorption lengths for H2O and D2O based on the values in mcprod which were used for the LETA analysis.
2018-10-01flag PMTs with the KPF_DIS bit settlatorre
Doh! I was previously using the tube number variable!
2018-09-25increase maxeval to 20 for the "quick" minimization phasetlatorre
When testing out the fitter on 500 MeV muons, there was at least one event which started out at a position very far from the true position. This event had a secondary electron like ring which is what I suspect caused the fit to start out in a position far from the true position. This fix correctly starts the minimization close to the true position. In the future I should look at updating get_direction() so that it finds the largest ring direction instead of just doing a weighted average of all the vectors from the position to the PMTs.
2018-09-20add particle id code to output filetlatorre
2018-09-20add git SHA1 hash to output filetlatorre
2018-09-20add time elapsed to the output filetlatorre
2018-09-20add a command line option to only fit the first eventtlatorre
This commit adds the ability to run the fit program with the --skip-second-event flag to only fit the first event after a MAST bank. This way we avoid fitting secondaries like Michel electrons when fitting MC events.
2018-09-20add absorption lengths for D2O and H2O weighted by the Cerenkov spectrum and ↵tlatorre
the quantum efficiency
2018-09-19change output file format to YAMLtlatorre
2018-09-18stop fitting when the likelihood difference is less than 1e-2tlatorre
2018-09-18add free_charge() to free memory used to interpolate the charge distributionstlatorre
2018-09-18add a ctrl-c handlertlatorre
2018-09-13fix width formatting for t0tlatorre
2018-09-12small updates to speed things uptlatorre
2018-09-12update the starting parameterstlatorre
2018-09-11only print the likelihood value once for each iteration during the "quick" ↵tlatorre
minimization phase
2018-09-11fix the energy and position when doing the "quick" minimizationstlatorre
2018-09-11switch order of expressions to avoid a valgrind warningtlatorre
2018-09-11add PMT responsetlatorre
This commit adds code to read in the PMT response from the PMTR bank from SNOMAN. This file was used for the grey disk model in SNOMAN and was created using a full 3D simulation of the PMT and concentrator. Since the PMT response in SNOMAN included the quantum efficiency of the PMT, we have to divide that out to get just the PMT response independent of the quantum efficiency. I also updated the likelihood calculation to use the pmt response. Currently the energy is being fit too high which I think will improve when we update the solid angle calculation to use the radius of the concentrator instead of the PMT.
2018-09-10add a fast likelihood functiontlatorre
This commit adds a fast function to calculate the expected number of PE at a PMT without numerically integrating over the track. This calculation is *much* faster than integrating over the track (~30 ms compared to several seconds) and so we use it during the "quick" minimization phase of the fit to quickly find the best position.
2018-09-04update kinetic energy step size to 2% of initial kinetic energy guesstlatorre
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-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-31print out how long the likelihood function takestlatorre
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-14fix ev pointer bugtlatorre
2018-08-14update pmt hit array in event struct to be MAX_PMTS longtlatorre