#ifndef LIKELIHOOD_H #define LIKELIHOOD_H #include "event.h" #include /* for size_t */ #define PSUP_REFLECTION_TIME 80.0 /* Minimum number of points in the track integral. */ #define MIN_NPOINTS 100 /* To avoid having to allocate new arrays every time we evaluate the likelihood * function, we just allocate static arrays with `MAX_POINTS` elements. */ #define MAX_NPOINTS 1000 /* Maximum number of PE to consider if the PMT was hit. */ #define MAX_PE 10000 /* Maximum number of PE to consider if the PMT wasn't hit. * * Note: This must be less than MAX_PE. */ #define MAX_PE_NO_HIT 10 /* To speed things up we quit calculating the probability of a hit when the * ratio between the current probability and the maximum probability is less * than 10**(-MIN_RATIO). So if MIN_RATIO is -10, that means that we ignore * probabilities which are 10 million times less likely than the most probable * value for n. */ #define MIN_RATIO -10 /* Same as above but for the "fast" likelihood calculation. */ #define MIN_RATIO_FAST -2 /* The fraction of reflected light which is detected. */ #define CHARGE_FRACTION_ELECTRON 0.4 #define CHARGE_FRACTION_MUON 0.5 /* Dark rate of the PMTs (Hz). * * From pmt_response.dat in SNOMAN. */ #define DARK_RATE 1000.0 /* Single PE transit time spread (ns). * * From pmt_response.dat in SNOMAN. */ #define PMT_TTS 1.61 /* Event window (ns) */ #define GTVALID 400.0 #define BETA_MIN 0.8 /* Number of photons in the range 200 nm - 800 nm generated per MeV of energy * lost to radiation for electrons. * * FIXME: This is just a rough estimate, should use an energy dependent * quantity from simulation. */ #define PHOTONS_PER_MEV 400.0 /* Maximum number of vertices to fit. */ #define MAX_VERTICES 2 typedef struct vertex { int id; double T0; double pos[3]; double dir[3]; double t0; double z1[10]; double z2[10]; size_t n; } vertex; typedef struct particle { int id; double mass; double range; double rad; double *x; double *T; size_t n; double a; double b; } particle; particle *particle_init(int id, double T0, size_t n); double particle_get_energy(double x, particle *p); void particle_free(particle *p); double time_pdf(double t, double mu_noise, double mu_indirect, double *mu_direct, double *mu_shower, size_t n, double *ts, double *ts_shower, double tmean, double sigma, double *ts_sigma); double time_cdf(double t, double mu_noise, double mu_indirect, double *mu_direct, double *mu_shower, size_t n, double *ts, double *ts_shower, double tmean, double sigma, double *ts_sigma); double nll_best(event *ev); double nll(event *ev, vertex *v, size_t n, double dx, double dx_shower, int fast, int charge_only); #endif