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_RFitPanel
0014 #define ROOT_RFitPanel
0015 
0016 #include <ROOT/RWebWindow.hxx>
0017 
0018 #include <ROOT/RFitPanelModel.hxx>
0019 
0020 #include <ROOT/RCanvas.hxx>
0021 
0022 #include "ROOT/RHist.hxx"
0023 
0024 #include "TFitResultPtr.h"
0025 
0026 #include <memory>
0027 #include <vector>
0028 #include <list>
0029 
0030 class TPad;
0031 class TH1;
0032 class TF1;
0033 
0034 namespace ROOT {
0035 namespace Experimental {
0036 
0037 class RFitPanel {
0038 
0039    std::unique_ptr<RFitPanelModel> fModel;
0040 
0041    std::vector<TObject*> fObjects;    ///<! objects provided directly to panel for fitting
0042    std::string fCanvName;             ///<! v6 canvas name used to display fit, will be created if not exists
0043    std::string fPadName;              ///<! v6 pad name in the canvas, where object is (was) drawn
0044 
0045    std::shared_ptr<RCanvas> fCanvas; ///<! v7 canvas used to display results
0046    std::shared_ptr<RH1D> fFitHist;   ///<! v7 histogram for fitting
0047 
0048    std::shared_ptr<ROOT::RWebWindow> fWindow;  ///<! configured display
0049    unsigned fConnId{0};                  ///<! client connection id
0050 
0051    std::vector<std::unique_ptr<TF1>> fSystemFuncs; ///<! local copy of all internal system funcs
0052 
0053    struct FitRes {
0054       std::string objid;         // object used for fitting
0055       std::unique_ptr<TF1> func; // function
0056       TFitResultPtr res;          // result
0057       FitRes() = default;
0058       FitRes(const std::string &_objid, std::unique_ptr<TF1> &_func, TFitResultPtr &_res);
0059       ~FitRes();
0060    };
0061 
0062    std::list<FitRes> fPrevRes; ///<! all previous functions used for fitting
0063 
0064    TF1 *copyTF1(TF1 *f);
0065 
0066    void GetFunctionsFromSystem();
0067 
0068    void ProcessData(unsigned connid, const std::string &arg);
0069 
0070    RFitPanelModel &model();
0071 
0072    int UpdateModel(const std::string &json);
0073 
0074    void SelectObject(const std::string &objid);
0075    TObject *GetSelectedObject(const std::string &objid);
0076    RFitPanelModel::EFitObjectType GetFitObjectType(TObject *obj);
0077    void UpdateDataSet();
0078 
0079    void UpdateFunctionsList();
0080    TF1 *FindFunction(const std::string &funcid);
0081    TFitResult *FindFitResult(const std::string &funcid);
0082    std::unique_ptr<TF1> GetFitFunction(const std::string &funcid);
0083    void SelectFunction(const std::string &funcid);
0084 
0085    TObject *MakeConfidenceLevels(TFitResult *res);
0086 
0087    Color_t GetColor(const std::string &colorid);
0088 
0089    TPad *GetDrawPad(TObject *obj, bool force = false);
0090 
0091    void DoPadUpdate(TPad *pad);
0092 
0093    void SendModel();
0094 
0095    bool DoFit();
0096    bool DoDraw();
0097 
0098 public:
0099    RFitPanel(const std::string &title = "Fit panel");
0100    ~RFitPanel();
0101 
0102    // method required when any panel want to be inserted into the RCanvas
0103    std::shared_ptr<ROOT::RWebWindow> GetWindow();
0104 
0105    void AssignHistogram(TH1 *hist);
0106 
0107    void AssignHistogram(const std::string &hname);
0108 
0109    void AssignCanvas(const std::string &cname) { fCanvName = cname; }
0110 
0111    void AssignCanvas(std::shared_ptr<RCanvas> &canv);
0112 
0113    void AssignHistogram(std::shared_ptr<RH1D> &hist);
0114 
0115    /// show FitPanel in specified place
0116    void Show(const std::string &where = "");
0117 
0118    /// hide FitPanel
0119    void Hide();
0120 
0121    void ClearOnClose(const std::shared_ptr<void> &handle);
0122 };
0123 
0124 } // namespace Experimental
0125 } // namespace ROOT
0126 
0127 #endif