Skip to content
Snippets Groups Projects
Commit e084e395 authored by Chao Peng's avatar Chao Peng
Browse files

tuned the peak search parameters

parent 678c3bfd
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment