Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/HFitInterface.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/hist:$Id$
0002 // Author: L. Moneta Thu Aug 31 10:40:20 2006
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 // Header file for class HFitInterface
0012 // set of free functions used to couple the ROOT data object with the fitting classes
0013 
0014 // avoid including this file when running CINT since free functions cannot be re-defined
0015 
0016 #ifndef ROOT_HFitInterface
0017 #define ROOT_HFitInterface
0018 
0019 
0020 class TH1;
0021 class THnBase;
0022 class TF1;
0023 class TF2;
0024 class TGraph;
0025 class TGraphErrors;
0026 class TGraph2D;
0027 class TMultiGraph;
0028 struct Foption_t;
0029 
0030 #include "TFitResultPtr.h"
0031 
0032 namespace ROOT {
0033 
0034    namespace Math {
0035       class MinimizerOptions;
0036    }
0037 
0038    namespace Fit {
0039 
0040       //class BinData;
0041 
0042       class FitResult;
0043       class DataRange;
0044       class BinData;
0045       class UnBinData;
0046       class SparseData;
0047 
0048       enum class EFitObjectType {
0049          kHistogram,
0050          kGraph
0051       };
0052 
0053       enum class EChisquareType {
0054          kNeyman = 0,
0055          kPLikeRatio,
0056          kPearson
0057       };
0058 
0059 
0060 
0061       /**
0062          Decode list of options into fitOption
0063        */
0064       void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption);
0065 
0066       /**
0067          fitting function for a TH1 (called from TH1::Fit)
0068        */
0069       TFitResultPtr FitObject(TH1 * h1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
0070 
0071       /**
0072          fitting function for a TGraph (called from TGraph::Fit)
0073        */
0074       TFitResultPtr FitObject(TGraph * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
0075 
0076       /**
0077          fitting function for a MultiGraph (called from TMultiGraph::Fit)
0078        */
0079       TFitResultPtr FitObject(TMultiGraph * mg, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
0080 
0081       /**
0082          fitting function for a TGraph2D (called from TGraph2D::Fit)
0083        */
0084       TFitResultPtr FitObject(TGraph2D * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
0085 
0086       /**
0087          fitting function for a THn / THnSparse (called from THnBase::Fit)
0088        */
0089       TFitResultPtr FitObject(THnBase * s1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
0090 
0091 
0092       /**
0093           fit an unbin data set (from tree or from histogram buffer)
0094           using a TF1 pointer and fit options.
0095           N.B. ownership of fit data is passed to the UnBinFit function which will be responsible of
0096           deleting the data after the fit. User calling this function MUST NOT delete UnBinData after
0097           calling it.
0098       */
0099       TFitResultPtr UnBinFit(ROOT::Fit::UnBinData * data, TF1 * f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption);
0100 
0101       /**
0102           fill the data vector from a TH1. Pass also the TF1 function which is
0103           needed in case of integral option and to reject points rejected by the function
0104       */
0105       void FillData ( BinData  & dv, const TH1 * hist, TF1 * func = nullptr);
0106 
0107       /**
0108           fill the data vector from a TH1 with sparse data. Pass also the TF1 function which is
0109           needed in case of integral option and to reject points rejected by the function
0110       */
0111       void FillData ( SparseData  & dv, const TH1 * hist, TF1 * func = nullptr);
0112 
0113       /**
0114           fill the data vector from a THnBase. Pass also the TF1 function which is
0115           needed in case of integral option and to reject points rejected by the function
0116       */
0117       void FillData ( SparseData  & dv, const THnBase * hist, TF1 * func = nullptr);
0118 
0119       /**
0120           fill the data vector from a THnBase. Pass also the TF1 function which is
0121           needed in case of integral option and to reject points rejected by the function
0122       */
0123       void FillData ( BinData  & dv, const THnBase * hist, TF1 * func = nullptr);
0124 
0125       /**
0126           fill the data vector from a TGraph2D. Pass also the TF1 function which is
0127           needed in case of integral option and to reject points rejected by the function
0128       */
0129       void FillData ( BinData  & dv, const TGraph2D * gr, TF1 * func = nullptr);
0130 
0131 
0132       /**
0133           fill the data vector from a TGraph. Pass also the TF1 function which is
0134           needed in case to exclude points rejected by the function
0135       */
0136       void FillData ( BinData  & dv, const TGraph * gr, TF1 * func = nullptr);
0137       /**
0138           fill the data vector from a TMultiGraph. Pass also the TF1 function which is
0139           needed in case to exclude points rejected by the function
0140       */
0141       void FillData ( BinData  & dv, const TMultiGraph * gr,  TF1 * func = nullptr);
0142 
0143 
0144       /**
0145           compute initial parameter for an exponential function given the fit data
0146           Set the constant and slope assuming a simple exponential going through xmin and xmax
0147           of the data set
0148        */
0149       void InitExpo(const ROOT::Fit::BinData & data, TF1 * f1);
0150 
0151 
0152       /**
0153           compute initial parameter for gaussian function given the fit data
0154           Set the sigma limits for zero top 10* initial rms values
0155           Set the initial parameter values in the TF1
0156        */
0157       void InitGaus(const ROOT::Fit::BinData & data, TF1 * f1);
0158 
0159       /**
0160           compute initial parameter for 2D gaussian function given the fit data
0161           Set the sigma limits for zero top 10* initial rms values
0162           Set the initial parameter values in the TF1
0163        */
0164       void Init2DGaus(const ROOT::Fit::BinData & data, TF1 * f1);
0165 
0166       /**
0167          compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
0168       */
0169       bool GetConfidenceIntervals(const TH1 * h1, const ROOT::Fit::FitResult & r, TGraphErrors * gr, double cl = 0.95);
0170 
0171       /**
0172          compute the chi2 value for an histogram given a function  (see TH1::Chisquare for the documentation)
0173       */
0174       double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type);
0175 
0176       /**
0177          compute the chi2 value for a graph given a function (see TGraph::Chisquare)
0178       */
0179       double Chisquare(const TGraph & h1, TF1 & f1, bool useRange);
0180 
0181 
0182    } // end namespace Fit
0183 
0184 } // end namespace ROOT
0185 
0186 
0187 #endif /* ROOT_Fit_TH1Interface */