88 if (hitCandidateVec.empty())
return;
91 chi2PerNDF = std::numeric_limits<double>::infinity();
93 int startTime = hitCandidateVec.front().startTick;
94 int endTime = hitCandidateVec.back().stopTick;
95 int roiSize = endTime - startTime;
100 std::string histName =
"PeakFitterHitSignal_" +
std::to_string(roiSize);
101 fHistogram = TH1F(histName.c_str(),
"",roiSize,0.,roiSize);
105 for(
int idx = 0; idx < roiSize; idx++)
fHistogram.SetBinContent(idx+1,roiSignalVec.at(startTime+idx));
113 for(
auto& candidateHit : hitCandidateVec)
115 double peakMean = candidateHit.hitCenter - float(startTime);
116 double peakWidth = candidateHit.hitSigma;
121 double amplitude = candidateHit.hitHeight;
122 double meanLowLim = std::max(peakMean -
fPeakRange * peakWidth, 0.);
123 double meanHiLim = std::min(peakMean +
fPeakRange * peakWidth,
double(roiSize));
127 fFit.SetParameter(0,0);
128 fFit.SetParameter(1, amplitude);
129 fFit.SetParameter(2, peakMean);
130 fFit.SetParameter(3,peakWidth/2);
131 fFit.SetParameter(4,peakWidth/2);
133 fFit.SetParLimits(0, -5, 5);
134 fFit.SetParLimits(1, 0.1 * amplitude, 10. * amplitude);
135 fFit.SetParLimits(2, meanLowLim,meanHiLim);
151 {mf::LogWarning(
"GausHitFinder") <<
"Fitter failed finding a hit";}
159 chi2PerNDF = (
fFit.GetChisquare() / NDF);
166 for(
size_t idx = 0; idx < hitCandidateVec.size(); idx++)
170 peakParams.peakAmplitude =
fFit.GetParameter(1);
171 peakParams.peakAmplitudeError =
fFit.GetParError(1);
172 peakParams.peakCenter =
fFit.GetParameter(2) + float(startTime);
173 peakParams.peakCenterError =
fFit.GetParError(2);
175 peakParams.peakTauLeft =
fFit.GetParameter(3);
176 peakParams.peakTauLeftError =
fFit.GetParError(3);
177 peakParams.peakTauRight =
fFit.GetParameter(4);
178 peakParams.peakTauRightError =
fFit.GetParError(4);
179 peakParams.peakBaseline =
fFit.GetParameter(0);
180 peakParams.peakBaselineError =
fFit.GetParError(0);
182 peakParamsVec.emplace_back(peakParams);
std::string to_string(WindowPattern const &pattern)