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