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 /**
62 Decode list of options into fitOption
63 */
64 void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption);
65
66 /**
67 fitting function for a TH1 (called from TH1::Fit)
68 */
69 TFitResultPtr FitObject(TH1 * h1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
70
71 /**
72 fitting function for a TGraph (called from TGraph::Fit)
73 */
74 TFitResultPtr FitObject(TGraph * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
75
76 /**
77 fitting function for a MultiGraph (called from TMultiGraph::Fit)
78 */
79 TFitResultPtr FitObject(TMultiGraph * mg, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
80
81 /**
82 fitting function for a TGraph2D (called from TGraph2D::Fit)
83 */
84 TFitResultPtr FitObject(TGraph2D * gr, TF1 *f1 , Foption_t & option , const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
85
86 /**
87 fitting function for a THn / THnSparse (called from THnBase::Fit)
88 */
89 TFitResultPtr FitObject(THnBase * s1, TF1 *f1, Foption_t & option, const ROOT::Math::MinimizerOptions & moption, const char *goption, ROOT::Fit::DataRange & range);
90
91
92 /**
93 fit an unbin data set (from tree or from histogram buffer)
94 using a TF1 pointer and fit options.
95 N.B. ownership of fit data is passed to the UnBinFit function which will be responsible of
96 deleting the data after the fit. User calling this function MUST NOT delete UnBinData after
97 calling it.
98 */
100
101 /**
102 fill the data vector from a TH1. Pass also the TF1 function which is
103 needed in case of integral option and to reject points rejected by the function
104 */
105 void FillData ( BinData & dv, const TH1 * hist, TF1 * func = nullptr);
106
107 /**
108 fill the data vector from a TH1 with sparse data. Pass also the TF1 function which is
109 needed in case of integral option and to reject points rejected by the function
110 */
111 void FillData ( SparseData & dv, const TH1 * hist, TF1 * func = nullptr);
112
113 /**
114 fill the data vector from a THnBase. Pass also the TF1 function which is
115 needed in case of integral option and to reject points rejected by the function
116 */
117 void FillData ( SparseData & dv, const THnBase * hist, TF1 * func = nullptr);
118
119 /**
120 fill the data vector from a THnBase. Pass also the TF1 function which is
121 needed in case of integral option and to reject points rejected by the function
122 */
123 void FillData ( BinData & dv, const THnBase * hist, TF1 * func = nullptr);
124
125 /**
126 fill the data vector from a TGraph2D. Pass also the TF1 function which is
127 needed in case of integral option and to reject points rejected by the function
128 */
129 void FillData ( BinData & dv, const TGraph2D * gr, TF1 * func = nullptr);
130
131
132 /**
133 fill the data vector from a TGraph. Pass also the TF1 function which is
134 needed in case to exclude points rejected by the function
135 */
136 void FillData ( BinData & dv, const TGraph * gr, TF1 * func = nullptr);
137 /**
138 fill the data vector from a TMultiGraph. Pass also the TF1 function which is
139 needed in case to exclude points rejected by the function
140 */
141 void FillData ( BinData & dv, const TMultiGraph * gr, TF1 * func = nullptr);
142
143
144 /**
145 compute initial parameter for an exponential function given the fit data
146 Set the constant and slope assuming a simple exponential going through xmin and xmax
147 of the data set
148 */
149 void InitExpo(const ROOT::Fit::BinData & data, TF1 * f1);
150
151
152 /**
153 compute initial parameter for gaussian function given the fit data
154 Set the sigma limits for zero top 10* initial rms values
155 Set the initial parameter values in the TF1
156 */
157 void InitGaus(const ROOT::Fit::BinData & data, TF1 * f1);
158
159 /**
160 compute initial parameter for 2D gaussian function given the fit data
161 Set the sigma limits for zero top 10* initial rms values
162 Set the initial parameter values in the TF1
163 */
164 void Init2DGaus(const ROOT::Fit::BinData & data, TF1 * f1);
165
166 /**
167 compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
168 */
169 bool GetConfidenceIntervals(const TH1 * h1, const ROOT::Fit::FitResult & r, TGraphErrors * gr, double cl = 0.95);
170
171 /**
172 compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
173 */
174 double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type);
175
176 /**
177 compute the chi2 value for a graph given a function (see TGraph::Chisquare)
178 */
179 double Chisquare(const TGraph & h1, TF1 & f1, bool useRange);
180
181
182 } // end namespace Fit
183
184} // end namespace ROOT
185
186
187#endif /* ROOT_Fit_TH1Interface */
#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:59
Multidimensional histogram base.
Definition THnBase.h:45
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:973
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:822
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
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...