LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MarqFitAlg.h
Go to the documentation of this file.
1 // Class: MarqFitAlg
3 // Purpose: Fit gaussians
4 //
5 //
6 // Original code by Mike Wang, converted to a larsoft algorithm by S. Berkman
8 
9 #ifndef MARQFITALG_H
10 #define MARQFITALG_H
11 
12 #include <cmath>
13 #include <iostream>
14 #include <vector>
15 
16 //#include "fhiclcpp/ParameterSet.h"
17 //#include "lardataobj/RecoBase/Hit.h"
18 
19 namespace gshf {
20 
21  class MarqFitAlg {
22  public:
23  explicit MarqFitAlg();
24  virtual ~MarqFitAlg() {}
25 
26  int cal_perr(float p[], float y[], const int nParam, const int nData, float perr[]);
27  int mrqdtfit(float& lambda,
28  float p[],
29  float y[],
30  const int nParam,
31  const int nData,
32  float& chiSqr,
33  float& dchiSqr);
34  int mrqdtfit(float& lambda,
35  float p[],
36  float plimmin[],
37  float plimmax[],
38  float y[],
39  const int nParam,
40  const int nData,
41  float& chiSqr,
42  float& dchiSqr);
43 
44  private:
45  //these functions are called by the public functions
46  void fgauss(const float yd[],
47  const float p[],
48  const int npar,
49  const int ndat,
50  std::vector<float>& res);
51  void dgauss(const float p[], const int npar, const int ndat, std::vector<float>& dydp);
52  float cal_xi2(const std::vector<float>& res, const int ndat);
53  void setup_matrix(const std::vector<float>& res,
54  const std::vector<float>& dydp,
55  const int npar,
56  const int ndat,
57  std::vector<float>& beta,
58  std::vector<float>& alpha);
59  void solve_matrix(const std::vector<float>& beta,
60  const std::vector<float>& alpha,
61  const int npar,
62  std::vector<float>& dp);
63  float invrt_matrix(std::vector<float>& alphaf, const int npar);
64  };
65 
66 } //end namespace gshf
67 #endif
void solve_matrix(const std::vector< float > &beta, const std::vector< float > &alpha, const int npar, std::vector< float > &dp)
Definition: MarqFitAlg.cxx:101
Float_t y
Definition: compare.C:6
int mrqdtfit(float &lambda, float p[], float y[], const int nParam, const int nData, float &chiSqr, float &dchiSqr)
Definition: MarqFitAlg.cxx:294
int cal_perr(float p[], float y[], const int nParam, const int nData, float perr[])
Definition: MarqFitAlg.cxx:262
void fgauss(const float yd[], const float p[], const int npar, const int ndat, std::vector< float > &res)
Definition: MarqFitAlg.cxx:7
float cal_xi2(const std::vector< float > &res, const int ndat)
Definition: MarqFitAlg.cxx:47
void dgauss(const float p[], const int npar, const int ndat, std::vector< float > &dydp)
Definition: MarqFitAlg.cxx:26
float invrt_matrix(std::vector< float > &alphaf, const int npar)
Definition: MarqFitAlg.cxx:149
virtual ~MarqFitAlg()
Definition: MarqFitAlg.h:24
void setup_matrix(const std::vector< float > &res, const std::vector< float > &dydp, const int npar, const int ndat, std::vector< float > &beta, std::vector< float > &alpha)
Definition: MarqFitAlg.cxx:59