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#ifndef ROOT_HFitInterface
15#define ROOT_HFitInterface
16
17
18class TH1;
19class THnBase;
20class TF1;
21class TF2;
22class TGraph;
23class TGraphErrors;
24class TGraph2D;
25class TMultiGraph;
26struct Foption_t;
27
28#include "TFitResultPtr.h"
29
30namespace ROOT {
31
32 namespace Math {
33 class MinimizerOptions;
34 }
35
36 namespace Fit {
37
38 //class BinData;
39
40 class FitResult;
41 class DataRange;
42 class BinData;
43 class UnBinData;
44 class SparseData;
45
46 enum class EFitObjectType {
48 kGraph
49 };
50
51 enum class EChisquareType {
52 kNeyman = 0,
55 };
56
57
58
59 /**
60 Decode list of options into fitOption
61 */
62 void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption);
63
64 /**
65 fitting function for a TH1 (called from TH1::Fit)
66 */
68
69 /**
70 fitting function for a TGraph (called from TGraph::Fit)
71 */
73
74 /**
75 fitting function for a MultiGraph (called from TMultiGraph::Fit)
76 */
78
79 /**
80 fitting function for a TGraph2D (called from TGraph2D::Fit)
81 */
83
84 /**
85 fitting function for a THn / THnSparse (called from THnBase::Fit)
86 */
88
89
90 /**
91 fit an unbin data set (from tree or from histogram buffer)
92 using a TF1 pointer and fit options.
93 N.B. ownership of fit data is passed to the UnBinFit function which will be responsible of
94 deleting the data after the fit. User calling this function MUST NOT delete UnBinData after
95 calling it.
96 */
98
99 /**
100 fill the data vector from a TH1. Pass also the TF1 function which is
101 needed in case of integral option and to reject points rejected by the function
102 */
103 void FillData ( BinData & dv, const TH1 * hist, TF1 * func = nullptr);
104
105 /**
106 fill the data vector from a TH1 with sparse data. Pass also the TF1 function which is
107 needed in case of integral option and to reject points rejected by the function
108 */
109 void FillData ( SparseData & dv, const TH1 * hist, TF1 * func = nullptr);
110
111 /**
112 fill the data vector from a THnBase. Pass also the TF1 function which is
113 needed in case of integral option and to reject points rejected by the function
114 */
115 void FillData ( SparseData & dv, const THnBase * hist, TF1 * func = nullptr);
116
117 /**
118 fill the data vector from a THnBase. Pass also the TF1 function which is
119 needed in case of integral option and to reject points rejected by the function
120 */
121 void FillData ( BinData & dv, const THnBase * hist, TF1 * func = nullptr);
122
123 /**
124 fill the data vector from a TGraph2D. Pass also the TF1 function which is
125 needed in case of integral option and to reject points rejected by the function
126 */
127 void FillData ( BinData & dv, const TGraph2D * gr, TF1 * func = nullptr);
128
129
130 /**
131 fill the data vector from a TGraph. Pass also the TF1 function which is
132 needed in case to exclude points rejected by the function
133 */
134 void FillData ( BinData & dv, const TGraph * gr, TF1 * func = nullptr);
135 /**
136 fill the data vector from a TMultiGraph. Pass also the TF1 function which is
137 needed in case to exclude points rejected by the function
138 */
139 void FillData ( BinData & dv, const TMultiGraph * gr, TF1 * func = nullptr);
140
141
142 /**
143 compute initial parameter for an exponential function given the fit data
144 Set the constant and slope assuming a simple exponential going through xmin and xmax
145 of the data set
146 */
147 void InitExpo(const ROOT::Fit::BinData & data, TF1 * f1);
148
149
150 /**
151 compute initial parameter for gaussian function given the fit data
152 Set the sigma limits for zero top 10* initial rms values
153 Set the initial parameter values in the TF1
154 */
155 void InitGaus(const ROOT::Fit::BinData & data, TF1 * f1);
156
157 /**
158 compute initial parameter for 2D gaussian function given the fit data
159 Set the sigma limits for zero top 10* initial rms values
160 Set the initial parameter values in the TF1
161 */
162 void Init2DGaus(const ROOT::Fit::BinData & data, TF1 * f1);
163
164 /**
165 compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
166 */
167 bool GetConfidenceIntervals(const TH1 * h1, const ROOT::Fit::FitResult & r, TGraphErrors * gr, double cl = 0.95);
168
169 /**
170 compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
171 */
172 double Chisquare(const TH1 & h1, TF1 & f1, bool useRange, EChisquareType type);
173
174 /**
175 compute the chi2 value for a graph given a function (see TGraph::Chisquare)
176 */
177 double Chisquare(const TGraph & h1, TF1 & f1, bool useRange);
178
179
180 } // end namespace Fit
181
182} // end namespace ROOT
183
184
185#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:44
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:182
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:109
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:977
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:826
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