8 #include "art/Utilities/ToolMacros.h"
9 #include "art/Utilities/make_tool.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
11 #include "cetlib_except/exception.h"
29 void configure(
const fhicl::ParameterSet& pset)
override;
37 static Double_t
fitf(Double_t *
x, Double_t *par);
55 : fFit(
"ICARUSfunc", fitf, 0.0, 1.0, 5)
63 fMinWidth = pset.get<
double>(
"MinWidth", 0.5);
65 fPeakRange = pset.get<
double>(
"PeakRangeFact", 2.);
66 fAmpRange = pset.get<
double>(
"PeakAmpRange", 2.);
68 fHistogram = TH1F(
"PeakFitterHitSignal",
"",500,0.,500.);
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);
192 Double_t fitval = par[0]+par[1]*TMath::Exp(-(x[0]-par[2])/par[3])/(1+TMath::Exp(-(x[0]-par[3])/par[4]));
Utilities related to art service access.
process_name opflash particleana ie x
Description of geometry of one entire detector.
std::string to_string(WindowPattern const &pattern)
art framework interface to geometry description