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