ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "TH2.h"
17 #include "TVirtualPad.h"
18 #include "TStyle.h"
19 #include "Riostream.h"
20 #include "TColor.h"
21 #include "TVirtualFitter.h"
22 #include "TClass.h"
23 
25 
26 /** \class TF2
27  \ingroup Hist
28 A 2-Dim function with parameters
29 
30 TF2 graphics function is via the TH1 drawing functions.
31 Example of a function
32 
33  TF2 *f2 = new TF2("f2","sin(x)*sin(y)/(x*y)",0,5,0,5);
34  f2->Draw();
35 
36 \image html tf2_function2.png
37 See TF1 class for the list of functions formats
38 */
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// TF2 default constructor
42 
43 TF2::TF2(): TF1(),fYmin(0),fYmax(0),fNpy(100)
44 {
45 }
46 
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// F2 constructor using a formula definition
50 ///
51 /// See TFormula constructor for explanation of the formula syntax.
52 ///
53 /// If formula has the form "fffffff;xxxx;yyyy", it is assumed that
54 /// the formula string is "fffffff" and "xxxx" and "yyyy" are the
55 /// titles for the X and Y axis respectively.
56 
57 TF2::TF2(const char *name,const char *formula, Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax)
58  :TF1(name,formula,xmax,xmin)
59 {
60  if (ymin < ymax) {
61  fYmin = ymin;
62  fYmax = ymax;
63  } else {
64  fYmin = ymax;
65  fYmax = ymin;
66  }
67  fNpx = 30;
68  fNpy = 30;
69  fContour.Set(0);
70  if (GetNdim() != 2 && xmin < xmax && ymin < ymax) {
71  Error("TF2","function: %s/%s has dimension %d instead of 2",name,formula,GetNdim());
72  MakeZombie();
73  }
74 }
75 
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// F2 constructor using a pointer to a compiled function
79 ///
80 /// npar is the number of free parameters used by the function
81 ///
82 /// This constructor creates a function of type C when invoked
83 /// with the normal C++ compiler.
84 ///
85 /// WARNING! A function created with this constructor cannot be Cloned.
86 
88  : TF1(name, fcn, xmin, xmax, npar,ndim)
89 {
90  fYmin = ymin;
91  fYmax = ymax;
92  fNpx = 30;
93  fNpy = 30;
94  fContour.Set(0);
95 
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// F2 constructor using a pointer to a compiled function
100 ///
101 /// npar is the number of free parameters used by the function
102 ///
103 /// This constructor creates a function of type C when invoked
104 /// with the normal C++ compiler.
105 ///
106 /// WARNING! A function created with this constructor cannot be Cloned.
107 
108 TF2::TF2(const char *name, Double_t (*fcn)(const Double_t *, const Double_t *), Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Int_t npar, Int_t ndim)
109  : TF1(name, fcn, xmin, xmax, npar,ndim)
110 {
111  fYmin = ymin;
112  fYmax = ymax;
113  fNpx = 30;
114  fNpy = 30;
115  fContour.Set(0);
116 
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// F2 constructor using a ParamFunctor,
121 /// a functor class implementing operator() (double *, double *)
122 ///
123 /// npar is the number of free parameters used by the function
124 ///
125 /// WARNING! A function created with this constructor cannot be Cloned.
126 
128  : TF1(name, f, xmin, xmax, npar,ndim)
129 {
130  fYmin = ymin;
131  fYmax = ymax;
132  fNpx = 30;
133  fNpy = 30;
134  fContour.Set(0);
135 
136 }
137 
138 ////////////////////////////////////////////////////////////////////////////////
139 /// Operator =
140 
141 TF2& TF2::operator=(const TF2 &rhs)
142 {
143  if (this != &rhs) {
144  rhs.Copy(*this);
145  }
146  return *this;
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// F2 default destructor
151 
153 {
154 }
155 
156 ////////////////////////////////////////////////////////////////////////////////
157 /// Copy constructor.
158 
159 TF2::TF2(const TF2 &f2) : TF1()
160 {
161  ((TF2&)f2).Copy(*this);
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// Copy this F2 to a new F2
166 
167 void TF2::Copy(TObject &obj) const
168 {
169  TF1::Copy(obj);
170  ((TF2&)obj).fYmin = fYmin;
171  ((TF2&)obj).fYmax = fYmax;
172  ((TF2&)obj).fNpy = fNpy;
173  fContour.Copy(((TF2&)obj).fContour);
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Compute distance from point px,py to a function
178 ///
179 /// \param[in] px x position
180 /// \param[in] py y position
181 ///
182 /// Compute the closest distance of approach from point px,py to this function.
183 /// The distance is computed in pixels units.
184 
186 {
187  if (!fHistogram) return 9999;
189  if (distance <= 1) return distance;
190 
191  Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
192  Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
193  const char *drawOption = GetDrawOption();
194  Double_t uxmin,uxmax;
195  Double_t uymin,uymax;
196  if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
197  || strncmp(drawOption,"CONT",4) == 0) {
198  uxmin=gPad->GetUxmin();
199  uxmax=gPad->GetUxmax();
200  x = fXmin +(fXmax-fXmin)*(x-uxmin)/(uxmax-uxmin);
201  uymin=gPad->GetUymin();
202  uymax=gPad->GetUymax();
203  y = fYmin +(fYmax-fYmin)*(y-uymin)/(uymax-uymin);
204  }
205  if (x < fXmin || x > fXmax) return distance;
206  if (y < fYmin || y > fYmax) return distance;
207  return 0;
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 /// Draw this function with its current attributes
212 ///
213 /// NB. You must use DrawCopy if you want to draw several times the same
214 /// function in the current canvas.
215 
216 void TF2::Draw(Option_t *option)
217 {
218  TString opt = option;
219  opt.ToLower();
220  if (gPad && !opt.Contains("same")) gPad->Clear();
221 
222  AppendPad(option);
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// Draw a copy of this function with its current attributes-*
227 ///
228 /// This function MUST be used instead of Draw when you want to draw
229 /// the same function with different parameters settings in the same canvas.
230 ///
231 /// Possible option values are:
232 ///
233 /// option | description
234 /// ---------|------------
235 /// "SAME" | superimpose on top of existing picture
236 /// "L" | connect all computed points with a straight line
237 /// "C" | connect all computed points with a smooth curve.
238 ///
239 /// Note that the default value is "F". Therefore to draw on top
240 /// of an existing picture, specify option "SL"
241 
242 
243 TF1 *TF2::DrawCopy(Option_t *option) const
244 {
245  TF2 *newf2 = new TF2();
246  Copy(*newf2);
247  newf2->AppendPad(option);
248  newf2->SetBit(kCanDelete);
249  return newf2;
250 }
251 
252 // remove this function
253 //______________________________________________________________________________
254 // void TF2::DrawF2(const char *formula, Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Option_t *option)
255 // {
256 // //----Draw formula between xmin,ymin and xmax,ymax---
257 // // ============================================
258 // //
259 
260 // //if (Compile((char*)formula)) return;
261 
262 // SetRange(xmin, ymin, xmax, ymax);
263 
264 // Draw(option);
265 
266 // }
267 
268 ////////////////////////////////////////////////////////////////////////////////
269 /// Execute action corresponding to one event
270 ///
271 /// This member function is called when a F2 is clicked with the locator
272 
274 {
275  TF1::ExecuteEvent(event, px, py);
276 }
277 
278 ////////////////////////////////////////////////////////////////////////////////
279 /// Return contour values into array levels
280 ///
281 /// The number of contour levels can be returned by getContourLevel
282 
284 {
285  Int_t nlevels = fContour.fN;
286  if (levels) {
287  for (Int_t level=0; level<nlevels; level++) levels[level] = GetContourLevel(level);
288  }
289  return nlevels;
290 }
291 
292 ////////////////////////////////////////////////////////////////////////////////
293 /// Return the number of contour levels
294 
296 {
297  if (level <0 || level >= fContour.fN) return 0;
298  if (fContour.fArray[0] != -9999) return fContour.fArray[level];
299  if (fHistogram == 0) return 0;
300  return fHistogram->GetContourLevel(level);
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Return minimum/maximum value of the function
305 ///
306 /// To find the minimum on a range, first set this range via the SetRange function.
307 /// If a vector x of coordinate is passed it will be used as starting point for the minimum.
308 /// In addition on exit x will contain the coordinate values at the minimuma
309 ///
310 /// If x is NULL or x is inifinity or NaN, first, a grid search is performed to find the initial estimate of the
311 /// minimum location. The range of the function is divided into fNpx and fNpy
312 /// sub-ranges. If the function is "good" (or "bad"), these values can be changed
313 /// by SetNpx and SetNpy functions
314 ///
315 /// Then, a minimization is used with starting values found by the grid search
316 /// The minimizer algorithm used (by default Minuit) can be changed by callinga
317 /// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
318 /// Other option for the minimizer can be set using the static method of the MinimizerOptions class
319 
321 {
322  //First do a grid search with step size fNpx and fNpy
323 
324  Double_t xx[2];
325  Double_t rsign = (findmax) ? -1. : 1.;
326  TF2 & function = const_cast<TF2&>(*this); // needed since EvalPar is not const
327  Double_t xxmin = 0, yymin = 0, zzmin = 0;
328  if (x == NULL || ( (x!= NULL) && ( !TMath::Finite(x[0]) || !TMath::Finite(x[1]) ) ) ){
329  Double_t dx = (fXmax - fXmin)/fNpx;
330  Double_t dy = (fYmax - fYmin)/fNpy;
331  xxmin = fXmin;
332  yymin = fYmin;
333  zzmin = rsign * TMath::Infinity();
334  for (Int_t i=0; i<fNpx; i++){
335  xx[0]=fXmin + (i+0.5)*dx;
336  for (Int_t j=0; j<fNpy; j++){
337  xx[1]=fYmin+(j+0.5)*dy;
338  Double_t zz = function(xx);
339  if (rsign*zz < rsign*zzmin) {xxmin = xx[0], yymin = xx[1]; zzmin = zz;}
340  }
341  }
342 
343  xxmin = TMath::Min(fXmax, xxmin);
344  yymin = TMath::Min(fYmax, yymin);
345  }
346  else {
347  xxmin = x[0];
348  yymin = x[1];
349  zzmin = function(xx);
350  }
351  xx[0] = xxmin;
352  xx[1] = yymin;
353 
354  double fmin = GetMinMaxNDim(xx,findmax);
355  if (rsign*fmin < rsign*zzmin) {
356  if (x) {x[0] = xx[0]; x[1] = xx[1]; }
357  return fmin;
358  }
359  // here if minimization failed
360  if (x) { x[0] = xxmin; x[1] = yymin; }
361  return zzmin;
362 }
363 
364 ////////////////////////////////////////////////////////////////////////////////
365 /// Compute the X and Y values corresponding to the minimum value of the function
366 ///
367 /// Return the minimum value of the function
368 /// To find the minimum on a range, first set this range via the SetRange function
369 ///
370 /// Method:
371 /// First, a grid search is performed to find the initial estimate of the
372 /// minimum location. The range of the function is divided into fNpx and fNpy
373 /// sub-ranges. If the function is "good" (or "bad"), these values can be changed
374 /// by SetNpx and SetNpy functions
375 /// Then, a minimization is used with starting values found by the grid search
376 /// The minimizer algorithm used (by default Minuit) can be changed by callinga
377 /// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
378 /// Other option for the minimizer can be set using the static method of the MinimizerOptions class
379 ///
380 /// Note that this method will always do first a grid search in contrast to GetMinimum
381 
383 {
384  double xx[2] = { 0,0 };
385  xx[0] = TMath::QuietNaN(); // to force to do grid search in TF2::FindMinMax
386  double fmin = FindMinMax(xx, false);
387  x = xx[0]; y = xx[1];
388  return fmin;
389 }
390 
391 ////////////////////////////////////////////////////////////////////////////////
392 /// Compute the X and Y values corresponding to the maximum value of the function
393 ///
394 /// Return the maximum value of the function
395 /// See TF2::GetMinimumXY
396 
398 {
399  double xx[2] = { 0,0 };
400  xx[0] = TMath::QuietNaN(); // to force to do grid search in TF2::FindMinMax
401  double fmax = FindMinMax(xx, true);
402  x = xx[0]; y = xx[1];
403  return fmax;
404 }
405 
406 
407 ////////////////////////////////////////////////////////////////////////////////
408 /// Return minimum/maximum value of the function
409 ///
410 /// To find the minimum on a range, first set this range via the SetRange function
411 /// If a vector x of coordinate is passed it will be used as starting point for the minimum.
412 /// In addition on exit x will contain the coordinate values at the minimuma
413 /// If x is NULL or x is inifinity or NaN, first, a grid search is performed to find the initial estimate of the
414 /// minimum location. The range of the function is divided into fNpx and fNpy
415 /// sub-ranges. If the function is "good" (or "bad"), these values can be changed
416 /// by SetNpx and SetNpy functions
417 /// Then, a minimization is used with starting values found by the grid search
418 /// The minimizer algorithm used (by default Minuit) can be changed by callinga
419 /// ROOT::Math::Minimizer::SetDefaultMinimizerType("..")
420 /// Other option for the minimizer can be set using the static method of the MinimizerOptions class
421 
423 {
424  return FindMinMax(x, false);
425 }
426 
427 ////////////////////////////////////////////////////////////////////////////////
428 /// Return maximum value of the function
429 /// See TF2::GetMinimum
430 
432 {
433  return FindMinMax(x, true);
434 }
435 
436 
437 ////////////////////////////////////////////////////////////////////////////////
438 /// Redefines TObject::GetObjectInfo.
439 ///
440 /// Displays the function value
441 /// corresponding to cursor position px,py
442 
444 {
445  const char *snull = "";
446  if (!gPad) return (char*)snull;
447  static char info[64];
448  Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
449  Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
450  const char *drawOption = GetDrawOption();
451  Double_t uxmin,uxmax;
452  Double_t uymin,uymax;
453  if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
454  || strncmp(drawOption,"CONT",4) == 0) {
455  uxmin=gPad->GetUxmin();
456  uxmax=gPad->GetUxmax();
457  x = fXmin +(fXmax-fXmin)*(x-uxmin)/(uxmax-uxmin);
458  uymin=gPad->GetUymin();
459  uymax=gPad->GetUymax();
460  y = fYmin +(fYmax-fYmin)*(y-uymin)/(uymax-uymin);
461  }
462  snprintf(info,64,"(x=%g, y=%g, f=%.18g)",x,y,((TF2*)this)->Eval(x,y));
463  return info;
464 }
465 
466 ////////////////////////////////////////////////////////////////////////////////
467 /// Return a random number following this function shape
468 
470 {
471  Error("GetRandom","cannot be called for TF2/3, use GetRandom2/3 instead");
472  return 0; // not yet implemented
473 }
474 
475 ////////////////////////////////////////////////////////////////////////////////
476 /// Return a random number following this function shape
477 
478 
480 {
481  Error("GetRandom","cannot be called for TF2/3, use GetRandom2/3 instead");
482  return 0; // not yet implemented
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 /// Return 2 random numbers following this function shape
487 ///
488 /// The distribution contained in this TF2 function is integrated
489 /// over the cell contents.
490 /// It is normalized to 1.
491 /// Getting the two random numbers implies:
492 /// - Generating a random number between 0 and 1 (say r1)
493 /// - Look in which cell in the normalized integral r1 corresponds to
494 /// - make a linear interpolation in the returned cell
495 ///
496 ///
497 /// IMPORTANT NOTE
498 ///
499 /// The integral of the function is computed at fNpx * fNpy points.
500 /// If the function has sharp peaks, you should increase the number of
501 /// points (SetNpx, SetNpy) such that the peak is correctly tabulated
502 /// at several points.
503 
504 void TF2::GetRandom2(Double_t &xrandom, Double_t &yrandom)
505 {
506  // Check if integral array must be build
507  Int_t i,j,cell;
508  Double_t dx = (fXmax-fXmin)/fNpx;
509  Double_t dy = (fYmax-fYmin)/fNpy;
510  Int_t ncells = fNpx*fNpy;
511  if (fIntegral.empty()) {
512  fIntegral.resize(ncells+1);
513  fIntegral[0] = 0;
514  Double_t integ;
515  Int_t intNegative = 0;
516  cell = 0;
517  for (j=0;j<fNpy;j++) {
518  for (i=0;i<fNpx;i++) {
519  integ = Integral(fXmin+i*dx,fXmin+i*dx+dx,fYmin+j*dy,fYmin+j*dy+dy);
520  if (integ < 0) {intNegative++; integ = -integ;}
521  fIntegral[cell+1] = fIntegral[cell] + integ;
522  cell++;
523  }
524  }
525  if (intNegative > 0) {
526  Warning("GetRandom2","function:%s has %d negative values: abs assumed",GetName(),intNegative);
527  }
528  if (fIntegral[ncells] == 0) {
529  Error("GetRandom2","Integral of function is zero");
530  return;
531  }
532  for (i=1;i<=ncells;i++) { // normalize integral to 1
533  fIntegral[i] /= fIntegral[ncells];
534  }
535  }
536 
537 // return random numbers
538  Double_t r,ddx,ddy,dxint;
539  r = gRandom->Rndm();
540  cell = TMath::BinarySearch(ncells,fIntegral.data(),r);
541  dxint = fIntegral[cell+1] - fIntegral[cell];
542  if (dxint > 0) ddx = dx*(r - fIntegral[cell])/dxint;
543  else ddx = 0;
544  ddy = dy*gRandom->Rndm();
545  j = cell/fNpx;
546  i = cell%fNpx;
547  xrandom = fXmin +dx*i +ddx;
548  yrandom = fYmin +dy*j +ddy;
549 }
550 
551 ////////////////////////////////////////////////////////////////////////////////
552 /// Return range of a 2-D function
553 
555 {
556  xmin = fXmin;
557  xmax = fXmax;
558  ymin = fYmin;
559  ymax = fYmax;
560 }
561 
562 ////////////////////////////////////////////////////////////////////////////////
563 /// Return range of function
564 
566 {
567  xmin = fXmin;
568  xmax = fXmax;
569  ymin = fYmin;
570  ymax = fYmax;
571  zmin = 0;
572  zmax = 0;
573 }
574 
575 
576 ////////////////////////////////////////////////////////////////////////////////
577 /// Get value corresponding to X in array of fSave values
578 
580 {
581  //if (fNsave <= 0) return 0;
582  if (fSave.empty()) return 0;
583  Int_t fNsave = fSave.size();
584  Int_t np = fNsave - 6;
585  Double_t xmin = Double_t(fSave[np+0]);
586  Double_t xmax = Double_t(fSave[np+1]);
587  Double_t ymin = Double_t(fSave[np+2]);
588  Double_t ymax = Double_t(fSave[np+3]);
589  Int_t npx = Int_t(fSave[np+4]);
590  Int_t npy = Int_t(fSave[np+5]);
591  Double_t x = Double_t(xx[0]);
592  Double_t dx = (xmax-xmin)/npx;
593  if (x < xmin || x > xmax) return 0;
594  if (dx <= 0) return 0;
595  Double_t y = Double_t(xx[1]);
596  Double_t dy = (ymax-ymin)/npy;
597  if (y < ymin || y > ymax) return 0;
598  if (dy <= 0) return 0;
599 
600  //we make a bilinear interpolation using the 4 points surrounding x,y
601  Int_t ibin = Int_t((x-xmin)/dx);
602  Int_t jbin = Int_t((y-ymin)/dy);
603  Double_t xlow = xmin + ibin*dx;
604  Double_t ylow = ymin + jbin*dy;
605  Double_t t = (x-xlow)/dx;
606  Double_t u = (y-ylow)/dy;
607  Int_t k1 = jbin*(npx+1) + ibin;
608  Int_t k2 = jbin*(npx+1) + ibin +1;
609  Int_t k3 = (jbin+1)*(npx+1) + ibin +1;
610  Int_t k4 = (jbin+1)*(npx+1) + ibin;
611  Double_t z = (1-t)*(1-u)*fSave[k1] +t*(1-u)*fSave[k2] +t*u*fSave[k3] + (1-t)*u*fSave[k4];
612  return z;
613 }
614 
615 ////////////////////////////////////////////////////////////////////////////////
616 /// Return Integral of a 2d function in range [ax,bx],[ay,by]
617 /// with desired relative accuracy (default value of eps is 1.e-9)
618 
620 {
621  Double_t a[2], b[2];
622  a[0] = ax;
623  b[0] = bx;
624  a[1] = ay;
625  b[1] = by;
626  Double_t relerr = 0;
627  Int_t n = 2;
628  Int_t maxpts = 20*fNpx*fNpy;
629  Int_t nfnevl,ifail;
630  Double_t result = IntegralMultiple(n,a,b,maxpts,epsrel,epsrel,relerr,nfnevl,ifail);
631  if (ifail > 0) {
632  Warning("Integral","failed code=%d, maxpts=%d, epsrel=%g, nfnevl=%d, relerr=%g ",ifail,maxpts,epsrel,nfnevl,relerr);
633  }
634  return result;
635 }
636 
637 ////////////////////////////////////////////////////////////////////////////////
638 /// Return kTRUE is the point is inside the function range
639 
641 {
642  if (x[0] < fXmin || x[0] > fXmax) return kFALSE;
643  if (x[1] < fYmin || x[1] > fYmax) return kFALSE;
644  return kTRUE;
645 }
646 
647 ////////////////////////////////////////////////////////////////////////////////
648 /// Create a histogram from function.
649 ///
650 /// always created it, even if it is already existing
651 
653 {
654  Int_t i,j,bin;
655  Double_t dx, dy;
656  Double_t xv[2];
657 
658 
659  Double_t *parameters = GetParameters();
660  TH2F* h = new TH2F("Func",(char*)GetTitle(),fNpx,fXmin,fXmax,fNpy,fYmin,fYmax);
661  h->SetDirectory(0);
662 
663  InitArgs(xv,parameters);
664  dx = (fXmax - fXmin)/Double_t(fNpx);
665  dy = (fYmax - fYmin)/Double_t(fNpy);
666  for (i=1;i<=fNpx;i++) {
667  xv[0] = fXmin + (Double_t(i) - 0.5)*dx;
668  for (j=1;j<=fNpy;j++) {
669  xv[1] = fYmin + (Double_t(j) - 0.5)*dy;
670  bin = j*(fNpx + 2) + i;
671  h->SetBinContent(bin,EvalPar(xv,parameters));
672  }
673  }
674  h->Fill(fXmin-1,fYmin-1,0); //This call to force fNentries non zero
675 
676  Double_t *levels = fContour.GetArray();
677  if (levels && levels[0] == -9999) levels = 0;
678  h->SetMinimum(fMinimum);
679  h->SetMaximum(fMaximum);
680  h->SetContour(fContour.fN, levels);
689  h->SetStats(0);
690 
691  return h;
692 }
693 
694 ////////////////////////////////////////////////////////////////////////////////
695 /// Paint this 2-D function with its current attributes
696 
697 void TF2::Paint(Option_t *option)
698 {
699  Int_t i,j,bin;
700  Double_t dx, dy;
701  Double_t xv[2];
702  Double_t *parameters = GetParameters();
703  TString opt = option;
704  opt.ToLower();
705 
706 //- Create a temporary histogram and fill each channel with the function value
707  if (!fHistogram) {
708  fHistogram = new TH2F("Func",(char*)GetTitle(),fNpx,fXmin,fXmax,fNpy,fYmin,fYmax);
709  if (!fHistogram) return;
711  }
712  InitArgs(xv,parameters);
713  dx = (fXmax - fXmin)/Double_t(fNpx);
714  dy = (fYmax - fYmin)/Double_t(fNpy);
715  for (i=1;i<=fNpx;i++) {
716  xv[0] = fXmin + (Double_t(i) - 0.5)*dx;
717  for (j=1;j<=fNpy;j++) {
718  xv[1] = fYmin + (Double_t(j) - 0.5)*dy;
719  bin = j*(fNpx + 2) + i;
720  fHistogram->SetBinContent(bin,EvalPar(xv,parameters));
721  }
722  }
723  ((TH2F*)fHistogram)->Fill(fXmin-1,fYmin-1,0); //This call to force fNentries non zero
724 
725 //- Copy Function attributes to histogram attributes
726  Double_t *levels = fContour.GetArray();
727  if (levels && levels[0] == -9999) levels = 0;
730  fHistogram->SetContour(fContour.fN, levels);
739  fHistogram->SetStats(0);
740 
741 //- Draw the histogram
742  if (!gPad) return;
743  if (opt.Length() == 0) fHistogram->Paint("cont3");
744  else if (opt == "same") fHistogram->Paint("cont2same");
745  else fHistogram->Paint(option);
746 }
747 
748 ////////////////////////////////////////////////////////////////////////////////
749 /// Save values of function in array fSave
750 
752 {
753  if (!fSave.empty()) fSave.clear();
754  //if (fSave != 0) {delete [] fSave; fSave = 0;}
755  Int_t nsave = (fNpx+1)*(fNpy+1);
756  Int_t fNsave = nsave+6;
757  if (fNsave <= 6) {fNsave=0; return;}
758  //fSave = new Double_t[fNsave];
759  fSave.resize(fNsave);
760  Int_t i,j,k=0;
761  Double_t dx = (xmax-xmin)/fNpx;
762  Double_t dy = (ymax-ymin)/fNpy;
763  if (dx <= 0) {
764  dx = (fXmax-fXmin)/fNpx;
765  xmin = fXmin +0.5*dx;
766  xmax = fXmax -0.5*dx;
767  }
768  if (dy <= 0) {
769  dy = (fYmax-fYmin)/fNpy;
770  ymin = fYmin +0.5*dy;
771  ymax = fYmax -0.5*dy;
772  }
773  Double_t xv[2];
774  Double_t *parameters = GetParameters();
775  InitArgs(xv,parameters);
776  for (j=0;j<=fNpy;j++) {
777  xv[1] = ymin + dy*j;
778  for (i=0;i<=fNpx;i++) {
779  xv[0] = xmin + dx*i;
780  fSave[k] = EvalPar(xv,parameters);
781  k++;
782  }
783  }
784  fSave[nsave+0] = xmin;
785  fSave[nsave+1] = xmax;
786  fSave[nsave+2] = ymin;
787  fSave[nsave+3] = ymax;
788  fSave[nsave+4] = fNpx;
789  fSave[nsave+5] = fNpy;
790 }
791 
792 ////////////////////////////////////////////////////////////////////////////////
793 /// Save primitive as a C++ statement(s) on output stream out
794 
795 void TF2::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
796 {
797  char quote = '"';
798  out<<" "<<std::endl;
799  if (gROOT->ClassSaved(TF2::Class())) {
800  out<<" ";
801  } else {
802  out<<" TF2 *";
803  }
804  if (!fMethodCall) {
805  out<<GetName()<<" = new TF2("<<quote<<GetName()<<quote<<","<<quote<<GetTitle()<<quote<<","<<fXmin<<","<<fXmax<<","<<fYmin<<","<<fYmax<<");"<<std::endl;
806  } else {
807  out<<GetName()<<" = new TF2("<<quote<<GetName()<<quote<<","<<GetTitle()<<","<<fXmin<<","<<fXmax<<","<<fYmin<<","<<fYmax<<","<<GetNpar()<<");"<<std::endl;
808  }
809 
810  if (GetFillColor() != 0) {
811  if (GetFillColor() > 228) {
813  out<<" "<<GetName()<<"->SetFillColor(ci);" << std::endl;
814  } else
815  out<<" "<<GetName()<<"->SetFillColor("<<GetFillColor()<<");"<<std::endl;
816  }
817  if (GetFillStyle() != 1001) {
818  out<<" "<<GetName()<<"->SetFillStyle("<<GetFillStyle()<<");"<<std::endl;
819  }
820  if (GetMarkerColor() != 1) {
821  if (GetMarkerColor() > 228) {
823  out<<" "<<GetName()<<"->SetMarkerColor(ci);" << std::endl;
824  } else
825  out<<" "<<GetName()<<"->SetMarkerColor("<<GetMarkerColor()<<");"<<std::endl;
826  }
827  if (GetMarkerStyle() != 1) {
828  out<<" "<<GetName()<<"->SetMarkerStyle("<<GetMarkerStyle()<<");"<<std::endl;
829  }
830  if (GetMarkerSize() != 1) {
831  out<<" "<<GetName()<<"->SetMarkerSize("<<GetMarkerSize()<<");"<<std::endl;
832  }
833  if (GetLineColor() != 1) {
834  if (GetLineColor() > 228) {
836  out<<" "<<GetName()<<"->SetLineColor(ci);" << std::endl;
837  } else
838  out<<" "<<GetName()<<"->SetLineColor("<<GetLineColor()<<");"<<std::endl;
839  }
840  if (GetLineWidth() != 4) {
841  out<<" "<<GetName()<<"->SetLineWidth("<<GetLineWidth()<<");"<<std::endl;
842  }
843  if (GetLineStyle() != 1) {
844  out<<" "<<GetName()<<"->SetLineStyle("<<GetLineStyle()<<");"<<std::endl;
845  }
846  if (GetNpx() != 100) {
847  out<<" "<<GetName()<<"->SetNpx("<<GetNpx()<<");"<<std::endl;
848  }
849  if (GetChisquare() != 0) {
850  out<<" "<<GetName()<<"->SetChisquare("<<GetChisquare()<<");"<<std::endl;
851  }
852  Double_t parmin, parmax;
853  for (Int_t i=0;i<GetNpar();i++) {
854  out<<" "<<GetName()<<"->SetParameter("<<i<<","<<GetParameter(i)<<");"<<std::endl;
855  out<<" "<<GetName()<<"->SetParError("<<i<<","<<GetParError(i)<<");"<<std::endl;
856  GetParLimits(i,parmin,parmax);
857  out<<" "<<GetName()<<"->SetParLimits("<<i<<","<<parmin<<","<<parmax<<");"<<std::endl;
858  }
859  out<<" "<<GetName()<<"->Draw("
860  <<quote<<option<<quote<<");"<<std::endl;
861 }
862 
863 
864 
865 ////////////////////////////////////////////////////////////////////////////////
866 /// Set the number and values of contour levels
867 ///
868 /// By default the number of contour levels is set to 20.
869 ///
870 /// if argument levels = 0 or missing, equidistant contours are computed
871 
872 void TF2::SetContour(Int_t nlevels, const Double_t *levels)
873 {
874  Int_t level;
875  if (nlevels <=0 ) {
876  fContour.Set(0);
877  return;
878  }
879  fContour.Set(nlevels);
880 
881  //- Contour levels are specified
882  if (levels) {
883  for (level=0; level<nlevels; level++) fContour.fArray[level] = levels[level];
884  } else {
885  fContour.fArray[0] = -9999; // means not defined at this point
886  }
887 }
888 
889 
890 ////////////////////////////////////////////////////////////////////////////////
891 /// Set value for one contour level
892 
894 {
895  if (level <0 || level >= fContour.fN) return;
896  fContour.fArray[level] = value;
897 }
898 
899 ////////////////////////////////////////////////////////////////////////////////
900 /// Set the number of points used to draw the function
901 ///
902 /// The default number of points along x is 30 for 2-d/3-d functions.
903 /// You can increase this value to get a better resolution when drawing
904 /// pictures with sharp peaks or to get a better result when using TF2::GetRandom2
905 /// the minimum number of points is 4, the maximum is 10000 for 2-d/3-d functions
906 
908 {
909  if (npy < 4) {
910  Warning("SetNpy","Number of points must be >=4 && <= 10000, fNpy set to 4");
911  fNpy = 4;
912  } else if(npy > 10000) {
913  Warning("SetNpy","Number of points must be >=4 && <= 10000, fNpy set to 10000");
914  fNpy = 10000;
915  } else {
916  fNpy = npy;
917  }
918  Update();
919 }
920 
921 ////////////////////////////////////////////////////////////////////////////////
922 /// Initialize the upper and lower bounds to draw the function-
923 
925 {
926  fXmin = xmin;
927  fXmax = xmax;
928  fYmin = ymin;
929  fYmax = ymax;
930  Update();
931 }
932 
933 ////////////////////////////////////////////////////////////////////////////////
934 /// Stream an object of class TF2.
935 
936 void TF2::Streamer(TBuffer &R__b)
937 {
938  if (R__b.IsReading()) {
939  UInt_t R__s, R__c;
940  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
941  if (R__v > 3) {
942  R__b.ReadClassBuffer(TF2::Class(), this, R__v, R__s, R__c);
943  return;
944  }
945  //====process old versions before automatic schema evolution
946  Int_t nlevels;
947  TF1::Streamer(R__b);
948  if (R__v < 3) {
949  Float_t ymin,ymax;
950  R__b >> ymin; fYmin = ymin;
951  R__b >> ymax; fYmax = ymax;
952  } else {
953  R__b >> fYmin;
954  R__b >> fYmax;
955  }
956  R__b >> fNpy;
957  R__b >> nlevels;
958  if (R__v < 3) {
959  Float_t *contour = 0;
960  Int_t n = R__b.ReadArray(contour);
961  fContour.Set(n);
962  for (Int_t i=0;i<n;i++) fContour.fArray[i] = contour[i];
963  delete [] contour;
964  } else {
965  fContour.Streamer(R__b);
966  }
967  R__b.CheckByteCount(R__s, R__c, TF2::IsA());
968  //====end of old versions
969 
970  } else {
971  Int_t saved = 0;
972  if (fType > 0 && fSave.empty()) { saved = 1; Save(fXmin,fXmax,fYmin,fYmax,0,0);}
973 
974  R__b.WriteClassBuffer(TF2::Class(),this);
975 
976  if (saved) {fSave.clear(); }
977  }
978 }
979 
980 ////////////////////////////////////////////////////////////////////////////////
981 /// Return x^nx * y^ny moment of a 2d function in range [ax,bx],[ay,by]
982 /// \author Gene Van Buren <gene@bnl.gov>
983 
985 {
986  Double_t norm = Integral(ax,bx,ay,by,epsilon);
987  if (norm == 0) {
988  Error("Moment2", "Integral zero over range");
989  return 0;
990  }
991 
992  TF2 fnc("TF2_ExpValHelper",Form("%s*pow(x,%f)*pow(y,%f)",GetName(),nx,ny));
993  return fnc.Integral(ax,bx,ay,by,epsilon)/norm;
994 }
995 
996 ////////////////////////////////////////////////////////////////////////////////
997 /// Return x^nx * y^ny central moment of a 2d function in range [ax,bx],[ay,by]
998 /// \author Gene Van Buren <gene@bnl.gov>
999 
1001 {
1002  Double_t norm = Integral(ax,bx,ay,by,epsilon);
1003  if (norm == 0) {
1004  Error("CentralMoment2", "Integral zero over range");
1005  return 0;
1006  }
1007 
1008  Double_t xbar = 0;
1009  Double_t ybar = 0;
1010  if (nx!=0) {
1011  TF2 fncx("TF2_ExpValHelperx",Form("%s*x",GetName()));
1012  xbar = fncx.Integral(ax,bx,ay,by,epsilon)/norm;
1013  }
1014  if (ny!=0) {
1015  TF2 fncx("TF2_ExpValHelpery",Form("%s*y",GetName()));
1016  ybar = fncx.Integral(ax,bx,ay,by,epsilon)/norm;
1017  }
1018  TF2 fnc("TF2_ExpValHelper",Form("%s*pow(x-%f,%f)*pow(y-%f,%f)",GetName(),xbar,nx,ybar,ny));
1019  return fnc.Integral(ax,bx,ay,by,epsilon)/norm;
1020 }
1021 
const int nx
Definition: kalman.C:16
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
Double_t fMaximum
Definition: TF1.h:165
virtual Style_t GetLineStyle() const
Definition: TAttLine.h:48
virtual Style_t GetFillStyle() const
Definition: TAttFill.h:44
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
Definition: TH1.cxx:5798
virtual void GetRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Return range of a 2-D function.
Definition: TF2.cxx:554
Int_t fNpx
Definition: TF1.h:159
float xmin
Definition: THbookFile.cxx:93
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:216
void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
Definition: Ifit.C:26
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
Bool_t IsReading() const
Definition: TBuffer.h:83
short Version_t
Definition: RtypesCore.h:61
Ssiz_t Length() const
Definition: TString.h:390
virtual Double_t GetMinimum(Double_t *x) const
Return minimum/maximum value of the function.
Definition: TF2.cxx:422
float Float_t
Definition: RtypesCore.h:53
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition: TRandom.cxx:512
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8266
const char Option_t
Definition: RtypesCore.h:62
float ymin
Definition: THbookFile.cxx:93
Double_t QuietNaN()
Definition: TMath.h:635
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:984
virtual void SetContour(Int_t nlevels, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TH1.cxx:7863
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
Definition: CsgOps.cxx:467
tuple f2
Definition: surfaces.py:24
TH1 * h
Definition: legend2.C:5
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index > 228 as a C++ statement(s) on output stream out.
Definition: TColor.cxx:1324
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TF1.cxx:1237
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual Double_t GetMaximum(Double_t *x) const
Return maximum value of the function See TF2::GetMinimum.
Definition: TF2.cxx:431
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:2556
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:395
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
#define gROOT
Definition: TROOT.h:344
Basic string class.
Definition: TString.h:137
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1075
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Definition: TF1.cxx:1608
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetFillStyle(Style_t fstyle)
Definition: TAttFill.h:52
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a function.
Definition: TF2.cxx:185
virtual Double_t FindMinMax(Double_t *x, bool findmax) const
Return minimum/maximum value of the function.
Definition: TF2.cxx:320
virtual Double_t GetContourLevel(Int_t level) const
Return the number of contour levels.
Definition: TF2.cxx:295
Float_t py
Definition: hprod.C:33
void Copy(TArrayD &array) const
Definition: TArrayD.h:44
Double_t fYmin
Definition: TF2.h:36
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 (default val...
Definition: TF2.cxx:619
TFile * f
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
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:1404
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:164
TArrayD fContour
Definition: TF2.h:39
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
Definition: TF2.cxx:893
Double_t x[n]
Definition: legend1.C:17
Double_t GetChisquare() const
Definition: TF1.h:329
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:399
void Class()
Definition: Class.C:29
const int ny
Definition: kalman.C:17
Double_t fYmax
Definition: TF2.h:37
virtual void Copy(TObject &f1) const
Copy this F1 to a new F1.
Definition: TF1.cxx:736
virtual void SetMarkerColor(Color_t mcolor=1)
Definition: TAttMarker.h:51
Double_t * fArray
Definition: TArrayD.h:32
tuple np
Definition: multifit.py:30
Int_t Finite(Double_t x)
Definition: TMath.h:532
virtual TH1 * CreateHistogram()
Create a histogram from function.
Definition: TF2.cxx:652
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
Float_t z[5]
Definition: Ifit.C:16
virtual TF1 * DrawCopy(Option_t *option="") const
Draw a copy of this function with its current attributes-*.
Definition: TF2.cxx:243
Double_t Infinity()
Definition: TMath.h:648
char * out
Definition: TBase64.cxx:29
std::vector< Double_t > fIntegral
Definition: TF1.h:170
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition: TF1.cxx:1618
virtual Int_t GetContour(Double_t *levels=0)
Return contour values into array levels.
Definition: TF2.cxx:283
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
Definition: TH1.cxx:2612
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
Int_t fN
Definition: TArray.h:40
virtual Size_t GetMarkerSize() const
Definition: TAttMarker.h:46
TThread * t[5]
Definition: threadsh1.C:13
float ymax
Definition: THbookFile.cxx:93
TH1 * fHistogram
Parent object hooking this function (if one)
Definition: TF1.h:175
ROOT::R::TRInterface & r
Definition: Object.C:4
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
Double_t GetRandom()
Return a random number following this function shape.
Definition: TF2.cxx:469
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:8543
virtual Color_t GetFillColor() const
Definition: TAttFill.h:43
TClass * IsA() const
virtual ~TF2()
F2 default destructor.
Definition: TF2.cxx:152
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Int_t GetNdim() const
Definition: TF1.h:343
char * Form(const char *fmt,...)
Int_t fType
Definition: TF1.h:160
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function.
Definition: TF2.cxx:907
Double_t fMinimum
Definition: TF1.h:164
virtual void Copy(TObject &f2) const
Copy this F2 to a new F2.
Definition: TF2.cxx:167
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual void SetMarkerStyle(Style_t mstyle=1)
Definition: TAttMarker.h:53
float xmax
Definition: THbookFile.cxx:93
virtual void Update()
Called by functions such as SetRange, SetNpx, SetParameters to force the deletion of the associated h...
Definition: TF1.cxx:3337
A 2-Dim function with parameters.
Definition: TF2.h:33
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
virtual Color_t GetLineColor() const
Definition: TAttLine.h:47
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TF2.cxx:273
TF2 & operator=(const TF2 &rhs)
Operator =.
Definition: TF2.cxx:141
virtual void SetMarkerSize(Size_t msize=1)
Definition: TAttMarker.h:54
REAL epsilon
Definition: triangle.c:617
const Double_t * GetArray() const
Definition: TArrayD.h:45
virtual Int_t GetNpx() const
Definition: TF1.h:345
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF2.h:154
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom)
Return 2 random numbers following this function shape.
Definition: TF2.cxx:504
std::vector< Double_t > fSave
Definition: TF1.h:169
Double_t fXmin
Definition: TF1.h:155
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:382
Double_t y[n]
Definition: legend1.C:17
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:872
The TH1 histogram class.
Definition: TH1.h:80
virtual void Paint(Option_t *option="")
Paint this 2-D function with its current attributes.
Definition: TF2.cxx:697
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Redefines TObject::GetObjectInfo.
Definition: TF2.cxx:443
virtual void SetLineStyle(Style_t lstyle)
Definition: TAttLine.h:56
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
Definition: TF1.cxx:2198
virtual Double_t GetParameter(Int_t ipar) const
Definition: TF1.h:352
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TF2.cxx:795
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Double_t * GetParameters() const
Definition: TF1.h:358
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:397
TMethodCall * fMethodCall
Pointer to histogram used for visualisation.
Definition: TF1.h:176
Float_t px
Definition: hprod.C:33
virtual Color_t GetMarkerColor() const
Definition: TAttMarker.h:44
virtual Double_t GetSave(const Double_t *x)
Get value corresponding to X in array of fSave values.
Definition: TF2.cxx:579
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
1-Dim function class
Definition: TF1.h:149
void MakeZombie()
Definition: TObject.h:68
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:1162
Param Functor class for Multidimensional functions.
Definition: ParamFunctor.h:209
#define NULL
Definition: Rtypes.h:82
#define gPad
Definition: TVirtualPad.h:288
double result[121]
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Definition: TH2.cxx:2699
virtual Bool_t IsInside(const Double_t *x) const
Return kTRUE is the point is inside the function range.
Definition: TF2.cxx:640
virtual Style_t GetMarkerStyle() const
Definition: TAttMarker.h:45
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:287
virtual Width_t GetLineWidth() const
Definition: TAttLine.h:49
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
Definition: TF1.cxx:1192
TObject * obj
float value
Definition: math.cpp:443
double norm(double *x, double *p)
Definition: unuranDistr.cxx:40
void Set(Int_t n)
Set size of this array to n doubles.
Definition: TArrayD.cxx:105
const Int_t n
Definition: legend1.C:16
Double_t fXmax
Definition: TF1.h:156
virtual Int_t GetNpar() const
Definition: TF1.h:342
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8320
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMath.h:944
virtual Double_t GetContourLevel(Int_t level) const
Return value of contour number level use GetContour to return the array of all contour levels...
Definition: TH1.cxx:7807
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual void Save(Double_t xmin, Double_t xmax, Double_t ymin, Double_t ymax, Double_t zmin, Double_t zmax)
Save values of function in array fSave.
Definition: TF2.cxx:751
virtual Int_t ReadArray(Bool_t *&b)=0
Int_t fNpy
Definition: TF2.h:38
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:1000
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904