Warning, file /include/root/TFitEditor.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TFitEditor
0013 #define ROOT_TFitEditor
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGButton.h"
0018
0019 #include "Foption.h"
0020 #include "Math/MinimizerOptions.h"
0021 #include "Fit/DataRange.h"
0022
0023 #include <vector>
0024 #include <map>
0025
0026
0027 enum EObjectType {
0028 kObjectHisto,
0029 kObjectGraph,
0030 kObjectGraph2D,
0031 kObjectHStack,
0032 kObjectTree,
0033 kObjectMultiGraph
0034 };
0035
0036
0037 class TGTab;
0038 class TVirtualPad;
0039 class TCanvas;
0040 class TGLabel;
0041 class TGComboBox;
0042 class TGTextEntry;
0043 class TGNumberEntry;
0044 class TGDoubleHSlider;
0045 class TGNumberEntry;
0046 class TGNumberEntryField;
0047 class TGStatusBar;
0048 class TAxis;
0049 class TF1;
0050 class TF1NormSum;
0051 class TF1Convolution;
0052
0053
0054 class TFitEditor : public TGMainFrame {
0055
0056 protected:
0057 TGTab *fTab;
0058 TGCompositeFrame *fTabContainer;
0059 TGCompositeFrame *fGeneral;
0060 TGCompositeFrame *fMinimization;
0061 TGTextButton *fUpdateButton;
0062 TGTextButton *fFitButton;
0063 TGTextButton *fResetButton;
0064 TGTextButton *fCloseButton;
0065 TGLabel *fSelLabel;
0066 TGComboBox *fDataSet;
0067 TGComboBox *fTypeFit;
0068 TGComboBox *fFuncList;
0069 TGTextEntry *fEnteredFunc;
0070 TGTextButton *fUserButton;
0071 TGRadioButton *fNone;
0072 TGRadioButton *fAdd;
0073 TGRadioButton *fNormAdd;
0074 TGRadioButton *fConv;
0075 TGLayoutHints *fLayoutNone;
0076 TGLayoutHints *fLayoutAdd;
0077 TGLayoutHints *fLayoutNormAdd;
0078 TGLayoutHints *fLayoutConv;
0079 TGTextButton *fSetParam;
0080 TGCheckButton *fIntegral;
0081 TGCheckButton *fBestErrors;
0082 TGCheckButton *fUseRange;
0083 TGCheckButton *fAdd2FuncList;
0084 TGCheckButton *fUseGradient ;
0085 TGCheckButton *fAllWeights1;
0086 TGCheckButton *fImproveResults;
0087 TGCheckButton *fEmptyBinsWghts1;
0088 TGComboBox *fMethodList;
0089 TGCheckButton *fLinearFit;
0090 TGCheckButton *fNoChi2;
0091 TGCheckButton *fNoStoreDrawing;
0092 TGCheckButton *fNoDrawing;
0093 TGCheckButton *fDrawSame;
0094 TGTextButton *fDrawAdvanced;
0095 TGDoubleHSlider *fSliderX;
0096 TGNumberEntry *fSliderXMax;
0097 TGNumberEntry *fSliderXMin;
0098 TGDoubleHSlider *fSliderY;
0099 TGNumberEntry *fSliderYMax;
0100 TGNumberEntry *fSliderYMin;
0101 TGDoubleHSlider *fSliderZ;
0102 TGHorizontalFrame *fSliderXParent;
0103 TGHorizontalFrame *fSliderYParent;
0104 TGHorizontalFrame *fSliderZParent;
0105 TGCheckButton *fEnableRobust;
0106 TGNumberEntry *fRobustValue;
0107 TGRadioButton *fOptDefault;
0108 TGRadioButton *fOptVerbose;
0109 TGRadioButton *fOptQuiet;
0110 TVirtualPad *fParentPad;
0111 TObject *fFitObject;
0112 EObjectType fType;
0113 Int_t fDim;
0114 TAxis *fXaxis;
0115 TAxis *fYaxis;
0116 TAxis *fZaxis;
0117 TF1NormSum *fSumFunc;
0118 TF1Convolution *fConvFunc;
0119
0120
0121 struct FuncParamData_t {
0122 FuncParamData_t() {
0123 fP[0] = 0; fP[1] = 0; fP[2] = 0;
0124 }
0125 Double_t & operator[](UInt_t i) { return fP[i];}
0126 Double_t fP[3];
0127 };
0128 std::vector<FuncParamData_t> fFuncPars;
0129
0130 std::multimap<TObject*, TF1*> fPrevFit;
0131 std::vector<TF1*> fSystemFuncs;
0132
0133 TGRadioButton *fLibMinuit;
0134 TGRadioButton *fLibMinuit2;
0135 TGRadioButton *fLibFumili;
0136 TGRadioButton *fLibGSL;
0137 TGRadioButton *fLibGenetics;
0138 TGComboBox *fMinMethodList;
0139 TGNumberEntryField *fErrorScale;
0140 TGNumberEntryField *fTolerance;
0141 TGNumberEntryField *fIterations;
0142
0143 TGStatusBar *fStatusBar;
0144
0145 Bool_t fChangedParams;
0146
0147 static TFitEditor *fgFitDialog;
0148
0149 protected:
0150 void GetFunctionsFromSystem();
0151 void ProcessTreeInput(TObject* objSelected, Int_t selected,
0152 TString variables, TString cuts);
0153 TF1* FindFunction();
0154 void FillDataSetList();
0155 TGComboBox* BuildMethodList(TGFrame *parent, Int_t id);
0156 void GetRanges(ROOT::Fit::DataRange&);
0157 TF1* GetFitFunction();
0158 TList* GetFitObjectListOfFunctions();
0159 void DrawSelection(bool restore = false);
0160 Int_t CheckFunctionString(const char* str);
0161 void CreateFunctionGroup();
0162 void CreateGeneralTab();
0163 void CreateMinimizationTab();
0164 void MakeTitle(TGCompositeFrame *parent, const char *title);
0165 TF1* HasFitFunction();
0166 void SetEditable(Bool_t) override;
0167
0168 private:
0169 TFitEditor(const TFitEditor&);
0170 TFitEditor& operator=(const TFitEditor&);
0171
0172 void RetrieveOptions(Foption_t&, TString&, ROOT::Math::MinimizerOptions&, Int_t);
0173
0174 public:
0175 TFitEditor(TVirtualPad* pad, TObject *obj);
0176 ~TFitEditor() override;
0177
0178 TList* GetListOfFittingFunctions(TObject *obj = nullptr);
0179
0180 static TFitEditor *GetInstance(TVirtualPad* pad = nullptr, TObject *obj = nullptr);
0181 Option_t *GetDrawOption() const override;
0182 virtual void Hide();
0183 virtual void Show(TVirtualPad* pad, TObject *obj);
0184
0185 void ShowObjectName(TObject* obj);
0186 Bool_t SetObjectType(TObject* obj);
0187 virtual void Terminate();
0188 void UpdateGUI();
0189
0190 void CloseWindow() override;
0191 virtual void ConnectSlots();
0192 virtual void DisconnectSlots();
0193 void RecursiveRemove(TObject* obj) override;
0194
0195 protected:
0196 virtual void SetCanvas(TCanvas *c);
0197
0198 public:
0199 virtual void SetFitObject(TVirtualPad *pad, TObject *obj, Int_t event);
0200 virtual void SetFunction(const char *function);
0201
0202
0203 void FillFunctionList(Int_t selected = -1);
0204 void FillMinMethodList(Int_t selected = -1);
0205 virtual void DoAddition(Bool_t on);
0206 virtual void DoNormAddition(Bool_t on);
0207 virtual void DoConvolution(Bool_t on);
0208 virtual void DoAdvancedOptions();
0209 virtual void DoAllWeights1();
0210 virtual void DoClose();
0211 virtual void DoEmptyBinsAllWeights1();
0212 virtual void DoEnteredFunction();
0213 virtual void DoUpdate();
0214 virtual void DoFit();
0215 virtual void DoMaxIterations();
0216 virtual void DoDataSet(Int_t sel);
0217 virtual void DoFunction(Int_t sel);
0218 virtual void DoLinearFit();
0219 virtual void DoNoChi2();
0220 virtual void DoNoSelection();
0221 virtual void DoNoStoreDrawing();
0222 virtual void DoReset();
0223 virtual void DoRobustFit();
0224 virtual void DoSetParameters();
0225 virtual void DoSliderXMoved();
0226 virtual void DoNumericSliderXChanged();
0227 virtual void DoSliderYMoved();
0228 virtual void DoNumericSliderYChanged();
0229 virtual void DoSliderZMoved();
0230 virtual void DoUserDialog();
0231 virtual void DoUseFuncRange();
0232
0233
0234 virtual void DoLibrary(Bool_t on);
0235 virtual void DoMinMethod(Int_t );
0236 virtual void DoPrintOpt(Bool_t on);
0237
0238 public:
0239 typedef std::vector<FuncParamData_t > FuncParams_t;
0240
0241 friend class FitEditorUnitTesting;
0242 ClassDefOverride(TFitEditor,0)
0243 };
0244
0245 #endif