NAGASH 0.9.8
Next Generation Analysis System
|
Fit the contributions use template histograms to a target histogram. More...
#include "NAGASH/TemplateFitter.h"
Classes | |
class | TemplateFitterFCN |
Public Member Functions | |
TemplateFitter (std::shared_ptr< MSGTool > MSG) | |
void | Clear () |
Clear this tool. | |
void | Fit () |
Run the fit. | |
double | GetChi2 () |
Get the fit \(\chi^2\). | |
double | GetSF (uint64_t i) |
Get the scale factors for ith template. | |
double | GetSFError (uint64_t i) |
Get the uncertainty of the scale factors for ith template. | |
void | SetFitRange (int min, int max) |
Set the fit range. | |
void | SetRelation (std::function< double(const std::vector< double > &, const std::vector< double > &)>, std::function< double(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &)>) |
Set the relation between the target histogram and the template histograms. if not called, the default relation is: \( t=\sum s_i \cdot h_i\), here \( t\) is the target histogram, \( s_i\) is the scale factor and \( h_i\) is the corresponding template histogram. | |
void | SetTarget (TH1D *h) |
Set the target histogram. | |
void | SetTemplate (TH1D *h, double SF, double min, double max) |
Set the template histogram. | |
void | SetTemplate (TH1D *h, double SF=1, bool fix=false) |
Set the template histogram. | |
Private Member Functions | |
bool | Check () |
Private Attributes | |
double | chi2 = 0 |
std::function< double(const std::vector< double > &, const std::vector< double > &)> | contentfunction |
std::function< double(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &)> | errorfunction |
int | FitRangeMax = 0 |
int | FitRangeMin = 0 |
TH1D * | ht = nullptr |
std::vector< bool > | isfixed |
std::vector< double > | sf |
std::vector< double > | sferr |
std::vector< double > | sfmax |
std::vector< double > | sfmin |
std::vector< TH1D * > | vh |
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 contributions use template histograms to a target histogram.
For example, if you know the target distribution is composed of two sub distributions like:
\[ f(x) = \alpha\cdot\frac{\exp\left(-(x-1)^2/2\right)}{\sqrt{2\pi}}+\beta\cdot\frac{2\exp\left(-2(x-2)^2\right)}{{\sqrt{2\pi}}} \]
Of course \(\alpha = 1-\beta\), but in real world we are more interested in the ratio \(\alpha/\beta\). And now you have a histogram filled with distribution \((x)\), then you can get \(\alpha/\beta\) using this tool like:
The output will be like:
Definition at line 24 of file TemplateFitter.h.
|
inline |
Definition at line 27 of file TemplateFitter.h.
|
private |
Definition at line 230 of file TemplateFitter.cxx.
void TemplateFitter::Clear | ( | ) |
Clear this tool.
Definition at line 122 of file TemplateFitter.cxx.
void TemplateFitter::Fit | ( | ) |
Run the fit.
Definition at line 258 of file TemplateFitter.cxx.
double TemplateFitter::GetChi2 | ( | ) |
Get the fit \(\chi^2\).
Definition at line 339 of file TemplateFitter.cxx.
double TemplateFitter::GetSF | ( | uint64_t | i | ) |
Get the scale factors for ith template.
i | template index |
Definition at line 306 of file TemplateFitter.cxx.
double TemplateFitter::GetSFError | ( | uint64_t | i | ) |
Get the uncertainty of the scale factors for ith template.
i | template index |
Definition at line 323 of file TemplateFitter.cxx.
void TemplateFitter::SetFitRange | ( | int | min, |
int | max | ||
) |
Set the fit range.
min | minimum bin index. |
max | maximum bin index. |
Definition at line 215 of file TemplateFitter.cxx.
void TemplateFitter::SetRelation | ( | std::function< double(const std::vector< double > &, const std::vector< double > &)> | cf, |
std::function< double(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &)> | ef | ||
) |
Set the relation between the target histogram and the template histograms. if not called, the default relation is: \( t=\sum s_i \cdot h_i\), here \( t\) is the target histogram, \( s_i\) is the scale factor and \( h_i\) is the corresponding template histogram.
cf | the function to calculate the content, first argument is the vector of the scale factors, second argument is the vector of the contents of template histograms. |
ef | the function to calculate the error, first argument is the vector of the scale factors, second argument is the vector of the contents of template histograms, third argument is the vector of the errors of template histograms. |
Definition at line 205 of file TemplateFitter.cxx.
void TemplateFitter::SetTarget | ( | TH1D * | h | ) |
Set the target histogram.
Definition at line 133 of file TemplateFitter.cxx.
void TemplateFitter::SetTemplate | ( | TH1D * | h, |
double | SF, | ||
double | SFMIN, | ||
double | SFMAX | ||
) |
Set the template histogram.
h | template histogram. |
SF | initial value of the scale factor. |
SFMIN | minimum value of the scale factor during the fit. |
SFMAX | maximum value of the scale factor during the fit. |
Definition at line 175 of file TemplateFitter.cxx.
void TemplateFitter::SetTemplate | ( | TH1D * | h, |
double | SF = 1 , |
||
bool | fix = false |
||
) |
Set the template histogram.
h | template histogram. |
SF | initial value of the scale factor. |
fix | whether to fix the scale factor during the fit. |
Definition at line 152 of file TemplateFitter.cxx.
|
private |
Definition at line 67 of file TemplateFitter.h.
|
private |
Definition at line 71 of file TemplateFitter.h.
|
private |
Definition at line 72 of file TemplateFitter.h.
|
private |
Definition at line 69 of file TemplateFitter.h.
|
private |
Definition at line 68 of file TemplateFitter.h.
|
private |
Definition at line 74 of file TemplateFitter.h.
|
private |
Definition at line 66 of file TemplateFitter.h.
|
private |
Definition at line 62 of file TemplateFitter.h.
|
private |
Definition at line 65 of file TemplateFitter.h.
|
private |
Definition at line 64 of file TemplateFitter.h.
|
private |
Definition at line 63 of file TemplateFitter.h.
|
private |
Definition at line 75 of file TemplateFitter.h.