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