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