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 {
262 Double_t par_min, par_max;
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) {
293 ROOT::Fit::FillData(data,fitobj,func);
295 // case gaussian or Landau
296 } else if ( 110 == special || 410 == special ) {
298 ROOT::Fit::FillData(data,fitobj,func);
300 }
301}
302
303////////////////////////////////////////////////////////////////////////////////
304/// Splits the entry in fDataSet to get the selected variables and cuts
305/// from the text.
306
307void GetTreeVarsAndCuts(TGComboBox* dataSet, TString& variablesStr, TString& cutsStr)
308{
309 // Get the entry
310 TGTextLBEntry* textEntry =
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
371 fDataSet = new TGComboBox(tf, kFP_DATAS);
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);
391 cf1->AddFrame(fUpdateButton, new TGLayoutHints(kLHintsTop |
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);
402 cf1->AddFrame(fResetButton, new TGLayoutHints(kLHintsTop |
403 kLHintsExpandX, 11, -2, 2, 2));
404
405 fCloseButton = new TGTextButton(cf1, "&Close", kFP_CLOSE);
406 fCloseButton->Associate(this);
407 cf1->AddFrame(fCloseButton, new TGLayoutHints(kLHintsTop |
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);
415 fStatusBar->SetParts(parts, 5);
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
454 SetFitObject(pad, obj, kButton1Down);
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);
487 SetWMPosition(gedx, gedy);
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);
542 TGCompositeFrame *tf0 = new TGCompositeFrame(gf1, 350, 26, kHorizontalFrame);
543 TGLabel *label1 = new TGLabel(tf0,"Type:");
544 tf0 -> AddFrame(label1, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
545
546 fTypeFit = new TGComboBox(tf0, kFP_TLIST);
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
557 fFuncList = new TGComboBox(tf0, kFP_FLIST);
559 fFuncList->Resize(194, 20);
561
562 lb = fFuncList->GetListBox();
563 lb -> Resize(lb->GetWidth(), 500);
564 tf0 -> AddFrame(fFuncList, new TGLayoutHints(kLHintsNormal, 5, 0, 5, 0));
565 fFuncList->Associate(this);
566
567 gf1->AddFrame(tf0, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
568
569 TGCompositeFrame *tf1 = new TGCompositeFrame(gf1, 350, 26, kHorizontalFrame);
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));
600 gf1 -> AddFrame(tf1, new TGLayoutHints(kLHintsExpandX));
601
602 TGCompositeFrame *tf2 = new TGCompositeFrame(gf1, 350, 26,
604 fEnteredFunc = new TGTextEntry(tf2, new TGTextBuffer(0), kFP_FILE);
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");
612 tf2->AddFrame(fEnteredFunc, new TGLayoutHints(kLHintsLeft |
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));
623 s1->AddFrame(hlines, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX));
624 gf1->AddFrame(s1, new TGLayoutHints(kLHintsExpandX));
625
626 TGCompositeFrame *tf4 = new TGCompositeFrame(gf1, 350, 26,
629 TString s = txt->GetTitle();
630 fSelLabel = new TGLabel(tf4, s.Sizeof()>30?s(0,30)+"...":s);
631 tf4->AddFrame(fSelLabel, new TGLayoutHints(kLHintsNormal |
632 kLHintsCenterY, 0, 6, 2, 0));
633 Pixel_t color;
634 gClient->GetColorByName("#336666", color);
636 TGCompositeFrame *tf5 = new TGCompositeFrame(tf4, 120, 20,
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));
672 h1->AddFrame(hline1, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX));
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
692
694 TGCompositeFrame *v21 = new TGCompositeFrame(v2, 120, 20,
696 fUserButton = new TGTextButton(v21, "User-Defined...", kFP_MUSR);
697 v21->AddFrame(fUserButton, new TGLayoutHints(kLHintsRight |
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));
732 TGHorizontal3DLine *hline2 = new TGHorizontal3DLine(h3);
733 h3->AddFrame(hline2, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX));
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));
789 TGHorizontal3DLine *hline3 = new TGHorizontal3DLine(h5);
790 h5->AddFrame(hline3, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX));
791 gf->AddFrame(h5, new TGLayoutHints(kLHintsExpandX));
792
794 TGVerticalFrame *v5 = new TGVerticalFrame(h6);
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
813 TGVerticalFrame *v6 = new TGVerticalFrame(h6);
814 TGCompositeFrame *v61 = new TGCompositeFrame(v6, 120, 20,
816 fDrawAdvanced = new TGTextButton(v61, "&Advanced...", kFP_DADVB);
817 v61->AddFrame(fDrawAdvanced, new TGLayoutHints(kLHintsRight |
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
826 h6->AddFrame(v6, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
827 gf->AddFrame(h6, new TGLayoutHints(kLHintsExpandX, 20, 0, 2, 0));
828
830 kLHintsExpandY, 5, 5, 0, 0));
831 // sliderX
833 TGLabel *label8 = new TGLabel(fSliderXParent, "X");
835 kLHintsCenterY, 0, 5, 0, 0));
836
842
844 fSliderX->SetScale(5);
846
847
854
855 // sliderY
857 TGLabel *label9 = new TGLabel(fSliderYParent, "Y");
859 kLHintsCenterY, 0, 5, 0, 0));
860
866
868 fSliderY->SetScale(5);
870
877
878 // sliderZ
880 TGLabel *label10 = new TGLabel(fSliderZParent, "Z:");
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));
919 fMinimization->AddFrame(hl, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 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
946 fMinimization->AddFrame(hl2, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 1));
947
948 MakeTitle(fMinimization, "Method");
949
952 fMinMethodList->Resize(290, 20);
954
956 lb->Resize(lb->GetWidth(), 500);
958
959 hm0->AddFrame(fMinMethodList, new TGLayoutHints(kLHintsNormal));
960 fMinimization->AddFrame(hm0, new TGLayoutHints(kLHintsExpandX, 60, 0, 5, 1));
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");
974 fMinimization->AddFrame(hslabel1, new TGLayoutHints(kLHintsNormal, 61, 0, 5, 1));
975 TGLabel *hslabel2 = new TGLabel(fMinimization,"on Reset button to set the defaults.");
976 fMinimization->AddFrame(hslabel2, new TGLayoutHints(kLHintsNormal, 61, 0, 1, 10));
977
979
980 TGVerticalFrame *hsv1 = new TGVerticalFrame(hs, 180, 10, kFixedWidth);
981 TGLabel *errlabel = new TGLabel(hsv1,"Error definition (default = 1): ");
982 hsv1->AddFrame(errlabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
983 1, 1, 5, 7));
984 TGLabel *tollabel = new TGLabel(hsv1,"Max tolerance (precision): ");
985 hsv1->AddFrame(tollabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
986 1, 1, 5, 7));
987 TGLabel *itrlabel = new TGLabel(hsv1,"Max number of iterations: ");
988 hsv1->AddFrame(itrlabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
989 1, 1, 5, 5));
990 hs->AddFrame(hsv1, new TGLayoutHints(kLHintsNormal, 60, 0, 0, 0));
991
992 TGVerticalFrame *hsv2 = new TGVerticalFrame(hs, 90,10, kFixedWidth);
998 1, 1, 0, 3));
1004 hsv2->AddFrame(fTolerance, new TGLayoutHints(kLHintsLeft | kLHintsExpandX,
1005 1, 1, 3, 3));
1006 fIterations = new TGNumberEntryField(hsv2, kFP_MITR, 5000,
1012 1, 1, 3, 3));
1013 hs->AddFrame(hsv2, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
1014 fMinimization->AddFrame(hs, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 1));
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
1037 fMinimization->AddFrame(h8, new TGLayoutHints(kLHintsExpandX, 20, 0, 5, 1));
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());
1236 SetFitObject(pad, obj, kButton1Down);
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 if (HasConnection("DoNoSelection()"))
1260 TQObject::Disconnect("TCanvas", "Closed()");
1261 delete fgFitDialog;
1262 fgFitDialog = 0;
1263}
1264
1265////////////////////////////////////////////////////////////////////////////////
1266/// Set the fit panel GUI according to the selected object.
1267
1269{
1271 return;
1272
1273 DrawSelection(true);
1274
1275 if ( fType == kObjectTree )
1276 // Don't do anything with the sliders, as they work with TAxis
1277 // that are not defined for the TTree
1278 return;
1279
1280 // sliders
1281 if (fType != kObjectTree) { // This is as fDim > 0
1282 TH1* hist = 0;
1283 switch (fType) {
1284 case kObjectHisto:
1285 hist = (TH1*)fFitObject;
1286 break;
1287
1288 case kObjectGraph:
1289 hist = ((TGraph*)fFitObject)->GetHistogram();
1290 break;
1291
1292 case kObjectMultiGraph:
1293 hist = ((TMultiGraph*)fFitObject)->GetHistogram();
1294 break;
1295
1296 case kObjectGraph2D:
1297 hist = ((TGraph2D*)fFitObject)->GetHistogram("empty");
1298 break;
1299
1300 case kObjectHStack:
1301 hist = (TH1 *)((THStack *)fFitObject)->GetHists()->First();
1302
1303 case kObjectTree:
1304 default:
1305 break;
1306 }
1307
1308
1309 if (!hist) {
1310 Error("UpdateGUI","No hist is present - this should not happen, please report."
1311 "The FitPanel might be in an inconsistent state");
1312 //assert(hist);
1313 return;
1314 }
1315
1316 fSliderX->Disconnect("PositionChanged()");
1317 fSliderXMin->Disconnect("ValueChanged()");
1318 fSliderXMax->Disconnect("ValueChanged()");
1319
1320 if (!fSliderXParent->IsMapped())
1322
1323 fXaxis = hist->GetXaxis();
1324 fYaxis = hist->GetYaxis();
1325 fZaxis = hist->GetZaxis();
1326 Int_t ixrange = fXaxis->GetNbins();
1327 Int_t ixmin = fXaxis->GetFirst();
1328 Int_t ixmax = fXaxis->GetLast();
1329
1330 if (ixmin > 1 || ixmax < ixrange) {
1331 fSliderX->SetRange(ixmin,ixmax);
1332 fSliderX->SetPosition(ixmin, ixmax);
1333 } else {
1334 fSliderX->SetRange(1,ixrange);
1335 fSliderX->SetPosition(ixmin,ixmax);
1336 }
1337
1338 fSliderX->SetScale(5);
1339
1341 fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1342 fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1345 fXaxis->GetBinLowEdge( static_cast<Int_t>( fSliderX->GetMinPosition() ) ),
1346 fXaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderX->GetMaxPosition() ) ));
1348
1349 fSliderX->Connect("PositionChanged()","TFitEditor",this, "DoSliderXMoved()");
1350 fSliderXMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1351 fSliderXMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderXChanged()");
1352 }
1353
1354 if (fDim > 1) {
1355 fSliderY->Disconnect("PositionChanged()");
1356 fSliderYMin->Disconnect("ValueChanged()");
1357 fSliderYMax->Disconnect("ValueChanged()");
1358
1359 if (!fSliderYParent->IsMapped())
1361 if (fSliderZParent->IsMapped())
1363
1364 Int_t iymin = 0, iymax = 0, iyrange = 0;
1365 switch (fType) {
1366 case kObjectHisto:
1367 case kObjectGraph2D:
1368 case kObjectHStack:
1369 iyrange = fYaxis->GetNbins();
1370 iymin = fYaxis->GetFirst();
1371 iymax = fYaxis->GetLast();
1372 break;
1373
1374 case kObjectGraph:
1375 case kObjectMultiGraph:
1376 case kObjectTree:
1377 default:
1378 //not implemented
1379 break;
1380 }
1381
1382 if (iymin > 1 || iymax < iyrange) {
1383 fSliderY->SetRange(iymin,iymax);
1384 fSliderY->SetPosition(iymin, iymax);
1385 } else {
1386 fSliderY->SetRange(1,iyrange);
1387 fSliderY->SetPosition(iymin,iymax);
1388 }
1389
1390 fSliderY->SetScale(5);
1391
1393 fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1394 fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1397 fYaxis->GetBinLowEdge( static_cast<Int_t>( fSliderY->GetMinPosition() ) ),
1398 fYaxis->GetBinUpEdge ( static_cast<Int_t>( fSliderY->GetMaxPosition() ) ));
1400
1401 fSliderY->Connect("PositionChanged()","TFitEditor",this, "DoSliderYMoved()");
1402 fSliderYMax->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1403 fSliderYMin->Connect("ValueSet(Long_t)", "TFitEditor", this, "DoNumericSliderYChanged()");
1404 }
1405
1406
1407 if (fDim > 2) {
1408 fSliderZ->Disconnect("PositionChanged()");
1409
1410 if (!fSliderZParent->IsMapped())
1412
1413 Int_t izmin = 0, izmax = 0, izrange = 0;
1414 switch (fType) {
1415 case kObjectHStack:
1416 case kObjectHisto:
1417 izrange = fZaxis->GetNbins();
1418 izmin = fZaxis->GetFirst();
1419 izmax = fZaxis->GetLast();
1420 break;
1421
1422 case kObjectGraph:
1423 case kObjectGraph2D:
1424 case kObjectMultiGraph:
1425 case kObjectTree:
1426 default:
1427 //not implemented
1428 break;
1429 }
1430
1431 if (izmin > 1 || izmax < izrange) {
1432 fSliderZ->SetRange(izmin,izmax);
1433 fSliderZ->SetPosition(izmin, izmax);
1434 } else {
1435 fSliderZ->SetRange(1,izrange);
1436 fSliderZ->SetPosition(izmin,izmax);
1437 }
1438
1439 fSliderZ->SetScale(5);
1440 fSliderZ->Connect("PositionChanged()","TFitEditor",this, "DoSliderZMoved()");
1441 }
1442}
1443
1444////////////////////////////////////////////////////////////////////////////////
1445/// Slot called when the user clicks on an object inside a canvas.
1446/// Updates pointers to the parent pad and the selected object
1447/// for fitting (if suitable).
1448
1450{
1451 if (event != kButton1Down) return;
1452
1453 if ( !obj ) {
1454 DoNoSelection();
1455 return;
1456 }
1457
1458 // is obj suitable for fitting?
1459 if (!SetObjectType(obj)) return;
1460
1461 fParentPad = pad;
1462 fFitObject = obj;
1463 ShowObjectName(obj);
1464 UpdateGUI();
1465
1466 ConnectSlots();
1467
1468 TF1* fitFunc = HasFitFunction();
1469
1470 if (fitFunc)
1471 {
1472 //fFuncPars = FuncParams_t( fitFunc->GetNpar() );
1473 GetParameters(fFuncPars, fitFunc);
1474
1475 TString tmpStr = fitFunc->GetExpFormula();
1476 TGLBEntry *en = 0;
1477 // If the function comes from a C raw function.
1478 if ( tmpStr.Length() == 0 )
1479 {
1480 // Show the name of the function
1481 fEnteredFunc->SetText(fitFunc->GetName());
1482 en= fFuncList->FindEntry(fitFunc->GetName());
1483 // Don't allow edition!
1485 }
1486 // otherwise, it's got a formula
1487 else
1488 {
1489 // Show the formula
1490 fEnteredFunc->SetText(fitFunc->GetExpFormula().Data());
1491 en= fFuncList->FindEntry(fitFunc->GetExpFormula().Data());
1493 }
1494 // Select the proper entry in the function list
1495 if (en) fFuncList->Select(en->EntryId());
1496 }
1497 else
1498 { // if there is no fit function in the object
1499 // Use the selected function in fFuncList
1501 // Add the text to fEnteredFunc
1502 if (te && fNone->GetState() == kButtonDown)
1503 fEnteredFunc->SetText(te->GetTitle());
1504 else if (te && fAdd->GetState() == kButtonDown)
1505 {
1506 TString tmpStr = fEnteredFunc->GetText();
1507 tmpStr += '+';
1508 tmpStr += te->GetTitle();
1509 fEnteredFunc->SetText(tmpStr);
1510 }
1511 else if (te && fNormAdd->GetState() == kButtonDown)
1512 {
1513 TString tmpStr = fEnteredFunc->GetText();
1514 tmpStr += '+';
1515 tmpStr += te -> GetTitle();
1516 fEnteredFunc -> SetText(tmpStr);
1517 }
1518 else if (te && fConv->GetState() == kButtonDown)
1519 {
1520 TString tmpStr = fEnteredFunc->GetText();
1521 tmpStr += '*';
1522 tmpStr +=te->GetTitle();
1523 fEnteredFunc->SetText(tmpStr);
1524 }
1525 else if ( !te )
1526 // If there is no space, an error message is shown:
1527 // Error in <TString::AssertElement>: out of bounds: i = -1, Length = 0
1528 // If there is no function selected, then put nothing.
1529 fEnteredFunc->SetText(" ");
1530 }
1532
1533
1534 // Update the information about the selected object.
1541 DoLinearFit();
1542}
1543
1544////////////////////////////////////////////////////////////////////////////////
1545/// Slot called when users close a TCanvas or when the user select
1546/// no object.
1547
1549{
1550 if (gROOT->GetListOfCanvases()->IsEmpty()) {
1551 Terminate();
1552 return;
1553 }
1554
1555 // Minimize user interaction until an object is selected
1557 fParentPad = 0;
1558 fFitObject = 0;
1559 fStatusBar->SetText("No selection",0);
1561 Layout();
1562
1567}
1568
1569////////////////////////////////////////////////////////////////////////////////
1570/// When obj is deleted, clear fFitObject if fFitObject = obj.
1571
1573{
1574 if (obj == fFitObject) {
1575 fFitObject = 0;
1577 fStatusBar->SetText("No selection",0);
1579 Layout();
1580
1584
1585 TQObject::Connect("TCanvas", "Selected(TVirtualPad *, TObject *, Int_t)",
1586 "TFitEditor",this,
1587 "SetFitObject(TVirtualPad *, TObject *, Int_t)");
1588 TQObject::Connect("TCanvas", "Closed()", "TFitEditor", this,
1589 "DoNoSelection()");
1590
1591 DoUpdate();
1592 return;
1593 }
1594 if (obj == fParentPad) {
1595 fFitObject = 0;
1596 fParentPad = 0;
1598 fStatusBar->SetText("No selection",0);
1600 Layout();
1601
1605 }
1606}
1607
1608////////////////////////////////////////////////////////////////////////////////
1609/// Fills the list of functions depending on the type of fit
1610/// selected.
1611
1613{
1615 // Case when the user has selected predefined functions in 1D.
1616 if ( fTypeFit->GetSelected() == kFP_PRED1D && fDim <= 1 ) {
1617 // Fill function list combo box.
1618 fFuncList->AddEntry("gaus" , kFP_GAUS);
1619 fFuncList->AddEntry("gausn", kFP_GAUSN);
1620 fFuncList->AddEntry("expo", kFP_EXPO);
1621 fFuncList->AddEntry("landau", kFP_LAND);
1622 fFuncList->AddEntry("landaun",kFP_LANDN);
1623 fFuncList->AddEntry("pol0", kFP_POL0);
1624 fFuncList->AddEntry("pol1", kFP_POL1);
1625 fFuncList->AddEntry("pol2", kFP_POL2);
1626 fFuncList->AddEntry("pol3", kFP_POL3);
1627 fFuncList->AddEntry("pol4", kFP_POL4);
1628 fFuncList->AddEntry("pol5", kFP_POL5);
1629 fFuncList->AddEntry("pol6", kFP_POL6);
1630 fFuncList->AddEntry("pol7", kFP_POL7);
1631 fFuncList->AddEntry("pol8", kFP_POL8);
1632 fFuncList->AddEntry("pol9", kFP_POL9);
1633 fFuncList->AddEntry("cheb0", kFP_CHEB0);
1634 fFuncList->AddEntry("cheb1", kFP_CHEB1);
1635 fFuncList->AddEntry("cheb2", kFP_CHEB2);
1636 fFuncList->AddEntry("cheb3", kFP_CHEB3);
1637 fFuncList->AddEntry("cheb4", kFP_CHEB4);
1638 fFuncList->AddEntry("cheb5", kFP_CHEB5);
1639 fFuncList->AddEntry("cheb6", kFP_CHEB6);
1640 fFuncList->AddEntry("cheb7", kFP_CHEB7);
1641 fFuncList->AddEntry("cheb8", kFP_CHEB8);
1642 fFuncList->AddEntry("cheb9", kFP_CHEB9);
1643 fFuncList->AddEntry("user", kFP_USER);
1644
1645 // Need to be setted this way, otherwise when the functions
1646 // are removed, the list doesn't show them.
1648 lb->Resize(lb->GetWidth(), 200);
1649
1650 // Select Gaus1D by default
1652
1653 }
1654 // Case for predefined 2D functions
1655 else if ( fTypeFit->GetSelected() == kFP_PRED2D && fDim == 2 ) {
1656 fFuncList->AddEntry("xygaus", kFP_XYGAUS);
1657 fFuncList->AddEntry("bigaus", kFP_BIGAUS);
1658 fFuncList->AddEntry("xyexpo", kFP_XYEXP);
1659 fFuncList->AddEntry("xylandau", kFP_XYLAN);
1660 fFuncList->AddEntry("xylandaun", kFP_XYLANN);
1661
1662 // Need to be setted this way, otherwise when the functions
1663 // are removed, the list doesn't show them.x
1665 lb->Resize(lb->GetWidth(), 200);
1666
1667 // Select Gaus2D by default
1669 } else if (fTypeFit->GetSelected() == kFP_PRED3D && fDim == 3) {
1670 fFuncList->AddEntry("xyzgaus", kFP_XYZGAUS);
1671
1672 // Need to be setted this way, otherwise when the functions
1673 // are removed, the list doesn't show them.x
1675 lb->Resize(lb->GetWidth(), 200);
1676
1677 // Select Gaus3D by default
1679 }
1680 // Case for user defined functions. References to these functions
1681 // are kept by the fitpanel, so the information is gathered from
1682 // there.
1683 else if (fTypeFit->GetSelected() == kFP_UFUNC) {
1684 Int_t newid = kFP_ALTFUNC;
1685
1686 // Add system functions
1687 for (auto f : fSystemFuncs) {
1688 // Don't include system functions that has been previously
1689 // used to fit, as those are included under the kFP_PREVFIT
1690 // section.
1691 if ( strncmp(f->GetName(), "PrevFit", 7) != 0 ) {
1692 // If the dimension of the object coincides with the
1693 // dimension of the function, then include the function in
1694 // the list. It will also include de function if the
1695 // dimension of the object is 0 (i.e. a multivariable
1696 // TTree) as it is currently imposible to know how many
1697 // dimensions a TF1 coming from a C raw function has.
1698 if ( f->GetNdim() == fDim || fDim == 0) {
1699 fFuncList->AddEntry(f->GetName(), newid++);
1700 }
1701 }
1702 }
1703
1704 // If no function was added
1705 if ( newid != kFP_ALTFUNC )
1706 fFuncList->Select(newid-1);
1707 else if( fDim == 1 ) {
1708 // Select predefined 1D functions for 1D objects
1710 } else if( fDim == 2 ) {
1711 // Select predefined 2D functions for 2D objects
1713 }
1714 }
1715 // Case for previously used functions.
1716 else if (fTypeFit->GetSelected() == kFP_PREVFIT) {
1717 Int_t newid = kFP_ALTFUNC;
1718
1719 // Look only for those functions used in the selected object
1720 std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(fFitObject);
1721 // Then go over all those functions and add them to the list
1722 for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
1723 fFuncList->AddEntry(it->second->GetName(), newid++);
1724 }
1725
1726 // If no functions were added.
1727 if ( newid == kFP_ALTFUNC ) {
1728 // Remove the entry previous fit from fTypeFit
1730 if( fDim == 1 )
1731 // Select predefined 1D functions for 1D objects
1733 else if ( fDim == 2 )
1734 // Select predefined 2D functions for 2D objects
1736 else
1737 // For more than 2 dimensions, select the user functions.
1739 }
1740 else
1741 // If there is there are previously used functions, select
1742 // the last one inserted.
1743 fFuncList->Select(newid-1, kTRUE);
1744 }
1745}
1746
1747////////////////////////////////////////////////////////////////////////////////
1748/// Fills the list of methods depending on the minimization library
1749/// selected.
1750
1752{
1754
1755 if ( fLibMinuit->GetState() == kButtonDown )
1756 {
1757 fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1758 fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1759 fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1760 fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1762 fStatusBar->SetText("MIGRAD",2);
1763 } else if ( fLibFumili->GetState() == kButtonDown )
1764 {
1765 fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1767 fStatusBar->SetText("FUMILI",2);
1768 } else if ( fLibGSL->GetState() == kButtonDown )
1769 {
1770 fMinMethodList->AddEntry("Fletcher-Reeves conjugate gradient" , kFP_GSLFR);
1771 fMinMethodList->AddEntry("Polak-Ribiere conjugate gradient" , kFP_GSLPR);
1772 fMinMethodList->AddEntry("BFGS conjugate gradient" , kFP_BFGS);
1773 fMinMethodList->AddEntry("BFGS conjugate gradient (Version 2)", kFP_BFGS2);
1774 fMinMethodList->AddEntry("Levenberg-Marquardt" , kFP_GSLLM);
1775 fMinMethodList->AddEntry("Simulated Annealing" , kFP_GSLSA);
1777 fStatusBar->SetText("CONJFR",2);
1778 } else if ( fLibGenetics->GetState() == kButtonDown )
1779 {
1780 if ( gPluginMgr->FindHandler("ROOT::Math::Minimizer","GAlibMin") ) {
1781 fMinMethodList->AddEntry("GA Lib Genetic Algorithm" , kFP_GALIB);
1783 } else if (gPluginMgr->FindHandler("ROOT::Math::Minimizer","Genetic")) {
1784 fMinMethodList->AddEntry("TMVA Genetic Algorithm" , kFP_TMVAGA);
1786 }
1787 } else // if ( fLibMinuit2->GetState() == kButtonDown )
1788 {
1789 fMinMethodList->AddEntry("MIGRAD" , kFP_MIGRAD);
1790 fMinMethodList->AddEntry("SIMPLEX" , kFP_SIMPLX);
1791 fMinMethodList->AddEntry("FUMILI" , kFP_FUMILI);
1792 fMinMethodList->AddEntry("SCAN" , kFP_SCAN);
1793 fMinMethodList->AddEntry("Combination" , kFP_COMBINATION);
1795 fStatusBar->SetText("MIGRAD",2);
1796 }
1797}
1798
1799void SearchCanvases(TSeqCollection* canvases, std::vector<TObject*>& objects)
1800{
1801 // Auxiliary function to recursively search for objects inside the
1802 // current canvases.
1803
1804 TIter canvasIter(canvases);
1805 // Iterate over all the canvases in canvases.
1806 while(TObject* obj = (TObject*) canvasIter()) {
1807 // If the object is another canvas, call this function
1808 // recursively.
1809 if ( TPad* can = dynamic_cast<TPad*>(obj))
1810 SearchCanvases(can->GetListOfPrimitives(), objects);
1811 // Otherwhise, if it's a recognised object, add it to the vector
1812 else if ( dynamic_cast<TH1*>(obj)
1813 || dynamic_cast<TGraph*>(obj)
1814 || dynamic_cast<TGraph2D*>(obj)
1815 || dynamic_cast<TMultiGraph*>(obj)
1816 || dynamic_cast<THStack*>(obj)
1817 || dynamic_cast<TTree*>(obj) ) {
1818 bool insertNew = true;
1819 // Be careful no to insert the same element twice.
1820 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i )
1821 if ( (*i) == obj ) {
1822 insertNew = false;
1823 break;
1824 }
1825 // If the object is not already in the vector, then insert
1826 // it.
1827 if ( insertNew ) objects.push_back(obj);
1828 }
1829 }
1830}
1831
1832////////////////////////////////////////////////////////////////////////////////
1833/// Create a combo box with all the possible objects to be fitted.
1834
1836{
1837 // Get the title of the entry selected, so that we can select it
1838 // again once the fDataSet has been refilled.
1840 TString selEntryStr;
1841 if ( entry ) {
1842 selEntryStr = entry->GetTitle();
1843 }
1844
1845 // Remove all the elements
1847 std::vector<TObject*> objects;
1848
1849 // Get all the objects registered in gDirectory
1850 if (gDirectory) {
1851 TList * l = gDirectory->GetList();
1852 if (l) {
1853 TIter next(l);
1854 TObject* obj = NULL;
1855 while ( (obj = (TObject*) next()) ) {
1856 // But only if they are of a type recognized by the FitPanel
1857 if ( dynamic_cast<TH1*>(obj) ||
1858 dynamic_cast<TGraph2D*>(obj) ||
1859 dynamic_cast<TTree*>(obj) ) {
1860 objects.push_back(obj);
1861 }
1862 }
1863 }
1864 }
1865
1866 // Look for all the drawn objects. The method will take care the
1867 // same objects are not inserted twice.
1868 SearchCanvases(gROOT->GetListOfCanvases(), objects);
1869
1870 // Add all the objects stored in the vector
1871 int selected = kFP_NOSEL;
1872 // Add the No selection.
1873 Int_t newid = kFP_NOSEL;
1874 fDataSet->AddEntry("No Selection", newid++);
1875 for ( std::vector<TObject*>::iterator i = objects.begin(); i != objects.end(); ++i ) {
1876 // Insert the name as the class name followed by the name of the
1877 // object.
1878 TString name = (*i)->ClassName(); name.Append("::"); name.Append((*i)->GetName());
1879 // Check whether the names are the same!
1880 if ( selEntryStr && name == selEntryStr )
1881 selected = newid;
1882 fDataSet->AddEntry(name, newid++);
1883 }
1884
1885 // If there was an entry selected (which should be always the case
1886 // except the first time this method is executed), then make it the
1887 // selected one again.
1888 if (entry) {
1889 fDataSet->Select(selected);
1890 }
1891}
1892
1893////////////////////////////////////////////////////////////////////////////////
1894/// Create method list in a combo box.
1895
1897{
1898 TGComboBox *c = new TGComboBox(parent, id);
1899 c->AddEntry("Chi-square", kFP_MCHIS);
1900 c->AddEntry("Binned Likelihood", kFP_MBINL);
1901 c->AddEntry("Unbinned Likelihood", kFP_MUBIN);
1902 //c->AddEntry("User", kFP_MUSER); //for later use
1903 c->Select(kFP_MCHIS);
1904 return c;
1905}
1906
1907////////////////////////////////////////////////////////////////////////////////
1908/// Slot connected to advanced option button (opens a dialog).
1909
1914
1915////////////////////////////////////////////////////////////////////////////////
1916/// Slot connected to 'include emtry bins and forse all weights to 1' setting.
1917
1924
1925////////////////////////////////////////////////////////////////////////////////
1926
1928{
1929 if ( fUseRange->GetState() == kButtonDown ) {
1931 // Get the function
1932 TF1* tmpTF1 = FindFunction();
1933 if ( !tmpTF1 ) {
1936 tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
1937 }
1938 }
1939 // If the function has been retrieved, i.e. is a registered function.
1940 if ( tmpTF1 ) {
1941 Double_t xmin, ymin, zmin, xmax, ymax, zmax;
1942 // Get the range
1943 tmpTF1->GetRange(xmin, ymin, zmin, xmax, ymax, zmax);
1944 // And set the sliders
1945 if ( fType != kObjectTree ) {
1949 if ( fDim > 1 ) {
1953 }
1954 }
1955 }
1956 }
1958 }
1959}
1960
1961////////////////////////////////////////////////////////////////////////////////
1962/// Slot connected to 'set all weights to 1' setting.
1963
1970
1971////////////////////////////////////////////////////////////////////////////////
1972/// Close the fit panel.
1973
1975{
1976 Hide();
1977}
1978
1979////////////////////////////////////////////////////////////////////////////////
1980/// Easy here!
1981
1987
1988////////////////////////////////////////////////////////////////////////////////
1989/// Perform a fit with current parameters' settings.
1990
1992{
1993 if (!fFitObject) return;
1994 //if (!fParentPad) return;
1995
1996 // If fNone->GetState() == kButtonDisabled means the function is
1997 // not editable, i.e. it comes from a raw C function. So in this
1998 // case, it is editable and we have to check wheather the formula
1999 // is well built.
2001 {
2002 // If not, then show an error message and leave.
2004 "Error...", "2) Verify the entered function string!",
2005 kMBIconStop,kMBOk, 0);
2006 return;
2007 }
2008
2009 // Set the button so that the user cannot use it while fitting, set
2010 // the mouse to watch type and so on.
2012 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kWatch);
2013 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));
2014
2015 TVirtualPad *save = nullptr;
2016 if ( fParentPad ) {
2017 fParentPad->Disconnect("RangeAxisChanged()");
2018 save = gPad;
2019 gPad = fParentPad;
2020 fParentPad->cd();
2021
2022 if (fParentPad->GetCanvas())
2023 fParentPad->GetCanvas()->SetCursor(kWatch);
2024 }
2025
2026 // Get the ranges from the sliders
2027 ROOT::Fit::DataRange drange;
2028 GetRanges(drange);
2029
2030 // Create a static pointer to fitFunc. Every second call to the
2031 // DoFit method, the old fitFunc is deleted. We need not to delete
2032 // the function after the fitting in case we want to do Advaced
2033 // graphics. The VirtualFitter need the function to be alived. One
2034 // problem, after the last fit the function is never deleted, but
2035 // ROOT's garbage collector will do the job for us.
2036 static TF1 *fitFunc = nullptr;
2037 if ( fitFunc ) {
2038 //std::cout << "TFitEditor::DoFit - deleting fit function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2039 delete fitFunc;
2040 }
2041 fitFunc = GetFitFunction();
2042
2043 std::cout << "TFitEditor::DoFit - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2044 // This assert
2045 if (!fitFunc) {
2046 Error("DoFit","This should have never happend, the fitfunc pointer is NULL! - Please Report" );
2047 return;
2048 }
2049
2050 // set parameters from panel in function
2051 SetParameters(fFuncPars, fitFunc);
2052 // Get the options stored in the GUI elements.
2054 Foption_t fitOpts;
2055 TString strDrawOpts;
2056 RetrieveOptions(fitOpts, strDrawOpts, mopts, fitFunc->GetNpar());
2057
2058 // Call the fit method, depending on the object to fit.
2059 switch (fType) {
2060 case kObjectHisto: {
2061
2062 TH1 *hist = dynamic_cast<TH1*>(fFitObject);
2063 if (hist)
2064 ROOT::Fit::FitObject(hist, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2065
2066 break;
2067 }
2068 case kObjectGraph: {
2069
2070 TGraph *gr = dynamic_cast<TGraph*>(fFitObject);
2071 if (gr)
2072 FitObject(gr, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2073 break;
2074 }
2075 case kObjectMultiGraph: {
2076
2077 TMultiGraph *mg = dynamic_cast<TMultiGraph*>(fFitObject);
2078 if (mg)
2079 FitObject(mg, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2080
2081 break;
2082 }
2083 case kObjectGraph2D: {
2084
2085 TGraph2D *g2d = dynamic_cast<TGraph2D*>(fFitObject);
2086 if (g2d)
2087 FitObject(g2d, fitFunc, fitOpts, mopts, strDrawOpts, drange);
2088
2089 break;
2090 }
2091 case kObjectHStack: {
2092 // N/A
2093 break;
2094 }
2095 case kObjectTree: {
2096 // The three is a much more special case. The steps for
2097 // fitting have to be done manually here until they are
2098 // properly implemented within a FitObject method in
2099 // THFitImpl.cxx
2100
2101 // Retrieve the variables and cuts selected from the current
2102 // tree.
2103 TString variables;
2104 TString cuts;
2105 GetTreeVarsAndCuts(fDataSet, variables, cuts);
2106
2107 // This should be straight forward and the return should
2108 // never be called.
2109 TTree *tree = dynamic_cast<TTree*>(fFitObject);
2110 if ( !tree ) return;
2111
2112 // These method calls are just to set up everything for the
2113 // fitting. It's taken from another script.
2114 gROOT->ls();
2115 tree->Draw(variables,cuts,"goff");
2116
2117 auto player = tree->GetPlayer();
2118 if ( !player ) {
2119 Error("DoFit","Player reference is NULL");
2120 return;
2121 }
2122
2123 auto selector = dynamic_cast<TSelectorDraw *>(player->GetSelector());
2124 if ( !selector ) {
2125 Error("DoFit","Selector reference is NULL");
2126 return;
2127 }
2128
2129 // use pointer stored in the tree (not copy the data in)
2130 unsigned int ndim = player->GetDimension();
2131 if ( ndim == 0 ) {
2132 Error("DoFit","NDIM == 0");
2133 return;
2134 }
2135
2136 std::vector<double *> vlist;
2137 for (unsigned int i = 0; i < ndim; ++i) {
2138 double * v = selector->GetVal(i);
2139 if (v != 0) vlist.push_back(v);
2140 else
2141 std::cerr << "pointer for variable " << i << " is zero" << std::endl;
2142 }
2143 if (vlist.size() != ndim) {
2144 Error("DoFit","Vector is not complete");
2145 return;
2146 }
2147
2148 // fill the data
2149 Long64_t nrows = player->GetSelectedRows();
2150 if ( !nrows ) {
2151 Error("DoFit","NROWS == 0");
2152 return;
2153 }
2154
2155 ROOT::Fit::UnBinData * fitdata = new ROOT::Fit::UnBinData(nrows, ndim, vlist.begin());
2156
2157 for ( int i = 0; i < std::min(int(fitdata->Size()),10); ++i) {
2158 // print j coordinate
2159 for (unsigned int j = 0; j < ndim; ++j) {
2160 printf(" x_%d [%d] = %f \n", j, i,*(fitdata->Coords(i)+j) );
2161 }
2162 printf("\n");
2163 }
2164
2165
2166 //TVirtualFitter::SetDefaultFitter("Minuit");
2167 Foption_t fitOption;
2169 fitOption.Verbose=1;
2170
2171 // After all the set up is performed, then do the Fit!!
2172 ROOT::Fit::UnBinFit(fitdata, fitFunc, fitOption, minOption);
2173
2174 break;
2175 }
2176 }
2177
2178 // if SAME is set re-plot the function
2179 // useful in case histogram was drawn with HIST
2180 // and no function will be drawm)
2181 if (fDrawSame->GetState() == kButtonDown && fitFunc)
2182 fitFunc->Draw("same");
2183
2184
2185 // update parameters value shown in dialog
2186 //if (!fFuncPars) fFuncPars = new Double_t[fitFunc->GetNpar()][3];
2187 GetParameters(fFuncPars,fitFunc);
2188
2189 // Save fit data for future use as a PrevFit function.
2190 TF1* tmpTF1 = copyTF1(fitFunc);
2191 TString name = TString::Format("PrevFit-%d", (int) fPrevFit.size() + 1);
2192 if (!strstr(fitFunc->GetName(),"PrevFit"))
2193 name.Append(TString::Format("-%s", fitFunc->GetName()));
2194 tmpTF1->SetName(name.Data());
2195 fPrevFit.emplace(fFitObject, tmpTF1);
2196 fSystemFuncs.emplace_back( copyTF1(tmpTF1) );
2197
2198 float xmin = 0.f, xmax = 0.f, ymin = 0.f, ymax = 0.f, zmin = 0.f, zmax = 0.f;
2199 if ( fParentPad ) {
2201 // As the range is not changed, save the old values and restore
2202 // after the GUI has been updated. It would be more elegant to
2203 // disconnect the signal from fParentPad, however, this doesn't
2204 // work for unknown reasons.
2206 if ( fDim > 1 ) fSliderY->GetPosition(ymin, ymax);
2207 if ( fDim > 2 ) fSliderZ->GetPosition(zmin, zmax);
2208 fParentPad->Update();
2209 }
2210
2211 // In case the fit method draws something! Set the canvas!
2212 fParentPad = gPad;
2213 UpdateGUI();
2214
2215 // Change the sliders if necessary.
2216 if ( fParentPad ) {
2218 if ( fType != kObjectTree && fDim > 1 ) { fSliderY->SetPosition(ymin, ymax); DoSliderYMoved(); }
2219 if ( fType != kObjectTree && fDim > 2 ) { fSliderZ->SetPosition(zmin, zmax); DoSliderZMoved(); }
2220 if (fParentPad->GetCanvas())
2221 fParentPad->GetCanvas()->SetCursor(kPointer);
2222 fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2223
2224 if (save) gPad = save;
2228 }
2229
2230 // Restore the Fit button and mouse cursor to their proper state.
2231 if (gPad && gPad->GetVirtCanvas()) gPad->GetVirtCanvas()->SetCursor(kPointer);
2232 gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));
2234
2235 if ( !fTypeFit->FindEntry("Prev. Fit") )
2237
2239}
2240
2241////////////////////////////////////////////////////////////////////////////////
2242/// Check entered function string.
2243
2245{
2246 Int_t rvalue = 0;
2247 if ( fDim == 1 || fDim == 0 ) {
2248 TF1 form("tmpCheck", fname);
2249 // coverity[uninit_use_in_call]
2250 rvalue = form.IsValid() ? 0 : -1;
2251 } else if ( fDim == 2 ) {
2252 TF2 form("tmpCheck", fname);
2253 // coverity[uninit_use_in_call]
2254 rvalue = form.IsValid() ? 0 : -1;
2255 } else if ( fDim == 3 ) {
2256 TF3 form("tmpCheck", fname);
2257 // coverity[uninit_use_in_call]
2258 rvalue = form.IsValid() ? 0 : -1;
2259 }
2260
2261 return rvalue;
2262}
2263
2264////////////////////////////////////////////////////////////////////////////////
2265/// Slot connected to addition of predefined functions. It will
2266/// insert the next selected function with a plus sign so that it
2267/// doesn't override the current content of the formula.
2268
2270{
2271 static Bool_t first = kFALSE;
2273 if (on) {
2274 if (!first) {
2275 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2276 s += "(0)";
2278 first = kTRUE;
2280 }
2281 } else {
2282 first = kFALSE;
2283 }
2284}
2285////////////////////////////////////////////////////////////////////////////////
2286/// Slot connected to addition of predefined functions. It will
2287/// insert the next selected function with a plus sign so that it
2288/// doesn't override the current content of the formula.
2289
2291{
2292 /*
2293 static Bool_t first = kFALSE;
2294 TString s = fEnteredFunc->GetText();
2295 if (on) {
2296 if (!first) {
2297 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2298 fEnteredFunc->SetText(s.Data());
2299 first = kTRUE;
2300 ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2301 }
2302 } else {
2303 first = kFALSE;
2304 }*/
2305
2306 if (on) Info("DoNormAddition","Normalized addition is selected");
2307}
2308
2309////////////////////////////////////////////////////////////////////////////////
2310/// Slot connected to addition of predefined functions. It will
2311/// insert the next selected function with a plus sign so that it
2312/// doesn't override the current content of the formula.
2313
2315{
2316 /*
2317 static Bool_t first = kFALSE;
2318 TString s = fEnteredFunc->GetText();
2319 if (on) {
2320 if (!first) {
2321 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2322 // s += "(0)";
2323 fEnteredFunc->SetText(s.Data());
2324 first = kTRUE;
2325 ((TGCompositeFrame *)fSelLabel->GetParent())->Layout();
2326 }
2327 } else
2328 first = kFALSE;*/
2329
2330 if (on) Info("DoConvolution","Convolution is selected");
2331}
2332
2333////////////////////////////////////////////////////////////////////////////////
2334/// Selects the data set to be fitted
2335
2337{
2338 if ( selected == kFP_NOSEL ) {
2339 DoNoSelection();
2340 return;
2341 }
2342
2343 // Get the name and class of the selected object.
2344 TGTextLBEntry* textEntry = static_cast<TGTextLBEntry*>(fDataSet->GetListBox()->GetEntry(selected));
2345 if (!textEntry) return;
2346 TString textEntryStr = textEntry->GetText()->GetString();
2347 TString name = textEntry->GetText()->GetString()+textEntry->GetText()->First(':')+2;
2348 TString className = textEntryStr(0,textEntry->GetText()->First(':'));
2349
2350 // Check the object exists in the ROOT session and it is registered
2351 TObject* objSelected(0);
2352 if ( className == "TTree" ) {
2353 // It's a tree, so the name is before the space (' ')
2354 TString lookStr;
2355 if ( name.First(' ') == kNPOS )
2356 lookStr = name;
2357 else
2358 lookStr = name(0, name.First(' '));
2359 //std::cout << "\t1 SITREE: '" << lookStr << "'" << std::endl;
2360 objSelected = gROOT->FindObject(lookStr);
2361 } else {
2362 // It's not a tree, so the name is the complete string
2363 //std::cout << "\t1 NOTREE: '" << name << "'" << std::endl;
2364 objSelected = gROOT->FindObject(name);
2365 }
2366 if ( !objSelected )
2367 {
2368 //std::cerr << "Object not found! Please report the error! " << std::endl;
2369 return;
2370 }
2371
2372 // If it is a tree, and there are no variables selected, show a dialog
2373 if ( objSelected->InheritsFrom(TTree::Class()) &&
2374 name.First(' ') == kNPOS ) {
2375 char variables[256] = {0}; char cuts[256] = {0};
2376 strlcpy(variables, "Sin input!", 256);
2377 new TTreeInput( fClient->GetRoot(), GetMainFrame(), variables, cuts );
2378 if ( strcmp ( variables, "" ) == 0 ) {
2379 DoNoSelection();
2380 return;
2381 }
2382 ProcessTreeInput(objSelected, selected, variables, cuts);
2383 }
2384
2385 // Search the canvas where the object is drawn, if any
2386 TPad* currentPad = NULL;
2387 bool found = false;
2388 std::queue<TPad*> stPad;
2389 TIter padIter( gROOT->GetListOfCanvases() );
2390 while ( TObject* canvas = static_cast<TObject*>(padIter() ) ) {
2391 if ( dynamic_cast<TPad*>(canvas) )
2392 stPad.push(dynamic_cast<TPad*>(canvas));
2393 }
2394
2395 while ( !stPad.empty() && !found ) {
2396 currentPad = stPad.front();
2397 stPad.pop();
2398 TIter elemIter( currentPad->GetListOfPrimitives() );
2399 while ( TObject* elem = static_cast<TObject*>(elemIter() ) ) {
2400 if ( elem == objSelected ) {
2401 found = true;
2402 break;
2403 } else if ( dynamic_cast<TPad*>(elem) )
2404 stPad.push( dynamic_cast<TPad*>(elem) );
2405 }
2406 }
2407
2408 // Set the proper object and canvas (if found!)
2409 SetFitObject( found ? currentPad : nullptr, objSelected, kButton1Down);
2410}
2411
2412void TFitEditor::ProcessTreeInput(TObject* objSelected, Int_t selected, TString variables, TString cuts)
2413{
2414 // If the input is valid, insert the tree with the selections as an entry to fDataSet
2415 TString entryName = (objSelected)->ClassName(); entryName.Append("::"); entryName.Append((objSelected)->GetName());
2416 entryName.Append(" (\""); entryName.Append(variables); entryName.Append("\", \"");
2417 entryName.Append(cuts); entryName.Append("\")");
2419 fDataSet->InsertEntry(entryName, newid, selected );
2420 fDataSet->Select(newid);
2421}
2422
2423////////////////////////////////////////////////////////////////////////////////
2424/// Slot connected to predefined fit function settings.
2425
2427{
2429
2430 // check that selected passesd value is the correct one in the TextEntry
2431 R__ASSERT( selected == te->EntryId());
2432 //std::cout << "calling do function " << selected << " " << te->GetTitle() << " function " << te->EntryId() << std::endl;
2433 //selected = te->EntryId();
2434
2435 bool editable = false;
2437 {
2438 // Get the function selected and check weather it is a raw C
2439 // function or not
2440 TF1* tmpTF1 = FindFunction();
2441 if ( !tmpTF1 )
2442 {
2444 tmpTF1 = (TF1*) GetFitObjectListOfFunctions()->FindObject( te->GetTitle() );
2445 }
2446 if ( tmpTF1 && strcmp(tmpTF1->GetExpFormula(), "") )
2447 {
2448 editable = kTRUE;
2449 fEnteredFunc->SetText(tmpTF1->GetExpFormula());
2450 }
2451 else
2452 {
2453 if ( selected <= kFP_USER )
2454 editable = kTRUE;
2455 else
2456 editable = kFALSE;
2457 fEnteredFunc->SetText(te->GetTitle());
2458 }
2459 // Once you have the function, set the editable.
2460 SetEditable(editable);
2461 }
2462 else if (fAdd -> GetState() == kButtonDown)
2463 {
2464 // If the add button is down don't replace the fEnteredFunc text
2465 Int_t np = 0;
2466 TString s = "";
2467 if (!strcmp(fEnteredFunc->GetText(), ""))
2468 {
2469 fEnteredFunc->SetText(te->GetTitle());
2470 }
2471 else
2472 {
2473 s = fEnteredFunc->GetTitle();
2474 TFormula tmp("tmp", fEnteredFunc->GetText());
2475 np = tmp.GetNpar();
2476 }
2477 if (np)
2478 s += TString::Format("+%s(%d)", te->GetTitle(), np);
2479 else
2480 s += TString::Format("%s(%d)", te->GetTitle(), np);
2482 editable = true;
2483 }
2484 else if (fNormAdd->GetState() == kButtonDown)
2485 {
2486 // If the normadd button is down don't replace the fEnteredFunc text
2487 Int_t np = 0;
2488 TString s = "";
2489 if (!strcmp(fEnteredFunc->GetText(), ""))
2490 {
2491 fEnteredFunc->SetText(te->GetTitle());
2492 }
2493 else
2494 {
2495 s = fEnteredFunc->GetTitle();
2496 TFormula tmp("tmp", fEnteredFunc->GetText());
2497 np = tmp.GetNpar();
2498 }
2499 if (np)
2500 s += TString::Format("+%s", te->GetTitle());
2501 else
2502 s += TString::Format("%s", te->GetTitle());
2504 //std::cout <<fEnteredFunc->GetText()<<std::endl;
2505 editable = true;
2506 }
2507 else if (fConv->GetState() == kButtonDown)
2508 {
2509 // If the conv button is down don't replace the fEnteredFunc text
2510 Int_t np = 0;
2511 TString s = "";
2512 if (!strcmp(fEnteredFunc->GetText(), ""))
2513 fEnteredFunc->SetText(te->GetTitle());
2514 else
2515 {
2516 s = fEnteredFunc->GetTitle();
2517 TFormula tmp("tmp", fEnteredFunc->GetText());
2518 np = tmp.GetNpar();
2519 }
2520 if (np)
2521 s += TString::Format("*%s", te->GetTitle());
2522 else
2523 s += TString::Format("%s", te->GetTitle());
2525 //std::cout <<fEnteredFunc->GetText()<<std::endl;
2526 editable = true;
2527 }
2528
2529
2530 // Get the final name in fEnteredFunc to process the function that
2531 // it would create
2532 TString tmpStr = fEnteredFunc->GetText();
2533
2534 // create TF1 with the passed string. Delete previous one if existing
2535 if (tmpStr.Contains("pol") || tmpStr.Contains("++")) {
2537 } else {
2539 }
2540
2542 fSelLabel->SetText(tmpStr.Sizeof()>30?tmpStr(0,30)+"...":tmpStr);
2544
2545 // reset function parameters if the number of parameters of the new
2546 // function is different from the old one!
2547 TF1* fitFunc = GetFitFunction();
2548 //std::cout << "TFitEditor::DoFunction - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2549
2550 if ( fitFunc && (unsigned int) fitFunc->GetNpar() != fFuncPars.size() ) {
2552 fFuncPars.resize(fitFunc->GetNpar());
2553 else
2554 fFuncPars.clear();
2555 }
2556 if ( fitFunc ) {
2557 //std::cout << "TFitEditor::DoFunction - deleting function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2558 delete fitFunc;
2559 }
2560}
2561
2562////////////////////////////////////////////////////////////////////////////////
2563/// Slot connected to entered function in text entry.
2564
2566{
2567 if (!strcmp(fEnteredFunc->GetText(), "")) return;
2568
2569 // Check if the function is well built
2571
2572 if (ok != 0) {
2574 "Error...", "3) Verify the entered function string!",
2575 kMBIconStop,kMBOk, 0);
2576 return;
2577 }
2578
2579 // And set the label with the entered text if everything is fine.
2581 fSelLabel->SetText(s.Sizeof()>30?s(0,30)+"...":s);
2583}
2584
2585////////////////////////////////////////////////////////////////////////////////
2586/// Slot connected to linear fit settings.
2587
2589{
2590 if (fLinearFit->GetState() == kButtonDown) {
2591 //fSetParam->SetState(kButtonDisabled);
2595 //fNoChi2->SetState(kButtonUp);
2596 } else {
2597 //fSetParam->SetState(kButtonUp);
2602 //fNoChi2->SetState(kButtonDisabled);
2603 }
2604}
2605
2606////////////////////////////////////////////////////////////////////////////////
2607/// Slot connected to 'no chi2' option settings.
2608
2610{
2611 //LM: no need to do operations here
2612 // if (fLinearFit->GetState() == kButtonUp)
2613 // fLinearFit->SetState(kButtonDown, kTRUE);
2614}
2615////////////////////////////////////////////////////////////////////////////////
2616/// Slot connected to 'robust fitting' option settings.
2617
2625
2626////////////////////////////////////////////////////////////////////////////////
2627/// Slot connected to 'no storing, no drawing' settings.
2628
2634
2635////////////////////////////////////////////////////////////////////////////////
2636/// Slot connected to print option settings.
2637
2639{
2640 // Change the states of the buttons depending of which one is
2641 // selected.
2642 TGButton *btn = (TGButton *) gTQSender;
2643 Int_t id = btn->WidgetId();
2644 switch (id) {
2645 case kFP_PDEF:
2646 if (on) {
2650 }
2651 fStatusBar->SetText("Prn: DEF",4);
2652 break;
2653 case kFP_PVER:
2654 if (on) {
2658 }
2659 fStatusBar->SetText("Prn: VER",4);
2660 break;
2661 case kFP_PQET:
2662 if (on) {
2666 }
2667 fStatusBar->SetText("Prn: QT",4);
2668 default:
2669 break;
2670 }
2671}
2672
2673////////////////////////////////////////////////////////////////////////////////
2674/// Reset all fit parameters.
2675
2677{
2678 if ( fParentPad ) {
2680 fParentPad->Update();
2681 }
2682 fEnteredFunc->SetText("gaus");
2683
2684 // To restore temporary points and sliders
2685 UpdateGUI();
2686
2691 if (fUseRange->GetState() == kButtonDown)
2705 // if (fNoChi2->GetState() == kButtonDown)
2706 // fNoChi2->SetState(kButtonUp, kFALSE);
2707 if (fDrawSame->GetState() == kButtonDown)
2714 fFuncList->Select(1, kTRUE);
2715
2716 // minimization tab
2725 }
2729 }
2733 }
2734}
2735
2736////////////////////////////////////////////////////////////////////////////////
2737/// Open set parameters dialog.
2738
2740{
2741 // Get the function.
2742 TF1* fitFunc = GetFitFunction();
2743 //std::cout << "TFitEditor::DoSetParameters - using function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2744
2745 if (!fitFunc) { Error("DoSetParameters","NUll function"); return; }
2746
2747 // case of special functions (gaus, expo, etc...) if the function
2748 // has not defined the parameters yet. For those, don't let the
2749 // parameters to be all equal to 0, as we can provide some good
2750 // starting value.
2751 if (fFuncPars.size() == 0) {
2752 switch (fType) {
2753 case kObjectHisto:
2754 InitParameters( fitFunc, (TH1*)fFitObject) ;
2755 break;
2756 case kObjectGraph:
2757 InitParameters( fitFunc, ((TGraph*)fFitObject));
2758 break;
2759 case kObjectMultiGraph:
2760 InitParameters( fitFunc, ((TMultiGraph*)fFitObject));
2761 break;
2762 case kObjectGraph2D:
2763 InitParameters( fitFunc, ((TGraph2D*)fFitObject));
2764 break;
2765 case kObjectHStack:
2766 case kObjectTree:
2767 default:
2768 break;
2769 }
2770 // The put these parameters into the fFuncPars structure
2771 GetParameters(fFuncPars, fitFunc);
2772 }
2773 else {
2774 // Otherwise, put the parameters in the function
2775 SetParameters(fFuncPars, fitFunc);
2776 }
2777
2778 if ( fParentPad ) fParentPad->Disconnect("RangeAxisChanged()");
2779 Int_t ret = 0;
2780 /// fit parameter dialog willbe deleted automatically when closed
2781 new TFitParametersDialog(gClient->GetDefaultRoot(), GetMainFrame(),
2782 fitFunc, fParentPad, &ret);
2783
2784 // Once the parameters are set in the fitfunction, save them.
2785 GetParameters(fFuncPars, fitFunc);
2786
2787 // check return code to see if parameters settings have been modified
2788 // in this case we need to set the B option when fitting
2789 if (ret) fChangedParams = kTRUE;
2790
2791
2792 if ( fParentPad ) fParentPad->Connect("RangeAxisChanged()", "TFitEditor", this, "UpdateGUI()");
2793
2794 if ( fNone->GetState() != kButtonDisabled ) {
2795 //std::cout << "TFitEditor::DoSetParameters - deleting function " << fitFunc->GetName() << " " << fitFunc << std::endl;
2796 delete fitFunc;
2797 }
2798}
2799
2800////////////////////////////////////////////////////////////////////////////////
2801/// Slot connected to range settings on x-axis.
2802
2804{
2805 if ( !fFitObject ) return;
2806
2809
2811
2812 DrawSelection();
2813}
2814
2815////////////////////////////////////////////////////////////////////////////////
2816/// Draws the square around the object showing where the limits for
2817/// fitting are.
2818
2820{
2821 // method does not work with 3D plots
2822 if (!fParentPad || fParentPad->GetView())
2823 return;
2824
2825 // no longer need to restore previous values
2826 if (restore)
2827 return;
2828
2830
2832
2835
2836 TAttLine{2, 1, 1}.ModifyOn(*fParentPad);
2837
2838 if (fDim == 1) {
2839 Double_t xx1[2] = {xleft, xleft};
2840 Double_t xx2[2] = {xright, xright};
2841 Double_t yy[2] = { fParentPad->GetUymin(), fParentPad->GetUymax() };
2842 Double_t yydummy[2] = { yy[0], yy[0] }; // used to trigger update without real paint
2843 fParentPad->PaintPolyLine(2, xx1, fParentPad->GetUxmin() != xleft ? yy : yydummy, "ifitpanel1");
2844 fParentPad->PaintPolyLine(2, xx2, fParentPad->GetUxmax() != xright ? yy : yydummy, "ifitpanel2");
2845 } else if (fDim > 1) {
2848 fParentPad->PaintBox(xleft, ymin, xright, ymax, "ilfitpanel");
2849 }
2850
2852
2854}
2855
2856////////////////////////////////////////////////////////////////////////////////
2857/// Sincronize the numeric sliders with the graphical one.
2858
2860{
2862 float xmin, xmax;
2864 fSliderXMin->SetNumber( fXaxis->GetBinLowEdge( static_cast<Int_t>( xmin ) ) );
2865 fSliderXMax->SetNumber( fXaxis->GetBinUpEdge ( static_cast<Int_t>( xmax ) ) );
2866 return;
2867 }
2868
2871
2873
2874 DrawSelection();
2875}
2876
2877////////////////////////////////////////////////////////////////////////////////
2878/// Slot connected to range settings on y-axis.
2879
2881{
2882 if ( !fFitObject ) return;
2883
2886
2888
2889 DrawSelection();
2890}
2891
2892////////////////////////////////////////////////////////////////////////////////
2893///syncronize the numeric slider with the graphical one.
2894
2896{
2898 float ymin, ymax;
2900 fSliderYMin->SetNumber( fYaxis->GetBinLowEdge( static_cast<Int_t>( ymin ) ) );
2901 fSliderYMax->SetNumber( fYaxis->GetBinUpEdge ( static_cast<Int_t>( ymax ) ) );
2902 return;
2903 }
2904
2907
2909
2910 DrawSelection();
2911}
2912
2913////////////////////////////////////////////////////////////////////////////////
2914/// Slot connected to range settings on z-axis.
2915
2919
2920////////////////////////////////////////////////////////////////////////////////
2921/// Open a dialog for getting a user defined method.
2922
2924{
2926 "Info", "Dialog of user method is not implemented yet",
2928}
2929
2930////////////////////////////////////////////////////////////////////////////////
2931/// Set the function to be used in performed fit.
2932
2933void TFitEditor::SetFunction(const char *function)
2934{
2935 fEnteredFunc->SetText(function);
2936}
2937
2938////////////////////////////////////////////////////////////////////////////////
2939/// Check whether the object suitable for fitting and set
2940/// its type, dimension and method combo box accordingly.
2941
2943{
2944 Bool_t set = kFALSE;
2945
2946 // For each kind of object, set a different status in the fit
2947 // panel.
2948 if (obj->InheritsFrom(TGraph::Class())) {
2950 set = kTRUE;
2951 fDim = 1;
2953 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2956 fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
2957 } else if (obj->InheritsFrom(TGraph2D::Class())) {
2959 set = kTRUE;
2960 fDim = 2;
2962 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2964 } else if (obj->InheritsFrom(THStack::Class())) {
2966 set = kTRUE;
2967 TH1 *hist = (TH1 *)((THStack *)obj)->GetHists()->First();
2968 fDim = hist->GetDimension();
2970 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2972 } else if (obj->InheritsFrom(TTree::Class())) {
2974 set = kTRUE;
2975 TString variables, cuts;
2976 GetTreeVarsAndCuts(fDataSet, variables, cuts);
2977 fDim = 1;
2978 for ( int i = 0; i < variables.Length() && fDim <= 2; ++i )
2979 if ( ':' == variables[i] ) fDim += 1;
2980 // For any three of dimension bigger than 2, set the dimension
2981 // to 0, as we cannot infer the dimension from the TF1s, it's
2982 // better to have 0 as reference.
2983 if ( fDim > 2 ) fDim = 0;
2985 fMethodList->AddEntry("Unbinned Likelihood", kFP_MUBIN);
2987 } else if (obj->InheritsFrom(TH1::Class())){
2989 set = kTRUE;
2990 fDim = ((TH1*)obj)->GetDimension();
2992 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
2993 fMethodList->AddEntry("Binned Likelihood", kFP_MBINL);
2995 } else if (obj->InheritsFrom(TMultiGraph::Class())) {
2997 set = kTRUE;
2998 fDim = 1;
3000 fMethodList->AddEntry("Chi-square", kFP_MCHIS);
3003 fRobustValue->GetNumberEntry()->SetToolTipText("Set robust value");
3004 }
3005
3006 // Depending on the dimension of the object, allow the
3007 // visualization of sliders.
3008 if ( fDim < 2 || fType == kObjectTree )
3010 else
3012
3013 if ( fDim < 1 || fType == kObjectTree )
3015 else
3017
3018 // And also, depending on the dimension, add predefined functions.
3019 if ( fDim == 1 ) {
3020 if ( !fTypeFit->FindEntry("Predef-1D") )
3022 } else {
3023 if ( fTypeFit->FindEntry("Predef-1D") )
3025 }
3026
3027 if ( fDim == 2 ) {
3028 if ( !fTypeFit->FindEntry("Predef-2D") )
3030 } else {
3031 if ( fTypeFit->FindEntry("Predef-2D") )
3033 }
3034
3035 return set;
3036}
3037
3038////////////////////////////////////////////////////////////////////////////////
3039/// Show object name on the top.
3040
3042{
3043 TString name;
3044 bool isTree = false;
3045
3046 // Build the string to be compared to look for the object.
3047 if (obj) {
3048 name = obj->ClassName();
3049 name.Append("::");
3050 name.Append(obj->GetName());
3051 isTree = strcmp(obj->ClassName(), "TTree") == 0;
3052 } else {
3053 name = "No object selected";
3054 }
3055 fStatusBar->SetText(name.Data(),0);
3056
3057 // If the selection was done in the fDataSet combo box, there is no need
3058 // to search through the list
3059 TGTextLBEntry* selectedEntry = static_cast<TGTextLBEntry*> ( fDataSet->GetSelectedEntry());
3060 if ( selectedEntry ) {
3061 TString selectedName = selectedEntry->GetText()->GetString();
3062 if ( isTree )
3063 selectedName = selectedName(0, selectedName.First(' '));
3064 if ( name.CompareTo(selectedName) == 0 ) {
3065 Layout();
3066 return;
3067 }
3068 }
3069
3070 // Search through the list for the object
3071 Int_t entryId = kFP_NOSEL+1;
3072 bool found = false;
3073 while ( TGTextLBEntry* entry = static_cast<TGTextLBEntry*>
3074 ( fDataSet->GetListBox()->GetEntry(entryId)) ) {
3075 TString compareName = entry->GetText()->GetString();
3076 if ( isTree )
3077 compareName = compareName(0, compareName.First(' '));
3078 if ( name.CompareTo(compareName) == 0 ) {
3079 // If the object is found, select it
3080 fDataSet->Select(entryId, false);
3081 found = true;
3082 break;
3083 }
3084 entryId += 1;
3085 }
3086
3087 // If the object was not found, add it and select it.
3088 if ( !found ) {
3089 fDataSet->AddEntry(name.Data(), entryId);
3090 fDataSet->Select(entryId, kTRUE);
3091 }
3092
3093 Layout();
3094}
3095
3096////////////////////////////////////////////////////////////////////////////////
3097/// Get draw options of the selected object.
3098
3100{
3101 if (!fParentPad) return "";
3102
3104 TObject *obj;
3105 while ((obj = next())) {
3106 if (obj == fFitObject) return next.GetOption();
3107 }
3108 return "";
3109}
3110
3111////////////////////////////////////////////////////////////////////////////////
3112/// Set selected minimization library in use.
3113
3115{
3116 TGButton *bt = (TGButton *)gTQSender;
3117 Int_t id = bt->WidgetId();
3118
3119 switch (id) {
3120
3121 // Depending on the selected library, set the state of the rest
3122 // of the buttons.
3123 case kFP_LMIN:
3124 {
3125 if (on) {
3129 if ( fLibGSL->GetState() != kButtonDisabled )
3133 fStatusBar->SetText("LIB Minuit", 1);
3134 }
3135
3136 }
3137 break;
3138
3139 case kFP_LMIN2:
3140 {
3141 if (on) {
3145 if ( fLibGSL->GetState() != kButtonDisabled )
3149 fStatusBar->SetText("LIB Minuit2", 1);
3150 }
3151 }
3152 break;
3153
3154 case kFP_LFUM:
3155 {
3156 if (on) {
3160 if ( fLibGSL->GetState() != kButtonDisabled )
3164 fStatusBar->SetText("LIB Fumili", 1);
3165 }
3166 }
3167 break;
3168 case kFP_LGSL:
3169 {
3170 if (on) {
3174 if ( fLibGSL->GetState() != kButtonDisabled )
3178 fStatusBar->SetText("LIB GSL", 1);
3179 }
3180 }
3181 break;
3182 case kFP_LGAS:
3183 {
3184 if (on) {
3188 if ( fLibGSL->GetState() != kButtonDisabled )
3192 fStatusBar->SetText("LIB Genetics", 1);
3193 }
3194 }
3195 default:
3196 break;
3197 }
3199}
3200
3201////////////////////////////////////////////////////////////////////////////////
3202/// Set selected minimization method in use.
3203
3205{
3207 fStatusBar->SetText("MIGRAD",2);
3208 else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3209 fStatusBar->SetText("FUMILI",2);
3210 else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3211 fStatusBar->SetText("SIMPLEX",2);
3212 else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3213 fStatusBar->SetText("SCAN",2);
3215 fStatusBar->SetText("Combination",2);
3216 else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3217 fStatusBar->SetText("CONJFR",2);
3218 else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3219 fStatusBar->SetText("CONJPR",2);
3220 else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3221 fStatusBar->SetText("BFGS",2);
3222 else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3223 fStatusBar->SetText("BFGS2",2);
3224 else if ( fMinMethodList->GetSelected() == kFP_GSLLM )
3225 fStatusBar->SetText("GSLLM",2);
3226 else if ( fMinMethodList->GetSelected() == kFP_GSLSA)
3227 fStatusBar->SetText("SimAn",2);
3228 else if ( fMinMethodList->GetSelected() == kFP_TMVAGA )
3229 fStatusBar->SetText("TMVAGA",2);
3230 else if ( fMinMethodList->GetSelected() == kFP_GALIB )
3231 fStatusBar->SetText("GALIB",2);
3232
3233
3234}
3235
3236////////////////////////////////////////////////////////////////////////////////
3237/// Set the maximum number of iterations.
3238
3240{
3242 fStatusBar->SetText(Form("Itr: %ld",itr),2);
3243}
3244
3245////////////////////////////////////////////////////////////////////////////////
3246/// Create section title in the GUI.
3247
3248void TFitEditor::MakeTitle(TGCompositeFrame *parent, const char *title)
3249{
3250 TGCompositeFrame *ht = new TGCompositeFrame(parent, 350, 10,
3252 ht->AddFrame(new TGLabel(ht, title),
3253 new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
3254 ht->AddFrame(new TGHorizontal3DLine(ht),
3255 new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 5, 5, 2, 2));
3256 parent->AddFrame(ht, new TGLayoutHints(kLHintsTop, 5, 0, 5, 0));
3257}
3258
3259////////////////////////////////////////////////////////////////////////////////
3260/// Look in the list of function for TF1. If a TF1 is
3261/// found in the list of functions, it will be returned
3262
3264{
3265 // Get the list of functions of the fit object
3267 TF1* func = 0;
3268
3269 // If it exists
3270 if ( lf ) {
3271 // Add the posibility to select previous fit function
3272 if ( !fTypeFit->FindEntry("Prev. Fit") )
3274
3275 // Then add all these functions to the fPrefFit structure.
3276 TObject *obj2;
3277 TIter next(lf, kIterForward);
3278 // Go over all the elements in lf
3279 while ((obj2 = next())) {
3280 if (obj2->InheritsFrom(TF1::Class())) {
3281 func = (TF1 *)obj2;
3282 fPrevFitIter it;
3283 // No go over all elements in fPrevFit
3284 for ( it = fPrevFit.begin(); it != fPrevFit.end(); ++it) {
3285 // To see wheather the object corresponds with fFitObject
3286 if ( it->first != fFitObject ) continue;
3287 // And if so, whether the function is already included
3288 if ( strcmp( func->GetName(), it->second->GetName() ) == 0 )
3289 break;
3290 if ( strcmp( func->GetName(), "PrevFitTMP" ) == 0 )
3291 break;
3292 }
3293 // Only if the function is not already in fPrevFit, the
3294 // breaks in the loops would make it to be different to
3295 // fPrevFit.end() if the function is already stored
3296 if ( it == fPrevFit.end() ) {
3297 fPrevFit.emplace(fFitObject, copyTF1(func));
3298 }
3299 }
3300 }
3301
3302 // Select the PrevFit set
3304 // And fill the function list
3307
3308
3309 } else {
3310 // If there is no prev fit functions.
3312 // Call FillFunctionList as it might happen that the user is
3313 // changing from a TTree to another one, and thus the fFuncList
3314 // if not properly filled
3316 }
3317
3319
3320 return func;
3321}
3322
3323////////////////////////////////////////////////////////////////////////////////
3324/// Retrieve the fitting options from all the widgets.
3325
3327{
3328 drawOpts = "";
3329
3330 fitOpts.Range = (fUseRange->GetState() == kButtonDown);
3331 fitOpts.Integral = (fIntegral->GetState() == kButtonDown);
3332 fitOpts.More = (fImproveResults->GetState() == kButtonDown);
3333 fitOpts.Errors = (fBestErrors->GetState() == kButtonDown);
3334 fitOpts.Like = (fMethodList->GetSelected() != kFP_MCHIS);
3335
3337 fitOpts.W1 = 2;
3338 else if (fAllWeights1->GetState() == kButtonDown)
3339 fitOpts.W1 = 1;
3340
3341 TString tmpStr = fEnteredFunc->GetText();
3342 if ( !(fLinearFit->GetState() == kButtonDown) &&
3343 (tmpStr.Contains("pol") || tmpStr.Contains("++")) )
3344 fitOpts.Minuit = 1;
3345
3346 // if ( (int) fFuncPars.size() == npar )
3347 // for ( Int_t i = 0; i < npar; ++i )
3348 // if ( fFuncPars[i][PAR_MIN] != fFuncPars[i][PAR_MAX] )
3349 //
3350
3351 // //fitOpts.Bound = 1;
3352 // break;
3353 // }
3354
3355 if (fChangedParams) {
3356 //std::cout << "Params have changed setting the Bound option " << std::endl;
3357 fitOpts.Bound = 1;
3358 fChangedParams = kFALSE; // reset
3359 }
3360
3361 //fitOpts.Nochisq = (fNoChi2->GetState() == kButtonDown);
3362 fitOpts.Nostore = (fNoStoreDrawing->GetState() == kButtonDown);
3363 fitOpts.Nograph = (fNoDrawing->GetState() == kButtonDown);
3364 fitOpts.Plus = (fAdd2FuncList->GetState() == kButtonDown);
3365 fitOpts.Gradient = (fUseGradient->GetState() == kButtonDown);
3366 fitOpts.Quiet = ( fOptQuiet->GetState() == kButtonDown );
3367 fitOpts.Verbose = ( fOptVerbose->GetState() == kButtonDown );
3368
3369 if ( !(fType != kObjectGraph) && (fEnableRobust->GetState() == kButtonDown) )
3370 {
3371 fitOpts.Robust = 1;
3372 fitOpts.hRobust = fRobustValue->GetNumber();
3373 }
3374
3375 drawOpts = GetDrawOption();
3376
3377 if ( fLibMinuit->GetState() == kButtonDown )
3378 minOpts.SetMinimizerType ( "Minuit");
3379 else if ( fLibMinuit2->GetState() == kButtonDown)
3380 minOpts.SetMinimizerType ( "Minuit2" );
3381 else if ( fLibFumili->GetState() == kButtonDown )
3382 minOpts.SetMinimizerType ("Fumili" );
3383 else if ( fLibGSL->GetState() == kButtonDown )
3384 minOpts.SetMinimizerType ("GSLMultiMin" );
3385
3387 minOpts.SetMinimizerAlgorithm( "Migrad" );
3388 else if ( fMinMethodList->GetSelected() == kFP_FUMILI)
3389 if ( fLibMinuit2->GetState() == kButtonDown )
3390 minOpts.SetMinimizerAlgorithm( "Fumili2" );
3391 else
3392 minOpts.SetMinimizerAlgorithm( "Fumili" );
3393 else if ( fMinMethodList->GetSelected() == kFP_SIMPLX )
3394 minOpts.SetMinimizerAlgorithm( "Simplex" );
3395 else if ( fMinMethodList->GetSelected() == kFP_SCAN )
3396 minOpts.SetMinimizerAlgorithm( "Scan" );
3398 minOpts.SetMinimizerAlgorithm( "Minimize" );
3399 else if ( fMinMethodList->GetSelected() == kFP_GSLFR )
3400 minOpts.SetMinimizerAlgorithm( "conjugatefr" );
3401 else if ( fMinMethodList->GetSelected() == kFP_GSLPR )
3402 minOpts.SetMinimizerAlgorithm( "conjugatepr" );
3403 else if ( fMinMethodList->GetSelected() == kFP_BFGS )
3404 minOpts.SetMinimizerAlgorithm( "bfgs" );
3405 else if ( fMinMethodList->GetSelected() == kFP_BFGS2 )
3406 minOpts.SetMinimizerAlgorithm( "bfgs2" );
3407 else if ( fMinMethodList->GetSelected() == kFP_GSLLM ) {
3408 minOpts.SetMinimizerType ("GSLMultiFit" );
3409 minOpts.SetMinimizerAlgorithm( "" );
3410 } else if ( fMinMethodList->GetSelected() == kFP_GSLSA) {
3411 minOpts.SetMinimizerType ("GSLSimAn" );
3412 minOpts.SetMinimizerAlgorithm( "" );
3413 } else if ( fMinMethodList->GetSelected() == kFP_TMVAGA) {
3414 minOpts.SetMinimizerType ("Geneti2c" );
3415 minOpts.SetMinimizerAlgorithm( "" );
3416 } else if ( fMinMethodList->GetSelected() == kFP_GALIB) {
3417 minOpts.SetMinimizerType ("GAlibMin" );
3418 minOpts.SetMinimizerAlgorithm( "" );
3419 }
3420
3421 minOpts.SetErrorDef ( fErrorScale->GetNumber() );
3422 minOpts.SetTolerance( fTolerance->GetNumber() );
3423 minOpts.SetMaxIterations(fIterations->GetIntNumber());
3424 minOpts.SetMaxFunctionCalls(fIterations->GetIntNumber());
3425}
3426
3428{
3429 // Set the state of some input widgets depending on whether the fit
3430 // function can be defined by text or if it is an existing one.
3431 if ( state )
3432 {
3433 fEnteredFunc-> SetState(kTRUE);
3434 fAdd -> SetState(kButtonUp, kFALSE);
3435 fNormAdd -> SetState(kButtonUp, kFALSE);
3436 fConv -> SetState(kButtonUp, kFALSE);
3437 fNone -> SetState(kButtonDown,kFALSE); // fNone::State is the one used as reference
3438 }
3439 else
3440 {
3441 fEnteredFunc-> SetState(kFALSE);
3442 fAdd -> SetState(kButtonDisabled, kFALSE);
3443 fNormAdd -> SetState(kButtonDisabled, kFALSE);
3444 fConv -> SetState(kButtonDisabled, kFALSE);
3445 fNone -> SetState(kButtonDisabled, kFALSE);
3446 }
3447}
3448
3450{
3451 // Return the ranges selected by the sliders.
3452
3453 // It's not working for trees as they don't have TAxis.
3454 if ( fType == kObjectTree ) return;
3455
3456 if ( fType != kObjectTree ) {
3457 Int_t ixmin = (Int_t)(fSliderX->GetMinPosition());
3458 Int_t ixmax = (Int_t)(fSliderX->GetMaxPosition());
3460 Double_t xmax = fXaxis->GetBinUpEdge(ixmax);
3461 drange.AddRange(0,xmin, xmax);
3462 }
3463
3464 if ( fDim > 1 ) {
3465 assert(fYaxis);
3466 Int_t iymin = (Int_t)(fSliderY->GetMinPosition());
3467 Int_t iymax = (Int_t)(fSliderY->GetMaxPosition());
3469 Double_t ymax = fYaxis->GetBinUpEdge(iymax);
3470 drange.AddRange(1,ymin, ymax);
3471 }
3472 if ( fDim > 2 ) {
3473 assert(fZaxis);
3474 Int_t izmin = (Int_t)(fSliderZ->GetMinPosition());
3475 Int_t izmax = (Int_t)(fSliderZ->GetMaxPosition());
3476 Double_t zmin = fZaxis->GetBinLowEdge(izmin);
3477 Double_t zmax = fZaxis->GetBinUpEdge(izmax);
3478 drange.AddRange(2,zmin, zmax);
3479 }
3480}
3481
3483{
3484 // Get the list of functions previously used in the fitobject.
3485
3486 TList *listOfFunctions = 0;
3487 if ( fFitObject ) {
3488 switch (fType) {
3489
3490 case kObjectHisto:
3491 listOfFunctions = ((TH1 *)fFitObject)->GetListOfFunctions();
3492 break;
3493
3494 case kObjectGraph:
3495 listOfFunctions = ((TGraph *)fFitObject)->GetListOfFunctions();
3496 break;
3497
3498 case kObjectMultiGraph:
3499 listOfFunctions = ((TMultiGraph *)fFitObject)->GetListOfFunctions();
3500 break;
3501
3502 case kObjectGraph2D:
3503 listOfFunctions = ((TGraph2D *)fFitObject)->GetListOfFunctions();
3504 break;
3505
3506 case kObjectHStack:
3507 case kObjectTree:
3508 default:
3509 break;
3510 }
3511 }
3512 return listOfFunctions;
3513}
3514
3516{
3517 // Looks for all the functions registered in the current ROOT
3518 // session.
3519
3520 // First, clean the copies stored in fSystemFunc
3521 for (auto func : fSystemFuncs)
3522 delete func;
3523
3524 fSystemFuncs.clear();
3525
3526 // Be carefull not to store functions that will be in the
3527 // predefined section
3528 const unsigned int nfuncs = 16;
3529 const char* fnames[nfuncs] = { "gaus" , "gausn", "expo", "landau",
3530 "landaun", "pol0", "pol1", "pol2",
3531 "pol3", "pol4", "pol5", "pol6",
3532 "pol7", "pol8", "pol9", "user"
3533 };
3534
3535 // No go through all the objects registered in gROOT
3536 TIter functionsIter(gROOT->GetListOfFunctions());
3537 TObject* obj;
3538 while( ( obj = (TObject*) functionsIter() ) ) {
3539 // And if they are TF1s
3540 if ( TF1* func = dynamic_cast<TF1*>(obj) ) {
3541 bool addFunction = true;
3542 // And they are not already registered in fSystemFunc
3543 for ( unsigned int i = 0; i < nfuncs; ++i ) {
3544 if ( strcmp( func->GetName(), fnames[i] ) == 0 ) {
3545 addFunction = false;
3546 break;
3547 }
3548 }
3549 // Add them.
3550 if ( addFunction )
3551 fSystemFuncs.emplace_back( copyTF1(func) );
3552 }
3553 }
3554}
3555
3557{
3558 // This function returns a TList with all the functions used in the
3559 // FitPanel to fit a given object. If the object passed is NULL,
3560 // then the object used is the currently selected one. It is
3561 // important to notice that the FitPanel is still the owner of
3562 // those functions. This means that the user SHOULD NOT delete any
3563 // of these functions, as the FitPanel will do so in the
3564 // destructor.
3565
3566 if (!obj) obj = fFitObject;
3567
3568 TList *retList = new TList();
3569
3570 std::pair<fPrevFitIter, fPrevFitIter> look = fPrevFit.equal_range(obj);
3571 for ( fPrevFitIter it = look.first; it != look.second; ++it ) {
3572 retList->Add(it->second);
3573 }
3574
3575 return retList;
3576}
3577
3579{
3580 // Get the fit function selected or declared in the fiteditor
3581
3582 TF1 *fitFunc = 0;
3583 // If the function is not editable ==> it means it is registered in
3584 // gROOT
3585 if ( fNone->GetState() == kButtonDisabled )
3586 {
3587 // So we find it
3588 TF1* tmpF1 = FindFunction();
3589 // And if we don't find it, then it means there is something wrong!
3590 if ( tmpF1 == 0 )
3591 {
3593 "Error...", "1) Verify the entered function string!",
3594 kMBIconStop,kMBOk, 0);
3595 return 0;
3596 }
3597
3598 // Now we make a copy that will be used temporary. The caller of
3599 // the function should delete the returned function.
3600 fitFunc = (TF1*)tmpF1->IsA()->New();
3601 tmpF1->Copy(*fitFunc);
3602 // Copy the parameters of the function, if and only if the
3603 // parameters stored does not correspond with the ones of these
3604 // functions. Perhaps the user has already called
3605 // DoSetParameters. There is no way to know whether the
3606 // parameters have been modified, so we check the size of
3607 // fFuncPars against number of parameters.
3608 if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3609 {
3610 fitFunc->SetParameters(tmpF1->GetParameters());
3611 GetParameters(fFuncPars, fitFunc);
3612 } else {
3613 SetParameters(fFuncPars, fitFunc);
3614 }
3615 }
3616
3617 // If, we have no function at this point, it means that is is
3618 // described in fEnteredFunc, so we create it from scratch.
3619 if ( fitFunc == 0 )
3620 {
3621 ROOT::Fit::DataRange drange;
3622 GetRanges(drange);
3623 double xmin, xmax, ymin, ymax, zmin, zmax;
3624 drange.GetRange(xmin, xmax, ymin, ymax, zmin, zmax);
3625
3626 // Depending of course on the number of dimensions the object
3627 // has. These commands will raise an error message if the user
3628 // has not defined the function properly
3629 if ( fDim == 1 || fDim == 0 )
3630 {
3631
3632 fitFunc = new TF1("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax );
3633 //std::cout << "GetFitFunction - created function PrevFitTMP " << fEnteredFunc->GetText() << " " << fitFunc << std::endl;
3634 if (fNormAdd->IsOn())
3635 {
3636 if (fSumFunc) delete fSumFunc;
3638 fitFunc = new TF1("PrevFitTMP", *fSumFunc, xmin, xmax, fSumFunc->GetNpar());
3639 for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fSumFunc->GetParName(i) );
3640 //std::cout << "create fit normalized function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3641 }
3642
3643 if (fConv -> IsOn())
3644 {
3645 if (fConvFunc) delete fConvFunc;
3647 fitFunc = new TF1("PrevFitTMP", *fConvFunc, xmin, xmax, fConvFunc->GetNpar());
3648 for (int i = 0; i < fitFunc->GetNpar(); ++i) fitFunc->SetParName(i, fConvFunc->GetParName(i) );
3649 //std::cout << "create fit convolution function " << fSumFunc << " fitfunc " << fitFunc << std::endl;
3650 }
3651 }
3652 else if ( fDim == 2 ) {
3653 fitFunc = new TF2("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax );
3654 }
3655 else if ( fDim == 3 ) {
3656 fitFunc = new TF3("PrevFitTMP",fEnteredFunc->GetText(), xmin, xmax, ymin, ymax, zmin, zmax );
3657 }
3658
3659 // if the function is not a C defined
3660 if ( fNone->GetState() != kButtonDisabled )
3661 {
3662 // and the formulas are the same
3663 TF1* tmpF1 = FindFunction();
3664// if (tmpF1)
3665 //std::cout << "GetFitFunction: found existing function " << tmpF1 << " " << tmpF1->GetName() << " " << tmpF1->GetExpFormula() << std::endl;
3666// else
3667 //std::cout << "GetFitFunction: - no existing function found " << std::endl;
3668 if ( tmpF1 != 0 && fitFunc != 0 &&
3669 strcmp(tmpF1->GetExpFormula(), fEnteredFunc->GetText()) == 0 ) {
3670 // copy everything from the founction available in gROOT
3671 //std::cout << "GetFitFunction: copying tmp function in PrevFitTMP " << tmpF1->GetName() << " "
3672 // << tmpF1->GetExpFormula() << std::endl;
3673 tmpF1->Copy(*fitFunc);
3674 if ( int(fFuncPars.size()) != tmpF1->GetNpar() )
3675 {
3676 GetParameters(fFuncPars, fitFunc);
3677 }
3678 }
3679 }
3680 }
3681
3682 return fitFunc;
3683}
@ kButton1Down
Definition Buttons.h:17
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kFixedSize
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
std::string className
Definition JSONIO.cxx:31
#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
cudaEvent_t event
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
const Bool_t kIterForward
Definition TCollection.h:42
#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:139
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:142
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:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2571
#define gPad
#define gVirtualX
Definition TVirtualX.h:391
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()
Allows to create advanced graphics from the last fit made in the fitpanel.
Line Attributes class.
Definition TAttLine.h:21
virtual void ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
Definition TAttLine.cxx:255
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:529
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:480
Int_t GetNbins() const
Definition TAxis.h:127
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:539
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:469
The Canvas class.
Definition TCanvas.h:23
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:5107
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:463
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition TF1.cxx:1991
static TClass * Class()
virtual Int_t GetNpar() const
Definition TF1.h:446
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
Definition TF1.cxx:3563
virtual void SetParameter(Int_t param, Double_t value)
Definition TF1.h:608
TClass * IsA() const override
Definition TF1.h:694
virtual Double_t GetParameter(Int_t ipar) const
Definition TF1.h:477
A 2-Dim function with parameters.
Definition TF2.h:29
TClass * IsA() const override
Definition TF2.h:130
TF3 defines a 3D Function with Parameters.
Definition TF3.h:28
TClass * IsA() const override
Definition TF3.h:124
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.
Bool_t fDrawingSelection
Definition TFitEditor.h:146
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:148
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:240
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:440
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:454
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:230
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:224
UInt_t GetDisplayWidth() const
Get display width.
Definition TGClient.cxx:262
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:1111
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition TGFrame.cxx:1212
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:961
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1158
TGCompositeFrame(const TGCompositeFrame &)=delete
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1251
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1198
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1066
void ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1037
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1184
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:623
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:599
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:532
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:1851
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition TGFrame.cxx:1794
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1886
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1781
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:153
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:296
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:126
TAxis * GetZaxis()
Definition TH1.h:603
static TClass * Class()
virtual Int_t GetDimension() const
Definition TH1.h:557
TAxis * GetXaxis()
Definition TH1.h:601
TAxis * GetYaxis()
Definition TH1.h:602
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:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
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:548
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:506
The most important graphics class in the ROOT system.
Definition TPad.h:32
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
virtual Bool_t HasConnection(const char *signal_name) const
Return true if there is any object connected to this signal.
Definition TQObject.cxx:523
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:137
const char * Data() const
Definition TString.h:385
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:2460
virtual Int_t Sizeof() const
Returns size string will occupy on I/O buffer.
Definition TString.cxx:1482
Tree Input Dialog Widget.
Definition TTreeInput.h:22
A TTree represents a columnar dataset.
Definition TTree.h:95
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6561
void Draw(Option_t *opt) override
Default Draw method for all objects.
Definition TTree.h:492
static TClass * Class()
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:58
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual void Modified(Bool_t flag=1)=0
virtual Double_t GetUymax() const =0
virtual TList * GetListOfPrimitives() const =0
virtual void UpdateAsync()=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual void Update()=0
virtual void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="")=0
virtual Double_t GetUxmax() const =0
virtual void PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="")=0
virtual Double_t GetUymin() const =0
virtual Double_t GetUxmin() const =0
virtual TView * GetView() 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:983
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:832
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