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