11 #include "cetlib_except/exception.h" 69 fHistogram = TH1F(
"PeakFitterHitSignal",
"",500,0.,500.);
73 std::string
function =
"Gaus(0)";
91 if (hitCandidateVec.empty())
return;
94 chi2PerNDF = std::numeric_limits<double>::infinity();
96 int startTime = hitCandidateVec.front().startTick;
97 int endTime = hitCandidateVec.back().stopTick;
98 int roiSize = endTime - startTime;
103 std::string histName =
"PeakFitterHitSignal_" +
std::to_string(roiSize);
104 fHistogram = TH1F(histName.c_str(),
"",roiSize,0.,roiSize);
108 for(
int idx = 0; idx < roiSize; idx++)
fHistogram.SetBinContent(idx+1,roiSignalVec.at(startTime+idx));
111 std::string equation =
"gaus(0)";
113 for(
size_t idx = 1; idx < hitCandidateVec.size(); idx++) equation +=
"+gaus(" +
std::to_string(3*idx) +
")";
116 TF1 Gaus(
"Gaus",equation.c_str(),0,roiSize);
120 for(
auto& candidateHit : hitCandidateVec)
122 double peakMean = candidateHit.hitCenter - float(startTime);
123 double peakWidth = candidateHit.hitSigma;
124 double amplitude = candidateHit.hitHeight;
128 Gaus.SetParameter( parIdx, amplitude);
129 Gaus.SetParameter(1+parIdx, peakMean);
130 Gaus.SetParameter(2+parIdx, peakWidth);
131 Gaus.SetParLimits( parIdx, 0.1 * amplitude,
fAmpRange * amplitude);
132 Gaus.SetParLimits(1+parIdx, meanLowLim, meanHiLim);
141 { fitResult =
fHistogram.Fit(&Gaus,
"QNRWB",
"", 0., roiSize);}
143 {
mf::LogWarning(
"GausHitFinder") <<
"Fitter failed finding a hit";}
151 chi2PerNDF = (Gaus.GetChisquare() / Gaus.GetNDF());
155 for(
size_t idx = 0; idx < hitCandidateVec.size(); idx++)
159 peakParams.peakAmplitude = Gaus.GetParameter(parIdx);
160 peakParams.peakAmplitudeError = Gaus.GetParError( parIdx);
161 peakParams.peakCenter = Gaus.GetParameter(parIdx + 1) + float(startTime);
162 peakParams.peakCenterError = Gaus.GetParError( parIdx + 1);
163 peakParams.peakSigma = Gaus.GetParameter(parIdx + 2);
164 peakParams.peakSigmaError = Gaus.GetParError( parIdx + 2);
166 peakParamsVec.emplace_back(peakParams);
T get(std::string const &key) const
Description of geometry of one entire detector.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
This provides an interface for tools which are tasked with fitting peaks on input waveforms...
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
art framework interface to geometry description