#ifndef ROOT_TFitEditor
#define ROOT_TFitEditor
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGButton
#include "TGButton.h"
#endif
#include "Foption.h"
#include "Math/MinimizerOptions.h"
#include "Fit/DataRange.h"
#include <vector>
#include <map>
#include <utility>
enum EObjectType {
kObjectHisto,
kObjectGraph,
kObjectGraph2D,
kObjectHStack,
kObjectTree,
kObjectMultiGraph
};
class TGTab;
class TVirtualPad;
class TCanvas;
class TGLabel;
class TGComboBox;
class TGTextEntry;
class TGNumberEntry;
class TGDoubleHSlider;
class TGNumberEntry;
class TGNumberEntryField;
class TGStatusBar;
class TAxis;
class TF1;
class TF1NormSum;
class TF1Convolution;
class TFitEditor : public TGMainFrame {
protected:
TGTab *fTab;
TGCompositeFrame *fTabContainer;
TGCompositeFrame *fGeneral;
TGCompositeFrame *fMinimization;
TGTextButton *fUpdateButton;
TGTextButton *fFitButton;
TGTextButton *fResetButton;
TGTextButton *fCloseButton;
TGLabel *fSelLabel;
TGComboBox *fDataSet;
TGComboBox *fTypeFit;
TGComboBox *fFuncList;
TGTextEntry *fEnteredFunc;
TGTextButton *fUserButton;
TGRadioButton *fNone;
TGRadioButton *fAdd;
TGRadioButton *fNormAdd;
TGRadioButton *fConv;
TGLayoutHints *fLayoutNone;
TGLayoutHints *fLayoutAdd;
TGLayoutHints *fLayoutNormAdd;
TGLayoutHints *fLayoutConv;
TGTextButton *fSetParam;
TGCheckButton *fIntegral;
TGCheckButton *fBestErrors;
TGCheckButton *fUseRange;
TGCheckButton *fAdd2FuncList;
TGCheckButton *fUseGradient ;
TGCheckButton *fAllWeights1;
TGCheckButton *fImproveResults;
TGCheckButton *fEmptyBinsWghts1;
TGComboBox *fMethodList;
TGCheckButton *fLinearFit;
TGCheckButton *fNoChi2;
TGCheckButton *fNoStoreDrawing;
TGCheckButton *fNoDrawing;
TGCheckButton *fDrawSame;
TGTextButton *fDrawAdvanced;
TGDoubleHSlider *fSliderX;
TGNumberEntry *fSliderXMax;
TGNumberEntry *fSliderXMin;
TGDoubleHSlider *fSliderY;
TGNumberEntry *fSliderYMax;
TGNumberEntry *fSliderYMin;
TGDoubleHSlider *fSliderZ;
TGHorizontalFrame *fSliderXParent;
TGHorizontalFrame *fSliderYParent;
TGHorizontalFrame *fSliderZParent;
TGCheckButton *fEnableRobust;
TGNumberEntry *fRobustValue;
TGRadioButton *fOptDefault;
TGRadioButton *fOptVerbose;
TGRadioButton *fOptQuiet;
TVirtualPad *fParentPad;
TObject *fFitObject;
EObjectType fType;
Int_t fDim;
TAxis *fXaxis;
TAxis *fYaxis;
TAxis *fZaxis;
TF1NormSum *fSumFunc;
TF1Convolution *fConvFunc;
struct FuncParamData_t {
FuncParamData_t() {
fP[0] = 0; fP[1] = 0; fP[2] = 0;
}
Double_t & operator[](UInt_t i) { return fP[i];}
Double_t fP[3];
};
std::vector<FuncParamData_t> fFuncPars;
std::multimap<TObject*, TF1*> fPrevFit;
std::vector<TF1*> fSystemFuncs;
TGRadioButton *fLibMinuit;
TGRadioButton *fLibMinuit2;
TGRadioButton *fLibFumili;
TGRadioButton *fLibGSL;
TGRadioButton *fLibGenetics;
TGComboBox *fMinMethodList;
TGNumberEntryField *fErrorScale;
TGNumberEntryField *fTolerance;
TGNumberEntryField *fIterations;
TGStatusBar *fStatusBar;
static TFitEditor *fgFitDialog;
protected:
void GetFunctionsFromSystem();
void ProcessTreeInput(TObject* objSelected, Int_t selected,
TString variables, TString cuts);
TF1* FindFunction();
void FillDataSetList();
TGComboBox* BuildMethodList(TGFrame *parent, Int_t id);
void GetRanges(ROOT::Fit::DataRange&);
TF1* GetFitFunction();
TList* GetFitObjectListOfFunctions();
void DrawSelection(bool restore = false);
Int_t CheckFunctionString(const char* str);
void CreateFunctionGroup();
void CreateGeneralTab();
void CreateMinimizationTab();
void MakeTitle(TGCompositeFrame *parent, const char *title);
TF1* HasFitFunction();
void SetEditable(Bool_t);
private:
TFitEditor(const TFitEditor&);
TFitEditor& operator=(const TFitEditor&);
void RetrieveOptions(Foption_t&, TString&, ROOT::Math::MinimizerOptions&, Int_t);
public:
TFitEditor(TVirtualPad* pad, TObject *obj);
virtual ~TFitEditor();
TList* GetListOfFittingFunctions(TObject* obj = 0);
static TFitEditor *GetInstance(TVirtualPad* pad = 0, TObject *obj = 0);
virtual Option_t *GetDrawOption() const;
virtual void Hide();
virtual void Show(TVirtualPad* pad, TObject *obj);
void ShowObjectName(TObject* obj);
Bool_t SetObjectType(TObject* obj);
virtual void Terminate();
void UpdateGUI();
virtual void CloseWindow();
virtual void ConnectSlots();
virtual void DisconnectSlots();
virtual void RecursiveRemove(TObject* obj);
protected:
virtual void SetCanvas(TCanvas *c);
public:
virtual void SetFitObject(TVirtualPad *pad, TObject *obj, Int_t event);
virtual void SetFunction(const char *function);
void FillFunctionList(Int_t selected = -1);
void FillMinMethodList(Int_t selected = -1);
virtual void DoAddition(Bool_t on);
virtual void DoNormAddition(Bool_t on);
virtual void DoConvolution(Bool_t on);
virtual void DoAdvancedOptions();
virtual void DoAllWeights1();
virtual void DoClose();
virtual void DoEmptyBinsAllWeights1();
virtual void DoEnteredFunction();
virtual void DoUpdate();
virtual void DoFit();
virtual void DoMaxIterations();
virtual void DoDataSet(Int_t sel);
virtual void DoFunction(Int_t sel);
virtual void DoLinearFit();
virtual void DoNoChi2();
virtual void DoNoSelection();
virtual void DoNoStoreDrawing();
virtual void DoReset();
virtual void DoRobustFit();
virtual void DoSetParameters();
virtual void DoSliderXMoved();
virtual void DoNumericSliderXChanged();
virtual void DoSliderYMoved();
virtual void DoNumericSliderYChanged();
virtual void DoSliderZMoved();
virtual void DoUserDialog();
virtual void DoUseFuncRange();
virtual void DoLibrary(Bool_t on);
virtual void DoMinMethod(Int_t );
virtual void DoPrintOpt(Bool_t on);
public:
typedef std::vector<FuncParamData_t > FuncParams_t;
friend class FitEditorUnitTesting;
ClassDef(TFitEditor,0)
};
#endif