ROOT  6.06/09
Reference Guide
TFitEditor.cxx
Go to the documentation of this file.
1 // @(#)root/fitpanel:$Id: ed8d59036b6a51c67cd739c2c75aa7780b847bf8 $
2 // Author: Ilka Antcheva, Lorenzo Moneta 10/08/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 //////////////////////////////////////////////////////////////////////////
14 // //
15 // TFitEditor //
16 // //
17 // Allows to perform, explore and compare various fits. //
18 // //
19 // To display the new Fit panel interface right click on a histogram //
20 // or a graph to pop up the context menu and then select the menu //
21 // entry 'Fit Panel'. //
22 // //
23 // "General" Tab //
24 // //
25 // The first set of GUI elements is related to the function choice //
26 // and settings. The status bar on the bottom provides information //
27 // about the current minimization settings using the following //
28 // abbreviations: //
29 // LIB - shows the current choice between Minuit/Minuit2/Fumili //
30 // MIGRAD or FUMILI points to the current minimization method in use. //
31 // Itr: - shows the maximum number of iterations nnnn set for the fit. //
32 // Prn: - can be DEF/VER/QT and shows the current print option in use. //
33 // //
34 // "Predefined" combo box - contains a list of predefined functions //
35 // in ROOT. The default one is Gaussian. //
36 // //
37 // "Operation" radio button group defines selected operational mode //
38 // between functions: NOP - no operation (default); ADD - addition //
39 // CONV - convolution (will be implemented in the future). //
40 // //
41 // Users can enter the function expression in a text entry field. //
42 // The entered string is checked after Enter key was pressed. An //
43 // error message shows up if the string is not accepted. The current //
44 // prototype is limited and users have no freedom to enter file/user //
45 // function names in this field. //
46 // //
47 // "Set Parameters" button opens a dialog for parameters settings. //
48 // //
49 // "Fit Settings" provides user interface elements related to the //
50 // fitter. Currently there are two method choices: Chi-square and //
51 // Binned Likelihood. //
52 // //
53 // "Linear Fit" check button sets the use of Linear fitter is it is //
54 // selected. Otherwise the option 'F' is applied if polN is selected. //
55 // "Robust" number entry sets the robust value when fitting graphs. //
56 // "No Chi-square" check button sets ON/OFF option 'C' - do not //
57 // calculate Chi-square (for Linear fitter). //
58 // //
59 // Fit options: //
60 // "Integral" check button switch ON/OFF option 'I' - use integral //
61 // of function instead of value in bin center. //
62 // "Best Errors" sets ON/OFF option 'E' - better errors estimation //
63 // using Minos technique. //
64 // "All weights = 1" sets ON/OFF option 'W' - all weights set to 1, //
65 // excluding empty bins and ignoring error bars. //
66 // "Empty bins, weights=1" sets ON/OFF option 'WW' - all weights //
67 // equal to 1, including empty bins, error bars ignored. //
68 // "Use range" sets ON/OFF option 'R' - fit only data within the //
69 // specified function range with the slider. //
70 // "Improve fit results" sets ON/OFF option 'M' - after minimum is //
71 // found, search for a new one. //
72 // "Add to list" sets On/Off option '+'- add function to the list //
73 // without deleting the previous. //
74 // //
75 // Draw options: //
76 // "SAME" sets On/Off function drawing on the same pad. //
77 // "No drawing" sets On/Off option '0'- do not draw function graphics. //
78 // "Do not store/draw" sets On/Off option 'N'- do not store the //
79 // function, do not draw it. //
80 // //
81 // Sliders settings are used if option 'R' - use range is active. //
82 // Users can change min/max values by pressing the left mouse button //
83 // near to the left/right slider edges. It is possible o change both //
84 // values simultaneously by pressing the left mouse button near to its //
85 // center and moving it to a new desire position. //
86 // //
87 // "Minimization" Tab //
88 // //
89 // "Library" group allows you to use Minuit, Minuit2 or Fumili //
90 // minimization packages for your fit. //
91 // "Minuit" - the popular Minuit minimization package. //
92 // "Minuit2" - a new object-oriented implementation of Minuit in C++. //
93 // "Fumili" - the popular Fumili minimization package. //
94 // //
95 // "Method" group has currently restricted functionality. //
96 // "MIGRAD" method is available for Minuit and Minuit2 //
97 // "FUMILI" method is available for Fumili and Minuit2 //
98 // "SIMPLEX" method is disabled (will come with the new fitter design) //
99 // //
100 // "Minimization Settings' group allows users to set values for: //
101 // "Error definition" - between 0.0 and 100.0 (default is 1.0). //
102 // "Maximum tolerance" - the fit relative precision in use. //
103 // "Maximum number of iterations" - default is 5000. //
104 // //
105 // Print options: //
106 // "Default" - between Verbose and Quiet. //
107 // "Verbose" - prints results after each iteration. //
108 // "Quiet" - no fit information is printed. //
109 // //
110 // Fit button - performs a fit. //
111 // Reset - resets all GUI elements and related fit settings to the //
112 // default ones. //
113 // Close - closes this window. //
114 // //
115 // Begin_Html //
116 /*
117 <img src="gif/TFitEditor.gif">
118 */
119 //End_Html
120 //////////////////////////////////////////////////////////////////////////
121 
122 #include "TFitEditor.h"
123 #include "TROOT.h"
124 #include "TClass.h"
125 #include "TCanvas.h"
126 #include "TGTab.h"
127 #include "TGLabel.h"
128 #include "TG3DLine.h"
129 #include "TGComboBox.h"
130 #include "TGTextEntry.h"
131 #include "TGFont.h"
132 #include "TGGC.h"
133 #include "TGButtonGroup.h"
134 #include "TGNumberEntry.h"
135 #include "TGDoubleSlider.h"
136 #include "TGStatusBar.h"
137 #include "TFitParametersDialog.h"
138 #include "TGMsgBox.h"
139 #include "TAxis.h"
140 #include "TGraph.h"
141 #include "TGraph2D.h"
142 #include "TH1.h"
143 #include "TH2.h"
144 #include "HFitInterface.h"
145 #include "TF1.h"
146 #include "TF1NormSum.h"
147 #include "TF1Convolution.h"
148 #include "TF2.h"
149 #include "TF3.h"
150 #include "TTimer.h"
151 #include "THStack.h"
152 #include "TMath.h"
153 #include "Fit/UnBinData.h"
154 #include "Fit/BinData.h"
155 #include "Fit/BinData.h"
156 #include "TMultiGraph.h"
157 #include "TTree.h"
158 #include "TTreePlayer.h"
159 #include "TTreeInput.h"
160 #include "TAdvancedGraphicsDialog.h"
161 
162 #include "RConfigure.h"
163 #include "TPluginManager.h"
164 
165 #include <sstream>
166 #include <vector>
167 #include <queue>
168 using std::vector;
169 using std::queue;
170 using std::pair;
171 using std::ostringstream;
172 using std::make_pair;
173 
174 #include "CommonDefs.h"
175 
176 // #include <iostream>
177 // using std::cout;
178 // using std::endl;
179 
180 void SearchCanvases(TSeqCollection* canvases, std::vector<TObject*>& objects);
181 
182 typedef std::multimap<TObject*, TF1*> FitFuncMap_t;
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 /// This method looks among the functions stored by the fitpanel, the
186 /// one that is currently selected in the fFuncList
187 
189 {
190  // Get the list of functions from the system
191  std::vector<TF1*>& funcList(fSystemFuncs);
192 
193  // Get the title/name of the function from fFuncList
195  if ( !te ) return 0;
196  TString name(te->GetTitle());
197 
198  // Look for a system function if it's USER DEFINED function
199  if ( fTypeFit->GetSelected() == kFP_UFUNC ) {
200  for ( fSystemFuncIter it = funcList.begin();
201  it != funcList.end(); ++it ) {
202  TF1* f = (*it);
203  if ( strcmp( f->GetName(), name ) == 0 )
204  // If found, return it.
205  return f;
206  }
207  // If we are looking for previously fitted functions, look in the
208  // fPrevFit data structure.
209  } else if ( fTypeFit->GetSelected() == kFP_PREVFIT ) {
210  std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(fFitObject);
211  for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
212  TF1* f = it->second;
213  if ( strcmp( f->GetName(), name ) == 0 )
214  // If found, return it
215  return f;
216  }
217  }
218 
219  // Return a pointer to null if the function does not exist. This
220  // will eventually create a segmentation fault, but the line should
221  // never be executed.
222  return 0;
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 ///Copies f into a new TF1 to be stored in the fitpanel with it's
227 ///own ownership. This is taken from Fit::StoreAndDrawFitFunction in
228 ///HFitImpl.cxx
229 
231 {
232  double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
233 
234  // no need to use kNotGlobal bit. TF1::Copy does not add in the list by default
235  if ( dynamic_cast<TF3*>(f) != 0 ) {
236  TF3* fnew = (TF3*)f->IsA()->New();
237  f->Copy(*fnew);
238  f->GetRange(xmin,ymin,zmin,xmax,ymax,zmax);
239  fnew->SetRange(xmin,ymin,zmin,xmax,ymax,zmax);
240  fnew->SetParent( 0 );
241  fnew->AddToGlobalList(false);
242  return fnew;
243  } else if ( dynamic_cast<TF2*>(f) != 0 ) {
244  TF2* fnew = (TF2*)f->IsA()->New();
245  f->Copy(*fnew);
246  f->GetRange(xmin,ymin,xmax,ymax);
247  fnew->SetRange(xmin,ymin,xmax,ymax);
248  fnew->Save(xmin,xmax,ymin,ymax,0,0);
249  fnew->SetParent( 0 );
250  fnew->AddToGlobalList(false);
251  return fnew;
252  } else {
253  TF1* fnew = (TF1*)f->IsA()->New();
254  f->Copy(*fnew);
255  f->GetRange(xmin,xmax);
256  fnew->SetRange(xmin,xmax);
257  // This next line is added, as fnew-Save fails with gausND! As
258  // the number of dimensions is unknown...
259  if ( '\0' != fnew->GetExpFormula()[0] )
260  fnew->Save(xmin,xmax,0,0,0,0);
261  fnew->SetParent( 0 );
262  fnew->AddToGlobalList(false);
263  return fnew;
264  }
265 }
266 
267 ////////////////////////////////////////////////////////////////////////////////
268 /// Stores the parameters of the given function into pars
269 
271 {
272  int npar = func->GetNpar();
273  if (npar != (int) pars.size() ) pars.resize(npar);
274  for ( Int_t i = 0; i < npar; ++i )
275  {
276  Double_t par_min, par_max;
277  pars[i][PAR_VAL] = func->GetParameter(i);
278  func->GetParLimits(i, par_min, par_max);
279  pars[i][PAR_MIN] = par_min;
280  pars[i][PAR_MAX] = par_max;
281  }
282 }
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Restore the parameters from pars into the function
286 
288 {
289  int npar = func->GetNpar();
290  if (npar > (int) pars.size() ) pars.resize(npar);
291  for ( Int_t i = 0; i < npar; ++i )
292  {
293  func->SetParameter(i, pars[i][PAR_VAL]);
294  func->SetParLimits(i, pars[i][PAR_MIN], pars[i][PAR_MAX]);
295  }
296 }
297 
298 ////////////////////////////////////////////////////////////////////////////////
299 /// Parameter initialization for the function
300 
301 template<class FitObject>
303 {
304  const int special = func->GetNumber();
305  if (100 == special || 400 == special) {
306  ROOT::Fit::BinData data;
307  ROOT::Fit::FillData(data,fitobj,func);
308  ROOT::Fit::InitGaus(data, func);
309  // case gaussian or Landau
310  } else if ( 110 == special || 410 == special ) {
311  ROOT::Fit::BinData data;
312  ROOT::Fit::FillData(data,fitobj,func);
313  ROOT::Fit::Init2DGaus(data,func);
314  }
315 }
316 
317 ////////////////////////////////////////////////////////////////////////////////
318 /// Splits the entry in fDataSet to get the selected variables and cuts
319 /// from the text.
320 
321 void GetTreeVarsAndCuts(TGComboBox* dataSet, TString& variablesStr, TString& cutsStr)
322 {
323  // Get the entry
324  TGTextLBEntry* textEntry =
325  static_cast<TGTextLBEntry*>( dataSet->GetListBox()->GetEntry( dataSet->GetSelected() ) );
326  if (!textEntry) return;
327  // Get the name of the tree
328  TString nameStr ( textEntry->GetText()->GetString() );
329  // Get the variables selected
330  variablesStr = nameStr(nameStr.First('(') + 2, nameStr.First(',') - nameStr.First('(') - 3);
331  // Get the cuts selected
332  cutsStr = nameStr( nameStr.First(',') + 3, nameStr.First(')') - nameStr.First(',') - 4 );
333 }
334 
335 
337 
338 TFitEditor *TFitEditor::fgFitDialog = 0;
339 
340 ////////////////////////////////////////////////////////////////////////////////
341 /// Static method - opens the fit panel.
342 
343 TFitEditor * TFitEditor::GetInstance(TVirtualPad* pad, TObject *obj)
344 {
345  // Get the default pad if not provided.
346  if (!pad)
347  {
348  if (!gPad)
349  gROOT->MakeDefCanvas();
350  pad = gPad;
351  }
352 
353  if (!fgFitDialog) {
354  fgFitDialog = new TFitEditor(pad, obj);
355  } else {
356  fgFitDialog->Show(pad, obj);
357  }
358  return fgFitDialog;
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// Constructor of fit editor. 'obj' is the object to be fitted and
363 /// 'pad' where it is drawn.
364 
366  TGMainFrame(gClient->GetRoot(), 20, 20),
367  fParentPad (0),
368  fFitObject (0),
369  fDim (0),
370  fXaxis (0),
371  fYaxis (0),
372  fZaxis (0),
373  fSumFunc (0),
374  fConvFunc (0),
375  fFuncPars (0)
376 {
379 
380  TGCompositeFrame *tf = new TGCompositeFrame(this, 350, 26,
382  TGLabel *label = new TGLabel(tf,"Data Set: ");
383  tf->AddFrame(label, new TGLayoutHints(kLHintsNormal, 15, 0, 5, 0));
384 
385  fDataSet = new TGComboBox(tf, kFP_DATAS);
386  FillDataSetList();
387  fDataSet->Resize(264, 20);
388 
389  tf->AddFrame(fDataSet, new TGLayoutHints(kLHintsNormal, 13, 0, 5, 0));
390  fDataSet->Associate(this);
391 
392  this->AddFrame(tf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX,0,0,5,5));
393 
395 
396  fTab = new TGTab(this, 10, 10);
399  fTab->Associate(this);
400 
401  TGHorizontalFrame *cf1 = new TGHorizontalFrame(this, 350, 20, kFixedWidth);
402  cf1->SetCleanup(kDeepCleanup);
403  fUpdateButton = new TGTextButton(cf1, "&Update", kFP_UPDATE);
404  fUpdateButton->Associate(this);
406  kLHintsExpandX, 0, 20, 2, 2));
407 
408 
409  fFitButton = new TGTextButton(cf1, "&Fit", kFP_FIT);
410  fFitButton->Associate(this);
412  kLHintsExpandX, 15, -6, 2, 2));
413 
414  fResetButton = new TGTextButton(cf1, "&Reset", kFP_RESET);
415  fResetButton->Associate(this);
417  kLHintsExpandX, 11, -2, 2, 2));
418 
419  fCloseButton = new TGTextButton(cf1, "&Close", kFP_CLOSE);
420  fCloseButton->Associate(this);
422  kLHintsExpandX, 7, 2, 2, 2));
424  kLHintsRight, 0, 5, 5, 5));
425 
426  // Create status bar
427  int parts[] = { 20, 20, 20, 20, 20 };
428  fStatusBar = new TGStatusBar(this, 10, 10);
429  fStatusBar->SetParts(parts, 5);
431  kLHintsLeft |
432  kLHintsExpandX));
433 
436 
437  gROOT->GetListOfCleanups()->Add(this);
438 
439  MapSubwindows();
441 
442  // do not allow resizing
443  TGDimension size = GetDefaultSize();
444  SetWindowName("Fit Panel");
445  SetIconName("Fit Panel");
446  SetClassHints("ROOT", "Fit Panel");
447 
453 
454  ConnectSlots();
455 
457 
458  if (!obj) {
459  TList* l = new TList();
460  l->Add(pad);
461  std::vector<TObject*> v;
462  SearchCanvases(l, v);
463  if ( v.size() )
464  obj = v[0];
465  delete l;
466  }
467 
468  SetFitObject(pad, obj, kButton1Down);
469 
470  // In case we want to make it without a default canvas. This will
471  // be implemented after the 5.21/06 Release. Remember to take out
472  // any reference to the pad/canvas when the fitpanel is shown
473  // and/or built.
474 
475  //SetCanvas(0 /*pad->GetCanvas()*/);
476 
477  if ( pad ) {
478  SetCanvas(pad->GetCanvas());
479  if ( obj )
480  pad->GetCanvas()->Selected(pad, obj, kButton1Down);
481  }
482 
484  UInt_t cw = 0;
485  UInt_t cx = 0;
486  UInt_t cy = 0;
487  if (pad && pad->GetCanvas() ) {
488  cw = pad->GetCanvas()->GetWindowWidth();
489  cx = (UInt_t)pad->GetCanvas()->GetWindowTopX();
490  cy = (UInt_t)pad->GetCanvas()->GetWindowTopY();
491  }
492 
493  Resize(size);
494  MapWindow();
495 
496  if (cw + size.fWidth < dw) {
497  Int_t gedx = 0, gedy = 0;
498  gedx = cx+cw+4;
499  gedy = (cy > 20) ? cy-20 : 0;
500  MoveResize(gedx, gedy, size.fWidth, size.fHeight);
501  SetWMPosition(gedx, gedy);
502  }
503 
504  gVirtualX->RaiseWindow(GetId());
505 
507  SetWMSize(size.fWidth, size.fHeight);
508  SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
509 }
510 
511 ////////////////////////////////////////////////////////////////////////////////
512 /// Fit editor destructor.
513 
515 {
516  DisconnectSlots();
517 
518  // Disconnect all the slot that were no disconnected in DisconnecSlots
519  fCloseButton ->Disconnect("Clicked()");
520  fDataSet ->Disconnect("Selected(Int_t)");
521  fUpdateButton->Disconnect("Clicked()");
522  TQObject::Disconnect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
523  this, "SetFitObject(TVirtualPad *, TObject *, Int_t)");
524  gROOT->GetListOfCleanups()->Remove(this);
525 
526  //Clean up the members that are not automatically cleaned.
527  Cleanup();
528  delete fLayoutNone;
529  delete fLayoutAdd;
530  delete fLayoutConv;
531 
532  if (fConvFunc) delete fConvFunc;
533  if (fSumFunc) delete fSumFunc;
534 
535  // Set the singleton reference to null
536  fgFitDialog = 0;
537 }
538 
539 ////////////////////////////////////////////////////////////////////////////////
540 /// Creates the Frame that contains oll the information about the
541 /// function.
542 
544 {
545  TGGroupFrame *gf1 = new TGGroupFrame(this, "Fit Function", kFitWidth);
546  TGCompositeFrame *tf0 = new TGCompositeFrame(gf1, 350, 26, kHorizontalFrame);
547  TGLabel *label1 = new TGLabel(tf0,"Type:");
548  tf0 -> AddFrame(label1, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
549 
550  fTypeFit = new TGComboBox(tf0, kFP_TLIST);
551  fTypeFit -> AddEntry("User Func", kFP_UFUNC);
552  fTypeFit -> AddEntry("Predef-1D", kFP_PRED1D);
553  fTypeFit -> Resize(90, 20);
554  fTypeFit -> Select(kFP_PRED1D, kFALSE);
555 
556  TGListBox *lb = fTypeFit->GetListBox();
557  lb->Resize(lb->GetWidth(), 200);
558  tf0->AddFrame(fTypeFit, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0));
559  fTypeFit->Associate(this);
560 
561  fFuncList = new TGComboBox(tf0, kFP_FLIST);
563  fFuncList->Resize(194, 20);
565 
566  lb = fFuncList->GetListBox();
567  lb -> Resize(lb->GetWidth(), 500);
568  tf0 -> AddFrame(fFuncList, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0));
569  fFuncList->Associate(this);
570 
572 
573  TGCompositeFrame *tf1 = new TGCompositeFrame(gf1, 350, 26, kHorizontalFrame);
574  TGHButtonGroup *bgr = new TGHButtonGroup(tf1, "Operation");
575 
576  bgr -> SetRadioButtonExclusive();
577  fNone = new TGRadioButton(bgr, "Nop", kFP_NONE);
578  fAdd = new TGRadioButton(bgr, "Add", kFP_ADD);
579  fNormAdd = new TGRadioButton(bgr, "NormAdd", kFP_NORMADD);
580  fConv = new TGRadioButton(bgr, "Conv", kFP_CONV);
581 
582  fNone -> SetToolTipText("No operation defined");
583  fNone -> SetState(kButtonDown, kFALSE);
584  fAdd -> SetToolTipText("Addition");
585  // fAdd -> SetState(kButtonDown, kFALSE);
586  fNormAdd -> SetToolTipText("NormAddition");
587  //fNormAdd -> SetState(kButtonDown, kFALSE);
588  fConv -> SetToolTipText("Convolution");
589  //fConv -> SetState(kButtonDown, kTRUE);
590 
591  fLayoutNone = new TGLayoutHints(kLHintsLeft,0 ,5,3,-10);
592  fLayoutAdd = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
593  fLayoutNormAdd = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
594  fLayoutConv = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
595 
596  bgr -> SetLayoutHints(fLayoutNone, fNone);
597  bgr -> SetLayoutHints(fLayoutAdd, fAdd);
598  bgr -> SetLayoutHints(fLayoutNormAdd,fNormAdd);
599  bgr -> SetLayoutHints(fLayoutConv, fConv);
600  bgr -> Show();
602 
603  tf1 -> AddFrame(bgr, new TGLayoutHints(kLHintsExpandX, 0, 0, 3, 0));
604  gf1 -> AddFrame(tf1, new TGLayoutHints(kLHintsExpandX));
605 
606  TGCompositeFrame *tf2 = new TGCompositeFrame(gf1, 350, 26,
608  fEnteredFunc = new TGTextEntry(tf2, new TGTextBuffer(0), kFP_FILE);
609  //fEnteredFunc->SetMaxLength(4000); // use default value (~4000)
612  assert(te);
613  fEnteredFunc->SetText(te->GetTitle());
614  fEnteredFunc->SetToolTipText("Enter file_name/function_name or a function expression");
618  kLHintsExpandX, 2, 2, 2, 2));
619  gf1->AddFrame(tf2, new TGLayoutHints(kLHintsNormal |
620  kLHintsExpandX, 0, 0, 2, 0));
621 
622  TGHorizontalFrame *s1 = new TGHorizontalFrame(gf1);
623  TGLabel *label21 = new TGLabel(s1, "Selected: ");
624  s1->AddFrame(label21, new TGLayoutHints(kLHintsNormal |
625  kLHintsCenterY, 2, 2, 2, 0));
626  TGHorizontal3DLine *hlines = new TGHorizontal3DLine(s1);
628  gf1->AddFrame(s1, new TGLayoutHints(kLHintsExpandX));
629 
630  TGCompositeFrame *tf4 = new TGCompositeFrame(gf1, 350, 26,
633  TString s = txt->GetTitle();
634  fSelLabel = new TGLabel(tf4, s.Sizeof()>30?s(0,30)+"...":s);
636  kLHintsCenterY, 0, 6, 2, 0));
637  Pixel_t color;
638  gClient->GetColorByName("#336666", color);
639  fSelLabel->SetTextColor(color, kFALSE);
640  TGCompositeFrame *tf5 = new TGCompositeFrame(tf4, 120, 20,
642  fSetParam = new TGTextButton(tf5, "Set Parameters...", kFP_PARS);
645  kLHintsExpandX));
646  fSetParam->SetToolTipText("Open a dialog for parameter(s) settings");
647  tf4->AddFrame(tf5, new TGLayoutHints(kLHintsRight |
648  kLHintsTop, 5, 0, 2, 2));
649  gf1->AddFrame(tf4, new TGLayoutHints(kLHintsNormal |
650  kLHintsExpandX, 5, 0, 0, 0));
651 
652  this->AddFrame(gf1, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
653 
654 }
655 
656 ////////////////////////////////////////////////////////////////////////////////
657 /// Create 'General' tab.
658 
660 {
661  fTabContainer = fTab->AddTab("General");
665  5, 5, 2, 2));
666 
667  // 'options' group frame
668  TGGroupFrame *gf = new TGGroupFrame(fGeneral, "Fit Settings", kFitWidth);
669 
670  // 'method' sub-group
672  TGLabel *label4 = new TGLabel(h1, "Method");
673  h1->AddFrame(label4, new TGLayoutHints(kLHintsNormal |
674  kLHintsCenterY, 2, 2, 0, 0));
675  TGHorizontal3DLine *hline1 = new TGHorizontal3DLine(h1);
677  gf->AddFrame(h1, new TGLayoutHints(kLHintsExpandX));
678 
679  TGHorizontalFrame *h2 = new TGHorizontalFrame(gf);
683  fMethodList->Resize(140, 20);
685  Int_t lbe = lb->GetNumberOfEntries();
686  lb->Resize(lb->GetWidth(), lbe*16);
687  v1->AddFrame(fMethodList, new TGLayoutHints(kLHintsLeft, 0, 0, 2, 5));
688 
689  fLinearFit = new TGCheckButton(v1, "Linear fit", kFP_MLINF);
690  fLinearFit->Associate(this);
691  fLinearFit->SetToolTipText("Perform Linear fitter if selected");
692  v1->AddFrame(fLinearFit, new TGLayoutHints(kLHintsNormal, 0, 0, 8, 2));
693 
694 
696 
697  TGVerticalFrame *v2 = new TGVerticalFrame(h2);
698  TGCompositeFrame *v21 = new TGCompositeFrame(v2, 120, 20,
700  fUserButton = new TGTextButton(v21, "User-Defined...", kFP_MUSR);
703  kLHintsExpandX));
704  fUserButton->SetToolTipText("Open a dialog for entering a user-defined method");
707 
708  TGHorizontalFrame *v1h = new TGHorizontalFrame(v2);
709  fEnableRobust = new TGCheckButton(v1h, "Robust:", -1);
710  fEnableRobust->Associate(this); // needed ???
711  fEnableRobust->SetToolTipText("Perform Linear Robust fitter if selected");
712  v1h->AddFrame(fEnableRobust, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
713  fRobustValue = new TGNumberEntry(v1h, 0.95, 5, kFP_RBUST,
718  v2->AddFrame(v1h, new TGLayoutHints(kLHintsNormal, 0, 0, 12, 2));
720  fRobustValue->GetNumberEntry()->SetToolTipText("Available only for graphs");
721 
722  fNoChi2 = 0;
723  // fNoChi2 = new TGCheckButton(v2, "No Chi-square", kFP_NOCHI);
724  // fNoChi2->Associate(this);
725  // fNoChi2->SetToolTipText("'C'- do not calculate Chi-square (for Linear fitter)");
726  // v2->AddFrame(fNoChi2, new TGLayoutHints(kLHintsNormal, 0, 0, 34, 2));
727 
728  h2->AddFrame(v2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 20, 0, 0, 0));
729  gf->AddFrame(h2, new TGLayoutHints(kLHintsExpandX, 20, 0, 0, 0));
730 
731  // 'fit option' sub-group
732  TGHorizontalFrame *h3 = new TGHorizontalFrame(gf);
733  TGLabel *label5 = new TGLabel(h3, "Fit Options");
734  h3->AddFrame(label5, new TGLayoutHints(kLHintsNormal |
735  kLHintsCenterY, 2, 2, 0, 0));
736  TGHorizontal3DLine *hline2 = new TGHorizontal3DLine(h3);
738  gf->AddFrame(h3, new TGLayoutHints(kLHintsExpandX));
739 
741  TGVerticalFrame *v3 = new TGVerticalFrame(h);
742  fIntegral = new TGCheckButton(v3, "Integral", kFP_INTEG);
743  fIntegral->Associate(this);
744  fIntegral->SetToolTipText("'I'- use integral of function instead of value in bin center");
745  v3->AddFrame(fIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
746 
747  fBestErrors = new TGCheckButton(v3, "Best errors", kFP_IMERR);
748  fBestErrors->Associate(this);
749  fBestErrors->SetToolTipText("'E'- better errors estimation using Minos technique");
750  v3->AddFrame(fBestErrors, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
751 
752  fAllWeights1 = new TGCheckButton(v3, "All weights = 1", kFP_ALLW1);
753  fAllWeights1->Associate(this);
754  fAllWeights1->SetToolTipText("'W'- all weights=1 for non empty bins; error bars ignored");
755  v3->AddFrame(fAllWeights1, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
756 
757  fEmptyBinsWghts1 = new TGCheckButton(v3, "Empty bins, weights=1", kFP_EMPW1);
759  fEmptyBinsWghts1->SetToolTipText("'WW'- all weights=1 including empty bins; error bars ignored");
760  v3->AddFrame(fEmptyBinsWghts1, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
761 
763 
764  TGVerticalFrame *v4 = new TGVerticalFrame(h);
765  fUseRange = new TGCheckButton(v4, "Use range", kFP_USERG);
766  fUseRange->Associate(this);
767  fUseRange->SetToolTipText("'R'- fit only data within the specified function range");
768  v4->AddFrame(fUseRange, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
769 
770  fImproveResults = new TGCheckButton(v4, "Improve fit results", kFP_IFITR);
771  fImproveResults->Associate(this);
772  fImproveResults->SetToolTipText("'M'- after minimum is found, search for a new one");
773  v4->AddFrame(fImproveResults, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
774 
775  fAdd2FuncList = new TGCheckButton(v4, "Add to list", kFP_ADDLS);
776  fAdd2FuncList->Associate(this);
777  fAdd2FuncList->SetToolTipText("'+'- add function to the list without deleting the previous");
778  v4->AddFrame(fAdd2FuncList, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
779 
780  fUseGradient = new TGCheckButton(v4, "Use Gradient", kFP_ADDLS);
781  fUseGradient->Associate(this);
782  fUseGradient->SetToolTipText("'G'- Use the gradient as an aid for the fitting");
783  v4->AddFrame(fUseGradient, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
784 
785  h->AddFrame(v4, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 20, 0, 0, 0));
786  gf->AddFrame(h, new TGLayoutHints(kLHintsExpandX, 20, 0, 0, 0));
787 
788  // 'draw option' sub-group
789  TGHorizontalFrame *h5 = new TGHorizontalFrame(gf);
790  TGLabel *label6 = new TGLabel(h5, "Draw Options");
791  h5->AddFrame(label6, new TGLayoutHints(kLHintsNormal |
792  kLHintsCenterY, 2, 2, 2, 2));
793  TGHorizontal3DLine *hline3 = new TGHorizontal3DLine(h5);
795  gf->AddFrame(h5, new TGLayoutHints(kLHintsExpandX));
796 
797  TGHorizontalFrame *h6 = new TGHorizontalFrame(gf);
798  TGVerticalFrame *v5 = new TGVerticalFrame(h6);
799 
800  fDrawSame = new TGCheckButton(v5, "SAME", kFP_DSAME);
801  fDrawSame->Associate(this);
802  fDrawSame->SetToolTipText("Superimpose on previous picture in the same pad");
803  v5->AddFrame(fDrawSame, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
804 
805  fNoDrawing = new TGCheckButton(v5, "No drawing", kFP_DNONE);
806  fNoDrawing->Associate(this);
807  fNoDrawing->SetToolTipText("'0'- do not draw function graphics");
808  v5->AddFrame(fNoDrawing, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
809 
810  fNoStoreDrawing = new TGCheckButton(v5, "Do not store/draw", kFP_DNOST);
811  fNoStoreDrawing->Associate(this);
812  fNoStoreDrawing->SetToolTipText("'N'- do not store the function, do not draw it");
813  v5->AddFrame(fNoStoreDrawing, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
814 
816 
817  TGVerticalFrame *v6 = new TGVerticalFrame(h6);
818  TGCompositeFrame *v61 = new TGCompositeFrame(v6, 120, 20,
820  fDrawAdvanced = new TGTextButton(v61, "&Advanced...", kFP_DADVB);
823  kLHintsExpandX));
824  fDrawAdvanced->SetToolTipText("Open a dialog for advanced draw options");
826 
828  0, 0, (4+fDrawSame->GetHeight())*2, 0));
829 
831  gf->AddFrame(h6, new TGLayoutHints(kLHintsExpandX, 20, 0, 2, 0));
832 
834  kLHintsExpandY, 5, 5, 0, 0));
835  // sliderX
837  TGLabel *label8 = new TGLabel(fSliderXParent, "X");
839  kLHintsCenterY, 0, 5, 0, 0));
840 
846 
848  fSliderX->SetScale(5);
850 
851 
858 
859  // sliderY
861  TGLabel *label9 = new TGLabel(fSliderYParent, "Y");
863  kLHintsCenterY, 0, 5, 0, 0));
864 
870 
872  fSliderY->SetScale(5);
874 
881 
882  // sliderZ
884  TGLabel *label10 = new TGLabel(fSliderZParent, "Z:");
886  kLHintsCenterY, 0, 5, 0, 0));
888  fSliderZ->SetScale(5);
890  kLHintsCenterY));
892 }
893 
894 
895 ////////////////////////////////////////////////////////////////////////////////
896 /// Create 'Minimization' tab.
897 
899 {
900  fTabContainer = fTab->AddTab("Minimization");
904  5, 5, 2, 2));
905  MakeTitle(fMinimization, "Library");
906 
908  fLibMinuit = new TGRadioButton(hl, "Minuit", kFP_LMIN);
909  fLibMinuit->Associate(this);
910  fLibMinuit->SetToolTipText("Use minimization from libMinuit (default)");
911  hl->AddFrame(fLibMinuit, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
912  fStatusBar->SetText("LIB Minuit",1);
913 
914  fLibMinuit2 = new TGRadioButton(hl, "Minuit2", kFP_LMIN2);
915  fLibMinuit2->Associate(this);
916  fLibMinuit2->SetToolTipText("New C++ version of Minuit");
917  hl->AddFrame(fLibMinuit2, new TGLayoutHints(kLHintsNormal, 35, 0, 0, 1));
918 
919  fLibFumili = new TGRadioButton(hl, "Fumili", kFP_LFUM);
920  fLibFumili->Associate(this);
921  fLibFumili->SetToolTipText("Use minimization from libFumili");
922  hl->AddFrame(fLibFumili, new TGLayoutHints(kLHintsNormal, 30, 0, 0, 1));
923  fMinimization->AddFrame(hl, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 1));
924 
926 
927  fLibGSL = new TGRadioButton(hl2, "GSL", kFP_LGSL);
928  #ifdef R__HAS_MATHMORE
929  fLibGSL->Associate(this);
930  fLibGSL->SetToolTipText("Use minimization from libGSL");
931  #else
933  fLibGSL->SetToolTipText("Needs GSL to be compiled");
934  #endif
935  hl2->AddFrame(fLibGSL, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
936 
937  fLibGenetics = new TGRadioButton(hl2, "Genetics", kFP_LGAS);
938  if (gPluginMgr->FindHandler("ROOT::Math::Minimizer","Genetic") ||
939  gPluginMgr->FindHandler("ROOT::Math::Minimizer","GAlibMin") )
940  {
941  fLibGenetics->Associate(this);
942  fLibGenetics->SetToolTipText("Different GAs implementations");
943  } else {
945  fLibGenetics->SetToolTipText("Needs any of the genetic"
946  "minimizers to be compiled");
947  }
948  hl2->AddFrame(fLibGenetics, new TGLayoutHints(kLHintsNormal, 45, 0, 0, 1));
949 
950  fMinimization->AddFrame(hl2, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 1));
951 
952  MakeTitle(fMinimization, "Method");
953 
956  fMinMethodList->Resize(290, 20);
958 
960  lb->Resize(lb->GetWidth(), 500);
961  fMinMethodList->Associate(this);
962 
964  fMinimization->AddFrame(hm0, new TGLayoutHints(kLHintsExpandX, 60, 0, 5, 1));
965 
966  // Set the status to the default minimization options!
969  } else if ( ROOT::Math::MinimizerOptions::DefaultMinimizerType() == "Minuit" ) {
971  } else {
973  }
975 
976  MakeTitle(fMinimization, "Settings");
977  TGLabel *hslabel1 = new TGLabel(fMinimization,"Use ENTER key to validate a new value or click");
978  fMinimization->AddFrame(hslabel1, new TGLayoutHints(kLHintsNormal, 61, 0, 5, 1));
979  TGLabel *hslabel2 = new TGLabel(fMinimization,"on Reset button to set the defaults.");
980  fMinimization->AddFrame(hslabel2, new TGLayoutHints(kLHintsNormal, 61, 0, 1, 10));
981 
983 
984  TGVerticalFrame *hsv1 = new TGVerticalFrame(hs, 180, 10, kFixedWidth);
985  TGLabel *errlabel = new TGLabel(hsv1,"Error definition (default = 1): ");
986  hsv1->AddFrame(errlabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
987  1, 1, 5, 7));
988  TGLabel *tollabel = new TGLabel(hsv1,"Max tolerance (precision): ");
989  hsv1->AddFrame(tollabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
990  1, 1, 5, 7));
991  TGLabel *itrlabel = new TGLabel(hsv1,"Max number of iterations: ");
992  hsv1->AddFrame(itrlabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
993  1, 1, 5, 5));
994  hs->AddFrame(hsv1, new TGLayoutHints(kLHintsNormal, 60, 0, 0, 0));
995 
996  TGVerticalFrame *hsv2 = new TGVerticalFrame(hs, 90,10, kFixedWidth);
1002  1, 1, 0, 3));
1009  1, 1, 3, 3));
1010  fIterations = new TGNumberEntryField(hsv2, kFP_MITR, 5000,
1016  1, 1, 3, 3));
1017  hs->AddFrame(hsv2, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
1018  fMinimization->AddFrame(hs, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 1));
1020 
1021  MakeTitle(fMinimization, "Print Options");
1022 
1024  fOptDefault = new TGRadioButton(h8, "Default", kFP_PDEF);
1025  fOptDefault->Associate(this);
1026  fOptDefault->SetToolTipText("Default is between Verbose and Quiet");
1027  h8->AddFrame(fOptDefault, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
1029  fStatusBar->SetText("Prn: DEF",4);
1030 
1031  fOptVerbose = new TGRadioButton(h8, "Verbose", kFP_PVER);
1032  fOptVerbose->Associate(this);
1033  fOptVerbose->SetToolTipText("'V'- print results after each iteration");
1034  h8->AddFrame(fOptVerbose, new TGLayoutHints(kLHintsNormal, 30, 0, 0, 1));
1035 
1036  fOptQuiet = new TGRadioButton(h8, "Quiet", kFP_PQET);
1037  fOptQuiet->Associate(this);
1038  fOptQuiet->SetToolTipText("'Q'- no print");
1039  h8->AddFrame(fOptQuiet, new TGLayoutHints(kLHintsNormal, 25, 0, 0, 1));
1040 
1041  fMinimization->AddFrame(h8, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 1));
1042 
1043 }
1044 
1045 ////////////////////////////////////////////////////////////////////////////////
1046 /// Connect GUI signals to fit panel slots.
1047 
1049 {
1050  // list of data sets to fit
1051  fDataSet -> Connect("Selected(Int_t)", "TFitEditor", this, "DoDataSet(Int_t)");
1052  // list of predefined functions
1053  fTypeFit -> Connect("Selected(Int_t)", "TFitEditor", this, "FillFunctionList(Int_t)");
1054  // list of predefined functions
1055  fFuncList -> Connect("Selected(Int_t)", "TFitEditor", this, "DoFunction(Int_t)");
1056  // entered formula or function name
1057  fEnteredFunc -> Connect("ReturnPressed()", "TFitEditor", this, "DoEnteredFunction()");
1058  // set parameters dialog
1059  fSetParam -> Connect("Clicked()", "TFitEditor", this, "DoSetParameters()");
1060  // allowed function operations
1061  fAdd -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoAddition(Bool_t)");
1062  //fNormAdd -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoNormAddition(Bool_t)");
1063  //fConv -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoConvolution(Bool_t)");
1064  // fit options
1065  fAllWeights1 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoAllWeights1()");
1066  fUseRange -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoUseFuncRange()");
1067  fEmptyBinsWghts1 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoEmptyBinsAllWeights1()");
1068  // linear fit
1069  fLinearFit -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLinearFit()");
1070  fEnableRobust -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoRobustFit()");
1071  //fNoChi2->Connect("Toggled(Bool_t)","TFitEditor",this,"DoNoChi2()");
1072  // draw options
1073  fNoStoreDrawing -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoNoStoreDrawing()");
1074  // fit, reset, close buttons
1075  fUpdateButton -> Connect("Clicked()", "TFitEditor", this, "DoUpdate()");
1076  fFitButton -> Connect("Clicked()", "TFitEditor", this, "DoFit()");
1077  fResetButton -> Connect("Clicked()", "TFitEditor", this, "DoReset()");
1078  fCloseButton -> Connect("Clicked()", "TFitEditor", this, "DoClose()");
1079  // user method button
1080  fUserButton -> Connect("Clicked()", "TFitEditor", this, "DoUserDialog()");
1081  // advanced draw options
1082  fDrawAdvanced -> Connect("Clicked()", "TFitEditor", this, "DoAdvancedOptions()");
1083 
1084  if (fType != kObjectTree)
1085  {
1086  fSliderX -> Connect("PositionChanged()","TFitEditor",this, "DoSliderXMoved()");
1087  fSliderXMax -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderXChanged()");
1088  fSliderXMin -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderXChanged()");
1089  }
1090  if (fDim > 1)
1091  {
1092  fSliderY -> Connect("PositionChanged()","TFitEditor",this, "DoSliderYMoved()");
1093  fSliderYMax -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderYChanged()");
1094  fSliderYMin -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderYChanged()");
1095  }
1096  if (fDim > 2)
1097  fSliderZ -> Connect("PositionChanged()","TFitEditor",this, "DoSliderZMoved()");
1098 
1099  if ( fParentPad )
1100  fParentPad -> Connect("RangeAxisChanged()","TFitEditor",this, "UpdateGUI()");
1101  // 'Minimization' tab
1102  // library
1103  fLibMinuit -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1104  fLibMinuit2 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1105  fLibFumili -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1106  fLibGSL -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1107  fLibGenetics -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1108 
1109  // minimization method
1110  fMinMethodList -> Connect("Selected(Int_t)", "TFitEditor", this, "DoMinMethod(Int_t)");
1111  // fitter settings
1112  fIterations -> Connect("ReturnPressed()", "TFitEditor", this, "DoMaxIterations()");
1113  // print options
1114  fOptDefault -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1115  fOptVerbose -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1116  fOptQuiet -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1117 
1118 }
1119 
1120 ////////////////////////////////////////////////////////////////////////////////
1121 /// Disconnect GUI signals from fit panel slots.
1122 
1124 {
1125  Disconnect("CloseWindow()");
1126 
1127  fFuncList -> Disconnect("Selected(Int_t)");
1128  fEnteredFunc -> Disconnect("ReturnPressed()");
1129  fSetParam -> Disconnect("Clicked()");
1130  fAdd -> Disconnect("Toggled(Bool_t)");
1131  // fNormAdd -> Disconnect("Toggled(Bool_t)");
1132  // fConv -> Disconnect("Toggled(Bool_t)");
1133 
1134  // fit options
1135  fAllWeights1 -> Disconnect("Toggled(Bool_t)");
1136  fEmptyBinsWghts1 -> Disconnect("Toggled(Bool_t)");
1137 
1138  // linear fit
1139  fLinearFit -> Disconnect("Toggled(Bool_t)");
1140  fEnableRobust -> Disconnect("Toggled(Bool_t)");
1141  //fNoChi2->Disconnect("Toggled(Bool_t)");
1142 
1143  // draw options
1144  fNoStoreDrawing -> Disconnect("Toggled(Bool_t)");
1145 
1146  // fit, reset, close buttons
1147  fFitButton -> Disconnect("Clicked()");
1148  fResetButton -> Disconnect("Clicked()");
1149 
1150  // other methods
1151  fUserButton -> Disconnect("Clicked()");
1152  fDrawAdvanced -> Disconnect("Clicked()");
1153 
1154  if (fType != kObjectTree)
1155  {
1156  fSliderX -> Disconnect("PositionChanged()");
1157  fSliderXMax -> Disconnect("ValueChanged(Long_t)");
1158  fSliderXMin -> Disconnect("ValueChanged(Long_t)");
1159  }
1160  if (fDim > 1)
1161  {
1162  fSliderY -> Disconnect("PositionChanged()");
1163  fSliderYMax -> Disconnect("ValueChanged(Long_t)");
1164  fSliderYMin -> Disconnect("ValueChanged(Long_t)");
1165  }
1166  if (fDim > 2)
1167  fSliderZ -> Disconnect("PositionChanged()");
1168  // slots related to 'Minimization' tab
1169  fLibMinuit -> Disconnect("Toggled(Bool_t)");
1170  fLibMinuit2 -> Disconnect("Toggled(Bool_t)");
1171  fLibFumili -> Disconnect("Toggled(Bool_t)");
1172  fLibGSL -> Disconnect("Toggled(Bool_t)");
1173  fLibGenetics -> Disconnect("Toggled(Bool_t)");
1174  // minimization method
1175  fMinMethodList -> Disconnect("Selected(Int_t)");
1176  // fitter settings
1177  fIterations -> Disconnect("ReturnPressed()");
1178  // print options
1179  fOptDefault -> Disconnect("Toggled(Bool_t)");
1180  fOptVerbose -> Disconnect("Toggled(Bool_t)");
1181  fOptQuiet -> Disconnect("Toggled(Bool_t)");
1182 
1183 }
1184 
1185 ////////////////////////////////////////////////////////////////////////////////
1186 /// Connect to another canvas.
1187 
1188 void TFitEditor::SetCanvas(TCanvas * /*newcan*/)
1189 {
1190  // The next line is commented because it is stablishing a
1191  // connection with the particular canvas, while right the following
1192  // line will connect all the canvas in a general way.
1193 
1194  // It would also make the fitpanel crash if there is no object
1195  // defined to be fitted in the construction (as a side effect of
1196  // it).
1197 
1198 // newcan->Connect("Selected(TVirtualPad*,TObject*,Int_t)", "TFitEditor",
1199 // this, "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1200 
1201  TQObject::Connect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1202  "TFitEditor",this,
1203  "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1204  TQObject::Connect("TCanvas", "Closed()", "TFitEditor", this, "DoNoSelection()");
1205 }
1206 
1207 ////////////////////////////////////////////////////////////////////////////////
1208 /// Hide the fit panel and set it to non-active state.
1209 
1211 {
1212  if (fgFitDialog) {
1213  fgFitDialog->UnmapWindow();
1214  }
1215  if (fParentPad) {
1216  fParentPad->Disconnect("RangeAxisChanged()");
1217  DoReset();
1218  }
1219  fParentPad = 0;
1220  fFitObject = 0;
1221  gROOT->GetListOfCleanups()->Remove(this);
1222 }
1223 
1224 ////////////////////////////////////////////////////////////////////////////////
1225 /// Show the fit panel (possible only via context menu).
1226 
1228 {
1229  if (!gROOT->GetListOfCleanups()->FindObject(this))
1230  gROOT->GetListOfCleanups()->Add(this);
1231 
1232  if (!fgFitDialog->IsMapped()) {
1233  fgFitDialog->MapWindow();
1234  gVirtualX->RaiseWindow(GetId());
1235  }
1236  fParentPad = static_cast<TPad*>(pad);
1237  SetCanvas(pad->GetCanvas());
1238  SetFitObject(pad, obj, kButton1Down);
1239 }
1240 
1241 ////////////////////////////////////////////////////////////////////////////////
1242 /// Close fit panel window.
1243 
1245 {
1246  Hide();
1247 }
1248 
1249 //______________________________________________________________________________
1250 // TFitEditor *&TFitEditor::GetFP()
1251 // {
1252 // // Static: return main fit panel
1253 // return fgFitDialog;
1254 // }
1255 
1256 ////////////////////////////////////////////////////////////////////////////////
1257 /// Called to delete the fit panel.
1258 
1260 {
1261  TQObject::Disconnect("TCanvas", "Closed()");
1262  delete fgFitDialog;
1263  fgFitDialog = 0;
1264 }
1265 
1266 ////////////////////////////////////////////////////////////////////////////////
1267 /// Set the fit panel GUI according to the selected object.
1268 
1270 {
1271  if (!fFitObject) return;
1272 
1273  DrawSelection(true);
1274 
1275  if ( fType == kObjectTree )
1276  // Don't do anything with the sliders, as they work with TAxis
1277  // that are not defined for the TTree
1278  return;
1279 
1280  // sliders
1281  if (fType != kObjectTree) { // This is as fDim > 0
1282  TH1* hist = 0;
1283  switch (fType) {
1284  case kObjectHisto:
1285  hist = (TH1*)fFitObject;
1286  break;
1287 
1288  case kObjectGraph:
1289  hist = ((TGraph*)fFitObject)->GetHistogram();
1290  break;
1291 
1292  case kObjectMultiGraph:
1293  hist = ((TMultiGraph*)fFitObject)->GetHistogram();
1294  break;
1295 
1296  case kObjectGraph2D:
1297  hist = ((TGraph2D*)fFitObject)->GetHistogram("empty");
1298  break;
1299 
1300  case kObjectHStack:
1301  hist = (TH1 *)((THStack *)fFitObject)->GetHists()->First();
1302 
1303  case kObjectTree:
1304  default:
1305  break;
1306  }
1307 
1308 
1309  if (!hist) {
1310  Error("UpdateGUI","No hist is present - this should not happen, please report."
1311  "The FitPanel might be in an inconsistent state");
1312  //assert(hist);
1313  return;
1314  }
1315 
1316  fSliderX->Disconnect("PositionChanged()");
1317  fSliderXMin->Disconnect("ValueChanged()");
1318  fSliderXMax->Disconnect("ValueChanged()");
1319 
1320  if (!fSliderXParent->IsMapped())
1322 
1323  fXaxis = hist->GetXaxis();
1324  fYaxis = hist->GetYaxis();
1325  fZaxis = hist->GetZaxis();
1326  Int_t ixrange = fXaxis->GetNbins();
1327  Int_t ixmin = fXaxis->GetFirst();
1328  Int_t ixmax = fXaxis->GetLast();
1329 
1330  if (ixmin > 1 || ixmax < ixrange) {
1331  fSliderX->SetRange(ixmin,ixmax);
1332  fSliderX->SetPosition(ixmin, ixmax);
1333  } else {
1334  fSliderX->SetRange(1,ixrange);
1335  fSliderX->SetPosition(ixmin,ixmax);
1336  }
1337 
1338  fSliderX->SetScale(5);
1339 
1341  fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1342  fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1343  fSliderXMin->SetNumber( fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ));
1345  fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1346  fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1347  fSliderXMax->SetNumber( fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1348 
1349  fSliderX->Connect("PositionChanged()","TFitEditor",this, "DoSliderXMoved()");
1350  fSliderXMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1351  fSliderXMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1352  }
1353 
1354  if (fDim > 1) {
1355  fSliderY->Disconnect("PositionChanged()");
1356  fSliderYMin->Disconnect("ValueChanged()");
1357  fSliderYMax->Disconnect("ValueChanged()");
1358 
1359  if (!fSliderYParent->IsMapped())
1361  if (fSliderZParent->IsMapped())
1363 
1364  Int_t iymin = 0, iymax = 0, iyrange = 0;
1365  switch (fType) {
1366  case kObjectHisto:
1367  case kObjectGraph2D:
1368  case kObjectHStack:
1369  iyrange = fYaxis->GetNbins();
1370  iymin = fYaxis->GetFirst();
1371  iymax = fYaxis->GetLast();
1372  break;
1373 
1374  case kObjectGraph:
1375  case kObjectMultiGraph:
1376  case kObjectTree:
1377  default:
1378  //not implemented
1379  break;
1380  }
1381 
1382  if (iymin > 1 || iymax < iyrange) {
1383  fSliderY->SetRange(iymin,iymax);
1384  fSliderY->SetPosition(iymin, iymax);
1385  } else {
1386  fSliderY->SetRange(1,iyrange);
1387  fSliderY->SetPosition(iymin,iymax);
1388  }
1389 
1390  fSliderY->SetScale(5);
1391 
1393  fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1394  fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1395  fSliderYMin->SetNumber(fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ));
1397  fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1398  fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1399  fSliderYMax->SetNumber( fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1400 
1401  fSliderY->Connect("PositionChanged()","TFitEditor",this, "DoSliderYMoved()");
1402  fSliderYMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1403  fSliderYMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1404  }
1405 
1406 
1407  if (fDim > 2) {
1408  fSliderZ->Disconnect("PositionChanged()");
1409 
1410  if (!fSliderZParent->IsMapped())
1412 
1413  Int_t izmin = 0, izmax = 0, izrange = 0;
1414  switch (fType) {
1415  case kObjectHStack:
1416  case kObjectHisto:
1417  izrange = fZaxis->GetNbins();
1418  izmin = fZaxis->GetFirst();
1419  izmax = fZaxis->GetLast();
1420  break;
1421 
1422  case kObjectGraph:
1423  case kObjectGraph2D:
1424  case kObjectMultiGraph:
1425  case kObjectTree:
1426  default:
1427  //not implemented
1428  break;
1429  }
1430 
1431  if (izmin > 1 || izmax < izrange) {
1432  fSliderZ->SetRange(izmin,izmax);
1433  fSliderZ->SetPosition(izmin, izmax);
1434  } else {
1435  fSliderZ->SetRange(1,izrange);
1436  fSliderZ->SetPosition(izmin,izmax);
1437  }
1438 
1439  fSliderZ->SetScale(5);
1440  fSliderZ->Connect("PositionChanged()","TFitEditor",this, "DoSliderZMoved()");
1441  }
1442 }
1443 
1444 ////////////////////////////////////////////////////////////////////////////////
1445 /// Slot called when the user clicks on an object inside a canvas.
1446 /// Updates pointers to the parent pad and the selected object
1447 /// for fitting (if suitable).
1448 
1450 {
1451  if (event != kButton1Down) return;
1452 
1453  if ( !obj ) {
1454  DoNoSelection();
1455  return;
1456  }
1457 
1458  // is obj suitable for fitting?
1459  if (!SetObjectType(obj)) return;
1460 
1461  fParentPad = pad;
1462  fFitObject = obj;
1463  ShowObjectName(obj);
1464  UpdateGUI();
1465 
1466  ConnectSlots();
1467 
1468  TF1* fitFunc = HasFitFunction();
1469 
1470  if (fitFunc)
1471  {
1472  //fFuncPars = FuncParams_t( fitFunc->GetNpar() );
1473  GetParameters(fFuncPars, fitFunc);
1474 
1475  TString tmpStr = fitFunc->GetExpFormula();
1476  TGLBEntry *en = 0;
1477  // If the function comes from a C raw function.
1478  if ( tmpStr.Length() == 0 )
1479  {
1480  // Show the name of the function
1481  fEnteredFunc->SetText(fitFunc->GetName());
1482  en= fFuncList->FindEntry(fitFunc->GetName());
1483  // Don't allow edition!
1485  }
1486  // otherwise, it's got a formula
1487  else
1488  {
1489  // Show the formula
1490  fEnteredFunc->SetText(fitFunc->GetExpFormula().Data());
1491  en= fFuncList->FindEntry(fitFunc->GetExpFormula().Data());
1492  SetEditable(kTRUE);
1493  }
1494  // Select the proper entry in the function list
1495  if (en) fFuncList->Select(en->EntryId());
1496  }
1497  else
1498  { // if there is no fit function in the object
1499  // Use the selected function in fFuncList
1501  // Add the text to fEnteredFunc
1502  if (te && fNone->GetState() == kButtonDown)
1503  fEnteredFunc->SetText(te->GetTitle());
1504  else if (te && fAdd->GetState() == kButtonDown)
1505  {
1506  TString tmpStr = fEnteredFunc->GetText();
1507  tmpStr += '+';
1508  tmpStr += te->GetTitle();
1509  fEnteredFunc->SetText(tmpStr);
1510  }
1511  else if (te && fNormAdd->GetState() == kButtonDown)
1512  {
1513  TString tmpStr = fEnteredFunc->GetText();
1514  tmpStr += '+';
1515  tmpStr += te -> GetTitle();
1516  fEnteredFunc -> SetText(tmpStr);
1517  }
1518  else if (te && fConv->GetState() == kButtonDown)
1519  {
1520  TString tmpStr = fEnteredFunc->GetText();
1521  tmpStr += '*';
1522  tmpStr +=te->GetTitle();
1523  fEnteredFunc->SetText(tmpStr);
1524  }
1525  else if ( !te )
1526  // If there is no space, an error message is shown:
1527  // Error in <TString::AssertElement>: out of bounds: i = -1, Length = 0
1528  // If there is no function selected, then put nothing.
1529  fEnteredFunc->SetText(" ");
1530  }
1532 
1533 
1534  // Update the information about the selected object.
1541  DoLinearFit();
1542 }
1543 
1544 ////////////////////////////////////////////////////////////////////////////////
1545 /// Slot called when users close a TCanvas or when the user select
1546 /// no object.
1547 
1549 {
1550  if (gROOT->GetListOfCanvases()->IsEmpty()) {
1551  Terminate();
1552  return;
1553  }
1554 
1555  // Minimize user interaction until an object is selected
1556  DisconnectSlots();
1557  fParentPad = 0;
1558  fFitObject = 0;
1559  fStatusBar->SetText("No selection",0);
1561  Layout();
1562 
1567 }
1568 
1569 ////////////////////////////////////////////////////////////////////////////////
1570 /// When obj is deleted, clear fFitObject if fFitObject = obj.
1571 
1573 {
1574  if (obj == fFitObject) {
1575  fFitObject = 0;
1576  DisconnectSlots();
1577  fStatusBar->SetText("No selection",0);
1579  Layout();
1580 
1584 
1585  TQObject::Connect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1586  "TFitEditor",this,
1587  "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1588  TQObject::Connect("TCanvas", "Closed()", "TFitEditor", this,
1589  "DoNoSelection()");
1590 
1591  DoUpdate();
1592  return;
1593  }
1594  if (obj == fParentPad) {
1595  fFitObject = 0;
1596  fParentPad = 0;
1597  DisconnectSlots();
1598  fStatusBar->SetText("No selection",0);
1600  Layout();
1601 
1605  }
1606 }
1607 
1608 ////////////////////////////////////////////////////////////////////////////////
1609 /// Fills the list of functions depending on the type of fit
1610 /// selected.
1611 
1613 {
1614  fFuncList->RemoveAll();
1615  // Case when the user has selected predefined functions in 1D.
1616  if ( fTypeFit->GetSelected() == kFP_PRED1D && fDim <= 1 ) {
1617  // Fill function list combo box.
1618  fFuncList->AddEntry("gaus" , kFP_GAUS);
1619  fFuncList->AddEntry("gausn", kFP_GAUSN);
1620  fFuncList->AddEntry("expo", kFP_EXPO);
1621  fFuncList->AddEntry("landau", kFP_LAND);
1622  fFuncList->AddEntry("landaun",kFP_LANDN);
1623  fFuncList->AddEntry("pol0", kFP_POL0);
1624  fFuncList->AddEntry("pol1", kFP_POL1);
1625  fFuncList->AddEntry("pol2", kFP_POL2);
1626  fFuncList->AddEntry("pol3", kFP_POL3);
1627  fFuncList->AddEntry("pol4", kFP_POL4);
1628  fFuncList->AddEntry("pol5", kFP_POL5);
1629  fFuncList->AddEntry("pol6", kFP_POL6);
1630  fFuncList->AddEntry("pol7", kFP_POL7);
1631  fFuncList->AddEntry("pol8", kFP_POL8);
1632  fFuncList->AddEntry("pol9", kFP_POL9);
1633  fFuncList->AddEntry("user", kFP_USER);
1634 
1635  // Need to be setted this way, otherwise when the functions
1636  // are removed, the list doesn't show them.
1637  TGListBox *lb = fFuncList->GetListBox();
1638  lb->Resize(lb->GetWidth(), 200);
1639 
1640  // Select Gaus1D by default
1642 
1643  }
1644  // Case for predefined 2D functions
1645  else if ( fTypeFit->GetSelected() == kFP_PRED2D && fDim == 2 ) {
1646  fFuncList->AddEntry("xygaus", kFP_XYGAUS);
1647  fFuncList->AddEntry("xyexpo", kFP_XYEXP);
1648  fFuncList->AddEntry("xylandau", kFP_XYLAN);
1649  fFuncList->AddEntry("xylandaun", kFP_XYLANN);
1650 
1651  // Need to be setted this way, otherwise when the functions
1652  // are removed, the list doesn't show them.x
1653  TGListBox *lb = fFuncList->GetListBox();
1654  lb->Resize(lb->GetWidth(), 200);
1655 
1656  // Select Gaus2D by default
1658  }
1659  // Case for user defined functions. References to these functions
1660  // are kept by the fitpanel, so the information is gathered from
1661  // there.
1662  else if ( fTypeFit->GetSelected() == kFP_UFUNC ) {
1663  Int_t newid = kFP_ALTFUNC;
1664 
1665  // Add system functions
1666  for ( fSystemFuncIter it = fSystemFuncs.begin();
1667  it != fSystemFuncs.end(); ++it ) {
1668  TF1* f = (*it);
1669  // Don't include system functions that has been previously
1670  // used to fit, as those are included under the kFP_PREVFIT
1671  // section.
1672  if ( strncmp(f->GetName(), "PrevFit", 7) != 0 ) {
1673  // If the dimension of the object coincides with the
1674  // dimension of the function, then include the function in
1675  // the list. It will also include de function if the
1676  // dimension of the object is 0 (i.e. a multivariable
1677  // TTree) as it is currently imposible to know how many
1678  // dimensions a TF1 coming from a C raw function has.
1679  if ( f->GetNdim() == fDim || fDim == 0) {
1680  fFuncList->AddEntry(f->GetName(), newid++);
1681  }
1682  }
1683  }
1684 
1685  // If no function was added
1686  if ( newid != kFP_ALTFUNC )
1687  fFuncList->Select(newid-1);
1688  else if( fDim == 1 ) {
1689  // Select predefined 1D functions for 1D objects
1691  } else if( fDim == 2 ) {
1692  // Select predefined 2D functions for 2D objects
1694  }
1695  }
1696  // Case for previously used functions.
1697  else if ( fTypeFit->GetSelected() == kFP_PREVFIT ) {
1698  Int_t newid = kFP_ALTFUNC;
1699 
1700  // Look only for those functions used in the selected object
1701  std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(fFitObject);
1702  // Then go over all those functions and add them to the list
1703  for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
1704  fFuncList->AddEntry(it->second->GetName(), newid++);
1705  }
1706 
1707  // If no functions were added.
1708  if ( newid == kFP_ALTFUNC ) {
1709  // Remove the entry previous fit from fTypeFit
1711  if( fDim == 1 )
1712  // Select predefined 1D functions for 1D objects
1714  else if ( fDim == 2 )
1715  // Select predefined 2D functions for 2D objects
1717  else
1718  // For more than 2 dimensions, select the user functions.
1720  }
1721  else
1722  // If there is there are previously used functions, select
1723  // the last one inserted.
1724  fFuncList->Select(newid-1, kTRUE);
1725  }
1726 }
1727 
1728 ////////////////////////////////////////////////////////////////////////////////
1729 /// Fills the list of methods depending on the minimization library
1730 /// selected.
1731 
1733 {
1735 
1736  if ( fLibMinuit->GetState() == kButtonDown )
1737  {
1738  fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1739  fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1740  fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1741  fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1743  fStatusBar->SetText("MIGRAD",2);
1744  } else if ( fLibFumili->GetState() == kButtonDown )
1745  {
1746  fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1748  fStatusBar->SetText("FUMILI",2);
1749  } else if ( fLibGSL->GetState() == kButtonDown )
1750  {
1751  fMinMethodList->AddEntry("Fletcher-Reeves conjugate gradient" , kFP_GSLFR);
1752  fMinMethodList->AddEntry("Polak-Ribiere conjugate gradient" , kFP_GSLPR);
1753  fMinMethodList->AddEntry("BFGS conjugate gradient" , kFP_BFGS);
1754  fMinMethodList->AddEntry("BFGS conjugate gradient (Version 2)", kFP_BFGS2);
1755  fMinMethodList->AddEntry("Levenberg-Marquardt" , kFP_GSLLM);
1756  fMinMethodList->AddEntry("Simulated Annealing" , kFP_GSLSA);
1758  fStatusBar->SetText("CONJFR",2);
1759  } else if ( fLibGenetics->GetState() == kButtonDown )
1760  {
1761  if ( gPluginMgr->FindHandler("ROOT::Math::Minimizer","GAlibMin") ) {
1762  fMinMethodList->AddEntry("GA Lib Genetic Algorithm" , kFP_GALIB);
1764  } else if (gPluginMgr->FindHandler("ROOT::Math::Minimizer","Genetic")) {
1765  fMinMethodList->AddEntry("TMVA Genetic Algorithm" , kFP_TMVAGA);
1767  }
1768  } else // if ( fLibMinuit2->GetState() == kButtonDown )
1769  {
1770  fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1771  fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1772  fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1773  fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1774  fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1776  fStatusBar->SetText("MIGRAD",2);
1777  }
1778 }
1779 
1780 void SearchCanvases(TSeqCollection* canvases, std::vector<TObject*>& objects)
1781 {
1782  // Auxiliary function to recursively search for objects inside the
1783  // current canvases.
1784 
1785  TIter canvasIter(canvases);
1786  // Iterate over all the canvases in canvases.
1787  while(TObject* obj = (TObject*) canvasIter()) {
1788  // If the object is another canvas, call this function
1789  // recursively.
1790  if ( TPad* can = dynamic_cast<TPad*>(obj))
1791  SearchCanvases(can->GetListOfPrimitives(), objects);
1792  // Otherwhise, if it's a recognised object, add it to the vector
1793  else if ( dynamic_cast<TH1*>(obj)
1794  || dynamic_cast<TGraph*>(obj)
1795  || dynamic_cast<TGraph2D*>(obj)
1796  || dynamic_cast<TMultiGraph*>(obj)
1797  || dynamic_cast<THStack*>(obj)
1798  || dynamic_cast<TTree*>(obj) ) {
1799  bool insertNew = true;
1800  // Be careful no to insert the same element twice.
1801  for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1802  if ( (*i) == obj ) {
1803  insertNew = false;
1804  break;
1805  }
1806  // If the object is not already in the vector, then insert
1807  // it.
1808  if ( insertNew ) objects.push_back(obj);
1809  }
1810  }
1811 }
1812 
1813 ////////////////////////////////////////////////////////////////////////////////
1814 /// Create a combo box with all the possible objects to be fitted.
1815 
1817 {
1818  // Get the title of the entry selected, so that we can select it
1819  // again once the fDataSet has been refilled.
1821  TString selEntryStr;
1822  if ( entry ) {
1823  selEntryStr = entry->GetTitle();
1824  }
1825 
1826  // Remove all the elements
1827  fDataSet->RemoveAll();
1828  std::vector<TObject*> objects;
1829 
1830  // Get all the objects registered in gDirectory
1831  TIter next(gDirectory->GetList());
1832  TObject* obj = NULL;
1833  while ( (obj = (TObject*) next()) ) {
1834  // But only if they are of a type recognized by the FitPanel
1835  if ( dynamic_cast<TH1*>(obj) ||
1836  dynamic_cast<TGraph2D*>(obj) ||
1837  dynamic_cast<TTree*>(obj) ) {
1838  objects.push_back(obj);
1839  }
1840  }
1841 
1842  // Look for all the drawn objects. The method will take care the
1843  // same objects are not inserted twice.
1844  SearchCanvases(gROOT->GetListOfCanvases(), objects);
1845 
1846  // Add all the objects stored in the vector
1847  int selected = kFP_NOSEL;
1848  // Add the No selection.
1849  Int_t newid = kFP_NOSEL;
1850  fDataSet->AddEntry("No Selection", newid++);
1851  for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1852  // Insert the name as the class name followed by the name of the
1853  // object.
1854  TString name = (*i)->ClassName(); name.Append("::"); name.Append((*i)->GetName());
1855  // Check whether the names are the same!
1856  if ( selEntryStr && name == selEntryStr )
1857  selected = newid;
1858  fDataSet->AddEntry(name, newid++);
1859  }
1860 
1861  // If there was an entry selected (which should be always the case
1862  // except the first time this method is executed), then make it the
1863  // selected one again.
1864  if (entry) {
1865  fDataSet->Select(selected);
1866  }
1867 }
1868 
1869 ////////////////////////////////////////////////////////////////////////////////
1870 /// Create method list in a combo box.
1871 
1873 {
1874  TGComboBox *c = new TGComboBox(parent, id);
1875  c->AddEntry("Chi-square", kFP_MCHIS);
1876  c->AddEntry("Binned Likelihood", kFP_MBINL);
1877  c->AddEntry("Unbinned Likelihood", kFP_MUBIN);
1878  //c->AddEntry("User", kFP_MUSER); //for later use
1879  c->Select(kFP_MCHIS);
1880  return c;
1881 }
1882 
1883 ////////////////////////////////////////////////////////////////////////////////
1884 /// Slot connected to advanced option button (opens a dialog).
1885 
1887 {
1889 }
1890 
1891 ////////////////////////////////////////////////////////////////////////////////
1892 /// Slot connected to 'include emtry bins and forse all weights to 1' setting.
1893 
1895 {
1897  if (fAllWeights1->GetState() == kButtonDown)
1899 }
1900 
1901 ////////////////////////////////////////////////////////////////////////////////
1902 
1904 {
1905  if ( fUseRange->GetState() == kButtonDown ) {
1906  if (fNone->GetState() == kButtonDown || fNone->GetState() == kButtonDisabled) {
1907  // Get the function
1908  TF1* tmpTF1 = FindFunction();
1909  if ( !tmpTF1 ) {
1912  tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
1913  }
1914  }
1915  // If the function has been retrieved, i.e. is a registered function.
1916  if ( tmpTF1 ) {
1917  Double_t xmin, ymin, zmin, xmax, ymax, zmax;
1918  // Get the range
1919  tmpTF1->GetRange(xmin, ymin, zmin, xmax, ymax, zmax);
1920  // And set the sliders
1921  if ( fType != kObjectTree ) {
1922  fSliderXMin->SetNumber( xmin );
1923  fSliderXMax->SetNumber( xmax );
1925  if ( fDim > 1 ) {
1926  fSliderYMin->SetNumber( ymin );
1927  fSliderYMax->SetNumber( ymax );
1929  }
1930  }
1931  }
1932  }
1934  }
1935 }
1936 
1937 ////////////////////////////////////////////////////////////////////////////////
1938 /// Slot connected to 'set all weights to 1' setting.
1939 
1941 {
1942  if (fAllWeights1->GetState() == kButtonDown)
1945 }
1946 
1947 ////////////////////////////////////////////////////////////////////////////////
1948 /// Close the fit panel.
1949 
1951 {
1952  Hide();
1953 }
1954 
1955 ////////////////////////////////////////////////////////////////////////////////
1956 /// Easy here!
1957 
1959 {
1961  FillDataSetList();
1962 }
1963 
1964 ////////////////////////////////////////////////////////////////////////////////
1965 /// Perform a fit with current parameters' settings.
1966 
1968 {
1969  if (!fFitObject) return;
1970  //if (!fParentPad) return;
1971 
1972  // If fNone->GetState() == kButtonDisabled means the function is
1973  // not editable, i.e. it comes from a raw C function. So in this
1974  // case, it is editable and we have to check wheather the formula
1975  // is well built.
1977  {
1978  // If not, then show an error message and leave.
1980  "Error...", "2) Verify the entered function string!",
1981  kMBIconStop,kMBOk, 0);
1982  return;
1983  }
1984 
1985  // Set the button so that the user cannot use it while fitting, set
1986  // the mouse to watch type and so on.
1988  if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kWatch);
1989  gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
1990 
1991  TVirtualPad *save = 0;
1992  if ( fParentPad ) {
1993  fParentPad->Disconnect("RangeAxisChanged()");
1994  save = gPad;
1995  gPad = fParentPad;
1996  fParentPad->cd();
1997 
1998  if (fParentPad->GetCanvas())
2000  }
2001 
2002  // Get the ranges from the sliders
2003  ROOT::Fit::DataRange drange;
2004  GetRanges(drange);
2005 
2006  // Create a static pointer to fitFunc. Every second call to the
2007  // DoFit method, the old fitFunc is deleted. We need not to delete
2008  // the function after the fitting in case we want to do Advaced
2009  // graphics. The VirtualFitter need the function to be alived. One
2010  // problem, after the last fit the function is never deleted, but
2011  // ROOT's garbage collector will do the job for us.
2012  static TF1 *fitFunc = 0;
2013  if ( fitFunc ) {
2014  delete fitFunc;
2015  }
2016  fitFunc = GetFitFunction();
2017 
2018  //std::cout << "dofit: using function " << fitFunc << std::endl;
2019  // This assert
2020  if (!fitFunc) {
2021  Error("DoFit","This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2022  return;
2023  }
2024 
2025  // set parameters from panel in function
2026  SetParameters(fFuncPars, fitFunc);
2027  // Get the options stored in the GUI elements.
2029  Foption_t fitOpts;
2030  TString strDrawOpts;
2031  RetrieveOptions(fitOpts, strDrawOpts, mopts, fitFunc->GetNpar());
2032 
2033  // Call the fit method, depending on the object to fit.
2034  switch (fType) {
2035  case kObjectHisto: {
2036 
2037  TH1 *hist = dynamic_cast<TH1*>(fFitObject);
2038  if (hist)
2039  ROOT::Fit::FitObject(hist, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2040 
2041  break;
2042  }
2043  case kObjectGraph: {
2044 
2045  TGraph *gr = dynamic_cast<TGraph*>(fFitObject);
2046  if (gr)
2047  FitObject(gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2048  break;
2049  }
2050  case kObjectMultiGraph: {
2051 
2052  TMultiGraph *mg = dynamic_cast<TMultiGraph*>(fFitObject);
2053  if (mg)
2054  FitObject(mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2055 
2056  break;
2057  }
2058  case kObjectGraph2D: {
2059 
2060  TGraph2D *g2d = dynamic_cast<TGraph2D*>(fFitObject);
2061  if (g2d)
2062  FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2063 
2064  break;
2065  }
2066  case kObjectHStack: {
2067  // N/A
2068  break;
2069  }
2070  case kObjectTree: {
2071  // The three is a much more special case. The steps for
2072  // fitting have to be done manually here until they are
2073  // properly implemented within a FitObject method in
2074  // THFitImpl.cxx
2075 
2076  // Retrieve the variables and cuts selected from the current
2077  // tree.
2079  TString cuts;
2080  GetTreeVarsAndCuts(fDataSet, variables, cuts);
2081 
2082  // This should be straight forward and the return should
2083  // never be called.
2084  TTree *tree = dynamic_cast<TTree*>(fFitObject);
2085  if ( !tree ) return;
2086 
2087  // These method calls are just to set up everything for the
2088  // fitting. It's taken from another script.
2089  gROOT->ls();
2090  tree->Draw(variables,cuts,"goff candle");
2091 
2092  TTreePlayer * player = (TTreePlayer*) tree->GetPlayer();
2093  if ( !player ) {
2094  Error("DoFit","Player reference is NULL");
2095  return;
2096  }
2097 
2098  TSelectorDraw * selector = (TSelectorDraw* ) player->GetSelector();
2099  if ( !selector ) {
2100  Error("DoFit","Selector reference is NULL");
2101  return;
2102  }
2103 
2104  // use pointer stored in the tree (not copy the data in)
2105  unsigned int ndim = player->GetDimension();
2106  if ( ndim == 0 ) {
2107  Error("DoFit","NDIM == 0");
2108  return;
2109  }
2110 
2111  std::vector<double *> vlist;
2112  for (unsigned int i = 0; i < ndim; ++i) {
2113  double * v = selector->GetVal(i);
2114  if (v != 0) vlist.push_back(v);
2115  else
2116  std::cerr << "pointer for variable " << i << " is zero" << std::endl;
2117  }
2118  if (vlist.size() != ndim) {
2119  Error("DoFit","Vector is not complete");
2120  return;
2121  }
2122 
2123  // fill the data
2124  Long64_t nrows = player->GetSelectedRows();
2125  if ( !nrows ) {
2126  Error("DoFit","NROWS == 0");
2127  return;
2128  }
2129 
2130  ROOT::Fit::UnBinData * fitdata = new ROOT::Fit::UnBinData(nrows, ndim, vlist.begin());
2131 
2132  for ( int i = 0; i < std::min(int(fitdata->Size()),10); ++i) {
2133  // print j coordinate
2134  for (unsigned int j = 0; j < ndim; ++j) {
2135  printf(" x_%d [%d] = %f \n", j, i,*(fitdata->Coords(i)+j) );
2136  }
2137  printf("\n");
2138  }
2139 
2140 
2141  //TVirtualFitter::SetDefaultFitter("Minuit");
2142  Foption_t fitOption;
2143  ROOT::Math::MinimizerOptions minOption;
2144  fitOption.Verbose=1;
2145 
2146  // After all the set up is performed, then do the Fit!!
2147  ROOT::Fit::UnBinFit(fitdata, fitFunc, fitOption, minOption);
2148 
2149  break;
2150  }
2151  }
2152 
2153  // if SAME is set re-plot the function
2154  // useful in case histogram was drawn with HIST
2155  // and no function will be drawm)
2156  if (fDrawSame->GetState() == kButtonDown && fitFunc)
2157  fitFunc->Draw("same");
2158 
2159 
2160  // update parameters value shown in dialog
2161  //if (!fFuncPars) fFuncPars = new Double_t[fitFunc->GetNpar()][3];
2162  GetParameters(fFuncPars,fitFunc);
2163 
2164  // Save fit data for future use as a PrevFit function.
2165  TF1* tmpTF1 = static_cast<TF1*>( copyTF1(fitFunc) );
2166  ostringstream name;
2167  name << "PrevFit-" << fPrevFit.size() + 1;
2168  if ( strcmp(tmpTF1->GetName(), "PrevFitTMP") != 0 )
2169  name << "-" << tmpTF1->GetName();
2170  tmpTF1->SetName(name.str().c_str());
2171  fPrevFit.insert(FitFuncMap_t::value_type(fFitObject, tmpTF1));
2172  fSystemFuncs.push_back( copyTF1(tmpTF1) );
2173 
2174  float xmin = 0.f, xmax = 0.f, ymin = 0.f, ymax = 0.f, zmin = 0.f, zmax = 0.f;
2175  if ( fParentPad ) {
2176  fParentPad->Modified();
2177  // As the range is not changed, save the old values and restore
2178  // after the GUI has been updated. It would be more elegant to
2179  // disconnect the signal from fParentPad, however, this doesn't
2180  // work for unknown reasons.
2181  if ( fType != kObjectTree ) fSliderX->GetPosition(xmin, xmax);
2182  if ( fDim > 1 ) fSliderY->GetPosition(ymin, ymax);
2183  if ( fDim > 2 ) fSliderZ->GetPosition(zmin, zmax);
2184  fParentPad->Update();
2185  }
2186 
2187  // In case the fit method draws something! Set the canvas!
2188  fParentPad = gPad;
2189  UpdateGUI();
2190 
2191  // Change the sliders if necessary.
2192  if ( fParentPad ) {
2193  if ( fType != kObjectTree ) { fSliderX->SetPosition(xmin, xmax); DoSliderXMoved(); }
2194  if ( fType != kObjectTree && fDim > 1 ) { fSliderY->SetPosition(ymin, ymax); DoSliderYMoved(); }
2195  if ( fType != kObjectTree && fDim > 2 ) { fSliderZ->SetPosition(zmin, zmax); DoSliderZMoved(); }
2196  if (fParentPad->GetCanvas())
2198  fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2199 
2200  if (save) gPad = save;
2201  if (fSetParam->GetState() == kButtonDisabled &&
2204  }
2205 
2206  // Restore the Fit button and mouse cursor to their proper state.
2207  if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kPointer);
2208  gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
2210 
2211  if ( !fTypeFit->FindEntry("Prev. Fit") )
2212  fTypeFit->InsertEntry("Prev. Fit",kFP_PREVFIT, kFP_UFUNC);
2213 
2215 }
2216 
2217 ////////////////////////////////////////////////////////////////////////////////
2218 /// Check entered function string.
2219 
2221 {
2222  Int_t rvalue = 0;
2223  if ( fDim == 1 || fDim == 0 ) {
2224  TF1 form("tmpCheck", fname);
2225  // coverity[uninit_use_in_call]
2226  rvalue = form.IsValid() ? 0 : -1;
2227  } else if ( fDim == 2 ) {
2228  TF2 form("tmpCheck", fname);
2229  // coverity[uninit_use_in_call]
2230  rvalue = form.IsValid() ? 0 : -1;
2231  } else if ( fDim == 3 ) {
2232  TF3 form("tmpCheck", fname);
2233  // coverity[uninit_use_in_call]
2234  rvalue = form.IsValid() ? 0 : -1;
2235  }
2236 
2237  return rvalue;
2238 }
2239 
2240 ////////////////////////////////////////////////////////////////////////////////
2241 /// Slot connected to addition of predefined functions. It will
2242 /// insert the next selected function with a plus sign so that it
2243 /// doesn't override the current content of the formula.
2244 
2246 {
2247  static Bool_t first = kFALSE;
2248  TString s = fEnteredFunc->GetText();
2249  if (on) {
2250  if (!first) {
2251  fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2252  s += "(0)";
2253  fEnteredFunc->SetText(s.Data());
2254  first = kTRUE;
2256  }
2257  } else {
2258  first = kFALSE;
2259  }
2260 }
2261 ////////////////////////////////////////////////////////////////////////////////
2262 /// Slot connected to addition of predefined functions. It will
2263 /// insert the next selected function with a plus sign so that it
2264 /// doesn't override the current content of the formula.
2265 
2267 {
2268  /*
2269  static Bool_t first = kFALSE;
2270  TString s = fEnteredFunc->GetText();
2271  if (on) {
2272  if (!first) {
2273  fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2274  fEnteredFunc->SetText(s.Data());
2275  first = kTRUE;
2276  ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2277  }
2278  } else {
2279  first = kFALSE;
2280  }*/
2281  if (on) std::cout << "DoNormAddition" << std::endl;
2282 }
2283 
2284 ////////////////////////////////////////////////////////////////////////////////
2285 /// Slot connected to addition of predefined functions. It will
2286 /// insert the next selected function with a plus sign so that it
2287 /// doesn't override the current content of the formula.
2288 
2290 {
2291  /*
2292  static Bool_t first = kFALSE;
2293  TString s = fEnteredFunc->GetText();
2294  if (on) {
2295  if (!first) {
2296  fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2297  // s += "(0)";
2298  fEnteredFunc->SetText(s.Data());
2299  first = kTRUE;
2300  ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2301  }
2302  } else
2303  first = kFALSE;*/
2304  if (on) std::cout << "DoConvolution" << std::endl;
2305 }
2306 
2307 ////////////////////////////////////////////////////////////////////////////////
2308 /// Selects the data set to be fitted
2309 
2311 {
2312  if ( selected == kFP_NOSEL ) {
2313  DoNoSelection();
2314  return;
2315  }
2316 
2317  // Get the name and class of the selected object.
2318  TGTextLBEntry* textEntry = static_cast<TGTextLBEntry*>(fDataSet->GetListBox()->GetEntry(selected));
2319  if (!textEntry) return;
2320  TString textEntryStr = textEntry->GetText()->GetString();
2321  TString name = textEntry->GetText()->GetString()+textEntry->GetText()->First(':')+2;
2322  TString className = textEntryStr(0,textEntry->GetText()->First(':'));
2323 
2324  // Check the object exists in the ROOT session and it is registered
2325  TObject* objSelected(0);
2326  if ( className == "TTree" ) {
2327  // It's a tree, so the name is before the space (' ')
2328  TString lookStr;
2329  if ( name.First(' ') == kNPOS )
2330  lookStr = name;
2331  else
2332  lookStr = name(0, name.First(' '));
2333  //std::cout << "\t1 SITREE: '" << lookStr << "'" << std::endl;
2334  objSelected = gROOT->FindObject(lookStr);
2335  } else {
2336  // It's not a tree, so the name is the complete string
2337  //std::cout << "\t1 NOTREE: '" << name << "'" << std::endl;
2338  objSelected = gROOT->FindObject(name);
2339  }
2340  if ( !objSelected )
2341  {
2342  //std::cerr << "Object not found! Please report the error! " << std::endl;
2343  return;
2344  }
2345 
2346  // If it is a tree, and there are no variables selected, show a dialog
2347  if ( objSelected->InheritsFrom(TTree::Class()) &&
2348  name.First(' ') == kNPOS ) {
2349  char variables[256] = {0}; char cuts[256] = {0};
2350  strlcpy(variables, "Sin input!", 256);
2351  new TTreeInput( fClient->GetRoot(), GetMainFrame(), variables, cuts );
2352  if ( strcmp ( variables, "" ) == 0 ) {
2353  DoNoSelection();
2354  return;
2355  }
2356  ProcessTreeInput(objSelected, selected, variables, cuts);
2357  }
2358 
2359  // Search the canvas where the object is drawn, if any
2360  TPad* currentPad = NULL;
2361  bool found = false;
2362  queue<TPad*> stPad;
2363  TIter padIter( gROOT->GetListOfCanvases() );
2364  while ( TObject* canvas = static_cast<TObject*>(padIter() ) ) {
2365  if ( dynamic_cast<TPad*>(canvas) )
2366  stPad.push(dynamic_cast<TPad*>(canvas));
2367  }
2368 
2369  while ( !stPad.empty() && !found ) {
2370  currentPad = stPad.front();
2371  stPad.pop();
2372  TIter elemIter( currentPad->GetListOfPrimitives() );
2373  while ( TObject* elem = static_cast<TObject*>(elemIter() ) ) {
2374  if ( elem == objSelected ) {
2375  found = true;
2376  break;
2377  } else if ( dynamic_cast<TPad*>(elem) )
2378  stPad.push( dynamic_cast<TPad*>(elem) );
2379  }
2380  }
2381 
2382  // Set the proper object and canvas (if found!)
2383  SetFitObject( found?currentPad:NULL, objSelected, kButton1Down);
2384 }
2385 
2387 {
2388  // If the input is valid, insert the tree with the selections as an entry to fDataSet
2389  TString entryName = (objSelected)->ClassName(); entryName.Append("::"); entryName.Append((objSelected)->GetName());
2390  entryName.Append(" (\""); entryName.Append(variables); entryName.Append("\", \"");
2391  entryName.Append(cuts); entryName.Append("\")");
2393  fDataSet->InsertEntry(entryName, newid, selected );
2394  fDataSet->Select(newid);
2395 }
2396 
2397 ////////////////////////////////////////////////////////////////////////////////
2398 /// Slot connected to predefined fit function settings.
2399 
2401 {
2403 
2404  // check that selected passesd value is the correct one in the TextEntry
2405  R__ASSERT( selected == te->EntryId());
2406  //std::cout << "calling do function " << selected << " " << te->GetTitle() << " function " << te->EntryId() << std::endl;
2407  //selected = te->EntryId();
2408 
2409  bool editable = false;
2410  if (fNone -> GetState() == kButtonDown || fNone->GetState() == kButtonDisabled)
2411  {
2412  // Get the function selected and check weather it is a raw C
2413  // function or not
2414  TF1* tmpTF1 = FindFunction();
2415  if ( !tmpTF1 )
2416  {
2418  tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
2419  }
2420  if ( tmpTF1 && strcmp(tmpTF1->GetExpFormula(), "") )
2421  {
2422  editable = kTRUE;
2423  fEnteredFunc->SetText(tmpTF1->GetExpFormula());
2424  }
2425  else
2426  {
2427  if ( selected <= kFP_USER )
2428  editable = kTRUE;
2429  else
2430  editable = kFALSE;
2431  fEnteredFunc->SetText(te->GetTitle());
2432  }
2433  // Once you have the function, set the editable.
2434  SetEditable(editable);
2435  }
2436  else if (fAdd -> GetState() == kButtonDown)
2437  {
2438  // If the add button is down don't replace the fEnteredFunc text
2439  Int_t np = 0;
2440  TString s = "";
2441  if (!strcmp(fEnteredFunc->GetText(), ""))
2442  {
2443  fEnteredFunc->SetText(te->GetTitle());
2444  }
2445  else
2446  {
2447  s = fEnteredFunc->GetTitle();
2448  TFormula tmp("tmp", fEnteredFunc->GetText());
2449  np = tmp.GetNpar();
2450  }
2451  if (np)
2452  s += TString::Format("+%s(%d)", te->GetTitle(), np);
2453  else
2454  s += TString::Format("%s(%d)", te->GetTitle(), np);
2455  fEnteredFunc->SetText(s.Data());
2456  editable = true;
2457  }
2458  else if (fNormAdd->GetState() == kButtonDown)
2459  {
2460  // If the normadd button is down don't replace the fEnteredFunc text
2461  Int_t np = 0;
2462  TString s = "";
2463  if (!strcmp(fEnteredFunc->GetText(), ""))
2464  {
2465  fEnteredFunc->SetText(te->GetTitle());
2466  }
2467  else
2468  {
2469  s = fEnteredFunc->GetTitle();
2470  TFormula tmp("tmp", fEnteredFunc->GetText());
2471  np = tmp.GetNpar();
2472  }
2473  if (np)
2474  s += TString::Format("+%s", te->GetTitle());
2475  else
2476  s += TString::Format("%s", te->GetTitle());
2477  fEnteredFunc->SetText(s.Data());
2478  //std::cout <<fEnteredFunc->GetText()<<std::endl;
2479  editable = true;
2480  }
2481  else if (fConv->GetState() == kButtonDown)
2482  {
2483  // If the normadd button is down don't replace the fEnteredFunc text
2484  Int_t np = 0;
2485  TString s = "";
2486  if (!strcmp(fEnteredFunc->GetText(), ""))
2487  fEnteredFunc->SetText(te->GetTitle());
2488  else
2489  {
2490  s = fEnteredFunc->GetTitle();
2491  TFormula tmp("tmp", fEnteredFunc->GetText());
2492  np = tmp.GetNpar();
2493  }
2494  if (np)
2495  s += TString::Format("*%s", te->GetTitle());
2496  else
2497  s += TString::Format("%s", te->GetTitle());
2498  fEnteredFunc->SetText(s.Data());
2499  //std::cout <<fEnteredFunc->GetText()<<std::endl;
2500  editable = true;
2501  }
2502 
2503 
2504  // Get the final name in fEnteredFunc to process the function that
2505  // it would create
2506  TString tmpStr = fEnteredFunc->GetText();
2507 
2508  // create TF1 with the passed string. Delete previous one if existing
2509  if (tmpStr.Contains("pol") || tmpStr.Contains("++")) {
2511  } else {
2513  }
2514 
2516  fSelLabel->SetText(tmpStr.Sizeof()>30?tmpStr(0,30)+"...":tmpStr);
2518 
2519  // reset function parameters if the number of parameters of the new
2520  // function is different from the old one!
2521  TF1* fitFunc = GetFitFunction();
2522 
2523  if ( fitFunc && (unsigned int) fitFunc->GetNpar() != fFuncPars.size() )
2524  fFuncPars.clear();
2525  if ( fitFunc ) delete fitFunc;
2526 }
2527 
2528 ////////////////////////////////////////////////////////////////////////////////
2529 /// Slot connected to entered function in text entry.
2530 
2532 {
2533  if (!strcmp(fEnteredFunc->GetText(), "")) return;
2534 
2535  // Check if the function is well built
2537 
2538  if (ok != 0) {
2540  "Error...", "3) Verify the entered function string!",
2541  kMBIconStop,kMBOk, 0);
2542  return;
2543  }
2544 
2545  // And set the label with the entered text if everything is fine.
2546  TString s = fEnteredFunc->GetText();
2547  fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2549 }
2550 
2551 ////////////////////////////////////////////////////////////////////////////////
2552 /// Slot connected to linear fit settings.
2553 
2555 {
2556  if (fLinearFit->GetState() == kButtonDown) {
2557  //fSetParam->SetState(kButtonDisabled);
2561  //fNoChi2->SetState(kButtonUp);
2562  } else {
2563  //fSetParam->SetState(kButtonUp);
2568  //fNoChi2->SetState(kButtonDisabled);
2569  }
2570 }
2571 
2572 ////////////////////////////////////////////////////////////////////////////////
2573 /// Slot connected to 'no chi2' option settings.
2574 
2576 {
2577  //LM: no need to do operations here
2578  // if (fLinearFit->GetState() == kButtonUp)
2579  // fLinearFit->SetState(kButtonDown, kTRUE);
2580 }
2581 ////////////////////////////////////////////////////////////////////////////////
2582 /// Slot connected to 'robust fitting' option settings.
2583 
2585 {
2588  else
2590 }
2591 
2592 ////////////////////////////////////////////////////////////////////////////////
2593 /// Slot connected to 'no storing, no drawing' settings.
2594 
2596 {
2597  if (fNoDrawing->GetState() == kButtonUp)
2599 }
2600 
2601 ////////////////////////////////////////////////////////////////////////////////
2602 /// Slot connected to print option settings.
2603 
2605 {
2606  // Change the states of the buttons depending of which one is
2607  // selected.
2608  TGButton *btn = (TGButton *) gTQSender;
2609  Int_t id = btn->WidgetId();
2610  switch (id) {
2611  case kFP_PDEF:
2612  if (on) {
2616  }
2617  fStatusBar->SetText("Prn: DEF",4);
2618  break;
2619  case kFP_PVER:
2620  if (on) {
2624  }
2625  fStatusBar->SetText("Prn: VER",4);
2626  break;
2627  case kFP_PQET:
2628  if (on) {
2632  }
2633  fStatusBar->SetText("Prn: QT",4);
2634  default:
2635  break;
2636  }
2637 }
2638 
2639 ////////////////////////////////////////////////////////////////////////////////
2640 /// Reset all fit parameters.
2641 
2643 {
2644  if ( fParentPad ) {
2645  fParentPad->Modified();
2646  fParentPad->Update();
2647  }
2648  fEnteredFunc->SetText("gaus");
2649 
2650  // To restore temporary points and sliders
2651  UpdateGUI();
2652 
2653  if (fLinearFit->GetState() == kButtonDown)
2655  if (fBestErrors->GetState() == kButtonDown)
2657  if (fUseRange->GetState() == kButtonDown)
2659  if (fAllWeights1->GetState() == kButtonDown)
2667  if (fUseGradient->GetState() == kButtonDown)
2671  // if (fNoChi2->GetState() == kButtonDown)
2672  // fNoChi2->SetState(kButtonUp, kFALSE);
2673  if (fDrawSame->GetState() == kButtonDown)
2675  if (fNoDrawing->GetState() == kButtonDown)
2680  fFuncList->Select(1, kTRUE);
2681 
2682  // minimization tab
2683  if (fLibMinuit->GetState() != kButtonDown)
2686  if (fOptDefault->GetState() != kButtonDown)
2691  }
2695  }
2699  }
2700 }
2701 
2702 ////////////////////////////////////////////////////////////////////////////////
2703 /// Open set parameters dialog.
2704 
2706 {
2707  // Get the function.
2708  TF1* fitFunc = GetFitFunction();
2709 
2710  if (!fitFunc) { Error("DoSetParameters","NUll function"); return; }
2711 
2712  // case of special functions (gaus, expo, etc...) if the function
2713  // has not defined the parameters yet. For those, don't let the
2714  // parameters to be all equal to 0, as we can provide some good
2715  // starting value.
2716  if (fFuncPars.size() == 0) {
2717  switch (fType) {
2718  case kObjectHisto:
2719  InitParameters( fitFunc, (TH1*)fFitObject) ;
2720  break;
2721  case kObjectGraph:
2722  InitParameters( fitFunc, ((TGraph*)fFitObject));
2723  break;
2724  case kObjectMultiGraph:
2725  InitParameters( fitFunc, ((TMultiGraph*)fFitObject));
2726  break;
2727  case kObjectGraph2D:
2728  InitParameters( fitFunc, ((TGraph2D*)fFitObject));
2729  break;
2730  case kObjectHStack:
2731  case kObjectTree:
2732  default:
2733  break;
2734  }
2735  // The put these parameters into the fFuncPars structure
2736  GetParameters(fFuncPars, fitFunc);
2737  }
2738  else {
2739  // Otherwise, put the parameters in the function
2740  SetParameters(fFuncPars, fitFunc);
2741  }
2742 
2743  if ( fParentPad ) fParentPad->Disconnect("RangeAxisChanged()");
2744  Int_t ret = 0;
2745  new TFitParametersDialog(gClient->GetDefaultRoot(), GetMainFrame(),
2746  fitFunc, fParentPad, &ret);
2747 
2748  // Once the parameters are set in the fitfunction, save them.
2749  GetParameters(fFuncPars, fitFunc);
2750 
2751  if ( fParentPad ) fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2752 
2753  if ( fNone->GetState() != kButtonDisabled ) delete fitFunc;
2754 }
2755 
2756 ////////////////////////////////////////////////////////////////////////////////
2757 /// Slot connected to range settings on x-axis.
2758 
2760 {
2761  if ( !fFitObject ) return;
2762 
2763  fSliderXMin->SetNumber( fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ) );
2764  fSliderXMax->SetNumber( fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ) );
2765 
2767 
2768  DrawSelection();
2769 }
2770 
2771 ////////////////////////////////////////////////////////////////////////////////
2772 /// Draws the square around the object showing where the limits for
2773 /// fitting are.
2774 
2775 void TFitEditor::DrawSelection(bool restore)
2776 {
2777  static Int_t px1old, py1old, px2old, py2old; // to remember the square drawn.
2778 
2779  if ( !fParentPad ) return;
2780 
2781  if (restore) {
2782  px1old = fParentPad->XtoAbsPixel(fParentPad->GetUxmin());
2783  py1old = fParentPad->YtoAbsPixel(fParentPad->GetUymin());
2784  px2old = fParentPad->XtoAbsPixel(fParentPad->GetUxmax());
2785  py2old = fParentPad->YtoAbsPixel(fParentPad->GetUymax());
2786  return;
2787  }
2788 
2789  Int_t px1,py1,px2,py2;
2790 
2791  TVirtualPad *save = 0;
2792  save = gPad;
2793  gPad = fParentPad;
2794  gPad->cd();
2795 
2796  Double_t xleft = 0;
2797  Double_t xright = 0;
2798  xleft = fXaxis->GetBinLowEdge((Int_t)((fSliderX->GetMinPosition())+0.5));
2799  xright = fXaxis->GetBinUpEdge((Int_t)((fSliderX->GetMaxPosition())+0.5));
2800 
2801  Float_t ymin, ymax;
2802  if ( fDim > 1 )
2803  {
2804  ymin = fYaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));//gPad->GetUymin();
2805  ymax = fYaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));//gPad->GetUymax();
2806  }
2807  else
2808  {
2809  ymin = gPad->GetUymin();
2810  ymax = gPad->GetUymax();
2811  }
2812 
2813  px1 = gPad->XtoAbsPixel(xleft);
2814  py1 = gPad->YtoAbsPixel(ymin);
2815  px2 = gPad->XtoAbsPixel(xright);
2816  py2 = gPad->YtoAbsPixel(ymax);
2817 
2818  if (gPad->GetCanvas()) gPad->GetCanvas()->FeedbackMode(kTRUE);
2819  gPad->SetLineWidth(1);
2820  gPad->SetLineColor(2);
2821 
2822  gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
2823  gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2824 
2825  px1old = px1;
2826  py1old = py1;
2827  px2old = px2 ;
2828  py2old = py2;
2829 
2830  if(save) gPad = save;
2831 }
2832 
2833 ////////////////////////////////////////////////////////////////////////////////
2834 /// Sincronize the numeric sliders with the graphical one.
2835 
2837 {
2838  if ( fSliderXMin->GetNumber() > fSliderXMax->GetNumber() ) {
2839  float xmin, xmax;
2840  fSliderX->GetPosition(xmin, xmax);
2841  fSliderXMin->SetNumber( fXaxis->GetBinLowEdge( static_cast<Int_t>( xmin ) ) );
2842  fSliderXMax->SetNumber( fXaxis->GetBinUpEdge ( static_cast<Int_t>( xmax ) ) );
2843  return;
2844  }
2845 
2848 
2850 
2851  DrawSelection();
2852 }
2853 
2854 ////////////////////////////////////////////////////////////////////////////////
2855 /// Slot connected to range settings on y-axis.
2856 
2858 {
2859  if ( !fFitObject ) return;
2860 
2861  fSliderYMin->SetNumber( fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ) );
2862  fSliderYMax->SetNumber( fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ) );
2863 
2865 
2866  DrawSelection();
2867 }
2868 
2869 ////////////////////////////////////////////////////////////////////////////////
2870 ///syncronize the numeric slider with the graphical one.
2871 
2873 {
2874  if ( fSliderYMin->GetNumber() > fSliderYMax->GetNumber() ) {
2875  float ymin, ymax;
2876  fSliderY->GetPosition(ymin, ymax);
2877  fSliderYMin->SetNumber( fYaxis->GetBinLowEdge( static_cast<Int_t>( ymin ) ) );
2878  fSliderYMax->SetNumber( fYaxis->GetBinUpEdge ( static_cast<Int_t>( ymax ) ) );
2879  return;
2880  }
2881 
2884 
2886 
2887  DrawSelection();
2888 }
2889 
2890 ////////////////////////////////////////////////////////////////////////////////
2891 /// Slot connected to range settings on z-axis.
2892 
2894 {
2895 }
2896 
2897 ////////////////////////////////////////////////////////////////////////////////
2898 /// Open a dialog for getting a user defined method.
2899 
2901 {
2903  "Info", "Dialog of user method is not implemented yet",
2904  kMBIconAsterisk,kMBOk, 0);
2905 }
2906 
2907 ////////////////////////////////////////////////////////////////////////////////
2908 /// Set the function to be used in performed fit.
2909 
2910 void TFitEditor::SetFunction(const char *function)
2911 {
2912  fEnteredFunc->SetText(function);
2913 }
2914 
2915 ////////////////////////////////////////////////////////////////////////////////
2916 /// Check whether the object suitable for fitting and set
2917 /// its type, dimension and method combo box accordingly.
2918 
2920 {
2921  Bool_t set = kFALSE;
2922 
2923  // For each kind of object, set a different status in the fit
2924  // panel.
2925  if (obj->InheritsFrom(TGraph::Class())) {
2926  fType = kObjectGraph;
2927  set = kTRUE;
2928  fDim = 1;
2930  fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2933  fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
2934  } else if (obj->InheritsFrom(TGraph2D::Class())) {
2936  set = kTRUE;
2937  fDim = 2;
2939  fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2941  } else if (obj->InheritsFrom(THStack::Class())) {
2942  fType = kObjectHStack;
2943  set = kTRUE;
2944  TH1 *hist = (TH1 *)((THStack *)obj)->GetHists()->First();
2945  fDim = hist->GetDimension();
2947  fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2949  } else if (obj->InheritsFrom(TTree::Class())) {
2950  fType = kObjectTree;
2951  set = kTRUE;
2952  TString variables, cuts;
2953  GetTreeVarsAndCuts(fDataSet, variables, cuts);
2954  fDim = 1;
2955  for ( int i = 0; i < variables.Length() && fDim <= 2; ++i )
2956  if ( ':' == variables[i] ) fDim += 1;
2957  // For any three of dimension bigger than 2, set the dimension
2958  // to 0, as we cannot infer the dimension from the TF1s, it's
2959  // better to have 0 as reference.
2960  if ( fDim > 2 ) fDim = 0;
2962  fMethodList->AddEntry("Unbinned Likelihood", kFP_MUBIN);
2964  } else if (obj->InheritsFrom(TH1::Class())){
2965  fType = kObjectHisto;
2966  set = kTRUE;
2967  fDim = ((TH1*)obj)->GetDimension();
2969  fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2970  fMethodList->AddEntry("Binned Likelihood", kFP_MBINL);
2972  } else if (obj->InheritsFrom(TMultiGraph::Class())) {
2974  set = kTRUE;
2975  fDim = 1;
2977  fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2980  fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
2981  }
2982 
2983  // Depending on the dimension of the object, allow the
2984  // visualization of sliders.
2985  if ( fDim < 2 || fType == kObjectTree )
2987  else
2989 
2990  if ( fDim < 1 || fType == kObjectTree )
2992  else
2994 
2995  // And also, depending on the dimension, add predefined functions.
2996  if ( fDim == 1 ) {
2997  if ( !fTypeFit->FindEntry("Predef-1D") )
2998  fTypeFit->InsertEntry("Predef-1D", kFP_PRED1D, kFP_PREVFIT);
2999  } else {
3000  if ( fTypeFit->FindEntry("Predef-1D") )
3002  }
3003 
3004  if ( fDim == 2 ) {
3005  if ( !fTypeFit->FindEntry("Predef-2D") )
3006  fTypeFit->InsertEntry("Predef-2D", kFP_PRED2D, kFP_PREVFIT);
3007  } else {
3008  if ( fTypeFit->FindEntry("Predef-2D") )
3010  }
3011 
3012  return set;
3013 }
3014 
3015 ////////////////////////////////////////////////////////////////////////////////
3016 /// Show object name on the top.
3017 
3019 {
3020  TString name;
3021  bool isTree = false;
3022 
3023  // Build the string to be compared to look for the object.
3024  if (obj) {
3025  name = obj->ClassName();
3026  name.Append("::");
3027  name.Append(obj->GetName());
3028  isTree = strcmp(obj->ClassName(), "TTree") == 0;
3029  } else {
3030  name = "No object selected";
3031  }
3032  fStatusBar->SetText(name.Data(),0);
3033 
3034  // If the selection was done in the fDataSet combo box, there is no need
3035  // to search through the list
3036  TGTextLBEntry* selectedEntry = static_cast<TGTextLBEntry*> ( fDataSet->GetSelectedEntry());
3037  if ( selectedEntry ) {
3038  TString selectedName = selectedEntry->GetText()->GetString();
3039  if ( isTree )
3040  selectedName = selectedName(0, selectedName.First(' '));
3041  if ( name.CompareTo(selectedName) == 0 ) {
3042  Layout();
3043  return;
3044  }
3045  }
3046 
3047  // Search through the list for the object
3048  Int_t entryId = kFP_NOSEL+1;
3049  bool found = false;
3050  while ( TGTextLBEntry* entry = static_cast<TGTextLBEntry*>
3051  ( fDataSet->GetListBox()->GetEntry(entryId)) ) {
3052  TString compareName = entry->GetText()->GetString();
3053  if ( isTree )
3054  compareName = compareName(0, compareName.First(' '));
3055  if ( name.CompareTo(compareName) == 0 ) {
3056  // If the object is found, select it
3057  fDataSet->Select(entryId, false);
3058  found = true;
3059  break;
3060  }
3061  entryId += 1;
3062  }
3063 
3064  // If the object was not found, add it and select it.
3065  if ( !found ) {
3066  fDataSet->AddEntry(name.Data(), entryId);
3067  fDataSet->Select(entryId, kTRUE);
3068  }
3069 
3070  Layout();
3071 }
3072 
3073 ////////////////////////////////////////////////////////////////////////////////
3074 /// Get draw options of the selected object.
3075 
3077 {
3078  if (!fParentPad) return "";
3079 
3081  TObject *obj;
3082  while ((obj = next())) {
3083  if (obj == fFitObject) return next.GetOption();
3084  }
3085  return "";
3086 }
3087 
3088 ////////////////////////////////////////////////////////////////////////////////
3089 /// Set selected minimization library in use.
3090 
3092 {
3093  TGButton *bt = (TGButton *)gTQSender;
3094  Int_t id = bt->WidgetId();
3095 
3096  switch (id) {
3097 
3098  // Depending on the selected library, set the state of the rest
3099  // of the buttons.
3100  case kFP_LMIN:
3101  {
3102  if (on) {
3106  if ( fLibGSL->GetState() != kButtonDisabled )
3110  fStatusBar->SetText("LIB Minuit", 1);
3111  }
3112 
3113  }
3114  break;
3115 
3116  case kFP_LMIN2:
3117  {
3118  if (on) {
3122  if ( fLibGSL->GetState() != kButtonDisabled )
3126  fStatusBar->SetText("LIB Minuit2", 1);
3127  }
3128  }
3129  break;
3130 
3131  case kFP_LFUM:
3132  {
3133  if (on) {
3137  if ( fLibGSL->GetState() != kButtonDisabled )
3141  fStatusBar->SetText("LIB Fumili", 1);
3142  }
3143  }
3144  break;
3145  case kFP_LGSL:
3146  {
3147  if (on) {
3151  if ( fLibGSL->GetState() != kButtonDisabled )
3155  fStatusBar->SetText("LIB GSL", 1);
3156  }
3157  }
3158  break;
3159  case kFP_LGAS:
3160  {
3161  if (on) {
3165  if ( fLibGSL->GetState() != kButtonDisabled )
3169  fStatusBar->SetText("LIB Genetics", 1);
3170  }
3171  }
3172  default:
3173  break;
3174  }
3176 }
3177 
3178 ////////////////////////////////////////////////////////////////////////////////
3179 /// Set selected minimization method in use.
3180 
3182 {
3184  fStatusBar->SetText("MIGRAD",2);
3185  else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3186  fStatusBar->SetText("FUMILI",2);
3187  else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3188  fStatusBar->SetText("SIMPLEX",2);
3189  else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3190  fStatusBar->SetText("SCAN",2);
3191  else if ( fMinMethodList->GetSelected() == kFP_COMBINATION )
3192  fStatusBar->SetText("Combination",2);
3193  else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3194  fStatusBar->SetText("CONJFR",2);
3195  else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3196  fStatusBar->SetText("CONJPR",2);
3197  else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3198  fStatusBar->SetText("BFGS",2);
3199  else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3200  fStatusBar->SetText("BFGS2",2);
3201  else if ( fMinMethodList->GetSelected() == kFP_GSLLM )
3202  fStatusBar->SetText("GSLLM",2);
3203  else if ( fMinMethodList->GetSelected() == kFP_GSLSA)
3204  fStatusBar->SetText("SimAn",2);
3205  else if ( fMinMethodList->GetSelected() == kFP_TMVAGA )
3206  fStatusBar->SetText("TMVAGA",2);
3207  else if ( fMinMethodList->GetSelected() == kFP_GALIB )
3208  fStatusBar->SetText("GALIB",2);
3209 
3210 
3211 }
3212 
3213 ////////////////////////////////////////////////////////////////////////////////
3214 /// Set the maximum number of iterations.
3215 
3217 {
3218  Long_t itr = fIterations->GetIntNumber();
3219  fStatusBar->SetText(Form("Itr: %ld",itr),2);
3220 }
3221 
3222 ////////////////////////////////////////////////////////////////////////////////
3223 /// Create section title in the GUI.
3224 
3225 void TFitEditor::MakeTitle(TGCompositeFrame *parent, const char *title)
3226 {
3227  TGCompositeFrame *ht = new TGCompositeFrame(parent, 350, 10,
3229  ht->AddFrame(new TGLabel(ht, title),
3230  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
3231  ht->AddFrame(new TGHorizontal3DLine(ht),
3232  new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 5, 5, 2, 2));
3233  parent->AddFrame(ht, new TGLayoutHints(kLHintsTop, 5, 0, 5, 0));
3234 }
3235 
3236 ////////////////////////////////////////////////////////////////////////////////
3237 /// Look in the list of function for TF1. If a TF1 is
3238 /// found in the list of functions, it will be returned
3239 
3241 {
3242  // Get the list of functions of the fit object
3244  TF1* func = 0;
3245 
3246  // If it exists
3247  if ( lf ) {
3248  // Add the posibility to select previous fit function
3249  if ( !fTypeFit->FindEntry("Prev. Fit") )
3250  fTypeFit->InsertEntry("Prev. Fit",kFP_PREVFIT, kFP_UFUNC);
3251 
3252  // Then add all these functions to the fPrefFit structure.
3253  TObject *obj2;
3254  TIter next(lf, kIterForward);
3255  // Go over all the elements in lf
3256  while ((obj2 = next())) {
3257  if (obj2->InheritsFrom(TF1::Class())) {
3258  func = (TF1 *)obj2;
3259  fPrevFitIter it;
3260  // No go over all elements in fPrevFit
3261  for ( it = fPrevFit.begin(); it != fPrevFit.end(); ++it) {
3262  // To see wheather the object corresponds with fFitObject
3263  if ( it->first != fFitObject ) continue;
3264  // And if so, whether the function is already included
3265  if ( strcmp( func->GetName(), it->second->GetName() ) == 0 )
3266  break;
3267  if ( strcmp( func->GetName(), "PrevFitTMP" ) == 0 )
3268  break;
3269  }
3270  // Only if the function is not already in fPrevFit, the
3271  // breaks in the loops would make it to be different to
3272  // fPrevFit.end() if the function is already stored
3273  if ( it == fPrevFit.end() ) {
3274  fPrevFit.insert( FitFuncMap_t::value_type( fFitObject, static_cast<TF1*>( copyTF1( func ) ) ) );
3275  }
3276  }
3277  }
3278 
3279  // Select the PrevFit set
3281  // And fill the function list
3282  FillFunctionList();
3284 
3285 
3286  } else {
3287  // If there is no prev fit functions.
3289  // Call FillFunctionList as it might happen that the user is
3290  // changing from a TTree to another one, and thus the fFuncList
3291  // if not properly filled
3292  FillFunctionList();
3293  }
3294 
3296 
3297  return func;
3298 }
3299 
3300 ////////////////////////////////////////////////////////////////////////////////
3301 /// Retrieve the fitting options from all the widgets.
3302 
3304 {
3305  drawOpts = "";
3306 
3307  fitOpts.Range = (fUseRange->GetState() == kButtonDown);
3308  fitOpts.Integral = (fIntegral->GetState() == kButtonDown);
3309  fitOpts.More = (fImproveResults->GetState() == kButtonDown);
3310  fitOpts.Errors = (fBestErrors->GetState() == kButtonDown);
3311  fitOpts.Like = (fMethodList->GetSelected() != kFP_MCHIS);
3312 
3314  fitOpts.W1 = 2;
3315  else if (fAllWeights1->GetState() == kButtonDown)
3316  fitOpts.W1 = 1;
3317 
3318  TString tmpStr = fEnteredFunc->GetText();
3319  if ( !(fLinearFit->GetState() == kButtonDown) &&
3320  (tmpStr.Contains("pol") || tmpStr.Contains("++")) )
3321  fitOpts.Minuit = 1;
3322 
3323  if ( (int) fFuncPars.size() == npar )
3324  for ( Int_t i = 0; i < npar; ++i )
3325  if ( fFuncPars[i][PAR_MIN] != fFuncPars[i][PAR_MAX] )
3326  {
3327  fitOpts.Bound = 1;
3328  break;
3329  }
3330 
3331  //fitOpts.Nochisq = (fNoChi2->GetState() == kButtonDown);
3332  fitOpts.Nostore = (fNoStoreDrawing->GetState() == kButtonDown);
3333  fitOpts.Nograph = (fNoDrawing->GetState() == kButtonDown);
3334  fitOpts.Plus = (fAdd2FuncList->GetState() == kButtonDown);
3335  fitOpts.Gradient = (fUseGradient->GetState() == kButtonDown);
3336  fitOpts.Quiet = ( fOptQuiet->GetState() == kButtonDown );
3337  fitOpts.Verbose = ( fOptVerbose->GetState() == kButtonDown );
3338 
3339  if ( !(fType != kObjectGraph) && (fEnableRobust->GetState() == kButtonDown) )
3340  {
3341  fitOpts.Robust = 1;
3342  fitOpts.hRobust = fRobustValue->GetNumber();
3343  }
3344 
3345  drawOpts = GetDrawOption();
3346 
3347  if ( fLibMinuit->GetState() == kButtonDown )
3348  minOpts.SetMinimizerType ( "Minuit");
3349  else if ( fLibMinuit2->GetState() == kButtonDown)
3350  minOpts.SetMinimizerType ( "Minuit2" );
3351  else if ( fLibFumili->GetState() == kButtonDown )
3352  minOpts.SetMinimizerType ("Fumili" );
3353  else if ( fLibGSL->GetState() == kButtonDown )
3354  minOpts.SetMinimizerType ("GSLMultiMin" );
3355 
3357  minOpts.SetMinimizerAlgorithm( "Migrad" );
3358  else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3359  if ( fLibMinuit2->GetState() == kButtonDown )
3360  minOpts.SetMinimizerAlgorithm( "Fumili2" );
3361  else
3362  minOpts.SetMinimizerAlgorithm( "Fumili" );
3363  else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3364  minOpts.SetMinimizerAlgorithm( "Simplex" );
3365  else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3366  minOpts.SetMinimizerAlgorithm( "Scan" );
3367  else if ( fMinMethodList->GetSelected() == kFP_COMBINATION )
3368  minOpts.SetMinimizerAlgorithm( "Minimize" );
3369  else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3370  minOpts.SetMinimizerAlgorithm( "conjugatefr" );
3371  else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3372  minOpts.SetMinimizerAlgorithm( "conjugatepr" );
3373  else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3374  minOpts.SetMinimizerAlgorithm( "bfgs" );
3375  else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3376  minOpts.SetMinimizerAlgorithm( "bfgs2" );
3377  else if ( fMinMethodList->GetSelected() == kFP_GSLLM ) {
3378  minOpts.SetMinimizerType ("GSLMultiFit" );
3379  minOpts.SetMinimizerAlgorithm( "" );
3380  } else if ( fMinMethodList->GetSelected() == kFP_GSLSA) {
3381  minOpts.SetMinimizerType ("GSLSimAn" );
3382  minOpts.SetMinimizerAlgorithm( "" );
3383  } else if ( fMinMethodList->GetSelected() == kFP_TMVAGA) {
3384  minOpts.SetMinimizerType ("Geneti2c" );
3385  minOpts.SetMinimizerAlgorithm( "" );
3386  } else if ( fMinMethodList->GetSelected() == kFP_GALIB) {
3387  minOpts.SetMinimizerType ("GAlibMin" );
3388  minOpts.SetMinimizerAlgorithm( "" );
3389  }
3390 
3391  minOpts.SetErrorDef ( fErrorScale->GetNumber() );
3392  minOpts.SetTolerance( fTolerance->GetNumber() );
3395 }
3396 
3398 {
3399  // Set the state of some input widgets depending on whether the fit
3400  // function can be defined by text or if it is an existing one.
3401  if ( state )
3402  {
3403  fEnteredFunc-> SetState(kTRUE);
3404  fAdd -> SetState(kButtonUp, kFALSE);
3405  fNormAdd -> SetState(kButtonUp, kFALSE);
3406  fConv -> SetState(kButtonUp, kFALSE);
3407  fNone -> SetState(kButtonDown,kFALSE); // fNone::State is the one used as reference
3408  }
3409  else
3410  {
3411  fEnteredFunc-> SetState(kFALSE);
3412  fAdd -> SetState(kButtonDisabled, kFALSE);
3413  fNormAdd -> SetState(kButtonDisabled, kFALSE);
3414  fConv -> SetState(kButtonDisabled, kFALSE);
3415  fNone -> SetState(kButtonDisabled, kFALSE);
3416  }
3417 }
3418 
3420 {
3421  // Return the ranges selected by the sliders.
3422 
3423  // It's not working for trees as they don't have TAxis.
3424  if ( fType == kObjectTree ) return;
3425 
3426  if ( fType != kObjectTree ) {
3427  Int_t ixmin = (Int_t)(fSliderX->GetMinPosition());
3428  Int_t ixmax = (Int_t)(fSliderX->GetMaxPosition());
3429  Double_t xmin = fXaxis->GetBinLowEdge(ixmin);
3430  Double_t xmax = fXaxis->GetBinUpEdge(ixmax);
3431  drange.AddRange(0,xmin, xmax);
3432  }
3433 
3434  if ( fDim > 1 ) {
3435  assert(fYaxis);
3436  Int_t iymin = (Int_t)(fSliderY->GetMinPosition());
3437  Int_t iymax = (Int_t)(fSliderY->GetMaxPosition());
3438  Double_t ymin = fYaxis->GetBinLowEdge(iymin);
3439  Double_t ymax = fYaxis->GetBinUpEdge(iymax);
3440  drange.AddRange(1,ymin, ymax);
3441  }
3442  if ( fDim > 2 ) {
3443  assert(fZaxis);
3444  Int_t izmin = (Int_t)(fSliderZ->GetMinPosition());
3445  Int_t izmax = (Int_t)(fSliderZ->GetMaxPosition());
3446  Double_t zmin = fZaxis->GetBinLowEdge(izmin);
3447  Double_t zmax = fZaxis->GetBinUpEdge(izmax);
3448  drange.AddRange(2,zmin, zmax);
3449  }
3450 }
3451 
3453 {
3454  // Get the list of functions previously used in the fitobject.
3455 
3456  TList *listOfFunctions = 0;
3457  if ( fFitObject ) {
3458  switch (fType) {
3459 
3460  case kObjectHisto:
3461  listOfFunctions = ((TH1 *)fFitObject)->GetListOfFunctions();
3462  break;
3463 
3464  case kObjectGraph:
3465  listOfFunctions = ((TGraph *)fFitObject)->GetListOfFunctions();
3466  break;
3467 
3468  case kObjectMultiGraph:
3469  listOfFunctions = ((TMultiGraph *)fFitObject)->GetListOfFunctions();
3470  break;
3471 
3472  case kObjectGraph2D:
3473  listOfFunctions = ((TGraph2D *)fFitObject)->GetListOfFunctions();
3474  break;
3475 
3476  case kObjectHStack:
3477  case kObjectTree:
3478  default:
3479  break;
3480  }
3481  }
3482  return listOfFunctions;
3483 }
3484 
3486 {
3487  // Looks for all the functions registered in the current ROOT
3488  // session.
3489 
3490  // First, clean the copies stored in fSystemFunc
3491  for ( fSystemFuncIter it = fSystemFuncs.begin();
3492  it != fSystemFuncs.end();
3493  ++it ) {
3494  delete (*it);
3495  }
3496 
3497  fSystemFuncs.clear();
3498 
3499  // Be carefull not to store functions that will be in the
3500  // predefined section
3501  const unsigned int nfuncs = 16;
3502  const char* fnames[nfuncs] = { "gaus" , "gausn", "expo", "landau",
3503  "landaun", "pol0", "pol1", "pol2",
3504  "pol3", "pol4", "pol5", "pol6",
3505  "pol7", "pol8", "pol9", "user"
3506  };
3507 
3508  // No go through all the objects registered in gROOT
3509  TIter functionsIter(gROOT->GetListOfFunctions());
3510  TObject* obj;
3511  while( ( obj = (TObject*) functionsIter() ) ) {
3512  // And if they are TF1s
3513  if ( TF1* func = dynamic_cast<TF1*>(obj) ) {
3514  bool addFunction = true;
3515  // And they are not already registered in fSystemFunc
3516  for ( unsigned int i = 0; i < nfuncs; ++i ) {
3517  if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3518  addFunction = false;
3519  break;
3520  }
3521  }
3522  // Add them.
3523  if ( addFunction )
3524  fSystemFuncs.push_back( copyTF1(func) );
3525  }
3526  }
3527 }
3528 
3530 {
3531  // This function returns a TList with all the functions used in the
3532  // FitPanel to fit a given object. If the object passed is NULL,
3533  // then the object used is the currently selected one. It is
3534  // important to notice that the FitPanel is still the owner of
3535  // those functions. This means that the user SHOULD NOT delete any
3536  // of these functions, as the FitPanel will do so in the
3537  // destructor.
3538 
3539  if (!obj) obj = fFitObject;
3540 
3541  TList *retList = new TList();
3542 
3543  std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(obj);
3544  for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
3545  retList->Add(it->second);
3546  }
3547 
3548  return retList;
3549 }
3550 
3552 {
3553  // Get the fit function selected or declared in the fiteditor
3554 
3555  TF1 *fitFunc = 0;
3556  // If the function is not editable ==> it means it is registered in
3557  // gROOT
3558  if ( fNone->GetState() == kButtonDisabled )
3559  {
3560  // So we find it
3561  TF1* tmpF1 = FindFunction();
3562  // And if we don't find it, then it means there is something wrong!
3563  if ( tmpF1 == 0 )
3564  {
3566  "Error...", "1) Verify the entered function string!",
3567  kMBIconStop,kMBOk, 0);
3568  return 0;
3569  }
3570 
3571  // Now we make a copy that will be used temporary. The caller of
3572  // the function should delete the returned function.
3573  fitFunc = (TF1*)tmpF1->IsA()->New();
3574  tmpF1->Copy(*fitFunc);
3575  // Copy the parameters of the function, if and only if the
3576  // parameters stored does not correspond with the ones of these
3577  // functions. Perhaps the user has already called
3578  // DoSetParameters. There is no way to know whether the
3579  // parameters have been modified, so we check the size of
3580  // fFuncPars against number of parameters.
3581  if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3582  {
3583  fitFunc->SetParameters(tmpF1->GetParameters());
3584  GetParameters(fFuncPars, fitFunc);
3585  } else {
3586  SetParameters(fFuncPars, fitFunc);
3587  }
3588  }
3589 
3590  // If, we have no function at this point, it means that is is
3591  // described in fEnteredFunc, so we create it from scratch.
3592  if ( fitFunc == 0 )
3593  {
3594  ROOT::Fit::DataRange drange;
3595  GetRanges(drange);
3596  double xmin, xmax, ymin, ymax, zmin, zmax;
3597  drange.GetRange(xmin, xmax, ymin, ymax, zmin, zmax);
3598 
3599  // Depending of course on the number of dimensions the object
3600  // has. These commands will raise an error message if the user
3601  // has not defined the function properly
3602  if ( fDim == 1 || fDim == 0 )
3603  {
3604  fitFunc = new TF1("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax );
3605  if (fNormAdd->IsOn())
3606  {
3607  if (fSumFunc) delete fSumFunc;
3609  fitFunc = new TF1("PrevFitTMP", *fSumFunc, xmin, xmax, fSumFunc->GetNpar());
3610  for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fSumFunc->GetParName(i) );
3611  //std::cout << "create fit normalized function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3612  }
3613 
3614  if (fConv -> IsOn())
3615  {
3616  if (fConvFunc) delete fConvFunc;
3618  fitFunc = new TF1("PrevFitTMP", *fConvFunc, xmin, xmax, fConvFunc->GetNpar());
3619  for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fConvFunc->GetParName(i) );
3620  //std::cout << "create fit convolution function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3621  }
3622  }
3623  else if ( fDim == 2 ) {
3624  fitFunc = new TF2("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax );
3625  }
3626  else if ( fDim == 3 ) {
3627  fitFunc = new TF3("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax, zmin, zmax );
3628  }
3629 
3630  // if the function is not a C defined
3631  if ( fNone->GetState() != kButtonDisabled )
3632  {
3633  // and the formulas are the same
3634  TF1* tmpF1 = FindFunction();
3635  if ( tmpF1 != 0 && fitFunc != 0 &&
3636  strcmp(tmpF1->GetExpFormula(), fEnteredFunc->GetText()) == 0 ) {
3637  // copy the parameters!
3638  if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3639  {
3640  fitFunc->SetParameters(tmpF1->GetParameters());
3641  GetParameters(fFuncPars, fitFunc);
3642  } else
3643  SetParameters(fFuncPars, fitFunc);
3644  }
3645  }
3646  }
3647 
3648  return fitFunc;
3649 }
virtual void SetFunction(const char *function)
Set the function to be used in performed fit.
virtual void DoFunction(Int_t sel)
Slot connected to predefined fit function settings.
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
TGCheckButton * fEnableRobust
Definition: TFitEditor.h:119
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:429
virtual Int_t GetNumberOfEntries() const
Definition: TGListBox.h:339
virtual void SetFitObject(TVirtualPad *pad, TObject *obj, Int_t event)
Slot called when the user clicks on an object inside a canvas.
virtual void DoSetParameters()
Open set parameters dialog.
std::multimap< TObject *, TF1 * > fPrevFit
Definition: TFitEditor.h:144
TGLayoutHints * fLayoutAdd
Definition: TFitEditor.h:90
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGDoubleHSlider * fSliderX
Definition: TFitEditor.h:109
TGTextButton * fDrawAdvanced
Definition: TFitEditor.h:108
virtual void DoSliderZMoved()
Slot connected to range settings on z-axis.
int Errors
Definition: Foption.h:37
virtual Double_t GetUxmin() const =0
virtual void DoNoChi2()
Slot connected to 'no chi2' option settings.
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:439
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition: TCanvas.cxx:1503
TGComboBox * fDataSet
Definition: TFitEditor.h:80
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
float xmin
Definition: THbookFile.cxx:93
TGCheckButton * fUseRange
Definition: TFitEditor.h:96
void InitParameters(TF1 *func, FitObject *fitobj)
Parameter initialization for the function.
Definition: TFitEditor.cxx:302
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
virtual Double_t * GetVal(Int_t i) const
Return the last values corresponding to the i-th component of the formula being processed (where the ...
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:1851
TGCheckButton * fNoDrawing
Definition: TFitEditor.h:106
long long Long64_t
Definition: RtypesCore.h:69
TGComboBox * BuildMethodList(TGFrame *parent, Int_t id)
Create method list in a combo box.
const Double_t * v1
Definition: TArcBall.cxx:33
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
TGLayoutHints * fLayoutConv
Definition: TFitEditor.h:92
The Histogram stack class.
Definition: THStack.h:35
void SetTolerance(double tol)
set the tolerance
Int_t fDim
Definition: TFitEditor.h:127
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
virtual void ReturnPressed()
Return was pressed.
TGNumberEntryField * fIterations
Definition: TFitEditor.h:155
void SetMinimizerType(const char *type)
set minimizer type
TGRadioButton * fLibGenetics
Definition: TFitEditor.h:151
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
virtual void DoMaxIterations()
Set the maximum number of iterations.
const TGWindow * GetParent() const
Definition: TGWindow.h:87
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Definition: TGTab.h:66
Ssiz_t Length() const
Definition: TString.h:390
TF1 * HasFitFunction()
Look in the list of function for TF1.
virtual void DoAllWeights1()
Slot connected to 'set all weights to 1' setting.
void RetrieveOptions(Foption_t &, TString &, ROOT::Math::MinimizerOptions &, Int_t)
Retrieve the fitting options from all the widgets.
void variables(TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
Definition: variables.cxx:10
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
float ymin
Definition: THbookFile.cxx:93
virtual Bool_t IsOn() const
Definition: TGButton.h:374
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
R__EXTERN void * gTQSender
Definition: TQObject.h:49
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
void FillDataSetList()
Create a combo box with all the possible objects to be fitted.
#define assert(cond)
Definition: unittest.h:542
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual Long64_t GetSelectedRows() const
Definition: TTreePlayer.h:89
virtual Int_t GetDimension() const
Definition: TH1.h:283
void ProcessTreeInput(TObject *objSelected, Int_t selected, TString variables, TString cuts)
virtual void Update()=0
int Verbose
Definition: Foption.h:30
#define gDirectory
Definition: TDirectory.h:218
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
TH1 * h
Definition: legend2.C:5
TF1NormSum * fSumFunc
Definition: TFitEditor.h:131
UInt_t GetWidth() const
Definition: TGFrame.h:287
TGLayoutHints * fLayoutNone
Definition: TFitEditor.h:89
TFitEditor(const TFitEditor &)
virtual void SetIntNumber(Long_t val)
Set the numeric value (integer representation).
virtual void DoAddition(Bool_t on)
Slot connected to addition of predefined functions.
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition: TMultiGraph.h:37
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF1.cxx:3223
virtual void SetNumber(Double_t val)
TGCheckButton * fNoStoreDrawing
Definition: TFitEditor.h:105
TGNumberEntry * fSliderXMin
Definition: TFitEditor.h:111
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.
Definition: TF1.cxx:2853
TGRadioButton * fOptQuiet
Definition: TFitEditor.h:123
TPluginHandler * FindHandler(const char *base, const char *uri=0)
Returns the handler if there exists a handler for the specified URI.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:489
double fitFunc(double *x, double *p)
#define R__ASSERT(e)
Definition: TError.h:98
TGCheckButton * fAllWeights1
Definition: TFitEditor.h:99
#define gROOT
Definition: TROOT.h:340
std::multimap< TObject *, TF1 * >::iterator fPrevFitIter
Definition: CommonDefs.h:1
Int_t GetNpar() const
TGNumberEntry * fSliderYMax
Definition: TFitEditor.h:113
Basic string class.
Definition: TString.h:137
TGCompositeFrame * fGeneral
Definition: TFitEditor.h:73
#define gClient
Definition: TGClient.h:174
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
Definition: TGComboBox.h:114
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
Definition: UnBinData.h:47
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:129
virtual void DoLibrary(Bool_t on)
Set selected minimization library in use.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF1.cxx:1075
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
virtual void SetLimits(ELimit limits=TGNumberFormat::kNELNoLimits, Double_t min=0, Double_t max=1)
TGTextButton * fSetParam
Definition: TFitEditor.h:93
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:496
TGCheckButton * fImproveResults
Definition: TFitEditor.h:100
TGCheckButton * fIntegral
Definition: TFitEditor.h:94
UInt_t GetDisplayWidth() const
Get display width.
Definition: TGClient.cxx:260
virtual void SetRange(Float_t min, Float_t max)
virtual void Hide()
Hide the fit panel and set it to non-active state.
UInt_t GetHeight() const
Definition: TGFrame.h:288
void SetErrorDef(double err)
set error def
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:137
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition: TTree.cxx:5653
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition: TGFrame.cxx:1759
int Nograph
Definition: Foption.h:42
TGRadioButton * fLibMinuit2
Definition: TFitEditor.h:148
int Minuit
Definition: Foption.h:46
TGStatusBar * fStatusBar
Definition: TFitEditor.h:157
TGLabel * fSelLabel
Definition: TFitEditor.h:79
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TGRadioButton * fConv
Definition: TFitEditor.h:88
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
int Nostore
Definition: Foption.h:41
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual const char * GetTitle() const
Returns title of object.
Definition: TGListBox.h:125
Iterator of linked list.
Definition: TList.h:187
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set radio button state.
Definition: TGButton.cxx:1563
void ShowObjectName(TObject *obj)
Show object name on the top.
TGHorizontalFrame * fSliderXParent
Definition: TFitEditor.h:116
virtual void DisconnectSlots()
Disconnect GUI signals from fit panel slots.
virtual void SetCanvas(TCanvas *c)
Connect to another canvas.
TGNumberEntry * fSliderYMin
Definition: TFitEditor.h:114
TFitResultPtr UnBinFit(ROOT::Fit::UnBinData *data, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption)
fit an unbin data set (from tree or from histogram buffer) using a TF1 pointer and fit options...
Definition: HFitImpl.cxx:783
const char * Data() const
Definition: TString.h:349
void CreateGeneralTab()
Create 'General' tab.
Definition: TFitEditor.cxx:659
double hRobust
Definition: Foption.h:51
virtual void SelectAll()
Selects all text (i.e.
TGTextButton * fResetButton
Definition: TFitEditor.h:77
virtual void SetParent(TObject *p=0)
Definition: TF1.h:458
Class wrapping convolution of two functions.
Sequenceable collection abstract base class.
virtual void DoReset()
Reset all fit parameters.
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function.
Definition: TFitEditor.cxx:287
virtual Bool_t IsValid() const
Return kTRUE if the function is valid.
Definition: TF1.cxx:2609
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition: TCanvas.cxx:1123
TGNumberEntryField * GetNumberEntry() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2334
ULong_t Pixel_t
Definition: GuiTypes.h:41
TGRadioButton * fLibGSL
Definition: TFitEditor.h:150
virtual TString GetExpFormula(Option_t *option="") const
Definition: TF1.h:341
void Class()
Definition: Class.C:29
virtual void ConnectSlots()
Connect GUI signals to fit panel slots.
virtual UInt_t GetOptions() const
Definition: TGFrame.h:260
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition: TGFrame.cxx:1862
TAxis * fXaxis
Definition: TFitEditor.h:128
const char * GetText() const
Definition: TGTextEntry.h:140
const char * GetParName(Int_t ipar) const
Definition: TF1NormSum.h:70
Int_t CheckFunctionString(const char *str)
Check entered function string.
int Plus
Definition: Foption.h:43
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
Definition: TF1.cxx:759
TGCheckButton * fLinearFit
Definition: TFitEditor.h:103
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
TGCompositeFrame(const TGCompositeFrame &)
TGCheckButton * fNoChi2
Definition: TFitEditor.h:104
virtual void DoMinMethod(Int_t)
Set selected minimization method in use.
if(pyself &&pyself!=Py_None)
virtual void DoNoStoreDrawing()
Slot connected to 'no storing, no drawing' settings.
TString & Append(const char *cs)
Definition: TString.h:492
virtual Option_t * GetOption() const
Definition: TObject.h:129
const Bool_t kIterForward
Definition: TCollection.h:43
TGTextEntry * fEnteredFunc
Definition: TFitEditor.h:83
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
TF1 * GetFitFunction()
TF1 * copyTF1(TF1 *f)
Copies f into a new TF1 to be stored in the fitpanel with it's own ownership.
Definition: TFitEditor.cxx:230
std::vector< TF1 * >::iterator fSystemFuncIter
Definition: CommonDefs.h:2
virtual void DoNumericSliderXChanged()
Sincronize the numeric sliders with the graphical one.
TGRadioButton * fNormAdd
Definition: TFitEditor.h:87
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
Definition: TF1.cxx:1976
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
TH1F * h1
Definition: legend1.C:5
TGComboBox * fFuncList
Definition: TFitEditor.h:82
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
virtual void RemoveAll()
Remove all entries from combo box.
Definition: TGComboBox.cxx:672
UInt_t fHeight
Definition: TGDimension.h:32
TGTextButton * fFitButton
Definition: TFitEditor.h:76
virtual void DoPrintOpt(Bool_t on)
Slot connected to print option settings.
virtual void DoAdvancedOptions()
Slot connected to advanced option button (opens a dialog).
R__EXTERN TPluginManager * gPluginMgr
void MakeTitle(TGCompositeFrame *parent, const char *title)
Create section title in the GUI.
virtual void DoUpdate()
Easy here!
void UpdateGUI()
Set the fit panel GUI according to the selected object.
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition: TF1.cxx:1641
A doubly linked list.
Definition: TList.h:47
virtual Double_t GetUymax() const =0
virtual Int_t GetSelected() const
Definition: TGComboBox.h:136
TSelector * GetSelector() const
Definition: TTreePlayer.h:90
virtual Int_t GetDimension() const
Definition: TTreePlayer.h:82
Int_t GetNpar() const
Definition: TF1NormSum.cxx:362
virtual Double_t GetUymin() const =0
virtual void DoConvolution(Bool_t on)
Slot connected to addition of predefined functions.
virtual void Show(TVirtualPad *pad, TObject *obj)
Show the fit panel (possible only via context menu).
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1135
virtual void Terminate()
Called to delete the fit panel.
virtual void DoUserDialog()
Open a dialog for getting a user defined method.
virtual void DoNormAddition(Bool_t on)
Slot connected to addition of predefined functions.
void InitGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for gaussian function given the fit data Set the sigma limits for zero top ...
float ymax
Definition: THbookFile.cxx:93
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
Definition: TF1.cxx:3206
UInt_t fWidth
Definition: TGDimension.h:31
TList * GetFitObjectListOfFunctions()
void FillData(BinData &dv, const TH1 *hist, TF1 *func=0)
fill the data vector from a TH1.
Int_t GetNpar() const
Definition: TFormula.h:175
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
TGTextButton * fCloseButton
Definition: TFitEditor.h:78
virtual void RecursiveRemove(TObject *obj)
When obj is deleted, clear fFitObject if fFitObject = obj.
static const std::string & DefaultMinimizerType()
virtual void GetPosition(Float_t &min, Float_t &max) const
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGComboBox.cxx:414
Int_t EntryId() const
Definition: TGListBox.h:76
SVector< double, 2 > v
Definition: Dict.h:5
virtual EButtonState GetState() const
Definition: TGButton.h:116
TAxis * fZaxis
Definition: TFitEditor.h:130
Int_t GetNbins() const
Definition: TAxis.h:125
TF1 * FindFunction()
This method looks among the functions stored by the fitpanel, the one that is currently selected in t...
Definition: TFitEditor.cxx:188
virtual Int_t XtoAbsPixel(Double_t x) const =0
A 3-Dim function with parameters.
Definition: TF3.h:30
leg AddEntry(h1,"Histogram filled with random numbers","f")
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:499
TGCompositeFrame * fMinimization
Definition: TFitEditor.h:74
TGDoubleHSlider * fSliderY
Definition: TFitEditor.h:112
int Gradient
Definition: Foption.h:40
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
TGComboBox * fMinMethodList
Definition: TFitEditor.h:152
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
The F O R M U L A class.
Definition: TFormula.h:89
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition: TGTab.cxx:341
TGNumberEntryField * fTolerance
Definition: TFitEditor.h:154
TGCheckButton * fDrawSame
Definition: TFitEditor.h:107
Bool_t SetObjectType(TObject *obj)
Check whether the object suitable for fitting and set its type, dimension and method combo box accord...
unsigned int UInt_t
Definition: RtypesCore.h:42
The most important graphics class in the ROOT system.
Definition: TPad.h:46
virtual Int_t GetNdim() const
Definition: TF1.h:350
char * Form(const char *fmt,...)
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:132
TGDoubleHSlider * fSliderZ
Definition: TFitEditor.h:115
TList * GetListOfFittingFunctions(TObject *obj=0)
virtual void DoUseFuncRange()
int More
Definition: Foption.h:38
virtual void DoClose()
Close the fit panel.
virtual void DoSliderXMoved()
Slot connected to range settings on x-axis.
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
TVirtualPad * fParentPad
Definition: TFitEditor.h:124
void GetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Stores the parameters of the given function into pars.
Definition: TFitEditor.cxx:270
TLine * l
Definition: textangle.C:4
Class adding two functions: c1*f1+c2*f2.
Definition: TF1NormSum.h:26
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual void DoNumericSliderYChanged()
syncronize the numeric slider with the graphical one.
void GetRanges(ROOT::Fit::DataRange &)
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
int Like
Definition: Foption.h:34
TAxis * GetYaxis()
Definition: TH1.h:320
int Integral
Definition: Foption.h:44
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Definition: BinData.h:61
virtual TList * GetListOfPrimitives() const =0
float xmax
Definition: THbookFile.cxx:93
TGRadioButton * fLibFumili
Definition: TFitEditor.h:149
virtual const char * GetTitle() const
Returns title of object.
Definition: TGTextEntry.h:142
TF1Convolution * fConvFunc
TF1NormSum object.
Definition: TFitEditor.h:132
A 2-Dim function with parameters.
Definition: TF2.h:33
TGCheckButton * fBestErrors
Definition: TFitEditor.h:95
virtual Double_t GetUxmax() const =0
std::vector< FuncParamData_t > FuncParams_t
Definition: TFitEditor.h:251
Long64_t entry
void DrawSelection(bool restore=false)
Draws the square around the object showing where the limits for fitting are.
TGComboBox * fMethodList
Definition: TFitEditor.h:102
TGraphErrors * gr
Definition: legend1.C:25
#define gVirtualX
Definition: TVirtualX.h:362
UInt_t GetWindowWidth() const
Definition: TCanvas.h:184
int W1
Definition: Foption.h:36
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
TGTextButton * fUserButton
Definition: TFitEditor.h:84
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition: TCanvas.cxx:1112
virtual void DoDataSet(Int_t sel)
Selects the data set to be fitted.
virtual void DoRobustFit()
Slot connected to 'robust fitting' option settings.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:264
virtual Int_t YtoAbsPixel(Double_t y) const =0
virtual void DoEnteredFunction()
Slot connected to entered function in text entry.
Int_t WidgetId() const
Definition: TGWidget.h:86
long Long_t
Definition: RtypesCore.h:50
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...
Definition: DataRange.cxx:94
virtual void Modified(Bool_t flag=1)=0
The Canvas class.
Definition: TCanvas.h:48
int Robust
Definition: Foption.h:48
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF2.h:154
int Range
Definition: Foption.h:39
void GetTreeVarsAndCuts(TGComboBox *dataSet, TString &variablesStr, TString &cutsStr)
Splits the entry in fDataSet to get the selected variables and cuts from the text.
Definition: TFitEditor.cxx:321
TGCompositeFrame * fTabContainer
Definition: TFitEditor.h:72
#define ClassImp(name)
Definition: Rtypes.h:279
TObject * fFitObject
Definition: TFitEditor.h:125
const char * GetParName(Int_t ipar) const
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition: DataRange.h:34
double f(double x)
TGNumberEntry * fSliderXMax
Definition: TFitEditor.h:110
void SearchCanvases(TSeqCollection *canvases, std::vector< TObject * > &objects)
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
void Init2DGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for 2D gaussian function given the fit data Set the sigma limits for zero t...
TGTab * fTab
Definition: TFitEditor.h:71
double Double_t
Definition: RtypesCore.h:55
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:108
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
void GetFunctionsFromSystem()
std::vector< TF1 * > fSystemFuncs
Definition: TFitEditor.h:145
const double * Coords(unsigned int ipoint) const
return pointer to coordinate data
Definition: UnBinData.h:282
void CreateFunctionGroup()
Creates the Frame that contains oll the information about the function.
Definition: TFitEditor.cxx:543
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
TGComboBox * fTypeFit
Definition: TFitEditor.h:81
TGCheckButton * fUseGradient
Definition: TFitEditor.h:98
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTree.h:356
TGRadioButton * fAdd
Definition: TFitEditor.h:86
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
std::multimap< TObject *, TF1 * > FitFuncMap_t
Definition: TFitEditor.cxx:182
double func(double *x, double *p)
Definition: stressTF1.cxx:213
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
The TH1 histogram class.
Definition: TH1.h:80
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1293
TGLayoutHints * fLayoutNormAdd
Definition: TFitEditor.h:91
TGTextButton * fUpdateButton
Definition: TFitEditor.h:75
virtual void DoSliderYMoved()
Slot connected to range settings on y-axis.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
TGCheckButton * fAdd2FuncList
Definition: TFitEditor.h:97
std::vector< FuncParamData_t > fFuncPars
Definition: TFitEditor.h:142
virtual Int_t GetNumber() const
Definition: TF1.h:354
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
int Bound
Definition: Foption.h:31
#define name(a, b)
Definition: linkTestLib0.cpp:5
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:440
TAxis * GetZaxis()
Definition: TH1.h:321
virtual Double_t GetParameter(Int_t ipar) const
Definition: TF1.h:359
void FillFunctionList(Int_t selected=-1)
Fills the list of functions depending on the type of fit selected.
Mother of all ROOT objects.
Definition: TObject.h:58
TGNumberEntryField * fErrorScale
Definition: TFitEditor.h:153
virtual Double_t * GetParameters() const
Definition: TF1.h:365
TAxis * fYaxis
Definition: TFitEditor.h:129
TGRadioButton * fOptVerbose
Definition: TFitEditor.h:122
virtual void UnmapWindow()
Definition: TGFrame.h:269
virtual void DoFit()
Perform a fit with current parameters' settings.
TList * GetListOfPrimitives() const
Definition: TPad.h:240
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition: TGFrame.cxx:1837
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
virtual void DoLinearFit()
Slot connected to linear fit settings.
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
virtual void DoEmptyBinsAllWeights1()
Slot connected to 'include emtry bins and forse all weights to 1' setting.
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF3.h:145
virtual void Add(TObject *obj)
Definition: TList.h:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
virtual void MapWindow()
Definition: TGFrame.h:267
TGClient * fClient
Definition: TGObject.h:41
virtual Bool_t AddToGlobalList(Bool_t on=kTRUE)
Add to global list of functions (gROOT->GetListOfFunctions() ) return previous status (true if the fu...
Definition: TF1.cxx:649
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
1-Dim function class
Definition: TF1.h:149
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
void FillMinMethodList(Int_t selected=-1)
Fills the list of methods depending on the minimization library selected.
virtual void SetPosition(Float_t min, Float_t max)
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition: TGFrame.cxx:1849
#define NULL
Definition: Rtypes.h:82
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition: TString.cxx:1297
TGRadioButton * fOptDefault
Definition: TFitEditor.h:121
#define gPad
Definition: TVirtualPad.h:288
virtual Float_t GetMinPosition() const
virtual void SetScale(Int_t scale)
virtual void SetParts(Int_t npart)
Divide the status bar in npart equal sized parts.
unsigned int Size() const
return number of contained points
Definition: UnBinData.h:316
void CreateMinimizationTab()
Create 'Minimization' tab.
Definition: TFitEditor.cxx:898
virtual Double_t GetNumber() const
A TTree object has a header with a name and a title.
Definition: TTree.h:94
const char * GetString() const
Definition: TGString.h:44
virtual Float_t GetMaxPosition() const
virtual void DoNoSelection()
Slot called when users close a TCanvas or when the user select no object.
virtual void RemoveEntry(Int_t id=-1)
Remove entry. If id == -1, the currently selected entry is removed.
Definition: TGComboBox.cxx:505
virtual void CloseWindow()
Close fit panel window.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
static TFitEditor * fgFitDialog
Definition: TFitEditor.h:159
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:431
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)
Definition: HFitImpl.cxx:935
TGHorizontalFrame * fSliderZParent
Definition: TFitEditor.h:118
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
const TGString * GetText() const
Definition: TGListBox.h:123
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
virtual ~TFitEditor()
Fit editor destructor.
Definition: TFitEditor.cxx:514
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:43
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:50
int Quiet
Definition: Foption.h:29
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGRadioButton * fLibMinuit
Definition: TFitEditor.h:147
EObjectType fType
Definition: TFitEditor.h:126
const Bool_t kTRUE
Definition: Rtypes.h:91
TGHorizontalFrame * fSliderYParent
Definition: TFitEditor.h:117
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:459
TGNumberEntry * fRobustValue
Definition: TFitEditor.h:120
TObject * obj
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition: TGFrame.cxx:1824
void SetMinimizerAlgorithm(const char *type)
set minimizer algorithm
Handle_t GetId() const
Definition: TGObject.h:52
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
TGRadioButton * fNone
Definition: TFitEditor.h:85
void GetRange(unsigned int icoord, double &xmin, double &xmax) const
get the first range for given coordinate.
Definition: DataRange.h:103
TGCheckButton * fEmptyBinsWghts1
Definition: TFitEditor.h:101
virtual Int_t GetNpar() const
Definition: TF1.h:349
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:466
virtual TGLBEntry * GetEntry(Int_t id) const
Returns list box entry with specified id.
Definition: TGListBox.cxx:1380
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:385
TAxis * GetXaxis()
Definition: TH1.h:319
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition: TGFrame.cxx:1200
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.
Definition: TF2.cxx:751
void SetEditable(Bool_t)
Switch ON/OFF edit mode.
Definition: TGMsgBox.h:52
virtual TCanvas * GetCanvas() const =0
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185