From e084e395eb0d965c93a1058301439a8fdd6de968 Mon Sep 17 00:00:00 2001 From: Chao Peng <cpeng@anl.gov> Date: Sat, 18 Apr 2020 20:27:19 -0500 Subject: [PATCH] tuned the peak search parameters --- src/esb_analyze.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/esb_analyze.cpp b/src/esb_analyze.cpp index 84aeca5..b6fb1a1 100644 --- a/src/esb_analyze.cpp +++ b/src/esb_analyze.cpp @@ -233,7 +233,7 @@ struct BranchData int npul, nraw; float integral[MAX_NPEAKS], peak[MAX_NPEAKS], time[MAX_NPEAKS]; int raw[MAX_RAW]; - float ped_mean, ped_err, best_peak; + float ped_mean, ped_err; }; #define BUF_SIZE 1000 @@ -271,6 +271,7 @@ void refine_pedestal(const std::vector<uint32_t> &raw, float &ped_mean, float &p refine_pedestal(raw, ped_mean, ped_err); } +// a function for a simple constant baseline fit void find_pedestal(const std::vector<uint32_t> &raw, float &ped_mean, float &ped_err) { ped_mean = 0; @@ -289,6 +290,7 @@ void find_pedestal(const std::vector<uint32_t> &raw, float &ped_mean, float &ped refine_pedestal(raw, ped_mean, ped_err); } +// analyze the waveform data and fill the result in a branch data void waveform_analysis(const std::vector<uint32_t> &raw, BranchData &res) { // no need to analyze @@ -312,27 +314,29 @@ void waveform_analysis(const std::vector<uint32_t> &raw, BranchData &res) // find peaks TSpectrum s; - int npeaks = s.SearchHighRes(wfbuf, bkbuf, res.nraw, 5.0, 5.0, false, 6, false, 3); + s.SetResolution(0.5); + int npeaks = s.SearchHighRes(wfbuf, bkbuf, res.nraw, 2.0, 5, false, 3, true, 3); // fill branch data double *pos = s.GetPositionX(); res.npul = 0; - res.best_peak = 0; for (int i = 0; i < npeaks; ++i) { - int j = pos[i] - 1; + int j = pos[i]; if (wfbuf[j] < 5.*res.ped_err) { continue; } res.time[res.npul] = j; res.peak[res.npul] = wfbuf[j]; + /* res.integral[res.npul] = wfbuf[j]; j = pos[i] - 1; - while ( (j > 0) && (wfbuf[j] > 3.0*res.ped_err) ) { res.integral[res.npul] += wfbuf[j--]; } + while ( (j > 0) && (wfbuf[j] - wfbuf[j - 1])*wfbuf[j] > 0. ) { + res.integral[res.npul] += wfbuf[j--]; + } j = pos[i] + 1; - while ( (j < res.nraw) && (wfbuf[j] > 3.0*res.ped_err) ) { res.integral[res.npul] += wfbuf[j++]; } - res.npul ++; - - if (j < 40 && j < 10 && wfbuf[j] > res.best_peak) { - res.best_peak = wfbuf[j]; + while ( (j < res.nraw - 1) && (wfbuf[j] - wfbuf[j + 1])*wfbuf[j] > 0. ) { + res.integral[res.npul] += wfbuf[j++]; } + */ + res.npul ++; } } @@ -376,7 +380,6 @@ void fill_tree(TTree *tree, std::unordered_map<std::string, BranchData> &brdata, tree->Branch((n + "_raw").c_str(), &brdata[n].raw[0], (n + "_raw[" + n + "_Nraw]/I").c_str()); tree->Branch((n + "_ped_mean").c_str(), &brdata[n].ped_mean, (n + "_ped_mean/F").c_str()); tree->Branch((n + "_ped_err").c_str(), &brdata[n].ped_err, (n + "_ped_err/F").c_str()); - tree->Branch((n + "_best_peak").c_str(), &brdata[n].ped_err, (n + "_best_peak/F").c_str()); } } init = true; -- GitLab