Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_TFitResultPtr
16 #include "TFitResultPtr.h"
17 #endif
18 
19 #include <vector>
20 
21 class TH1;
22 
23 namespace ROOT {
24  namespace Fit {
25  class Fitter;
26  }
27 }
28 
29 class TFractionFitter: public TObject {
30 public:
32  TFractionFitter(TH1* data, TObjArray *MCs, Option_t *option="");
33  virtual ~TFractionFitter();
34 
35  //TVirtualFitter* GetFitter() const;
36  ROOT::Fit::Fitter* GetFitter() const;
37  void ErrorAnalysis(Double_t UP);
38  void SetRangeX(Int_t low, Int_t high);
39  void ReleaseRangeX();
40  void SetRangeY(Int_t low, Int_t high);
41  void ReleaseRangeY();
42  void SetRangeZ(Int_t low, Int_t high);
43  void ReleaseRangeZ();
44  void ExcludeBin(Int_t bin);
45  void IncludeBin(Int_t bin);
46  void Constrain(Int_t parm, Double_t low, Double_t high);
47  void UnConstrain(Int_t parm);
48  void SetData(TH1 *data);
49  void SetMC(Int_t parm, TH1 *MC);
50  void SetWeight(Int_t parm, TH1* weight);
52 
53  void GetResult(Int_t parm, Double_t& value, Double_t& error) const;
54  TH1* GetPlot();
55 
56  // This global function needs access to computeFCN()
57  //friend void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
58 
59  // Goodness of fit
60  Double_t GetChisquare() const;
61  Int_t GetNDF() const;
62  Double_t GetProb() const;
63 
64  // MC predictions (smeared templates)
65  TH1* GetMCPrediction(Int_t parm) const;
66 
67  // FCN evaluation
69  Double_t f = 0;
70  ComputeFCN(f, par, 0);
71  return f;
72  }
73 
74 private:
75  void CheckParNo(Int_t parm) const;
76  void CheckConsistency();
77  void FindPrediction(int bin, double& t_i, int& k_0, double& A_ki) const;
78  void ComputeFCN(Double_t& f, const Double_t* par, Int_t flag);
79  void GetRanges(Int_t& minX, Int_t& maxX, Int_t& minY, Int_t& maxY,
80  Int_t& minZ, Int_t& maxZ) const;
81  void ComputeChisquareLambda();
82  bool IsExcluded(Int_t bin) const;
83 
84 protected:
85  Bool_t fFitDone; // flags whether a valid fit has been performed
86  Int_t fLowLimitX; // first bin in X dimension
87  Int_t fHighLimitX; // last bin in X dimension
88  Int_t fLowLimitY; // first bin in Y dimension
89  Int_t fHighLimitY; // last bin in Y dimension
90  Int_t fLowLimitZ; // first bin in Z dimension
91  Int_t fHighLimitZ; // last bin in Z dimension
92  std::vector<Int_t> fExcludedBins; // bins excluded from the fit
93 
94  Int_t fNpfits; // Number of points used in the fit
95  Int_t fNDF; // Number of degrees of freedom in the fit
96  Double_t fChisquare; // Template fit chisquare
97 
98  TObjArray fAji; // array of pointers to predictions of real template distributions
99 
100  // Histograms
101  TH1* fData; // pointer to the "data" histogram to be fitted to
102  TObjArray fMCs; // array of pointers to template histograms
103  TObjArray fWeights; // array of pointers to corresponding weight factors (may be null)
104  Double_t fIntegralData; // "data" histogram content integral over allowed fit range
105  Double_t* fIntegralMCs; // same for template histograms (weights not taken into account)
106  Double_t* fFractions; // template fractions scaled to the "data" histogram statistics
107  TH1* fPlot; // pointer to histogram containing summed template predictions
108  ROOT::Fit::Fitter *fFractionFitter; // pointer to Fitter class
109 
110  Int_t fNpar; // number of fit parameters
111 
112  ClassDef(TFractionFitter, 0); // Fits MC fractions to data histogram
113 };
114 
115 //
116 // TFractionFitFCN
117 //
118 // Computes negative log-likelihood for TFractionFitter
119 //
120 
121 void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
122 
123 #endif // ROOT_TFractionFitter
Double_t EvaluateFCN(const Double_t *par)
double par[1]
Definition: unuranDistr.cxx:38
Double_t fIntegralData
An array of TObjects.
Definition: TObjArray.h:39
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
const char Option_t
Definition: RtypesCore.h:62
std::vector< Int_t > fExcludedBins
void TFractionFitFCN(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:254
ROOT::Fit::Fitter * fFractionFitter
Fitter class, entry point for performing all type of fits.
Definition: Fitter.h:94
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:33
Double_t * fFractions
double f(double x)
double Double_t
Definition: RtypesCore.h:55
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
The TH1 histogram class.
Definition: TH1.h:80
Double_t * fIntegralMCs
Mother of all ROOT objects.
Definition: TObject.h:37
Fits MC fractions to data histogram.
RooCmdArg Constrain(const RooArgSet &params)