icecube / flarestack

Unbinned likelihood analysis code for astroparticle physics datasets
https://flarestack.readthedocs.io/en/latest/?badge=latest
MIT License
8 stars 7 forks source link

Fix NorthernTracks MC time simulation #253

Closed mlincett closed 1 year ago

mlincett commented 1 year ago

PR to introduce simulation of event times for MC background in NorthernTracks.

Adds signal_integral() to DetectorOnOffList which in turn is used by generate_times(). Pretty straightforward.

Need to double check the generated times to verify they are as expected.

mlincett commented 1 year ago

The sampling of event times is now implemented and the background test statistic is kind of meaningful. However it seems that the background events are spilling in the detector "off" periods.

I suspect this is an artifact from the CDF sampling and subsequent interpolation in the generic TimePDF: https://github.com/icecube/flarestack/blob/290f4b9ef62e4e1c5d2c88eb4fe219496da389e1/flarestack/core/time_pdf.py#L177-L188

The evaluation over 10k points is too coarse and when interpolated will yield a non-zero probability to times in the off periods.

mlincett commented 1 year ago

The method TimePDF.inverse_interpolate() has been renamed to inverse_cumulative(). This is reimplemented in DetectorOnOffList based on the native livetime_to_mjd() of the subclass.

I have tested the generated time and their distribution is consistent with the on-off PDF.

mlincett commented 1 year ago

Thanks! You say you did a test to show that the simulation of times works. Could you upload a plot of that for future reference?

Good idea indeed. Here is a set of randomly selected gaps in the livetime and the distribution of the simulated events on top.

MCtime-benchmark

I have also added a notebook to reproduce this.