Esempio n. 1
0
def make_l(l, H, spectra, cov, left, right, Xcov, x1, x2, gamma, Q, N):
    Sspectra = Sim_fit(x1, x2, left, right, gamma, Q, 13.7,
                       np.arange(np.shape(spectra)[0]))
    if np.any(Sspectra < 0):
        l.value = -1e10 * (1 - np.amin(Sspectra))
    else:
        # model=np.sum(H[:,0,0])*np.ravel(S)
        # data=np.ravel(H[:,:100,:])
        # model=np.sum(H[:,0,0])*np.ravel(np.sum(S, axis=-1))
        # data=np.ravel(np.sum(H[:,:100,:], axis=-1))
        # l.value+=np.sum(data*np.log((model+1e-10)/(data+1e-10))+data-model)

        spectra = rebin_spectra(spectra)[1]
        Sspectra = rebin_spectra(Sspectra)[1]
        data = np.ravel(spectra)
        model = N * np.ravel(Sspectra)
        l.value += np.sum(data * np.log((model + 1e-10) / (data + 1e-10)) +
                          data - model)
Esempio n. 2
0
def make_l(l, H, spectra, cov, left, right, Xcov, x1, x2, gamma, Q, T, St, mu,
           W, g, F, Tf, Ts, R, a):
    S, Sspectra, Scov = Sim_fit(x1, x2, left, right, gamma, Q, T, St, mu, W,
                                g, F, Tf, Ts, R, a,
                                np.arange(np.shape(spectra)[0]))
    if np.any(S < 0):
        print('S<0', S[S < 0])
        print(Q, T, St, mu, W, F, Tf, Ts, R, a)
        l.value = -1e10 * (1 - np.amin(S))
    else:
        # model=np.sum(H[:,0,0])*np.ravel(S)
        # data=np.ravel(H[:,:100,:])
        # l.value+=np.sum(data*np.log((model+1e-10)/(data+1e-10))+data-model)

        spectra = rebin_spectra(spectra)[1]
        Sspectra = rebin_spectra(Sspectra)[1]
        data = np.ravel(spectra)
        model = np.sum(H[:, 0, 0]) * np.ravel(Sspectra)
        l.value += np.sum(data * np.log((model + 1e-10) / (data + 1e-10)) +
                          data - model)
Esempio n. 3
0
        np.arange(500) / 5 + 0.5,
        N * np.sum(S[:, :500, i].T * np.arange(np.shape(S)[0]), axis=1) / 0.2,
        'r.',
        label='sim',
        linewidth=3)
    #np.ravel(ax)[i].errorbar(t[:100]+0.5, N*np.sum(S[:,:100,i].T*np.arange(np.shape(S)[0]), axis=1)/dt, N*np.sqrt(np.sum(S[:,:100,i].T*np.arange(np.shape(S)[0]), axis=1)/(dt*SN)), fmt='r.')
    np.ravel(ax)[i].set_xlabel('Time [ns]', fontsize='15')
    np.ravel(ax)[i].legend()
fig.text(0.04,
         0.5,
         r'$N_{events}\sum_n nH_{ni}$',
         va='center',
         rotation='vertical',
         fontsize=15)

PEs, spectra = rebin_spectra(spectra)
PEs, Sspectra = rebin_spectra(Sspectra)
fig, ax = plt.subplots(2, 3)
for i in range(len(pmts)):
    np.ravel(ax)[i].step(PEs,
                         spectra[:, i],
                         linewidth=3,
                         where='mid',
                         label='spectrum A - PMT{}'.format(pmts[i]))
    # np.ravel(ax)[i].plot(PEs, N*Mspectra[:,i], 'r.', label='model')
    np.ravel(ax)[i].plot(PEs, N * Sspectra[:, i], 'g.', label='sim')
    np.ravel(ax)[i].errorbar(PEs,
                             N * Sspectra[:, i],
                             N * np.sqrt(Sspectra[:, i] / SN),
                             fmt='g.')
    np.ravel(ax)[i].legend()
Esempio n. 4
0
delays = []
for i in range(len(pmts) - 1):
    for j in range(i + 1, len(pmts)):
        data = np.load(path + 'delay_hist{}-{}.npz'.format(pmts[i], pmts[j]))
        delays.append(data['x'] - data['m'])
        delay_hs.append(data['h'])
        names.append('{}_{}'.format(pmts[i], pmts[j]))

source = 'Co57'
type = ''
path = '/home/gerak/Desktop/DireXeno/190803/' + source + type + '/EventRecon/'
data = np.load(path + 'H.npz')
H = data['H'][:50, :, :]
G = data['G']
spectrum = data['spectrum']
bins, spectra = rebin_spectra(data['spectra'])
left = data['left']
right = data['right']
cov = data['cov']
Xcov = data['Xcov']
N = data['N']

t = np.arange(200)
dt = 1
PEs = np.arange(np.shape(spectra)[0])
if type == 'B':
    x1 = 1
    x2 = 0
elif type == '':
    x1 = 0
    x2 = 1