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