Data = np.reshape(Data, (PMT_num + 4, time_samples + 2)).T trig = np.argmin(Data[2:1002, 0]) H = np.zeros(200) for i, pmt in enumerate(pmts): wf = Data[2:1002, chns[i]] wf = wf - np.median(wf[:Init]) blw = np.sqrt(np.mean(wf[:Init]**2)) wf -= BL[i] for k in range(np.argmin(wf)): if np.all(wf[k:k + 20] < -blw): rec[j]['init_wf'][i] = k break #if pmts[i]<14: wf = np.roll(wf, int(np.round(delays[i] * 5))) waveform = WaveForm(blw) h, recon_wf = Recon_wf(waveform, wf, height_cuts[i], rise_time_cuts[i], spes[i], Init) H += h chi2 = np.sqrt(np.sum((wf[Init:] - recon_wf[Init:])**2)) if blw < 10 and rec[j]['init_wf'][i] > 20 and chi2 < 500: WFs[i] += wf recon_WFs[i] += recon_wf rec[j]['area'] = -np.sum(wf[Init:]) rec[j]['blw'][i] = blw rec[j]['id'] = id rec[j]['chi2'][i] = chi2 rec[j]['h'][:, i] = h if len(np.nonzero(H > 0)[0]) == 0: init = -1 else:
print(path, pmts) start_time = time.time() Data = np.fromfile(file, np.float32, (PMT_num + 4) * (time_samples + 2)) if len(Data) < (PMT_num + 4) * (time_samples + 2): break Data = np.reshape(Data, (PMT_num + 4, time_samples + 2)).T trig = find_trig(Data[2:1002, PMT_num + 2]) H = np.zeros(1000) for i, pmt in enumerate(pmts): wf = Data[2:1002, chns[np.nonzero(pmts == pmt)[0][0]]] wf = np.roll(wf, 100 - trig) wf = wf - np.median(wf[:Init]) blw = np.sqrt(np.mean(wf[:Init]**2)) wf += BL[i] waveform = WaveForm(blw) h, recon_wf = Recon_wf(waveform, wf, height_cuts[i], dh3_cuts[i], spk_cuts[i], spes[i], 3) rec[j]['chi2'][i] = np.sqrt(np.sum((wf - recon_wf)**2)) rec[j]['blw'][i] = blw rec[j]['id'] = id rec[j]['h'][:, i] = h if len(np.nonzero(wf[:np.argmin(wf)] > 0.1 * np.amin(wf))[0]) > 0: rec[j]['init10'][i] = np.amax( np.nonzero(wf[:np.argmin(wf)] > 0.1 * np.amin(wf))[0]) else: rec[j]['init10'][i] = -1 # x=np.arange(1000) # plt.figure() # plt.title(pmts[i]) # plt.plot(x, wf, 'k.') # plt.plot(x, recon_wf, 'r--')
break Data = np.reshape(Data, (PMT_num + 4, time_samples + 2)).T trig = np.argmin(Data[2:1002, 0]) H = np.zeros(1000) for i, pmt in enumerate(pmts): wf = Data[2:1002, chns[i]] wf = wf - np.median(wf[:left]) blw = np.sqrt(np.mean(wf[:left]**2)) wf -= BL[i] for k in range(np.argmin(wf)): if np.all(wf[k:k + 20] < -blw): rec[j]['init_wf'][i] = k break waveform = WaveForm(blw) h, recon_wf, Areas, DCAreas, Abins = Recon_wf( waveform, wf, height_cuts[i], dh3_cut[i], spes[i] * SPEcorrection[i], Init, left, right, th[i]) H += h chi2 = np.sqrt(np.sum((wf[Init:] - recon_wf[Init:])**2)) if blw < 10 and rec[j]['init_wf'][i] > 20 and chi2 < 500: WFs[i] += wf recon_WFs[i] += recon_wf rec[j]['Areas'][i] = Areas rec[j]['DCAreas'][i] = DCAreas rec[j]['blw'][i] = blw rec[j]['id'] = id rec[j]['chi2'][i] = chi2 rec[j]['h'][:, i] = h if len(np.nonzero(H > 0)[0]) == 0:
start_time = time.time() path = '/home/gerak/Desktop/DireXeno/190803/pulser/' file = open(path + 'out.DXD', 'rb') Data = np.fromfile(file, np.float32, (PMT_num + 4) * (time_samples + 2) * id) j = 0 Data = np.fromfile(file, np.float32, (PMT_num + 4) * (time_samples + 2)) Data = np.reshape(Data, (PMT_num + 4, time_samples + 2)).T trig = np.argmin(Data[2:1002, 0]) for i, pmt in enumerate(pmts): wf = Data[2:1002, chns[i]] wf = wf - np.median(wf[:left]) blw = np.sqrt(np.mean(wf[:left]**2)) wf -= BL[i] waveform = WaveForm(blw) h, recon_wf, Areas, DCAreas, Abins = Recon_wf(waveform, wf, height_cuts[i], dh3_cut[i], spes[i], Init, left, right, 0.5) t = np.arange(1000) fig, ax = plt.subplots(1) fig.suptitle('..', fontsize=25) np.ravel(ax)[0].plot(t, wf, 'ko', label='PMT{}'.format(pmts[i])) np.ravel(ax)[0].plot(t, spes[i], 'b.-', label='PMT{}'.format(pmts[i])) np.ravel(ax)[0].plot(t, recon_wf, 'r.-') np.ravel(ax)[0].plot(t, wf - recon_wf, 'g--') np.ravel(ax)[0].legend(fontsize=15) plt.show()