Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TF2.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 23/08/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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#include "TROOT.h"
13#include "TF2.h"
14#include "TMath.h"
15#include "TRandom.h"
16#include "TBuffer.h"
17#include "TH2.h"
18#include "TVirtualPad.h"
19#include <iostream>
20#include "TColor.h"
21#include "TVirtualFitter.h"
23#include "snprintf.h"
24
26
27/** \class TF2
28 \ingroup Functions
29 \brief A 2-Dim function with parameters.
30
31The following types of functions can be created:
32
331. [Expression using variables x and y](\ref TF2a)
342. [Expression using a user defined function](\ref TF2b)
353. [Lambda Expression with x and y variables and parameters](\ref TF2c)
36
37\anchor TF2a
38### Expression using variables x and y
39
40Begin_Macro (source)
41{
42 auto f2 = new TF2("f2","sin(x)*sin(y)/(x*y)",0,5,0,5);
43 f2->Draw();
44}
45End_Macro
46
47\anchor TF2b
48### Expression using a user defined function
49
50~~~~{.cpp}
51Double_t func(Double_t *val, Double_t *par)
52{
53 Float_t x = val[0];
54 Float_t y = val[1];
55 Double_t f = x*x-y*y;
56 return f;
57}
58
59void fplot()
60{
61 auto f = new TF2("f",func,-1,1,-1,1);
62 f->Draw("surf1");
63}
64~~~~
65
66\anchor TF2c
67### Lambda Expression with x and y variables and parameters
68
69~~~~{.cpp}
70root [0] TF2 f2("f2", [](double* x, double*p) { return x[0] + x[1] * p[0]; }, 0., 1., 0., 1., 1)
71(TF2 &) Name: f2 Title: f2
72root [1] f2.SetParameter(0, 1.)
73root [2] f2.Eval(1., 2.)
74(double) 3.0000000
75~~~~
76
77See TF1 class for the list of functions formats
78*/
79
80////////////////////////////////////////////////////////////////////////////////
81/// TF2 default constructor
82
83TF2::TF2(): fYmin(0),fYmax(0),fNpy(100)
84{
85}
86
87
88////////////////////////////////////////////////////////////////////////////////
89/// F2 constructor using a formula definition
90///
91/// See TFormula constructor for explanation of the formula syntax.
92///
93/// If formula has the form "fffffff;xxxx;yyyy", it is assumed that
94/// the formula string is "fffffff" and "xxxx" and "yyyy" are the
95/// titles for the X and Y axis respectively.
96
97TF2::TF2(const char *name,const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Option_t * opt)
98 :TF1(name,formula,xmax,xmin,opt)
99{
100 if (ymin < ymax) {
101 fYmin = ymin;
102 fYmax = ymax;
103 } else {
104 fYmin = ymax;
105 fYmax = ymin;
106 }
107 fNpx = 30;
108 fNpy = 30;
109 fContour.Set(0);
110 // accept 1-d formula
111 if (GetNdim() < 2) fNdim = 2;
112 // dimension is obtained by TFormula
113 // accept cases where formula dim is less than 2
114 if (GetNdim() > 2 && xmin < xmax && ymin < ymax) {
115 Error("TF2","function: %s/%s has dimension %d instead of 2",name,formula,GetNdim());
116 MakeZombie();
117 }
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// F2 constructor using a pointer to a compiled function
123///
124/// npar is the number of free parameters used by the function
125///
126/// This constructor creates a function of type C when invoked
127/// with the normal C++ compiler.
128///
129/// WARNING! A function created with this constructor cannot be Cloned.
130
132 : TF1(name, fcn, xmin, xmax, npar,ndim)
133{
134 fYmin = ymin;
135 fYmax = ymax;
136 fNpx = 30;
137 fNpy = 30;
138 fContour.Set(0);
139}
140
143{
144 fYmin = ymin;
145 fYmax = ymax;
146 fNpx = 30;
147 fNpy = 30;
148 fContour.Set(0);
149}
150
151
152////////////////////////////////////////////////////////////////////////////////
153/// F2 constructor using a pointer to a compiled function
154///
155/// npar is the number of free parameters used by the function
156///
157/// This constructor creates a function of type C when invoked
158/// with the normal C++ compiler.
159///
160/// WARNING! A function created with this constructor cannot be Cloned.
161
163 : TF1(name, fcn, xmin, xmax, npar,ndim)
164{
165 fYmin = ymin;
166 fYmax = ymax;
167 fNpx = 30;
168 fNpy = 30;
169 fContour.Set(0);
170
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// F2 constructor using a ParamFunctor,
175/// a functor class implementing operator() (double *, double *)
176///
177/// npar is the number of free parameters used by the function
178///
179/// WARNING! A function created with this constructor cannot be Cloned.
180
182 : TF1(name, f, xmin, xmax, npar,ndim)
183{
184 fYmin = ymin;
185 fYmax = ymax;
186 fNpx = 30;
187 fNpy = 30;
188 fContour.Set(0);
189
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Operator =
194
196{
197 if (this != &rhs)
198 rhs.TF2::Copy(*this);
199 return *this;
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// F2 default destructor
204
206{
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Copy constructor.
211
212TF2::TF2(const TF2 &f2) : TF1()
213{
214 f2.TF2::Copy(*this);
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Copy this F2 to a new F2
219
220void TF2::Copy(TObject &obj) const
221{
222 TF1::Copy(obj);
223 ((TF2&)obj).fYmin = fYmin;
224 ((TF2&)obj).fYmax = fYmax;
225 ((TF2&)obj).fNpy = fNpy;
226 fContour.Copy(((TF2&)obj).fContour);
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Compute distance from point px,py to a function
231///
232/// \param[in] px x position
233/// \param[in] py y position
234///
235/// Compute the closest distance of approach from point px,py to this function.
236/// The distance is computed in pixels units.
237
239{
240 if (!fHistogram) return 9999;
242 if (distance <= 1) return distance;
243
244 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
245 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
246 const char *drawOption = GetDrawOption();
249 if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
250 || strncmp(drawOption,"CONT",4) == 0) {
251 uxmin=gPad->GetUxmin();
252 uxmax=gPad->GetUxmax();
253 x = fXmin +(fXmax-fXmin)*(x-uxmin)/(uxmax-uxmin);
254 uymin=gPad->GetUymin();
255 uymax=gPad->GetUymax();
256 y = fYmin +(fYmax-fYmin)*(y-uymin)/(uymax-uymin);
257 }
258 if (x < fXmin || x > fXmax) return distance;
259 if (y < fYmin || y > fYmax) return distance;
260 return 0;
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Draw this function with its current attributes
265///
266/// NB. You must use DrawCopy if you want to draw several times the same
267/// function in the current canvas.
268
270{
271 TString opt = option;
272 opt.ToLower();
273 if (gPad && !opt.Contains("same")) gPad->Clear();
274
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Draw a copy of this function with its current attributes-*
280///
281/// This function MUST be used instead of Draw when you want to draw
282/// the same function with different parameters settings in the same canvas.
283///
284/// Possible option values are:
285///
286/// option | description
287/// ---------|------------
288/// "SAME" | superimpose on top of existing picture
289/// "L" | connect all computed points with a straight line
290/// "C" | connect all computed points with a smooth curve.
291///
292/// Note that the default value is "F". Therefore to draw on top
293/// of an existing picture, specify option "SL"
294
295
297{
298 TF2 *newf2 = new TF2();
299 Copy(*newf2);
300 newf2->AppendPad(option);
301 newf2->SetBit(kCanDelete);
302 return newf2;
303}
304
305// remove this function
306//______________________________________________________________________________
307// void TF2::DrawF2(const char *formula, Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Option_t *option)
308// {
309// //----Draw formula between xmin,ymin and xmax,ymax---
310// // ============================================
311// //
312
313// //if (Compile((char*)formula)) return;
314
315// SetRange(xmin, ymin, xmax, ymax);
316
317// Draw(option);
318
319// }
320
321////////////////////////////////////////////////////////////////////////////////
322/// Execute action corresponding to one event
323///
324/// This member function is called when a F2 is clicked with the locator
325
327{
328 TF1::ExecuteEvent(event, px, py);
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Return contour values into array levels
333///
334/// The number of contour levels can be returned by getContourLevel
335
337{
339 if (levels) {
340 for (Int_t level=0; level<nlevels; level++) levels[level] = GetContourLevel(level);
341 }
342 return nlevels;
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Return the number of contour levels
347
349{
350 if (level <0 || level >= fContour.fN) return 0;
351 if (fContour.fArray[0] != -9999) return fContour.fArray[level];
352 if (fHistogram == nullptr) return 0;
353 return fHistogram->GetContourLevel(level);
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Return minimum/maximum value of the function
358///
359/// To find the minimum on a range, first set this range via the SetRange function.
360/// If a vector x of coordinate is passed it will be used as starting point for the minimum.
361/// In addition on exit x will contain the coordinate values at the minimuma
362///
363/// If x is NULL or x is infinity or NaN, first, a grid search is performed to find the initial estimate of the
364/// minimum location. The range of the function is divided into fNpx and fNpy
365/// sub-ranges. If the function is "good" (or "bad"), these values can be changed
366/// by SetNpx and SetNpy functions
367///
368/// Then, a minimization is used with starting values found by the grid search
369/// The minimizer algorithm used (by default Minuit) can be changed by callinga
370/// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
371/// Other option for the minimizer can be set using the static method of the MinimizerOptions class
372
374{
375 //First do a grid search with step size fNpx and fNpy
376
377 Double_t xx[2];
378 Double_t rsign = (findmax) ? -1. : 1.;
379 TF2 & function = const_cast<TF2&>(*this); // needed since EvalPar is not const
380 Double_t xxmin = 0, yymin = 0, zzmin = 0;
381 if (x == nullptr || ( (x!= nullptr) && ( !TMath::Finite(x[0]) || !TMath::Finite(x[1]) ) ) ){
382 Double_t dx = (fXmax - fXmin)/fNpx;
383 Double_t dy = (fYmax - fYmin)/fNpy;
384 xxmin = fXmin;
385 yymin = fYmin;
387 for (Int_t i=0; i<fNpx; i++){
388 xx[0]=fXmin + (i+0.5)*dx;
389 for (Int_t j=0; j<fNpy; j++){
390 xx[1]=fYmin+(j+0.5)*dy;
391 Double_t zz = function(xx);
392 if (rsign*zz < rsign*zzmin) {xxmin = xx[0], yymin = xx[1]; zzmin = zz;}
393 }
394 }
395
398 }
399 else {
400 xxmin = x[0];
401 yymin = x[1];
402 zzmin = function(x);
403 }
404 xx[0] = xxmin;
405 xx[1] = yymin;
406
407 double fmin = GetMinMaxNDim(xx,findmax);
408 if (rsign*fmin < rsign*zzmin) {
409 if (x) {x[0] = xx[0]; x[1] = xx[1]; }
410 return fmin;
411 }
412 // here if minimization failed
413 if (x) { x[0] = xxmin; x[1] = yymin; }
414 return zzmin;
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Compute the X and Y values corresponding to the minimum value of the function
419///
420/// Return the minimum value of the function
421/// To find the minimum on a range, first set this range via the SetRange function
422///
423/// Method:
424/// First, a grid search is performed to find the initial estimate of the
425/// minimum location. The range of the function is divided into fNpx and fNpy
426/// sub-ranges. If the function is "good" (or "bad"), these values can be changed
427/// by SetNpx and SetNpy functions
428/// Then, a minimization is used with starting values found by the grid search
429/// The minimizer algorithm used (by default Minuit) can be changed by callinga
430/// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
431/// Other option for the minimizer can be set using the static method of the MinimizerOptions class
432///
433/// Note that this method will always do first a grid search in contrast to GetMinimum
434
436{
437 double xx[2] = { 0,0 };
438 xx[0] = TMath::QuietNaN(); // to force to do grid search in TF2::FindMinMax
439 double fmin = FindMinMax(xx, false);
440 x = xx[0]; y = xx[1];
441 return fmin;
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Compute the X and Y values corresponding to the maximum value of the function
446///
447/// Return the maximum value of the function
448/// See TF2::GetMinimumXY
449
451{
452 double xx[2] = { 0,0 };
453 xx[0] = TMath::QuietNaN(); // to force to do grid search in TF2::FindMinMax
454 double fmax = FindMinMax(xx, true);
455 x = xx[0]; y = xx[1];
456 return fmax;
457}
458
459
460////////////////////////////////////////////////////////////////////////////////
461/// Return minimum/maximum value of the function
462///
463/// To find the minimum on a range, first set this range via the SetRange function
464/// If a vector x of coordinate is passed it will be used as starting point for the minimum.
465/// In addition on exit x will contain the coordinate values at the minimuma
466/// If x is NULL or x is infinity or NaN, first, a grid search is performed to find the initial estimate of the
467/// minimum location. The range of the function is divided into fNpx and fNpy
468/// sub-ranges. If the function is "good" (or "bad"), these values can be changed
469/// by SetNpx and SetNpy functions
470/// Then, a minimization is used with starting values found by the grid search
471/// The minimizer algorithm used (by default Minuit) can be changed by callinga
472/// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
473/// Other option for the minimizer can be set using the static method of the MinimizerOptions class
474
476{
477 return FindMinMax(x, false);
478}
479
480////////////////////////////////////////////////////////////////////////////////
481/// Return maximum value of the function
482/// See TF2::GetMinimum
483
485{
486 return FindMinMax(x, true);
487}
488
489
490////////////////////////////////////////////////////////////////////////////////
491/// Redefines TObject::GetObjectInfo.
492///
493/// Displays the function value
494/// corresponding to cursor position px,py
495
496char *TF2::GetObjectInfo(Int_t px, Int_t py) const
497{
498 const char *snull = "";
499 if (!gPad) return (char*)snull;
500 static char info[64];
501 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
502 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
503 const char *drawOption = GetDrawOption();
506 if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
507 || strncmp(drawOption,"CONT",4) == 0) {
508 uxmin=gPad->GetUxmin();
509 uxmax=gPad->GetUxmax();
510 x = fXmin +(fXmax-fXmin)*(x-uxmin)/(uxmax-uxmin);
511 uymin=gPad->GetUymin();
512 uymax=gPad->GetUymax();
513 y = fYmin +(fYmax-fYmin)*(y-uymin)/(uymax-uymin);
514 }
515 snprintf(info,64,"(x=%g, y=%g, f=%.18g)",x,y,((TF2*)this)->Eval(x,y));
516 return info;
517}
518
519////////////////////////////////////////////////////////////////////////////////
520/// Return a random number following this function shape
521
523{
524 Error("GetRandom","cannot be called for TF2/3, use GetRandom2/3 instead");
525 return 0; // not yet implemented
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Return a random number following this function shape
530
531
533{
534 Error("GetRandom","cannot be called for TF2/3, use GetRandom2/3 instead");
535 return 0; // not yet implemented
536}
537
538////////////////////////////////////////////////////////////////////////////////
539/// Return 2 random numbers following this function shape
540///
541/// The distribution contained in this TF2 function is integrated
542/// over the cell contents.
543/// It is normalized to 1.
544/// Getting the two random numbers implies:
545/// - Generating a random number between 0 and 1 (say r1)
546/// - Look in which cell in the normalized integral r1 corresponds to
547/// - make a linear interpolation in the returned cell
548///
549///
550/// IMPORTANT NOTE
551///
552/// The integral of the function is computed at fNpx * fNpy points.
553/// If the function has sharp peaks, you should increase the number of
554/// points (SetNpx, SetNpy) such that the peak is correctly tabulated
555/// at several points.
556
558{
559 // Check if integral array must be built
560 Int_t i,j,cell;
564 if (fIntegral.empty()) {
565 fIntegral.resize(ncells+1);
566 fIntegral[0] = 0;
568 Int_t intNegative = 0;
569 cell = 0;
570 for (j=0;j<fNpy;j++) {
571 for (i=0;i<fNpx;i++) {
573 if (integ < 0) {intNegative++; integ = -integ;}
575 cell++;
576 }
577 }
578 if (intNegative > 0) {
579 Warning("GetRandom2","function:%s has %d negative values: abs assumed",GetName(),intNegative);
580 }
581 if (fIntegral[ncells] == 0) {
582 Error("GetRandom2","Integral of function is zero");
583 return;
584 }
585 for (i=1;i<=ncells;i++) { // normalize integral to 1
587 }
588 }
589
590// return random numbers
592 if (!rng) rng = gRandom;
593 r = rng->Rndm();
596 if (dxint > 0) ddx = dx*(r - fIntegral[cell])/dxint;
597 else ddx = 0;
598 ddy = dy*rng->Rndm();
599 j = cell/fNpx;
600 i = cell%fNpx;
601 xrandom = fXmin +dx*i +ddx;
602 yrandom = fYmin +dy*j +ddy;
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Return range of a 2-D function
607
609{
610 xmin = fXmin;
611 xmax = fXmax;
612 ymin = fYmin;
613 ymax = fYmax;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Return range of function
618
620{
621 xmin = fXmin;
622 xmax = fXmax;
623 ymin = fYmin;
624 ymax = fYmax;
625 zmin = 0;
626 zmax = 0;
627}
628
629
630////////////////////////////////////////////////////////////////////////////////
631/// Get value corresponding to X in array of fSave values
632
634{
635 if (fSave.size() < 6) return 0;
636 Int_t nsave = fSave.size() - 6;
641 Int_t npx = Int_t(fSave[nsave+4]);
642 Int_t npy = Int_t(fSave[nsave+5]);
643 Double_t x = Double_t(xx[0]);
644 Double_t dx = (xmax-xmin)/npx;
645 if (x < xmin || x > xmax) return 0;
646 if (dx <= 0) return 0;
647 Double_t y = Double_t(xx[1]);
648 Double_t dy = (ymax-ymin)/npy;
649 if (y < ymin || y > ymax) return 0;
650 if (dy <= 0) return 0;
651
652 //we make a bilinear interpolation using the 4 points surrounding x,y
655 Double_t xlow = xmin + ibin*dx;
656 Double_t ylow = ymin + jbin*dy;
657 Double_t t = (x-xlow)/dx;
658 Double_t u = (y-ylow)/dy;
659 Int_t k1 = jbin*(npx+1) + ibin;
660 Int_t k2 = jbin*(npx+1) + ibin +1;
661 Int_t k3 = (jbin+1)*(npx+1) + ibin +1;
662 Int_t k4 = (jbin+1)*(npx+1) + ibin;
663 Double_t z = (1-t)*(1-u)*fSave[k1] +t*(1-u)*fSave[k2] +t*u*fSave[k3] + (1-t)*u*fSave[k4];
664 return z;
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// Return Integral of a 2d function in range [ax,bx],[ay,by]
669/// with desired relative accuracy (defined by eps)
670
672{
673 Double_t a[2], b[2];
674 a[0] = ax;
675 b[0] = bx;
676 a[1] = ay;
677 b[1] = by;
678 Double_t relerr = 0;
679 Int_t n = 2;
683 if (ifail > 0) {
684 Warning("Integral","failed for %s code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",GetName(),ifail,maxpts,epsrel,nfnevl,relerr);
685 }
686 if (gDebug) {
687 Info("Integral", "Integral of %s using %d and tol=%f is %f , relerr=%f nfcn=%d", GetName(), maxpts,epsrel,result,relerr,nfnevl);
688 }
689 return result;
690}
691
692////////////////////////////////////////////////////////////////////////////////
693/// Return kTRUE is the point is inside the function range
694
696{
697 if (x[0] < fXmin || x[0] > fXmax) return kFALSE;
698 if (x[1] < fYmin || x[1] > fYmax) return kFALSE;
699 return kTRUE;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Create a histogram from function.
704///
705/// always created it, even if it is already existing
706
708{
709 Int_t i,j,bin;
710 Double_t dx, dy;
711 Double_t xv[2];
712
713
714 Double_t *parameters = GetParameters();
715 TH2F* h = new TH2F("Func",(char*)GetTitle(),fNpx,fXmin,fXmax,fNpy,fYmin,fYmax);
716 h->SetDirectory(nullptr);
717
718 InitArgs(xv,parameters);
719 dx = (fXmax - fXmin)/Double_t(fNpx);
720 dy = (fYmax - fYmin)/Double_t(fNpy);
721 for (i=1;i<=fNpx;i++) {
722 xv[0] = fXmin + (Double_t(i) - 0.5)*dx;
723 for (j=1;j<=fNpy;j++) {
724 xv[1] = fYmin + (Double_t(j) - 0.5)*dy;
725 bin = j*(fNpx + 2) + i;
726 h->SetBinContent(bin,EvalPar(xv,parameters));
727 }
728 }
729 h->Fill(fXmin-1,fYmin-1,0); //This call to force fNentries non zero
730
732 if (levels && levels[0] == -9999) levels = nullptr;
733 h->SetMinimum(fMinimum);
734 h->SetMaximum(fMaximum);
735 h->SetContour(fContour.fN, levels);
736 h->SetLineColor(GetLineColor());
737 h->SetLineStyle(GetLineStyle());
738 h->SetLineWidth(GetLineWidth());
739 h->SetFillColor(GetFillColor());
740 h->SetFillStyle(GetFillStyle());
741 h->SetMarkerColor(GetMarkerColor());
742 h->SetMarkerStyle(GetMarkerStyle());
743 h->SetMarkerSize(GetMarkerSize());
744 h->SetStats(false);
745
746 return h;
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Paint this 2-D function with its current attributes
751
753{
754 Int_t i,j,bin;
755 Double_t dx, dy;
756 Double_t xv[2];
757 Double_t *parameters = GetParameters();
758 TString opt = option;
759 opt.ToLower();
760
761//- Create a temporary histogram and fill each channel with the function value
762 if (!fHistogram) {
763 fHistogram = new TH2F("Func",(char*)GetTitle(),fNpx,fXmin,fXmax,fNpy,fYmin,fYmax);
764 if (!fHistogram) return;
765 fHistogram->SetDirectory(nullptr);
766 }
767 InitArgs(xv,parameters);
768 dx = (fXmax - fXmin)/Double_t(fNpx);
769 dy = (fYmax - fYmin)/Double_t(fNpy);
770 for (i=1;i<=fNpx;i++) {
771 xv[0] = fXmin + (Double_t(i) - 0.5)*dx;
772 for (j=1;j<=fNpy;j++) {
773 xv[1] = fYmin + (Double_t(j) - 0.5)*dy;
774 bin = j*(fNpx + 2) + i;
775 fHistogram->SetBinContent(bin,EvalPar(xv,parameters));
776 }
777 }
778 ((TH2F*)fHistogram)->Fill(fXmin-1,fYmin-1,0); //This call to force fNentries non zero
779
780//- Copy Function attributes to histogram attributes
782 if (levels && levels[0] == -9999) levels = nullptr;
794 fHistogram->SetStats(false);
796
797//- Draw the histogram
798 if (!gPad) return;
799 if (opt.Length() == 0) fHistogram->Paint("cont3");
800 else if (opt == "same") fHistogram->Paint("cont2same");
801 else fHistogram->Paint(option);
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Save values of function in array fSave
806
808{
809 if (!fSave.empty())
810 fSave.clear();
811 Int_t npx = fNpx, npy = fNpy;
812 if ((npx < 2) || (npy < 2))
813 return;
816 if (dx <= 0) {
817 dx = (fXmax-fXmin)/fNpx;
818 npx--;
819 xmin = fXmin + 0.5*dx;
820 xmax = fXmax - 0.5*dx;
821 }
822 if (dy <= 0) {
823 dy = (fYmax-fYmin)/fNpy;
824 npy--;
825 ymin = fYmin + 0.5*dy;
826 ymax = fYmax - 0.5*dy;
827 }
828
829 Int_t nsave = (npx + 1) * (npy + 1);
830 fSave.resize(nsave + 6);
831 Double_t xv[2];
832 Double_t *parameters = GetParameters();
833 InitArgs(xv, parameters);
834 for (Int_t j = 0, k = 0; j <= npy; j++) {
835 xv[1] = ymin + dy*j;
836 for (Int_t i = 0; i <= npx; i++) {
837 xv[0] = xmin + dx*i;
838 fSave[k++] = EvalPar(xv, parameters);
839 }
840 }
841 fSave[nsave+0] = xmin;
842 fSave[nsave+1] = xmax;
843 fSave[nsave+2] = ymin;
844 fSave[nsave+3] = ymax;
845 fSave[nsave+4] = npx;
846 fSave[nsave+5] = npy;
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Restore value of function saved at point
851
853{
854 if (fSave.empty())
855 fSave.resize((fNpx + 1) * (fNpy + 1) + 6);
856 if (point >= 0 && point < (Int_t)fSave.size())
857 fSave[point] = value;
858}
859
860////////////////////////////////////////////////////////////////////////////////
861/// Save primitive as a C++ statement(s) on output stream out
862
863void TF2::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
864{
866 out << " \n";
867 if (!fType)
868 out << " TF2 *" << f2Name << " = new TF2(\"" << GetName() << "\", \""
869 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << fXmin << "," << fXmax << "," << fYmin << ","
870 << fYmax << ");\n";
871 else {
872 out << " TF2 *" << f2Name << " = new TF2(\"" << "*" << GetName() << "\", " << fXmin << "," << fXmax << ","
873 << fYmin << "," << fYmax << "," << GetNpar() << ");\n";
875 }
876
877 if (GetNpx() != 30)
878 out << " " << f2Name << "->SetNpx(" << GetNpx() << ");\n";
879 if (GetNpy() != 30)
880 out << " " << f2Name << "->SetNpy(" << GetNpy() << ");\n";
881
882 if (GetChisquare() != 0)
883 out << " " << f2Name << "->SetChisquare(" << GetChisquare() << ");\n";
884
886 for (Int_t i = 0; i < GetNpar(); i++) {
887 out << " " << f2Name << "->SetParameter(" << i << "," << GetParameter(i) << ");\n";
888 out << " " << f2Name << "->SetParError(" << i << "," << GetParError(i) << ");\n";
890 out << " " << f2Name << "->SetParLimits(" << i << "," << parmin << "," << parmax << ");\n";
891 }
892
894
895 if ((fType != EFType::kFormula) && ((Int_t) fSave.size() != ((GetNpx() + 1) * (GetNpy() + 1) + 6))) {
896 saved = kTRUE;
897 Save(fXmin, fXmax, fYmin, fYmax, 0, 0);
898 }
899
900 if (!fSave.empty()) {
901 TString arrs = SavePrimitiveArray(out, f2Name, fSave.size(), fSave.data());
902 out << " for (int n = 0; n < " << fSave.size() << "; n++)\n";
903 out << " " << f2Name << "->SetSavedPoint(n, " << arrs << "[n]);\n";
904 }
905
906 if (saved)
907 fSave.clear();
908
909 if (fContour.fN > 0) {
911 if (fContour.fArray[0] != -9999)
913 out << " " << f2Name << "->SetContour(" << fContour.fN;
914 if (!arrname.IsNull())
915 out << ", " << arrname;
916 out << ");\n";
917 }
918
919 SaveFillAttributes(out, f2Name, -1, 0);
920 SaveMarkerAttributes(out, f2Name, -1, -1, -1);
921 SaveLineAttributes(out, f2Name, -1, -1, -1);
922
923 if (fHistogram && !strstr(option, "same")) {
924 GetXaxis()->SaveAttributes(out, f2Name, "->GetXaxis()");
925 GetYaxis()->SaveAttributes(out, f2Name, "->GetYaxis()");
926 GetZaxis()->SaveAttributes(out, f2Name, "->GetZaxis()");
927 }
928
929 if (!option || !strstr(option, "nodraw"))
930 out << " " << f2Name << "->Draw(\"" << TString(option).ReplaceSpecialCppChars() << "\");\n";
931}
932
933////////////////////////////////////////////////////////////////////////////////
934/// Set the number and values of contour levels
935///
936/// By default the number of contour levels is set to 20.
937///
938/// if argument levels = 0 or missing, equidistant contours are computed
939
941{
942 Int_t level;
943 if (nlevels <=0 ) {
944 fContour.Set(0);
945 return;
946 }
948
949 //- Contour levels are specified
950 if (levels) {
951 for (level=0; level<nlevels; level++) fContour.fArray[level] = levels[level];
952 } else {
953 fContour.fArray[0] = -9999; // means not defined at this point
954 }
955}
956
957
958////////////////////////////////////////////////////////////////////////////////
959/// Set value for one contour level
960
962{
963 if (level <0 || level >= fContour.fN) return;
964 fContour.fArray[level] = value;
965}
966
967////////////////////////////////////////////////////////////////////////////////
968/// Set the number of points used to draw the function
969///
970/// The default number of points along x is 30 for 2-d/3-d functions.
971/// You can increase this value to get a better resolution when drawing
972/// pictures with sharp peaks or to get a better result when using TF2::GetRandom2
973/// the minimum number of points is 4, the maximum is 10000 for 2-d/3-d functions
974
976{
977 if (npy < 4) {
978 Warning("SetNpy","Number of points must be >=4 && <= 10000, fNpy set to 4");
979 fNpy = 4;
980 } else if(npy > 10000) {
981 Warning("SetNpy","Number of points must be >=4 && <= 10000, fNpy set to 10000");
982 fNpy = 10000;
983 } else {
984 fNpy = npy;
985 }
986 Update();
987}
988
989////////////////////////////////////////////////////////////////////////////////
990/// Initialize the upper and lower bounds to draw the function-
991
993{
994 fXmin = xmin;
995 fXmax = xmax;
996 fYmin = ymin;
997 fYmax = ymax;
998 Update();
999}
1000
1001////////////////////////////////////////////////////////////////////////////////
1002/// Stream an object of class TF2.
1003
1005{
1006 if (R__b.IsReading()) {
1007 UInt_t R__s, R__c;
1008 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1009 if (R__v > 3) {
1010 R__b.ReadClassBuffer(TF2::Class(), this, R__v, R__s, R__c);
1011 return;
1012 }
1013 //====process old versions before automatic schema evolution
1014 Int_t nlevels;
1016 if (R__v < 3) {
1018 R__b >> ymin; fYmin = ymin;
1019 R__b >> ymax; fYmax = ymax;
1020 } else {
1021 R__b >> fYmin;
1022 R__b >> fYmax;
1023 }
1024 R__b >> fNpy;
1025 R__b >> nlevels;
1026 if (R__v < 3) {
1027 Float_t *contour = nullptr;
1028 Int_t n = R__b.ReadArray(contour);
1029 fContour.Set(n);
1030 for (Int_t i=0;i<n;i++) fContour.fArray[i] = contour[i];
1031 delete [] contour;
1032 } else {
1034 }
1035 R__b.CheckByteCount(R__s, R__c, TF2::IsA());
1036 //====end of old versions
1037
1038 } else {
1039 Int_t saved = 0;
1040 if (fType != EFType::kFormula && fSave.empty()) { saved = 1; Save(fXmin,fXmax,fYmin,fYmax,0,0);}
1041
1042 R__b.WriteClassBuffer(TF2::Class(),this);
1043
1044 if (saved) {fSave.clear(); }
1045 }
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Return x^nx * y^ny moment of a 2d function in range [ax,bx],[ay,by]
1050/// \author Gene Van Buren <gene@bnl.gov>
1051
1053{
1054 Double_t norm = Integral(ax,bx,ay,by,epsilon);
1055 if (norm == 0) {
1056 Error("Moment2", "Integral zero over range");
1057 return 0;
1058 }
1059
1060 // define integrand function as a lambda : g(x,y)= x^(nx) * y^(ny) * f(x,y)
1061 auto integrand = [&](double *x, double *) {
1062 return std::pow(x[0], nx) * std::pow(x[1], ny) * this->EvalPar(x, nullptr);
1063 };
1064 // compute integral of g(x,y)
1065 TF2 fnc("TF2_ExpValHelper",integrand,ax,bx,ay,by,0);
1066 // set same points as current function to get correct max points when computing the integral
1067 fnc.fNpx = fNpx;
1068 fnc.fNpy = fNpy;
1069 return fnc.Integral(ax,bx,ay,by,epsilon)/norm;
1070}
1071
1072////////////////////////////////////////////////////////////////////////////////
1073/// Return x^nx * y^ny central moment of a 2d function in range [ax,bx],[ay,by]
1074/// \author Gene Van Buren <gene@bnl.gov>
1075
1077{
1078 Double_t norm = Integral(ax,bx,ay,by,epsilon);
1079 if (norm == 0) {
1080 Error("CentralMoment2", "Integral zero over range");
1081 return 0;
1082 }
1083
1084 Double_t xbar = 0;
1085 Double_t ybar = 0;
1086 if (nx!=0) {
1087 // compute first momentum in x
1088 auto integrandX = [&](double *x, double *) { return x[0] * this->EvalPar(x, nullptr); };
1089 TF2 fncx("TF2_ExpValHelperx",integrandX, ax, bx, ay, by, 0);
1090 fncx.fNpx = fNpx;
1091 fncx.fNpy = fNpy;
1092 xbar = fncx.Integral(ax,bx,ay,by,epsilon)/norm;
1093 }
1094 if (ny!=0) {
1095 // compute first momentum in y
1096 auto integrandY = [&](double *x, double *) { return x[1] * this->EvalPar(x, nullptr); };
1097 TF2 fncy("TF2_ExpValHelperx", integrandY, ax, bx, ay, by, 0);
1098 fncy.fNpx = fNpx;
1099 fncy.fNpy = fNpy;
1100 ybar = fncy.Integral(ax,bx,ay,by,epsilon)/norm;
1101 }
1102 // define integrand function as a lambda : g(x,y)= (x-xbar)^(nx) * (y-ybar)^(ny) * f(x,y)
1103 auto integrand = [&](double *x, double *) {
1104 double xxx = (nx != 0) ? std::pow(x[0] - xbar, nx) : 1.;
1105 double yyy = (ny != 0) ? std::pow(x[1] - ybar, ny) : 1.;
1106 return xxx * yyy * this->EvalPar(x, nullptr);
1107 };
1108 // compute integral of g(x,y)
1109 TF2 fnc("TF2_ExpValHelper", integrand, ax, bx, ay, by, 0);
1110 fnc.fNpx = fNpx;
1111 fnc.fNpy = fNpy;
1112 return fnc.Integral(ax, bx, ay, by, epsilon) / norm;
1113}
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
short Version_t
Definition RtypesCore.h:65
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
Int_t gDebug
Definition TROOT.cxx:597
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
@ kDefault
Definition TSystem.h:243
#define gPad
#define snprintf
Definition civetweb.c:1540
Param Functor class for Multidimensional functions.
Double_t * fArray
Definition TArrayD.h:30
void Streamer(TBuffer &) override
Stream a TArrayD object.
Definition TArrayD.cxx:149
void Copy(TArrayD &array) const
Definition TArrayD.h:42
void Set(Int_t n) override
Set size of this array to n doubles.
Definition TArrayD.cxx:106
const Double_t * GetArray() const
Definition TArrayD.h:43
Int_t fN
Definition TArray.h:38
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:40
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:239
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition TAttLine.cxx:275
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:33
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:32
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:34
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:41
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:46
void SaveAttributes(std::ostream &out, const char *name, const char *subname) override
Save axis attributes as C++ statement(s) on output stream out.
Definition TAxis.cxx:715
Buffer base class used for serializing objects.
Definition TBuffer.h:43
1-Dim function class
Definition TF1.h:233
EAddToList
Add to list behavior.
Definition TF1.h:240
Int_t fNdim
Function dimension.
Definition TF1.h:266
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition TF1.cxx:1940
TAxis * GetYaxis() const
Get y axis of the function.
Definition TF1.cxx:2411
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Definition TF1.cxx:1930
Double_t GetChisquare() const
Return the Chisquare after fitting. See ROOT::Fit::FitResult::Chi2()
Definition TF1.h:474
Double_t fXmin
Lower bounds for the range.
Definition TF1.h:263
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
Definition TF1.cxx:3626
TAxis * GetZaxis() const
Get z axis of the function. (In case this object is a TF2 or TF3)
Definition TF1.cxx:2422
virtual Int_t GetNpar() const
Definition TF1.h:511
TString ProvideSaveName(Option_t *option)
Provide variable name for function for saving as primitive When TH1 or TGraph stores list of function...
Definition TF1.cxx:3220
TH1 * fHistogram
! Pointer to histogram used for visualisation
Definition TF1.h:283
Double_t fMaximum
Maximum value for plotting.
Definition TF1.h:273
virtual Double_t * GetParameters() const
Definition TF1.h:550
Double_t fMinimum
Minimum value for plotting.
Definition TF1.h:272
void Copy(TObject &f1) const override
Copy this F1 to a new F1.
Definition TF1.cxx:1005
void Streamer(TBuffer &) override
Stream a class object.
Definition TF1.cxx:3578
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
Definition TF1.cxx:2482
virtual Double_t IntegralMultiple(Int_t n, const Double_t *a, const Double_t *b, Int_t maxpts, Double_t epsrel, Double_t epsabs, Double_t &relerr, Int_t &nfnevl, Int_t &ifail)
This function computes, to an attempted specified accuracy, the value of the integral.
Definition TF1.cxx:2851
EFType fType
Definition TF1.h:268
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=nullptr)
Evaluate function with given coordinates and parameters.
Definition TF1.cxx:1468
Int_t fNpx
Number of points used for the graphical representation.
Definition TF1.h:267
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TF1.cxx:1536
std::vector< Double_t > fSave
Array of fNsave function values.
Definition TF1.h:277
virtual Double_t GetMinMaxNDim(Double_t *x, Bool_t findmax, Double_t epsilon=0, Int_t maxiter=0) const
Find the minimum of a function of whatever dimension.
Definition TF1.cxx:1723
std::vector< Double_t > fIntegral
! Integral of function binned on fNpx bins
Definition TF1.h:278
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
Definition TF1.cxx:1439
@ kFormula
Formula functions which can be stored,.
Definition TF1.h:255
virtual Int_t GetNpx() const
Definition TF1.h:520
Double_t fXmax
Upper bounds for the range.
Definition TF1.h:264
virtual Int_t GetNdim() const
Definition TF1.h:515
virtual Double_t GetParameter(Int_t ipar) const
Definition TF1.h:542
TAxis * GetXaxis() const
Get x axis of the function.
Definition TF1.cxx:2400
A 2-Dim function with parameters.
Definition TF2.h:29
virtual Double_t GetMaximumXY(Double_t &x, Double_t &y) const
Compute the X and Y values corresponding to the maximum value of the function.
Definition TF2.cxx:450
void SetSavedPoint(Int_t point, Double_t value) override
Restore value of function saved at point.
Definition TF2.cxx:852
void Streamer(TBuffer &) override
Stream an object of class TF2.
Definition TF2.cxx:1004
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
Definition TF2.cxx:373
~TF2() override
F2 default destructor.
Definition TF2.cxx:205
virtual Double_t GetMinimum(Double_t *x) const
Return minimum/maximum value of the function.
Definition TF2.cxx:475
void Copy(TObject &f2) const override
Copy this F2 to a new F2.
Definition TF2.cxx:220
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom, TRandom *rng=nullptr)
Return 2 random numbers following this function shape.
Definition TF2.cxx:557
Double_t GetSave(const Double_t *x) override
Get value corresponding to X in array of fSave values.
Definition TF2.cxx:633
TClass * IsA() const override
Definition TF2.h:145
void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax) override
Save values of function in array fSave.
Definition TF2.cxx:807
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a function.
Definition TF2.cxx:238
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=nullptr)
Set the number and values of contour levels.
Definition TF2.cxx:940
TH1 * CreateHistogram() override
Create a histogram from function.
Definition TF2.cxx:707
void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Return range of a 2-D function.
Definition TF2.cxx:608
virtual Int_t GetContour(Double_t *levels=nullptr)
Return contour values into array levels.
Definition TF2.cxx:336
Bool_t IsInside(const Double_t *x) const override
Return kTRUE is the point is inside the function range.
Definition TF2.cxx:695
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
Definition TF2.cxx:975
virtual Double_t Moment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Return x^nx * y^ny moment of a 2d function in range [ax,bx],[ay,by].
Definition TF2.cxx:1052
TF1 * DrawCopy(Option_t *option="") const override
Draw a copy of this function with its current attributes-*.
Definition TF2.cxx:296
virtual Double_t GetMinimumXY(Double_t &x, Double_t &y) const
Compute the X and Y values corresponding to the minimum value of the function.
Definition TF2.cxx:435
Int_t fNpy
Number of points along y used for the graphical representation.
Definition TF2.h:34
void Paint(Option_t *option="") override
Paint this 2-D function with its current attributes.
Definition TF2.cxx:752
TArrayD fContour
Array to display contour levels.
Definition TF2.h:35
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF2.cxx:269
Double_t fYmax
Upper bound for the range in y.
Definition TF2.h:33
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TF2.cxx:863
TF2 & operator=(const TF2 &rhs)
Operator =.
Definition TF2.cxx:195
char * GetObjectInfo(Int_t px, Int_t py) const override
Redefines TObject::GetObjectInfo.
Definition TF2.cxx:496
virtual Double_t Integral(Double_t ax, Double_t bx, Double_t ay, Double_t by, Double_t epsrel=1.e-6)
Return Integral of a 2d function in range [ax,bx],[ay,by] with desired relative accuracy (defined by ...
Definition TF2.cxx:671
Double_t fYmin
Lower bound for the range in y.
Definition TF2.h:32
Int_t GetNpy() const
Definition TF2.h:97
virtual Double_t GetContourLevel(Int_t level) const
Return the number of contour levels.
Definition TF2.cxx:348
virtual Double_t CentralMoment2(Double_t nx, Double_t ax, Double_t bx, Double_t ny, Double_t ay, Double_t by, Double_t epsilon=0.000001)
Return x^nx * y^ny central moment of a 2d function in range [ax,bx],[ay,by].
Definition TF2.cxx:1076
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TF2.cxx:326
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
Definition TF2.cxx:961
TF2()
TF2 default constructor.
Definition TF2.cxx:83
virtual Double_t GetMaximum(Double_t *x) const
Return maximum value of the function See TF2::GetMinimum.
Definition TF2.cxx:484
Double_t GetRandom(TRandom *rng=nullptr, Option_t *opt=nullptr) override
Return a random number following this function shape.
Definition TF2.cxx:522
void SetRange(Double_t xmin, Double_t xmax) override
Initialize the upper and lower bounds to draw the function.
Definition TF2.h:148
static TClass * Class()
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:8924
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TH1.cxx:2794
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:421
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:422
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition TH1.cxx:9209
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6204
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level.
Definition TH1.cxx:8417
virtual void SetContour(Int_t nlevels, const Double_t *levels=nullptr)
Set the number and values of contour levels.
Definition TH1.cxx:8470
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9007
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:8977
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
void SavePrimitiveNameTitle(std::ostream &out, const char *variable_name)
Save object name and title into the output stream "out".
Definition TNamed.cxx:136
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:41
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:441
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1040
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1054
void MakeZombie()
Definition TObject.h:53
static TString SavePrimitiveArray(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Bool_t empty_line=kFALSE)
Save array in the output stream "out".
Definition TObject.cxx:786
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:66
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1114
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
std::ostream & Info()
Definition hadd.cxx:171
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Definition TMath.h:906
Int_t Finite(Double_t x)
Check if it is finite with a mask in order to be consistent in presence of fast math.
Definition TMath.h:774
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:347
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.
Definition TMath.h:921