Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:14:28

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