Logo ROOT  
Reference Guide
TFitEditor.h
Go to the documentation of this file.
1// @(#)root/fitpanel:$Id$
2// Author: Ilka Antcheva, Lorenzo Moneta, David Gonzalez Maline 10/08/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TFitEditor
13#define ROOT_TFitEditor
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TFitEditor //
18// //
19// Allows to explore and compare various fits. //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TGFrame.h"
24#include "TGButton.h"
25
26#include "Foption.h"
28#include "Fit/DataRange.h"
29
30
31
32#include <vector>
33#include <map>
34#include <utility>
35
36//--- Object types
44};
45
46
47class TGTab;
48class TVirtualPad;
49class TCanvas;
50class TGLabel;
51class TGComboBox;
52class TGTextEntry;
53class TGNumberEntry;
54class TGDoubleHSlider;
55class TGNumberEntry;
57class TGStatusBar;
58class TAxis;
59class TF1;
60class TF1NormSum;
61class TF1Convolution;
62
63
64class TFitEditor : public TGMainFrame {
65
66protected:
67 TGTab *fTab; // tab widget holding the editor
68 TGCompositeFrame *fTabContainer; // main tab container
69 TGCompositeFrame *fGeneral; // general tab
70 TGCompositeFrame *fMinimization; // minimization tab
71 TGTextButton *fUpdateButton; // updates data from gROOT and gDirectory
72 TGTextButton *fFitButton; // performs fitting
73 TGTextButton *fResetButton; // resets fit parameters
74 TGTextButton *fCloseButton; // close the fit panel
75 TGLabel *fSelLabel; // contains selected fit function
76 TGComboBox *fDataSet; // contains list of data set to be fitted
77 TGComboBox *fTypeFit; // contains the types of functions to be selected
78 TGComboBox *fFuncList; // contains function list
79 TGTextEntry *fEnteredFunc; // contains user function file name
80 TGTextButton *fUserButton; // opens a dialog for user-defined fit method
81 TGRadioButton *fNone; // set no operation mode
82 TGRadioButton *fAdd; // set addition mode
83 TGRadioButton *fNormAdd; // set normalized addition mode
84 TGRadioButton *fConv; // set convolution mode
85 TGLayoutHints *fLayoutNone; // layout hints of fNone radio button
86 TGLayoutHints *fLayoutAdd; // layout hints of fAdd radio button
87 TGLayoutHints *fLayoutNormAdd; // layout hints of fNOrmAdd radio button
88 TGLayoutHints *fLayoutConv; // layout hints of fConv radio button
89 TGTextButton *fSetParam; // open set parameters dialog
90 TGCheckButton *fIntegral; // switch on/off option 'integral'
91 TGCheckButton *fBestErrors; // switch on/off option 'improve errors'
92 TGCheckButton *fUseRange; // switch on/off option 'use function range'
93 TGCheckButton *fAdd2FuncList; // switch on/off option 'add to list'
94 TGCheckButton *fUseGradient ; // switch on/off option 'use gradient'
95 TGCheckButton *fAllWeights1; // switch on/off option 'all weights=1'
96 TGCheckButton *fImproveResults; // switch on/off option 'improve fit results'
97 TGCheckButton *fEmptyBinsWghts1; // switch on/off option 'include empry bins'
98 TGComboBox *fMethodList; // contains method list
99 TGCheckButton *fLinearFit; // switch on/off linear fit option
100 TGCheckButton *fNoChi2; // switch on/off option 'No Chi-square'
101 TGCheckButton *fNoStoreDrawing; // switch on/off 'no store/drwing' option
102 TGCheckButton *fNoDrawing; // switch on/off 'no drawing' option
103 TGCheckButton *fDrawSame; // switch on/off fit function drawing
104 TGTextButton *fDrawAdvanced; // opens a dialog for advanced draw options
105 TGDoubleHSlider *fSliderX; // slider to set fit range along x-axis
106 TGNumberEntry *fSliderXMax; // entry to set the maximum in the range
107 TGNumberEntry *fSliderXMin; // entry to set the minumum in the range
108 TGDoubleHSlider *fSliderY; // slider to set fit range along y-axis
109 TGNumberEntry *fSliderYMax; // entry to set the maximum in the range
110 TGNumberEntry *fSliderYMin; // entry to set the minumum in the range
111 TGDoubleHSlider *fSliderZ; // slider to set fit range along z-axis
112 TGHorizontalFrame *fSliderXParent; // parent of fSliderX
113 TGHorizontalFrame *fSliderYParent; // parent of fSliderY
114 TGHorizontalFrame *fSliderZParent; // parent of fSliderZ
115 TGCheckButton *fEnableRobust; // switch on/off robust option
116 TGNumberEntry *fRobustValue; // contains robust value for linear fit
117 TGRadioButton *fOptDefault; // set default printing mode
118 TGRadioButton *fOptVerbose; // set printing mode to 'Verbose'
119 TGRadioButton *fOptQuiet; // set printing mode to 'Quiet'
120 TVirtualPad *fParentPad; // pad containing the object
121 TObject *fFitObject; // selected object to fit
122 EObjectType fType; // object type info
123 Int_t fDim; // object dimension
124 TAxis *fXaxis; // x-axis
125 TAxis *fYaxis; // y-axis
126 TAxis *fZaxis; // z-axis
127 TF1NormSum *fSumFunc; //! TF1NormSum object
128 TF1Convolution *fConvFunc; //! TF1Convolution object
129
130 // structure holding parameter value and limits
133 fP[0] = 0; fP[1] = 0; fP[2] = 0;
134 }
135 Double_t & operator[](UInt_t i) { return fP[i];}
137 };
138 std::vector<FuncParamData_t> fFuncPars; // function parameters (value + limits)
139
140 std::multimap<TObject*, TF1*> fPrevFit; // Previous successful fits.
141 std::vector<TF1*> fSystemFuncs; // functions managed by the fitpanel
142
143 TGRadioButton *fLibMinuit; // set default minimization library (Minuit)
144 TGRadioButton *fLibMinuit2; // set Minuit2 as minimization library
145 TGRadioButton *fLibFumili; // set Fumili as minimization library
146 TGRadioButton *fLibGSL; // set GSL as minimization library
147 TGRadioButton *fLibGenetics; // set Genetic/GALib as minimization library
148 TGComboBox *fMinMethodList; // set the minimization method
149 TGNumberEntryField *fErrorScale; // contains error scale set for minimization
150 TGNumberEntryField *fTolerance; // contains tolerance set for minimization
151 TGNumberEntryField *fIterations; // contains maximum number of iterations
152
153 TGStatusBar *fStatusBar; // statusbar widget
154
155 Bool_t fChangedParams; // flag to indicate if the parameters have been set in the ParameterDialog GUI
156
157 static TFitEditor *fgFitDialog; // singleton fit panel
158
159protected:
161 void ProcessTreeInput(TObject* objSelected, Int_t selected,
163 TF1* FindFunction();
164 void FillDataSetList();
169 void DrawSelection(bool restore = false);
170 Int_t CheckFunctionString(const char* str);
171 void CreateFunctionGroup();
172 void CreateGeneralTab();
174 void MakeTitle(TGCompositeFrame *parent, const char *title);
176 void SetEditable(Bool_t);
177
178private:
179 TFitEditor(const TFitEditor&); // not implemented
180 TFitEditor& operator=(const TFitEditor&); // not implemented
181
183
184public:
185 TFitEditor(TVirtualPad* pad, TObject *obj);
186 virtual ~TFitEditor();
187
189
190 static TFitEditor *GetInstance(TVirtualPad* pad = 0, TObject *obj = 0);
191 virtual Option_t *GetDrawOption() const;
192 virtual void Hide();
193 virtual void Show(TVirtualPad* pad, TObject *obj);
194
195 void ShowObjectName(TObject* obj);
197 virtual void Terminate();
198 void UpdateGUI();
199
200 virtual void CloseWindow();
201 virtual void ConnectSlots();
202 virtual void DisconnectSlots();
203 virtual void RecursiveRemove(TObject* obj);
204
205protected:
206 virtual void SetCanvas(TCanvas *c);
207
208public:
209 virtual void SetFitObject(TVirtualPad *pad, TObject *obj, Int_t event);
210 virtual void SetFunction(const char *function);
211
212 // slot methods 'General' tab
213 void FillFunctionList(Int_t selected = -1);
214 void FillMinMethodList(Int_t selected = -1);
215 virtual void DoAddition(Bool_t on);
216 virtual void DoNormAddition(Bool_t on);
217 virtual void DoConvolution(Bool_t on);
218 virtual void DoAdvancedOptions();
219 virtual void DoAllWeights1();
220 virtual void DoClose();
221 virtual void DoEmptyBinsAllWeights1();
222 virtual void DoEnteredFunction();
223 virtual void DoUpdate();
224 virtual void DoFit();
225 virtual void DoMaxIterations();
226 virtual void DoDataSet(Int_t sel);
227 virtual void DoFunction(Int_t sel);
228 virtual void DoLinearFit();
229 virtual void DoNoChi2();
230 virtual void DoNoSelection();
231 virtual void DoNoStoreDrawing();
232 virtual void DoReset();
233 virtual void DoRobustFit();
234 virtual void DoSetParameters();
235 virtual void DoSliderXMoved();
236 virtual void DoNumericSliderXChanged();
237 virtual void DoSliderYMoved();
238 virtual void DoNumericSliderYChanged();
239 virtual void DoSliderZMoved();
240 virtual void DoUserDialog();
241 virtual void DoUseFuncRange();
242
243 // slot methods 'Minimization' tab
244 virtual void DoLibrary(Bool_t on);
245 virtual void DoMinMethod(Int_t );
246 virtual void DoPrintOpt(Bool_t on);
247
248public:
249 typedef std::vector<FuncParamData_t > FuncParams_t;
250
252 ClassDef(TFitEditor,0) //Fit Panel interface
253};
254
255#endif
#define c(i)
Definition: RSha256.hxx:101
double Double_t
Definition: RtypesCore.h:57
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
EObjectType
Definition: TFitEditor.h:37
@ kObjectMultiGraph
Definition: TFitEditor.h:43
@ kObjectGraph
Definition: TFitEditor.h:39
@ kObjectHStack
Definition: TFitEditor.h:41
@ kObjectHisto
Definition: TFitEditor.h:38
@ kObjectGraph2D
Definition: TFitEditor.h:40
@ kObjectTree
Definition: TFitEditor.h:42
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition: DataRange.h:34
Class to manage histogram axis.
Definition: TAxis.h:30
The Canvas class.
Definition: TCanvas.h:27
Class wrapping convolution of two functions.
Class adding two functions: c1*f1+c2*f2.
Definition: TF1NormSum.h:19
1-Dim function class
Definition: TF1.h:210
TGCheckButton * fBestErrors
Definition: TFitEditor.h:91
TF1 * FindFunction()
This method looks among the functions stored by the fitpanel, the one that is currently selected in t...
Definition: TFitEditor.cxx:185
TGDoubleHSlider * fSliderX
Definition: TFitEditor.h:105
TFitEditor(const TFitEditor &)
TGComboBox * fMinMethodList
Definition: TFitEditor.h:148
TGTextButton * fSetParam
Definition: TFitEditor.h:89
void CreateGeneralTab()
Create 'General' tab.
Definition: TFitEditor.cxx:662
virtual void DoUpdate()
Easy here!
TGLayoutHints * fLayoutNormAdd
Definition: TFitEditor.h:87
TGNumberEntry * fSliderXMax
Definition: TFitEditor.h:106
virtual void DoConvolution(Bool_t on)
Slot connected to addition of predefined functions.
TGNumberEntry * fSliderXMin
Definition: TFitEditor.h:107
virtual void SetFitObject(TVirtualPad *pad, TObject *obj, Int_t event)
Slot called when the user clicks on an object inside a canvas.
virtual void DoEnteredFunction()
Slot connected to entered function in text entry.
virtual void DoNormAddition(Bool_t on)
Slot connected to addition of predefined functions.
virtual void DoPrintOpt(Bool_t on)
Slot connected to print option settings.
std::vector< TF1 * > fSystemFuncs
Definition: TFitEditor.h:141
TGCheckButton * fDrawSame
Definition: TFitEditor.h:103
TGRadioButton * fLibMinuit
Definition: TFitEditor.h:143
TGRadioButton * fConv
Definition: TFitEditor.h:84
TVirtualPad * fParentPad
Definition: TFitEditor.h:120
TGRadioButton * fOptDefault
Definition: TFitEditor.h:117
TGCheckButton * fLinearFit
Definition: TFitEditor.h:99
TGRadioButton * fLibMinuit2
Definition: TFitEditor.h:144
virtual void DoMinMethod(Int_t)
Set selected minimization method in use.
TF1 * HasFitFunction()
Look in the list of function for TF1.
void UpdateGUI()
Set the fit panel GUI according to the selected object.
TGCheckButton * fUseRange
Definition: TFitEditor.h:92
virtual void DoSliderXMoved()
Slot connected to range settings on x-axis.
TAxis * fYaxis
Definition: TFitEditor.h:125
TGTextButton * fDrawAdvanced
Definition: TFitEditor.h:104
TGComboBox * fTypeFit
Definition: TFitEditor.h:77
virtual void DoReset()
Reset all fit parameters.
TGNumberEntryField * fTolerance
Definition: TFitEditor.h:150
TGCheckButton * fNoDrawing
Definition: TFitEditor.h:102
TF1 * GetFitFunction()
void SetEditable(Bool_t)
Switch ON/OFF edit mode.
TGHorizontalFrame * fSliderZParent
Definition: TFitEditor.h:114
virtual void DoSetParameters()
Open set parameters dialog.
TGCompositeFrame * fMinimization
Definition: TFitEditor.h:70
TGTab * fTab
Definition: TFitEditor.h:67
virtual void DoLinearFit()
Slot connected to linear fit settings.
void FillFunctionList(Int_t selected=-1)
Fills the list of functions depending on the type of fit selected.
virtual void Show(TVirtualPad *pad, TObject *obj)
Show the fit panel (possible only via context menu).
virtual void DoNumericSliderYChanged()
syncronize the numeric slider with the graphical one.
virtual void DoClose()
Close the fit panel.
TF1NormSum * fSumFunc
Definition: TFitEditor.h:127
TGComboBox * fMethodList
Definition: TFitEditor.h:98
TGDoubleHSlider * fSliderY
Definition: TFitEditor.h:108
void ShowObjectName(TObject *obj)
Show object name on the top.
friend class FitEditorUnitTesting
Definition: TFitEditor.h:251
static TFitEditor * fgFitDialog
Definition: TFitEditor.h:157
virtual void RecursiveRemove(TObject *obj)
When obj is deleted, clear fFitObject if fFitObject = obj.
TList * GetFitObjectListOfFunctions()
virtual void DoAdvancedOptions()
Slot connected to advanced option button (opens a dialog).
TGRadioButton * fLibFumili
Definition: TFitEditor.h:145
virtual void DoDataSet(Int_t sel)
Selects the data set to be fitted.
TGRadioButton * fAdd
Definition: TFitEditor.h:82
TGComboBox * BuildMethodList(TGFrame *parent, Int_t id)
Create method list in a combo box.
void CreateMinimizationTab()
Create 'Minimization' tab.
Definition: TFitEditor.cxx:901
TGRadioButton * fLibGenetics
Definition: TFitEditor.h:147
TGCheckButton * fImproveResults
Definition: TFitEditor.h:96
TGComboBox * fFuncList
Definition: TFitEditor.h:78
TF1Convolution * fConvFunc
TF1NormSum object.
Definition: TFitEditor.h:128
TGCheckButton * fUseGradient
Definition: TFitEditor.h:94
TGRadioButton * fNormAdd
Definition: TFitEditor.h:83
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
virtual void SetCanvas(TCanvas *c)
Connect to another canvas.
EObjectType fType
Definition: TFitEditor.h:122
TGNumberEntryField * fIterations
Definition: TFitEditor.h:151
TGCompositeFrame * fTabContainer
Definition: TFitEditor.h:68
virtual void DoFunction(Int_t sel)
Slot connected to predefined fit function settings.
virtual void DoUseFuncRange()
virtual ~TFitEditor()
Fit editor destructor.
Definition: TFitEditor.cxx:507
TGComboBox * fDataSet
Definition: TFitEditor.h:76
virtual void ConnectSlots()
Connect GUI signals to fit panel slots.
virtual void DoFit()
Perform a fit with current parameters' settings.
TAxis * fZaxis
Definition: TFitEditor.h:126
TGRadioButton * fOptVerbose
Definition: TFitEditor.h:118
virtual void SetFunction(const char *function)
Set the function to be used in performed fit.
virtual void Terminate()
Called to delete the fit panel.
TGTextButton * fUserButton
Definition: TFitEditor.h:80
TGDoubleHSlider * fSliderZ
Definition: TFitEditor.h:111
TGTextButton * fFitButton
Definition: TFitEditor.h:72
virtual void DoMaxIterations()
Set the maximum number of iterations.
virtual void DoLibrary(Bool_t on)
Set selected minimization library in use.
void FillDataSetList()
Create a combo box with all the possible objects to be fitted.
virtual void DoEmptyBinsAllWeights1()
Slot connected to 'include emtry bins and forse all weights to 1' setting.
virtual void DoSliderYMoved()
Slot connected to range settings on y-axis.
void RetrieveOptions(Foption_t &, TString &, ROOT::Math::MinimizerOptions &, Int_t)
Retrieve the fitting options from all the widgets.
std::vector< FuncParamData_t > fFuncPars
Definition: TFitEditor.h:138
TGHorizontalFrame * fSliderYParent
Definition: TFitEditor.h:113
TGCheckButton * fNoChi2
Definition: TFitEditor.h:100
virtual void DoNoStoreDrawing()
Slot connected to 'no storing, no drawing' settings.
void MakeTitle(TGCompositeFrame *parent, const char *title)
Create section title in the GUI.
virtual void DoNoSelection()
Slot called when users close a TCanvas or when the user select no object.
TList * GetListOfFittingFunctions(TObject *obj=0)
TGTextButton * fUpdateButton
Definition: TFitEditor.h:71
TGTextEntry * fEnteredFunc
Definition: TFitEditor.h:79
TGCheckButton * fIntegral
Definition: TFitEditor.h:90
virtual void DoAllWeights1()
Slot connected to 'set all weights to 1' setting.
Bool_t SetObjectType(TObject *obj)
Check whether the object suitable for fitting and set its type, dimension and method combo box accord...
virtual void Hide()
Hide the fit panel and set it to non-active state.
TFitEditor & operator=(const TFitEditor &)
TGNumberEntryField * fErrorScale
Definition: TFitEditor.h:149
TAxis * fXaxis
Definition: TFitEditor.h:124
std::vector< FuncParamData_t > FuncParams_t
Definition: TFitEditor.h:249
TGLayoutHints * fLayoutAdd
Definition: TFitEditor.h:86
TGHorizontalFrame * fSliderXParent
Definition: TFitEditor.h:112
void ProcessTreeInput(TObject *objSelected, Int_t selected, TString variables, TString cuts)
TGCheckButton * fEnableRobust
Definition: TFitEditor.h:115
void DrawSelection(bool restore=false)
Draws the square around the object showing where the limits for fitting are.
TGCheckButton * fEmptyBinsWghts1
Definition: TFitEditor.h:97
virtual void DoSliderZMoved()
Slot connected to range settings on z-axis.
Int_t fDim
Definition: TFitEditor.h:123
TGNumberEntry * fSliderYMin
Definition: TFitEditor.h:110
void GetRanges(ROOT::Fit::DataRange &)
std::multimap< TObject *, TF1 * > fPrevFit
Definition: TFitEditor.h:140
TGNumberEntry * fRobustValue
Definition: TFitEditor.h:116
static TFitEditor * GetInstance(TVirtualPad *pad=0, TObject *obj=0)
Static method - opens the fit panel.
Definition: TFitEditor.cxx:335
TGNumberEntry * fSliderYMax
Definition: TFitEditor.h:109
virtual void DoNoChi2()
Slot connected to 'no chi2' option settings.
TGCheckButton * fAdd2FuncList
Definition: TFitEditor.h:93
TGCompositeFrame * fGeneral
Definition: TFitEditor.h:69
virtual void DisconnectSlots()
Disconnect GUI signals from fit panel slots.
void GetFunctionsFromSystem()
TGRadioButton * fOptQuiet
Definition: TFitEditor.h:119
void FillMinMethodList(Int_t selected=-1)
Fills the list of methods depending on the minimization library selected.
TGCheckButton * fNoStoreDrawing
Definition: TFitEditor.h:101
TGCheckButton * fAllWeights1
Definition: TFitEditor.h:95
TGRadioButton * fNone
Definition: TFitEditor.h:81
TGLayoutHints * fLayoutConv
Definition: TFitEditor.h:88
TGTextButton * fResetButton
Definition: TFitEditor.h:73
void CreateFunctionGroup()
Creates the Frame that contains oll the information about the function.
Definition: TFitEditor.cxx:546
TGLayoutHints * fLayoutNone
Definition: TFitEditor.h:85
TGLabel * fSelLabel
Definition: TFitEditor.h:75
TGRadioButton * fLibGSL
Definition: TFitEditor.h:146
Int_t CheckFunctionString(const char *str)
Check entered function string.
TObject * fFitObject
Definition: TFitEditor.h:121
virtual void DoRobustFit()
Slot connected to 'robust fitting' option settings.
virtual void CloseWindow()
Close fit panel window.
TGTextButton * fCloseButton
Definition: TFitEditor.h:74
virtual void DoAddition(Bool_t on)
Slot connected to addition of predefined functions.
Bool_t fChangedParams
Definition: TFitEditor.h:155
TGStatusBar * fStatusBar
Definition: TFitEditor.h:153
virtual void DoUserDialog()
Open a dialog for getting a user defined method.
virtual void DoNumericSliderXChanged()
Sincronize the numeric sliders with the graphical one.
Definition: TGTab.h:62
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
TF1Convolution object.
Definition: TFitEditor.h:131
Double_t & operator[](UInt_t i)
Definition: TFitEditor.h:135