Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
HFitInterface.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: L. Moneta Thu Aug 31 10:40:20 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11// Header file for class HFitInterface
12// set of free functions used to couple the ROOT data object with the fitting classes
13
14// avoid including this file when running CINT since free functions cannot be re-defined
15
16#ifndef ROOT_HFitInterface
17#define ROOT_HFitInterface
18
19
20class TH1;
21class THnBase;
22class TF1;
23class TF2;
24class TGraph;
25class TGraphErrors;
26class TGraph2D;
27class TMultiGraph;
28struct Foption_t;
29
30#include "TFitResultPtr.h"
31
32namespace ROOT {
33
34 namespace Math {
35 class MinimizerOptions;
36 }
37
38 namespace Fit {
39
40 //class BinData;
41
42 class FitResult;
43 class DataRange;
44 class BinData;
45 class UnBinData;
46 class SparseData;
47
48 enum class EFitObjectType {
50 kGraph
51 };
52
53 enum class EChisquareType {
54 kNeyman = 0,
57 };
58
59
60
61 //#ifndef __CINT__ // does not link on Windows (why ??)
62
63 /**
64 Decode list of options into fitOption
65 */
66 void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption);
67
68 /**
69 fitting function for a TH1 (called from TH1::Fit)
70 */
71 TFitResultPtr FitObject(TH1 * h1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
72
73 /**
74 fitting function for a TGraph (called from TGraph::Fit)
75 */
76 TFitResultPtr FitObject(TGraph * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
77
78 /**
79 fitting function for a MultiGraph (called from TMultiGraph::Fit)
80 */
81 TFitResultPtr FitObject(TMultiGraph * mg, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
82
83 /**
84 fitting function for a TGraph2D (called from TGraph2D::Fit)
85 */
86 TFitResultPtr FitObject(TGraph2D * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
87
88 /**
89 fitting function for a THn / THnSparse (called from THnBase::Fit)
90 */
91 TFitResultPtr FitObject(THnBase * s1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
92
93
94 /**
95 fit an unbin data set (from tree or from histogram buffer)
96 using a TF1 pointer and fit options.
97 N.B. ownership of fit data is passed to the UnBinFit function which will be responsible of
98 deleting the data after the fit. User calling this function MUST NOT delete UnBinData after
99 calling it.
100 */
102
103 /**
104 fill the data vector from a TH1. Pass also the TF1 function which is
105 needed in case of integral option and to reject points rejected by the function
106 */
107 void FillData ( BinData & dv, const TH1 * hist, TF1 * func = nullptr);
108
109 /**
110 fill the data vector from a TH1 with sparse data. Pass also the TF1 function which is
111 needed in case of integral option and to reject points rejected by the function
112 */
113 void FillData ( SparseData & dv, const TH1 * hist, TF1 * func = nullptr);
114
115 /**
116 fill the data vector from a THnBase. Pass also the TF1 function which is
117 needed in case of integral option and to reject points rejected by the function
118 */
119 void FillData ( SparseData & dv, const THnBase * hist, TF1 * func = nullptr);
120
121 /**
122 fill the data vector from a THnBase. Pass also the TF1 function which is
123 needed in case of integral option and to reject points rejected by the function
124 */
125 void FillData ( BinData & dv, const THnBase * hist, TF1 * func = nullptr);
126
127 /**
128 fill the data vector from a TGraph2D. Pass also the TF1 function which is
129 needed in case of integral option and to reject points rejected by the function
130 */
131 void FillData ( BinData & dv, const TGraph2D * gr, TF1 * func = nullptr);
132
133
134 /**
135 fill the data vector from a TGraph. Pass also the TF1 function which is
136 needed in case to exclude points rejected by the function
137 */
138 void FillData ( BinData & dv, const TGraph * gr, TF1 * func = nullptr);
139 /**
140 fill the data vector from a TMultiGraph. Pass also the TF1 function which is
141 needed in case to exclude points rejected by the function
142 */
143 void FillData ( BinData & dv, const TMultiGraph * gr, TF1 * func = nullptr);
144
145
146 /**
147 compute initial parameter for an exponential function given the fit data
148 Set the constant and slope assuming a simple exponential going through xmin and xmax
149 of the data set
150 */
151 void InitExpo(const ROOT::Fit::BinData & data, TF1 * f1);
152
153
154 /**
155 compute initial parameter for gaussian function given the fit data
156 Set the sigma limits for zero top 10* initial rms values
157 Set the initial parameter values in the TF1
158 */
159 void InitGaus(const ROOT::Fit::BinData & data, TF1 * f1);
160
161 /**
162 compute initial parameter for 2D gaussian function given the fit data
163 Set the sigma limits for zero top 10* initial rms values
164 Set the initial parameter values in the TF1
165 */
166 void Init2DGaus(const ROOT::Fit::BinData & data, TF1 * f1);
167
168 /**
169 compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
170 */
171 bool GetConfidenceIntervals(const TH1 * h1, const ROOT::Fit::FitResult & r, TGraphErrors * gr, double cl = 0.95);
172
173 /**
174 compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
175 */
176 double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type);
177
178 /**
179 compute the chi2 value for a graph given a function (see TGraph::Chisquare)
180 */
181 double Chisquare(const TGraph & h1, TF1 & f1, bool useRange);
182
183
184 } // end namespace Fit
185
186} // end namespace ROOT
187
188
189#endif /* ROOT_Fit_TH1Interface */
190
191
192//#endif /* not CINT OR MAKE_CINT */
#define s1(x)
Definition RSha256.hxx:91
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 char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Definition BinData.h:52
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition DataRange.h:35
class containing the result of the fit and all the related information (fitted parameter values,...
Definition FitResult.h:47
SparseData class representing the data of a THNSparse histogram The data needs to be converted to a B...
Definition SparseData.h:35
Class describing the un-binned data sets (just x coordinates values) of any dimensions.
Definition UnBinData.h:46
1-Dim function class
Definition TF1.h:233
A 2-Dim function with parameters.
Definition TF2.h:29
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition TGraph2D.h:41
A TGraphErrors is a TGraph with error bars.
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
Multidimensional histogram base.
Definition THnBase.h:43
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
TGraphErrors * gr
Definition legend1.C:25
TH1F * h1
Definition legend1.C:5
TF1 * f1
Definition legend1.C:11
Namespace for new Math classes and functions.
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
Definition HFitImpl.cxx:972
double Chisquare(const TH1 &h1, TF1 &f1, bool useRange, EChisquareType type)
compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Definition HFitImpl.cxx:685
void Init2DGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for 2D gaussian function given the fit data Set the sigma limits for zero t...
TFitResultPtr UnBinFit(ROOT::Fit::UnBinData *data, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption)
fit an unbin data set (from tree or from histogram buffer) using a TF1 pointer and fit options.
Definition HFitImpl.cxx:821
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.
void InitExpo(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for an exponential function given the fit data Set the constant and slope a...
void InitGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for gaussian function given the fit data Set the sigma limits for zero top ...
bool GetConfidenceIntervals(const TH1 *h1, const ROOT::Fit::FitResult &r, TGraphErrors *gr, double cl=0.95)
compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.