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/** \class TFitEditor
14 \ingroup fitpanel
15
16
17Allows to perform, explore and compare various fits.
18
19To display the new Fit panel interface right click on a histogram
20or a graph to pop up the context menu and then select the menu
21entry 'Fit Panel'.
22
23"General" Tab
24
25The first set of GUI elements is related to the function choice
26and settings. The status bar on the bottom provides information
27about the current minimization settings using the following
28abbreviations:
29LIB - shows the current choice between Minuit/Minuit2/Fumili
30MIGRAD or FUMILI points to the current minimization method in use.
31Itr: - shows the maximum number of iterations nnnn set for the fit.
32Prn: - can be DEF/VER/QT and shows the current print option in use.
33
34"Predefined" combo box - contains a list of predefined functions
35in ROOT. The default one is Gaussian.
36
37"Operation" radio button group defines selected operational mode
38between functions: NOP - no operation (default); ADD - addition
39CONV - convolution (will be implemented in the future).
40
41Users can enter the function expression in a text entry field.
42The entered string is checked after Enter key was pressed. An
43error message shows up if the string is not accepted. The current
44prototype is limited and users have no freedom to enter file/user
45function 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
50fitter. Currently there are two method choices: Chi-square and
51Binned Likelihood.
52
53"Linear Fit" check button sets the use of Linear fitter is it is
54selected. 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
57calculate Chi-square (for Linear fitter).
58
59Fit options:
60"Integral" check button switch ON/OFF option 'I' - use integral
61of function instead of value in bin center.
62"Best Errors" sets ON/OFF option 'E' - better errors estimation
63using Minos technique.
64"All weights = 1" sets ON/OFF option 'W' - all weights set to 1,
65excluding empty bins and ignoring error bars.
66"Empty bins, weights=1" sets ON/OFF option 'WW' - all weights
67equal to 1, including empty bins, error bars ignored.
68"Use range" sets ON/OFF option 'R' - fit only data within the
69specified function range with the slider.
70"Improve fit results" sets ON/OFF option 'M' - after minimum is
71found, search for a new one.
72"Add to list" sets On/Off option '+'- add function to the list
73without deleting the previous.
74
75Draw 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
79function, do not draw it.
80
81Sliders settings are used if option 'R' - use range is active.
82Users can change min/max values by pressing the left mouse button
83near to the left/right slider edges. It is possible o change both
84values simultaneously by pressing the left mouse button near to its
85center and moving it to a new desire position.
86
87"Minimization" Tab
88
89"Library" group allows you to use Minuit, Minuit2 or Fumili
90minimization 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
105Print options:
106 "Default" - between Verbose and Quiet.
107 "Verbose" - prints results after each iteration.
108 "Quiet" - no fit information is printed.
109
110Fit button - performs a fit.
111Reset - resets all GUI elements and related fit settings to the
112default ones.
113Close - closes this window.
114
115*/
116
117
118#include "TFitEditor.h"
119#include "TROOT.h"
120#include "TClass.h"
121#include "TCanvas.h"
122#include "TGTab.h"
123#include "TGLabel.h"
124#include "TG3DLine.h"
125#include "TGComboBox.h"
126#include "TGTextEntry.h"
127#include "TGGC.h"
128#include "TGButtonGroup.h"
129#include "TGNumberEntry.h"
130#include "TGDoubleSlider.h"
131#include "TGStatusBar.h"
132#include "TFitParametersDialog.h"
133#include "TGMsgBox.h"
134#include "TAxis.h"
135#include "TGraph.h"
136#include "TGraph2D.h"
137#include "TH1.h"
138#include "TH2.h"
139#include "HFitInterface.h"
140#include "TF1.h"
141#include "TF1NormSum.h"
142#include "TF1Convolution.h"
143#include "TF2.h"
144#include "TF3.h"
145#include "THStack.h"
146#include "Fit/UnBinData.h"
147#include "Fit/BinData.h"
148#include "TMultiGraph.h"
149#include "TTree.h"
150#include "TVirtualTreePlayer.h"
151#include "TSelectorDraw.h"
152#include "TTreeInput.h"
154#include "TVirtualX.h"
155#include "strlcpy.h"
156
157#include "RConfigure.h"
158#include "TPluginManager.h"
159
160#include <vector>
161#include <queue>
162using std::vector;
163using std::pair;
164
165#include "CommonDefs.h"
166
167// #include <iostream>
168// using std::cout;
169// using std::endl;
170
171void SearchCanvases(TSeqCollection* canvases, std::vector<TObject*>& objects);
172
173typedef std::multimap<TObject*, TF1*> FitFuncMap_t;
174
175////////////////////////////////////////////////////////////////////////////////
176/// This method looks among the functions stored by the fitpanel, the
177/// one that is currently selected in the fFuncList
178
180{
181 // Get the title/name of the function from fFuncList
183 if ( !te ) return 0;
184 TString name(te->GetTitle());
185
186 // Look for a system function if it's USER DEFINED function
187 if ( fTypeFit->GetSelected() == kFP_UFUNC ) {
188 for (auto f : fSystemFuncs) {
189 if ( strcmp( f->GetName(), name ) == 0 )
190 // If found, return it.
191 return f;
192 }
193 // If we are looking for previously fitted functions, look in the
194 // fPrevFit data structure.
195 } else if ( fTypeFit->GetSelected() == kFP_PREVFIT ) {
196 std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(fFitObject);
197 for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
198 TF1* f = it->second;
199 if ( strcmp( f->GetName(), name ) == 0 )
200 // If found, return it
201 return f;
202 }
203 }
204
205 // Return a pointer to null if the function does not exist. This
206 // will eventually create a segmentation fault, but the line should
207 // never be executed.
208 return 0;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212///Copies f into a new TF1 to be stored in the fitpanel with it's
213///own ownership. This is taken from Fit::StoreAndDrawFitFunction in
214///HFitImpl.cxx
215
217{
218 double xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
219
220 // no need to use kNotGlobal bit. TF1::Copy does not add in the list by default
221 if ( dynamic_cast<TF3 *>(f) != 0 ) {
222 TF3* fnew = (TF3 *)f->IsA()->New();
223 f->Copy(*fnew);
224 f->GetRange(xmin,ymin,zmin,xmax,ymax,zmax);
225 fnew->SetRange(xmin,ymin,zmin,xmax,ymax,zmax);
226 fnew->SetParent( nullptr );
227 fnew->AddToGlobalList(false);
228 return fnew;
229 } else if ( dynamic_cast<TF2 *>(f) != 0 ) {
230 TF2* fnew = (TF2 *)f->IsA()->New();
231 f->Copy(*fnew);
232 f->GetRange(xmin,ymin,xmax,ymax);
233 fnew->SetRange(xmin,ymin,xmax,ymax);
234 fnew->Save(xmin,xmax,ymin,ymax,0,0);
235 fnew->SetParent( nullptr );
236 fnew->AddToGlobalList(false);
237 return fnew;
238 } else {
239 TF1* fnew = (TF1 *)f->IsA()->New();
240 f->Copy(*fnew);
241 f->GetRange(xmin,xmax);
242 fnew->SetRange(xmin,xmax);
243 // This next line is added, as fnew-Save fails with gausND! As
244 // the number of dimensions is unknown...
245 if ( '\0' != fnew->GetExpFormula()[0] )
246 fnew->Save(xmin,xmax,0,0,0,0);
247 fnew->SetParent( nullptr );
248 fnew->AddToGlobalList(false);
249 return fnew;
250 }
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Stores the parameters of the given function into pars
255
257{
258 int npar = func->GetNpar();
259 if (npar != (int) pars.size() ) pars.resize(npar);
260 for ( Int_t i = 0; i < npar; ++i )
261 {
263 pars[i][PAR_VAL] = func->GetParameter(i);
264 func->GetParLimits(i, par_min, par_max);
265 pars[i][PAR_MIN] = par_min;
266 pars[i][PAR_MAX] = par_max;
267 }
268}
269
270////////////////////////////////////////////////////////////////////////////////
271/// Restore the parameters from pars into the function
272
274{
275 int npar = func->GetNpar();
276 if (npar > (int) pars.size() ) pars.resize(npar);
277 for ( Int_t i = 0; i < npar; ++i )
278 {
279 func->SetParameter(i, pars[i][PAR_VAL]);
280 func->SetParLimits(i, pars[i][PAR_MIN], pars[i][PAR_MAX]);
281 }
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Parameter initialization for the function
286
287template<class FitObject>
288void InitParameters(TF1* func, FitObject * fitobj)
289{
290 const int special = func->GetNumber();
291 if (100 == special || 400 == special) {
295 // case gaussian or Landau
296 } else if ( 110 == special || 410 == special ) {
300 }
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Splits the entry in fDataSet to get the selected variables and cuts
305/// from the text.
306
308{
309 // Get the entry
311 static_cast<TGTextLBEntry*>( dataSet->GetListBox()->GetEntry( dataSet->GetSelected() ) );
312 if (!textEntry) return;
313 // Get the name of the tree
314 TString nameStr ( textEntry->GetText()->GetString() );
315 // Get the variables selected
316 variablesStr = nameStr(nameStr.First('(') + 2, nameStr.First(',') - nameStr.First('(') - 3);
317 // Get the cuts selected
318 cutsStr = nameStr( nameStr.First(',') + 3, nameStr.First(')') - nameStr.First(',') - 4 );
319}
320
321
322
324
325////////////////////////////////////////////////////////////////////////////////
326/// Static method - opens the fit panel.
327
329{
330 // Get the default pad if not provided.
331 if (!pad)
332 {
333 if (!gPad)
334 gROOT->MakeDefCanvas();
335 pad = gPad;
336 }
337
338 if (!fgFitDialog) {
339 fgFitDialog = new TFitEditor(pad, obj);
340 } else {
341 fgFitDialog->Show(pad, obj);
342 }
343 return fgFitDialog;
344}
345
346////////////////////////////////////////////////////////////////////////////////
347/// Constructor of fit editor. 'obj' is the object to be fitted and
348/// 'pad' where it is drawn.
349
351 TGMainFrame(gClient->GetRoot(), 20, 20),
352 fParentPad (0),
353 fFitObject (0),
354 fDim (0),
355 fXaxis (0),
356 fYaxis (0),
357 fZaxis (0),
358 fSumFunc (0),
359 fConvFunc (0),
360 fFuncPars (0),
361 fChangedParams (kFALSE)
362{
365
366 TGCompositeFrame *tf = new TGCompositeFrame(this, 350, 26,
368 TGLabel *label = new TGLabel(tf,"Data Set: ");
369 tf->AddFrame(label, new TGLayoutHints(kLHintsNormal, 15, 0, 5, 0));
370
373 fDataSet->Resize(264, 20);
374
375 tf->AddFrame(fDataSet, new TGLayoutHints(kLHintsNormal, 13, 0, 5, 0));
376 fDataSet->Associate(this);
377
378 this->AddFrame(tf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX,0,0,5,5));
379
381
382 fTab = new TGTab(this, 10, 10);
385 fTab->Associate(this);
386
387 TGHorizontalFrame *cf1 = new TGHorizontalFrame(this, 350, 20, kFixedWidth);
388 cf1->SetCleanup(kDeepCleanup);
389 fUpdateButton = new TGTextButton(cf1, "&Update", kFP_UPDATE);
392 kLHintsExpandX, 0, 20, 2, 2));
393
394
395 fFitButton = new TGTextButton(cf1, "&Fit", kFP_FIT);
396 fFitButton->Associate(this);
397 cf1->AddFrame(fFitButton, new TGLayoutHints(kLHintsTop |
398 kLHintsExpandX, 15, -6, 2, 2));
399
400 fResetButton = new TGTextButton(cf1, "&Reset", kFP_RESET);
401 fResetButton->Associate(this);
403 kLHintsExpandX, 11, -2, 2, 2));
404
405 fCloseButton = new TGTextButton(cf1, "&Close", kFP_CLOSE);
406 fCloseButton->Associate(this);
408 kLHintsExpandX, 7, 2, 2, 2));
410 kLHintsRight, 0, 5, 5, 5));
411
412 // Create status bar
413 int parts[] = { 20, 20, 20, 20, 20 };
414 fStatusBar = new TGStatusBar(this, 10, 10);
419
422
423 gROOT->GetListOfCleanups()->Add(this);
424
427
428 // do not allow resizing
430 SetWindowName("Fit Panel");
431 SetIconName("Fit Panel");
432 SetClassHints("ROOT", "Fit Panel");
433
439
440 ConnectSlots();
441
443
444 if (!obj) {
445 TList* l = new TList();
446 l->Add(pad);
447 std::vector<TObject*> v;
449 if ( v.size() )
450 obj = v[0];
451 delete l;
452 }
453
455
456 // In case we want to make it without a default canvas. This will
457 // be implemented after the 5.21/06 Release. Remember to take out
458 // any reference to the pad/canvas when the fitpanel is shown
459 // and/or built.
460
461 //SetCanvas(0 /*pad->GetCanvas()*/);
462
463 if ( pad ) {
464 SetCanvas(pad->GetCanvas());
465 if ( obj )
466 pad->GetCanvas()->Selected(pad, obj, kButton1Down);
467 }
468
470 UInt_t cw = 0;
471 UInt_t cx = 0;
472 UInt_t cy = 0;
473 if (pad && pad->GetCanvas() ) {
474 cw = pad->GetCanvas()->GetWindowWidth();
475 cx = (UInt_t)pad->GetCanvas()->GetWindowTopX();
476 cy = (UInt_t)pad->GetCanvas()->GetWindowTopY();
477 }
478
479 Resize(size);
480 MapWindow();
481
482 if (cw + size.fWidth < dw) {
483 Int_t gedx = 0, gedy = 0;
484 gedx = cx+cw+4;
485 gedy = (cy > 20) ? cy-20 : 0;
486 MoveResize(gedx, gedy, size.fWidth, size.fHeight);
488 }
489
490 gVirtualX->RaiseWindow(GetId());
491
493 SetWMSize(size.fWidth, size.fHeight);
494 SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
495}
496
497////////////////////////////////////////////////////////////////////////////////
498/// Fit editor destructor.
499
501{
503
504 // Disconnect all the slot that were no disconnected in DisconnecSlots
505 fCloseButton ->Disconnect("Clicked()");
506 fDataSet ->Disconnect("Selected(Int_t)");
507 fUpdateButton->Disconnect("Clicked()");
508 TQObject::Disconnect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
509 this, "SetFitObject(TVirtualPad *, TObject *, Int_t)");
510 gROOT->GetListOfCleanups()->Remove(this);
511
512 //Clean up the members that are not automatically cleaned.
513 Cleanup();
514 delete fLayoutNone;
515 delete fLayoutAdd;
516 delete fLayoutConv;
517
518 if (fConvFunc) delete fConvFunc;
519 if (fSumFunc) delete fSumFunc;
520
521 // release memory used by stored functions of previous fits
522 for (auto &entry : fPrevFit)
523 delete entry.second;
524 fPrevFit.clear();
525
526 // release memory used by copies of system functions
527 for (auto func : fSystemFuncs)
528 delete func;
529 fSystemFuncs.clear();
530
531 // Set the singleton reference to null
532 fgFitDialog = 0;
533}
534
535////////////////////////////////////////////////////////////////////////////////
536/// Creates the Frame that contains oll the information about the
537/// function.
538
540{
541 TGGroupFrame *gf1 = new TGGroupFrame(this, "Fit Function", kFitWidth);
543 TGLabel *label1 = new TGLabel(tf0,"Type:");
544 tf0 -> AddFrame(label1, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
545
547 fTypeFit -> AddEntry("User Func", kFP_UFUNC);
548 fTypeFit -> AddEntry("Predef-1D", kFP_PRED1D);
549 fTypeFit -> Resize(90, 20);
550 fTypeFit -> Select(kFP_PRED1D, kFALSE);
551
553 lb->Resize(lb->GetWidth(), 200);
554 tf0->AddFrame(fTypeFit, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0));
555 fTypeFit->Associate(this);
556
559 fFuncList->Resize(194, 20);
561
563 lb -> Resize(lb->GetWidth(), 500);
564 tf0 -> AddFrame(fFuncList, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0));
565 fFuncList->Associate(this);
566
568
570 TGHButtonGroup *bgr = new TGHButtonGroup(tf1, "Operation");
571
572 bgr -> SetRadioButtonExclusive();
573 fNone = new TGRadioButton(bgr, "Nop", kFP_NONE);
574 fAdd = new TGRadioButton(bgr, "Add", kFP_ADD);
575 fNormAdd = new TGRadioButton(bgr, "NormAdd", kFP_NORMADD);
576 fConv = new TGRadioButton(bgr, "Conv", kFP_CONV);
577
578 fNone -> SetToolTipText("No operation defined");
579 fNone -> SetState(kButtonDown, kFALSE);
580 fAdd -> SetToolTipText("Addition");
581 // fAdd -> SetState(kButtonDown, kFALSE);
582 fNormAdd -> SetToolTipText("NormAddition");
583 //fNormAdd -> SetState(kButtonDown, kFALSE);
584 fConv -> SetToolTipText("Convolution");
585 //fConv -> SetState(kButtonDown, kTRUE);
586
587 fLayoutNone = new TGLayoutHints(kLHintsLeft,0 ,5,3,-10);
588 fLayoutAdd = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
589 fLayoutNormAdd = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
590 fLayoutConv = new TGLayoutHints(kLHintsLeft,10,5,3,-10);
591
592 bgr -> SetLayoutHints(fLayoutNone, fNone);
593 bgr -> SetLayoutHints(fLayoutAdd, fAdd);
594 bgr -> SetLayoutHints(fLayoutNormAdd,fNormAdd);
595 bgr -> SetLayoutHints(fLayoutConv, fConv);
596 bgr -> Show();
598
599 tf1 -> AddFrame(bgr, new TGLayoutHints(kLHintsExpandX, 0, 0, 3, 0));
601
605 //fEnteredFunc->SetMaxLength(4000); // use default value (~4000)
608 assert(te);
609 fEnteredFunc->SetText(te->GetTitle());
610 fEnteredFunc->SetToolTipText("Enter file_name/function_name or a function expression");
614 kLHintsExpandX, 2, 2, 2, 2));
615 gf1->AddFrame(tf2, new TGLayoutHints(kLHintsNormal |
616 kLHintsExpandX, 0, 0, 2, 0));
617
619 TGLabel *label21 = new TGLabel(s1, "Selected: ");
620 s1->AddFrame(label21, new TGLayoutHints(kLHintsNormal |
621 kLHintsCenterY, 2, 2, 2, 0));
624 gf1->AddFrame(s1, new TGLayoutHints(kLHintsExpandX));
625
629 TString s = txt->GetTitle();
630 fSelLabel = new TGLabel(tf4, s.Sizeof()>30?s(0,30)+"...":s);
632 kLHintsCenterY, 0, 6, 2, 0));
633 Pixel_t color;
634 gClient->GetColorByName("#336666", color);
638 fSetParam = new TGTextButton(tf5, "Set Parameters...", kFP_PARS);
639 tf5->AddFrame(fSetParam, new TGLayoutHints(kLHintsRight |
642 fSetParam->SetToolTipText("Open a dialog for parameter(s) settings");
643 tf4->AddFrame(tf5, new TGLayoutHints(kLHintsRight |
644 kLHintsTop, 5, 0, 2, 2));
645 gf1->AddFrame(tf4, new TGLayoutHints(kLHintsNormal |
646 kLHintsExpandX, 5, 0, 0, 0));
647
648 this->AddFrame(gf1, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 0));
649
650}
651
652////////////////////////////////////////////////////////////////////////////////
653/// Create 'General' tab.
654
656{
657 fTabContainer = fTab->AddTab("General");
661 5, 5, 2, 2));
662
663 // 'options' group frame
664 TGGroupFrame *gf = new TGGroupFrame(fGeneral, "Fit Settings", kFitWidth);
665
666 // 'method' sub-group
668 TGLabel *label4 = new TGLabel(h1, "Method");
669 h1->AddFrame(label4, new TGLayoutHints(kLHintsNormal |
670 kLHintsCenterY, 2, 2, 0, 0));
673 gf->AddFrame(h1, new TGLayoutHints(kLHintsExpandX));
674
679 fMethodList->Resize(140, 20);
681 Int_t lbe = lb->GetNumberOfEntries();
682 lb->Resize(lb->GetWidth(), lbe*16);
683 v1->AddFrame(fMethodList, new TGLayoutHints(kLHintsLeft, 0, 0, 2, 5));
684
685 fLinearFit = new TGCheckButton(v1, "Linear fit", kFP_MLINF);
686 fLinearFit->Associate(this);
687 fLinearFit->SetToolTipText("Perform Linear fitter if selected");
688 v1->AddFrame(fLinearFit, new TGLayoutHints(kLHintsNormal, 0, 0, 8, 2));
689
690
691 h2->AddFrame(v1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
692
694 TGCompositeFrame *v21 = new TGCompositeFrame(v2, 120, 20,
696 fUserButton = new TGTextButton(v21, "User-Defined...", kFP_MUSR);
700 fUserButton->SetToolTipText("Open a dialog for entering a user-defined method");
702 v2->AddFrame(v21, new TGLayoutHints(kLHintsRight | kLHintsTop));
703
705 fEnableRobust = new TGCheckButton(v1h, "Robust:", -1);
706 fEnableRobust->Associate(this); // needed ???
707 fEnableRobust->SetToolTipText("Perform Linear Robust fitter if selected");
708 v1h->AddFrame(fEnableRobust, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
709 fRobustValue = new TGNumberEntry(v1h, 0.95, 5, kFP_RBUST,
713 v1h->AddFrame(fRobustValue, new TGLayoutHints(kLHintsLeft));
714 v2->AddFrame(v1h, new TGLayoutHints(kLHintsNormal, 0, 0, 12, 2));
716 fRobustValue->GetNumberEntry()->SetToolTipText("Available only for graphs");
717
718 fNoChi2 = 0;
719 // fNoChi2 = new TGCheckButton(v2, "No Chi-square", kFP_NOCHI);
720 // fNoChi2->Associate(this);
721 // fNoChi2->SetToolTipText("'C'- do not calculate Chi-square (for Linear fitter)");
722 // v2->AddFrame(fNoChi2, new TGLayoutHints(kLHintsNormal, 0, 0, 34, 2));
723
724 h2->AddFrame(v2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 20, 0, 0, 0));
725 gf->AddFrame(h2, new TGLayoutHints(kLHintsExpandX, 20, 0, 0, 0));
726
727 // 'fit option' sub-group
729 TGLabel *label5 = new TGLabel(h3, "Fit Options");
730 h3->AddFrame(label5, new TGLayoutHints(kLHintsNormal |
731 kLHintsCenterY, 2, 2, 0, 0));
734 gf->AddFrame(h3, new TGLayoutHints(kLHintsExpandX));
735
738 fIntegral = new TGCheckButton(v3, "Integral", kFP_INTEG);
739 fIntegral->Associate(this);
740 fIntegral->SetToolTipText("'I'- use integral of function instead of value in bin center");
741 v3->AddFrame(fIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
742
743 fBestErrors = new TGCheckButton(v3, "Best errors", kFP_IMERR);
744 fBestErrors->Associate(this);
745 fBestErrors->SetToolTipText("'E'- better errors estimation using Minos technique");
746 v3->AddFrame(fBestErrors, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
747
748 fAllWeights1 = new TGCheckButton(v3, "All weights = 1", kFP_ALLW1);
749 fAllWeights1->Associate(this);
750 fAllWeights1->SetToolTipText("'W'- all weights=1 for non empty bins; error bars ignored");
751 v3->AddFrame(fAllWeights1, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
752
753 fEmptyBinsWghts1 = new TGCheckButton(v3, "Empty bins, weights=1", kFP_EMPW1);
755 fEmptyBinsWghts1->SetToolTipText("'WW'- all weights=1 including empty bins; error bars ignored");
756 v3->AddFrame(fEmptyBinsWghts1, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
757
759
761 fUseRange = new TGCheckButton(v4, "Use range", kFP_USERG);
762 fUseRange->Associate(this);
763 fUseRange->SetToolTipText("'R'- fit only data within the specified function range");
764 v4->AddFrame(fUseRange, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
765
766 fImproveResults = new TGCheckButton(v4, "Improve fit results", kFP_IFITR);
768 fImproveResults->SetToolTipText("'M'- after minimum is found, search for a new one");
769 v4->AddFrame(fImproveResults, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
770
771 fAdd2FuncList = new TGCheckButton(v4, "Add to list", kFP_ADDLS);
773 fAdd2FuncList->SetToolTipText("'+'- add function to the list without deleting the previous");
774 v4->AddFrame(fAdd2FuncList, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
775
776 fUseGradient = new TGCheckButton(v4, "Use Gradient", kFP_ADDLS);
777 fUseGradient->Associate(this);
778 fUseGradient->SetToolTipText("'G'- Use the gradient as an aid for the fitting");
779 v4->AddFrame(fUseGradient, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
780
781 h->AddFrame(v4, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 20, 0, 0, 0));
782 gf->AddFrame(h, new TGLayoutHints(kLHintsExpandX, 20, 0, 0, 0));
783
784 // 'draw option' sub-group
786 TGLabel *label6 = new TGLabel(h5, "Draw Options");
787 h5->AddFrame(label6, new TGLayoutHints(kLHintsNormal |
788 kLHintsCenterY, 2, 2, 2, 2));
791 gf->AddFrame(h5, new TGLayoutHints(kLHintsExpandX));
792
795
796 fDrawSame = new TGCheckButton(v5, "SAME", kFP_DSAME);
797 fDrawSame->Associate(this);
798 fDrawSame->SetToolTipText("Superimpose on previous picture in the same pad");
799 v5->AddFrame(fDrawSame, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
800
801 fNoDrawing = new TGCheckButton(v5, "No drawing", kFP_DNONE);
802 fNoDrawing->Associate(this);
803 fNoDrawing->SetToolTipText("'0'- do not draw function graphics");
804 v5->AddFrame(fNoDrawing, new TGLayoutHints(kLHintsNormal, 0, 0, 2, 2));
805
806 fNoStoreDrawing = new TGCheckButton(v5, "Do not store/draw", kFP_DNOST);
808 fNoStoreDrawing->SetToolTipText("'N'- do not store the function, do not draw it");
810
811 h6->AddFrame(v5, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
812
814 TGCompositeFrame *v61 = new TGCompositeFrame(v6, 120, 20,
816 fDrawAdvanced = new TGTextButton(v61, "&Advanced...", kFP_DADVB);
820 fDrawAdvanced->SetToolTipText("Open a dialog for advanced draw options");
822
823 v6->AddFrame(v61, new TGLayoutHints(kLHintsRight | kLHintsTop,
824 0, 0, (4+fDrawSame->GetHeight())*2, 0));
825
827 gf->AddFrame(h6, new TGLayoutHints(kLHintsExpandX, 20, 0, 2, 0));
828
830 kLHintsExpandY, 5, 5, 0, 0));
831 // sliderX
835 kLHintsCenterY, 0, 5, 0, 0));
836
842
844 fSliderX->SetScale(5);
846
847
854
855 // sliderY
859 kLHintsCenterY, 0, 5, 0, 0));
860
866
868 fSliderY->SetScale(5);
870
877
878 // sliderZ
882 kLHintsCenterY, 0, 5, 0, 0));
884 fSliderZ->SetScale(5);
888}
889
890
891////////////////////////////////////////////////////////////////////////////////
892/// Create 'Minimization' tab.
893
895{
896 fTabContainer = fTab->AddTab("Minimization");
900 5, 5, 2, 2));
901 MakeTitle(fMinimization, "Library");
902
904 fLibMinuit = new TGRadioButton(hl, "Minuit", kFP_LMIN);
905 fLibMinuit->Associate(this);
906 fLibMinuit->SetToolTipText("Use minimization from libMinuit (default)");
907 hl->AddFrame(fLibMinuit, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
908 fStatusBar->SetText("LIB Minuit",1);
909
910 fLibMinuit2 = new TGRadioButton(hl, "Minuit2", kFP_LMIN2);
911 fLibMinuit2->Associate(this);
912 fLibMinuit2->SetToolTipText("New C++ version of Minuit");
913 hl->AddFrame(fLibMinuit2, new TGLayoutHints(kLHintsNormal, 35, 0, 0, 1));
914
915 fLibFumili = new TGRadioButton(hl, "Fumili", kFP_LFUM);
916 fLibFumili->Associate(this);
917 fLibFumili->SetToolTipText("Use minimization from libFumili");
918 hl->AddFrame(fLibFumili, new TGLayoutHints(kLHintsNormal, 30, 0, 0, 1));
920
922
923 fLibGSL = new TGRadioButton(hl2, "GSL", kFP_LGSL);
924 #ifdef R__HAS_MATHMORE
925 fLibGSL->Associate(this);
926 fLibGSL->SetToolTipText("Use minimization from libGSL");
927 #else
929 fLibGSL->SetToolTipText("Needs GSL to be compiled");
930 #endif
931 hl2->AddFrame(fLibGSL, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
932
933 fLibGenetics = new TGRadioButton(hl2, "Genetics", kFP_LGAS);
934 if (gPluginMgr->FindHandler("ROOT::Math::Minimizer","Genetic") ||
935 gPluginMgr->FindHandler("ROOT::Math::Minimizer","GAlibMin") )
936 {
937 fLibGenetics->Associate(this);
938 fLibGenetics->SetToolTipText("Different GAs implementations");
939 } else {
941 fLibGenetics->SetToolTipText("Needs any of the genetic"
942 "minimizers to be compiled");
943 }
944 hl2->AddFrame(fLibGenetics, new TGLayoutHints(kLHintsNormal, 45, 0, 0, 1));
945
947
948 MakeTitle(fMinimization, "Method");
949
952 fMinMethodList->Resize(290, 20);
954
956 lb->Resize(lb->GetWidth(), 500);
958
961
962 // Set the status to the default minimization options!
965 } else if ( ROOT::Math::MinimizerOptions::DefaultMinimizerType() == "Minuit" ) {
967 } else {
969 }
971
972 MakeTitle(fMinimization, "Settings");
973 TGLabel *hslabel1 = new TGLabel(fMinimization,"Use ENTER key to validate a new value or click");
975 TGLabel *hslabel2 = new TGLabel(fMinimization,"on Reset button to set the defaults.");
977
979
981 TGLabel *errlabel = new TGLabel(hsv1,"Error definition (default = 1): ");
983 1, 1, 5, 7));
984 TGLabel *tollabel = new TGLabel(hsv1,"Max tolerance (precision): ");
986 1, 1, 5, 7));
987 TGLabel *itrlabel = new TGLabel(hsv1,"Max number of iterations: ");
989 1, 1, 5, 5));
990 hs->AddFrame(hsv1, new TGLayoutHints(kLHintsNormal, 60, 0, 0, 0));
991
998 1, 1, 0, 3));
1005 1, 1, 3, 3));
1012 1, 1, 3, 3));
1013 hs->AddFrame(hsv2, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
1016
1017 MakeTitle(fMinimization, "Print Options");
1018
1020 fOptDefault = new TGRadioButton(h8, "Default", kFP_PDEF);
1021 fOptDefault->Associate(this);
1022 fOptDefault->SetToolTipText("Default is between Verbose and Quiet");
1023 h8->AddFrame(fOptDefault, new TGLayoutHints(kLHintsNormal, 40, 0, 0, 1));
1025 fStatusBar->SetText("Prn: DEF",4);
1026
1027 fOptVerbose = new TGRadioButton(h8, "Verbose", kFP_PVER);
1028 fOptVerbose->Associate(this);
1029 fOptVerbose->SetToolTipText("'V'- print results after each iteration");
1030 h8->AddFrame(fOptVerbose, new TGLayoutHints(kLHintsNormal, 30, 0, 0, 1));
1031
1032 fOptQuiet = new TGRadioButton(h8, "Quiet", kFP_PQET);
1033 fOptQuiet->Associate(this);
1034 fOptQuiet->SetToolTipText("'Q'- no print");
1035 h8->AddFrame(fOptQuiet, new TGLayoutHints(kLHintsNormal, 25, 0, 0, 1));
1036
1038
1039}
1040
1041////////////////////////////////////////////////////////////////////////////////
1042/// Connect GUI signals to fit panel slots.
1043
1045{
1046 // list of data sets to fit
1047 fDataSet -> Connect("Selected(Int_t)", "TFitEditor", this, "DoDataSet(Int_t)");
1048 // list of predefined functions
1049 fTypeFit -> Connect("Selected(Int_t)", "TFitEditor", this, "FillFunctionList(Int_t)");
1050 // list of predefined functions
1051 fFuncList -> Connect("Selected(Int_t)", "TFitEditor", this, "DoFunction(Int_t)");
1052 // entered formula or function name
1053 fEnteredFunc -> Connect("ReturnPressed()", "TFitEditor", this, "DoEnteredFunction()");
1054 // set parameters dialog
1055 fSetParam -> Connect("Clicked()", "TFitEditor", this, "DoSetParameters()");
1056 // allowed function operations
1057 fAdd -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoAddition(Bool_t)");
1058 //fNormAdd -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoNormAddition(Bool_t)");
1059 //fConv -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoConvolution(Bool_t)");
1060 // fit options
1061 fAllWeights1 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoAllWeights1()");
1062 fUseRange -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoUseFuncRange()");
1063 fEmptyBinsWghts1 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoEmptyBinsAllWeights1()");
1064 // linear fit
1065 fLinearFit -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLinearFit()");
1066 fEnableRobust -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoRobustFit()");
1067 //fNoChi2->Connect("Toggled(Bool_t)","TFitEditor",this,"DoNoChi2()");
1068 // draw options
1069 fNoStoreDrawing -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoNoStoreDrawing()");
1070 // fit, reset, close buttons
1071 fUpdateButton -> Connect("Clicked()", "TFitEditor", this, "DoUpdate()");
1072 fFitButton -> Connect("Clicked()", "TFitEditor", this, "DoFit()");
1073 fResetButton -> Connect("Clicked()", "TFitEditor", this, "DoReset()");
1074 fCloseButton -> Connect("Clicked()", "TFitEditor", this, "DoClose()");
1075 // user method button
1076 fUserButton -> Connect("Clicked()", "TFitEditor", this, "DoUserDialog()");
1077 // advanced draw options
1078 fDrawAdvanced -> Connect("Clicked()", "TFitEditor", this, "DoAdvancedOptions()");
1079
1080 if (fType != kObjectTree)
1081 {
1082 fSliderX -> Connect("PositionChanged()","TFitEditor",this, "DoSliderXMoved()");
1083 fSliderXMax -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderXChanged()");
1084 fSliderXMin -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderXChanged()");
1085 }
1086 if (fDim > 1)
1087 {
1088 fSliderY -> Connect("PositionChanged()","TFitEditor",this, "DoSliderYMoved()");
1089 fSliderYMax -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderYChanged()");
1090 fSliderYMin -> Connect("ValueSet(Long_t)", "TFitEditor",this, "DoNumericSliderYChanged()");
1091 }
1092 if (fDim > 2)
1093 fSliderZ -> Connect("PositionChanged()","TFitEditor",this, "DoSliderZMoved()");
1094
1095 if ( fParentPad )
1096 fParentPad -> Connect("RangeAxisChanged()","TFitEditor",this, "UpdateGUI()");
1097 // 'Minimization' tab
1098 // library
1099 fLibMinuit -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1100 fLibMinuit2 -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1101 fLibFumili -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1102 fLibGSL -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1103 fLibGenetics -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoLibrary(Bool_t)");
1104
1105 // minimization method
1106 fMinMethodList -> Connect("Selected(Int_t)", "TFitEditor", this, "DoMinMethod(Int_t)");
1107 // fitter settings
1108 fIterations -> Connect("ReturnPressed()", "TFitEditor", this, "DoMaxIterations()");
1109 // print options
1110 fOptDefault -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1111 fOptVerbose -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1112 fOptQuiet -> Connect("Toggled(Bool_t)", "TFitEditor", this, "DoPrintOpt(Bool_t)");
1113
1114}
1115
1116////////////////////////////////////////////////////////////////////////////////
1117/// Disconnect GUI signals from fit panel slots.
1118
1120{
1121 Disconnect("CloseWindow()");
1122
1123 fFuncList -> Disconnect("Selected(Int_t)");
1124 fEnteredFunc -> Disconnect("ReturnPressed()");
1125 fSetParam -> Disconnect("Clicked()");
1126 fAdd -> Disconnect("Toggled(Bool_t)");
1127 // fNormAdd -> Disconnect("Toggled(Bool_t)");
1128 // fConv -> Disconnect("Toggled(Bool_t)");
1129
1130 // fit options
1131 fAllWeights1 -> Disconnect("Toggled(Bool_t)");
1132 fEmptyBinsWghts1 -> Disconnect("Toggled(Bool_t)");
1133
1134 // linear fit
1135 fLinearFit -> Disconnect("Toggled(Bool_t)");
1136 fEnableRobust -> Disconnect("Toggled(Bool_t)");
1137 //fNoChi2->Disconnect("Toggled(Bool_t)");
1138
1139 // draw options
1140 fNoStoreDrawing -> Disconnect("Toggled(Bool_t)");
1141
1142 // fit, reset, close buttons
1143 fFitButton -> Disconnect("Clicked()");
1144 fResetButton -> Disconnect("Clicked()");
1145
1146 // other methods
1147 fUserButton -> Disconnect("Clicked()");
1148 fDrawAdvanced -> Disconnect("Clicked()");
1149
1150 if (fType != kObjectTree)
1151 {
1152 fSliderX -> Disconnect("PositionChanged()");
1153 fSliderXMax -> Disconnect("ValueChanged(Long_t)");
1154 fSliderXMin -> Disconnect("ValueChanged(Long_t)");
1155 }
1156 if (fDim > 1)
1157 {
1158 fSliderY -> Disconnect("PositionChanged()");
1159 fSliderYMax -> Disconnect("ValueChanged(Long_t)");
1160 fSliderYMin -> Disconnect("ValueChanged(Long_t)");
1161 }
1162 if (fDim > 2)
1163 fSliderZ -> Disconnect("PositionChanged()");
1164 // slots related to 'Minimization' tab
1165 fLibMinuit -> Disconnect("Toggled(Bool_t)");
1166 fLibMinuit2 -> Disconnect("Toggled(Bool_t)");
1167 fLibFumili -> Disconnect("Toggled(Bool_t)");
1168 fLibGSL -> Disconnect("Toggled(Bool_t)");
1169 fLibGenetics -> Disconnect("Toggled(Bool_t)");
1170 // minimization method
1171 fMinMethodList -> Disconnect("Selected(Int_t)");
1172 // fitter settings
1173 fIterations -> Disconnect("ReturnPressed()");
1174 // print options
1175 fOptDefault -> Disconnect("Toggled(Bool_t)");
1176 fOptVerbose -> Disconnect("Toggled(Bool_t)");
1177 fOptQuiet -> Disconnect("Toggled(Bool_t)");
1178
1179}
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Connect to another canvas.
1183
1185{
1186 // The next line is commented because it is stablishing a
1187 // connection with the particular canvas, while right the following
1188 // line will connect all the canvas in a general way.
1189
1190 // It would also make the fitpanel crash if there is no object
1191 // defined to be fitted in the construction (as a side effect of
1192 // it).
1193
1194// newcan->Connect("Selected(TVirtualPad*,TObject*,Int_t)", "TFitEditor",
1195// this, "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1196
1197 TQObject::Connect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1198 "TFitEditor",this,
1199 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1200 TQObject::Connect("TCanvas", "Closed()", "TFitEditor", this, "DoNoSelection()");
1201}
1202
1203////////////////////////////////////////////////////////////////////////////////
1204/// Hide the fit panel and set it to non-active state.
1205
1207{
1208 if (fgFitDialog) {
1209 fgFitDialog->UnmapWindow();
1210 }
1211 if (fParentPad) {
1212 fParentPad->Disconnect("RangeAxisChanged()");
1213 DoReset();
1214 TQObject::Disconnect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1215 this, "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1216 }
1217 fParentPad = 0;
1218 fFitObject = 0;
1219 gROOT->GetListOfCleanups()->Remove(this);
1220}
1221
1222////////////////////////////////////////////////////////////////////////////////
1223/// Show the fit panel (possible only via context menu).
1224
1226{
1227 if (!gROOT->GetListOfCleanups()->FindObject(this))
1228 gROOT->GetListOfCleanups()->Add(this);
1229
1230 if (!fgFitDialog->IsMapped()) {
1231 fgFitDialog->MapWindow();
1232 gVirtualX->RaiseWindow(GetId());
1233 }
1234 fParentPad = static_cast<TPad*>(pad);
1235 SetCanvas(pad->GetCanvas());
1237}
1238
1239////////////////////////////////////////////////////////////////////////////////
1240/// Close fit panel window.
1241
1243{
1244 Hide();
1245}
1246
1247//______________________________________________________________________________
1248// TFitEditor *&TFitEditor::GetFP()
1249// {
1250// // Static: return main fit panel
1251// return fgFitDialog;
1252// }
1253
1254////////////////////////////////////////////////////////////////////////////////
1255/// Called to delete the fit panel.
1256
1258{
1259 TQObject::Disconnect("TCanvas", "Closed()");
1260 delete fgFitDialog;
1261 fgFitDialog = 0;
1262}
1263
1264////////////////////////////////////////////////////////////////////////////////
1265/// Set the fit panel GUI according to the selected object.
1266
1268{
1269 if (!fFitObject) return;
1270
1271 DrawSelection(true);
1272
1273 if ( fType == kObjectTree )
1274 // Don't do anything with the sliders, as they work with TAxis
1275 // that are not defined for the TTree
1276 return;
1277
1278 // sliders
1279 if (fType != kObjectTree) { // This is as fDim > 0
1280 TH1* hist = 0;
1281 switch (fType) {
1282 case kObjectHisto:
1283 hist = (TH1*)fFitObject;
1284 break;
1285
1286 case kObjectGraph:
1287 hist = ((TGraph*)fFitObject)->GetHistogram();
1288 break;
1289
1290 case kObjectMultiGraph:
1291 hist = ((TMultiGraph*)fFitObject)->GetHistogram();
1292 break;
1293
1294 case kObjectGraph2D:
1295 hist = ((TGraph2D*)fFitObject)->GetHistogram("empty");
1296 break;
1297
1298 case kObjectHStack:
1299 hist = (TH1 *)((THStack *)fFitObject)->GetHists()->First();
1300
1301 case kObjectTree:
1302 default:
1303 break;
1304 }
1305
1306
1307 if (!hist) {
1308 Error("UpdateGUI","No hist is present - this should not happen, please report."
1309 "The FitPanel might be in an inconsistent state");
1310 //assert(hist);
1311 return;
1312 }
1313
1314 fSliderX->Disconnect("PositionChanged()");
1315 fSliderXMin->Disconnect("ValueChanged()");
1316 fSliderXMax->Disconnect("ValueChanged()");
1317
1318 if (!fSliderXParent->IsMapped())
1320
1321 fXaxis = hist->GetXaxis();
1322 fYaxis = hist->GetYaxis();
1323 fZaxis = hist->GetZaxis();
1327
1328 if (ixmin > 1 || ixmax < ixrange) {
1331 } else {
1334 }
1335
1336 fSliderX->SetScale(5);
1337
1339 fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1340 fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1343 fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1344 fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1346
1347 fSliderX->Connect("PositionChanged()","TFitEditor",this, "DoSliderXMoved()");
1348 fSliderXMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1349 fSliderXMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1350 }
1351
1352 if (fDim > 1) {
1353 fSliderY->Disconnect("PositionChanged()");
1354 fSliderYMin->Disconnect("ValueChanged()");
1355 fSliderYMax->Disconnect("ValueChanged()");
1356
1357 if (!fSliderYParent->IsMapped())
1359 if (fSliderZParent->IsMapped())
1361
1362 Int_t iymin = 0, iymax = 0, iyrange = 0;
1363 switch (fType) {
1364 case kObjectHisto:
1365 case kObjectGraph2D:
1366 case kObjectHStack:
1367 iyrange = fYaxis->GetNbins();
1368 iymin = fYaxis->GetFirst();
1369 iymax = fYaxis->GetLast();
1370 break;
1371
1372 case kObjectGraph:
1373 case kObjectMultiGraph:
1374 case kObjectTree:
1375 default:
1376 //not implemented
1377 break;
1378 }
1379
1380 if (iymin > 1 || iymax < iyrange) {
1383 } else {
1386 }
1387
1388 fSliderY->SetScale(5);
1389
1391 fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1392 fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1395 fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1396 fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1398
1399 fSliderY->Connect("PositionChanged()","TFitEditor",this, "DoSliderYMoved()");
1400 fSliderYMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1401 fSliderYMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1402 }
1403
1404
1405 if (fDim > 2) {
1406 fSliderZ->Disconnect("PositionChanged()");
1407
1408 if (!fSliderZParent->IsMapped())
1410
1411 Int_t izmin = 0, izmax = 0, izrange = 0;
1412 switch (fType) {
1413 case kObjectHStack:
1414 case kObjectHisto:
1415 izrange = fZaxis->GetNbins();
1416 izmin = fZaxis->GetFirst();
1417 izmax = fZaxis->GetLast();
1418 break;
1419
1420 case kObjectGraph:
1421 case kObjectGraph2D:
1422 case kObjectMultiGraph:
1423 case kObjectTree:
1424 default:
1425 //not implemented
1426 break;
1427 }
1428
1429 if (izmin > 1 || izmax < izrange) {
1432 } else {
1435 }
1436
1437 fSliderZ->SetScale(5);
1438 fSliderZ->Connect("PositionChanged()","TFitEditor",this, "DoSliderZMoved()");
1439 }
1440}
1441
1442////////////////////////////////////////////////////////////////////////////////
1443/// Slot called when the user clicks on an object inside a canvas.
1444/// Updates pointers to the parent pad and the selected object
1445/// for fitting (if suitable).
1446
1448{
1449 if (event != kButton1Down) return;
1450
1451 if ( !obj ) {
1452 DoNoSelection();
1453 return;
1454 }
1455
1456 // is obj suitable for fitting?
1457 if (!SetObjectType(obj)) return;
1458
1459 fParentPad = pad;
1460 fFitObject = obj;
1461 ShowObjectName(obj);
1462 UpdateGUI();
1463
1464 ConnectSlots();
1465
1467
1468 if (fitFunc)
1469 {
1470 //fFuncPars = FuncParams_t( fitFunc->GetNpar() );
1472
1473 TString tmpStr = fitFunc->GetExpFormula();
1474 TGLBEntry *en = 0;
1475 // If the function comes from a C raw function.
1476 if ( tmpStr.Length() == 0 )
1477 {
1478 // Show the name of the function
1479 fEnteredFunc->SetText(fitFunc->GetName());
1480 en= fFuncList->FindEntry(fitFunc->GetName());
1481 // Don't allow edition!
1483 }
1484 // otherwise, it's got a formula
1485 else
1486 {
1487 // Show the formula
1488 fEnteredFunc->SetText(fitFunc->GetExpFormula().Data());
1489 en= fFuncList->FindEntry(fitFunc->GetExpFormula().Data());
1491 }
1492 // Select the proper entry in the function list
1493 if (en) fFuncList->Select(en->EntryId());
1494 }
1495 else
1496 { // if there is no fit function in the object
1497 // Use the selected function in fFuncList
1499 // Add the text to fEnteredFunc
1500 if (te && fNone->GetState() == kButtonDown)
1501 fEnteredFunc->SetText(te->GetTitle());
1502 else if (te && fAdd->GetState() == kButtonDown)
1503 {
1505 tmpStr += '+';
1506 tmpStr += te->GetTitle();
1508 }
1509 else if (te && fNormAdd->GetState() == kButtonDown)
1510 {
1512 tmpStr += '+';
1513 tmpStr += te -> GetTitle();
1514 fEnteredFunc -> SetText(tmpStr);
1515 }
1516 else if (te && fConv->GetState() == kButtonDown)
1517 {
1519 tmpStr += '*';
1520 tmpStr +=te->GetTitle();
1522 }
1523 else if ( !te )
1524 // If there is no space, an error message is shown:
1525 // Error in <TString::AssertElement>: out of bounds: i = -1, Length = 0
1526 // If there is no function selected, then put nothing.
1527 fEnteredFunc->SetText(" ");
1528 }
1530
1531
1532 // Update the information about the selected object.
1539 DoLinearFit();
1540}
1541
1542////////////////////////////////////////////////////////////////////////////////
1543/// Slot called when users close a TCanvas or when the user select
1544/// no object.
1545
1547{
1548 if (gROOT->GetListOfCanvases()->IsEmpty()) {
1549 Terminate();
1550 return;
1551 }
1552
1553 // Minimize user interaction until an object is selected
1555 fParentPad = 0;
1556 fFitObject = 0;
1557 fStatusBar->SetText("No selection",0);
1559 Layout();
1560
1565}
1566
1567////////////////////////////////////////////////////////////////////////////////
1568/// When obj is deleted, clear fFitObject if fFitObject = obj.
1569
1571{
1572 if (obj == fFitObject) {
1573 fFitObject = 0;
1575 fStatusBar->SetText("No selection",0);
1577 Layout();
1578
1582
1583 TQObject::Connect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1584 "TFitEditor",this,
1585 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1586 TQObject::Connect("TCanvas", "Closed()", "TFitEditor", this,
1587 "DoNoSelection()");
1588
1589 DoUpdate();
1590 return;
1591 }
1592 if (obj == fParentPad) {
1593 fFitObject = 0;
1594 fParentPad = 0;
1596 fStatusBar->SetText("No selection",0);
1598 Layout();
1599
1603 }
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Fills the list of functions depending on the type of fit
1608/// selected.
1609
1611{
1613 // Case when the user has selected predefined functions in 1D.
1614 if ( fTypeFit->GetSelected() == kFP_PRED1D && fDim <= 1 ) {
1615 // Fill function list combo box.
1616 fFuncList->AddEntry("gaus" , kFP_GAUS);
1617 fFuncList->AddEntry("gausn", kFP_GAUSN);
1618 fFuncList->AddEntry("expo", kFP_EXPO);
1619 fFuncList->AddEntry("landau", kFP_LAND);
1620 fFuncList->AddEntry("landaun",kFP_LANDN);
1621 fFuncList->AddEntry("pol0", kFP_POL0);
1622 fFuncList->AddEntry("pol1", kFP_POL1);
1623 fFuncList->AddEntry("pol2", kFP_POL2);
1624 fFuncList->AddEntry("pol3", kFP_POL3);
1625 fFuncList->AddEntry("pol4", kFP_POL4);
1626 fFuncList->AddEntry("pol5", kFP_POL5);
1627 fFuncList->AddEntry("pol6", kFP_POL6);
1628 fFuncList->AddEntry("pol7", kFP_POL7);
1629 fFuncList->AddEntry("pol8", kFP_POL8);
1630 fFuncList->AddEntry("pol9", kFP_POL9);
1631 fFuncList->AddEntry("cheb0", kFP_CHEB0);
1632 fFuncList->AddEntry("cheb1", kFP_CHEB1);
1633 fFuncList->AddEntry("cheb2", kFP_CHEB2);
1634 fFuncList->AddEntry("cheb3", kFP_CHEB3);
1635 fFuncList->AddEntry("cheb4", kFP_CHEB4);
1636 fFuncList->AddEntry("cheb5", kFP_CHEB5);
1637 fFuncList->AddEntry("cheb6", kFP_CHEB6);
1638 fFuncList->AddEntry("cheb7", kFP_CHEB7);
1639 fFuncList->AddEntry("cheb8", kFP_CHEB8);
1640 fFuncList->AddEntry("cheb9", kFP_CHEB9);
1641 fFuncList->AddEntry("user", kFP_USER);
1642
1643 // Need to be setted this way, otherwise when the functions
1644 // are removed, the list doesn't show them.
1646 lb->Resize(lb->GetWidth(), 200);
1647
1648 // Select Gaus1D by default
1650
1651 }
1652 // Case for predefined 2D functions
1653 else if ( fTypeFit->GetSelected() == kFP_PRED2D && fDim == 2 ) {
1654 fFuncList->AddEntry("xygaus", kFP_XYGAUS);
1655 fFuncList->AddEntry("bigaus", kFP_BIGAUS);
1656 fFuncList->AddEntry("xyexpo", kFP_XYEXP);
1657 fFuncList->AddEntry("xylandau", kFP_XYLAN);
1658 fFuncList->AddEntry("xylandaun", kFP_XYLANN);
1659
1660 // Need to be setted this way, otherwise when the functions
1661 // are removed, the list doesn't show them.x
1663 lb->Resize(lb->GetWidth(), 200);
1664
1665 // Select Gaus2D by default
1667 } else if (fTypeFit->GetSelected() == kFP_PRED3D && fDim == 3) {
1668 fFuncList->AddEntry("xyzgaus", kFP_XYZGAUS);
1669
1670 // Need to be setted this way, otherwise when the functions
1671 // are removed, the list doesn't show them.x
1673 lb->Resize(lb->GetWidth(), 200);
1674
1675 // Select Gaus3D by default
1677 }
1678 // Case for user defined functions. References to these functions
1679 // are kept by the fitpanel, so the information is gathered from
1680 // there.
1681 else if (fTypeFit->GetSelected() == kFP_UFUNC) {
1683
1684 // Add system functions
1685 for (auto f : fSystemFuncs) {
1686 // Don't include system functions that has been previously
1687 // used to fit, as those are included under the kFP_PREVFIT
1688 // section.
1689 if ( strncmp(f->GetName(), "PrevFit", 7) != 0 ) {
1690 // If the dimension of the object coincides with the
1691 // dimension of the function, then include the function in
1692 // the list. It will also include de function if the
1693 // dimension of the object is 0 (i.e. a multivariable
1694 // TTree) as it is currently imposible to know how many
1695 // dimensions a TF1 coming from a C raw function has.
1696 if ( f->GetNdim() == fDim || fDim == 0) {
1697 fFuncList->AddEntry(f->GetName(), newid++);
1698 }
1699 }
1700 }
1701
1702 // If no function was added
1703 if ( newid != kFP_ALTFUNC )
1705 else if( fDim == 1 ) {
1706 // Select predefined 1D functions for 1D objects
1708 } else if( fDim == 2 ) {
1709 // Select predefined 2D functions for 2D objects
1711 }
1712 }
1713 // Case for previously used functions.
1714 else if (fTypeFit->GetSelected() == kFP_PREVFIT) {
1716
1717 // Look only for those functions used in the selected object
1718 std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(fFitObject);
1719 // Then go over all those functions and add them to the list
1720 for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
1721 fFuncList->AddEntry(it->second->GetName(), newid++);
1722 }
1723
1724 // If no functions were added.
1725 if ( newid == kFP_ALTFUNC ) {
1726 // Remove the entry previous fit from fTypeFit
1728 if( fDim == 1 )
1729 // Select predefined 1D functions for 1D objects
1731 else if ( fDim == 2 )
1732 // Select predefined 2D functions for 2D objects
1734 else
1735 // For more than 2 dimensions, select the user functions.
1737 }
1738 else
1739 // If there is there are previously used functions, select
1740 // the last one inserted.
1742 }
1743}
1744
1745////////////////////////////////////////////////////////////////////////////////
1746/// Fills the list of methods depending on the minimization library
1747/// selected.
1748
1750{
1752
1753 if ( fLibMinuit->GetState() == kButtonDown )
1754 {
1755 fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1756 fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1757 fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1758 fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1760 fStatusBar->SetText("MIGRAD",2);
1761 } else if ( fLibFumili->GetState() == kButtonDown )
1762 {
1763 fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1765 fStatusBar->SetText("FUMILI",2);
1766 } else if ( fLibGSL->GetState() == kButtonDown )
1767 {
1768 fMinMethodList->AddEntry("Fletcher-Reeves conjugate gradient" , kFP_GSLFR);
1769 fMinMethodList->AddEntry("Polak-Ribiere conjugate gradient" , kFP_GSLPR);
1770 fMinMethodList->AddEntry("BFGS conjugate gradient" , kFP_BFGS);
1771 fMinMethodList->AddEntry("BFGS conjugate gradient (Version 2)", kFP_BFGS2);
1772 fMinMethodList->AddEntry("Levenberg-Marquardt" , kFP_GSLLM);
1773 fMinMethodList->AddEntry("Simulated Annealing" , kFP_GSLSA);
1775 fStatusBar->SetText("CONJFR",2);
1776 } else if ( fLibGenetics->GetState() == kButtonDown )
1777 {
1778 if ( gPluginMgr->FindHandler("ROOT::Math::Minimizer","GAlibMin") ) {
1779 fMinMethodList->AddEntry("GA Lib Genetic Algorithm" , kFP_GALIB);
1781 } else if (gPluginMgr->FindHandler("ROOT::Math::Minimizer","Genetic")) {
1782 fMinMethodList->AddEntry("TMVA Genetic Algorithm" , kFP_TMVAGA);
1784 }
1785 } else // if ( fLibMinuit2->GetState() == kButtonDown )
1786 {
1787 fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1788 fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1789 fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1790 fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1791 fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1793 fStatusBar->SetText("MIGRAD",2);
1794 }
1795}
1796
1797void SearchCanvases(TSeqCollection* canvases, std::vector<TObject*>& objects)
1798{
1799 // Auxiliary function to recursively search for objects inside the
1800 // current canvases.
1801
1803 // Iterate over all the canvases in canvases.
1804 while(TObject* obj = (TObject*) canvasIter()) {
1805 // If the object is another canvas, call this function
1806 // recursively.
1807 if ( TPad* can = dynamic_cast<TPad*>(obj))
1808 SearchCanvases(can->GetListOfPrimitives(), objects);
1809 // Otherwhise, if it's a recognised object, add it to the vector
1810 else if ( dynamic_cast<TH1*>(obj)
1811 || dynamic_cast<TGraph*>(obj)
1812 || dynamic_cast<TGraph2D*>(obj)
1813 || dynamic_cast<TMultiGraph*>(obj)
1814 || dynamic_cast<THStack*>(obj)
1815 || dynamic_cast<TTree*>(obj) ) {
1816 bool insertNew = true;
1817 // Be careful no to insert the same element twice.
1818 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1819 if ( (*i) == obj ) {
1820 insertNew = false;
1821 break;
1822 }
1823 // If the object is not already in the vector, then insert
1824 // it.
1825 if ( insertNew ) objects.push_back(obj);
1826 }
1827 }
1828}
1829
1830////////////////////////////////////////////////////////////////////////////////
1831/// Create a combo box with all the possible objects to be fitted.
1832
1834{
1835 // Get the title of the entry selected, so that we can select it
1836 // again once the fDataSet has been refilled.
1839 if ( entry ) {
1840 selEntryStr = entry->GetTitle();
1841 }
1842
1843 // Remove all the elements
1845 std::vector<TObject*> objects;
1846
1847 // Get all the objects registered in gDirectory
1848 if (gDirectory) {
1849 TList * l = gDirectory->GetList();
1850 if (l) {
1851 TIter next(l);
1852 TObject* obj = NULL;
1853 while ( (obj = (TObject*) next()) ) {
1854 // But only if they are of a type recognized by the FitPanel
1855 if ( dynamic_cast<TH1*>(obj) ||
1856 dynamic_cast<TGraph2D*>(obj) ||
1857 dynamic_cast<TTree*>(obj) ) {
1858 objects.push_back(obj);
1859 }
1860 }
1861 }
1862 }
1863
1864 // Look for all the drawn objects. The method will take care the
1865 // same objects are not inserted twice.
1866 SearchCanvases(gROOT->GetListOfCanvases(), objects);
1867
1868 // Add all the objects stored in the vector
1869 int selected = kFP_NOSEL;
1870 // Add the No selection.
1872 fDataSet->AddEntry("No Selection", newid++);
1873 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1874 // Insert the name as the class name followed by the name of the
1875 // object.
1876 TString name = (*i)->ClassName(); name.Append("::"); name.Append((*i)->GetName());
1877 // Check whether the names are the same!
1878 if ( selEntryStr && name == selEntryStr )
1879 selected = newid;
1881 }
1882
1883 // If there was an entry selected (which should be always the case
1884 // except the first time this method is executed), then make it the
1885 // selected one again.
1886 if (entry) {
1887 fDataSet->Select(selected);
1888 }
1889}
1890
1891////////////////////////////////////////////////////////////////////////////////
1892/// Create method list in a combo box.
1893
1895{
1896 TGComboBox *c = new TGComboBox(parent, id);
1897 c->AddEntry("Chi-square", kFP_MCHIS);
1898 c->AddEntry("Binned Likelihood", kFP_MBINL);
1899 c->AddEntry("Unbinned Likelihood", kFP_MUBIN);
1900 //c->AddEntry("User", kFP_MUSER); //for later use
1901 c->Select(kFP_MCHIS);
1902 return c;
1903}
1904
1905////////////////////////////////////////////////////////////////////////////////
1906/// Slot connected to advanced option button (opens a dialog).
1907
1912
1913////////////////////////////////////////////////////////////////////////////////
1914/// Slot connected to 'include emtry bins and forse all weights to 1' setting.
1915
1922
1923////////////////////////////////////////////////////////////////////////////////
1924
1926{
1927 if ( fUseRange->GetState() == kButtonDown ) {
1929 // Get the function
1930 TF1* tmpTF1 = FindFunction();
1931 if ( !tmpTF1 ) {
1934 tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
1935 }
1936 }
1937 // If the function has been retrieved, i.e. is a registered function.
1938 if ( tmpTF1 ) {
1939 Double_t xmin, ymin, zmin, xmax, ymax, zmax;
1940 // Get the range
1941 tmpTF1->GetRange(xmin, ymin, zmin, xmax, ymax, zmax);
1942 // And set the sliders
1943 if ( fType != kObjectTree ) {
1947 if ( fDim > 1 ) {
1951 }
1952 }
1953 }
1954 }
1956 }
1957}
1958
1959////////////////////////////////////////////////////////////////////////////////
1960/// Slot connected to 'set all weights to 1' setting.
1961
1968
1969////////////////////////////////////////////////////////////////////////////////
1970/// Close the fit panel.
1971
1973{
1974 Hide();
1975}
1976
1977////////////////////////////////////////////////////////////////////////////////
1978/// Easy here!
1979
1985
1986////////////////////////////////////////////////////////////////////////////////
1987/// Perform a fit with current parameters' settings.
1988
1990{
1991 if (!fFitObject) return;
1992 //if (!fParentPad) return;
1993
1994 // If fNone->GetState() == kButtonDisabled means the function is
1995 // not editable, i.e. it comes from a raw C function. So in this
1996 // case, it is editable and we have to check wheather the formula
1997 // is well built.
1999 {
2000 // If not, then show an error message and leave.
2002 "Error...", "2) Verify the entered function string!",
2003 kMBIconStop,kMBOk, 0);
2004 return;
2005 }
2006
2007 // Set the button so that the user cannot use it while fitting, set
2008 // the mouse to watch type and so on.
2010 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kWatch);
2011 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
2012
2013 TVirtualPad *save = nullptr;
2014 if ( fParentPad ) {
2015 fParentPad->Disconnect("RangeAxisChanged()");
2016 save = gPad;
2017 gPad = fParentPad;
2018 fParentPad->cd();
2019
2020 if (fParentPad->GetCanvas())
2021 fParentPad->GetCanvas()->SetCursor(kWatch);
2022 }
2023
2024 // Get the ranges from the sliders
2027
2028 // Create a static pointer to fitFunc. Every second call to the
2029 // DoFit method, the old fitFunc is deleted. We need not to delete
2030 // the function after the fitting in case we want to do Advaced
2031 // graphics. The VirtualFitter need the function to be alived. One
2032 // problem, after the last fit the function is never deleted, but
2033 // ROOT's garbage collector will do the job for us.
2034 static TF1 *fitFunc = nullptr;
2035 if ( fitFunc ) {
2036 //std::cout << "TFitEditor::DoFit - deleting fit function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2037 delete fitFunc;
2038 }
2040
2041 std::cout << "TFitEditor::DoFit - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2042 // This assert
2043 if (!fitFunc) {
2044 Error("DoFit","This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2045 return;
2046 }
2047
2048 // set parameters from panel in function
2050 // Get the options stored in the GUI elements.
2055
2056 // Call the fit method, depending on the object to fit.
2057 switch (fType) {
2058 case kObjectHisto: {
2059
2060 TH1 *hist = dynamic_cast<TH1*>(fFitObject);
2061 if (hist)
2063
2064 break;
2065 }
2066 case kObjectGraph: {
2067
2068 TGraph *gr = dynamic_cast<TGraph*>(fFitObject);
2069 if (gr)
2070 FitObject(gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2071 break;
2072 }
2073 case kObjectMultiGraph: {
2074
2075 TMultiGraph *mg = dynamic_cast<TMultiGraph*>(fFitObject);
2076 if (mg)
2077 FitObject(mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2078
2079 break;
2080 }
2081 case kObjectGraph2D: {
2082
2083 TGraph2D *g2d = dynamic_cast<TGraph2D*>(fFitObject);
2084 if (g2d)
2085 FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2086
2087 break;
2088 }
2089 case kObjectHStack: {
2090 // N/A
2091 break;
2092 }
2093 case kObjectTree: {
2094 // The three is a much more special case. The steps for
2095 // fitting have to be done manually here until they are
2096 // properly implemented within a FitObject method in
2097 // THFitImpl.cxx
2098
2099 // Retrieve the variables and cuts selected from the current
2100 // tree.
2101 TString variables;
2102 TString cuts;
2103 GetTreeVarsAndCuts(fDataSet, variables, cuts);
2104
2105 // This should be straight forward and the return should
2106 // never be called.
2107 TTree *tree = dynamic_cast<TTree*>(fFitObject);
2108 if ( !tree ) return;
2109
2110 // These method calls are just to set up everything for the
2111 // fitting. It's taken from another script.
2112 gROOT->ls();
2113 tree->Draw(variables,cuts,"goff");
2114
2115 auto player = tree->GetPlayer();
2116 if ( !player ) {
2117 Error("DoFit","Player reference is NULL");
2118 return;
2119 }
2120
2121 auto selector = dynamic_cast<TSelectorDraw *>(player->GetSelector());
2122 if ( !selector ) {
2123 Error("DoFit","Selector reference is NULL");
2124 return;
2125 }
2126
2127 // use pointer stored in the tree (not copy the data in)
2128 unsigned int ndim = player->GetDimension();
2129 if ( ndim == 0 ) {
2130 Error("DoFit","NDIM == 0");
2131 return;
2132 }
2133
2134 std::vector<double *> vlist;
2135 for (unsigned int i = 0; i < ndim; ++i) {
2136 double * v = selector->GetVal(i);
2137 if (v != 0) vlist.push_back(v);
2138 else
2139 std::cerr << "pointer for variable " << i << " is zero" << std::endl;
2140 }
2141 if (vlist.size() != ndim) {
2142 Error("DoFit","Vector is not complete");
2143 return;
2144 }
2145
2146 // fill the data
2147 Long64_t nrows = player->GetSelectedRows();
2148 if ( !nrows ) {
2149 Error("DoFit","NROWS == 0");
2150 return;
2151 }
2152
2154
2155 for ( int i = 0; i < std::min(int(fitdata->Size()),10); ++i) {
2156 // print j coordinate
2157 for (unsigned int j = 0; j < ndim; ++j) {
2158 printf(" x_%d [%d] = %f \n", j, i,*(fitdata->Coords(i)+j) );
2159 }
2160 printf("\n");
2161 }
2162
2163
2164 //TVirtualFitter::SetDefaultFitter("Minuit");
2167 fitOption.Verbose=1;
2168
2169 // After all the set up is performed, then do the Fit!!
2171
2172 break;
2173 }
2174 }
2175
2176 // if SAME is set re-plot the function
2177 // useful in case histogram was drawn with HIST
2178 // and no function will be drawm)
2180 fitFunc->Draw("same");
2181
2182
2183 // update parameters value shown in dialog
2184 //if (!fFuncPars) fFuncPars = new Double_t[fitFunc->GetNpar()][3];
2186
2187 // Save fit data for future use as a PrevFit function.
2189 TString name = TString::Format("PrevFit-%d", (int) fPrevFit.size() + 1);
2190 if (!strstr(fitFunc->GetName(),"PrevFit"))
2191 name.Append(TString::Format("-%s", fitFunc->GetName()));
2192 tmpTF1->SetName(name.Data());
2193 fPrevFit.emplace(fFitObject, tmpTF1);
2194 fSystemFuncs.emplace_back( copyTF1(tmpTF1) );
2195
2196 float xmin = 0.f, xmax = 0.f, ymin = 0.f, ymax = 0.f, zmin = 0.f, zmax = 0.f;
2197 if ( fParentPad ) {
2199 // As the range is not changed, save the old values and restore
2200 // after the GUI has been updated. It would be more elegant to
2201 // disconnect the signal from fParentPad, however, this doesn't
2202 // work for unknown reasons.
2204 if ( fDim > 1 ) fSliderY->GetPosition(ymin, ymax);
2205 if ( fDim > 2 ) fSliderZ->GetPosition(zmin, zmax);
2206 fParentPad->Update();
2207 }
2208
2209 // In case the fit method draws something! Set the canvas!
2210 fParentPad = gPad;
2211 UpdateGUI();
2212
2213 // Change the sliders if necessary.
2214 if ( fParentPad ) {
2216 if ( fType != kObjectTree && fDim > 1 ) { fSliderY->SetPosition(ymin, ymax); DoSliderYMoved(); }
2217 if ( fType != kObjectTree && fDim > 2 ) { fSliderZ->SetPosition(zmin, zmax); DoSliderZMoved(); }
2218 if (fParentPad->GetCanvas())
2219 fParentPad->GetCanvas()->SetCursor(kPointer);
2220 fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2221
2222 if (save) gPad = save;
2226 }
2227
2228 // Restore the Fit button and mouse cursor to their proper state.
2229 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kPointer);
2230 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
2232
2233 if ( !fTypeFit->FindEntry("Prev. Fit") )
2235
2237}
2238
2239////////////////////////////////////////////////////////////////////////////////
2240/// Check entered function string.
2241
2243{
2244 Int_t rvalue = 0;
2245 if ( fDim == 1 || fDim == 0 ) {
2246 TF1 form("tmpCheck", fname);
2247 // coverity[uninit_use_in_call]
2248 rvalue = form.IsValid() ? 0 : -1;
2249 } else if ( fDim == 2 ) {
2250 TF2 form("tmpCheck", fname);
2251 // coverity[uninit_use_in_call]
2252 rvalue = form.IsValid() ? 0 : -1;
2253 } else if ( fDim == 3 ) {
2254 TF3 form("tmpCheck", fname);
2255 // coverity[uninit_use_in_call]
2256 rvalue = form.IsValid() ? 0 : -1;
2257 }
2258
2259 return rvalue;
2260}
2261
2262////////////////////////////////////////////////////////////////////////////////
2263/// Slot connected to addition of predefined functions. It will
2264/// insert the next selected function with a plus sign so that it
2265/// doesn't override the current content of the formula.
2266
2268{
2269 static Bool_t first = kFALSE;
2271 if (on) {
2272 if (!first) {
2273 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2274 s += "(0)";
2276 first = kTRUE;
2278 }
2279 } else {
2280 first = kFALSE;
2281 }
2282}
2283////////////////////////////////////////////////////////////////////////////////
2284/// Slot connected to addition of predefined functions. It will
2285/// insert the next selected function with a plus sign so that it
2286/// doesn't override the current content of the formula.
2287
2289{
2290 /*
2291 static Bool_t first = kFALSE;
2292 TString s = fEnteredFunc->GetText();
2293 if (on) {
2294 if (!first) {
2295 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2296 fEnteredFunc->SetText(s.Data());
2297 first = kTRUE;
2298 ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2299 }
2300 } else {
2301 first = kFALSE;
2302 }*/
2303
2304 if (on) Info("DoNormAddition","Normalized addition is selected");
2305}
2306
2307////////////////////////////////////////////////////////////////////////////////
2308/// Slot connected to addition of predefined functions. It will
2309/// insert the next selected function with a plus sign so that it
2310/// doesn't override the current content of the formula.
2311
2313{
2314 /*
2315 static Bool_t first = kFALSE;
2316 TString s = fEnteredFunc->GetText();
2317 if (on) {
2318 if (!first) {
2319 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2320 // s += "(0)";
2321 fEnteredFunc->SetText(s.Data());
2322 first = kTRUE;
2323 ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2324 }
2325 } else
2326 first = kFALSE;*/
2327
2328 if (on) Info("DoConvolution","Convolution is selected");
2329}
2330
2331////////////////////////////////////////////////////////////////////////////////
2332/// Selects the data set to be fitted
2333
2335{
2336 if ( selected == kFP_NOSEL ) {
2337 DoNoSelection();
2338 return;
2339 }
2340
2341 // Get the name and class of the selected object.
2342 TGTextLBEntry* textEntry = static_cast<TGTextLBEntry*>(fDataSet->GetListBox()->GetEntry(selected));
2343 if (!textEntry) return;
2344 TString textEntryStr = textEntry->GetText()->GetString();
2345 TString name = textEntry->GetText()->GetString()+textEntry->GetText()->First(':')+2;
2346 TString className = textEntryStr(0,textEntry->GetText()->First(':'));
2347
2348 // Check the object exists in the ROOT session and it is registered
2349 TObject* objSelected(0);
2350 if ( className == "TTree" ) {
2351 // It's a tree, so the name is before the space (' ')
2353 if ( name.First(' ') == kNPOS )
2354 lookStr = name;
2355 else
2356 lookStr = name(0, name.First(' '));
2357 //std::cout << "\t1 SITREE: '" << lookStr << "'" << std::endl;
2358 objSelected = gROOT->FindObject(lookStr);
2359 } else {
2360 // It's not a tree, so the name is the complete string
2361 //std::cout << "\t1 NOTREE: '" << name << "'" << std::endl;
2362 objSelected = gROOT->FindObject(name);
2363 }
2364 if ( !objSelected )
2365 {
2366 //std::cerr << "Object not found! Please report the error! " << std::endl;
2367 return;
2368 }
2369
2370 // If it is a tree, and there are no variables selected, show a dialog
2371 if ( objSelected->InheritsFrom(TTree::Class()) &&
2372 name.First(' ') == kNPOS ) {
2373 char variables[256] = {0}; char cuts[256] = {0};
2374 strlcpy(variables, "Sin input!", 256);
2375 new TTreeInput( fClient->GetRoot(), GetMainFrame(), variables, cuts );
2376 if ( strcmp ( variables, "" ) == 0 ) {
2377 DoNoSelection();
2378 return;
2379 }
2380 ProcessTreeInput(objSelected, selected, variables, cuts);
2381 }
2382
2383 // Search the canvas where the object is drawn, if any
2384 TPad* currentPad = NULL;
2385 bool found = false;
2386 std::queue<TPad*> stPad;
2387 TIter padIter( gROOT->GetListOfCanvases() );
2388 while ( TObject* canvas = static_cast<TObject*>(padIter() ) ) {
2389 if ( dynamic_cast<TPad*>(canvas) )
2390 stPad.push(dynamic_cast<TPad*>(canvas));
2391 }
2392
2393 while ( !stPad.empty() && !found ) {
2394 currentPad = stPad.front();
2395 stPad.pop();
2396 TIter elemIter( currentPad->GetListOfPrimitives() );
2397 while ( TObject* elem = static_cast<TObject*>(elemIter() ) ) {
2398 if ( elem == objSelected ) {
2399 found = true;
2400 break;
2401 } else if ( dynamic_cast<TPad*>(elem) )
2402 stPad.push( dynamic_cast<TPad*>(elem) );
2403 }
2404 }
2405
2406 // Set the proper object and canvas (if found!)
2407 SetFitObject( found ? currentPad : nullptr, objSelected, kButton1Down);
2408}
2409
2411{
2412 // If the input is valid, insert the tree with the selections as an entry to fDataSet
2413 TString entryName = (objSelected)->ClassName(); entryName.Append("::"); entryName.Append((objSelected)->GetName());
2414 entryName.Append(" (\""); entryName.Append(variables); entryName.Append("\", \"");
2415 entryName.Append(cuts); entryName.Append("\")");
2417 fDataSet->InsertEntry(entryName, newid, selected );
2419}
2420
2421////////////////////////////////////////////////////////////////////////////////
2422/// Slot connected to predefined fit function settings.
2423
2425{
2427
2428 // check that selected passesd value is the correct one in the TextEntry
2429 R__ASSERT( selected == te->EntryId());
2430 //std::cout << "calling do function " << selected << " " << te->GetTitle() << " function " << te->EntryId() << std::endl;
2431 //selected = te->EntryId();
2432
2433 bool editable = false;
2435 {
2436 // Get the function selected and check weather it is a raw C
2437 // function or not
2438 TF1* tmpTF1 = FindFunction();
2439 if ( !tmpTF1 )
2440 {
2442 tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
2443 }
2444 if ( tmpTF1 && strcmp(tmpTF1->GetExpFormula(), "") )
2445 {
2446 editable = kTRUE;
2447 fEnteredFunc->SetText(tmpTF1->GetExpFormula());
2448 }
2449 else
2450 {
2451 if ( selected <= kFP_USER )
2452 editable = kTRUE;
2453 else
2454 editable = kFALSE;
2455 fEnteredFunc->SetText(te->GetTitle());
2456 }
2457 // Once you have the function, set the editable.
2459 }
2460 else if (fAdd -> GetState() == kButtonDown)
2461 {
2462 // If the add button is down don't replace the fEnteredFunc text
2463 Int_t np = 0;
2464 TString s = "";
2465 if (!strcmp(fEnteredFunc->GetText(), ""))
2466 {
2467 fEnteredFunc->SetText(te->GetTitle());
2468 }
2469 else
2470 {
2471 s = fEnteredFunc->GetTitle();
2472 TFormula tmp("tmp", fEnteredFunc->GetText());
2473 np = tmp.GetNpar();
2474 }
2475 if (np)
2476 s += TString::Format("+%s(%d)", te->GetTitle(), np);
2477 else
2478 s += TString::Format("%s(%d)", te->GetTitle(), np);
2480 editable = true;
2481 }
2482 else if (fNormAdd->GetState() == kButtonDown)
2483 {
2484 // If the normadd button is down don't replace the fEnteredFunc text
2485 Int_t np = 0;
2486 TString s = "";
2487 if (!strcmp(fEnteredFunc->GetText(), ""))
2488 {
2489 fEnteredFunc->SetText(te->GetTitle());
2490 }
2491 else
2492 {
2493 s = fEnteredFunc->GetTitle();
2494 TFormula tmp("tmp", fEnteredFunc->GetText());
2495 np = tmp.GetNpar();
2496 }
2497 if (np)
2498 s += TString::Format("+%s", te->GetTitle());
2499 else
2500 s += TString::Format("%s", te->GetTitle());
2502 //std::cout <<fEnteredFunc->GetText()<<std::endl;
2503 editable = true;
2504 }
2505 else if (fConv->GetState() == kButtonDown)
2506 {
2507 // If the conv button is down don't replace the fEnteredFunc text
2508 Int_t np = 0;
2509 TString s = "";
2510 if (!strcmp(fEnteredFunc->GetText(), ""))
2511 fEnteredFunc->SetText(te->GetTitle());
2512 else
2513 {
2514 s = fEnteredFunc->GetTitle();
2515 TFormula tmp("tmp", fEnteredFunc->GetText());
2516 np = tmp.GetNpar();
2517 }
2518 if (np)
2519 s += TString::Format("*%s", te->GetTitle());
2520 else
2521 s += TString::Format("%s", te->GetTitle());
2523 //std::cout <<fEnteredFunc->GetText()<<std::endl;
2524 editable = true;
2525 }
2526
2527
2528 // Get the final name in fEnteredFunc to process the function that
2529 // it would create
2531
2532 // create TF1 with the passed string. Delete previous one if existing
2533 if (tmpStr.Contains("pol") || tmpStr.Contains("++")) {
2535 } else {
2537 }
2538
2540 fSelLabel->SetText(tmpStr.Sizeof()>30?tmpStr(0,30)+"...":tmpStr);
2542
2543 // reset function parameters if the number of parameters of the new
2544 // function is different from the old one!
2546 //std::cout << "TFitEditor::DoFunction - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2547
2548 if ( fitFunc && (unsigned int) fitFunc->GetNpar() != fFuncPars.size() ) {
2550 fFuncPars.resize(fitFunc->GetNpar());
2551 else
2552 fFuncPars.clear();
2553 }
2554 if ( fitFunc ) {
2555 //std::cout << "TFitEditor::DoFunction - deleting function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2556 delete fitFunc;
2557 }
2558}
2559
2560////////////////////////////////////////////////////////////////////////////////
2561/// Slot connected to entered function in text entry.
2562
2564{
2565 if (!strcmp(fEnteredFunc->GetText(), "")) return;
2566
2567 // Check if the function is well built
2569
2570 if (ok != 0) {
2572 "Error...", "3) Verify the entered function string!",
2573 kMBIconStop,kMBOk, 0);
2574 return;
2575 }
2576
2577 // And set the label with the entered text if everything is fine.
2579 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2581}
2582
2583////////////////////////////////////////////////////////////////////////////////
2584/// Slot connected to linear fit settings.
2585
2587{
2588 if (fLinearFit->GetState() == kButtonDown) {
2589 //fSetParam->SetState(kButtonDisabled);
2593 //fNoChi2->SetState(kButtonUp);
2594 } else {
2595 //fSetParam->SetState(kButtonUp);
2600 //fNoChi2->SetState(kButtonDisabled);
2601 }
2602}
2603
2604////////////////////////////////////////////////////////////////////////////////
2605/// Slot connected to 'no chi2' option settings.
2606
2608{
2609 //LM: no need to do operations here
2610 // if (fLinearFit->GetState() == kButtonUp)
2611 // fLinearFit->SetState(kButtonDown, kTRUE);
2612}
2613////////////////////////////////////////////////////////////////////////////////
2614/// Slot connected to 'robust fitting' option settings.
2615
2623
2624////////////////////////////////////////////////////////////////////////////////
2625/// Slot connected to 'no storing, no drawing' settings.
2626
2632
2633////////////////////////////////////////////////////////////////////////////////
2634/// Slot connected to print option settings.
2635
2637{
2638 // Change the states of the buttons depending of which one is
2639 // selected.
2641 Int_t id = btn->WidgetId();
2642 switch (id) {
2643 case kFP_PDEF:
2644 if (on) {
2648 }
2649 fStatusBar->SetText("Prn: DEF",4);
2650 break;
2651 case kFP_PVER:
2652 if (on) {
2656 }
2657 fStatusBar->SetText("Prn: VER",4);
2658 break;
2659 case kFP_PQET:
2660 if (on) {
2664 }
2665 fStatusBar->SetText("Prn: QT",4);
2666 default:
2667 break;
2668 }
2669}
2670
2671////////////////////////////////////////////////////////////////////////////////
2672/// Reset all fit parameters.
2673
2675{
2676 if ( fParentPad ) {
2678 fParentPad->Update();
2679 }
2680 fEnteredFunc->SetText("gaus");
2681
2682 // To restore temporary points and sliders
2683 UpdateGUI();
2684
2689 if (fUseRange->GetState() == kButtonDown)
2703 // if (fNoChi2->GetState() == kButtonDown)
2704 // fNoChi2->SetState(kButtonUp, kFALSE);
2705 if (fDrawSame->GetState() == kButtonDown)
2712 fFuncList->Select(1, kTRUE);
2713
2714 // minimization tab
2723 }
2727 }
2731 }
2732}
2733
2734////////////////////////////////////////////////////////////////////////////////
2735/// Open set parameters dialog.
2736
2738{
2739 // Get the function.
2741 //std::cout << "TFitEditor::DoSetParameters - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2742
2743 if (!fitFunc) { Error("DoSetParameters","NUll function"); return; }
2744
2745 // case of special functions (gaus, expo, etc...) if the function
2746 // has not defined the parameters yet. For those, don't let the
2747 // parameters to be all equal to 0, as we can provide some good
2748 // starting value.
2749 if (fFuncPars.size() == 0) {
2750 switch (fType) {
2751 case kObjectHisto:
2753 break;
2754 case kObjectGraph:
2756 break;
2757 case kObjectMultiGraph:
2759 break;
2760 case kObjectGraph2D:
2762 break;
2763 case kObjectHStack:
2764 case kObjectTree:
2765 default:
2766 break;
2767 }
2768 // The put these parameters into the fFuncPars structure
2770 }
2771 else {
2772 // Otherwise, put the parameters in the function
2774 }
2775
2776 if ( fParentPad ) fParentPad->Disconnect("RangeAxisChanged()");
2777 Int_t ret = 0;
2778 /// fit parameter dialog willbe deleted automatically when closed
2779 new TFitParametersDialog(gClient->GetDefaultRoot(), GetMainFrame(),
2781
2782 // Once the parameters are set in the fitfunction, save them.
2784
2785 // check return code to see if parameters settings have been modified
2786 // in this case we need to set the B option when fitting
2787 if (ret) fChangedParams = kTRUE;
2788
2789
2790 if ( fParentPad ) fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2791
2792 if ( fNone->GetState() != kButtonDisabled ) {
2793 //std::cout << "TFitEditor::DoSetParameters - deleting function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2794 delete fitFunc;
2795 }
2796}
2797
2798////////////////////////////////////////////////////////////////////////////////
2799/// Slot connected to range settings on x-axis.
2800
2802{
2803 if ( !fFitObject ) return;
2804
2807
2809
2810 DrawSelection();
2811}
2812
2813////////////////////////////////////////////////////////////////////////////////
2814/// Draws the square around the object showing where the limits for
2815/// fitting are.
2816
2818{
2819#ifndef R__HAS_COCOA
2820 static Int_t px1old, py1old, px2old, py2old; // to remember the square drawn.
2821#endif
2822
2823 if ( !fParentPad ) return;
2824
2825 if (restore) {
2826#ifndef R__HAS_COCOA
2831#endif
2832 return;
2833 }
2834
2835 Int_t px1,py1,px2,py2;
2836
2837 TVirtualPad *save = 0;
2838 save = gPad;
2839 gPad = fParentPad;
2840 gPad->cd();
2841
2842 Double_t xleft = 0;
2843 Double_t xright = 0;
2846
2847 Float_t ymin, ymax;
2848 if ( fDim > 1 )
2849 {
2850 ymin = fYaxis->GetBinLowEdge((Int_t)((fSliderY->GetMinPosition())+0.5));//gPad->GetUymin();
2851 ymax = fYaxis->GetBinUpEdge((Int_t)((fSliderY->GetMaxPosition())+0.5));//gPad->GetUymax();
2852 }
2853 else
2854 {
2855 ymin = gPad->GetUymin();
2856 ymax = gPad->GetUymax();
2857 }
2858
2859 px1 = gPad->XtoAbsPixel(xleft);
2860 py1 = gPad->YtoAbsPixel(ymin);
2861 px2 = gPad->XtoAbsPixel(xright);
2862 py2 = gPad->YtoAbsPixel(ymax);
2863
2864 if (gPad->GetCanvas()) gPad->GetCanvas()->FeedbackMode(kTRUE);
2865 gPad->SetLineWidth(1);
2866 gPad->SetLineColor(2);
2867#ifndef R__HAS_COCOA
2868 // With Cocoa XOR is fake, so no need in erasing the old box, it's
2869 // done by clearing the backing store and repainting inside a special
2870 // window.
2872
2873 px1old = px1;
2874 py1old = py1;
2875 px2old = px2;
2876 py2old = py2;
2877#endif // R__HAS_COCOA
2878 gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2879
2880 if(save) gPad = save;
2881}
2882
2883////////////////////////////////////////////////////////////////////////////////
2884/// Sincronize the numeric sliders with the graphical one.
2885
2887{
2889 float xmin, xmax;
2891 fSliderXMin->SetNumber( fXaxis->GetBinLowEdge( static_cast<Int_t>( xmin ) ) );
2892 fSliderXMax->SetNumber( fXaxis->GetBinUpEdge ( static_cast<Int_t>( xmax ) ) );
2893 return;
2894 }
2895
2898
2900
2901 DrawSelection();
2902}
2903
2904////////////////////////////////////////////////////////////////////////////////
2905/// Slot connected to range settings on y-axis.
2906
2908{
2909 if ( !fFitObject ) return;
2910
2913
2915
2916 DrawSelection();
2917}
2918
2919////////////////////////////////////////////////////////////////////////////////
2920///syncronize the numeric slider with the graphical one.
2921
2923{
2925 float ymin, ymax;
2927 fSliderYMin->SetNumber( fYaxis->GetBinLowEdge( static_cast<Int_t>( ymin ) ) );
2928 fSliderYMax->SetNumber( fYaxis->GetBinUpEdge ( static_cast<Int_t>( ymax ) ) );
2929 return;
2930 }
2931
2934
2936
2937 DrawSelection();
2938}
2939
2940////////////////////////////////////////////////////////////////////////////////
2941/// Slot connected to range settings on z-axis.
2942
2946
2947////////////////////////////////////////////////////////////////////////////////
2948/// Open a dialog for getting a user defined method.
2949
2951{
2953 "Info", "Dialog of user method is not implemented yet",
2955}
2956
2957////////////////////////////////////////////////////////////////////////////////
2958/// Set the function to be used in performed fit.
2959
2960void TFitEditor::SetFunction(const char *function)
2961{
2962 fEnteredFunc->SetText(function);
2963}
2964
2965////////////////////////////////////////////////////////////////////////////////
2966/// Check whether the object suitable for fitting and set
2967/// its type, dimension and method combo box accordingly.
2968
2970{
2971 Bool_t set = kFALSE;
2972
2973 // For each kind of object, set a different status in the fit
2974 // panel.
2975 if (obj->InheritsFrom(TGraph::Class())) {
2977 set = kTRUE;
2978 fDim = 1;
2980 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2983 fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
2984 } else if (obj->InheritsFrom(TGraph2D::Class())) {
2986 set = kTRUE;
2987 fDim = 2;
2989 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2991 } else if (obj->InheritsFrom(THStack::Class())) {
2993 set = kTRUE;
2994 TH1 *hist = (TH1 *)((THStack *)obj)->GetHists()->First();
2995 fDim = hist->GetDimension();
2997 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2999 } else if (obj->InheritsFrom(TTree::Class())) {
3001 set = kTRUE;
3002 TString variables, cuts;
3003 GetTreeVarsAndCuts(fDataSet, variables, cuts);
3004 fDim = 1;
3005 for ( int i = 0; i < variables.Length() && fDim <= 2; ++i )
3006 if ( ':' == variables[i] ) fDim += 1;
3007 // For any three of dimension bigger than 2, set the dimension
3008 // to 0, as we cannot infer the dimension from the TF1s, it's
3009 // better to have 0 as reference.
3010 if ( fDim > 2 ) fDim = 0;
3012 fMethodList->AddEntry("Unbinned Likelihood", kFP_MUBIN);
3014 } else if (obj->InheritsFrom(TH1::Class())){
3016 set = kTRUE;
3017 fDim = ((TH1*)obj)->GetDimension();
3019 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
3020 fMethodList->AddEntry("Binned Likelihood", kFP_MBINL);
3022 } else if (obj->InheritsFrom(TMultiGraph::Class())) {
3024 set = kTRUE;
3025 fDim = 1;
3027 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
3030 fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
3031 }
3032
3033 // Depending on the dimension of the object, allow the
3034 // visualization of sliders.
3035 if ( fDim < 2 || fType == kObjectTree )
3037 else
3039
3040 if ( fDim < 1 || fType == kObjectTree )
3042 else
3044
3045 // And also, depending on the dimension, add predefined functions.
3046 if ( fDim == 1 ) {
3047 if ( !fTypeFit->FindEntry("Predef-1D") )
3049 } else {
3050 if ( fTypeFit->FindEntry("Predef-1D") )
3052 }
3053
3054 if ( fDim == 2 ) {
3055 if ( !fTypeFit->FindEntry("Predef-2D") )
3057 } else {
3058 if ( fTypeFit->FindEntry("Predef-2D") )
3060 }
3061
3062 return set;
3063}
3064
3065////////////////////////////////////////////////////////////////////////////////
3066/// Show object name on the top.
3067
3069{
3070 TString name;
3071 bool isTree = false;
3072
3073 // Build the string to be compared to look for the object.
3074 if (obj) {
3075 name = obj->ClassName();
3076 name.Append("::");
3077 name.Append(obj->GetName());
3078 isTree = strcmp(obj->ClassName(), "TTree") == 0;
3079 } else {
3080 name = "No object selected";
3081 }
3082 fStatusBar->SetText(name.Data(),0);
3083
3084 // If the selection was done in the fDataSet combo box, there is no need
3085 // to search through the list
3087 if ( selectedEntry ) {
3088 TString selectedName = selectedEntry->GetText()->GetString();
3089 if ( isTree )
3090 selectedName = selectedName(0, selectedName.First(' '));
3091 if ( name.CompareTo(selectedName) == 0 ) {
3092 Layout();
3093 return;
3094 }
3095 }
3096
3097 // Search through the list for the object
3099 bool found = false;
3100 while ( TGTextLBEntry* entry = static_cast<TGTextLBEntry*>
3101 ( fDataSet->GetListBox()->GetEntry(entryId)) ) {
3102 TString compareName = entry->GetText()->GetString();
3103 if ( isTree )
3104 compareName = compareName(0, compareName.First(' '));
3105 if ( name.CompareTo(compareName) == 0 ) {
3106 // If the object is found, select it
3107 fDataSet->Select(entryId, false);
3108 found = true;
3109 break;
3110 }
3111 entryId += 1;
3112 }
3113
3114 // If the object was not found, add it and select it.
3115 if ( !found ) {
3116 fDataSet->AddEntry(name.Data(), entryId);
3118 }
3119
3120 Layout();
3121}
3122
3123////////////////////////////////////////////////////////////////////////////////
3124/// Get draw options of the selected object.
3125
3127{
3128 if (!fParentPad) return "";
3129
3131 TObject *obj;
3132 while ((obj = next())) {
3133 if (obj == fFitObject) return next.GetOption();
3134 }
3135 return "";
3136}
3137
3138////////////////////////////////////////////////////////////////////////////////
3139/// Set selected minimization library in use.
3140
3142{
3144 Int_t id = bt->WidgetId();
3145
3146 switch (id) {
3147
3148 // Depending on the selected library, set the state of the rest
3149 // of the buttons.
3150 case kFP_LMIN:
3151 {
3152 if (on) {
3156 if ( fLibGSL->GetState() != kButtonDisabled )
3160 fStatusBar->SetText("LIB Minuit", 1);
3161 }
3162
3163 }
3164 break;
3165
3166 case kFP_LMIN2:
3167 {
3168 if (on) {
3172 if ( fLibGSL->GetState() != kButtonDisabled )
3176 fStatusBar->SetText("LIB Minuit2", 1);
3177 }
3178 }
3179 break;
3180
3181 case kFP_LFUM:
3182 {
3183 if (on) {
3187 if ( fLibGSL->GetState() != kButtonDisabled )
3191 fStatusBar->SetText("LIB Fumili", 1);
3192 }
3193 }
3194 break;
3195 case kFP_LGSL:
3196 {
3197 if (on) {
3201 if ( fLibGSL->GetState() != kButtonDisabled )
3205 fStatusBar->SetText("LIB GSL", 1);
3206 }
3207 }
3208 break;
3209 case kFP_LGAS:
3210 {
3211 if (on) {
3215 if ( fLibGSL->GetState() != kButtonDisabled )
3219 fStatusBar->SetText("LIB Genetics", 1);
3220 }
3221 }
3222 default:
3223 break;
3224 }
3226}
3227
3228////////////////////////////////////////////////////////////////////////////////
3229/// Set selected minimization method in use.
3230
3232{
3234 fStatusBar->SetText("MIGRAD",2);
3235 else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3236 fStatusBar->SetText("FUMILI",2);
3237 else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3238 fStatusBar->SetText("SIMPLEX",2);
3239 else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3240 fStatusBar->SetText("SCAN",2);
3242 fStatusBar->SetText("Combination",2);
3243 else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3244 fStatusBar->SetText("CONJFR",2);
3245 else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3246 fStatusBar->SetText("CONJPR",2);
3247 else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3248 fStatusBar->SetText("BFGS",2);
3249 else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3250 fStatusBar->SetText("BFGS2",2);
3251 else if ( fMinMethodList->GetSelected() == kFP_GSLLM )
3252 fStatusBar->SetText("GSLLM",2);
3253 else if ( fMinMethodList->GetSelected() == kFP_GSLSA)
3254 fStatusBar->SetText("SimAn",2);
3255 else if ( fMinMethodList->GetSelected() == kFP_TMVAGA )
3256 fStatusBar->SetText("TMVAGA",2);
3257 else if ( fMinMethodList->GetSelected() == kFP_GALIB )
3258 fStatusBar->SetText("GALIB",2);
3259
3260
3261}
3262
3263////////////////////////////////////////////////////////////////////////////////
3264/// Set the maximum number of iterations.
3265
3267{
3269 fStatusBar->SetText(Form("Itr: %ld",itr),2);
3270}
3271
3272////////////////////////////////////////////////////////////////////////////////
3273/// Create section title in the GUI.
3274
3275void TFitEditor::MakeTitle(TGCompositeFrame *parent, const char *title)
3276{
3277 TGCompositeFrame *ht = new TGCompositeFrame(parent, 350, 10,
3279 ht->AddFrame(new TGLabel(ht, title),
3280 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
3281 ht->AddFrame(new TGHorizontal3DLine(ht),
3282 new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 5, 5, 2, 2));
3283 parent->AddFrame(ht, new TGLayoutHints(kLHintsTop, 5, 0, 5, 0));
3284}
3285
3286////////////////////////////////////////////////////////////////////////////////
3287/// Look in the list of function for TF1. If a TF1 is
3288/// found in the list of functions, it will be returned
3289
3291{
3292 // Get the list of functions of the fit object
3294 TF1* func = 0;
3295
3296 // If it exists
3297 if ( lf ) {
3298 // Add the posibility to select previous fit function
3299 if ( !fTypeFit->FindEntry("Prev. Fit") )
3301
3302 // Then add all these functions to the fPrefFit structure.
3303 TObject *obj2;
3304 TIter next(lf, kIterForward);
3305 // Go over all the elements in lf
3306 while ((obj2 = next())) {
3307 if (obj2->InheritsFrom(TF1::Class())) {
3308 func = (TF1 *)obj2;
3309 fPrevFitIter it;
3310 // No go over all elements in fPrevFit
3311 for ( it = fPrevFit.begin(); it != fPrevFit.end(); ++it) {
3312 // To see wheather the object corresponds with fFitObject
3313 if ( it->first != fFitObject ) continue;
3314 // And if so, whether the function is already included
3315 if ( strcmp( func->GetName(), it->second->GetName() ) == 0 )
3316 break;
3317 if ( strcmp( func->GetName(), "PrevFitTMP" ) == 0 )
3318 break;
3319 }
3320 // Only if the function is not already in fPrevFit, the
3321 // breaks in the loops would make it to be different to
3322 // fPrevFit.end() if the function is already stored
3323 if ( it == fPrevFit.end() ) {
3324 fPrevFit.emplace(fFitObject, copyTF1(func));
3325 }
3326 }
3327 }
3328
3329 // Select the PrevFit set
3331 // And fill the function list
3334
3335
3336 } else {
3337 // If there is no prev fit functions.
3339 // Call FillFunctionList as it might happen that the user is
3340 // changing from a TTree to another one, and thus the fFuncList
3341 // if not properly filled
3343 }
3344
3346
3347 return func;
3348}
3349
3350////////////////////////////////////////////////////////////////////////////////
3351/// Retrieve the fitting options from all the widgets.
3352
3354{
3355 drawOpts = "";
3356
3357 fitOpts.Range = (fUseRange->GetState() == kButtonDown);
3358 fitOpts.Integral = (fIntegral->GetState() == kButtonDown);
3360 fitOpts.Errors = (fBestErrors->GetState() == kButtonDown);
3362
3364 fitOpts.W1 = 2;
3365 else if (fAllWeights1->GetState() == kButtonDown)
3366 fitOpts.W1 = 1;
3367
3369 if ( !(fLinearFit->GetState() == kButtonDown) &&
3370 (tmpStr.Contains("pol") || tmpStr.Contains("++")) )
3371 fitOpts.Minuit = 1;
3372
3373 // if ( (int) fFuncPars.size() == npar )
3374 // for ( Int_t i = 0; i < npar; ++i )
3375 // if ( fFuncPars[i][PAR_MIN] != fFuncPars[i][PAR_MAX] )
3376 //
3377
3378 // //fitOpts.Bound = 1;
3379 // break;
3380 // }
3381
3382 if (fChangedParams) {
3383 //std::cout << "Params have changed setting the Bound option " << std::endl;
3384 fitOpts.Bound = 1;
3385 fChangedParams = kFALSE; // reset
3386 }
3387
3388 //fitOpts.Nochisq = (fNoChi2->GetState() == kButtonDown);
3389 fitOpts.Nostore = (fNoStoreDrawing->GetState() == kButtonDown);
3390 fitOpts.Nograph = (fNoDrawing->GetState() == kButtonDown);
3392 fitOpts.Gradient = (fUseGradient->GetState() == kButtonDown);
3393 fitOpts.Quiet = ( fOptQuiet->GetState() == kButtonDown );
3394 fitOpts.Verbose = ( fOptVerbose->GetState() == kButtonDown );
3395
3396 if ( !(fType != kObjectGraph) && (fEnableRobust->GetState() == kButtonDown) )
3397 {
3398 fitOpts.Robust = 1;
3399 fitOpts.hRobust = fRobustValue->GetNumber();
3400 }
3401
3403
3404 if ( fLibMinuit->GetState() == kButtonDown )
3405 minOpts.SetMinimizerType ( "Minuit");
3406 else if ( fLibMinuit2->GetState() == kButtonDown)
3407 minOpts.SetMinimizerType ( "Minuit2" );
3408 else if ( fLibFumili->GetState() == kButtonDown )
3409 minOpts.SetMinimizerType ("Fumili" );
3410 else if ( fLibGSL->GetState() == kButtonDown )
3411 minOpts.SetMinimizerType ("GSLMultiMin" );
3412
3414 minOpts.SetMinimizerAlgorithm( "Migrad" );
3415 else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3416 if ( fLibMinuit2->GetState() == kButtonDown )
3417 minOpts.SetMinimizerAlgorithm( "Fumili2" );
3418 else
3419 minOpts.SetMinimizerAlgorithm( "Fumili" );
3420 else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3421 minOpts.SetMinimizerAlgorithm( "Simplex" );
3422 else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3423 minOpts.SetMinimizerAlgorithm( "Scan" );
3425 minOpts.SetMinimizerAlgorithm( "Minimize" );
3426 else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3427 minOpts.SetMinimizerAlgorithm( "conjugatefr" );
3428 else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3429 minOpts.SetMinimizerAlgorithm( "conjugatepr" );
3430 else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3431 minOpts.SetMinimizerAlgorithm( "bfgs" );
3432 else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3433 minOpts.SetMinimizerAlgorithm( "bfgs2" );
3434 else if ( fMinMethodList->GetSelected() == kFP_GSLLM ) {
3435 minOpts.SetMinimizerType ("GSLMultiFit" );
3436 minOpts.SetMinimizerAlgorithm( "" );
3437 } else if ( fMinMethodList->GetSelected() == kFP_GSLSA) {
3438 minOpts.SetMinimizerType ("GSLSimAn" );
3439 minOpts.SetMinimizerAlgorithm( "" );
3440 } else if ( fMinMethodList->GetSelected() == kFP_TMVAGA) {
3441 minOpts.SetMinimizerType ("Geneti2c" );
3442 minOpts.SetMinimizerAlgorithm( "" );
3443 } else if ( fMinMethodList->GetSelected() == kFP_GALIB) {
3444 minOpts.SetMinimizerType ("GAlibMin" );
3445 minOpts.SetMinimizerAlgorithm( "" );
3446 }
3447
3448 minOpts.SetErrorDef ( fErrorScale->GetNumber() );
3449 minOpts.SetTolerance( fTolerance->GetNumber() );
3450 minOpts.SetMaxIterations(fIterations->GetIntNumber());
3451 minOpts.SetMaxFunctionCalls(fIterations->GetIntNumber());
3452}
3453
3455{
3456 // Set the state of some input widgets depending on whether the fit
3457 // function can be defined by text or if it is an existing one.
3458 if ( state )
3459 {
3460 fEnteredFunc-> SetState(kTRUE);
3461 fAdd -> SetState(kButtonUp, kFALSE);
3462 fNormAdd -> SetState(kButtonUp, kFALSE);
3463 fConv -> SetState(kButtonUp, kFALSE);
3464 fNone -> SetState(kButtonDown,kFALSE); // fNone::State is the one used as reference
3465 }
3466 else
3467 {
3468 fEnteredFunc-> SetState(kFALSE);
3469 fAdd -> SetState(kButtonDisabled, kFALSE);
3470 fNormAdd -> SetState(kButtonDisabled, kFALSE);
3471 fConv -> SetState(kButtonDisabled, kFALSE);
3472 fNone -> SetState(kButtonDisabled, kFALSE);
3473 }
3474}
3475
3477{
3478 // Return the ranges selected by the sliders.
3479
3480 // It's not working for trees as they don't have TAxis.
3481 if ( fType == kObjectTree ) return;
3482
3483 if ( fType != kObjectTree ) {
3488 drange.AddRange(0,xmin, xmax);
3489 }
3490
3491 if ( fDim > 1 ) {
3492 assert(fYaxis);
3497 drange.AddRange(1,ymin, ymax);
3498 }
3499 if ( fDim > 2 ) {
3500 assert(fZaxis);
3505 drange.AddRange(2,zmin, zmax);
3506 }
3507}
3508
3510{
3511 // Get the list of functions previously used in the fitobject.
3512
3514 if ( fFitObject ) {
3515 switch (fType) {
3516
3517 case kObjectHisto:
3518 listOfFunctions = ((TH1 *)fFitObject)->GetListOfFunctions();
3519 break;
3520
3521 case kObjectGraph:
3522 listOfFunctions = ((TGraph *)fFitObject)->GetListOfFunctions();
3523 break;
3524
3525 case kObjectMultiGraph:
3526 listOfFunctions = ((TMultiGraph *)fFitObject)->GetListOfFunctions();
3527 break;
3528
3529 case kObjectGraph2D:
3530 listOfFunctions = ((TGraph2D *)fFitObject)->GetListOfFunctions();
3531 break;
3532
3533 case kObjectHStack:
3534 case kObjectTree:
3535 default:
3536 break;
3537 }
3538 }
3539 return listOfFunctions;
3540}
3541
3543{
3544 // Looks for all the functions registered in the current ROOT
3545 // session.
3546
3547 // First, clean the copies stored in fSystemFunc
3548 for (auto func : fSystemFuncs)
3549 delete func;
3550
3551 fSystemFuncs.clear();
3552
3553 // Be carefull not to store functions that will be in the
3554 // predefined section
3555 const unsigned int nfuncs = 16;
3556 const char* fnames[nfuncs] = { "gaus" , "gausn", "expo", "landau",
3557 "landaun", "pol0", "pol1", "pol2",
3558 "pol3", "pol4", "pol5", "pol6",
3559 "pol7", "pol8", "pol9", "user"
3560 };
3561
3562 // No go through all the objects registered in gROOT
3563 TIter functionsIter(gROOT->GetListOfFunctions());
3564 TObject* obj;
3565 while( ( obj = (TObject*) functionsIter() ) ) {
3566 // And if they are TF1s
3567 if ( TF1* func = dynamic_cast<TF1*>(obj) ) {
3568 bool addFunction = true;
3569 // And they are not already registered in fSystemFunc
3570 for ( unsigned int i = 0; i < nfuncs; ++i ) {
3571 if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3572 addFunction = false;
3573 break;
3574 }
3575 }
3576 // Add them.
3577 if ( addFunction )
3578 fSystemFuncs.emplace_back( copyTF1(func) );
3579 }
3580 }
3581}
3582
3584{
3585 // This function returns a TList with all the functions used in the
3586 // FitPanel to fit a given object. If the object passed is NULL,
3587 // then the object used is the currently selected one. It is
3588 // important to notice that the FitPanel is still the owner of
3589 // those functions. This means that the user SHOULD NOT delete any
3590 // of these functions, as the FitPanel will do so in the
3591 // destructor.
3592
3593 if (!obj) obj = fFitObject;
3594
3595 TList *retList = new TList();
3596
3597 std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(obj);
3598 for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
3599 retList->Add(it->second);
3600 }
3601
3602 return retList;
3603}
3604
3606{
3607 // Get the fit function selected or declared in the fiteditor
3608
3609 TF1 *fitFunc = 0;
3610 // If the function is not editable ==> it means it is registered in
3611 // gROOT
3612 if ( fNone->GetState() == kButtonDisabled )
3613 {
3614 // So we find it
3615 TF1* tmpF1 = FindFunction();
3616 // And if we don't find it, then it means there is something wrong!
3617 if ( tmpF1 == 0 )
3618 {
3620 "Error...", "1) Verify the entered function string!",
3621 kMBIconStop,kMBOk, 0);
3622 return 0;
3623 }
3624
3625 // Now we make a copy that will be used temporary. The caller of
3626 // the function should delete the returned function.
3627 fitFunc = (TF1*)tmpF1->IsA()->New();
3628 tmpF1->Copy(*fitFunc);
3629 // Copy the parameters of the function, if and only if the
3630 // parameters stored does not correspond with the ones of these
3631 // functions. Perhaps the user has already called
3632 // DoSetParameters. There is no way to know whether the
3633 // parameters have been modified, so we check the size of
3634 // fFuncPars against number of parameters.
3635 if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3636 {
3637 fitFunc->SetParameters(tmpF1->GetParameters());
3639 } else {
3641 }
3642 }
3643
3644 // If, we have no function at this point, it means that is is
3645 // described in fEnteredFunc, so we create it from scratch.
3646 if ( fitFunc == 0 )
3647 {
3650 double xmin, xmax, ymin, ymax, zmin, zmax;
3651 drange.GetRange(xmin, xmax, ymin, ymax, zmin, zmax);
3652
3653 // Depending of course on the number of dimensions the object
3654 // has. These commands will raise an error message if the user
3655 // has not defined the function properly
3656 if ( fDim == 1 || fDim == 0 )
3657 {
3658
3659 fitFunc = new TF1("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax );
3660 //std::cout << "GetFitFunction - created function PrevFitTMP " << fEnteredFunc->GetText() << " " << fitFunc << std::endl;
3661 if (fNormAdd->IsOn())
3662 {
3663 if (fSumFunc) delete fSumFunc;
3665 fitFunc = new TF1("PrevFitTMP", *fSumFunc, xmin, xmax, fSumFunc->GetNpar());
3666 for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fSumFunc->GetParName(i) );
3667 //std::cout << "create fit normalized function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3668 }
3669
3670 if (fConv -> IsOn())
3671 {
3672 if (fConvFunc) delete fConvFunc;
3674 fitFunc = new TF1("PrevFitTMP", *fConvFunc, xmin, xmax, fConvFunc->GetNpar());
3675 for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fConvFunc->GetParName(i) );
3676 //std::cout << "create fit convolution function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3677 }
3678 }
3679 else if ( fDim == 2 ) {
3680 fitFunc = new TF2("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax );
3681 }
3682 else if ( fDim == 3 ) {
3683 fitFunc = new TF3("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax, zmin, zmax );
3684 }
3685
3686 // if the function is not a C defined
3687 if ( fNone->GetState() != kButtonDisabled )
3688 {
3689 // and the formulas are the same
3690 TF1* tmpF1 = FindFunction();
3691// if (tmpF1)
3692 //std::cout << "GetFitFunction: found existing function " << tmpF1 << " " << tmpF1->GetName() << " " << tmpF1->GetExpFormula() << std::endl;
3693// else
3694 //std::cout << "GetFitFunction: - no existing function found " << std::endl;
3695 if ( tmpF1 != 0 && fitFunc != 0 &&
3696 strcmp(tmpF1->GetExpFormula(), fEnteredFunc->GetText()) == 0 ) {
3697 // copy everything from the founction available in gROOT
3698 //std::cout << "GetFitFunction: copying tmp function in PrevFitTMP " << tmpF1->GetName() << " "
3699 // << tmpF1->GetExpFormula() << std::endl;
3700 tmpF1->Copy(*fitFunc);
3701 if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3702 {
3704 }
3705 }
3706 }
3707 }
3708
3709 return fitFunc;
3710}
@ kButton1Down
Definition Buttons.h:17
@ kWatch
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:375
@ 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
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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
const Bool_t kIterForward
Definition TCollection.h:42
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
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:33
@ kObjectGraph
Definition TFitEditor.h:29
@ kObjectHStack
Definition TFitEditor.h:31
@ kObjectHisto
Definition TFitEditor.h:28
@ kObjectGraph2D
Definition TFitEditor.h:30
@ kObjectTree
Definition TFitEditor.h:32
@ 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:157
@ kDoubleScaleBoth
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconAsterisk
Definition TGMsgBox.h:25
@ kMBIconStop
Definition TGMsgBox.h:22
@ kTextLeft
Definition TGWidget.h:23
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
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:411
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
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
Class describing the un-binned data sets (just x coordinates values) of any dimensions.
Definition UnBinData.h:46
static const std::string & DefaultMinimizerType()
const_iterator begin() const
const_iterator end() const
Allows to create advanced graphics from the last fit made in the fitpanel.
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:293
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:522
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:473
Int_t GetNbins() const
Definition TAxis.h:127
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:532
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:462
The Canvas class.
Definition TCanvas.h:23
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:182
virtual Int_t GetNumber() const
Definition TF1.h:478
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition TF1.cxx:1967
static TClass * Class()
virtual Int_t GetNpar() const
Definition TF1.h:461
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
Definition TF1.cxx:3539
virtual void SetParameter(Int_t param, Double_t value)
Definition TF1.h:623
virtual Double_t GetParameter(Int_t ipar) const
Definition TF1.h:492
A 2-Dim function with parameters.
Definition TF2.h:29
TF3 defines a 3D Function with Parameters.
Definition TF3.h:28
Allows to perform, explore and compare various fits.
Definition TFitEditor.h:54
TList * GetListOfFittingFunctions(TObject *obj=nullptr)
TGCheckButton * fBestErrors
switch on/off option 'improve errors'
Definition TFitEditor.h:81
TF1 * FindFunction()
This method looks among the functions stored by the fitpanel, the one that is currently selected in t...
TGDoubleHSlider * fSliderX
slider to set fit range along x-axis
Definition TFitEditor.h:95
static TFitEditor * GetInstance(TVirtualPad *pad=nullptr, TObject *obj=nullptr)
Static method - opens the fit panel.
TFitEditor(const TFitEditor &)
TGComboBox * fMinMethodList
Definition TFitEditor.h:138
void CloseWindow() override
Close fit panel window.
TGTextButton * fSetParam
open set parameters dialog
Definition TFitEditor.h:79
void CreateGeneralTab()
Create 'General' tab.
virtual void DoUpdate()
Easy here!
TGLayoutHints * fLayoutNormAdd
layout hints of fNOrmAdd radio button
Definition TFitEditor.h:77
TGNumberEntry * fSliderXMax
entry to set the maximum in the range
Definition TFitEditor.h:96
virtual void DoConvolution(Bool_t on)
Slot connected to addition of predefined functions.
TGNumberEntry * fSliderXMin
entry to set the minumum in the range
Definition TFitEditor.h:97
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:131
TGCheckButton * fDrawSame
switch on/off fit function drawing
Definition TFitEditor.h:93
TGRadioButton * fLibMinuit
Definition TFitEditor.h:133
TGRadioButton * fConv
set convolution mode
Definition TFitEditor.h:74
TVirtualPad * fParentPad
pad containing the object
Definition TFitEditor.h:110
TGRadioButton * fOptDefault
set default printing mode
Definition TFitEditor.h:107
TGCheckButton * fLinearFit
switch on/off linear fit option
Definition TFitEditor.h:89
TGRadioButton * fLibMinuit2
Definition TFitEditor.h:134
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
switch on/off option 'use function range'
Definition TFitEditor.h:82
virtual void DoSliderXMoved()
Slot connected to range settings on x-axis.
TAxis * fYaxis
y-axis
Definition TFitEditor.h:115
TGTextButton * fDrawAdvanced
opens a dialog for advanced draw options
Definition TFitEditor.h:94
TGComboBox * fTypeFit
contains the types of functions to be selected
Definition TFitEditor.h:67
virtual void DoReset()
Reset all fit parameters.
TGNumberEntryField * fTolerance
Definition TFitEditor.h:140
TGCheckButton * fNoDrawing
switch on/off 'no drawing' option
Definition TFitEditor.h:92
TF1 * GetFitFunction()
TGHorizontalFrame * fSliderZParent
parent of fSliderZ
Definition TFitEditor.h:104
virtual void DoSetParameters()
Open set parameters dialog.
TGCompositeFrame * fMinimization
minimization tab
Definition TFitEditor.h:60
TGTab * fTab
tab widget holding the editor
Definition TFitEditor.h:57
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
! TF1NormSum object
Definition TFitEditor.h:117
TGComboBox * fMethodList
contains method list
Definition TFitEditor.h:88
TGDoubleHSlider * fSliderY
slider to set fit range along y-axis
Definition TFitEditor.h:98
void ShowObjectName(TObject *obj)
Show object name on the top.
static TFitEditor * fgFitDialog
Definition TFitEditor.h:147
TList * GetFitObjectListOfFunctions()
virtual void DoAdvancedOptions()
Slot connected to advanced option button (opens a dialog).
TGRadioButton * fLibFumili
Definition TFitEditor.h:135
virtual void DoDataSet(Int_t sel)
Selects the data set to be fitted.
TGRadioButton * fAdd
set addition mode
Definition TFitEditor.h:72
TGComboBox * BuildMethodList(TGFrame *parent, Int_t id)
Create method list in a combo box.
void CreateMinimizationTab()
Create 'Minimization' tab.
TGRadioButton * fLibGenetics
Definition TFitEditor.h:137
TGCheckButton * fImproveResults
switch on/off option 'improve fit results'
Definition TFitEditor.h:86
TGComboBox * fFuncList
contains function list
Definition TFitEditor.h:68
TF1Convolution * fConvFunc
! TF1Convolution object
Definition TFitEditor.h:118
TGCheckButton * fUseGradient
switch on/off option 'use gradient'
Definition TFitEditor.h:84
TGRadioButton * fNormAdd
set normalized addition mode
Definition TFitEditor.h:73
virtual void SetCanvas(TCanvas *c)
Connect to another canvas.
EObjectType fType
object type info
Definition TFitEditor.h:112
TGNumberEntryField * fIterations
Definition TFitEditor.h:141
TGCompositeFrame * fTabContainer
main tab container
Definition TFitEditor.h:58
virtual void DoFunction(Int_t sel)
Slot connected to predefined fit function settings.
virtual void DoUseFuncRange()
TGComboBox * fDataSet
contains list of data set to be fitted
Definition TFitEditor.h:66
virtual void ConnectSlots()
Connect GUI signals to fit panel slots.
virtual void DoFit()
Perform a fit with current parameters' settings.
TAxis * fZaxis
z-axis
Definition TFitEditor.h:116
TGRadioButton * fOptVerbose
set printing mode to 'Verbose'
Definition TFitEditor.h:108
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
opens a dialog for user-defined fit method
Definition TFitEditor.h:70
~TFitEditor() override
Fit editor destructor.
TGDoubleHSlider * fSliderZ
slider to set fit range along z-axis
Definition TFitEditor.h:101
TGTextButton * fFitButton
performs fitting
Definition TFitEditor.h:62
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:128
TGHorizontalFrame * fSliderYParent
parent of fSliderY
Definition TFitEditor.h:103
TGCheckButton * fNoChi2
switch on/off option 'No Chi-square'
Definition TFitEditor.h:90
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.
TGTextButton * fUpdateButton
updates data from gROOT and gDirectory
Definition TFitEditor.h:61
TGTextEntry * fEnteredFunc
contains user function file name
Definition TFitEditor.h:69
TGCheckButton * fIntegral
switch on/off option 'integral'
Definition TFitEditor.h:80
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:139
void SetEditable(Bool_t) override
Option_t * GetDrawOption() const override
Get draw options of the selected object.
TAxis * fXaxis
x-axis
Definition TFitEditor.h:114
std::vector< FuncParamData_t > FuncParams_t
Definition TFitEditor.h:239
TGLayoutHints * fLayoutAdd
layout hints of fAdd radio button
Definition TFitEditor.h:76
TGHorizontalFrame * fSliderXParent
parent of fSliderX
Definition TFitEditor.h:102
void ProcessTreeInput(TObject *objSelected, Int_t selected, TString variables, TString cuts)
TGCheckButton * fEnableRobust
switch on/off robust option
Definition TFitEditor.h:105
void DrawSelection(bool restore=false)
Draws the square around the object showing where the limits for fitting are.
TGCheckButton * fEmptyBinsWghts1
switch on/off option 'include empry bins'
Definition TFitEditor.h:87
virtual void DoSliderZMoved()
Slot connected to range settings on z-axis.
Int_t fDim
object dimension
Definition TFitEditor.h:113
TGNumberEntry * fSliderYMin
entry to set the minumum in the range
Definition TFitEditor.h:100
void GetRanges(ROOT::Fit::DataRange &)
std::multimap< TObject *, TF1 * > fPrevFit
Definition TFitEditor.h:130
TGNumberEntry * fRobustValue
contains robust value for linear fit
Definition TFitEditor.h:106
TGNumberEntry * fSliderYMax
entry to set the maximum in the range
Definition TFitEditor.h:99
virtual void DoNoChi2()
Slot connected to 'no chi2' option settings.
TGCheckButton * fAdd2FuncList
switch on/off option 'add to list'
Definition TFitEditor.h:83
TGCompositeFrame * fGeneral
general tab
Definition TFitEditor.h:59
virtual void DisconnectSlots()
Disconnect GUI signals from fit panel slots.
void GetFunctionsFromSystem()
TGRadioButton * fOptQuiet
set printing mode to 'Quiet'
Definition TFitEditor.h:109
void FillMinMethodList(Int_t selected=-1)
Fills the list of methods depending on the minimization library selected.
TGCheckButton * fNoStoreDrawing
switch on/off 'no store/drwing' option
Definition TFitEditor.h:91
TGCheckButton * fAllWeights1
switch on/off option 'all weights=1'
Definition TFitEditor.h:85
TGRadioButton * fNone
set no operation mode
Definition TFitEditor.h:71
TGLayoutHints * fLayoutConv
layout hints of fConv radio button
Definition TFitEditor.h:78
TGTextButton * fResetButton
resets fit parameters
Definition TFitEditor.h:63
void CreateFunctionGroup()
Creates the Frame that contains oll the information about the function.
TGLayoutHints * fLayoutNone
layout hints of fNone radio button
Definition TFitEditor.h:75
TGLabel * fSelLabel
contains selected fit function
Definition TFitEditor.h:65
TGRadioButton * fLibGSL
Definition TFitEditor.h:136
Int_t CheckFunctionString(const char *str)
Check entered function string.
void RecursiveRemove(TObject *obj) override
When obj is deleted, clear fFitObject if fFitObject = obj.
TObject * fFitObject
selected object to fit
Definition TFitEditor.h:111
virtual void DoRobustFit()
Slot connected to 'robust fitting' option settings.
TGTextButton * fCloseButton
close the fit panel
Definition TFitEditor.h:64
virtual void DoAddition(Bool_t on)
Slot connected to addition of predefined functions.
Bool_t fChangedParams
Definition TFitEditor.h:145
TGStatusBar * fStatusBar
Definition TFitEditor.h:143
virtual void DoUserDialog()
Open a dialog for getting a user defined method.
virtual void DoNumericSliderXChanged()
Sincronize the numeric sliders with the graphical one.
Create a dialog for fit function parameter settings.
The Formula class.
Definition TFormula.h:89
A button abstract base class.
Definition TGButton.h:68
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
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:453
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
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
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual Int_t GetSelected() const
Definition TGComboBox.h:114
void RemoveAll() override
Remove all entries from combo box.
virtual TGLBEntry * GetSelectedEntry() const
Definition TGComboBox.h:115
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
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:110
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:92
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
virtual Int_t GetNumberOfEntries() const
Definition TGComboBox.h:107
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1210
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
Dragging the slider will generate the event:
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)
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
void MapWindow() override
map window
Definition TGFrame.h:206
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
UInt_t GetHeight() const
Definition TGFrame.h:227
A composite frame with a border and a title.
Definition TGFrame.h:524
Organizes TGButton widgets in a group with one horizontal row.
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
Basic listbox entries.
Definition TGListBox.h:24
This class handles GUI labels.
Definition TGLabel.h:24
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
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition TGFrame.cxx:1850
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1793
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1885
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1780
virtual Long_t GetIntNumber() const
Get the numeric value (integer representation).
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
Set the numeric value (floating point representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
void ReturnPressed() override
Return was pressed.
virtual void SetIntNumber(Long_t val, Bool_t emit=kTRUE)
Set the numeric value (integer representation).
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
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
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEAPositive
Positive number.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNESReal
Real number.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELNoLimits
Limit selection of number entry field.
@ kNELLimitMinMax
Both lower and upper limits.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Selects different options.
Definition TGButton.h:321
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set radio button state.
Bool_t IsOn() const override
Definition TGButton.h:369
Provides a StatusBar widget.
Definition TGStatusBar.h:21
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.
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:373
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
const char * GetTitle() const override
Returns title of object.
const char * GetText() const
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.
Text string listbox entries.
Definition TGListBox.h:48
A composite frame that layout their children in vertical way.
Definition TGFrame.h:376
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
const TGWindow * GetParent() const
Definition TGWindow.h:83
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition TGraph2D.h:41
static TClass * Class()
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
static TClass * Class()
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TAxis * GetZaxis()
Definition TH1.h:573
static TClass * Class()
virtual Int_t GetDimension() const
Definition TH1.h:527
TAxis * GetXaxis()
Definition TH1.h:571
TAxis * GetYaxis()
Definition TH1.h:572
The Histogram stack class.
Definition THStack.h:40
static TClass * Class()
Iterator of linked list.
Definition TList.h:196
Option_t * GetOption() const override
Returns the object option stored in the list.
Definition TList.cxx:1274
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
static TClass * Class()
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
void ls(Option_t *option="") const override
List TNamed name and title.
Definition TNamed.cxx:112
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:501
The most important graphics class in the ROOT system.
Definition TPad.h:28
TPluginHandler * FindHandler(const char *base, const char *uri=nullptr)
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:865
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
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:138
const char * Data() const
Definition TString.h:384
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:2384
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition TString.cxx:1407
Tree Input Dialog Widget.
Definition TTreeInput.h:22
A TTree represents a columnar dataset.
Definition TTree.h:89
static TClass * Class()
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:43
@ PAR_MAX
Definition CommonDefs.h:44
@ PAR_VAL
Definition CommonDefs.h:42
@ kFP_PRED1D
Definition CommonDefs.h:33
@ kFP_PQET
Definition CommonDefs.h:20
@ kFP_CLOSE
Definition CommonDefs.h:30
@ kFP_ADD
Definition CommonDefs.h:17
@ kFP_CHEB7
Definition CommonDefs.h:12
@ kFP_RESET
Definition CommonDefs.h:30
@ kFP_FILE
Definition CommonDefs.h:17
@ kFP_YMIN
Definition CommonDefs.h:21
@ kFP_UPDATE
Definition CommonDefs.h:30
@ kFP_MUSR
Definition CommonDefs.h:19
@ kFP_POL6
Definition CommonDefs.h:10
@ kFP_LGSL
Definition CommonDefs.h:23
@ kFP_XMIN
Definition CommonDefs.h:21
@ kFP_CHEB2
Definition CommonDefs.h:11
@ kFP_LMIN2
Definition CommonDefs.h:23
@ kFP_XYGAUS
Definition CommonDefs.h:13
@ kFP_CHEB6
Definition CommonDefs.h:12
@ kFP_MCHIS
Definition CommonDefs.h:19
@ kFP_MLINF
Definition CommonDefs.h:19
@ kFP_IMERR
Definition CommonDefs.h:18
@ kFP_POL1
Definition CommonDefs.h:9
@ kFP_POL5
Definition CommonDefs.h:9
@ kFP_LFUM
Definition CommonDefs.h:23
@ kFP_POL0
Definition CommonDefs.h:9
@ kFP_NOSEL
Definition CommonDefs.h:36
@ kFP_INTEG
Definition CommonDefs.h:18
@ kFP_DATAS
Definition CommonDefs.h:34
@ kFP_CHEB9
Definition CommonDefs.h:12
@ kFP_LAND
Definition CommonDefs.h:8
@ kFP_CHEB1
Definition CommonDefs.h:11
@ kFP_NONE
Definition CommonDefs.h:17
@ kFP_MLIST
Definition CommonDefs.h:19
@ 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:25
@ kFP_CHEB5
Definition CommonDefs.h:11
@ kFP_MITR
Definition CommonDefs.h:28
@ kFP_UFUNC
Definition CommonDefs.h:33
@ kFP_IFITR
Definition CommonDefs.h:18
@ kFP_BIGAUS
Definition CommonDefs.h:13
@ kFP_XYLANN
Definition CommonDefs.h:13
@ kFP_MINMETHOD
Definition CommonDefs.h:24
@ kFP_FLIST
Definition CommonDefs.h:8
@ kFP_TLIST
Definition CommonDefs.h:33
@ kFP_POL3
Definition CommonDefs.h:9
@ kFP_FIT
Definition CommonDefs.h:30
@ kFP_NORMADD
Definition CommonDefs.h:17
@ kFP_GAUSN
Definition CommonDefs.h:8
@ kFP_MTOL
Definition CommonDefs.h:28
@ kFP_CHEB8
Definition CommonDefs.h:12
@ kFP_CHEB3
Definition CommonDefs.h:11
@ kFP_FUMILI
Definition CommonDefs.h:24
@ kFP_RBUST
Definition CommonDefs.h:17
@ kFP_POL2
Definition CommonDefs.h:9
@ kFP_POL8
Definition CommonDefs.h:10
@ kFP_SIMPLX
Definition CommonDefs.h:23
@ kFP_PDEF
Definition CommonDefs.h:20
@ kFP_PRED2D
Definition CommonDefs.h:33
@ kFP_USERG
Definition CommonDefs.h:18
@ kFP_XYZGAUS
Definition CommonDefs.h:14
@ kFP_PARS
Definition CommonDefs.h:17
@ kFP_XYLAN
Definition CommonDefs.h:13
@ kFP_MBINL
Definition CommonDefs.h:19
@ kFP_ALTFUNC
Definition CommonDefs.h:37
@ kFP_DNOST
Definition CommonDefs.h:20
@ kFP_GSLLM
Definition CommonDefs.h:25
@ kFP_BFGS
Definition CommonDefs.h:25
@ kFP_MUBIN
Definition CommonDefs.h:19
@ kFP_CONV
Definition CommonDefs.h:17
@ kFP_GAUS
Definition CommonDefs.h:8
@ kFP_PVER
Definition CommonDefs.h:20
@ kFP_PRED3D
Definition CommonDefs.h:33
@ kFP_GALIB
Definition CommonDefs.h:26
@ kFP_LMIN
Definition CommonDefs.h:23
@ kFP_POL9
Definition CommonDefs.h:10
@ kFP_EMPW1
Definition CommonDefs.h:17
@ kFP_DNONE
Definition CommonDefs.h:20
@ kFP_GSLPR
Definition CommonDefs.h:25
@ kFP_USER
Definition CommonDefs.h:16
@ kFP_SCAN
Definition CommonDefs.h:26
@ kFP_LANDN
Definition CommonDefs.h:8
@ kFP_ALLW1
Definition CommonDefs.h:18
@ kFP_COMBINATION
Definition CommonDefs.h:24
@ kFP_XYEXP
Definition CommonDefs.h:13
@ kFP_GSLFR
Definition CommonDefs.h:25
@ kFP_BFGS2
Definition CommonDefs.h:25
@ kFP_ADDLS
Definition CommonDefs.h:18
@ kFP_DADVB
Definition CommonDefs.h:20
@ kFP_LGAS
Definition CommonDefs.h:23
@ kFP_MERR
Definition CommonDefs.h:28
@ kFP_PREVFIT
Definition CommonDefs.h:33
@ kFP_MIGRAD
Definition CommonDefs.h:23
@ kFP_TMVAGA
Definition CommonDefs.h:26
@ kFP_DSAME
Definition CommonDefs.h:20
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:977
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:826
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
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 ...
TLine l
Definition textangle.C:4