162#include "RConfigure.h"
194 if ( strcmp(
f->GetName(),
name ) == 0 )
202 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
204 if ( strcmp(
f->GetName(),
name ) == 0 )
226 if (
dynamic_cast<TF3 *
>(
f) != 0 ) {
227 TF3* fnew = (
TF3 *)
f->IsA()->New();
234 }
else if (
dynamic_cast<TF2 *
>(
f) != 0 ) {
235 TF2* fnew = (
TF2 *)
f->IsA()->New();
244 TF1* fnew = (
TF1 *)
f->IsA()->New();
264 if (npar != (
int) pars.size() ) pars.resize(npar);
265 for (
Int_t i = 0; i < npar; ++i )
281 if (npar > (
int) pars.size() ) pars.resize(npar);
282 for (
Int_t i = 0; i < npar; ++i )
292template<
class FitObject>
296 if (100 == special || 400 == special) {
301 }
else if ( 110 == special || 410 == special ) {
317 if (!textEntry)
return;
321 variablesStr = nameStr(nameStr.
First(
'(') + 2, nameStr.
First(
',') - nameStr.
First(
'(') - 3);
323 cutsStr = nameStr( nameStr.
First(
',') + 3, nameStr.
First(
')') - nameStr.
First(
',') - 4 );
340 gROOT->MakeDefCanvas();
419 int parts[] = { 20, 20, 20, 20, 20 };
429 gROOT->GetListOfCleanups()->Add(
this);
453 std::vector<TObject*>
v;
488 if (cw + size.
fWidth < dw) {
489 Int_t gedx = 0, gedy = 0;
491 gedy = (cy > 20) ? cy-20 : 0;
515 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
516 gROOT->GetListOfCleanups()->Remove(
this);
578 bgr -> SetRadioButtonExclusive();
584 fNone -> SetToolTipText(
"No operation defined");
586 fAdd -> SetToolTipText(
"Addition");
588 fNormAdd -> SetToolTipText(
"NormAddition");
590 fConv -> SetToolTipText(
"Convolution");
640 gClient->GetColorByName(
"#336666", color);
930 #ifdef R__HAS_MATHMORE
948 "minimizers to be compiled");
987 TGLabel *errlabel =
new TGLabel(hsv1,
"Error definition (default = 1): ");
990 TGLabel *tollabel =
new TGLabel(hsv1,
"Max tolerance (precision): ");
993 TGLabel *itrlabel =
new TGLabel(hsv1,
"Max number of iterations: ");
1053 fDataSet ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoDataSet(Int_t)");
1055 fTypeFit ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"FillFunctionList(Int_t)");
1057 fFuncList ->
Connect(
"Selected(Int_t)",
"TFitEditor",
this,
"DoFunction(Int_t)");
1061 fSetParam ->
Connect(
"Clicked()",
"TFitEditor",
this,
"DoSetParameters()");
1063 fAdd ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoAddition(Bool_t)");
1068 fUseRange ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoUseFuncRange()");
1088 fSliderX ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1089 fSliderXMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1090 fSliderXMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1094 fSliderY ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1095 fSliderYMax ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1096 fSliderYMin ->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1099 fSliderZ ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1105 fLibMinuit ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1107 fLibFumili ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1108 fLibGSL ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoLibrary(Bool_t)");
1118 fOptQuiet ->
Connect(
"Toggled(Bool_t)",
"TFitEditor",
this,
"DoPrintOpt(Bool_t)");
1205 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1206 TQObject::Connect(
"TCanvas",
"Closed()",
"TFitEditor",
this,
"DoNoSelection()");
1221 this,
"SetFitObject(TVirtualPad *, TObject *, Int_t)");
1225 gROOT->GetListOfCleanups()->Remove(
this);
1233 if (!
gROOT->GetListOfCleanups()->FindObject(
this))
1234 gROOT->GetListOfCleanups()->Add(
this);
1314 Error(
"UpdateGUI",
"No hist is present - this should not happen, please report."
1315 "The FitPanel might be in an inconsistent state");
1334 if (ixmin > 1 || ixmax < ixrange) {
1353 fSliderX->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderXMoved()");
1354 fSliderXMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1355 fSliderXMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderXChanged()");
1368 Int_t iymin = 0, iymax = 0, iyrange = 0;
1386 if (iymin > 1 || iymax < iyrange) {
1405 fSliderY->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderYMoved()");
1406 fSliderYMax->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1407 fSliderYMin->
Connect(
"ValueSet(Long_t)",
"TFitEditor",
this,
"DoNumericSliderYChanged()");
1417 Int_t izmin = 0, izmax = 0, izrange = 0;
1435 if (izmin > 1 || izmax < izrange) {
1444 fSliderZ->
Connect(
"PositionChanged()",
"TFitEditor",
this,
"DoSliderZMoved()");
1482 if ( tmpStr.
Length() == 0 )
1554 if (
gROOT->GetListOfCanvases()->IsEmpty()) {
1591 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1685 if ( strncmp(
f->GetName(),
"PrevFit", 7) != 0 ) {
1692 if (
f->GetNdim() ==
fDim ||
fDim == 0) {
1701 else if(
fDim == 1 ) {
1704 }
else if(
fDim == 2 ) {
1716 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
1727 else if (
fDim == 2 )
1798 TIter canvasIter(canvases);
1803 if (
TPad* can =
dynamic_cast<TPad*
>(obj))
1806 else if (
dynamic_cast<TH1*
>(obj)
1807 ||
dynamic_cast<TGraph*
>(obj)
1810 ||
dynamic_cast<THStack*
>(obj)
1811 ||
dynamic_cast<TTree*
>(obj) ) {
1812 bool insertNew =
true;
1814 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1815 if ( (*i) == obj ) {
1821 if ( insertNew ) objects.push_back(obj);
1841 std::vector<TObject*> objects;
1849 while ( (obj = (
TObject*) next()) ) {
1851 if (
dynamic_cast<TH1*
>(obj) ||
1853 dynamic_cast<TTree*
>(obj) ) {
1854 objects.push_back(obj);
1869 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1874 if ( selEntryStr &&
name == selEntryStr )
1895 c->AddEntry(
"Unbinned Likelihood",
kFP_MUBIN);
1998 "Error...",
"2) Verify the entered function string!",
2030 static TF1 *fitFunc =
nullptr;
2037 std::cout <<
"TFitEditor::DoFit - using function " << fitFunc->
GetName() <<
" " << fitFunc << std::endl;
2040 Error(
"DoFit",
"This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2066 FitObject(
gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2073 FitObject(
mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2081 FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2104 if ( !
tree )
return;
2113 Error(
"DoFit",
"Player reference is NULL");
2119 Error(
"DoFit",
"Selector reference is NULL");
2126 Error(
"DoFit",
"NDIM == 0");
2130 std::vector<double *> vlist;
2131 for (
unsigned int i = 0; i < ndim; ++i) {
2132 double *
v = selector->
GetVal(i);
2133 if (
v != 0) vlist.push_back(
v);
2135 std::cerr <<
"pointer for variable " << i <<
" is zero" << std::endl;
2137 if (vlist.size() != ndim) {
2138 Error(
"DoFit",
"Vector is not complete");
2145 Error(
"DoFit",
"NROWS == 0");
2151 for (
int i = 0; i < std::min(
int(fitdata->
Size()),10); ++i) {
2153 for (
unsigned int j = 0; j < ndim; ++j) {
2154 printf(
" x_%d [%d] = %f \n", j, i,*(fitdata->
Coords(i)+j) );
2176 fitFunc->
Draw(
"same");
2186 if (!strstr(fitFunc->
GetName(),
"PrevFit"))
2192 float xmin = 0.f,
xmax = 0.f,
ymin = 0.f,
ymax = 0.f, zmin = 0.f, zmax = 0.f;
2218 if (save)
gPad = save;
2242 TF1 form(
"tmpCheck", fname);
2244 rvalue = form.
IsValid() ? 0 : -1;
2245 }
else if (
fDim == 2 ) {
2246 TF2 form(
"tmpCheck", fname);
2248 rvalue = form.
IsValid() ? 0 : -1;
2249 }
else if (
fDim == 3 ) {
2250 TF3 form(
"tmpCheck", fname);
2252 rvalue = form.
IsValid() ? 0 : -1;
2300 if (on)
Info(
"DoNormAddition",
"Normalized addition is selected");
2324 if (on)
Info(
"DoConvolution",
"Convolution is selected");
2339 if (!textEntry)
return;
2346 if ( className ==
"TTree" ) {
2352 lookStr =
name(0,
name.First(
' '));
2354 objSelected =
gROOT->FindObject(lookStr);
2369 char variables[256] = {0};
char cuts[256] = {0};
2380 TPad* currentPad = NULL;
2382 std::queue<TPad*> stPad;
2385 if (
dynamic_cast<TPad*
>(canvas) )
2386 stPad.push(
dynamic_cast<TPad*
>(canvas));
2389 while ( !stPad.empty() && !found ) {
2390 currentPad = stPad.front();
2394 if ( elem == objSelected ) {
2397 }
else if (
dynamic_cast<TPad*
>(elem) )
2398 stPad.push(
dynamic_cast<TPad*
>(elem) );
2429 bool editable =
false;
2564 "Error...",
"3) Verify the entered function string!",
2735 if (!fitFunc) {
Error(
"DoSetParameters",
"NUll function");
return; }
2811 static Int_t px1old, py1old, px2old, py2old;
2823 Int_t px1,py1,px2,py2;
2847 px1 =
gPad->XtoAbsPixel(xleft);
2849 px2 =
gPad->XtoAbsPixel(xright);
2852 if (
gPad->GetCanvas())
gPad->GetCanvas()->FeedbackMode(
kTRUE);
2853 gPad->SetLineWidth(1);
2854 gPad->SetLineColor(2);
2864 if(save)
gPad = save;
2937 "Info",
"Dialog of user method is not implemented yet",
3001 fDim = ((
TH1*)obj)->GetDimension();
3055 bool isTree =
false;
3062 isTree = strcmp(obj->
ClassName(),
"TTree") == 0;
3064 name =
"No object selected";
3071 if ( selectedEntry ) {
3074 selectedName = selectedName(0, selectedName.
First(
' '));
3075 if (
name.CompareTo(selectedName) == 0 ) {
3086 TString compareName = entry->GetText()->GetString();
3088 compareName = compareName(0, compareName.
First(
' '));
3089 if (
name.CompareTo(compareName) == 0 ) {
3116 while ((obj = next())) {
3290 while ((obj2 = next())) {
3299 if ( strcmp( func->
GetName(), it->second->GetName() ) == 0 )
3301 if ( strcmp( func->
GetName(),
"PrevFitTMP" ) == 0 )
3354 (tmpStr.Contains(
"pol") || tmpStr.Contains(
"++")) )
3497 TList *listOfFunctions = 0;
3502 listOfFunctions = ((
TH1 *)
fFitObject)->GetListOfFunctions();
3523 return listOfFunctions;
3539 const unsigned int nfuncs = 16;
3540 const char* fnames[nfuncs] = {
"gaus" ,
"gausn",
"expo",
"landau",
3541 "landaun",
"pol0",
"pol1",
"pol2",
3542 "pol3",
"pol4",
"pol5",
"pol6",
3543 "pol7",
"pol8",
"pol9",
"user"
3547 TIter functionsIter(
gROOT->GetListOfFunctions());
3549 while( ( obj = (
TObject*) functionsIter() ) ) {
3551 if (
TF1* func =
dynamic_cast<TF1*
>(obj) ) {
3552 bool addFunction =
true;
3554 for (
unsigned int i = 0; i < nfuncs; ++i ) {
3555 if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3556 addFunction =
false;
3581 std::pair<fPrevFitIter, fPrevFitIter> look =
fPrevFit.equal_range(obj);
3582 for (
fPrevFitIter it = look.first; it != look.second; ++it ) {
3583 retList->
Add(it->second);
3604 "Error...",
"1) Verify the entered function string!",
3611 fitFunc = (
TF1*)tmpF1->IsA()->New();
3612 tmpF1->
Copy(*fitFunc);
3654 if (
fConv -> IsOn())
3663 else if (
fDim == 2 ) {
3666 else if (
fDim == 3 ) {
3679 if ( tmpF1 != 0 && fitFunc != 0 &&
3684 tmpF1->
Copy(*fitFunc);
std::multimap< TObject *, TF1 * >::iterator fPrevFitIter
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
<