-
Notifications
You must be signed in to change notification settings - Fork 1
/
spectrum.h
45 lines (36 loc) · 1.71 KB
/
spectrum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
/*define size of the grid*/
#define RESE 200
#define REST 900
#define EMAX 60.0
#define TMAX 10.0
#define STEPE EMAX/RESE
#define STEPT TMAX/REST
#ifdef USE_SP
typedef float user_data_t;
#else
typedef double user_data_t;
#endif
/* normalized LL energy spectrum - 15.4: average energy, 3.8: betha, 4802: normalization factor*/
#define LL_energy_spectrum(E) pow(E, 3.8)*exp(-(1.0+3.8)*E/15.4)/4802.516160
/* normalized LL arrival time spectrum - approximated by log-normal-dist */
#define MY -1.0324
#define SIGMA 0.9134
#define LL_time_spectrum(t) exp( - (log(t)-MY)*(log(t)-MY)/(2*SIGMA*SIGMA) ) / (t*SIGMA*sqrt(2*M_PI))
/*gaussian (around 0): error for the energy smearing from photon counts:
N is proportional to E -> N = 1/alpha*E -> N=alpha*E -> factor of alpha for sigma2 (sigma2=E)
*/
#define ALPHA 2.22
#define GAUSS(i, sigma2) 1/sqrt(2.0*M_PI*sigma2*ALPHA)*exp(-(i*i)/(2.0*sigma2*ALPHA))
#ifndef SPECTRUM_H_
#define SPECTRUM_H_
void createSpectrum(double *spectrum, double mass, double distance, double events, bool useEnergyRes, bool useTriggerEff, double noise, double noise_events);
void getEvent(int *eventEnergy, int *eventTime, double mass, double distance, double events, int filenumber, double noise);
double getLLH(double mass, double distance, double events, bool triggEff, bool energyRes, double noise, int *eventTime, int *eventEnergy, double noise_events);
void createEventsArray(double events, double *spectrum, double max, int *timeArray, int *energyArray, int filenumber);
void getSeed(double distance, double mass, double events, double noise);
double findSpectrumMax(double *spectrum);
#endif