LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PeakFitterGaussElimination_tool.cc
Go to the documentation of this file.
1 
7 
10 
11 #include <algorithm>
12 
13 namespace reco_tool {
14 
16  public:
17  explicit PeakFitterGaussElimination(const fhicl::ParameterSet& pset);
18 
19  void findPeakParameters(const std::vector<float>&,
22  double&,
23  int&) const override;
24 
25  private:
26  // Member variables from the fhicl file
27  float fStepSize;
28  float fMax;
29 
30  std::unique_ptr<util::GaussianEliminationAlg> fGEAlg;
31  };
32 
33  //----------------------------------------------------------------------
34  // Constructor.
36  {
37  // Start by recovering the parameters
38  fStepSize = pset.get<float>("StepSize", 0.1);
39  fMax = pset.get<float>("Max", 0.5);
40 
41  // fGEAlg = std::make_unique<util::GaussianEliminationAlg>(fStepSize, fMax);
42 
43  return;
44  }
45 
46  // --------------------------------------------------------------------------------------------
48  const std::vector<float>& roiSignalVec,
49  const ICandidateHitFinder::HitCandidateVec& hitCandidateVec,
50  PeakParamsVec& /* peakParamsVec */,
51  double& /* chi2PerNDF */,
52  int& /* NDF */) const
53  {
54  // This module tries to use the method for fitting hits found in the RRFHitFinder
55  // from Wes Ketchum. It uses the gaussian elimation algorithm he set up.
56  //
57  // *** NOTE: this algorithm assumes the reference time for input hit candidates is to
58  // the first tick of the input waveform (ie 0)
59  //
60  if (hitCandidateVec.empty()) return;
61 
62  std::vector<float> meanVec;
63  std::vector<float> sigmaVec;
64  std::vector<float> heightVec;
65 
66  for (const auto& hitCandidate : hitCandidateVec) {
67  float candMean = hitCandidate.hitCenter;
68  float candSigma = hitCandidate.hitSigma;
69  size_t bin = std::floor(candMean);
70 
71  bin = std::min(bin, roiSignalVec.size() - 1);
72 
73  float candHeight =
74  roiSignalVec[bin] - (candMean - (float)bin) * (roiSignalVec[bin] - roiSignalVec[bin + 1]);
75 
76  meanVec.push_back(candMean);
77  sigmaVec.push_back(candSigma);
78  heightVec.push_back(candHeight);
79  }
80 
81  return;
82  }
83 
85 }
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
float fStepSize
Step size used by gaussian elim alg.
PeakFitterGaussElimination(const fhicl::ParameterSet &pset)
void findPeakParameters(const std::vector< float > &, const ICandidateHitFinder::HitCandidateVec &, PeakParamsVec &, double &, int &) const override
T get(std::string const &key) const
Definition: ParameterSet.h:314
float bin[41]
Definition: plottest35.C:14
std::unique_ptr< util::GaussianEliminationAlg > fGEAlg
std::vector< PeakFitParams_t > PeakParamsVec
Definition: IPeakFitter.h:34
This provides an interface for tools which are tasked with fitting peaks on input waveforms...
std::vector< HitCandidate > HitCandidateVec