Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:33

0001 // Authors: Sergey Linev <S.Linev@gsi.de> Iliana Betsou <Iliana.Betsou@cern.ch>
0002 // Date: 2019-04-11
0003 // Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0004 
0005 /*************************************************************************
0006  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0007  * All rights reserved.                                                  *
0008  *                                                                       *
0009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0011  *************************************************************************/
0012 
0013 #ifndef ROOT_RFitPanelModel
0014 #define ROOT_RFitPanelModel
0015 
0016 #include "Foption.h"
0017 #include "Fit/DataRange.h"
0018 #include "Math/MinimizerOptions.h"
0019 #include "TString.h"
0020 
0021 #include <vector>
0022 #include <string>
0023 
0024 class TH1;
0025 class TF1;
0026 class TFitResult;
0027 
0028 namespace ROOT {
0029 namespace Experimental {
0030 
0031 class RLogChannel;
0032 /// Log channel for FitPanel diagnostics.
0033 RLogChannel &FitPanelLog();
0034 
0035 /** Data structure for the fit panel */
0036 
0037 struct RFitPanelModel {
0038 
0039    enum EFitObjectType {
0040       kObjectNone,
0041       kObjectHisto,
0042       kObjectGraph,
0043       kObjectGraph2D,
0044       kObjectHStack,
0045    //   kObjectTree,
0046       kObjectMultiGraph,
0047       kObjectNotSupported
0048    };
0049 
0050    /// Generic item for ui5 ComboBox
0051    struct RComboBoxItem {
0052       std::string key;
0053       std::string value;
0054       RComboBoxItem() = default;
0055       RComboBoxItem(const std::string &_key, const std::string &_value) : key(_key), value(_value) {}
0056    };
0057 
0058    struct RMethodInfo {
0059       int id{0};                 // method id
0060       std::string text;          // text shown in combobox
0061       RMethodInfo() = default;
0062       RMethodInfo(int _id, const std::string &_text) : id(_id), text(_text) {}
0063    };
0064 
0065    /// Entry in minimizer algorithm combo
0066    struct RMinimezerAlgorithm {
0067       int lib{0};        // to which library belongs
0068       int id{0};         // identifier
0069       std::string text;  // text shown in combobox
0070       RMinimezerAlgorithm() = default;
0071       RMinimezerAlgorithm(int _lib, int _id, const std::string &_text) : lib(_lib), id(_id), text(_text) {}
0072    };
0073 
0074    /// Basic function info, used in combo boxes
0075    struct RItemInfo {
0076       std::string group;
0077       std::string id;
0078       std::string name;
0079 
0080       RItemInfo() = default;
0081       RItemInfo(const std::string &_name) : group("Predefined"), name(_name) { id = "dflt::"; id.append(_name); }
0082       RItemInfo(const std::string &_group, const std::string &_id, const std::string &_name) : group(_group), id(_id), name(_name) {}
0083    };
0084 
0085    /// Function parameter info, used in edit parameters dialog
0086 
0087    struct RFuncPar {
0088       int ipar{0};
0089       std::string name;
0090       std::string value;
0091       bool fixed{false};
0092       std::string error;
0093       std::string min;
0094       std::string max;
0095       RFuncPar() = default;
0096       RFuncPar(int _ipar, const std::string &_name) : ipar(_ipar), name(_name) {}
0097    };
0098 
0099    /// Class used to transfer functions parameters list from/to client
0100    struct RFuncParsList {
0101       bool haspars{false};
0102       std::string id;                ///< function id in the FitPanel
0103       std::string name;              ///< display name
0104       std::vector<RFuncPar> pars;    ///< parameters
0105       void GetParameters(TF1 *f1);
0106       void SetParameters(TF1 *f1);
0107       void Clear();
0108    };
0109 
0110    std::string fTitle;                    ///< title of the fit panel
0111 
0112    std::vector<RItemInfo> fDataSet;       ///< list of available data sources
0113    std::string fSelectedData;             ///< selected data
0114    EFitObjectType fDataType{kObjectNone}; ///< selected object type, provided by server
0115 
0116    int fDim{0};                           ///< number of dimensions in selected data object
0117 
0118    std::vector<RItemInfo> fFuncList;      ///< all available fit functions
0119    std::string fSelectedFunc;             ///< id of selected fit function like dflt::gaus
0120 
0121    std::string fSelectedTab;              ///< key of selected tab, useful for drawing
0122 
0123    // General tab
0124 
0125    // Method
0126    std::vector<RMethodInfo> fFitMethods;  ///< all supported for selected data
0127    int fFitMethod{0};                     ///< selected fit method
0128 
0129    bool fLinearFit{false};
0130    bool fRobust{false};
0131    float fRobustLevel{0.95};
0132 
0133    // Fit Options
0134    bool fIntegral{false};
0135    bool fUseRange{false};
0136    bool fBestErrors{false};
0137    bool fImproveFitResults{false};
0138    bool fAllWeights1{false};
0139    bool fAddToList{false};
0140    bool fEmptyBins1{false};
0141    bool fUseGradient{false};
0142 
0143    // Draw Options
0144    bool fSame{false};
0145    bool fNoDrawing{false};
0146    bool fNoStoreDraw{false};
0147 
0148 
0149    // all combo items for all methods
0150 
0151    // Minimization Tab
0152    int fLibrary{0};                                 ///< selected minimization library
0153    bool fHasGenetics{false};                        ///< is genetics available
0154    std::vector<RMinimezerAlgorithm> fMethodMinAll;  ///< all items for all methods
0155    int fSelectMethodMin{0};
0156 
0157    float fErrorDef{1.00};
0158    float fMaxTolerance{0.01};
0159    int fMaxIterations{0};
0160    int fPrint{0};
0161 
0162 
0163    // range selection, shown depending on fDim
0164    float fMinRangeX{0};
0165    float fMaxRangeX{1};
0166    float fStepX{0.01};
0167    float fRangeX[2] = {0,1};
0168 
0169    float fMinRangeY{0};
0170    float fMaxRangeY{1};
0171    float fStepY{0.01};
0172    float fRangeY[2] = {0,1};
0173 
0174 
0175    /// Parameters
0176 
0177    RFuncParsList fFuncPars;
0178 
0179    /// Advanced Options
0180 
0181    bool fHasAdvanced{false};
0182    std::string fAdvancedTab;
0183    std::vector<RComboBoxItem> fAdvancedPars;
0184    float fConfidenceLevel{0.683};
0185 
0186    /// Contour sub-tab
0187    int fContourPoints{0};
0188    std::string fContourPar1Id;
0189    std::string fContourPar2Id;
0190    std::string fContourColor;
0191    bool fContourSuperImpose{false};
0192 
0193    // Scan sub-tab
0194    int fScanPoints{0};
0195    std::string fScanId;
0196    float fScanMin{0};
0197    float fScanMax{0};
0198    std::string fScanColor;
0199 
0200    /// Confidence sub-tab
0201    std::string fConfidenceColor;
0202 
0203    bool fInitialized{false};        ///<! indicates if data were initialized
0204 
0205    RFitPanelModel() = default;
0206 
0207    void Initialize();
0208 
0209    bool SelectHistogram(const std::string &hname, TH1 *hist);
0210 
0211    void SetObjectKind(EFitObjectType kind);
0212 
0213    bool HasFunction(const std::string &id);
0214 
0215    void SelectedFunc(const std::string &name, TF1 *func);
0216 
0217    void UpdateRange(TH1 *hist);
0218 
0219    void UpdateAdvanced(TFitResult *res);
0220 
0221    bool IsDataSelected() const { return !fSelectedData.empty(); }
0222 
0223    ROOT::Fit::DataRange GetRanges();
0224    Foption_t GetFitOptions();
0225    ROOT::Math::MinimizerOptions GetMinimizerOptions();
0226 
0227    TString GetDrawOption();
0228 };
0229 
0230 } // namespace Experimental
0231 } // namespace ROOT
0232 
0233 #endif