Skip to content

Instantly share code, notes, and snippets.

@ggggggggg
Created March 7, 2015 00:20
Show Gist options
  • Save ggggggggg/73d676c1f4db926ecba9 to your computer and use it in GitHub Desktop.
Save ggggggggg/73d676c1f4db926ecba9 to your computer and use it in GitHub Desktop.
psuedocode for mass
function update_channel(ljhfile)
getnewpulses(pulses!, ljhfile)
#summarize
oldsummarizelen = length(p_pretrig_mean)
newsummarizelen = length(pulses)
for j=oldsummarizelen+1:newsummarizelen
summaryj = summarize(pulses[j])
p_pretrig_mean[j] = summaryj[1]
p_pulse_mean[j] = summaryj[2]
p_rise_time[j] = summary[3]
end
# cuts
oldcutlen = length(good)
newcutlen = length(pulses)
for j = oldcutlen+1:newcutlen
good[j] = pt_low < p_pretrig_mean[j] < pt_high && pm_low < p_pulse_mean < pt_high
end
# calibrate
if !alreadycalibrated()
if npulses > num_pulses_for_calibration
p_filt_value_calibration = calibrate(p_filt_value[good])
lastneeded = inf # note taht we no longer have a hold on past p_filt_value entries
end
end
# apply calibration
if alreadycalibrated()
oldenergylen = length(p_energy)
newenergylen = length(p_filt_value)
for j = oldenergylen+1:newenergylen
p_energy[j] = applycal(p_filt_value_calibration, p_filt_value[j])
end
end
# drift correction
if alreadydriftcorrected()
olddclen = length(p_filt_value_dc)
newdclen = length(p_filt_value)
for j in olddclen+1:newdclen
applyt(dcinfo, p_filt_value[j])
end
end
# histogram
counts, edges = histogram(p_filt_value_dc[alreadyhistogrammed:1:end],edges)
p_filt_value_histogram += counts
# freeup old stuff
freeuntil(pulses, lastneeded(pulses))
freeuntil(p_filt_value, lastneeded(p_filt_value))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment