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