forked from Pocar-Lab/SPE-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLXe_July_2022_Analysis.py
212 lines (185 loc) · 8.93 KB
/
LXe_July_2022_Analysis.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 9 14:28:38 2023
@author: hpeltzsmalle
@author: Ed van Bruggen (evanbruggen@umass.edu)
"""
import sys
import numpy as np
from MeasurementInfo import MeasurementInfo
from RunInfo import RunInfo
import heapq
from scipy import signal
from scipy.optimize import curve_fit
import AnalyzePDE
from AnalyzePDE import SPE_data
from AnalyzePDE import Alpha_data
import matplotlib.pyplot as plt
import matplotlib as mpl
import ProcessWaveforms_MultiGaussian
from ProcessWaveforms_MultiGaussian import WaveformProcessor as WaveformProcessor
#%% SPE-VBD
#100ns, new shaper, 10x gain, filtered (change as needed; make sure it is the correct factor for the data set)
invC_spe_filter = 0.011959447603692185
invC_spe_err_filter = 3.881945391072933E-05
file_path = 'self/' # folder with H5 data files
run_spe_solicited = RunInfo([file_path+'Run_1658337800.hdf5'], do_filter = True, is_solicit = True, upper_limit = 1, baseline_correct = True)
# loop quickly loads in files
# separate files for each bias voltage -> specifyAcquisition = False
files = ['Run_1658339042.hdf5', 'Run_1658339468.hdf5', 'Run_1658339739.hdf5', 'Run_1658339990.hdf5', 'Run_1658340318.hdf5']
proms = [0.003,0.003,0.003,0.003,0.003,0.003,0.003,0.003,0.003]
upperlim = [0.1, 0.1, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18]
runs = []
for file in range(len(files)):
run_spe = RunInfo([file_path+files[file]], specifyAcquisition = False, do_filter = True, upper_limit = upperlim[file], baseline_correct = True, prominence = proms[file])
runs.append(run_spe)
biases = [run.bias for run in runs]
#%%
range_lows = [0.00225, 0.0032, 0.0031, 0.0037, 0.0037, 0.00475, 0.005, 0.0053, 0.006]
range_highs = [0.0205, 0.025, 0.025, 0.027, 0.03, 0.03, 0.033, 0.036, 0.04]
centers = [0.0046, 0.0049, 0.0059, 0.0065, 0.0069, 0.0072, 0.0075, 0.008, 0.008]
#%% testing cell - plot with peak fit
# set conditions, temp
n= 0
T = 170
info_spe = MeasurementInfo()
info_spe.condition = 'LXe'
info_spe.date = runs[n].date
# info_spe.date = 'NA'
info_spe.temperature = T
info_spe.bias = biases[n]
info_spe.baseline_numbins = 50
info_spe.peaks_numbins = 150
info_spe.data_type = 'h5'
wp = WaveformProcessor(info_spe, run_info_self = runs[n], baseline_correct = True, range_low = range_lows[n], range_high = range_highs[n], center = centers[n], no_solicit = True)
wp.process(do_spe = True, do_alpha = False)
wp.plot_peak_histograms()
wp.plot_spe()
#%% make a list of ProcessWaveforms objects
campaign_spe = []
for i in range(len(runs)):
info_spe = MeasurementInfo()
info_spe.condition = 'LXe'
info_spe.date = runs[i].date
info_spe.temperature = 170
info_spe.bias = runs[i].bias
info_spe.baseline_numbins = 50
info_spe.peaks_numbins = 150
info_spe.data_type = 'h5'
wp_spe = WaveformProcessor(info_spe, run_info_self = runs[i], run_info_solicit = run_spe_solicited, baseline_correct = True, range_low = range_lows[i], range_high = range_highs[i], center = centers[i], no_solicit = True)
wp_spe.process(do_spe = True, do_alpha = False)
campaign_spe.append(wp_spe)
#%% plot linear fit to the breakdown voltage
curr_campaign = campaign_spe
filtered_spe = SPE_data(curr_campaign, invC_spe_filter, invC_spe_err_filter, filtered = True)
filtered_spe.plot_spe(in_ov = False, absolute = False, out_file = None)
print(filtered_spe.v_bd)
print(filtered_spe.v_bd_err)
#%% plot in units of absolute gain vs OV
filtered_spe.plot_spe(in_ov = True, absolute = True, out_file = None)
#%% record BD voltage
v_bd = 27.69
v_bd_err = 0.06
#%%
#%% CORRELATED AVALANCHE SPE
file_path = 'self/' # folder with H5 data files
run_spe_solicited = RunInfo([file_path+'Run_1648191265.hdf5'], do_filter = True, is_solicit = True, upper_limit = 1, baseline_correct = True)
files = ['Run_1648176286','Run_1648179496', 'Run_1648181807', 'Run_1648184235', 'Run_1648186910'] #, 'Run_1648186910', 'Run_1648171846'
proms = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05]
upperlim = [5, 5, 5, 5, 5, 5]
runs = []
for file in range(len(files)):
run_spe = RunInfo([file_path + files[file] + '.hdf5'], do_filter = True, upper_limit = upperlim[file], baseline_correct = True, prominence = proms[file])
runs.append(run_spe)
biases = [run.bias for run in runs] # get all the bias voltages from RunInfo (enter manually if metadata is wrong)
#%%
a_guess = 0.01689
b_guess = -0.4739
range_lows = [0.05, 0.059, 0.071, 0.09, 0.09, 0.04]
centers = [biases[i]*a_guess+b_guess for i in range(len(runs))]
range_highs = [centers[i]*4 + range_lows[i] for i in range(len(runs))]
#%%
campaign_spe = []
for i in range(len(runs)):
info_spe = MeasurementInfo()
info_spe.condition = 'Vacuum'
info_spe.date = 'March 2022'
info_spe.temperature = 190
info_spe.bias = runs[i].bias
info_spe.baseline_numbins = 50
info_spe.peaks_numbins = 200
info_spe.data_type = 'h5'
wp_spe = WaveformProcessor(info_spe, run_info_self = runs[i], run_info_solicit = run_spe_solicited, baseline_correct = True, range_low = range_lows[i], range_high = range_highs[i], center = centers[i])
wp_spe.process(do_spe = True, do_alpha = False)
campaign_spe.append(wp_spe)
#%%
invC_spe_filter = 0.19261918346201742
invC_spe_err_filter = 0.0021831140214106596
spe = SPE_data(campaign_spe, invC_spe_filter, invC_spe_err_filter, filtered = True)
#%%
#%% ALPHA - 100ns
#100ns, new shaper, no gain, no filter
invC_alpha_100ns = 0.004074442176917963
invC_alpha_err_100ns = 1.4320358414009397E-05
file_path = 'self/' # folder with H5 data files
files = ['Acquisition_1684439574', 'Acquisition_1684439834','Acquisition_1684440058', 'Acquisition_1684440328','Acquisition_1684440542', 'Acquisition_1684440766', 'Acquisition_1684441008','Acquisition_1684441249','Acquisition_1684441553', 'Acquisition_1684441781', 'Acquisition_1684442031', 'Acquisition_1684442292', 'Acquisition_1684442515', 'Acquisition_1684442713', 'Acquisition_1684442986', 'Acquisition_1684443190', 'Acquisition_1684443416']
proms = [0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01]
upperlim = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]
runs_alpha_100ns = []
for file in range(len(files)):
run_alpha_100ns = RunInfo([file_path+'Run_1684439289.hdf5'], specifyAcquisition = True, acquisition = files[file], do_filter = False, upper_limit = upperlim[file], baseline_correct = True, prominence = proms[file], is_solicit = False)
runs_alpha_100ns.append(run_alpha_100ns)
biases = [run.bias for run in runs_alpha_100ns] # get all the bias voltages from RunInfo (enter manually if metadata is wrong)
#%% ALPHA - 1us
#1us, no gain, no filter
invC_alpha_1us = 0.004074442176917963 # *************PLACEHOLDER
invC_alpha_err_1us = 1.4320358414009397E-05 # ********PLACEHOLDER
file_path = 'self/' # folder with H5 data files
files = [ 'Run_1658339042.hdf5', 'Run_1658339468.hdf5', 'Run_1658339739.hdf5', 'Run_1658339990.hdf5', 'Run_1658340318.hdf5' ]
proms = [ .15 for i in range(len(files)) ]
upperlim = [ 20 for i in range(len(files)) ]
runs_alpha_1us = []
for file in range(len(files)):
run_alpha_1us = RunInfo([file_path+files[file]], do_filter = False, upper_limit = upperlim[file], baseline_correct = True, prominence = proms[file], is_solicit = False, plot_waveforms=False)
runs_alpha_1us.append(run_alpha_1us)
biases = [run.bias for run in runs_alpha_1us] # get all the bias voltages from RunInfo (enter manually if metadata is wrong)
runs_alpha_1us[0].plot_hists('169.9', '.1')
# runs_alpha_1us[0].plot_peak_waveform_hist()
#%%
campaign_alpha = []
runs_alpha = runs_alpha_1us #change as needed
bins = [40,40,50,50,50,50,50,50,60,60,60,70,70,70,70,70,70,70,70]
for i in range(len(runs_alpha)):
info_alpha = MeasurementInfo()
info_alpha.min_alpha_value = 0.029
if i > 8: # set lower cutoff to be higher for higher ov
info_alpha.min_alpha_value = 0.3
info_alpha.condition = 'LXe'
info_alpha.date = runs_alpha[i].date
info_alpha.temperature = 170
info_alpha.bias = runs_alpha[i].bias
info_alpha.baseline_numbins = 40
info_alpha.peaks_numbins = bins[i]
info_alpha.data_type = 'h5'
print(f"{i=}")
wp = WaveformProcessor(info_alpha, run_info_self = runs_alpha[i], baseline_correct = True, no_solicit = True, range_high = 10)
wp.process(do_spe = False, do_alpha = True)
j, k = wp.get_alpha()
campaign_alpha.append(wp)
print(f"{info_alpha.bias=}")
#%%
runs_alpha[0].plot_hists('','')
for i in range(len(runs_alpha)):
campaign_alpha[i].plot_alpha_histogram(peakcolor = 'blue')
#%%
invC_alpha = invC_alpha_1us
invC_alpha_err = invC_alpha_err_1us
alpha_data = Alpha_data(campaign_alpha, invC_alpha, invC_alpha_err, spe, v_bd, v_bd_err)
alpha_data.analyze_alpha()
#%%
alpha_data.plot_alpha(color = 'purple')
alpha_data.plot_num_det_photons()
#%% values based on Wesley's APS slides
N = 5.49/(19.6E-6)
PTE = 0.0042
alpha_data.plot_PDE(N*PTE)