Back to home page

EIC code displayed by LXR

 
 

    


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 // @(#)root/fitpanel:$Id$
0002 // Author: Ilka Antcheva, Lorenzo Moneta, David Gonzalez Maline 10/08/2006
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 //--- Object types
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;              ///< tab widget holding the editor
0058    TGCompositeFrame    *fTabContainer;     ///< main tab container
0059    TGCompositeFrame    *fGeneral;          ///< general tab
0060    TGCompositeFrame    *fMinimization;     ///< minimization tab
0061    TGTextButton        *fUpdateButton;     ///< updates data from gROOT and gDirectory
0062    TGTextButton        *fFitButton;        ///< performs fitting
0063    TGTextButton        *fResetButton;      ///< resets fit parameters
0064    TGTextButton        *fCloseButton;      ///< close the fit panel
0065    TGLabel             *fSelLabel;         ///< contains selected fit function
0066    TGComboBox          *fDataSet;          ///< contains list of data set to be fitted
0067    TGComboBox          *fTypeFit;          ///< contains the types of functions to be selected
0068    TGComboBox          *fFuncList;         ///< contains function list
0069    TGTextEntry         *fEnteredFunc;      ///< contains user function file name
0070    TGTextButton        *fUserButton;       ///< opens a dialog for user-defined fit method
0071    TGRadioButton       *fNone;             ///< set no operation mode
0072    TGRadioButton       *fAdd;              ///< set addition mode
0073    TGRadioButton       *fNormAdd;          ///< set normalized addition mode
0074    TGRadioButton       *fConv;             ///< set convolution mode
0075    TGLayoutHints       *fLayoutNone;       ///< layout hints of fNone radio button
0076    TGLayoutHints       *fLayoutAdd;        ///< layout hints of fAdd radio button
0077    TGLayoutHints       *fLayoutNormAdd;    ///< layout hints of fNOrmAdd radio button
0078    TGLayoutHints       *fLayoutConv;       ///< layout hints of fConv radio button
0079    TGTextButton        *fSetParam;         ///< open set parameters dialog
0080    TGCheckButton       *fIntegral;         ///< switch on/off option 'integral'
0081    TGCheckButton       *fBestErrors;       ///< switch on/off option 'improve errors'
0082    TGCheckButton       *fUseRange;         ///< switch on/off option 'use function range'
0083    TGCheckButton       *fAdd2FuncList;     ///< switch on/off option 'add to list'
0084    TGCheckButton       *fUseGradient ;     ///< switch on/off option 'use gradient'
0085    TGCheckButton       *fAllWeights1;      ///< switch on/off option 'all weights=1'
0086    TGCheckButton       *fImproveResults;   ///< switch on/off option 'improve fit results'
0087    TGCheckButton       *fEmptyBinsWghts1;  ///< switch on/off option 'include empry bins'
0088    TGComboBox          *fMethodList;       ///< contains method list
0089    TGCheckButton       *fLinearFit;        ///< switch on/off linear fit option
0090    TGCheckButton       *fNoChi2;           ///< switch on/off option 'No Chi-square'
0091    TGCheckButton       *fNoStoreDrawing;   ///< switch on/off 'no store/drwing' option
0092    TGCheckButton       *fNoDrawing;        ///< switch on/off 'no drawing' option
0093    TGCheckButton       *fDrawSame;         ///< switch on/off fit function drawing
0094    TGTextButton        *fDrawAdvanced;     ///< opens a dialog for advanced draw options
0095    TGDoubleHSlider     *fSliderX;          ///< slider to set fit range along x-axis
0096    TGNumberEntry       *fSliderXMax;       ///< entry to set the maximum in the range
0097    TGNumberEntry       *fSliderXMin;       ///< entry to set the minumum in the range
0098    TGDoubleHSlider     *fSliderY;          ///< slider to set fit range along y-axis
0099    TGNumberEntry       *fSliderYMax;       ///< entry to set the maximum in the range
0100    TGNumberEntry       *fSliderYMin;       ///< entry to set the minumum in the range
0101    TGDoubleHSlider     *fSliderZ;          ///< slider to set fit range along z-axis
0102    TGHorizontalFrame   *fSliderXParent;    ///< parent of fSliderX
0103    TGHorizontalFrame   *fSliderYParent;    ///< parent of fSliderY
0104    TGHorizontalFrame   *fSliderZParent;    ///< parent of fSliderZ
0105    TGCheckButton       *fEnableRobust;     ///< switch on/off robust option
0106    TGNumberEntry       *fRobustValue;      ///< contains robust value for linear fit
0107    TGRadioButton       *fOptDefault;       ///< set default printing mode
0108    TGRadioButton       *fOptVerbose;       ///< set printing mode to 'Verbose'
0109    TGRadioButton       *fOptQuiet;         ///< set printing mode to 'Quiet'
0110    TVirtualPad         *fParentPad;        ///< pad containing the object
0111    TObject             *fFitObject;        ///< selected object to fit
0112    EObjectType          fType;             ///< object type info
0113    Int_t                fDim;              ///< object dimension
0114    TAxis               *fXaxis;            ///< x-axis
0115    TAxis               *fYaxis;            ///< y-axis
0116    TAxis               *fZaxis;            ///< z-axis
0117    TF1NormSum          *fSumFunc;          ///<! TF1NormSum object
0118    TF1Convolution      *fConvFunc;         ///<! TF1Convolution object
0119 
0120    // structure holding parameter value and limits
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; // function parameters (value + limits)
0129 
0130    std::multimap<TObject*, TF1*> fPrevFit; // Previous successful fits.
0131    std::vector<TF1*> fSystemFuncs;         // functions managed by the fitpanel
0132 
0133    TGRadioButton       *fLibMinuit;        // set default minimization library (Minuit)
0134    TGRadioButton       *fLibMinuit2;       // set Minuit2 as minimization library
0135    TGRadioButton       *fLibFumili;        // set Fumili as minimization library
0136    TGRadioButton       *fLibGSL;           // set GSL as minimization library
0137    TGRadioButton       *fLibGenetics;      // set Genetic/GALib as minimization library
0138    TGComboBox          *fMinMethodList;    // set the minimization method
0139    TGNumberEntryField  *fErrorScale;       // contains error scale set for minimization
0140    TGNumberEntryField  *fTolerance;        // contains tolerance set for minimization
0141    TGNumberEntryField  *fIterations;       // contains maximum number of iterations
0142 
0143    TGStatusBar         *fStatusBar;        // statusbar widget
0144 
0145    Bool_t               fChangedParams;    // flag to indicate if the parameters have been set in the ParameterDialog GUI
0146 
0147    static TFitEditor *fgFitDialog;         // singleton fit panel
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&);              // not implemented
0170    TFitEditor& operator=(const TFitEditor&);   // not implemented
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    // slot methods 'General' tab
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    // slot methods 'Minimization' tab
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)  //Fit Panel interface
0243 };
0244 
0245 #endif