NAGASH 0.9.8
Next Generation Analysis System
|
fit the parameters of a \(\chi^2\) shape function. More...
#include "NAGASH/Chi2Fitter.h"
Classes | |
class | Chi2FitterFCN |
fcn function to calculate the \(\chi^2\) More... | |
Public Types | |
enum class | FitMethod { Eigen , Minuit } |
Fit method. More... | |
Public Member Functions | |
Chi2Fitter (std::shared_ptr< MSGTool >, uint64_t) | |
Constructor. | |
Chi2Fitter (std::shared_ptr< MSGTool >, uint64_t, TH1D *, TH2D *_cov_=nullptr) | |
Constructor. | |
const TMatrixD & | Cov () |
double | Error (uint64_t) |
Get the fit error of ith parameter. | |
void | Fit (FitMethod fm=FitMethod::Eigen) |
Start to fit. | |
double | FitChi2 () |
Get the \(\chi^2\) of the fitting procedure. | |
double | GetChi2 (uint64_t) |
Get the \(\chi^2\) of ith model. | |
double | OffSet () |
The offset parameter \( b\) of the fitted \(\chi^2\) function. | |
void | SetModel (const std::vector< double > &, double) |
Set the \(\chi^2\) value of a set of parameters. | |
void | SetModel (const std::vector< double > &, TH1D *, TH2D *cov=nullptr) |
Set the model with a set of parameter. | |
void | SetRange (int min, int max) |
Set the range of calculation of \(\chi^2\) of the target histogram. | |
const std::vector< double > & | Value () |
double | Value (uint64_t) |
Get the best-fit value of ith parameter. | |
Private Attributes | |
double | chi2 = 0 |
TMatrixD | cov |
uint64_t | dimension = 1 |
HistTool | histtool |
bool | isvalid = false |
double | offset = 0 |
int | RangeMax = 1 |
int | RangeMin = 1 |
TH1D * | target = nullptr |
TH2D * | targetcov = nullptr |
std::vector< double > | value |
std::vector< double > | vchi2 |
std::vector< std::vector< double > > | vvalue |
std::vector< double > | vvaluemax |
std::vector< double > | vvaluemin |
Additional Inherited Members | |
Protected Member Functions inherited from NAGASH::Tool | |
Tool ()=delete | |
Tool (const Tool &tool)=delete | |
Tool (std::shared_ptr< MSGTool > MSG) | |
Constructor. | |
Tool (Tool &&tool)=delete | |
virtual | ~Tool ()=default |
std::shared_ptr< MSGTool > | MSGUser () |
return the MSGTool inside. | |
Tool & | operator= (const Tool &tool)=delete |
Tool & | operator= (Tool &&tool)=delete |
fit the parameters of a \(\chi^2\) shape function.
For a given set of \(\chi^2\) at different points: \((\vec{x},\chi^2)\), fit to the quadratic function:
\[ \chi^2(\vec{x},\vec{v},\Sigma)=(\vec{x}-\vec{v})^{T}\Sigma^{-1}(\vec{x}-\vec{v})+b \]
Where \(\vec{v}\) are best-fit value of parameters with \(\Sigma\) as their covariance matrix.
This tool provides methods of processing histograms. Firstly, user should pass the target histogram as well as its covariance matrix to this tool, then set different models with different parameters. Then the \(\chi^2\)s are calculated and best-fit parameters are fitted along with their covariance matrix.
Definition at line 23 of file Chi2Fitter.h.
|
strong |
Fit method.
Enumerator | |
---|---|
Eigen | use matrix calculation to get the fitted value, Eigen library is used. |
Minuit | use minuit library to fit the value. |
Definition at line 27 of file Chi2Fitter.h.
Chi2Fitter::Chi2Fitter | ( | std::shared_ptr< MSGTool > | msg, |
uint64_t | dim, | ||
TH1D * | _target_, | ||
TH2D * | _cov_ = nullptr |
||
) |
Constructor.
msg | input MSGTool. |
dim | the degrees of freedomof the \(\chi^2\). |
_target_ | the target histogram to be compared with. |
_cov_ | the covariance matrix of the target histogram. |
Definition at line 32 of file Chi2Fitter.cxx.
Chi2Fitter::Chi2Fitter | ( | std::shared_ptr< MSGTool > | msg, |
uint64_t | dim | ||
) |
Constructor.
msg | input MSGTool. |
dim | the degrees of freedomof the \(\chi^2\). |
Definition at line 51 of file Chi2Fitter.cxx.
|
inline |
Definition at line 44 of file Chi2Fitter.h.
double Chi2Fitter::Error | ( | uint64_t | index | ) |
Get the fit error of ith parameter.
index | index of the parameter. |
Definition at line 242 of file Chi2Fitter.cxx.
void Chi2Fitter::Fit | ( | FitMethod | fm = FitMethod::Eigen | ) |
double Chi2Fitter::FitChi2 | ( | ) |
Get the \(\chi^2\) of the fitting procedure.
Definition at line 223 of file Chi2Fitter.cxx.
double Chi2Fitter::GetChi2 | ( | uint64_t | index | ) |
Get the \(\chi^2\) of ith model.
index | the index of the model. |
Definition at line 213 of file Chi2Fitter.cxx.
double Chi2Fitter::OffSet | ( | ) |
The offset parameter \( b\) of the fitted \(\chi^2\) function.
Definition at line 252 of file Chi2Fitter.cxx.
void Chi2Fitter::SetModel | ( | const std::vector< double > & | vv, |
double | _chi2_ | ||
) |
Set the \(\chi^2\) value of a set of parameters.
vv | the set of parameters, must be the same size as the dimension of the \(\chi^2\). |
_chi2_ | the corresponding \(\chi^2\) value. |
Definition at line 77 of file Chi2Fitter.cxx.
void Chi2Fitter::SetModel | ( | const std::vector< double > & | vv, |
TH1D * | hmodel, | ||
TH2D * | covmodel = nullptr |
||
) |
Set the model with a set of parameter.
vv | the parameters defining the model, must be the same size as the dimension of the \(\chi^2\). |
hmodel | the histogram of the model. |
covmodel | the covariance matrix of the histogram. |
Definition at line 111 of file Chi2Fitter.cxx.
void Chi2Fitter::SetRange | ( | int | min, |
int | max | ||
) |
Set the range of calculation of \(\chi^2\) of the target histogram.
min | mininum bin index. |
max | maximum bin index. |
Definition at line 60 of file Chi2Fitter.cxx.
|
inline |
Definition at line 43 of file Chi2Fitter.h.
double Chi2Fitter::Value | ( | uint64_t | index | ) |
Get the best-fit value of ith parameter.
index | index of the parameter. |
Definition at line 231 of file Chi2Fitter.cxx.
|
private |
Definition at line 81 of file Chi2Fitter.h.
|
private |
Definition at line 80 of file Chi2Fitter.h.
|
private |
Definition at line 70 of file Chi2Fitter.h.
|
private |
Definition at line 84 of file Chi2Fitter.h.
|
private |
Definition at line 69 of file Chi2Fitter.h.
|
private |
Definition at line 82 of file Chi2Fitter.h.
|
private |
Definition at line 72 of file Chi2Fitter.h.
|
private |
Definition at line 71 of file Chi2Fitter.h.
|
private |
Definition at line 73 of file Chi2Fitter.h.
|
private |
Definition at line 74 of file Chi2Fitter.h.
|
private |
Definition at line 79 of file Chi2Fitter.h.
|
private |
Definition at line 75 of file Chi2Fitter.h.
|
private |
Definition at line 76 of file Chi2Fitter.h.
|
private |
Definition at line 77 of file Chi2Fitter.h.
|
private |
Definition at line 78 of file Chi2Fitter.h.