Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// Authors: Sergey Linev <S.Linev@gsi.de> Iliana Betsou <Iliana.Betsou@cern.ch>
2// Date: 2019-04-11
3// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
13#ifndef ROOT_RFitPanel
14#define ROOT_RFitPanel
16#include <ROOT/RWebWindow.hxx>
20#include <ROOT/RCanvas.hxx>
22#include "ROOT/RHist.hxx"
24#include "TFitResultPtr.h"
26#include <memory>
27#include <vector>
28#include <list>
30class TPad;
31class TH1;
32class TF1;
34namespace ROOT {
35namespace Experimental {
37class RFitPanel {
39 std::unique_ptr<RFitPanelModel> fModel;
41 std::vector<TObject*> fObjects; ///<! objects provided directly to panel for fitting
42 std::string fCanvName; ///<! v6 canvas name used to display fit, will be created if not exists
43 std::string fPadName; ///<! v6 pad name in the canvas, where object is (was) drawn
45 std::shared_ptr<RCanvas> fCanvas; ///<! v7 canvas used to display results
46 std::shared_ptr<RH1D> fFitHist; ///<! v7 histogram for fitting
48 std::shared_ptr<RWebWindow> fWindow; ///<! configured display
49 unsigned fConnId{0}; ///<! client connection id
51 std::vector<std::unique_ptr<TF1>> fSystemFuncs; ///<! local copy of all internal system funcs
53 struct FitRes {
54 std::string objid; // object used for fitting
55 std::unique_ptr<TF1> func; // function
56 TFitResultPtr res; // result
57 FitRes() = default;
58 FitRes(const std::string &_objid, std::unique_ptr<TF1> &_func, TFitResultPtr &_res);
59 ~FitRes();
60 };
62 std::list<FitRes> fPrevRes; ///<! all previous functions used for fitting
64 TF1 *copyTF1(TF1 *f);
68 void ProcessData(unsigned connid, const std::string &arg);
72 int UpdateModel(const std::string &json);
74 void SelectObject(const std::string &objid);
75 TObject *GetSelectedObject(const std::string &objid);
77 void UpdateDataSet();
80 TF1 *FindFunction(const std::string &funcid);
81 TFitResult *FindFitResult(const std::string &funcid);
82 std::unique_ptr<TF1> GetFitFunction(const std::string &funcid);
83 void SelectFunction(const std::string &funcid);
87 Color_t GetColor(const std::string &colorid);
89 TPad *GetDrawPad(TObject *obj, bool force = false);
91 void SendModel();
93 bool DoFit();
94 bool DoDraw();
97 RFitPanel(const std::string &title = "Fit panel");
98 ~RFitPanel();
100 // method required when any panel want to be inserted into the RCanvas
101 std::shared_ptr<RWebWindow> GetWindow();
103 void AssignHistogram(TH1 *hist);
105 void AssignHistogram(const std::string &hname);
107 void AssignCanvas(const std::string &cname) { fCanvName = cname; }
109 void AssignCanvas(std::shared_ptr<RCanvas> &canv);
111 void AssignHistogram(std::shared_ptr<RH1D> &hist);
113 /// show FitPanel in specified place
114 void Show(const std::string &where = "");
116 /// hide FitPanel
117 void Hide();
119 void ClearOnClose(const std::shared_ptr<void> &handle);
122} // namespace Experimental
123} // namespace ROOT
nlohmann::json json
#define f(i)
Definition: RSha256.hxx:104
short Color_t
Definition: RtypesCore.h:92
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
RFitPanel(const std::string &title="Fit panel")
Definition: RFitPanel.cxx:83
TPad * GetDrawPad(TObject *obj, bool force=false)
Returns pad where histogram is drawn If canvas not exists, create new one.
Definition: RFitPanel.cxx:632
void UpdateDataSet()
Update list of available data.
Definition: RFitPanel.cxx:129
void UpdateFunctionsList()
Update list of available functions.
Definition: RFitPanel.cxx:275
void SelectFunction(const std::string &funcid)
Select fit function.
Definition: RFitPanel.cxx:302
void GetFunctionsFromSystem()
Looks for all the functions registered in the current ROOT session.
Definition: RFitPanel.cxx:595
void ClearOnClose(const std::shared_ptr< void > &handle)
Set handle which will be cleared when connection is closed.
Definition: RFitPanel.cxx:981
RFitPanelModel::EFitObjectType GetFitObjectType(TObject *obj)
Returns kind of object.
Definition: RFitPanel.cxx:249
std::shared_ptr< RCanvas > fCanvas
! v7 canvas used to display results
Definition: RFitPanel.hxx:45
TF1 * FindFunction(const std::string &funcid)
Search for existing functions, ownership still belongs to FitPanel or global lists.
Definition: RFitPanel.cxx:440
std::shared_ptr< RWebWindow > fWindow
! configured display
Definition: RFitPanel.hxx:48
std::string fCanvName
! v6 canvas name used to display fit, will be created if not exists
Definition: RFitPanel.hxx:42
std::unique_ptr< RFitPanelModel > fModel
Definition: RFitPanel.hxx:39
void Show(const std::string &where="")
show FitPanel in specified place
Definition: RFitPanel.cxx:350
std::shared_ptr< RWebWindow > GetWindow()
Returns RWebWindow instance, used to display FitPanel.
Definition: RFitPanel.cxx:101
Color_t GetColor(const std::string &colorid)
Extract color from string Should be coded as #ff00ff string.
Definition: RFitPanel.cxx:794
unsigned fConnId
! client connection id
Definition: RFitPanel.hxx:49
std::string fPadName
! v6 pad name in the canvas, where object is (was) drawn
Definition: RFitPanel.hxx:43
bool DoFit()
Perform fitting using current model settings Returns true if any action was done.
Definition: RFitPanel.cxx:693
TObject * MakeConfidenceLevels(TFitResult *res)
Create confidence levels drawing tab.
Definition: RFitPanel.cxx:805
std::vector< TObject * > fObjects
! objects provided directly to panel for fitting
Definition: RFitPanel.hxx:41
std::unique_ptr< TF1 > GetFitFunction(const std::string &funcid)
Creates new instance to make fitting.
Definition: RFitPanel.cxx:480
void AssignHistogram(TH1 *hist)
Assign histogram to use with fit panel - without ownership.
Definition: RFitPanel.cxx:312
TFitResult * FindFitResult(const std::string &funcid)
Creates new instance to make fitting.
Definition: RFitPanel.cxx:464
TObject * GetSelectedObject(const std::string &objid)
Returns object based on it string id Searches either in gDirectory or in internal panel list.
Definition: RFitPanel.cxx:230
void SendModel()
Send model object to the client.
Definition: RFitPanel.cxx:382
void Hide()
hide FitPanel
Definition: RFitPanel.cxx:358
int UpdateModel(const std::string &json)
Update fit model returns -1 if JSON fails return 0 if nothing large changed return 1 if important sel...
Definition: RFitPanel.cxx:517
std::shared_ptr< RH1D > fFitHist
! v7 histogram for fitting
Definition: RFitPanel.hxx:46
RFitPanelModel & model()
Return reference on model object Model created if was not exists before.
Definition: RFitPanel.cxx:369
TF1 * copyTF1(TF1 *f)
Copies f into a new TF1 to be stored in the fitpanel with it's own ownership.
Definition: RFitPanel.cxx:554
std::vector< std::unique_ptr< TF1 > > fSystemFuncs
! local copy of all internal system funcs
Definition: RFitPanel.hxx:51
std::list< FitRes > fPrevRes
! all previous functions used for fitting
Definition: RFitPanel.hxx:62
void ProcessData(unsigned connid, const std::string &arg)
Process data from FitPanel OpenUI5-based FitPanel sends commands or status changes.
Definition: RFitPanel.cxx:394
void AssignCanvas(const std::string &cname)
Definition: RFitPanel.hxx:107
bool DoDraw()
Perform drawing using current model settings Returns true if any action was done.
Definition: RFitPanel.cxx:875
void SelectObject(const std::string &objid)
Select object for fitting.
Definition: RFitPanel.cxx:151
1-Dim function class
Definition: TF1.h:213
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:32
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
Definition: TFitResult.h:34
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
Mother of all ROOT objects.
Definition: TObject.h:41
The most important graphics class in the ROOT system.
Definition: TPad.h:28
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Data structure for the fit panel.