TFractionFitter.h

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: TFractionFitter.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Frank Filthaut filthaut@hef.kun.nl  20/05/2002
00003    
00004 #ifndef ROOT_TFractionFitter
00005 #define ROOT_TFractionFitter
00006 
00007 #ifndef ROOT_TVirtualFitter
00008 # include "TVirtualFitter.h"
00009 #endif
00010 #ifndef ROOT_TObjArray
00011 # include "TObjArray.h"
00012 #endif
00013 
00014 class TH1;
00015 
00016 ///////////////////////////////////////////////////////////////////////////////
00017 // TFractionFitter
00018 //
00019 // Fits MC fractions to data histogram (a la HMCMLL, see R. Barlow and C. Beeston,
00020 // Comp. Phys. Comm. 77 (1993) 219-228, and http://www.hep.man.ac.uk/~roger/hfrac.f).
00021 // 
00022 ///////////////////////////////////////////////////////////////////////////////
00023 
00024 class TFractionFitter: public TObject {
00025 public:
00026    TFractionFitter();
00027    TFractionFitter(TH1* data, TObjArray *MCs);
00028    virtual ~TFractionFitter();
00029 
00030    TVirtualFitter* GetFitter() const;
00031    void ErrorAnalysis(Double_t UP);
00032    void SetRangeX(Int_t low, Int_t high);
00033    void ReleaseRangeX();
00034    void SetRangeY(Int_t low, Int_t high);
00035    void ReleaseRangeY();
00036    void SetRangeZ(Int_t low, Int_t high);
00037    void ReleaseRangeZ();
00038    void Constrain(Int_t parm, Double_t low, Double_t high);
00039    void UnConstrain(Int_t parm);
00040    void SetData(TH1 *data);
00041    void SetMC(Int_t parm, TH1 *MC);
00042    void SetWeight(Int_t parm, TH1* weight);
00043    Int_t Fit();
00044 
00045    void GetResult(Int_t parm, Double_t& value, Double_t& error) const;
00046    TH1* GetPlot();
00047 
00048    // This global function needs access to computeFCN()
00049    friend void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
00050 
00051    // Goodness of fit
00052    Double_t GetChisquare() const;
00053    Int_t GetNDF() const;
00054    Double_t GetProb() const;
00055 
00056    // MC predictions (smeared templates)
00057    TH1* GetMCPrediction(Int_t parm) const;
00058 
00059 private:
00060    void CheckParNo(Int_t parm) const;
00061    void CheckConsistency();
00062    void FindPrediction(int bin, double* fractions, double& Ti, int& k0, double& Aki) const;
00063    void ComputeFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
00064    void GetRanges(Int_t& minX, Int_t& maxX, Int_t& minY, Int_t& maxY,
00065                   Int_t& minZ, Int_t& maxZ) const;
00066    void ComputeChisquareLambda();
00067 
00068 protected:
00069    Bool_t   fFitDone;             // flags whether a valid fit has been performed
00070    Int_t    fLowLimitX;           // first bin in X dimension
00071    Int_t    fHighLimitX;          // last  bin in X dimension
00072    Int_t    fLowLimitY;           // first bin in Y dimension
00073    Int_t    fHighLimitY;          // last  bin in Y dimension
00074    Int_t    fLowLimitZ;           // first bin in Z dimension
00075    Int_t    fHighLimitZ;          // last  bin in Z dimension
00076 
00077    Int_t    fNpfits;              // Number of points used in the fit
00078    Int_t    fNDF;                 // Number of degrees of freedom in the fit
00079    Double_t fChisquare;           // Template fit chisquare
00080 
00081    TObjArray fAji;                // array of pointers to predictions of real template distributions
00082 
00083    // Histograms
00084    TH1*      fData;               // pointer to the "data" histogram to be fitted to
00085    TObjArray fMCs;                // array of pointers to template histograms
00086    TObjArray fWeights;            // array of pointers to corresponding weight factors (may be null)
00087    Double_t  fIntegralData;       // "data" histogram content integral over allowed fit range
00088    Double_t* fIntegralMCs;        // same for template histograms (weights not taken into account)
00089    Double_t* fFractions;          // template fractions scaled to the "data" histogram statistics
00090    TH1*      fPlot;               // pointer to histogram containing summed template predictions
00091 
00092    Int_t     fNpar;               // number of fit parameters
00093 
00094    ClassDef(TFractionFitter, 0)   // Fits MC fractions to data histogram
00095 };
00096 
00097 //
00098 //  TFractionFitFCN
00099 //
00100 //  Computes negative log-likelihood for TFractionFitter
00101 //
00102 
00103 void TFractionFitFCN(Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t flag);
00104 
00105 #endif // ROOT_TFractionFitter

Generated on Tue Jul 5 14:22:49 2011 for ROOT_528-00b_version by  doxygen 1.5.1