-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze.jl
46 lines (32 loc) · 1016 Bytes
/
analyze.jl
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
using LegendHDF5IO, HDF5
using ArraysOfArrays
using Statistics, StatsBase
using DSP, RadiationDetectorDSP
using RadiationSpectra
using Plots
events = HDF5.h5open("adcdata.lh5") do f
LegendHDF5IO.readdata(f, "raw")
end
wfs = ArrayOfSimilarArrays(deepmap(Float32, events.samples))
plot(wfs[1:10])
wf = wfs[1]
wf_blcorr = wf .- mean(wf[1:1500])
deconv_filter = RadiationDetectorDSP.inv_cr_filter(13000)
deconv_wf = filt(deconv_filter, wf_blcorr)
plot(wf_blcorr)
plot!(deconv_wf)
eflt_wf = charge_trapflt!(copy(deconv_wf), 1000, 500)
plot(eflt_wf)
maximum(eflt_wf)
function energy_reco(wf)
wf_blcorr = wf .- mean(wf[1:1500])
deconv_filter = RadiationDetectorDSP.inv_cr_filter(13000)
deconv_wf = filt(deconv_filter, wf_blcorr)
eflt_wf = charge_trapflt!(copy(deconv_wf), 1000, 500)
maximum(eflt_wf)
end
E_rec = energy_reco.(wfs)
h_uncal = fit(Histogram, E_rec, 0:1:2000)
plot(h_uncal, lt = :stepbins, yscale = :log10)
_, peakpos = RadiationSpectra.peakfinder(h_uncal)
vline!(peakpos)