Logo ROOT   6.08/07
Reference Guide
TGraph2D.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id: TGraph2D.cxx,v 1.00
2 // Author: Olivier Couet
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 "Riostream.h"
13 #include "TROOT.h"
14 #include "TMath.h"
15 #include "TH2.h"
16 #include "TF2.h"
17 #include "TList.h"
18 #include "TGraph2D.h"
19 #include "TGraphDelaunay.h"
20 #include "TGraphDelaunay2D.h"
21 #include "TVirtualPad.h"
22 #include "TVirtualFitter.h"
23 #include "TPluginManager.h"
24 #include "TClass.h"
25 #include "TSystem.h"
26 #include <stdlib.h>
27 #include <cassert>
28 
29 #include "HFitInterface.h"
30 #include "Fit/DataRange.h"
31 #include "Math/MinimizerOptions.h"
32 
34 
35 
36 /** \class TGraph2D
37  \ingroup Hist
38 Graphics object made of three arrays X, Y and Z with the same number of points each.
39 
40 This class has different constructors:
41 - With an array's dimension and three arrays x, y, and z:
42 ~~~ {.cpp}
43  TGraph2D *g = new TGraph2D(n, x, y, z);
44 ~~~
45  x, y, z arrays can be doubles, floats, or ints.
46 - With an array's dimension only:
47 ~~~ {.cpp}
48  TGraph2D *g = new TGraph2D(n);
49 ~~~
50  The internal arrays are then filled with `SetPoint()`. The following line
51  fills the internal arrays at the position `i` with the values
52  `x`, `y`, `z`.
53 ~~~ {.cpp}
54  g->SetPoint(i, x, y, z);
55 ~~~
56 - Without parameters:
57 ~~~ {.cpp}
58  TGraph2D *g = new TGraph2D();
59 ~~~
60  again `SetPoint()` must be used to fill the internal arrays.
61 - From a file:
62 ~~~ {.cpp}
63  TGraph2D *g = new TGraph2D("graph.dat");
64 ~~~
65  Arrays are read from the ASCII file "graph.dat" according to a specifies
66  format. The default format is `%%lg %%lg %%lg`
67 
68 Note that in any of these three cases, `SetPoint()` can be used to change a data
69 point or add a new one. If the data point index (`i`) is greater than the
70 current size of the internal arrays, they are automatically extended.
71 
72 Like TGraph the TGraph2D constructors do not have the TGraph2D title and name as parameters.
73 A TGraph2D has the default title and name "Graph2D". To change the default title
74 and name `SetTitle` and `SetName` should be called on the TGraph2D after its creation.
75 
76 Specific drawing options can be used to paint a TGraph2D:
77 
78 
79 | Option | Description |
80 |----------|-------------------------------------------------------------------|
81 | "TRI" | The Delaunay triangles are drawn using filled area. An hidden surface drawing technique is used. The surface is painted with the current fill area color. The edges of each triangles are painted with the current line color. |
82 | "TRIW" | The Delaunay triangles are drawn as wire frame. |
83 | "TRI1" | The Delaunay triangles are painted with color levels. The edges of each triangles are painted with the current line color. |
84 | "TRI2" | The Delaunay triangles are painted with color levels. |
85 | "P" | Draw a marker at each vertex. |
86 | "P0" | Draw a circle at each vertex. Each circle background is white. |
87 | "PCOL" | Draw a marker at each vertex. The color of each marker is defined according to its Z position. |
88 | "LINE" | Draw a 3D polyline. |
89 
90 A TGraph2D can be also drawn with any options valid to draw a 2D histogram
91 (like `COL`, `SURF`, `LEGO`, `CONT` etc..).
92 
93 When a TGraph2D is drawn with one of the 2D histogram drawing option,
94 an intermediate 2D histogram is filled using the Delaunay triangles
95 to interpolate the data set. The 2D histogram has equidistant bins along the X
96 and Y directions. The number of bins along each direction can be change using
97 `SetNpx()` and `SetNpy()`. Each bin is filled with the Z
98 value found via a linear interpolation on the plane defined by the triangle above
99 the (X,Y) coordinates of the bin center.
100 
101 The existing (X,Y,Z) points can be randomly scattered.
102 The Delaunay triangles are build in the (X,Y) plane. These 2D triangles are then
103 used to define flat planes in (X,Y,Z) over which the interpolation is done to fill
104 the 2D histogram. The 3D triangles int takes build a 3D surface in
105 the form of tessellating triangles at various angles. The triangles found can be
106 drawn in 3D with one of the TGraph2D specific drawing options.
107 
108 The histogram generated by the Delaunay interpolation can be accessed using the
109 `GetHistogram()` method.
110 
111 The axis settings (title, ranges etc ...) can be changed accessing the axis via
112 the GetXaxis GetYaxis and GetZaxis methods. They access the histogram axis created
113 at drawing time only. Therefore they should called after the TGraph2D is drawn:
114 
115 ~~~ {.cpp}
116  TGraph2D *g = new TGraph2D();
117 
118  [...]
119 
120  g->Draw("tri1");
121  gPad->Update();
122  g->GetXaxis()->SetTitle("X axis title");
123 ~~~
124 
125 Example:
126 
127 Begin_Macro(source)
128 {
129  TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
130  Double_t x, y, z, P = 6.;
131  Int_t np = 200;
132  TGraph2D *dt = new TGraph2D();
133  TRandom *r = new TRandom();
134  for (Int_t N=0; N<np; N++) {
135  x = 2*P*(r->Rndm(N))-P;
136  y = 2*P*(r->Rndm(N))-P;
137  z = (sin(x)/x)*(sin(y)/y)+0.2;
138  dt->SetPoint(N,x,y,z);
139  }
140  gStyle->SetPalette(1);
141  dt->Draw("surf1");
142  return c;
143 }
144 End_Macro
145 
146 2D graphs can be fitted as shown by the following example:
147 
148 Begin_Macro(source)
149 ../../../tutorials/fit/graph2dfit.C
150 End_Macro
151 
152 Example showing the PCOL option.
153 
154 Begin_Macro(source)
155 {
156  TCanvas *c1 = new TCanvas("c1","Graph2D example",0,0,600,400);
157  Double_t P = 5.;
158  Int_t npx = 20 ;
159  Int_t npy = 20 ;
160  Double_t x = -P;
161  Double_t y = -P;
162  Double_t z;
163  Int_t k = 0;
164  Double_t dx = (2*P)/npx;
165  Double_t dy = (2*P)/npy;
166  TGraph2D *dt = new TGraph2D(npx*npy);
167  dt->SetNpy(41);
168  dt->SetNpx(40);
169  for (Int_t i=0; i<npx; i++) {
170  for (Int_t j=0; j<npy; j++) {
171  z = sin(sqrt(x*x+y*y))+1;
172  dt->SetPoint(k,x,y,z);
173  k++;
174  y = y+dy;
175  }
176  x = x+dx;
177  y = -P;
178  }
179  gStyle->SetPalette(1);
180  dt->SetMarkerStyle(20);
181  dt->Draw("pcol");
182  return c1;
183 }
184 End_Macro
185 
186 ### Definition of Delaunay triangulation (After B. Delaunay)
187 For a set S of points in the Euclidean plane, the unique triangulation DT(S)
188 of S such that no point in S is inside the circumcircle of any triangle in
189 DT(S). DT(S) is the dual of the Voronoi diagram of S.
190 If n is the number of points in S, the Voronoi diagram of S is the partitioning
191 of the plane containing S points into n convex polygons such that each polygon
192 contains exactly one point and every point in a given polygon is closer to its
193 central point than to any other. A Voronoi diagram is sometimes also known as
194 a Dirichlet tessellation.
195 
196 \image html tgraph2d_delaunay.png
197 
198 [This applet](http://www.cs.cornell.edu/Info/People/chew/Delaunay.html)
199 gives a nice practical view of Delaunay triangulation and Voronoi diagram.
200 */
201 
202 
203 ////////////////////////////////////////////////////////////////////////////////
204 /// Graph2D default constructor
205 
207  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
208  TAttMarker(), fNpoints(0)
209 {
210  fSize = 0;
211  fMargin = 0.;
212  fNpx = 40;
213  fNpy = 40;
214  fDirectory = 0;
215  fHistogram = 0;
216  fDelaunay = nullptr;
217  fMaximum = -1111;
218  fMinimum = -1111;
219  fX = 0;
220  fY = 0;
221  fZ = 0;
222  fZout = 0;
223  fMaxIter = 100000;
224  fPainter = 0;
225  fFunctions = new TList;
226  fUserHisto = kFALSE;
227 }
228 
229 
230 ////////////////////////////////////////////////////////////////////////////////
231 /// Graph2D constructor with three vectors of ints as input.
232 
234  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
235  TAttMarker(), fNpoints(n)
236 {
237  Build(n);
238 
239  // Copy the input vectors into local arrays
240  for (Int_t i = 0; i < fNpoints; ++i) {
241  fX[i] = (Double_t)x[i];
242  fY[i] = (Double_t)y[i];
243  fZ[i] = (Double_t)z[i];
244  }
245 }
246 
247 
248 ////////////////////////////////////////////////////////////////////////////////
249 /// Graph2D constructor with three vectors of floats as input.
250 
252  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
253  TAttMarker(), fNpoints(n)
254 {
255  Build(n);
256 
257  // Copy the input vectors into local arrays
258  for (Int_t i = 0; i < fNpoints; ++i) {
259  fX[i] = x[i];
260  fY[i] = y[i];
261  fZ[i] = z[i];
262  }
263 }
264 
265 
266 ////////////////////////////////////////////////////////////////////////////////
267 /// Graph2D constructor with three vectors of doubles as input.
268 
270  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
271  TAttMarker(), fNpoints(n)
272 {
273  Build(n);
274 
275  // Copy the input vectors into local arrays
276  for (Int_t i = 0; i < fNpoints; ++i) {
277  fX[i] = x[i];
278  fY[i] = y[i];
279  fZ[i] = z[i];
280  }
281 }
282 
283 
284 ////////////////////////////////////////////////////////////////////////////////
285 /// Graph2D constructor with a TH2 (h2) as input.
286 /// Only the h2's bins within the X and Y axis ranges are used.
287 /// Empty bins, recognized when both content and errors are zero, are excluded.
288 
290  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
291  TAttMarker(), fNpoints(0)
292 {
293  Build(h2->GetNbinsX()*h2->GetNbinsY());
294 
295  TString gname = "Graph2D_from_" + TString(h2->GetName());
296  SetName(gname);
297  // need to call later because sets title in ref histogram
298  SetTitle(h2->GetTitle());
299 
300 
301 
302  TAxis *xaxis = h2->GetXaxis();
303  TAxis *yaxis = h2->GetYaxis();
304  Int_t xfirst = xaxis->GetFirst();
305  Int_t xlast = xaxis->GetLast();
306  Int_t yfirst = yaxis->GetFirst();
307  Int_t ylast = yaxis->GetLast();
308 
309 
310  Double_t x, y, z;
311  Int_t k = 0;
312 
313  for (Int_t i = xfirst; i <= xlast; i++) {
314  for (Int_t j = yfirst; j <= ylast; j++) {
315  x = xaxis->GetBinCenter(i);
316  y = yaxis->GetBinCenter(j);
317  z = h2->GetBinContent(i, j);
318  Double_t ez = h2->GetBinError(i, j);
319  if (z != 0. || ez != 0) {
320  SetPoint(k, x, y, z);
321  k++;
322  }
323  }
324  }
325 }
326 
327 
328 ////////////////////////////////////////////////////////////////////////////////
329 /// Graph2D constructor with name, title and three vectors of doubles as input.
330 /// name : name of 2D graph (avoid blanks)
331 /// title : 2D graph title
332 /// if title is of the form "stringt;stringx;stringy;stringz"
333 /// the 2D graph title is set to stringt, the x axis title to stringx,
334 /// the y axis title to stringy,etc
335 
336 TGraph2D::TGraph2D(const char *name, const char *title,
338  : TNamed(name, title), TAttLine(1, 1, 1), TAttFill(0, 1001),
339  TAttMarker(), fNpoints(n)
340 {
341  Build(n);
342 
343  // Copy the input vectors into local arrays
344  for (Int_t i = 0; i < fNpoints; ++i) {
345  fX[i] = x[i];
346  fY[i] = y[i];
347  fZ[i] = z[i];
348  }
349 }
350 
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Graph2D constructor. The arrays fX, fY and fZ should be filled via
354 /// calls to SetPoint
355 
357  : TNamed("Graph2D", "Graph2D"), TAttLine(1, 1, 1), TAttFill(0, 1001),
358  TAttMarker(), fNpoints(n)
359 {
360  Build(n);
361  for (Int_t i = 0; i < fNpoints; i++) {
362  fX[i] = 0.;
363  fY[i] = 0.;
364  fZ[i] = 0.;
365  }
366 }
367 
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Graph2D constructor reading input from filename
371 /// filename is assumed to contain at least three columns of numbers.
372 /// For files separated by a specific delimiter different from ' ' and '\t' (e.g. ';' in csv files)
373 /// you can avoid using %*s to bypass this delimiter by explicitly specify the "option" argument,
374 /// e.g. option=" \t,;" for columns of figures separated by any of these characters (' ', '\t', ',', ';')
375 /// used once (e.g. "1;1") or in a combined way (" 1;,;; 1").
376 /// Note in that case, the instantiation is about 2 times slower.
377 
378 TGraph2D::TGraph2D(const char *filename, const char *format, Option_t *option)
379  : TNamed("Graph2D", filename), TAttLine(1, 1, 1), TAttFill(0, 1001),
380  TAttMarker(), fNpoints(0)
381 {
382  Double_t x, y, z;
383  TString fname = filename;
384  gSystem->ExpandPathName(fname);
385 
386  std::ifstream infile(fname.Data());
387  if (!infile.good()) {
388  MakeZombie();
389  Error("TGraph2D", "Cannot open file: %s, TGraph2D is Zombie", filename);
390  return;
391  } else {
392  Build(100);
393  }
394  std::string line;
395  Int_t np = 0;
396 
397  if (strcmp(option, "") == 0) { // No delimiters specified (standard constructor).
398 
399  while (std::getline(infile, line, '\n')) {
400  if (3 != sscanf(line.c_str(), format, &x, &y, &z)) {
401  continue; // skip empty and ill-formed lines
402  }
403  SetPoint(np, x, y, z);
404  np++;
405  }
406 
407  } else { // A delimiter has been specified in "option"
408 
409  // Checking format and creating its boolean equivalent
410  TString format_ = TString(format) ;
411  format_.ReplaceAll(" ", "") ;
412  format_.ReplaceAll("\t", "") ;
413  format_.ReplaceAll("lg", "") ;
414  format_.ReplaceAll("s", "") ;
415  format_.ReplaceAll("%*", "0") ;
416  format_.ReplaceAll("%", "1") ;
417  if (!format_.IsDigit()) {
418  Error("TGraph2D", "Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
419  return;
420  }
421  Int_t ntokens = format_.Length() ;
422  if (ntokens < 3) {
423  Error("TGraph2D", "Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
424  return;
425  }
426  Int_t ntokensToBeSaved = 0 ;
427  Bool_t * isTokenToBeSaved = new Bool_t [ntokens] ;
428  for (Int_t idx = 0; idx < ntokens; idx++) {
429  isTokenToBeSaved[idx] = TString::Format("%c", format_[idx]).Atoi() ; //atoi(&format_[idx]) does not work for some reason...
430  if (isTokenToBeSaved[idx] == 1) {
431  ntokensToBeSaved++ ;
432  }
433  }
434  if (ntokens >= 3 && ntokensToBeSaved != 3) { //first condition not to repeat the previous error message
435  Error("TGraph2D", "Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
436  delete [] isTokenToBeSaved ;
437  return;
438  }
439 
440  // Initializing loop variables
441  Bool_t isLineToBeSkipped = kFALSE ; //empty and ill-formed lines
442  char * token = NULL ;
443  TString token_str = "" ;
444  Int_t token_idx = 0 ;
445  Double_t * value = new Double_t [3] ; //x,y,z buffers
446  Int_t value_idx = 0 ;
447 
448  // Looping
449  while (std::getline(infile, line, '\n')) {
450  if (line != "") {
451  if (line[line.size() - 1] == char(13)) { // removing DOS CR character
452  line.erase(line.end() - 1, line.end()) ;
453  }
454  token = strtok(const_cast<char*>(line.c_str()), option) ;
455  while (token != NULL && value_idx < 3) {
456  if (isTokenToBeSaved[token_idx]) {
457  token_str = TString(token) ;
458  token_str.ReplaceAll("\t", "") ;
459  if (!token_str.IsFloat()) {
460  isLineToBeSkipped = kTRUE ;
461  break ;
462  } else {
463  value[value_idx] = token_str.Atof() ;
464  value_idx++ ;
465  }
466  }
467  token = strtok(NULL, option) ; //next token
468  token_idx++ ;
469  }
470  if (!isLineToBeSkipped && value_idx == 3) {
471  x = value[0] ;
472  y = value[1] ;
473  z = value[2] ;
474  SetPoint(np, x, y, z) ;
475  np++ ;
476  }
477  }
478  isLineToBeSkipped = kFALSE ;
479  token = NULL ;
480  token_idx = 0 ;
481  value_idx = 0 ;
482  }
483 
484  // Cleaning
485  delete [] isTokenToBeSaved ;
486  delete [] value ;
487  delete token ;
488  }
489  infile.close();
490 }
491 
492 
493 ////////////////////////////////////////////////////////////////////////////////
494 /// Graph2D copy constructor.
495 /// copy everything apart from the list of contained functions
496 
499  fX(0), fY(0), fZ(0),
500  fHistogram(0), fDirectory(0), fPainter(0)
501 {
502  fFunctions = new TList(); // do not copy the functions
503 
504  // use operator=
505  (*this) = g;
506 
507  // append TGraph2D to gdirectory
508  if (TH1::AddDirectoryStatus()) {
510  if (fDirectory) {
511  // append without replacing existing objects
512  fDirectory->Append(this);
513  }
514  }
515 
516 
517 }
518 
519 
520 ////////////////////////////////////////////////////////////////////////////////
521 /// TGraph2D destructor.
522 
524 {
525  Clear();
526 }
527 
528 
529 ////////////////////////////////////////////////////////////////////////////////
530 /// Graph2D operator "="
531 
533 {
534  if (this == &g) return *this;
535 
536  // delete before existing contained objects
537  if (fX) delete [] fX;
538  if (fY) delete [] fY;
539  if (fZ) delete [] fZ;
540  if (fHistogram && !fUserHisto) {
541  delete fHistogram;
542  fHistogram = 0;
543  }
544  // copy everything except the function list
545  fNpoints = g.fNpoints;
546  fNpx = g.fNpx;
547  fNpy = g.fNpy;
548  fMaxIter = g.fMaxIter;
549  fSize = fNpoints; // force size to be the same of npoints
550  fX = (fSize > 0) ? new Double_t[fSize] : 0;
551  fY = (fSize > 0) ? new Double_t[fSize] : 0;
552  fZ = (fSize > 0) ? new Double_t[fSize] : 0;
553  fMinimum = g.fMinimum;
554  fMaximum = g.fMaximum;
555  fMargin = g.fMargin;
556  fZout = g.fZout;
558  if (g.fHistogram)
559  fHistogram = (fUserHisto ) ? g.fHistogram : new TH2D(*g.fHistogram);
560 
561 
562 
563  // copy the points
564  for (Int_t n = 0; n < fSize; n++) {
565  fX[n] = g.fX[n];
566  fY[n] = g.fY[n];
567  fZ[n] = g.fZ[n];
568  }
569 
570  return *this;
571 }
572 
573 ////////////////////////////////////////////////////////////////////////////////
574 /// Creates the 2D graph basic data structure
575 
576 void TGraph2D::Build(Int_t n)
577 {
578  if (n <= 0) {
579  Error("TGraph2D", "Invalid number of points (%d)", n);
580  return;
581  }
582 
583  fSize = n;
584  fMargin = 0.;
585  fNpx = 40;
586  fNpy = 40;
587  fDirectory = 0;
588  fHistogram = 0;
589  fDelaunay = nullptr;
590  fMaximum = -1111;
591  fMinimum = -1111;
592  fX = new Double_t[fSize];
593  fY = new Double_t[fSize];
594  fZ = new Double_t[fSize];
595  fZout = 0;
596  fMaxIter = 100000;
597  fFunctions = new TList;
598  fPainter = 0;
599  fUserHisto = kFALSE;
600 
601  if (TH1::AddDirectoryStatus()) {
603  if (fDirectory) {
604  fDirectory->Append(this, kTRUE);
605  }
606  }
607 }
608 
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 /// Browse
612 
614 {
615  Draw("p0");
616  gPad->Update();
617 }
618 
619 
620 ////////////////////////////////////////////////////////////////////////////////
621 /// Free all memory allocated by this object.
622 
623 void TGraph2D::Clear(Option_t * /*option = "" */)
624 {
625  if (fX) delete [] fX;
626  fX = 0;
627  if (fY) delete [] fY;
628  fY = 0;
629  if (fZ) delete [] fZ;
630  fZ = 0;
631  fSize = fNpoints = 0;
632  if (fHistogram && !fUserHisto) {
633  delete fHistogram;
634  fHistogram = 0;
635  }
636  if (fFunctions) {
638  fFunctions->Delete();
639  delete fFunctions;
640  fFunctions = 0;
641  }
642  if (fDirectory) {
643  fDirectory->Remove(this);
644  fDirectory = 0;
645  }
646 }
647 
648 
649 ////////////////////////////////////////////////////////////////////////////////
650 /// Perform the automatic addition of the graph to the given directory
651 ///
652 /// Note this function is called in place when the semantic requires
653 /// this object to be added to a directory (I.e. when being read from
654 /// a TKey or being Cloned)
655 
657 {
658  Bool_t addStatus = TH1::AddDirectoryStatus();
659  if (addStatus) {
660  SetDirectory(dir);
661  if (dir) {
663  }
664  }
665 }
666 
667 
668 ////////////////////////////////////////////////////////////////////////////////
669 /// Computes distance from point px,py to a graph
670 
672 {
673  Int_t distance = 9999;
674  if (fHistogram) distance = fHistogram->DistancetoPrimitive(px, py);
675  return distance;
676 }
677 
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Specific drawing options can be used to paint a TGraph2D:
681 ///
682 /// "TRI" : The Delaunay triangles are drawn using filled area.
683 /// An hidden surface drawing technique is used. The surface is
684 /// painted with the current fill area color. The edges of each
685 /// triangles are painted with the current line color.
686 /// "TRIW" : The Delaunay triangles are drawn as wire frame
687 /// "TRI1" : The Delaunay triangles are painted with color levels. The edges
688 /// of each triangles are painted with the current line color.
689 /// "TRI2" : the Delaunay triangles are painted with color levels.
690 /// "P" : Draw a marker at each vertex
691 /// "P0" : Draw a circle at each vertex. Each circle background is white.
692 /// "PCOL" : Draw a marker at each vertex. The color of each marker is
693 /// defined according to its Z position.
694 /// "CONT" : Draw contours
695 /// "LINE" : Draw a 3D polyline
696 ///
697 /// A TGraph2D can be also drawn with ANY options valid to draw a 2D histogram.
698 ///
699 /// When a TGraph2D is drawn with one of the 2D histogram drawing option,
700 /// a intermediate 2D histogram is filled using the Delaunay triangles
701 /// technique to interpolate the data set.
702 
703 void TGraph2D::Draw(Option_t *option)
704 {
705  TString opt = option;
706  opt.ToLower();
707  if (gPad) {
708  if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
709  if (!opt.Contains("same")) {
710  //the following statement is necessary in case one attempts to draw
711  //a temporary histogram already in the current pad
712  if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this);
713  gPad->Clear();
714  }
715  }
716  AppendPad(opt.Data());
717 }
718 
719 
720 ////////////////////////////////////////////////////////////////////////////////
721 /// Executes action corresponding to one event
722 
723 void TGraph2D::ExecuteEvent(Int_t event, Int_t px, Int_t py)
724 {
725  if (fHistogram) fHistogram->ExecuteEvent(event, px, py);
726 }
727 
728 
729 ////////////////////////////////////////////////////////////////////////////////
730 /// search object named name in the list of functions
731 
732 TObject *TGraph2D::FindObject(const char *name) const
733 {
734  if (fFunctions) return fFunctions->FindObject(name);
735  return 0;
736 }
737 
738 
739 ////////////////////////////////////////////////////////////////////////////////
740 /// search object obj in the list of functions
741 
742 TObject *TGraph2D::FindObject(const TObject *obj) const
743 {
744  if (fFunctions) return fFunctions->FindObject(obj);
745  return 0;
746 }
747 
748 
749 ////////////////////////////////////////////////////////////////////////////////
750 /// Fits this graph with function with name fname
751 /// Predefined functions such as gaus, expo and poln are automatically
752 /// created by ROOT.
753 /// fname can also be a formula, accepted by the linear fitter (linear parts divided
754 /// by "++" sign), for example "x++sin(y)" for fitting "[0]*x+[1]*sin(y)"
755 
756 TFitResultPtr TGraph2D::Fit(const char *fname, Option_t *option, Option_t *)
757 {
758 
759  char *linear;
760  linear = (char*)strstr(fname, "++");
761  TF2 *f2 = 0;
762  if (linear)
763  f2 = new TF2(fname, fname);
764  else {
765  f2 = (TF2*)gROOT->GetFunction(fname);
766  if (!f2) {
767  Printf("Unknown function: %s", fname);
768  return -1;
769  }
770  }
771  return Fit(f2, option, "");
772 
773 }
774 
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// Fits this 2D graph with function f2
778 ///
779 /// f2 is an already predefined function created by TF2.
780 /// Predefined functions such as gaus, expo and poln are automatically
781 /// created by ROOT.
782 ///
783 /// The list of fit options is given in parameter option.
784 /// option = "W" Set all weights to 1; ignore error bars
785 /// = "U" Use a User specified fitting algorithm (via SetFCN)
786 /// = "Q" Quiet mode (minimum printing)
787 /// = "V" Verbose mode (default is between Q and V)
788 /// = "R" Use the Range specified in the function range
789 /// = "N" Do not store the graphics function, do not draw
790 /// = "0" Do not plot the result of the fit. By default the fitted function
791 /// is drawn unless the option "N" above is specified.
792 /// = "+" Add this new fitted function to the list of fitted functions
793 /// (by default, any previous function is deleted)
794 /// = "C" In case of linear fitting, not calculate the chisquare
795 /// (saves time)
796 /// = "EX0" When fitting a TGraphErrors do not consider errors in the coordinate
797 /// = "ROB" In case of linear fitting, compute the LTS regression
798 /// coefficients (robust (resistant) regression), using
799 /// the default fraction of good points
800 /// "ROB=0.x" - compute the LTS regression coefficients, using
801 /// 0.x as a fraction of good points
802 /// = "S" The result of the fit is returned in the TFitResultPtr
803 /// (see below Access to the Fit Result)
804 ///
805 /// In order to use the Range option, one must first create a function
806 /// with the expression to be fitted. For example, if your graph2d
807 /// has a defined range between -4 and 4 and you want to fit a gaussian
808 /// only in the interval 1 to 3, you can do:
809 /// TF2 *f2 = new TF2("f2","gaus",1,3);
810 /// graph2d->Fit("f2","R");
811 ///
812 ///
813 /// Setting initial conditions
814 /// ==========================
815 /// Parameters must be initialized before invoking the Fit function.
816 /// The setting of the parameter initial values is automatic for the
817 /// predefined functions : poln, expo, gaus. One can however disable
818 /// this automatic computation by specifying the option "B".
819 /// You can specify boundary limits for some or all parameters via
820 /// f2->SetParLimits(p_number, parmin, parmax);
821 /// if parmin>=parmax, the parameter is fixed
822 /// Note that you are not forced to fix the limits for all parameters.
823 /// For example, if you fit a function with 6 parameters, you can do:
824 /// func->SetParameters(0,3.1,1.e-6,0.1,-8,100);
825 /// func->SetParLimits(4,-10,-4);
826 /// func->SetParLimits(5, 1,1);
827 /// With this setup, parameters 0->3 can vary freely
828 /// Parameter 4 has boundaries [-10,-4] with initial value -8
829 /// Parameter 5 is fixed to 100.
830 ///
831 /// Fit range
832 /// =========
833 /// The fit range can be specified in two ways:
834 /// - specify rxmax > rxmin (default is rxmin=rxmax=0)
835 /// - specify the option "R". In this case, the function will be taken
836 /// instead of the full graph range.
837 ///
838 /// Changing the fitting function
839 /// =============================
840 /// By default a chi2 fitting function is used for fitting a TGraph.
841 /// The function is implemented in FitUtil::EvaluateChi2.
842 /// In case of TGraph2DErrors an effective chi2 is used
843 /// (see TGraphErrors fit in TGraph::Fit) and is implemented in
844 /// FitUtil::EvaluateChi2Effective
845 /// To specify a User defined fitting function, specify option "U" and
846 /// call the following functions:
847 /// TVirtualFitter::Fitter(mygraph)->SetFCN(MyFittingFunction)
848 /// where MyFittingFunction is of type:
849 /// extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
850 ///
851 /// Associated functions
852 /// ====================
853 /// One or more object (typically a TF2*) can be added to the list
854 /// of functions (fFunctions) associated to each graph.
855 /// When TGraph::Fit is invoked, the fitted function is added to this list.
856 /// Given a graph gr, one can retrieve an associated function
857 /// with: TF2 *myfunc = gr->GetFunction("myfunc");
858 ///
859 /// Access to the fit results
860 /// =========================
861 /// The function returns a TFitResultPtr which can hold a pointer to a TFitResult object.
862 /// By default the TFitResultPtr contains only the status of the fit and it converts automatically to an
863 /// integer. If the option "S" is instead used, TFitResultPtr contains the TFitResult and behaves as a smart
864 /// pointer to it. For example one can do:
865 /// TFitResultPtr r = graph->Fit("myFunc","S");
866 /// TMatrixDSym cov = r->GetCovarianceMatrix(); // to access the covariance matrix
867 /// Double_t par0 = r->Value(0); // retrieve the value for the parameter 0
868 /// Double_t err0 = r->Error(0); // retrieve the error for the parameter 0
869 /// r->Print("V"); // print full information of fit including covariance matrix
870 /// r->Write(); // store the result in a file
871 ///
872 /// The fit parameters, error and chi2 (but not covariance matrix) can be retrieved also
873 /// from the fitted function.
874 /// If the graph is made persistent, the list of
875 /// associated functions is also persistent. Given a pointer (see above)
876 /// to an associated function myfunc, one can retrieve the function/fit
877 /// parameters with calls such as:
878 /// Double_t chi2 = myfunc->GetChisquare();
879 /// Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
880 /// Double_t err0 = myfunc->GetParError(0); //error on first parameter
881 ///
882 /// Fit Statistics
883 /// ==============
884 /// You can change the statistics box to display the fit parameters with
885 /// the TStyle::SetOptFit(mode) method. This mode has four digits.
886 /// mode = pcev (default = 0111)
887 /// v = 1; print name/values of parameters
888 /// e = 1; print errors (if e=1, v must be 1)
889 /// c = 1; print Chisquare/Number of degrees of freedom
890 /// p = 1; print Probability
891 ///
892 /// For example: gStyle->SetOptFit(1011);
893 /// prints the fit probability, parameter names/values, and errors.
894 /// You can change the position of the statistics box with these lines
895 /// (where g is a pointer to the TGraph):
896 ///
897 /// Root > TPaveStats *st = (TPaveStats*)g->GetListOfFunctions()->FindObject("stats")
898 /// Root > st->SetX1NDC(newx1); //new x start position
899 /// Root > st->SetX2NDC(newx2); //new x end position
900 
902 {
903  // internal graph2D fitting methods
904  Foption_t fitOption;
905  Option_t *goption = "";
906  ROOT::Fit::FitOptionsMake(ROOT::Fit::kGraph, option, fitOption);
907 
908  // create range and minimizer options with default values
909  ROOT::Fit::DataRange range(2);
911  return ROOT::Fit::FitObject(this, f2 , fitOption , minOption, goption, range);
912 }
913 
914 
915 ////////////////////////////////////////////////////////////////////////////////
916 /// Display a GUI panel with all graph fit options.
917 ///
918 /// See class TFitEditor for example
919 
920 void TGraph2D::FitPanel()
921 {
922  if (!gPad)
923  gROOT->MakeDefCanvas();
924 
925  if (!gPad) {
926  Error("FitPanel", "Unable to create a default canvas");
927  return;
928  }
929 
930  // use plugin manager to create instance of TFitEditor
931  TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
932  if (handler && handler->LoadPlugin() != -1) {
933  if (handler->ExecPlugin(2, gPad, this) == 0)
934  Error("FitPanel", "Unable to crate the FitPanel");
935  } else
936  Error("FitPanel", "Unable to find the FitPanel plug-in");
937 
938 }
939 
940 
941 ////////////////////////////////////////////////////////////////////////////////
942 /// Get x axis of the graph.
943 
944 TAxis *TGraph2D::GetXaxis() const
945 {
946  TH1 *h = ((TGraph2D*)this)->GetHistogram("empty");
947  if (!h) return 0;
948  return h->GetXaxis();
949 }
950 
951 
952 ////////////////////////////////////////////////////////////////////////////////
953 /// Get y axis of the graph.
954 
955 TAxis *TGraph2D::GetYaxis() const
956 {
957  TH1 *h = ((TGraph2D*)this)->GetHistogram("empty");
958  if (!h) return 0;
959  return h->GetYaxis();
960 }
961 
962 
963 ////////////////////////////////////////////////////////////////////////////////
964 /// Get z axis of the graph.
965 
966 TAxis *TGraph2D::GetZaxis() const
967 {
968  TH1 *h = ((TGraph2D*)this)->GetHistogram("empty");
969  if (!h) return 0;
970  return h->GetZaxis();
971 }
972 
973 
974 ////////////////////////////////////////////////////////////////////////////////
975 /// Returns the X and Y graphs building a contour. A contour level may
976 /// consist in several parts not connected to each other. This function
977 /// returns them in a graphs' list.
978 
980 {
981  if (fNpoints <= 0) {
982  Error("GetContourList", "Empty TGraph2D");
983  return 0;
984  }
985 
986  if (!fHistogram) GetHistogram("empty");
987 
989 
990  return fPainter->GetContourList(contour);
991 }
992 
993 
994 ////////////////////////////////////////////////////////////////////////////////
995 /// This function is called by Graph2DFitChisquare.
996 /// It always returns a negative value. Real implementation in TGraph2DErrors
997 
999 {
1000  return -1;
1001 }
1002 
1003 
1004 ////////////////////////////////////////////////////////////////////////////////
1005 /// This function is called by Graph2DFitChisquare.
1006 /// It always returns a negative value. Real implementation in TGraph2DErrors
1007 
1010  return -1;
1011 }
1012 
1013 
1014 ////////////////////////////////////////////////////////////////////////////////
1015 /// This function is called by Graph2DFitChisquare.
1016 /// It always returns a negative value. Real implementation in TGraph2DErrors
1017 
1020  return -1;
1021 }
1022 
1023 
1024 ////////////////////////////////////////////////////////////////////////////////
1025 /// By default returns a pointer to the Delaunay histogram. If fHistogram
1026 /// doesn't exist, books the 2D histogram fHistogram with a margin around
1027 /// the hull. Calls TGraphDelaunay::Interpolate at each bin centre to build up
1028 /// an interpolated 2D histogram.
1029 /// If the "empty" option is selected, returns an empty histogram booked with
1030 /// the limits of fX, fY and fZ. This option is used when the data set is
1031 /// drawn with markers only. In that particular case there is no need to
1032 /// find the Delaunay triangles.
1033 /// By default use the new interpolation routine based on Triangles
1034 /// If the option "old" the old interpolation is used
1035 
1038  // for an empty graph create histogram in [0,1][0,1]
1039  if (fNpoints <= 0) {
1040  if (!fHistogram) {
1043  fHistogram = new TH2D(GetName(), GetTitle(), fNpx , 0., 1., fNpy, 0., 1.);
1044  TH1::AddDirectory(add);
1046  }
1047  return fHistogram;
1048  }
1049 
1050  TString opt = option;
1051  opt.ToLower();
1052  Bool_t empty = opt.Contains("empty");
1053  Bool_t oldInterp = opt.Contains("old");
1054 
1055  if (fHistogram) {
1056  if (!empty && fHistogram->GetEntries() == 0) {
1057  if (!fUserHisto) {
1058  delete fHistogram;
1059  fHistogram = 0;
1060  }
1061  } else if (fHistogram->GetEntries() == 0)
1062  {; }
1063  // check case if interpolation type has changed
1064  else if ( (TestBit(kOldInterpolation) && !oldInterp) || ( !TestBit(kOldInterpolation) && oldInterp ) ) {
1065  delete fHistogram;
1066  fHistogram = 0;
1067  }
1068  // normal case return existing histogram
1069  else {
1070  return fHistogram;
1071  }
1072  }
1073 
1074  Double_t hxmax, hymax, hxmin, hymin;
1075 
1076  // Book fHistogram if needed. It is not added in the current directory
1077  if (!fUserHisto) {
1080  Double_t xmax = GetXmaxE();
1081  Double_t ymax = GetYmaxE();
1082  Double_t xmin = GetXminE();
1083  Double_t ymin = GetYminE();
1084  hxmin = xmin - fMargin * (xmax - xmin);
1085  hymin = ymin - fMargin * (ymax - ymin);
1086  hxmax = xmax + fMargin * (xmax - xmin);
1087  hymax = ymax + fMargin * (ymax - ymin);
1088  if (hxmin==hxmax) {
1089  if (hxmin==0) {
1090  hxmin = -0.01;
1091  hxmax = 0.01;
1092  } else {
1093  hxmin = hxmin-hxmin*0.01;
1094  hxmax = hxmax+hxmax*0.01;
1095  }
1096  }
1097  if (hymin==hymax) {
1098  if (hxmin==0) {
1099  hymin = -0.01;
1100  hymax = 0.01;
1101  } else {
1102  hymin = hymin-hymin*0.01;
1103  hymax = hymax+hymax*0.01;
1104  }
1105  }
1106  if (fHistogram) {
1107  fHistogram->GetXaxis()->SetLimits(hxmin, hxmax);
1108  fHistogram->GetYaxis()->SetLimits(hymin, hymax);
1109  } else {
1110  fHistogram = new TH2D(GetName(), GetTitle(),
1111  fNpx , hxmin, hxmax,
1112  fNpy, hymin, hymax);
1113  }
1114  TH1::AddDirectory(add);
1116  } else {
1117  hxmin = fHistogram->GetXaxis()->GetXmin();
1118  hymin = fHistogram->GetYaxis()->GetXmin();
1119  hxmax = fHistogram->GetXaxis()->GetXmax();
1120  hymax = fHistogram->GetYaxis()->GetXmax();
1121  }
1122 
1123  // Add a TGraphDelaunay in the list of the fHistogram's functions
1124 
1125  if (oldInterp) {
1126  TGraphDelaunay *dt = new TGraphDelaunay(this);
1127  dt->SetMaxIter(fMaxIter);
1129  fDelaunay = dt;
1131  }
1132  else {
1133  // new interpolation based on ROOT::Math::Delaunay
1134  TGraphDelaunay2D *dt = new TGraphDelaunay2D(this);
1136  fDelaunay = dt;
1138  }
1140  hl->Add(fDelaunay);
1141 
1142  // Option "empty" is selected. An empty histogram is returned.
1143  if (empty) {
1144  Double_t hzmax, hzmin;
1145  if (fMinimum != -1111) {
1146  hzmin = fMinimum;
1147  } else {
1148  hzmin = GetZmin();
1149  }
1150  if (fMaximum != -1111) {
1151  hzmax = fMaximum;
1152  } else {
1153  hzmax = GetZmax();
1154  }
1155  if (hzmin == hzmax) {
1156  Double_t hz = hzmin;
1157  if (hz==0) hz = 1.;
1158  hzmin = hz - 0.01 * hz;
1159  hzmax = hz + 0.01 * hz;
1160  }
1161  fHistogram->SetMinimum(hzmin);
1162  fHistogram->SetMaximum(hzmax);
1163  return fHistogram;
1164  }
1165 
1166  Double_t dx = (hxmax - hxmin) / fNpx;
1167  Double_t dy = (hymax - hymin) / fNpy;
1168 
1169  Double_t x, y, z;
1170 
1171  for (Int_t ix = 1; ix <= fNpx; ix++) {
1172  x = hxmin + (ix - 0.5) * dx;
1173  for (Int_t iy = 1; iy <= fNpy; iy++) {
1174  y = hymin + (iy - 0.5) * dy;
1175  // do interpolation
1176  if (oldInterp)
1177  z = ((TGraphDelaunay*)fDelaunay)->ComputeZ(x, y);
1178  else
1179  z = ((TGraphDelaunay2D*)fDelaunay)->ComputeZ(x, y);
1180 
1181  fHistogram->Fill(x, y, z);
1182  }
1183  }
1184 
1185 
1186  if (fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
1187  if (fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
1188 
1189  return fHistogram;
1190 }
1191 
1192 
1193 ////////////////////////////////////////////////////////////////////////////////
1194 /// Returns the X maximum
1195 
1198  Double_t v = fX[0];
1199  for (Int_t i = 1; i < fNpoints; i++) if (fX[i] > v) v = fX[i];
1200  return v;
1201 }
1202 
1203 
1204 ////////////////////////////////////////////////////////////////////////////////
1205 /// Returns the X minimum
1206 
1209  Double_t v = fX[0];
1210  for (Int_t i = 1; i < fNpoints; i++) if (fX[i] < v) v = fX[i];
1211  return v;
1212 }
1213 
1214 
1215 ////////////////////////////////////////////////////////////////////////////////
1216 /// Returns the Y maximum
1217 
1220  Double_t v = fY[0];
1221  for (Int_t i = 1; i < fNpoints; i++) if (fY[i] > v) v = fY[i];
1222  return v;
1223 }
1224 
1225 
1226 ////////////////////////////////////////////////////////////////////////////////
1227 /// Returns the Y minimum
1228 
1231  Double_t v = fY[0];
1232  for (Int_t i = 1; i < fNpoints; i++) if (fY[i] < v) v = fY[i];
1233  return v;
1234 }
1235 
1236 
1237 ////////////////////////////////////////////////////////////////////////////////
1238 /// Returns the Z maximum
1239 
1242  Double_t v = fZ[0];
1243  for (Int_t i = 1; i < fNpoints; i++) if (fZ[i] > v) v = fZ[i];
1244  return v;
1245 }
1246 
1247 
1248 ////////////////////////////////////////////////////////////////////////////////
1249 /// Returns the Z minimum
1250 
1253  Double_t v = fZ[0];
1254  for (Int_t i = 1; i < fNpoints; i++) if (fZ[i] < v) v = fZ[i];
1255  return v;
1256 }
1257 
1258 
1259 ////////////////////////////////////////////////////////////////////////////////
1260 /// Finds the z value at the position (x,y) thanks to
1261 /// the Delaunay interpolation.
1262 
1265  if (fNpoints <= 0) {
1266  Error("Interpolate", "Empty TGraph2D");
1267  return 0;
1268  }
1269 
1270  if (!fHistogram) GetHistogram("empty");
1271  if (!fDelaunay) {
1273  if (!TestBit(kOldInterpolation) ) {
1274  fDelaunay = hl->FindObject("TGraphDelaunay2D");
1275  if (!fDelaunay) fDelaunay = hl->FindObject("TGraphDelaunay");
1276  }
1277  else {
1278  // if using old implementation
1279  fDelaunay = hl->FindObject("TGraphDelaunay");
1280  if (!fDelaunay) fDelaunay = hl->FindObject("TGraphDelaunay2D");
1281  }
1282  }
1283 
1284  if (!fDelaunay) return TMath::QuietNaN();
1285 
1286  if (fDelaunay->IsA() == TGraphDelaunay2D::Class() )
1287  return ((TGraphDelaunay2D*)fDelaunay)->ComputeZ(x, y);
1288  else if (fDelaunay->IsA() == TGraphDelaunay::Class() )
1289  return ((TGraphDelaunay*)fDelaunay)->ComputeZ(x, y);
1290 
1291  // cannot be here
1292  assert(false);
1293  return TMath::QuietNaN();
1294 }
1295 
1296 
1297 ////////////////////////////////////////////////////////////////////////////////
1298 /// Paints this 2D graph with its current attributes
1299 
1300 void TGraph2D::Paint(Option_t *option)
1302  if (fNpoints <= 0) {
1303  Error("Paint", "Empty TGraph2D");
1304  return;
1305  }
1306 
1307  TString opt = option;
1308  opt.ToLower();
1309  if (opt.Contains("p") && !opt.Contains("tri")) {
1310  if (!opt.Contains("pol") &&
1311  !opt.Contains("sph") &&
1312  !opt.Contains("psr")) opt.Append("tri0");
1313  }
1314 
1315  if (opt.Contains("line") && !opt.Contains("tri")) opt.Append("tri0");
1316 
1317  if (opt.Contains("err") && !opt.Contains("tri")) opt.Append("tri0");
1318 
1319  if (opt.Contains("tri0")) {
1320  GetHistogram("empty");
1321  } else if (opt.Contains("old")) {
1322  GetHistogram("old");
1323  } else {
1324  GetHistogram();
1325  }
1326 
1335  fHistogram->Paint(opt.Data());
1336 }
1337 
1338 
1339 ////////////////////////////////////////////////////////////////////////////////
1340 /// Projects a 2-d graph into 1 or 2-d histograms depending on the
1341 /// option parameter
1342 /// option may contain a combination of the characters x,y,z
1343 /// option = "x" return the x projection into a TH1D histogram
1344 /// option = "y" return the y projection into a TH1D histogram
1345 /// option = "xy" return the x versus y projection into a TH2D histogram
1346 /// option = "yx" return the y versus x projection into a TH2D histogram
1347 
1348 TH1 *TGraph2D::Project(Option_t *option) const
1350  if (fNpoints <= 0) {
1351  Error("Project", "Empty TGraph2D");
1352  return 0;
1353  }
1354 
1355  TString opt = option;
1356  opt.ToLower();
1357 
1358  Int_t pcase = 0;
1359  if (opt.Contains("x")) pcase = 1;
1360  if (opt.Contains("y")) pcase = 2;
1361  if (opt.Contains("xy")) pcase = 3;
1362  if (opt.Contains("yx")) pcase = 4;
1363 
1364  // Create the projection histogram
1365  TH1D *h1 = 0;
1366  TH2D *h2 = 0;
1367  Int_t nch = strlen(GetName()) + opt.Length() + 2;
1368  char *name = new char[nch];
1369  snprintf(name, nch, "%s_%s", GetName(), option);
1370  nch = strlen(GetTitle()) + opt.Length() + 2;
1371  char *title = new char[nch];
1372  snprintf(title, nch, "%s_%s", GetTitle(), option);
1373 
1374  Double_t hxmin = GetXmin();
1375  Double_t hxmax = GetXmax();
1376  Double_t hymin = GetYmin();
1377  Double_t hymax = GetYmax();
1378 
1379  switch (pcase) {
1380  case 1:
1381  // "x"
1382  h1 = new TH1D(name, title, fNpx, hxmin, hxmax);
1383  break;
1384  case 2:
1385  // "y"
1386  h1 = new TH1D(name, title, fNpy, hymin, hymax);
1387  break;
1388  case 3:
1389  // "xy"
1390  h2 = new TH2D(name, title, fNpx, hxmin, hxmax, fNpy, hymin, hymax);
1391  break;
1392  case 4:
1393  // "yx"
1394  h2 = new TH2D(name, title, fNpy, hymin, hymax, fNpx, hxmin, hxmax);
1395  break;
1396  }
1397 
1398  delete [] name;
1399  delete [] title;
1400  TH1 *h = h1;
1401  if (h2) h = h2;
1402  if (h == 0) return 0;
1403 
1404  // Fill the projected histogram
1405  Double_t entries = 0;
1406  for (Int_t n = 0; n < fNpoints; n++) {
1407  switch (pcase) {
1408  case 1:
1409  // "x"
1410  h1->Fill(fX[n], fZ[n]);
1411  break;
1412  case 2:
1413  // "y"
1414  h1->Fill(fY[n], fZ[n]);
1415  break;
1416  case 3:
1417  // "xy"
1418  h2->Fill(fX[n], fY[n], fZ[n]);
1419  break;
1420  case 4:
1421  // "yx"
1422  h2->Fill(fY[n], fX[n], fZ[n]);
1423  break;
1424  }
1425  entries += fZ[n];
1426  }
1427  h->SetEntries(entries);
1428  return h;
1429 }
1430 
1431 
1432 ////////////////////////////////////////////////////////////////////////////////
1433 /// Deletes point number ipoint
1434 
1437  if (ipoint < 0) return -1;
1438  if (ipoint >= fNpoints) return -1;
1439 
1440  fNpoints--;
1441  Double_t *newX = new Double_t[fNpoints];
1442  Double_t *newY = new Double_t[fNpoints];
1443  Double_t *newZ = new Double_t[fNpoints];
1444  Int_t j = -1;
1445  for (Int_t i = 0; i < fNpoints + 1; i++) {
1446  if (i == ipoint) continue;
1447  j++;
1448  newX[j] = fX[i];
1449  newY[j] = fY[i];
1450  newZ[j] = fZ[i];
1451  }
1452  delete [] fX;
1453  delete [] fY;
1454  delete [] fZ;
1455  fX = newX;
1456  fY = newY;
1457  fZ = newZ;
1458  fSize = fNpoints;
1459  if (fHistogram) {
1460  delete fHistogram;
1461  fHistogram = 0;
1462  }
1463  return ipoint;
1464 }
1465 
1466 
1467 ////////////////////////////////////////////////////////////////////////////////
1468 /// Saves primitive as a C++ statement(s) on output stream out
1469 
1470 void TGraph2D::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1472  char quote = '"';
1473  out << " " << std::endl;
1474  if (gROOT->ClassSaved(TGraph2D::Class())) {
1475  out << " ";
1476  } else {
1477  out << " TGraph2D *";
1478  }
1479 
1480  out << "graph2d = new TGraph2D(" << fNpoints << ");" << std::endl;
1481  out << " graph2d->SetName(" << quote << GetName() << quote << ");" << std::endl;
1482  out << " graph2d->SetTitle(" << quote << GetTitle() << quote << ");" << std::endl;
1483 
1484  if (fDirectory == 0) {
1485  out << " " << GetName() << "->SetDirectory(0);" << std::endl;
1486  }
1487 
1488  SaveFillAttributes(out, "graph2d", 0, 1001);
1489  SaveLineAttributes(out, "graph2d", 1, 1, 1);
1490  SaveMarkerAttributes(out, "graph2d", 1, 1, 1);
1491 
1492  for (Int_t i = 0; i < fNpoints; i++) {
1493  out << " graph2d->SetPoint(" << i << "," << fX[i] << "," << fY[i] << "," << fZ[i] << ");" << std::endl;
1494  }
1495 
1496  // save list of functions
1497  TIter next(fFunctions);
1498  TObject *obj;
1499  while ((obj = next())) {
1500  obj->SavePrimitive(out, "nodraw");
1501  out << " graph2d->GetListOfFunctions()->Add(" << obj->GetName() << ");" << std::endl;
1502  if (obj->InheritsFrom("TPaveStats")) {
1503  out << " ptstats->SetParent(graph2d->GetListOfFunctions());" << std::endl;
1504  }
1505  }
1506 
1507  out << " graph2d->Draw(" << quote << option << quote << ");" << std::endl;
1508 }
1509 
1510 
1511 ////////////////////////////////////////////////////////////////////////////////
1512 /// Set number of points in the 2D graph.
1513 /// Existing coordinates are preserved.
1514 /// New coordinates above fNpoints are preset to 0.
1515 
1516 void TGraph2D::Set(Int_t n)
1518  if (n < 0) n = 0;
1519  if (n == fNpoints) return;
1520  if (n > fNpoints) SetPoint(n, 0, 0, 0);
1521  fNpoints = n;
1522 }
1523 
1524 
1525 ////////////////////////////////////////////////////////////////////////////////
1526 /// By default when an 2D graph is created, it is added to the list
1527 /// of 2D graph objects in the current directory in memory.
1528 /// This method removes reference to this 2D graph from current directory and add
1529 /// reference to new directory dir. dir can be 0 in which case the
1530 /// 2D graph does not belong to any directory.
1531 
1534  if (fDirectory == dir) return;
1535  if (fDirectory) fDirectory->Remove(this);
1536  fDirectory = dir;
1537  if (fDirectory) fDirectory->Append(this);
1538 }
1539 
1540 
1541 ////////////////////////////////////////////////////////////////////////////////
1542 /// Sets the histogram to be filled.
1543 /// If the 2D graph needs to be save in a TFile the following set should be
1544 /// followed to read it back:
1545 /// 1) Create TGraph2D
1546 /// 2) Call g->SetHistogram(h), and do whatever you need to do
1547 /// 3) Save g and h to the TFile, exit
1548 /// 4) Open the TFile, retrieve g and h
1549 /// 5) Call h->SetDirectory(0)
1550 /// 6) Call g->SetHistogram(h) again
1551 /// 7) Carry on as normal
1552 
1555  fUserHisto = kTRUE;
1556  fHistogram = (TH2D*)h;
1557  fNpx = h->GetNbinsX();
1558  fNpy = h->GetNbinsY();
1559 }
1560 
1561 
1562 ////////////////////////////////////////////////////////////////////////////////
1563 /// Sets the extra space (in %) around interpolated area for the 2D histogram
1564 
1567  if (m < 0 || m > 1) {
1568  Warning("SetMargin", "The margin must be >= 0 && <= 1, fMargin set to 0.1");
1569  fMargin = 0.1;
1570  } else {
1571  fMargin = m;
1572  }
1573  if (fHistogram) {
1574  delete fHistogram;
1575  fHistogram = 0;
1576  }
1577 }
1578 
1579 
1580 ////////////////////////////////////////////////////////////////////////////////
1581 /// Sets the histogram bin height for points lying outside the TGraphDelaunay
1582 /// convex hull ie: the bins in the margin.
1583 
1586  fZout = z;
1587  if (fHistogram) {
1588  delete fHistogram;
1589  fHistogram = 0;
1590  }
1591 }
1592 
1593 
1594 ////////////////////////////////////////////////////////////////////////////////
1595 /// Set maximum.
1596 
1597 void TGraph2D::SetMaximum(Double_t maximum)
1599  fMaximum = maximum;
1600  TH1 * h = GetHistogram();
1601  if (h) h->SetMaximum(maximum);
1602 }
1603 
1604 
1605 ////////////////////////////////////////////////////////////////////////////////
1606 /// Set minimum.
1607 
1608 void TGraph2D::SetMinimum(Double_t minimum)
1610  fMinimum = minimum;
1611  TH1 * h = GetHistogram();
1612  if (h) h->SetMinimum(minimum);
1613 }
1614 
1615 
1616 ////////////////////////////////////////////////////////////////////////////////
1617 /// Changes the name of this 2D graph
1618 
1619 void TGraph2D::SetName(const char *name)
1621  // 2D graphs are named objects in a THashList.
1622  // We must update the hashlist if we change the name
1623  if (fDirectory) fDirectory->Remove(this);
1624  fName = name;
1625  if (fDirectory) fDirectory->Append(this);
1626 }
1627 
1628 
1629 ////////////////////////////////////////////////////////////////////////////////
1630 /// Change the name and title of this 2D graph
1631 ///
1632 
1633 void TGraph2D::SetNameTitle(const char *name, const char *title)
1635  // 2D graphs are named objects in a THashList.
1636  // We must update the hashlist if we change the name
1637  if (fDirectory) fDirectory->Remove(this);
1638  fName = name;
1639  SetTitle(title);
1640  if (fDirectory) fDirectory->Append(this);
1641 }
1642 
1643 
1644 ////////////////////////////////////////////////////////////////////////////////
1645 /// Sets the number of bins along X used to draw the function
1646 
1647 void TGraph2D::SetNpx(Int_t npx)
1649  if (npx < 4) {
1650  Warning("SetNpx", "Number of points must be >4 && < 500, fNpx set to 4");
1651  fNpx = 4;
1652  } else if (npx > 500) {
1653  Warning("SetNpx", "Number of points must be >4 && < 500, fNpx set to 500");
1654  fNpx = 500;
1655  } else {
1656  fNpx = npx;
1657  }
1658  if (fHistogram) {
1659  delete fHistogram;
1660  fHistogram = 0;
1661  }
1662 }
1663 
1664 
1665 ////////////////////////////////////////////////////////////////////////////////
1666 /// Sets the number of bins along Y used to draw the function
1667 
1668 void TGraph2D::SetNpy(Int_t npy)
1670  if (npy < 4) {
1671  Warning("SetNpy", "Number of points must be >4 && < 500, fNpy set to 4");
1672  fNpy = 4;
1673  } else if (npy > 500) {
1674  Warning("SetNpy", "Number of points must be >4 && < 500, fNpy set to 500");
1675  fNpy = 500;
1676  } else {
1677  fNpy = npy;
1678  }
1679  if (fHistogram) {
1680  delete fHistogram;
1681  fHistogram = 0;
1682  }
1683 }
1684 
1685 
1686 ////////////////////////////////////////////////////////////////////////////////
1687 /// Sets point number n.
1688 /// If n is greater than the current size, the arrays are automatically
1689 /// extended.
1690 
1693  if (n < 0) return;
1694 
1695  if (!fX || !fY || !fZ || n >= fSize) {
1696  // re-allocate the object
1697  Int_t newN = TMath::Max(2 * fSize, n + 1);
1698  Double_t *savex = new Double_t [newN];
1699  Double_t *savey = new Double_t [newN];
1700  Double_t *savez = new Double_t [newN];
1701  if (fX && fSize) {
1702  memcpy(savex, fX, fSize * sizeof(Double_t));
1703  memset(&savex[fSize], 0, (newN - fSize)*sizeof(Double_t));
1704  delete [] fX;
1705  }
1706  if (fY && fSize) {
1707  memcpy(savey, fY, fSize * sizeof(Double_t));
1708  memset(&savey[fSize], 0, (newN - fSize)*sizeof(Double_t));
1709  delete [] fY;
1710  }
1711  if (fZ && fSize) {
1712  memcpy(savez, fZ, fSize * sizeof(Double_t));
1713  memset(&savez[fSize], 0, (newN - fSize)*sizeof(Double_t));
1714  delete [] fZ;
1715  }
1716  fX = savex;
1717  fY = savey;
1718  fZ = savez;
1719  fSize = newN;
1720  }
1721  fX[n] = x;
1722  fY[n] = y;
1723  fZ[n] = z;
1724  fNpoints = TMath::Max(fNpoints, n + 1);
1725 }
1726 
1727 
1728 ////////////////////////////////////////////////////////////////////////////////
1729 /// Sets graph title
1730 
1731 void TGraph2D::SetTitle(const char* title)
1733  fTitle = title;
1734  if (fHistogram) fHistogram->SetTitle(title);
1735 }
1736 
1737 
1738 ////////////////////////////////////////////////////////////////////////////////
1739 /// Stream a class object
1740 
1741 void TGraph2D::Streamer(TBuffer &b)
1742 {
1743  if (b.IsReading()) {
1744  UInt_t R__s, R__c;
1745  Version_t R__v = b.ReadVersion(&R__s, &R__c);
1746  b.ReadClassBuffer(TGraph2D::Class(), this, R__v, R__s, R__c);
1747 
1749  } else {
1750  b.WriteClassBuffer(TGraph2D::Class(), this);
1751  }
1752 }
TString fTitle
Definition: TNamed.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Int_t fMaxIter
Definition: TGraph2D.h:57
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:49
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point px,py to a graph.
Definition: TGraph2D.cxx:672
Bool_t IsReading() const
Definition: TBuffer.h:83
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3125
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
Definition: TH1.cxx:5538
void SetMarginBinsContent(Double_t z=0.)
float xmin
Definition: THbookFile.cxx:93
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:405
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
Definition: TGraph2D.cxx:1037
void SetMaxIter(Int_t n=100000)
Defines the number of triangles tested for a Delaunay triangle (number of iterations) before abandoni...
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
Definition: TGraph2D.cxx:657
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:444
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1019
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:399
virtual void Draw(Option_t *option="")
Specific drawing options can be used to paint a TGraph2D:
Definition: TGraph2D.cxx:704
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:160
short Version_t
Definition: RtypesCore.h:61
Bool_t fUserHisto
Definition: TGraph2D.h:76
Double_t * fX
Real size of fX, fY and fZ.
Definition: TGraph2D.h:59
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Definition: TH1.cxx:4099
TLine * line
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
float ymin
Definition: THbookFile.cxx:93
Double_t QuietNaN()
Definition: TMath.h:622
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
Int_t fNpx
Definition: TGraph2D.h:55
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:157
TH1 * h
Definition: legend2.C:5
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
Definition: TGraph2D.cxx:1566
Double_t GetXmax() const
Returns the X maximum.
Definition: TGraph2D.cxx:1197
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Definition: TGraph2D.cxx:533
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition: TString.cxx:1835
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual void Set(Int_t n)
Set number of points in the 2D graph.
Definition: TGraph2D.cxx:1517
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:400
#define gROOT
Definition: TROOT.h:364
Int_t LoadPlugin()
Load the plugin library for this handler.
TList * fFunctions
Definition: TGraph2D.h:66
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the TGraphDelaunay convex hull ie: the bins in...
Definition: TGraph2D.cxx:1585
Basic string class.
Definition: TString.h:137
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition: TH1.cxx:700
Double_t GetZmin() const
Returns the Z minimum.
Definition: TGraph2D.cxx:1252
TVirtualHistPainter * fPainter
Pointer to directory holding this 2D graph.
Definition: TGraph2D.h:70
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:44
Double_t GetYmax() const
Returns the Y maximum.
Definition: TGraph2D.cxx:1219
static std::string format(double x, double y, int digits, int width)
TObject * fDelaunay
2D histogram of z values linearly interpolated on the triangles
Definition: TGraph2D.h:68
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="")
Fits this graph with function with name fname Predefined functions such as gaus, expo and poln are au...
Definition: TGraph2D.cxx:757
const char * Class
Definition: TXMLSetup.cxx:64
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:41
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:739
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:497
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition: TH1.cxx:1218
if object in a list can be deleted
Definition: TObject.h:56
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
Definition: TGraph2D.cxx:1554
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:165
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:37
virtual Double_t GetXmaxE() const
Definition: TGraph2D.h:140
Marker Attributes class.
Definition: TAttMarker.h:24
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:40
Double_t GetXmin() const
Definition: TAxis.h:139
Fill Area Attributes class.
Definition: TAttFill.h:24
Double_t x[n]
Definition: legend1.C:17
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
Definition: TGraph2D.cxx:724
Int_t fNpy
Definition: TGraph2D.h:56
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2335
virtual void SetTitle(const char *title="")
Sets graph title.
Definition: TGraph2D.cxx:1732
TDirectory * fDirectory
Pointer to Delaunay interpolator object.
Definition: TGraph2D.h:69
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition: TAttLine.cxx:260
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Double_t GetXmin() const
Returns the X minimum.
Definition: TGraph2D.cxx:1208
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the convex hull ie: the bins in the margin...
Int_t fSize
Definition: TGraph2D.h:58
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
Definition: TGraph2D.cxx:624
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:43
TString & Append(const char *cs)
Definition: TString.h:492
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:38
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition: TAttMarker.cxx:229
TH1F * h1
Definition: legend1.C:5
Double_t fMaximum
Definition: TGraph2D.h:63
void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: TGraph2D.cxx:1598
A doubly linked list.
Definition: TList.h:47
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1009
void Paint(Option_t *option="")
Paints this 2D graph with its current attributes.
Definition: TGraph2D.cxx:1301
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 SetName(const char *name)
Changes the name of this 2D graph.
Definition: TGraph2D.cxx:1620
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:46
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TH1.cxx:3021
virtual Double_t GetYminE() const
Definition: TGraph2D.h:143
virtual TList * GetContourList(Double_t contour) const =0
float ymax
Definition: THbookFile.cxx:93
void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: TGraph2D.cxx:1609
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:455
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
Class to manage histogram axis.
Definition: TAxis.h:36
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
SVector< double, 2 > v
Definition: Dict.h:5
if object ctor succeeded but object should not be used
Definition: TObject.h:63
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:42
virtual void SetDirectory(TDirectory *dir)
By default when an 2D graph is created, it is added to the list of 2D graph objects in the current di...
Definition: TGraph2D.cxx:1533
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Saves primitive as a C++ statement(s) on output stream out.
Definition: TGraph2D.cxx:1471
Long_t ExecPlugin(int nargs, const T &... params)
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Definition: TGraph2D.cxx:980
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:33
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
Double_t Interpolate(Double_t x, Double_t y)
Finds the z value at the position (x,y) thanks to the Delaunay interpolation.
Definition: TGraph2D.cxx:1264
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition: TAttFill.cxx:232
TMarker * m
Definition: textangle.C:8
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
Ssiz_t Length() const
Definition: TString.h:390
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
Definition: TDirectory.cxx:153
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:45
Double_t fMinimum
Definition: TGraph2D.h:62
TAxis * GetYaxis()
Definition: TH1.h:325
float xmax
Definition: THbookFile.cxx:93
don&#39;t draw stats box
Definition: TH1.h:172
A 2-Dim function with parameters.
Definition: TF2.h:33
tomato 1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:618
TString fName
Definition: TNamed.h:36
Int_t fNpoints
Definition: TGraph2D.h:54
virtual ~TGraph2D()
TGraph2D destructor.
Definition: TGraph2D.cxx:524
if object destructor must call RecursiveRemove()
Definition: TObject.h:57
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:46
#define Printf
Definition: TGeoToOCC.h:18
TH2D * fHistogram
Definition: TGraph2D.h:67
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
Definition: TGraph2D.cxx:1436
Double_t GetZmax() const
Returns the Z maximum.
Definition: TGraph2D.cxx:1241
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:39
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
Definition: TGraph2D.cxx:733
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Double_t fZout
Definition: TGraph2D.h:65
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
#define ClassImp(name)
Definition: Rtypes.h:279
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition: DataRange.h:34
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
Definition: TGraph2D.cxx:1692
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:44
virtual Double_t GetYmaxE() const
Definition: TGraph2D.h:142
Double_t y[n]
Definition: legend1.C:17
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:35
TGraphDelaunay2D generates a Delaunay triangulation of a TGraph2D.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
The TH1 histogram class.
Definition: TH1.h:80
virtual Double_t GetEntries() const
Return the current number of entries.
Definition: TH1.cxx:4053
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
Definition: THist.hxx:307
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:48
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:999
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Definition: HFitImpl.cxx:678
TAxis * GetZaxis()
Definition: TH1.h:326
TH1 * Project(Option_t *option="x") const
Projects a 2-d graph into 1 or 2-d histograms depending on the option parameter option may contain a ...
Definition: TGraph2D.cxx:1349
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
TGraph2D()
Graph2D default constructor.
Definition: TGraph2D.cxx:207
Double_t * fZ
Definition: TGraph2D.h:61
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition: TGraph2D.cxx:921
TAxis * GetXaxis() const
Get x axis of the graph.
Definition: TGraph2D.cxx:945
void Build(Int_t n)
Pointer to histogram painter.
Definition: TGraph2D.cxx:577
virtual void Add(TObject *obj)
Definition: TList.h:81
double f2(const double *x)
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
void MakeZombie()
Definition: TObject.h:47
Double_t GetYmin() const
Returns the Y minimum.
Definition: TGraph2D.cxx:1230
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
Definition: TGraph2D.cxx:1669
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 NULL
Definition: Rtypes.h:82
#define snprintf
Definition: civetweb.c:822
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
Definition: THist.hxx:301
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH2.h:90
virtual void Browse(TBrowser *)
Browse.
Definition: TGraph2D.cxx:614
#define gPad
Definition: TVirtualPad.h:289
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1965
TAxis * GetZaxis() const
Get z axis of the graph.
Definition: TGraph2D.cxx:967
virtual Double_t GetXminE() const
Definition: TGraph2D.h:141
virtual void SetEntries(Double_t n)
Definition: TH1.h:387
Double_t Atof() const
Return floating-point value contained in string.
Definition: TString.cxx:2031
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1807
#define gDirectory
Definition: TDirectory.h:221
void ResetBit(UInt_t f)
Definition: TObject.h:156
virtual void SetTitle(const char *title)
Change (i.e.
Definition: TH1.cxx:6027
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
Definition: HFitImpl.cxx:943
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1244
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:36
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
Definition: TGraph2D.cxx:1648
virtual Int_t GetNbinsX() const
Definition: TH1.h:301
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:36
Double_t fMargin
Definition: TGraph2D.h:64
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:50
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:416
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
Definition: TGraph2D.cxx:1634
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:292
TList * GetListOfFunctions() const
Definition: TH1.h:248
Double_t GetXmax() const
Definition: TAxis.h:140
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:24
gr SetName("gr")
char name[80]
Definition: TGX11.cxx:109
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911
TAxis * GetXaxis()
Definition: TH1.h:324
TGraphDelaunay generates a Delaunay triangulation of a TGraph2D.
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:52
virtual Int_t GetNbinsY() const
Definition: TH1.h:302
Double_t * fY
Definition: TGraph2D.h:60
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition: TH1.cxx:8173
tomato 2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:296
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph2D.cxx:956
const char * Data() const
Definition: TString.h:349
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:709