Skip to content
Snippets Groups Projects
Commit 41d3fbb3 authored by Sergey Linev's avatar Sergey Linev Committed by Axel Naumann
Browse files

web fitpanel: let perform fit without update of model

parent 0af242ba
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,7 @@ class RFitPanel { ...@@ -52,7 +52,7 @@ class RFitPanel {
int UpdateModel(const std::string &json); int UpdateModel(const std::string &json);
void DoFit(const std::string &model); bool DoFit();
void DrawContour(const std::string &model); void DrawContour(const std::string &model);
......
...@@ -125,6 +125,11 @@ void ROOT::Experimental::RFitPanel::Hide() ...@@ -125,6 +125,11 @@ void ROOT::Experimental::RFitPanel::Hide()
fWindow->CloseConnections(); fWindow->CloseConnections();
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Return reference on model object
/// Model created if was not exists before
ROOT::Experimental::RFitPanelModel &ROOT::Experimental::RFitPanel::model() ROOT::Experimental::RFitPanelModel &ROOT::Experimental::RFitPanel::model()
{ {
if (!fModel) if (!fModel)
...@@ -171,7 +176,9 @@ void ROOT::Experimental::RFitPanel::ProcessData(unsigned connid, const std::stri ...@@ -171,7 +176,9 @@ void ROOT::Experimental::RFitPanel::ProcessData(unsigned connid, const std::stri
} else if (arg.compare(0, 6, "DOFIT:") == 0) { } else if (arg.compare(0, 6, "DOFIT:") == 0) {
DoFit(arg.substr(6)); if (UpdateModel(arg.substr(6)) >= 0)
if (DoFit())
SendModel();
} else if (arg.compare(0, 11, "SETCONTOUR:") == 0) { } else if (arg.compare(0, 11, "SETCONTOUR:") == 0) {
...@@ -207,6 +214,7 @@ void ROOT::Experimental::RFitPanel::ProcessData(unsigned connid, const std::stri ...@@ -207,6 +214,7 @@ void ROOT::Experimental::RFitPanel::ProcessData(unsigned connid, const std::stri
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Dummy function, called when "Fit" button pressed in UI /// Dummy function, called when "Fit" button pressed in UI
void ROOT::Experimental::RFitPanel::DrawContour(const std::string &model) void ROOT::Experimental::RFitPanel::DrawContour(const std::string &model)
{ {
// FIXME: do not use static!!! // FIXME: do not use static!!!
...@@ -339,11 +347,12 @@ int ROOT::Experimental::RFitPanel::UpdateModel(const std::string &json) ...@@ -339,11 +347,12 @@ int ROOT::Experimental::RFitPanel::UpdateModel(const std::string &json)
return res; return res;
} }
///////////////////////////////////////////////
/// Perform fitting using current model settings
/// Returns true if any action was done
void ROOT::Experimental::RFitPanel::DoFit(const std::string &json) bool ROOT::Experimental::RFitPanel::DoFit()
{ {
if (UpdateModel(json) < 0) return;
auto &m = model(); auto &m = model();
ROOT::Math::MinimizerOptions minOption; ROOT::Math::MinimizerOptions minOption;
...@@ -377,18 +386,17 @@ void ROOT::Experimental::RFitPanel::DoFit(const std::string &json) ...@@ -377,18 +386,17 @@ void ROOT::Experimental::RFitPanel::DoFit(const std::string &json)
TF1 *f1 = m.FindFunction(m.fSelectedFunc, h1); TF1 *f1 = m.FindFunction(m.fSelectedFunc, h1);
if (!h1 || !f1) return false;
auto pad = GetDrawPad(h1); auto pad = GetDrawPad(h1);
// Assign the options to Fitting function h1->Fit(f1, opt.c_str(), "*", m.fRangeX[0], m.fRangeX[1]);
if (h1 && f1) {
h1->Fit(f1, opt.c_str(), "*", m.fRangeX[0], m.fRangeX[1]);
if (pad) pad->Update(); if (pad) pad->Update();
auto *fres = m.UpdateFuncList(h1, true); auto *fres = m.UpdateFuncList(h1, true);
m.UpdateAdvanced(fres); m.UpdateAdvanced(fres);
}
SendModel(); // provide client with latest changes return true; // provide client with latest changes
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment