157#include "RConfigure.h"
189 if ( strcmp(
f->GetName(),
name ) == 0 )
197 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
199 if ( strcmp(
f->GetName(),
name ) == 0 )
221 if (
dynamic_cast<TF3 *
>(
f) != 0 ) {
229 }
else if (
dynamic_cast<TF2 *
>(
f) != 0 ) {
259 if (npar != (
int) pars.size() ) pars.resize(npar);
260 for (
Int_t i = 0; i < npar; ++i )
276 if (npar > (
int) pars.size() ) pars.resize(npar);
277 for (
Int_t i = 0; i < npar; ++i )
287template<
class FitObject>
291 if (100 == special || 400 == special) {
296 }
else if ( 110 == special || 410 == special ) {
311 static_cast<TGTextLBEntry*
>( dataSet->GetListBox()->GetEntry( dataSet->GetSelected() ) );
312 if (!textEntry)
return;
316 variablesStr = nameStr(nameStr.
First(
'(') + 2, nameStr.
First(
',') - nameStr.
First(
'(') - 3);
318 cutsStr = nameStr( nameStr.
First(
',') + 3, nameStr.
First(
')') - nameStr.
First(
',') - 4 );
335 gROOT->MakeDefCanvas();
414 int parts[] = { 20, 20, 20, 20, 20 };
424 gROOT->GetListOfCleanups()->Add(
this);
448 std::vector<TObject*>
v;
483 if (cw +
size.fWidth < dw) {
484 Int_t gedx = 0, gedy = 0;
486 gedy = (cy > 20) ? cy-20 : 0;
510 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
511 gROOT->GetListOfCleanups()->Remove(
this);
573 bgr -> SetRadioButtonExclusive();
579 fNone -> SetToolTipText(
"No operation defined");
581 fAdd -> SetToolTipText(
"Addition");
583 fNormAdd -> SetToolTipText(
"NormAddition");
585 fConv -> SetToolTipText(
"Convolution");
635 gClient->GetColorByName(
"#336666", color);
925 #ifdef R__HAS_MATHMORE
943 "minimizers to be compiled");
982 TGLabel *errlabel =
new TGLabel(hsv1,
"Error definition (default = 1): ");
985 TGLabel *tollabel =
new TGLabel(hsv1,
"Max tolerance (precision): ");
988 TGLabel *itrlabel =
new TGLabel(hsv1,
"Max number of iterations: ");
1048 fDataSet ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoDataSet(Int_t)");
1050 fTypeFit ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"FillFunctionList(Int_t)");
1052 fFuncList ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoFunction(Int_t)");
1056 fSetParam ->
Connect(
"Clicked()",
"TFitEditor",
this,
"DoSetParameters()");
1058 fAdd ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoAddition(Bool_t)");
1063 fUseRange ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoUseFuncRange()");
1083 fSliderX ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1084 fSliderXMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1085 fSliderXMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1089 fSliderY ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1090 fSliderYMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1091 fSliderYMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1094 fSliderZ ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1100 fLibMinuit ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1102 fLibFumili ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1103 fLibGSL ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1113 fOptQuiet ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoPrintOpt(Bool_t)");
1200 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1201 TQObject::Connect(
"TCanvas",
"Closed()",
"TFitEditor",
this,
"DoNoSelection()");
1216 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
1220 gROOT->GetListOfCleanups()->Remove(
this);
1228 if (!
gROOT->GetListOfCleanups()->FindObject(
this))
1229 gROOT->GetListOfCleanups()->Add(
this);
1309 Error(
"UpdateGUI",
"No hist is present - this should not happen, please report."
1310 "The FitPanel might be in an inconsistent state");
1329 if (ixmin > 1 || ixmax < ixrange) {
1348 fSliderX->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1349 fSliderXMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1350 fSliderXMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1363 Int_t iymin = 0, iymax = 0, iyrange = 0;
1381 if (iymin > 1 || iymax < iyrange) {
1400 fSliderY->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1401 fSliderYMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1402 fSliderYMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1412 Int_t izmin = 0, izmax = 0, izrange = 0;
1430 if (izmin > 1 || izmax < izrange) {
1439 fSliderZ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1477 if ( tmpStr.
Length() == 0 )
1549 if (
gROOT->GetListOfCanvases()->IsEmpty()) {
1586 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1680 if ( strncmp(
f->GetName(),
"PrevFit", 7) != 0 ) {
1687 if (
f->GetNdim() ==
fDim ||
fDim == 0) {
1696 else if(
fDim == 1 ) {
1699 }
else if(
fDim == 2 ) {
1711 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
1722 else if (
fDim == 2 )
1793 TIter canvasIter(canvases);
1798 if (
TPad* can =
dynamic_cast<TPad*
>(obj))
1801 else if (
dynamic_cast<TH1*
>(obj)
1802 ||
dynamic_cast<TGraph*
>(obj)
1805 ||
dynamic_cast<THStack*
>(obj)
1806 ||
dynamic_cast<TTree*
>(obj) ) {
1807 bool insertNew =
true;
1809 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1810 if ( (*i) == obj ) {
1816 if ( insertNew ) objects.push_back(obj);
1836 std::vector<TObject*> objects;
1844 while ( (obj = (
TObject*) next()) ) {
1846 if (
dynamic_cast<TH1*
>(obj) ||
1848 dynamic_cast<TTree*
>(obj) ) {
1849 objects.push_back(obj);
1864 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1869 if ( selEntryStr &&
name == selEntryStr )
1890 c->AddEntry(
"Unbinned Likelihood",
kFP_MUBIN);
1993 "Error...",
"2) Verify the entered function string!",
2025 static TF1 *fitFunc =
nullptr;
2032 std::cout <<
"TFitEditor::DoFit - using function " << fitFunc->
GetName() <<
" " << fitFunc << std::endl;
2035 Error(
"DoFit",
"This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2061 FitObject(
gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2068 FitObject(mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2076 FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2099 if ( !
tree )
return;
2104 tree->Draw(variables,cuts,
"goff");
2106 auto player =
tree->GetPlayer();
2108 Error(
"DoFit",
"Player reference is NULL");
2112 auto selector =
dynamic_cast<TSelectorDraw *
>(player->GetSelector());
2114 Error(
"DoFit",
"Selector reference is NULL");
2119 unsigned int ndim = player->GetDimension();
2121 Error(
"DoFit",
"NDIM == 0");
2125 std::vector<double *> vlist;
2126 for (
unsigned int i = 0; i < ndim; ++i) {
2127 double *
v = selector->GetVal(i);
2128 if (
v != 0) vlist.push_back(
v);
2130 std::cerr <<
"pointer for variable " << i <<
" is zero" << std::endl;
2132 if (vlist.size() != ndim) {
2133 Error(
"DoFit",
"Vector is not complete");
2138 Long64_t nrows = player->GetSelectedRows();
2140 Error(
"DoFit",
"NROWS == 0");
2146 for (
int i = 0; i < std::min(
int(fitdata->
Size()),10); ++i) {
2148 for (
unsigned int j = 0; j < ndim; ++j) {
2149 printf(
" x_%d [%d] = %f \n", j, i,*(fitdata->
Coords(i)+j) );
2171 fitFunc->
Draw(
"same");
2181 if (!strstr(fitFunc->
GetName(),
"PrevFit"))
2187 float xmin = 0.f,
xmax = 0.f,
ymin = 0.f,
ymax = 0.f, zmin = 0.f, zmax = 0.f;
2213 if (save)
gPad = save;
2237 TF1 form(
"tmpCheck", fname);
2239 rvalue = form.
IsValid() ? 0 : -1;
2240 }
else if (
fDim == 2 ) {
2241 TF2 form(
"tmpCheck", fname);
2243 rvalue = form.
IsValid() ? 0 : -1;
2244 }
else if (
fDim == 3 ) {
2245 TF3 form(
"tmpCheck", fname);
2247 rvalue = form.
IsValid() ? 0 : -1;
2295 if (
on)
Info(
"DoNormAddition",
"Normalized addition is selected");
2319 if (
on)
Info(
"DoConvolution",
"Convolution is selected");
2334 if (!textEntry)
return;
2341 if ( className ==
"TTree" ) {
2347 lookStr =
name(0,
name.First(
' '));
2364 char variables[256] = {0};
char cuts[256] = {0};
2365 strlcpy(variables,
"Sin input!", 256);
2367 if ( strcmp ( variables,
"" ) == 0 ) {
2375 TPad* currentPad = NULL;
2377 std::queue<TPad*> stPad;
2380 if (
dynamic_cast<TPad*
>(canvas) )
2381 stPad.push(
dynamic_cast<TPad*
>(canvas));
2384 while ( !stPad.empty() && !found ) {
2385 currentPad = stPad.front();
2389 if ( elem == objSelected ) {
2392 }
else if (
dynamic_cast<TPad*
>(elem) )
2393 stPad.push(
dynamic_cast<TPad*
>(elem) );
2424 bool editable =
false;
2559 "Error...",
"3) Verify the entered function string!",
2730 if (!fitFunc) {
Error(
"DoSetParameters",
"NUll function");
return; }
2807 static Int_t px1old, py1old, px2old, py2old;
2822 Int_t px1,py1,px2,py2;
2846 px1 =
gPad->XtoAbsPixel(xleft);
2848 px2 =
gPad->XtoAbsPixel(xright);
2851 if (
gPad->GetCanvas())
gPad->GetCanvas()->FeedbackMode(
kTRUE);
2852 gPad->SetLineWidth(1);
2853 gPad->SetLineColor(2);
2867 if(save)
gPad = save;
2940 "Info",
"Dialog of user method is not implemented yet",
2992 for (
int i = 0; i < variables.Length() &&
fDim <= 2; ++i )
2993 if (
':' == variables[i] )
fDim += 1;
3004 fDim = ((
TH1*)obj)->GetDimension();
3058 bool isTree =
false;
3065 isTree = strcmp(obj->
ClassName(),
"TTree") == 0;
3067 name =
"No object selected";
3074 if ( selectedEntry ) {
3077 selectedName = selectedName(0, selectedName.
First(
' '));
3078 if (
name.CompareTo(selectedName) == 0 ) {
3089 TString compareName = entry->GetText()->GetString();
3091 compareName = compareName(0, compareName.
First(
' '));
3092 if (
name.CompareTo(compareName) == 0 ) {
3119 while ((obj = next())) {
3293 while ((obj2 = next())) {
3302 if ( strcmp( func->
GetName(), it->second->GetName() ) == 0 )
3304 if ( strcmp( func->
GetName(),
"PrevFitTMP" ) == 0 )
3500 TList *listOfFunctions = 0;
3505 listOfFunctions = ((
TH1 *)
fFitObject)->GetListOfFunctions();
3526 return listOfFunctions;
3542 const unsigned int nfuncs = 16;
3543 const char* fnames[nfuncs] = {
"gaus" ,
"gausn",
"expo",
"landau",
3544 "landaun",
"pol0",
"pol1",
"pol2",
3545 "pol3",
"pol4",
"pol5",
"pol6",
3546 "pol7",
"pol8",
"pol9",
"user"
3550 TIter functionsIter(
gROOT->GetListOfFunctions());
3552 while( ( obj = (
TObject*) functionsIter() ) ) {
3554 if (
TF1* func =
dynamic_cast<TF1*
>(obj) ) {
3555 bool addFunction =
true;
3557 for (
unsigned int i = 0; i < nfuncs; ++i ) {
3558 if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3559 addFunction =
false;
3584 std::pair<fPrevFitIter, fPrevFitIter> look =
fPrevFit.equal_range(obj);
3585 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
3586 retList->
Add(it->second);
3607 "Error...",
"1) Verify the entered function string!",
3615 tmpF1->
Copy(*fitFunc);
3657 if (
fConv -> IsOn())
3666 else if (
fDim == 2 ) {
3669 else if (
fDim == 3 ) {
3682 if ( tmpF1 != 0 && fitFunc != 0 &&
3687 tmpF1->
Copy(*fitFunc);
ULong_t Pixel_t
Pixel value.
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
const Bool_t kIterForward
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
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
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 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 np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
R__EXTERN TPluginManager * gPluginMgr
R__EXTERN void * gTQSender
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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 un-binned 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
Allows to create advanced graphics from the last fit made in the fitpanel.
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.
void SetCursor(ECursor cursor) override
Set cursor.
UInt_t GetWindowWidth() const
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
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 SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
virtual Int_t GetNpar() const
virtual TString GetExpFormula(Option_t *option="") const
virtual void SetParent(TObject *p=nullptr)
virtual Double_t * GetParameters() const
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.
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 lower and upper limits for parameter ipar.
virtual void SetParName(Int_t ipar, const char *name)
Set name of parameter number ipar.
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.