Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TFractionFitter.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Frank Filthaut F.Filthaut@science.ru.nl 20/05/2002
3
4#ifndef ROOT_TFractionFitter
5#define ROOT_TFractionFitter
6
7#ifndef ROOT_TVirtualFitter
8# include "TVirtualFitter.h"
9#endif
10
11#ifndef ROOT_TObjArray
12# include "TObjArray.h"
13#endif
14
15#include "TFitResultPtr.h"
16
17#include <vector>
18
19class TH1;
20
21namespace ROOT {
22 namespace Fit {
23 class Fitter;
24 }
25}
26
27class TFractionFitter: public TObject {
28public:
31 ~TFractionFitter() override;
32
33 //TVirtualFitter* GetFitter() const;
35 void ErrorAnalysis(Double_t UP);
36 void SetRangeX(Int_t low, Int_t high);
37 void ReleaseRangeX();
38 void SetRangeY(Int_t low, Int_t high);
39 void ReleaseRangeY();
40 void SetRangeZ(Int_t low, Int_t high);
41 void ReleaseRangeZ();
42 void ExcludeBin(Int_t bin);
43 void IncludeBin(Int_t bin);
44 void Constrain(Int_t parm, Double_t low, Double_t high);
45 void UnConstrain(Int_t parm);
46 void SetData(TH1 *data);
47 void SetMC(Int_t parm, TH1 *MC);
48 void SetWeight(Int_t parm, TH1* weight);
50
51 void GetResult(Int_t parm, Double_t& value, Double_t& error) const;
52 TH1* GetPlot();
53
54 // This global function needs access to computeFCN()
55 //friend void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
56
57 // Goodness of fit
58 Double_t GetChisquare() const;
59 Int_t GetNDF() const;
60 Double_t GetProb() const;
61
62 // MC predictions (smeared templates)
63 TH1* GetMCPrediction(Int_t parm) const;
64
65 // FCN evaluation
67 Double_t f = 0;
68 ComputeFCN(f, par, 0);
69 return f;
70 }
71
72private:
73 void CheckParNo(Int_t parm) const;
74 void CheckConsistency();
75 void FindPrediction(int bin, double& t_i, int& k_0, double& A_ki) const;
76 void ComputeFCN(Double_t& f, const Double_t* par, Int_t flag);
77 void GetRanges(Int_t& minX, Int_t& maxX, Int_t& minY, Int_t& maxY,
78 Int_t& minZ, Int_t& maxZ) const;
80 bool IsExcluded(Int_t bin) const;
81
82protected:
83 Bool_t fFitDone; ///< Flags whether a valid fit has been performed
84 Int_t fLowLimitX; ///< First bin in X dimension
85 Int_t fHighLimitX; ///< Last bin in X dimension
86 Int_t fLowLimitY; ///< First bin in Y dimension
87 Int_t fHighLimitY; ///< Last bin in Y dimension
88 Int_t fLowLimitZ; ///< First bin in Z dimension
89 Int_t fHighLimitZ; ///< Last bin in Z dimension
90 std::vector<Int_t> fExcludedBins; ///< Bins excluded from the fit
91
92 Int_t fNpfits; ///< Number of points used in the fit
93 Int_t fNDF; ///< Number of degrees of freedom in the fit
94 Double_t fChisquare; ///< Template fit chisquare
95
96 TObjArray fAji; ///< Array of pointers to predictions of real template distributions
97
98 ///@name Histograms
99 ///@{
100 TH1* fData; ///< Pointer to the "data" histogram to be fitted to
101 TObjArray fMCs; ///< Array of pointers to template histograms
102 TObjArray fWeights; ///< Array of pointers to corresponding weight factors (may be null)
103 Double_t fIntegralData; ///< "data" histogram content integral over allowed fit range
104 Double_t* fIntegralMCs; ///< Same for template histograms (weights not taken into account)
105 Double_t* fFractions; ///< Template fractions scaled to the "data" histogram statistics
106 TH1* fPlot; ///< Pointer to histogram containing summed template predictions
107 ROOT::Fit::Fitter *fFractionFitter; ///< Pointer to Fitter class
108 ///@}
109
110 Int_t fNpar; ///< number of fit parameters
111
112 ClassDefOverride(TFractionFitter, 0); // Fits MC fractions to data histogram
113};
114
115//
116// TFractionFitFCN
117//
118// Computes negative log-likelihood for TFractionFitter
119//
120
121void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
122
123#endif // ROOT_TFractionFitter
#define f(i)
Definition RSha256.hxx:104
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
void TFractionFitFCN(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Fitter class, entry point for performing all type of fits.
Definition Fitter.h:77
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Fits MC fractions to data histogram.
void ComputeFCN(Double_t &f, const Double_t *par, Int_t flag)
Used internally to compute the likelihood value.
void GetRanges(Int_t &minX, Int_t &maxX, Int_t &minY, Int_t &maxY, Int_t &minZ, Int_t &maxZ) const
Used internally to obtain the bin ranges according to the dimensionality of the histogram and the lim...
void FindPrediction(int bin, double &t_i, int &k_0, double &A_ki) const
Function used internally to obtain the template prediction in the individual bins 'bin' <=> 'i' (pape...
TH1 * GetPlot()
Return the "template prediction" corresponding to the fit result (this is not the same as the weighte...
Int_t fLowLimitX
First bin in X dimension.
Double_t GetProb() const
return the fit probability
void GetResult(Int_t parm, Double_t &value, Double_t &error) const
Obtain the fit result for parameter <parm> (the parameter numbering follows that of the input templat...
TObjArray fAji
Array of pointers to predictions of real template distributions.
void CheckConsistency()
Function used internally to check the consistency between the various histograms.
Bool_t fFitDone
Flags whether a valid fit has been performed.
void SetRangeX(Int_t low, Int_t high)
Set the X range of the histogram to be used in the fit.
void SetMC(Int_t parm, TH1 *MC)
Change the histogram for template number <parm>.
TObjArray fMCs
Array of pointers to template histograms.
Double_t EvaluateFCN(const Double_t *par)
ROOT::Fit::Fitter * GetFitter() const
Give direct access to the underlying fitter class.
void SetRangeY(Int_t low, Int_t high)
Set the Y range of the histogram to be used in the fit (2D or 3D histograms only).
~TFractionFitter() override
TFractionFitter default destructor.
void ExcludeBin(Int_t bin)
Exclude the given bin from the fit.
TFractionFitter()
TFractionFitter default constructor.
TObjArray fWeights
Array of pointers to corresponding weight factors (may be null)
void IncludeBin(Int_t bin)
Include the given bin in the fit, if it was excluded before using ExcludeBin().
ROOT::Fit::Fitter * fFractionFitter
Pointer to Fitter class.
void Constrain(Int_t parm, Double_t low, Double_t high)
Constrain the values of parameter number <parm> (the parameter numbering follows that of the input te...
void SetData(TH1 *data)
Change the histogram to be fitted to.
TH1 * fPlot
Pointer to histogram containing summed template predictions.
Int_t fHighLimitY
Last bin in Y dimension.
bool IsExcluded(Int_t bin) const
Function for internal use, checking whether the given bin is excluded from the fit or not.
void SetRangeZ(Int_t low, Int_t high)
Set the Z range of the histogram to be used in the fit (3D histograms only).
Int_t fNpar
number of fit parameters
Int_t fHighLimitZ
Last bin in Z dimension.
Int_t fNpfits
Number of points used in the fit.
Double_t GetChisquare() const
Return the likelihood ratio Chi-squared (chi2) for the fit.
void UnConstrain(Int_t parm)
Remove the constraints on the possible values of parameter <parm>.
Int_t fLowLimitY
First bin in Y dimension.
Int_t fHighLimitX
Last bin in X dimension.
Int_t GetNDF() const
return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
Double_t * fFractions
Template fractions scaled to the "data" histogram statistics.
Int_t fLowLimitZ
First bin in Z dimension.
void ReleaseRangeZ()
Release restrictions on the Z range of the histogram to be used in the fit.
void SetWeight(Int_t parm, TH1 *weight)
Set bin by bin weights for template number <parm> (the parameter numbering follows that of the input ...
Double_t fIntegralData
"data" histogram content integral over allowed fit range
void ReleaseRangeX()
Release restrictions on the X range of the histogram to be used in the fit.
void ErrorAnalysis(Double_t UP)
Set UP to the given value (see class TMinuit), and perform a MINOS minimisation.
void ComputeChisquareLambda()
Method used internally to compute the likelihood ratio chi2 See the function GetChisquare() for detai...
Int_t fNDF
Number of degrees of freedom in the fit.
TFitResultPtr Fit()
Perform the fit with the default UP value.
Double_t * fIntegralMCs
Same for template histograms (weights not taken into account)
Double_t fChisquare
Template fit chisquare.
void ReleaseRangeY()
Release restrictions on the Y range of the histogram to be used in the fit.
TH1 * fData
Pointer to the "data" histogram to be fitted to.
std::vector< Int_t > fExcludedBins
Bins excluded from the fit.
TH1 * GetMCPrediction(Int_t parm) const
Return the adjusted MC template (Aji) for template (parm).
void CheckParNo(Int_t parm) const
Function for internal use, checking parameter validity An invalid parameter results in an error.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.