Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Sort for peakpos based on ADC energy value #134

Draft
wants to merge 1 commit into
base: co60
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/simple_calibration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,23 @@ function peak_search_gamma(e_uncal::Vector{<:Real}, gamma_lines::Vector{<:Unitfu
quantile(e_uncal, quantile_perc), length(gamma_lines)
end

@debug "Identified most prominent peak at $(round(peak_guess, digits = 2)) - literature value: $(gamma_lines[peak_idx])"
# 1) sort by ADC x value (accending)
sorted_peakpos = peakpos[sortperm(peakpos)]
sorted_cts_peakpos = cts_peakpos[sortperm(peakpos)]

# 2) log
@info "=== Sorted detected peaks by ADC value ==="
for i in eachindex(sorted_peakpos)
@info " Sorted Peak #$i: ADC=$(sorted_peakpos[i]), counts=$(sorted_cts_peakpos[i])"
end

# 3) peak used for calibration = sorted index 1
peak_guess = sorted_peakpos[1]
peak_idx = 1

@info "Using Lowest ADC Peak for calibration: ADC=$(peak_guess)"
@info "peak_idx => $(gamma_lines[peak_idx])"

# get calibration constant for simple calibration
c = gamma_lines[peak_idx] / peak_guess

result = (h_uncal = h_uncal, c = c, peak_guess = peak_guess)
Expand Down
Loading