163#include "RConfigure.h"
195 if ( strcmp(
f->GetName(),
name ) == 0 )
203 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
205 if ( strcmp(
f->GetName(),
name ) == 0 )
227 if (
dynamic_cast<TF3 *
>(
f) != 0 ) {
228 TF3* fnew = (
TF3 *)
f->IsA()->New();
235 }
else if (
dynamic_cast<TF2 *
>(
f) != 0 ) {
236 TF2* fnew = (
TF2 *)
f->IsA()->New();
245 TF1* fnew = (
TF1 *)
f->IsA()->New();
265 if (npar != (
int) pars.size() ) pars.resize(npar);
266 for (
Int_t i = 0; i < npar; ++i )
282 if (npar > (
int) pars.size() ) pars.resize(npar);
283 for (
Int_t i = 0; i < npar; ++i )
293template<
class FitObject>
297 if (100 == special || 400 == special) {
302 }
else if ( 110 == special || 410 == special ) {
318 if (!textEntry)
return;
322 variablesStr = nameStr(nameStr.
First(
'(') + 2, nameStr.
First(
',') - nameStr.
First(
'(') - 3);
324 cutsStr = nameStr( nameStr.
First(
',') + 3, nameStr.
First(
')') - nameStr.
First(
',') - 4 );
341 gROOT->MakeDefCanvas();
420 int parts[] = { 20, 20, 20, 20, 20 };
430 gROOT->GetListOfCleanups()->Add(
this);
454 std::vector<TObject*>
v;
489 if (cw + size.
fWidth < dw) {
490 Int_t gedx = 0, gedy = 0;
492 gedy = (cy > 20) ? cy-20 : 0;
516 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
517 gROOT->GetListOfCleanups()->Remove(
this);
579 bgr -> SetRadioButtonExclusive();
585 fNone -> SetToolTipText(
"No operation defined");
587 fAdd -> SetToolTipText(
"Addition");
589 fNormAdd -> SetToolTipText(
"NormAddition");
591 fConv -> SetToolTipText(
"Convolution");
641 gClient->GetColorByName(
"#336666", color);
931 #ifdef R__HAS_MATHMORE
949 "minimizers to be compiled");
988 TGLabel *errlabel =
new TGLabel(hsv1,
"Error definition (default = 1): ");
991 TGLabel *tollabel =
new TGLabel(hsv1,
"Max tolerance (precision): ");
994 TGLabel *itrlabel =
new TGLabel(hsv1,
"Max number of iterations: ");
1054 fDataSet ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoDataSet(Int_t)");
1056 fTypeFit ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"FillFunctionList(Int_t)");
1058 fFuncList ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoFunction(Int_t)");
1062 fSetParam ->
Connect(
"Clicked()",
"TFitEditor",
this,
"DoSetParameters()");
1064 fAdd ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoAddition(Bool_t)");
1069 fUseRange ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoUseFuncRange()");
1089 fSliderX ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1090 fSliderXMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1091 fSliderXMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1095 fSliderY ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1096 fSliderYMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1097 fSliderYMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1100 fSliderZ ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1106 fLibMinuit ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1108 fLibFumili ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1109 fLibGSL ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1119 fOptQuiet ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoPrintOpt(Bool_t)");
1206 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1207 TQObject::Connect(
"TCanvas",
"Closed()",
"TFitEditor",
this,
"DoNoSelection()");
1222 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
1226 gROOT->GetListOfCleanups()->Remove(
this);
1234 if (!
gROOT->GetListOfCleanups()->FindObject(
this))
1235 gROOT->GetListOfCleanups()->Add(
this);
1315 Error(
"UpdateGUI",
"No hist is present - this should not happen, please report."
1316 "The FitPanel might be in an inconsistent state");
1335 if (ixmin > 1 || ixmax < ixrange) {
1354 fSliderX->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1355 fSliderXMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1356 fSliderXMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1369 Int_t iymin = 0, iymax = 0, iyrange = 0;
1387 if (iymin > 1 || iymax < iyrange) {
1406 fSliderY->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1407 fSliderYMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1408 fSliderYMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1418 Int_t izmin = 0, izmax = 0, izrange = 0;
1436 if (izmin > 1 || izmax < izrange) {
1445 fSliderZ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1483 if ( tmpStr.
Length() == 0 )
1555 if (
gROOT->GetListOfCanvases()->IsEmpty()) {
1592 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1686 if ( strncmp(
f->GetName(),
"PrevFit", 7) != 0 ) {
1693 if (
f->GetNdim() ==
fDim ||
fDim == 0) {
1702 else if(
fDim == 1 ) {
1705 }
else if(
fDim == 2 ) {
1717 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
1728 else if (
fDim == 2 )
1799 TIter canvasIter(canvases);
1804 if (
TPad* can =
dynamic_cast<TPad*
>(obj))
1807 else if (
dynamic_cast<TH1*
>(obj)
1808 ||
dynamic_cast<TGraph*
>(obj)
1811 ||
dynamic_cast<THStack*
>(obj)
1812 ||
dynamic_cast<TTree*
>(obj) ) {
1813 bool insertNew =
true;
1815 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1816 if ( (*i) == obj ) {
1822 if ( insertNew ) objects.push_back(obj);
1842 std::vector<TObject*> objects;
1850 while ( (obj = (
TObject*) next()) ) {
1852 if (
dynamic_cast<TH1*
>(obj) ||
1854 dynamic_cast<TTree*
>(obj) ) {
1855 objects.push_back(obj);
1870 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1875 if ( selEntryStr &&
name == selEntryStr )
1896 c->AddEntry(
"Unbinned Likelihood",
kFP_MUBIN);
1999 "Error...",
"2) Verify the entered function string!",
2031 static TF1 *fitFunc =
nullptr;
2038 std::cout <<
"TFitEditor::DoFit - using function " << fitFunc->
GetName() <<
" " << fitFunc << std::endl;
2041 Error(
"DoFit",
"This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2067 FitObject(
gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2074 FitObject(
mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2082 FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2105 if ( !
tree )
return;
2112 auto player =
tree->GetPlayer();
2114 Error(
"DoFit",
"Player reference is NULL");
2118 auto selector =
dynamic_cast<TSelectorDraw *
>(player->GetSelector());
2120 Error(
"DoFit",
"Selector reference is NULL");
2125 unsigned int ndim = player->GetDimension();
2127 Error(
"DoFit",
"NDIM == 0");
2131 std::vector<double *> vlist;
2132 for (
unsigned int i = 0; i < ndim; ++i) {
2133 double *
v = selector->GetVal(i);
2134 if (
v != 0) vlist.push_back(
v);
2136 std::cerr <<
"pointer for variable " << i <<
" is zero" << std::endl;
2138 if (vlist.size() != ndim) {
2139 Error(
"DoFit",
"Vector is not complete");
2144 Long64_t nrows = player->GetSelectedRows();
2146 Error(
"DoFit",
"NROWS == 0");
2152 for (
int i = 0; i < std::min(
int(fitdata->
Size()),10); ++i) {
2154 for (
unsigned int j = 0; j < ndim; ++j) {
2155 printf(
" x_%d [%d] = %f \n", j, i,*(fitdata->
Coords(i)+j) );
2177 fitFunc->
Draw(
"same");
2187 if (!strstr(fitFunc->
GetName(),
"PrevFit"))
2193 float xmin = 0.f,
xmax = 0.f,
ymin = 0.f,
ymax = 0.f, zmin = 0.f, zmax = 0.f;
2219 if (save)
gPad = save;
2243 TF1 form(
"tmpCheck", fname);
2245 rvalue = form.
IsValid() ? 0 : -1;
2246 }
else if (
fDim == 2 ) {
2247 TF2 form(
"tmpCheck", fname);
2249 rvalue = form.
IsValid() ? 0 : -1;
2250 }
else if (
fDim == 3 ) {
2251 TF3 form(
"tmpCheck", fname);
2253 rvalue = form.
IsValid() ? 0 : -1;
2301 if (on)
Info(
"DoNormAddition",
"Normalized addition is selected");
2325 if (on)
Info(
"DoConvolution",
"Convolution is selected");
2340 if (!textEntry)
return;
2347 if ( className ==
"TTree" ) {
2353 lookStr =
name(0,
name.First(
' '));
2355 objSelected =
gROOT->FindObject(lookStr);
2370 char variables[256] = {0};
char cuts[256] = {0};
2381 TPad* currentPad = NULL;
2383 std::queue<TPad*> stPad;
2386 if (
dynamic_cast<TPad*
>(canvas) )
2387 stPad.push(
dynamic_cast<TPad*
>(canvas));
2390 while ( !stPad.empty() && !found ) {
2391 currentPad = stPad.front();
2395 if ( elem == objSelected ) {
2398 }
else if (
dynamic_cast<TPad*
>(elem) )
2399 stPad.push(
dynamic_cast<TPad*
>(elem) );
2430 bool editable =
false;
2565 "Error...",
"3) Verify the entered function string!",
2736 if (!fitFunc) {
Error(
"DoSetParameters",
"NUll function");
return; }
2812 static Int_t px1old, py1old, px2old, py2old;
2824 Int_t px1,py1,px2,py2;
2848 px1 =
gPad->XtoAbsPixel(xleft);
2850 px2 =
gPad->XtoAbsPixel(xright);
2853 if (
gPad->GetCanvas())
gPad->GetCanvas()->FeedbackMode(
kTRUE);
2854 gPad->SetLineWidth(1);
2855 gPad->SetLineColor(2);
2865 if(save)
gPad = save;
2938 "Info",
"Dialog of user method is not implemented yet",
3002 fDim = ((
TH1*)obj)->GetDimension();
3056 bool isTree =
false;
3063 isTree = strcmp(obj->
ClassName(),
"TTree") == 0;
3065 name =
"No object selected";
3072 if ( selectedEntry ) {
3075 selectedName = selectedName(0, selectedName.
First(
' '));
3076 if (
name.CompareTo(selectedName) == 0 ) {
3087 TString compareName = entry->GetText()->GetString();
3089 compareName = compareName(0, compareName.
First(
' '));
3090 if (
name.CompareTo(compareName) == 0 ) {
3117 while ((obj = next())) {
3291 while ((obj2 = next())) {
3300 if ( strcmp( func->
GetName(), it->second->GetName() ) == 0 )
3302 if ( strcmp( func->
GetName(),
"PrevFitTMP" ) == 0 )
3355 (tmpStr.Contains(
"pol") || tmpStr.Contains(
"++")) )
3498 TList *listOfFunctions = 0;
3503 listOfFunctions = ((
TH1 *)
fFitObject)->GetListOfFunctions();
3524 return listOfFunctions;
3540 const unsigned int nfuncs = 16;
3541 const char* fnames[nfuncs] = {
"gaus" ,
"gausn",
"expo",
"landau",
3542 "landaun",
"pol0",
"pol1",
"pol2",
3543 "pol3",
"pol4",
"pol5",
"pol6",
3544 "pol7",
"pol8",
"pol9",
"user"
3548 TIter functionsIter(
gROOT->GetListOfFunctions());
3550 while( ( obj = (
TObject*) functionsIter() ) ) {
3552 if (
TF1* func =
dynamic_cast<TF1*
>(obj) ) {
3553 bool addFunction =
true;
3555 for (
unsigned int i = 0; i < nfuncs; ++i ) {
3556 if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3557 addFunction =
false;
3582 std::pair<fPrevFitIter, fPrevFitIter> look =
fPrevFit.equal_range(obj);
3583 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
3584 retList->
Add(it->second);
3605 "Error...",
"1) Verify the entered function string!",
3612 fitFunc = (
TF1*)tmpF1->IsA()->New();
3613 tmpF1->
Copy(*fitFunc);
3655 if (
fConv -> IsOn())
3664 else if (
fDim == 2 ) {
3667 else if (
fDim == 3 ) {
3680 if ( tmpF1 != 0 && fitFunc != 0 &&
3685 tmpF1->
Copy(*fitFunc);
const Bool_t kIterForward
TF1 * copyTF1(TF1 *f)
Copies f into a new TF1 to be stored in the fitpanel with it's own ownership.
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Stores the parameters of the given function into pars.
void InitParameters(TF1 *func, FitObject *fitobj)
Parameter initialization for the function.
void GetTreeVarsAndCuts(TGComboBox *dataSet, TString &variablesStr, TString &cutsStr)
Splits the entry in fDataSet to get the selected variables and cuts from the text.
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function.
void SearchCanvases(TSeqCollection *canvases, std::vector< TObject * > &objects)
std::multimap< TObject *, TF1 * > FitFuncMap_t
R__EXTERN TPluginManager * gPluginMgr
R__EXTERN void * gTQSender
char * Form(const char *fmt,...)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
class describing the range in the coordinates it supports multiple range in a coordinate.
void AddRange(unsigned int icoord, double xmin, double xmax)
add a range [xmin,xmax] for the new coordinate icoord Adding a range does not delete existing one,...
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
unsigned int Size() const
return number of fit points
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
void SetMinimizerType(const char *type)
set minimizer type
static double DefaultTolerance()
static const std::string & DefaultMinimizerType()
void SetErrorDef(double err)
set error def
static int DefaultMaxIterations()
static double DefaultErrorDef()
void SetMinimizerAlgorithm(const char *type)
set minimizer algorithm
void SetTolerance(double tol)
set the tolerance
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Int_t GetWindowTopY()
Returns current top y position of window on screen.
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
virtual void SetCursor(ECursor cursor)
Set cursor.
UInt_t GetWindowWidth() const
Class wrapping convolution of two functions.
const char * GetParName(Int_t ipar) const
Class adding two functions: c1*f1+c2*f2.
const char * GetParName(Int_t ipar) const
Int_t GetNpar() const
Return the number of (non constant) parameters including the coefficients: for 2 functions: c1,...
virtual Int_t GetNumber() const
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
virtual void SetParent(TObject *p=0)
virtual Int_t GetNpar() const
virtual TString GetExpFormula(Option_t *option="") const
virtual Double_t * GetParameters() const
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
virtual void SetParName(Int_t ipar, const char *name)
Set name of parameter number ipar.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual Bool_t IsValid() const
Return kTRUE if the function is valid.
virtual void SetParameters(const Double_t *params)
virtual void SetParameter(Int_t param, Double_t value)
virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax)
Save values of function in array fSave.
virtual Bool_t AddToGlobalList(Bool_t on=kTRUE)
Add to global list of functions (gROOT->GetListOfFunctions() ) return previous status (true if the fu...
virtual Double_t GetParameter(Int_t ipar) const
A 2-Dim function with parameters.