48using namespace std::string_literals;
 
   75   if (func && func->IsZombie())
 
 
  106      fWindow->SetPanelName(
"rootui5.fitpanel.view.FitPanel");
 
  109            [
this](
unsigned connid)
 
  113               if (!
model().fInitialized)
 
  117            [
this](
unsigned connid, 
const std::string &arg) { 
ProcessData(connid, arg); },
 
  118            [
this](unsigned) { 
fConnId = 0; });
 
  120      fWindow->SetGeometry(400, 650); 
 
 
  136      m.fDataSet.emplace_back(
"Panel", 
"panel::"s + obj->GetName(), 
Form(
"%s::%s", obj->ClassName(), obj->GetName()));
 
  141      while ((obj = iter()) != 
nullptr) {
 
 
  157   std::string 
id = objid;
 
  158   if (
id.compare(
"$$$") == 0) {
 
  159      if (
m.fDataSet.size() > 0)
 
  160         id = 
m.fDataSet[0].id;
 
  168   m.SetObjectKind(kind);
 
  177         hist = ((
TGraph*)obj)->GetHistogram();
 
  185         hist = ((
TGraph2D*)obj)->GetHistogram(
"empty");
 
  189         hist = (
TH1 *)((
THStack *)obj)->GetHists()->First();
 
  202      m.fSelectedData = 
"";
 
  204      m.fSelectedData = 
id;
 
  206   m.fInitialized = 
true;
 
  214   std::string 
selfunc = 
m.fSelectedFunc;
 
  217      if (
m.fFuncList.size() > 0)
 
 
  232   if (objid.compare(0,6,
"gdir::") == 0) {
 
  233      std::string 
name = objid.substr(6);
 
  236   } 
else if (objid.compare(0,7,
"panel::") == 0) {
 
  237      std::string 
name = objid.substr(7);
 
  239         if (
name.compare(item->GetName()) == 0)
 
 
  282      m.fFuncList = { {
"gaus"}, {
"gausn"}, {
"expo"}, {
"landau"}, {
"landaun"},
 
  283                    {
"pol0"},{
"pol1"},{
"pol2"},{
"pol3"},{
"pol4"},{
"pol5"},{
"pol6"},{
"pol7"},{
"pol8"},{
"pol9"},
 
  284                    {
"cheb0"}, {
"cheb1"}, {
"cheb2"}, {
"cheb3"}, {
"cheb4"}, {
"cheb5"}, {
"cheb6"}, {
"cheb7"}, {
"cheb8"}, {
"cheb9"} };
 
  285   } 
else if (
m.fDim == 2) {
 
  286      m.fFuncList = { {
"xygaus"}, {
"bigaus"}, {
"xyexpo"}, {
"xylandau"}, {
"xylandaun"} };
 
  290      m.fFuncList.emplace_back(
"System", 
"system::"s + func->GetName(), func->GetName());
 
  294      if (
entry.objid == 
m.fSelectedData)
 
  295         m.fFuncList.emplace_back(
"Previous", 
"previous::"s + 
entry.func->GetName(), 
entry.func->GetName());
 
 
  372      fModel = std::make_unique<RFitPanelModel>();
 
 
  396   if (arg == 
"RELOAD") {
 
  405   } 
else if (arg.compare(0, 7, 
"UPDATE:") == 0) {
 
  410   } 
else if (arg.compare(0, 6, 
"DOFIT:") == 0) {
 
  416   } 
else if (arg.compare(0, 7, 
"DODRAW:") == 0) {
 
  422   } 
else if (arg.compare(0, 8, 
"SETPARS:") == 0) {
 
  424      auto info = TBufferJSON::FromJSON<RFitPanelModel::RFuncParsList>(arg.substr(8));
 
  431            info->SetParameters(func);
 
 
  442   if (
id.compare(0,8,
"system::") == 0) {
 
  443      std::string 
name = 
id.substr(8);
 
  446         if (
name.compare(item->GetName()) == 0)
 
  450   if (
id.compare(0,10,
"previous::") == 0) {
 
  451      std::string 
name = 
id.substr(10);
 
  454         if (
name.compare(
entry.func->GetName()) == 0)
 
  455            return entry.func.get();
 
 
  466   if (
id.compare(0,10,
"previous::") == 0) {
 
  467      std::string 
name = 
id.substr(10);
 
  470         if (
name.compare(
entry.func->GetName()) == 0)
 
  471            return entry.res.Get();
 
 
  482   std::unique_ptr<TF1> res;
 
  490   } 
else if (
funcname.compare(0,6,
"dflt::") == 0) {
 
  492      std::string formula = 
funcname.substr(6);
 
  499      if ( 
model().fDim == 1 || 
model().fDim == 0 ) {
 
  500         res.reset(
new TF1(formula.c_str(), formula.c_str(), 
xmin, 
xmax));
 
  501      } 
else if ( 
model().fDim == 2 ) {
 
  503      } 
else if ( 
model().fDim == 3 ) {
 
 
  519   auto m = TBufferJSON::FromJSON<RFitPanelModel>(
json);
 
  526   m->fInitialized = 
true;
 
  530   if (
model().fSelectedData != 
m->fSelectedData) {
 
  534   if (
model().fSelectedFunc != 
m->fSelectedFunc) {
 
 
  559   if ( 
dynamic_cast<TF3*
>(
f)) {
 
  564      fnew->SetParent( 
nullptr );
 
  565      fnew->AddToGlobalList(
false);
 
  567   } 
else if ( 
dynamic_cast<TF2*
>(
f) != 0 ) {
 
  573      fnew->SetParent( 
nullptr );
 
  574      fnew->AddToGlobalList(
false);
 
  584   if ( 
'\0' != 
fnew->GetExpFormula()[0] )
 
  586   fnew->SetParent( 
nullptr );
 
  587   fnew->AddToGlobalList(
false);
 
 
  602   std::vector<std::string> 
fnames = { 
"gaus" ,   
"gausn", 
"expo", 
"landau",
 
  603                                       "landaun", 
"pol0",  
"pol1", 
"pol2",
 
  604                                       "pol3",    
"pol4",  
"pol5", 
"pol6",
 
  605                                       "pol7",    
"pol8",  
"pol9", 
"user" };
 
  612      if ( 
TF1* func = 
dynamic_cast<TF1*
>(obj) ) {
 
  616            if ( 
name.compare(func->GetName()) == 0 ) {
 
 
  639      if (!
pad) 
return res;
 
  641      TIter next(
pad->GetListOfPrimitives());
 
  643      while (!res && (
prim = next())) {
 
  679   canv->SetName(
"fpc");
 
  680   canv->SetTitle(
"Fit panel drawings");
 
 
  698   if (!obj) 
return false;
 
  702   if (!
f1) 
return false;
 
  720         TH1 *hist = 
dynamic_cast<TH1*
>(obj);
 
  762      gROOT->GetListOfFunctions()->Remove(
f1.get());
 
  764   if (
m.fSame && 
f1 && 
pad) {
 
 
  793   if ((
colorid.length() != 7) || (
colorid.compare(0,1,
"#") != 0)) 
return 0;
 
 
  823   std::vector<Double_t> 
ci(
data->Size());
 
  826   if (
model().fDim == 1) {
 
  828      for (
unsigned int i = 0; i < 
ci.size(); ++i) {
 
  831         g->SetPoint(i, *
x, 
y);
 
  832         g->SetPointError(i, 0, 
ci[i]);
 
  837      g->SetTitle(
"Confidence Intervals with");
 
  840      g->SetLineColor(
icol);
 
  841      g->SetFillColor(
icol);
 
  842      g->SetFillStyle(3001);
 
  844   } 
else if (
model().fDim == 2) {
 
  846      for (
unsigned int i = 0; i < 
ci.size(); ++i) {
 
  849         g->SetPoint(i, 
x[0], 
x[1], 
y);
 
  850         g->SetPointError(i, 0, 0, 
ci[i]);
 
  856      g->SetTitle(
"Confidence Intervals with");
 
  859      g->SetLineColor(
icol);
 
  860      g->SetFillColor(
icol);
 
  861      g->SetFillStyle(3001);
 
 
  877   if (!obj) 
return false;
 
  883   if (
m.fHasAdvanced && (
m.fSelectedTab == 
"Advanced")) {
 
  886      if (!res) 
return false;
 
  888      if (
m.fAdvancedTab == 
"Contour") {
 
  891         int par1 = std::stoi(
m.fContourPar1Id);
 
  892         int par2 = std::stoi(
m.fContourPar2Id);
 
  909      } 
else if (
m.fAdvancedTab == 
"Scan") {
 
  911         int par = std::stoi(
m.fScanId);
 
  913         if (!res->
Scan( par, 
graph, 
m.fScanMin, 
m.fScanMax)) {
 
  920         graph->SetLineWidth(2);
 
  922         graph->GetYaxis()->SetTitle(
"FCN" );
 
  928      } 
else if (
m.fAdvancedTab == 
"Confidence") {
 
  942       if (func && (
m.fSelectedTab.compare(
"Pars") == 0) && (
m.fSelectedFunc == 
m.fFuncPars.id))
 
  943           m.fFuncPars.SetParameters(func);
 
  966   drawobj->Draw(drawopt.c_str());
 
 
#define R__LOG_ERROR(...)
 
RooAbsReal * _func
Pointer to original input function.
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
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 result
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
 
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
 
RFitPanel(const std::string &title="Fit panel")
Constructor.
 
TPad * GetDrawPad(TObject *obj, bool force=false)
Returns pad where histogram is drawn If canvas not exists, create new one.
 
void UpdateDataSet()
Update list of available data.
 
void UpdateFunctionsList()
Update list of available functions.
 
void SelectFunction(const std::string &funcid)
Select fit function.
 
void GetFunctionsFromSystem()
Looks for all the functions registered in the current ROOT session.
 
void ClearOnClose(const std::shared_ptr< void > &handle)
Set handle which will be cleared when connection is closed.
 
RFitPanelModel::EFitObjectType GetFitObjectType(TObject *obj)
Returns kind of object.
 
std::shared_ptr< RCanvas > fCanvas
! v7 canvas used to display results
 
TF1 * FindFunction(const std::string &funcid)
Search for existing functions, ownership still belongs to FitPanel or global lists.
 
std::string fCanvName
! v6 canvas name used to display fit, will be created if not exists
 
std::unique_ptr< RFitPanelModel > fModel
 
void Show(const std::string &where="")
show FitPanel in specified place
 
Color_t GetColor(const std::string &colorid)
Extract color from string Should be coded as #ff00ff string.
 
unsigned fConnId
! client connection id
 
std::string fPadName
! v6 pad name in the canvas, where object is (was) drawn
 
bool DoFit()
Perform fitting using current model settings Returns true if any action was done.
 
std::shared_ptr< ROOT::RWebWindow > fWindow
! configured display
 
TObject * MakeConfidenceLevels(TFitResult *res)
Create confidence levels drawing tab.
 
std::vector< TObject * > fObjects
! objects provided directly to panel for fitting
 
std::unique_ptr< TF1 > GetFitFunction(const std::string &funcid)
Creates new instance to make fitting.
 
void AssignHistogram(TH1 *hist)
Assign histogram to use with fit panel - without ownership.
 
TFitResult * FindFitResult(const std::string &funcid)
Creates new instance to make fitting.
 
TObject * GetSelectedObject(const std::string &objid)
Returns object based on it string id Searches either in gDirectory or in internal panel list.
 
void SendModel()
Send model object to the client.
 
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...
 
void DoPadUpdate(TPad *pad)
Mark pad modified and do update For web canvas set async mode first to avoid blocking here.
 
std::shared_ptr< RH1D > fFitHist
! v7 histogram for fitting
 
RFitPanelModel & model()
Return reference on model object Model created if was not exists before.
 
TF1 * copyTF1(TF1 *f)
Copies f into a new TF1 to be stored in the fitpanel with it's own ownership.
 
std::vector< std::unique_ptr< TF1 > > fSystemFuncs
! local copy of all internal system funcs
 
std::list< FitRes > fPrevRes
! all previous functions used for fitting
 
void ProcessData(unsigned connid, const std::string &arg)
Process data from FitPanel OpenUI5-based FitPanel sends commands or status changes.
 
void AssignCanvas(const std::string &cname)
 
bool DoDraw()
Perform drawing using current model settings Returns true if any action was done.
 
void SelectObject(const std::string &objid)
Select object for fitting.
 
std::shared_ptr< ROOT::RWebWindow > GetWindow()
Returns RWebWindow instance, used to display FitPanel.
 
class describing the range in the coordinates it supports multiple range in a coordinate.
 
std::string ParName(unsigned int i) const
name of the parameter
 
static std::shared_ptr< RWebWindow > Create()
Create new RWebWindow Using default RWebWindowsManager.
 
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
 
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
 
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
 
void Copy(TObject &f1) const override
Copy this F1 to a new F1.
 
void Draw(Option_t *option="") override
Draw this function with its current attributes.
 
TClass * IsA() const override
 
A 2-Dim function with parameters.
 
A 3-Dim function with parameters.
 
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
 
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
 
bool Contour(unsigned int ipar, unsigned int jpar, TGraph *gr, double confLevel=0.683)
Create a 2D contour around the minimum for the parameter ipar and jpar if a minimum does not exist or...
 
bool Scan(unsigned int ipar, TGraph *gr, double xmin=0, double xmax=0)
Scan parameter ipar between value of xmin and xmax A graph must be given which will be on return fill...
 
Graph 2D class with errors.
 
Graphics object made of three arrays X, Y and Z with the same number of points each.
 
A TGraphErrors is a TGraph with error bars.
 
A TGraph is an object made of two arrays X and Y with npoints each.
 
TH1 is the base class of all histogram classes in ROOT.
 
The Histogram stack class.
 
A TMultiGraph is a collection of TGraph (or derived) objects.
 
const char * GetName() const override
Returns name of object.
 
virtual void SetName(const char *name)
Set the name of the TNamed.
 
Mother of all ROOT objects.
 
virtual const char * GetName() const
Returns name of object.
 
virtual const char * ClassName() const
Returns name of class to which the object belongs.
 
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
 
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
 
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
 
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
 
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
 
The most important graphics class in the ROOT system.
 
small helper class to store/restore gPad context in TPad methods
 
RLogChannel & FitPanelLog()
Log channel for FitPanel diagnostics.
 
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
 
Data structure for the fit panel.
 
void UpdateAdvanced(TFitResult *res)
Update advanced parameters associated with fit function.
 
void SelectedFunc(const std::string &name, TF1 *func)
Select function.
 
std::string fTitle
title of the fit panel
 
ROOT::Fit::DataRange GetRanges()
 
std::unique_ptr< TF1 > func