1 #include "larvecutils/MarqFitAlg/MarqFitAlg.h" 7 #include "art_root_io/TFileService.h" 8 #include "cetlib_except/exception.h" 61 if (fhc_vec.empty())
return;
63 const float chiCut = 1
e-3;
68 int startTime = fhc_vec.front().startTick;
69 int endTime = fhc_vec.back().stopTick;
71 int roiSize = endTime - startTime;
76 std::vector<float>
y(roiSize);
77 std::vector<float>
p(3 * fhc_vec.size());
78 std::vector<float> plimmin(3 * fhc_vec.size());
79 std::vector<float> plimmax(3 * fhc_vec.size());
80 std::vector<float> perr(3 * fhc_vec.size());
85 for (
size_t ih = 0;
ih < fhc_vec.size();
ih++) {
86 float const peakMean =
87 fhc_vec[
ih].hitCenter - 0.5 - (
float)startTime;
88 float const peakWidth = fhc_vec[
ih].hitSigma;
89 float const amplitude = fhc_vec[
ih].hitHeight;
90 float const meanLowLim = fmax(peakMean -
fPeakRange * peakWidth, 0.);
91 float const meanHiLim = fmin(peakMean +
fPeakRange * peakWidth, (
float)roiSize);
92 p[0 + nParams] = amplitude;
93 p[1 + nParams] = peakMean;
94 p[2 + nParams] = peakWidth;
96 plimmin[0 + nParams] = amplitude * 0.1;
97 plimmin[1 + nParams] = meanLowLim;
100 plimmax[0 + nParams] = amplitude *
fAmpRange;
101 plimmax[1 + nParams] = meanHiLim;
108 for (
size_t idx = 0; idx < size_t(roiSize); idx++) {
109 y[idx] = signal[startTime + idx];
115 fitResult =
fMarqFitAlg->gshf::MarqFitAlg::mrqdtfit(
116 lambda, &
p[0], &plimmin[0], &plimmax[0], &y[0], nParams, roiSize, chiSqr, dchiSqr);
118 if (fitResult || (trial > 100))
break;
119 }
while (fabs(dchiSqr) >= chiCut);
123 fMarqFitAlg->gshf::MarqFitAlg::cal_perr(&
p[0], &y[0], nParams, roiSize, &perr[0]);
125 NDF = roiSize - nParams;
126 chi2PerNDF = chiSqr / NDF;
128 for (
size_t i = 0; i < fhc_vec.size(); i++) {
143 p[parIdx + 1] + 0.5 +
float(startTime);
148 mhpp_vec.emplace_back(mhpp);
art framework interface to geometry description
static int max(int a, int b)
Description of geometry of one entire detector.
This provides an interface for tools which are tasked with fitting peaks on input waveforms...
This provides an interface for tools which are tasked with finding candidate hits on input waveforms...
Provide caches for TF1 functions to be used with ROOT fitters.
auto const & get(AssnsNode< L, R, D > const &r)