There is still the problem that accidentals sometimes throw off the reconstruction.
The three high showers are:
Shower 10It occurred to me that there may be a problem with the P_TDF formula. Looking more closely it seems the background noise was included in the raw TDF, but not in the "IntegrateTDF" function. This is evident from the plot I made a few days ago, though I didn't realize it at the time:
This is a log plot of the integral of the TDF. If the background noise were included it would go to a flat line at the expected rate of accidentals, 2e-4 per 100 ms interval. Instead it goes down to 10^-9 and lower.
I changed the code so that the background noise is not included in either the raw TDF or the integrated TDF (because sometimes one may want only the TDF). While testing this, I noticed that P_TDF sometimes returns a negative value (before taking the log, which you expect to return a negative number). I thought this could be because integrating from t-delta to t+delta will sometimes start before t=0, for which the TDF is not defined.
I inserted a catch in the code so that P_TDF would always be greater than or equal to the probability of background accidentals, and this allowed me to reconstruct a shower that otherwise failed. However, it doesn't explain why this is ever returning a negative number in the first place. I looked at where this was happening, and it seemed to happen most often when evaluating the TDF at very large radii. Below are plots of the TDF at a given angle, for different radii:
Clearly TDF 5 behaves badly at large radii. However, it does not go negative.
Looking at the angle at which this behaviour is happening when doing reconstructions, it is at cos(theta) = .46, which is close to the limiting angle of cos(63.435) = 0.44721. Making plots at different angles...
TDF 4 has areas where it is negative for angles steeper than 0.55.
TDF 5 has areas where it is negative for angles steeper than about 0.49. It also has a spiked shape at large r.
Suggestions:
- decrease the range of allowed angles
- for hits at large r, use only the background rate