Logo ROOT   6.10/09
Reference Guide
TGraph.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun, Olivier Couet 12/12/94
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 <string.h>
13 
14 #include "Riostream.h"
15 #include "TROOT.h"
16 #include "TEnv.h"
17 #include "TGraph.h"
18 #include "TH1.h"
19 #include "TF1.h"
20 #include "TStyle.h"
21 #include "TMath.h"
22 #include "TFrame.h"
23 #include "TVector.h"
24 #include "TVectorD.h"
25 #include "Foption.h"
26 #include "TRandom.h"
27 #include "TSpline.h"
28 #include "TVirtualFitter.h"
29 #include "TVirtualPad.h"
30 #include "TVirtualGraphPainter.h"
31 #include "TBrowser.h"
32 #include "TClass.h"
33 #include "TSystem.h"
34 #include "TPluginManager.h"
35 #include <stdlib.h>
36 #include <string>
37 #include <cassert>
38 
39 #include "HFitInterface.h"
40 #include "Fit/DataRange.h"
41 #include "Math/MinimizerOptions.h"
42 
43 extern void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b);
44 
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 /** \class TGraph
50  \ingroup Hist
51 A Graph is a graphics object made of two arrays X and Y with npoints each.
52 The TGraph painting is performed thanks to the TGraphPainter
53 class. All details about the various painting options are given in this class.
54 
55 #### Notes
56 
57  - Unlike histogram or tree (or even TGraph2D), TGraph objects
58  are not automatically attached to the current TFile, in order to keep the
59  management and size of the TGraph as small as possible.
60  - The TGraph constructors do not have the TGraph title and name as parameters.
61  A TGraph has the default title and name "Graph". To change the default title
62  and name `SetTitle` and `SetName` should be called on the TGraph after its creation.
63  TGraph was a light weight object to start with, like TPolyline or TPolyMarker.
64  That’s why it did not have any title and name parameters in the constructors.
65 
66 The picture below gives an example:
67 
68 Begin_Macro(source)
69 {
70  TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
71  Double_t x[100], y[100];
72  Int_t n = 20;
73  for (Int_t i=0;i<n;i++) {
74  x[i] = i*0.1;
75  y[i] = 10*sin(x[i]+0.2);
76  }
77  TGraph* gr = new TGraph(n,x,y);
78  gr->Draw("AC*");
79 }
80 End_Macro
81 */
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Graph default constructor.
85 
87 {
88  fNpoints = -1; //will be reset to 0 in CtorAllocate
89  if (!CtorAllocate()) return;
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Constructor with only the number of points set
94 /// the arrays x and y will be set later
95 
97  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
98 {
99  fNpoints = n;
100  if (!CtorAllocate()) return;
101  FillZero(0, fNpoints);
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Graph normal constructor with ints.
106 
107 TGraph::TGraph(Int_t n, const Int_t *x, const Int_t *y)
108  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
109 {
110  if (!x || !y) {
111  fNpoints = 0;
112  } else {
113  fNpoints = n;
114  }
115  if (!CtorAllocate()) return;
116  for (Int_t i = 0; i < n; i++) {
117  fX[i] = (Double_t)x[i];
118  fY[i] = (Double_t)y[i];
119  }
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// Graph normal constructor with floats.
124 
126  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
127 {
128  if (!x || !y) {
129  fNpoints = 0;
130  } else {
131  fNpoints = n;
132  }
133  if (!CtorAllocate()) return;
134  for (Int_t i = 0; i < n; i++) {
135  fX[i] = x[i];
136  fY[i] = y[i];
137  }
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Graph normal constructor with doubles.
142 
144  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
145 {
146  if (!x || !y) {
147  fNpoints = 0;
148  } else {
149  fNpoints = n;
150  }
151  if (!CtorAllocate()) return;
152  n = fNpoints * sizeof(Double_t);
153  memcpy(fX, x, n);
154  memcpy(fY, y, n);
155 }
156 
157 ////////////////////////////////////////////////////////////////////////////////
158 /// Copy constructor for this graph
159 
161  : TNamed(gr), TAttLine(gr), TAttFill(gr), TAttMarker(gr)
162 {
163  fNpoints = gr.fNpoints;
164  fMaxSize = gr.fMaxSize;
165  if (gr.fFunctions) fFunctions = (TList*)gr.fFunctions->Clone();
166  else fFunctions = new TList;
167  if (gr.fHistogram) fHistogram = (TH1F*)gr.fHistogram->Clone();
168  else fHistogram = 0;
169  fMinimum = gr.fMinimum;
170  fMaximum = gr.fMaximum;
171  if (!fMaxSize) {
172  fX = fY = 0;
173  return;
174  } else {
175  fX = new Double_t[fMaxSize];
176  fY = new Double_t[fMaxSize];
177  }
178 
179  Int_t n = gr.GetN() * sizeof(Double_t);
180  memcpy(fX, gr.fX, n);
181  memcpy(fY, gr.fY, n);
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 /// Equal operator for this graph
186 
188 {
189  if (this != &gr) {
190  TNamed::operator=(gr);
194 
195  fNpoints = gr.fNpoints;
196  fMaxSize = gr.fMaxSize;
197 
198  // delete list of functions and their contents before copying it
199  if (fFunctions) {
200  // delete previous lists of functions
201  if (!fFunctions->IsEmpty()) {
203  // use TList::Remove to take into account the case the same object is
204  // added multiple times in the list
205  TObject *obj;
206  while ((obj = fFunctions->First())) {
207  while (fFunctions->Remove(obj)) { }
208  delete obj;
209  }
210  }
211  delete fFunctions;
212  }
213 
214  if (gr.fFunctions) fFunctions = (TList*)gr.fFunctions->Clone();
215  else fFunctions = new TList;
216 
217  if (fHistogram) delete fHistogram;
218  if (gr.fHistogram) fHistogram = new TH1F(*(gr.fHistogram));
219  else fHistogram = 0;
220 
221  fMinimum = gr.fMinimum;
222  fMaximum = gr.fMaximum;
223  if (fX) delete [] fX;
224  if (fY) delete [] fY;
225  if (!fMaxSize) {
226  fX = fY = 0;
227  return *this;
228  } else {
229  fX = new Double_t[fMaxSize];
230  fY = new Double_t[fMaxSize];
231  }
232 
233  Int_t n = gr.GetN() * sizeof(Double_t);
234  if (n > 0) {
235  memcpy(fX, gr.fX, n);
236  memcpy(fY, gr.fY, n);
237  }
238  }
239  return *this;
240 }
241 
242 ////////////////////////////////////////////////////////////////////////////////
243 /// Graph constructor with two vectors of floats in input
244 /// A graph is build with the X coordinates taken from vx and Y coord from vy
245 /// The number of points in the graph is the minimum of number of points
246 /// in vx and vy.
247 
248 TGraph::TGraph(const TVectorF &vx, const TVectorF &vy)
249  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
250 {
251  fNpoints = TMath::Min(vx.GetNrows(), vy.GetNrows());
252  if (!CtorAllocate()) return;
253  Int_t ivxlow = vx.GetLwb();
254  Int_t ivylow = vy.GetLwb();
255  for (Int_t i = 0; i < fNpoints; i++) {
256  fX[i] = vx(i + ivxlow);
257  fY[i] = vy(i + ivylow);
258  }
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 /// Graph constructor with two vectors of doubles in input
263 /// A graph is build with the X coordinates taken from vx and Y coord from vy
264 /// The number of points in the graph is the minimum of number of points
265 /// in vx and vy.
266 
267 TGraph::TGraph(const TVectorD &vx, const TVectorD &vy)
268  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
269 {
270  fNpoints = TMath::Min(vx.GetNrows(), vy.GetNrows());
271  if (!CtorAllocate()) return;
272  Int_t ivxlow = vx.GetLwb();
273  Int_t ivylow = vy.GetLwb();
274  for (Int_t i = 0; i < fNpoints; i++) {
275  fX[i] = vx(i + ivxlow);
276  fY[i] = vy(i + ivylow);
277  }
278 }
279 
280 ////////////////////////////////////////////////////////////////////////////////
281 /// Graph constructor importing its parameters from the TH1 object passed as argument
282 
284  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
285 {
286  if (!h) {
287  Error("TGraph", "Pointer to histogram is null");
288  fNpoints = 0;
289  return;
290  }
291  if (h->GetDimension() != 1) {
292  Error("TGraph", "Histogram must be 1-D; h %s is %d-D", h->GetName(), h->GetDimension());
293  fNpoints = 0;
294  } else {
295  fNpoints = ((TH1*)h)->GetXaxis()->GetNbins();
296  }
297 
298  if (!CtorAllocate()) return;
299 
300  TAxis *xaxis = ((TH1*)h)->GetXaxis();
301  for (Int_t i = 0; i < fNpoints; i++) {
302  fX[i] = xaxis->GetBinCenter(i + 1);
303  fY[i] = h->GetBinContent(i + 1);
304  }
305  h->TAttLine::Copy(*this);
306  h->TAttFill::Copy(*this);
307  h->TAttMarker::Copy(*this);
308 
309  std::string gname = "Graph_from_" + std::string(h->GetName());
310  SetName(gname.c_str());
311  SetTitle(h->GetTitle());
312 }
313 
314 ////////////////////////////////////////////////////////////////////////////////
315 /// Graph constructor importing its parameters from the TF1 object passed as argument
316 /// - if option =="" (default), a TGraph is created with points computed
317 /// at the fNpx points of f.
318 /// - if option =="d", a TGraph is created with points computed with the derivatives
319 /// at the fNpx points of f.
320 /// - if option =="i", a TGraph is created with points computed with the integral
321 /// at the fNpx points of f.
322 /// - if option =="I", a TGraph is created with points computed with the integral
323 /// at the fNpx+1 points of f and the integral is normalized to 1.
324 
325 TGraph::TGraph(const TF1 *f, Option_t *option)
326  : TNamed("Graph", "Graph"), TAttLine(), TAttFill(1, 1001), TAttMarker()
327 {
328  char coption = ' ';
329  if (!f) {
330  Error("TGraph", "Pointer to function is null");
331  fNpoints = 0;
332  } else {
333  fNpoints = f->GetNpx();
334  if (option) coption = *option;
335  if (coption == 'i' || coption == 'I') fNpoints++;
336  }
337  if (!CtorAllocate()) return;
338 
339  Double_t xmin = f->GetXmin();
340  Double_t xmax = f->GetXmax();
341  Double_t dx = (xmax - xmin) / fNpoints;
342  Double_t integ = 0;
343  Int_t i;
344  for (i = 0; i < fNpoints; i++) {
345  if (coption == 'i' || coption == 'I') {
346  fX[i] = xmin + i * dx;
347  if (i == 0) fY[i] = 0;
348  else fY[i] = integ + ((TF1*)f)->Integral(fX[i] - dx, fX[i]);
349  integ = fY[i];
350  } else if (coption == 'd' || coption == 'D') {
351  fX[i] = xmin + (i + 0.5) * dx;
352  fY[i] = ((TF1*)f)->Derivative(fX[i]);
353  } else {
354  fX[i] = xmin + (i + 0.5) * dx;
355  fY[i] = ((TF1*)f)->Eval(fX[i]);
356  }
357  }
358  if (integ != 0 && coption == 'I') {
359  for (i = 1; i < fNpoints; i++) fY[i] /= integ;
360  }
361 
362  f->TAttLine::Copy(*this);
363  f->TAttFill::Copy(*this);
364  f->TAttMarker::Copy(*this);
365 
366  SetName(f->GetName());
367  SetTitle(f->GetTitle());
368 }
369 
370 ////////////////////////////////////////////////////////////////////////////////
371 /// Graph constructor reading input from filename.
372 /// filename is assumed to contain at least two columns of numbers.
373 /// the string format is by default "%%lg %%lg".
374 /// this is a standard c formatting for scanf. If columns of numbers should be
375 /// skipped, a "%*lg" or "%*s" for each column can be added,
376 /// e.g. "%%lg %%*lg %%lg" would read x-values from the first and y-values from
377 /// the third column.
378 /// For files separated by a specific delimiter different from ' ' and '\t' (e.g. ';' in csv files)
379 /// you can avoid using %*s to bypass this delimiter by explicitly specify the "option" argument,
380 /// e.g. option=" \t,;" for columns of figures separated by any of these characters (' ', '\t', ',', ';')
381 /// used once (e.g. "1;1") or in a combined way (" 1;,;; 1").
382 /// Note in that case, the instantiation is about 2 times slower.
383 
384 TGraph::TGraph(const char *filename, const char *format, Option_t *option)
385  : TNamed("Graph", filename), TAttLine(), TAttFill(1, 1001), TAttMarker()
386 {
387  Double_t x, y;
388  TString fname = filename;
389  gSystem->ExpandPathName(fname);
390 
391  std::ifstream infile(fname.Data());
392  if (!infile.good()) {
393  MakeZombie();
394  Error("TGraph", "Cannot open file: %s, TGraph is Zombie", filename);
395  fNpoints = 0;
396  return;
397  } else {
398  fNpoints = 100; //initial number of points
399  }
400  if (!CtorAllocate()) return;
401  std::string line;
402  Int_t np = 0;
403 
404  // No delimiters specified (standard constructor).
405  if (strcmp(option, "") == 0) {
406 
407  while (std::getline(infile, line, '\n')) {
408  if (2 != sscanf(line.c_str(), format, &x, &y)) {
409  continue; //skip empty and ill-formed lines
410  }
411  SetPoint(np, x, y);
412  np++;
413  }
414  Set(np);
415 
416  // A delimiter has been specified in "option"
417  } else {
418 
419  // Checking format and creating its boolean counterpart
420  TString format_ = TString(format) ;
421  format_.ReplaceAll(" ", "") ;
422  format_.ReplaceAll("\t", "") ;
423  format_.ReplaceAll("lg", "") ;
424  format_.ReplaceAll("s", "") ;
425  format_.ReplaceAll("%*", "0") ;
426  format_.ReplaceAll("%", "1") ;
427  if (!format_.IsDigit()) {
428  Error("TGraph", "Incorrect input format! Allowed formats are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
429  return;
430  }
431  Int_t ntokens = format_.Length() ;
432  if (ntokens < 2) {
433  Error("TGraph", "Incorrect input format! Only %d tag(s) in format whereas 2 \"%%lg\" tags are expected!", ntokens);
434  return;
435  }
436  Int_t ntokensToBeSaved = 0 ;
437  Bool_t * isTokenToBeSaved = new Bool_t [ntokens] ;
438  for (Int_t idx = 0; idx < ntokens; idx++) {
439  isTokenToBeSaved[idx] = TString::Format("%c", format_[idx]).Atoi() ; //atoi(&format_[idx]) does not work for some reason...
440  if (isTokenToBeSaved[idx] == 1) {
441  ntokensToBeSaved++ ;
442  }
443  }
444  if (ntokens >= 2 && ntokensToBeSaved != 2) { //first condition not to repeat the previous error message
445  Error("TGraph", "Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2 and only 2 are expected!", ntokensToBeSaved);
446  delete [] isTokenToBeSaved ;
447  return;
448  }
449 
450  // Initializing loop variables
451  Bool_t isLineToBeSkipped = kFALSE ; //empty and ill-formed lines
452  char * token = NULL ;
453  TString token_str = "" ;
454  Int_t token_idx = 0 ;
455  Double_t * value = new Double_t [2] ; //x,y buffers
456  Int_t value_idx = 0 ;
457 
458  // Looping
459  while (std::getline(infile, line, '\n')) {
460  if (line != "") {
461  if (line[line.size() - 1] == char(13)) { // removing DOS CR character
462  line.erase(line.end() - 1, line.end()) ;
463  }
464  token = strtok(const_cast<char*>(line.c_str()), option) ;
465  while (token != NULL && value_idx < 2) {
466  if (isTokenToBeSaved[token_idx]) {
467  token_str = TString(token) ;
468  token_str.ReplaceAll("\t", "") ;
469  if (!token_str.IsFloat()) {
470  isLineToBeSkipped = kTRUE ;
471  break ;
472  } else {
473  value[value_idx] = token_str.Atof() ;
474  value_idx++ ;
475  }
476  }
477  token = strtok(NULL, option) ; //next token
478  token_idx++ ;
479  }
480  if (!isLineToBeSkipped && value_idx == 2) {
481  x = value[0] ;
482  y = value[1] ;
483  SetPoint(np, x, y) ;
484  np++ ;
485  }
486  }
487  isLineToBeSkipped = kFALSE ;
488  token = NULL ;
489  token_idx = 0 ;
490  value_idx = 0 ;
491  }
492  Set(np) ;
493 
494  // Cleaning
495  delete [] isTokenToBeSaved ;
496  delete [] value ;
497  delete token ;
498  }
499  infile.close();
500 }
501 
502 ////////////////////////////////////////////////////////////////////////////////
503 /// Graph default destructor.
504 
506 {
507  delete [] fX;
508  delete [] fY;
509  if (fFunctions) {
511  //special logic to support the case where the same object is
512  //added multiple times in fFunctions.
513  //This case happens when the same object is added with different
514  //drawing modes
515  TObject *obj;
516  while ((obj = fFunctions->First())) {
517  while (fFunctions->Remove(obj)) { }
518  delete obj;
519  }
520  delete fFunctions;
521  fFunctions = 0; //to avoid accessing a deleted object in RecursiveRemove
522  }
523  delete fHistogram;
524 }
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// Allocate arrays.
528 
530 {
531  if (arraySize < 0) {
532  arraySize = 0;
533  }
534  Double_t **newarrays = new Double_t*[Narrays];
535  if (!arraySize) {
536  for (Int_t i = 0; i < Narrays; ++i)
537  newarrays[i] = 0;
538  } else {
539  for (Int_t i = 0; i < Narrays; ++i)
540  newarrays[i] = new Double_t[arraySize];
541  }
542  fMaxSize = arraySize;
543  return newarrays;
544 }
545 
546 ////////////////////////////////////////////////////////////////////////////////
547 /// Apply function f to all the data points
548 /// f may be a 1-D function TF1 or 2-d function TF2
549 /// The Y values of the graph are replaced by the new values computed
550 /// using the function
551 
553 {
555 
556  for (Int_t i = 0; i < fNpoints; i++) {
557  fY[i] = f->Eval(fX[i], fY[i]);
558  }
559  if (gPad) gPad->Modified();
560 }
561 
562 ////////////////////////////////////////////////////////////////////////////////
563 /// Browse
564 
566 {
567  TString opt = gEnv->GetValue("TGraph.BrowseOption", "");
568  if (opt.IsNull()) {
569  opt = b ? b->GetDrawOption() : "alp";
570  opt = (opt == "") ? "alp" : opt.Data();
571  }
572  Draw(opt.Data());
573  gPad->Update();
574 }
575 
576 ////////////////////////////////////////////////////////////////////////////////
577 /// Return the chisquare of this graph with respect to f1.
578 /// The chisquare is computed as the sum of the quantity below at each point:
579 /// \f[
580 /// \frac{(y-f1(x))^{2}}{ey^{2}+(\frac{1}{2}(exl+exh)f1'(x))^{2}}
581 /// \f]
582 /// where x and y are the graph point coordinates and f1'(x) is the derivative of function f1(x).
583 /// This method to approximate the uncertainty in y because of the errors in x, is called
584 /// "effective variance" method.
585 /// In case of a pure TGraph, the denominator is 1.
586 /// In case of a TGraphErrors or TGraphAsymmErrors the errors are taken
587 /// into account.
588 /// By default the range of the graph is used whatever function range.
589 /// Use option "R" to use the function range
590 
592 {
593  if (!func) {
594  Error("Chisquare","Function pointer is Null - return -1");
595  return -1;
596  }
597 
598  TString opt(option); opt.ToUpper();
599  bool useRange = opt.Contains("R");
600 
601  return ROOT::Fit::Chisquare(*this, *func,useRange);
602 }
603 
604 ////////////////////////////////////////////////////////////////////////////////
605 /// Return kTRUE if point number "left"'s argument (angle with respect to positive
606 /// x-axis) is bigger than that of point number "right". Can be used by Sort.
607 
609 {
610  Double_t xl, yl, xr, yr;
611  gr->GetPoint(left, xl, yl);
612  gr->GetPoint(right, xr, yr);
613  return (TMath::ATan2(yl, xl) > TMath::ATan2(yr, xr));
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 /// Return kTRUE if fX[left] > fX[right]. Can be used by Sort.
618 
620 {
621  return gr->fX[left] > gr->fX[right];
622 }
623 
624 ////////////////////////////////////////////////////////////////////////////////
625 /// Return kTRUE if fY[left] > fY[right]. Can be used by Sort.
626 
628 {
629  return gr->fY[left] > gr->fY[right];
630 }
631 
632 ////////////////////////////////////////////////////////////////////////////////
633 /// Return kTRUE if point number "left"'s distance to origin is bigger than
634 /// that of point number "right". Can be used by Sort.
635 
637 {
638  return gr->fX[left] * gr->fX[left] + gr->fY[left] * gr->fY[left]
639  > gr->fX[right] * gr->fX[right] + gr->fY[right] * gr->fY[right];
640 }
641 
642 ////////////////////////////////////////////////////////////////////////////////
643 /// Compute the x/y range of the points in this graph
644 
646 {
647  if (fNpoints <= 0) {
648  xmin = xmax = ymin = ymax = 0;
649  return;
650  }
651  xmin = xmax = fX[0];
652  ymin = ymax = fY[0];
653 
654  Double_t xminl = 0; // Positive minimum. Used in case of log scale along X axis.
655  Double_t yminl = 0; // Positive minimum. Used in case of log scale along Y axis.
656 
657  for (Int_t i = 1; i < fNpoints; i++) {
658  if (fX[i] < xmin) xmin = fX[i];
659  if (fX[i] > xmax) xmax = fX[i];
660  if (fY[i] < ymin) ymin = fY[i];
661  if (fY[i] > ymax) ymax = fY[i];
662  if (ymin>0 && (yminl==0 || ymin<yminl)) yminl = ymin;
663  if (xmin>0 && (xminl==0 || xmin<xminl)) xminl = xmin;
664  }
665 
666  if (gPad && gPad->GetLogy() && yminl>0) ymin = yminl;
667  if (gPad && gPad->GetLogx() && xminl>0) xmin = xminl;
668 }
669 
670 ////////////////////////////////////////////////////////////////////////////////
671 /// Copy points from fX and fY to arrays[0] and arrays[1]
672 /// or to fX and fY if arrays == 0 and ibegin != iend.
673 /// If newarrays is non null, replace fX, fY with pointers from newarrays[0,1].
674 /// Delete newarrays, old fX and fY
675 
676 void TGraph::CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend,
677  Int_t obegin)
678 {
679  CopyPoints(newarrays, ibegin, iend, obegin);
680  if (newarrays) {
681  delete[] fX;
682  fX = newarrays[0];
683  delete[] fY;
684  fY = newarrays[1];
685  delete[] newarrays;
686  }
687 }
688 
689 ////////////////////////////////////////////////////////////////////////////////
690 /// Copy points from fX and fY to arrays[0] and arrays[1]
691 /// or to fX and fY if arrays == 0 and ibegin != iend.
692 
694  Int_t obegin)
695 {
696  if (ibegin < 0 || iend <= ibegin || obegin < 0) { // Error;
697  return kFALSE;
698  }
699  if (!arrays && ibegin == obegin) { // No copying is needed
700  return kFALSE;
701  }
702  Int_t n = (iend - ibegin) * sizeof(Double_t);
703  if (arrays) {
704  memmove(&arrays[0][obegin], &fX[ibegin], n);
705  memmove(&arrays[1][obegin], &fY[ibegin], n);
706  } else {
707  memmove(&fX[obegin], &fX[ibegin], n);
708  memmove(&fY[obegin], &fY[ibegin], n);
709  }
710  return kTRUE;
711 }
712 
713 ////////////////////////////////////////////////////////////////////////////////
714 /// In constructors set fNpoints than call this method.
715 /// Return kFALSE if the graph will contain no points.
716 ///Note: This function should be called only from the constructor
717 /// since it does not delete previously existing arrays
718 
720 {
721  fHistogram = 0;
722  fMaximum = -1111;
723  fMinimum = -1111;
725  fFunctions = new TList;
726  if (fNpoints <= 0) {
727  fNpoints = 0;
728  fMaxSize = 0;
729  fX = 0;
730  fY = 0;
731  return kFALSE;
732  } else {
733  fMaxSize = fNpoints;
734  fX = new Double_t[fMaxSize];
735  fY = new Double_t[fMaxSize];
736  }
737  return kTRUE;
738 }
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 /// Draw this graph with its current attributes.
742 ///
743 /// The options to draw a graph are described in TGraphPainter class.
744 
745 void TGraph::Draw(Option_t *option)
746 {
747  TString opt = option;
748  opt.ToLower();
749 
750  if (opt.Contains("same")) {
751  opt.ReplaceAll("same", "");
752  }
753 
754  // in case of option *, set marker style to 3 (star) and replace
755  // * option by option P.
756  Ssiz_t pos;
757  if ((pos = opt.Index("*")) != kNPOS) {
758  SetMarkerStyle(3);
759  opt.Replace(pos, 1, "p");
760  }
761 
762  // If no option is specified, it is defined as "alp" in case there
763  // no current pad or if the current pad as no axis defined.
764  if (!strlen(option)) {
765  if (gPad) {
766  if (!gPad->GetListOfPrimitives()->FindObject("TFrame")) opt = "alp";
767  } else {
768  opt = "alp";
769  }
770  }
771 
772  if (gPad) {
773  if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
774  if (opt.Contains("a")) gPad->Clear();
775  }
776 
777  AppendPad(opt);
778 
779  gPad->IncrementPaletteColor(1, opt);
780 
781 }
782 
783 ////////////////////////////////////////////////////////////////////////////////
784 /// Compute distance from point px,py to a graph.
785 ///
786 /// Compute the closest distance of approach from point px,py to this line.
787 /// The distance is computed in pixels units.
788 
790 {
792  if (painter) return painter->DistancetoPrimitiveHelper(this, px, py);
793  else return 0;
794 }
795 
796 ////////////////////////////////////////////////////////////////////////////////
797 /// Draw this graph with new attributes.
798 
799 void TGraph::DrawGraph(Int_t n, const Int_t *x, const Int_t *y, Option_t *option)
800 {
801  TGraph *newgraph = new TGraph(n, x, y);
802  TAttLine::Copy(*newgraph);
803  TAttFill::Copy(*newgraph);
804  TAttMarker::Copy(*newgraph);
805  newgraph->SetBit(kCanDelete);
806  newgraph->AppendPad(option);
807 }
808 
809 ////////////////////////////////////////////////////////////////////////////////
810 /// Draw this graph with new attributes.
811 
812 void TGraph::DrawGraph(Int_t n, const Float_t *x, const Float_t *y, Option_t *option)
813 {
814  TGraph *newgraph = new TGraph(n, x, y);
815  TAttLine::Copy(*newgraph);
816  TAttFill::Copy(*newgraph);
817  TAttMarker::Copy(*newgraph);
818  newgraph->SetBit(kCanDelete);
819  newgraph->AppendPad(option);
820 }
821 
822 ////////////////////////////////////////////////////////////////////////////////
823 /// Draw this graph with new attributes.
824 
825 void TGraph::DrawGraph(Int_t n, const Double_t *x, const Double_t *y, Option_t *option)
826 {
827  const Double_t *xx = x;
828  const Double_t *yy = y;
829  if (!xx) xx = fX;
830  if (!yy) yy = fY;
831  TGraph *newgraph = new TGraph(n, xx, yy);
832  TAttLine::Copy(*newgraph);
833  TAttFill::Copy(*newgraph);
834  TAttMarker::Copy(*newgraph);
835  newgraph->SetBit(kCanDelete);
836  newgraph->AppendPad(option);
837 }
838 
839 ////////////////////////////////////////////////////////////////////////////////
840 /// Display a panel with all graph drawing options.
841 
843 {
845  if (painter) painter->DrawPanelHelper(this);
846 }
847 
848 ////////////////////////////////////////////////////////////////////////////////
849 /// Interpolate points in this graph at x using a TSpline.
850 ///
851 /// - if spline==0 and option="" a linear interpolation between the two points
852 /// close to x is computed. If x is outside the graph range, a linear
853 /// extrapolation is computed.
854 /// - if spline==0 and option="S" a TSpline3 object is created using this graph
855 /// and the interpolated value from the spline is returned.
856 /// the internally created spline is deleted on return.
857 /// - if spline is specified, it is used to return the interpolated value.
858 ///
859 /// If the points are sorted in X a binary search is used (significantly faster)
860 /// One needs to set the bit TGraph::SetBit(TGraph::kIsSortedX) before calling
861 /// TGraph::Eval to indicate that the graph is sorted in X.
862 
863 Double_t TGraph::Eval(Double_t x, TSpline *spline, Option_t *option) const
864 {
865 
866  if (spline) {
867  //spline interpolation using the input spline
868  return spline->Eval(x);
869  }
870 
871  if (fNpoints == 0) return 0;
872  if (fNpoints == 1) return fY[0];
873 
874  if (option && *option) {
875  TString opt = option;
876  opt.ToLower();
877  // create a TSpline every time when using option "s" and no spline pointer is given
878  if (opt.Contains("s")) {
879 
880  // points must be sorted before using a TSpline
881  std::vector<Double_t> xsort(fNpoints);
882  std::vector<Double_t> ysort(fNpoints);
883  std::vector<Int_t> indxsort(fNpoints);
884  TMath::Sort(fNpoints, fX, &indxsort[0], false);
885  for (Int_t i = 0; i < fNpoints; ++i) {
886  xsort[i] = fX[ indxsort[i] ];
887  ysort[i] = fY[ indxsort[i] ];
888  }
889 
890  // spline interpolation creating a new spline
891  TSpline3 s("", &xsort[0], &ysort[0], fNpoints);
892  Double_t result = s.Eval(x);
893  return result;
894  }
895  }
896  //linear interpolation
897  //In case x is < fX[0] or > fX[fNpoints-1] return the extrapolated point
898 
899  //find points in graph around x assuming points are not sorted
900  // (if point are sorted use a binary search)
901  Int_t low = -1;
902  Int_t up = -1;
903  if (TestBit(TGraph::kIsSortedX) ) {
904  low = TMath::BinarySearch(fNpoints, fX, x);
905  if (low == -1) {
906  // use first two points for doing an extrapolation
907  low = 0;
908  }
909  if (fX[low] == x) return fY[low];
910  if (low == fNpoints-1) low--; // for extrapolating
911  up = low+1;
912  }
913  else {
914  // case TGraph is not sorted
915 
916  // find neighbours simply looping all points
917  // and find also the 2 adjacent points: (low2 < low < x < up < up2 )
918  // needed in case x is outside the graph ascissa interval
919  Int_t low2 = -1;
920  Int_t up2 = -1;
921 
922  for (Int_t i = 0; i < fNpoints; ++i) {
923  if (fX[i] < x) {
924  if (low == -1 || fX[i] > fX[low]) {
925  low2 = low;
926  low = i;
927  } else if (low2 == -1) low2 = i;
928  } else if (fX[i] > x) {
929  if (up == -1 || fX[i] < fX[up]) {
930  up2 = up;
931  up = i;
932  } else if (up2 == -1) up2 = i;
933  } else // case x == fX[i]
934  return fY[i]; // no interpolation needed
935  }
936 
937  // treat cases when x is outside graph min max abscissa
938  if (up == -1) {
939  up = low;
940  low = low2;
941  }
942  if (low == -1) {
943  low = up;
944  up = up2;
945  }
946  }
947  // do now the linear interpolation
948  assert(low != -1 && up != -1);
949 
950  if (fX[low] == fX[up]) return fY[low];
951  Double_t yn = fY[up] + (x - fX[up]) * (fY[low] - fY[up]) / (fX[low] - fX[up]);
952  return yn;
953 }
954 
955 ////////////////////////////////////////////////////////////////////////////////
956 /// Execute action corresponding to one event.
957 ///
958 /// This member function is called when a graph is clicked with the locator
959 ///
960 /// If Left button clicked on one of the line end points, this point
961 /// follows the cursor until button is released.
962 ///
963 /// if Middle button clicked, the line is moved parallel to itself
964 /// until the button is released.
965 
967 {
969  if (painter) painter->ExecuteEventHelper(this, event, px, py);
970 }
971 
972 ////////////////////////////////////////////////////////////////////////////////
973 /// If array sizes <= newsize, expand storage to 2*newsize.
974 
975 void TGraph::Expand(Int_t newsize)
976 {
977  Double_t **ps = ExpandAndCopy(newsize, fNpoints);
978  CopyAndRelease(ps, 0, 0, 0);
979 }
980 
981 ////////////////////////////////////////////////////////////////////////////////
982 /// If graph capacity is less than newsize points then make array sizes
983 /// equal to least multiple of step to contain newsize points.
984 /// Returns kTRUE if size was altered
985 
986 void TGraph::Expand(Int_t newsize, Int_t step)
987 {
988  if (newsize <= fMaxSize) {
989  return;
990  }
991  Double_t **ps = Allocate(step * (newsize / step + (newsize % step ? 1 : 0)));
992  CopyAndRelease(ps, 0, fNpoints, 0);
993 }
994 
995 ////////////////////////////////////////////////////////////////////////////////
996 /// if size > fMaxSize allocate new arrays of 2*size points and copy iend first
997 /// points.
998 /// Return pointer to new arrays.
999 
1001 {
1002  if (size <= fMaxSize) {
1003  return 0;
1004  }
1005  Double_t **newarrays = Allocate(2 * size);
1006  CopyPoints(newarrays, 0, iend, 0);
1007  return newarrays;
1008 }
1009 
1010 ////////////////////////////////////////////////////////////////////////////////
1011 /// Set zero values for point arrays in the range [begin, end)
1012 /// Should be redefined in descendant classes
1013 
1015 {
1016  memset(fX + begin, 0, (end - begin)*sizeof(Double_t));
1017  memset(fY + begin, 0, (end - begin)*sizeof(Double_t));
1018 }
1019 
1020 ////////////////////////////////////////////////////////////////////////////////
1021 /// Search object named name in the list of functions
1022 
1023 TObject *TGraph::FindObject(const char *name) const
1024 {
1025  if (fFunctions) return fFunctions->FindObject(name);
1026  return 0;
1027 }
1028 
1029 ////////////////////////////////////////////////////////////////////////////////
1030 /// Search object obj in the list of functions
1031 
1033 {
1034  if (fFunctions) return fFunctions->FindObject(obj);
1035  return 0;
1036 }
1037 
1038 ////////////////////////////////////////////////////////////////////////////////
1039 /// Fit this graph with function with name fname.
1040 ///
1041 /// interface to TGraph::Fit(TF1 *f1...
1042 ///
1043 /// fname is the name of an already predefined function created by TF1 or TF2
1044 /// Predefined functions such as gaus, expo and poln are automatically
1045 /// created by ROOT.
1046 ///
1047 /// fname can also be a formula, accepted by the linear fitter (linear parts divided
1048 /// by "++" sign), for example "x++sin(x)" for fitting "[0]*x+[1]*sin(x)"
1049 
1051 {
1052  char *linear;
1053  linear = (char*) strstr(fname, "++");
1054  TF1 *f1 = 0;
1055  if (linear)
1056  f1 = new TF1(fname, fname, xmin, xmax);
1057  else {
1058  f1 = (TF1*)gROOT->GetFunction(fname);
1059  if (!f1) {
1060  Printf("Unknown function: %s", fname);
1061  return -1;
1062  }
1063  }
1064  return Fit(f1, option, "", xmin, xmax);
1065 }
1066 
1067 ////////////////////////////////////////////////////////////////////////////////
1068 /// Fit this graph with function f1.
1069 ///
1070 /// f1 is an already predefined function created by TF1.
1071 /// Predefined functions such as gaus, expo and poln are automatically
1072 /// created by ROOT.
1073 ///
1074 /// The list of fit options is given in parameter option.
1075 ///
1076 /// option | description
1077 /// -------|------------
1078 /// "W" | Set all weights to 1; ignore error bars
1079 /// "U" | Use a User specified fitting algorithm (via SetFCN)
1080 /// "Q" | Quiet mode (minimum printing)
1081 /// "V" | Verbose mode (default is between Q and V)
1082 /// "E" | Perform better Errors estimation using Minos technique
1083 /// "B" | User defined parameter settings are used for predefined functions like "gaus", "expo", "poln", "landau". Use this option when you want to fix one or more parameters for these functions.
1084 /// "M" | More. Improve fit results. It uses the IMPROVE command of TMinuit (see TMinuit::mnimpr). This algorithm attempts to improve the found local minimum by searching for a better one.
1085 /// "R" | Use the Range specified in the function range
1086 /// "N" | Do not store the graphics function, do not draw
1087 /// "0" | Do not plot the result of the fit. By default the fitted function is drawn unless the option "N" above is specified.
1088 /// "+" | Add this new fitted function to the list of fitted functions (by default, any previous function is deleted)
1089 /// "C" | In case of linear fitting, do not calculate the chisquare (saves time)
1090 /// "F" | If fitting a polN, use the minuit fitter
1091 /// "EX0" | When fitting a TGraphErrors or TGraphAsymErrors do not consider errors in the coordinate
1092 /// "ROB" | In case of linear fitting, compute the LTS regression coefficients (robust (resistant) regression), using the default fraction of good points "ROB=0.x" - compute the LTS regression coefficients, using 0.x as a fraction of good points
1093 /// "S" | The result of the fit is returned in the TFitResultPtr (see below Access to the Fit Result)
1094 ///
1095 /// When the fit is drawn (by default), the parameter goption may be used
1096 /// to specify a list of graphics options. See TGraphPainter for a complete
1097 /// list of these options.
1098 ///
1099 /// In order to use the Range option, one must first create a function
1100 /// with the expression to be fitted. For example, if your graph
1101 /// has a defined range between -4 and 4 and you want to fit a gaussian
1102 /// only in the interval 1 to 3, you can do:
1103 ///
1104 /// TF1 *f1 = new TF1("f1","gaus",1,3);
1105 /// graph->Fit("f1","R");
1106 ///
1107 /// Who is calling this function:
1108 ///
1109 /// Note that this function is called when calling TGraphErrors::Fit
1110 /// or TGraphAsymmErrors::Fit ot TGraphBentErrors::Fit
1111 /// See the discussion below on error calculation.
1112 ///
1113 /// ### Linear fitting:
1114 /// When the fitting function is linear (contains the "++" sign) or the fitting
1115 /// function is a polynomial, a linear fitter is initialised.
1116 /// To create a linear function, use the following syntax: linear parts
1117 /// separated by "++" sign.
1118 /// Example: to fit the parameters of "[0]*x + [1]*sin(x)", create a
1119 /// TF1 *f1=new TF1("f1", "x++sin(x)", xmin, xmax);
1120 /// For such a TF1 you don't have to set the initial conditions.
1121 /// Going via the linear fitter for functions, linear in parameters, gives a
1122 /// considerable advantage in speed.
1123 ///
1124 /// ### Setting initial conditions:
1125 ///
1126 /// Parameters must be initialized before invoking the Fit function.
1127 /// The setting of the parameter initial values is automatic for the
1128 /// predefined functions : poln, expo, gaus, landau. One can however disable
1129 /// this automatic computation by specifying the option "B".
1130 /// You can specify boundary limits for some or all parameters via
1131 ///
1132 /// f1->SetParLimits(p_number, parmin, parmax);
1133 /// If parmin>=parmax, the parameter is fixed
1134 /// Note that you are not forced to fix the limits for all parameters.
1135 /// For example, if you fit a function with 6 parameters, you can do:
1136 ///
1137 /// func->SetParameters(0,3.1,1.e-6,0.1,-8,100);
1138 /// func->SetParLimits(4,-10,-4);
1139 /// func->SetParLimits(5, 1,1);
1140 /// With this setup, parameters 0->3 can vary freely.
1141 /// Parameter 4 has boundaries [-10,-4] with initial value -8.
1142 /// Parameter 5 is fixed to 100.
1143 ///
1144 /// ### Fit range:
1145 ///
1146 /// The fit range can be specified in two ways:
1147 /// - specify rxmax > rxmin (default is rxmin=rxmax=0)
1148 /// - specify the option "R". In this case, the function will be taken
1149 /// instead of the full graph range.
1150 ///
1151 /// ### Changing the fitting function:
1152 ///
1153 /// By default a chi2 fitting function is used for fitting a TGraph.
1154 /// The function is implemented in FitUtil::EvaluateChi2.
1155 /// In case of TGraphErrors an effective chi2 is used (see below TGraphErrors fit)
1156 /// To specify a User defined fitting function, specify option "U" and
1157 /// call the following functions:
1158 ///
1159 /// TVirtualFitter::Fitter(mygraph)->SetFCN(MyFittingFunction)
1160 /// where MyFittingFunction is of type:
1161 /// extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f,
1162 /// Double_t *u, Int_t flag);
1163 ///
1164 ///
1165 /// ### TGraphErrors fit:
1166 ///
1167 /// In case of a TGraphErrors object, when x errors are present, the error along x,
1168 /// is projected along the y-direction by calculating the function at the points x-exlow and
1169 /// x+exhigh. The chisquare is then computed as the sum of the quantity below at each point:
1170 ///
1171 /// \f[
1172 /// \frac{(y-f(x))^{2}}{ey^{2}+(\frac{1}{2}(exl+exh)f'(x))^{2}}
1173 /// \f]
1174 ///
1175 /// where x and y are the point coordinates, and f'(x) is the derivative of the
1176 /// function f(x).
1177 ///
1178 /// In case the function lies below (above) the data point, ey is ey_low (ey_high).
1179 ///
1180 /// thanks to Andy Haas (haas@yahoo.com) for adding the case with TGraphAsymmErrors
1181 /// University of Washington
1182 ///
1183 /// The approach used to approximate the uncertainty in y because of the
1184 /// errors in x is to make it equal the error in x times the slope of the line.
1185 /// The improvement, compared to the first method (f(x+ exhigh) - f(x-exlow))/2
1186 /// is of (error of x)**2 order. This approach is called "effective variance method".
1187 /// This improvement has been made in version 4.00/08 by Anna Kreshuk.
1188 /// The implementation is provided in the function FitUtil::EvaluateChi2Effective
1189 ///
1190 /// NOTE:
1191 /// 1. By using the "effective variance" method a simple linear regression
1192 /// becomes a non-linear case, which takes several iterations
1193 /// instead of 0 as in the linear case.
1194 /// 2. The effective variance technique assumes that there is no correlation
1195 /// between the x and y coordinate.
1196 /// 3. The standard chi2 (least square) method without error in the coordinates (x) can
1197 /// be forced by using option "EX0"
1198 /// 4. The linear fitter doesn't take into account the errors in x. When fitting a
1199 /// TGraphErrors with a linear functions the errors in x will not be considered.
1200 /// If errors in x are important, go through minuit (use option "F" for polynomial fitting).
1201 /// 5. When fitting a TGraph (i.e. no errors associated with each point),
1202 /// a correction is applied to the errors on the parameters with the following
1203 /// formula: errorp *= sqrt(chisquare/(ndf-1))
1204 ///
1205 /// ## Access to the fit result
1206 /// The function returns a TFitResultPtr which can hold a pointer to a TFitResult object.
1207 /// By default the TFitResultPtr contains only the status of the fit which is return by an
1208 /// automatic conversion of the TFitResultPtr to an integer. One can write in this case
1209 /// directly:
1210 ///
1211 /// Int_t fitStatus = h->Fit(myFunc)
1212 ///
1213 /// If the option "S" is instead used, TFitResultPtr contains the TFitResult and behaves
1214 /// as a smart pointer to it. For example one can do:
1215 ///
1216 /// TFitResultPtr r = h->Fit(myFunc,"S");
1217 /// TMatrixDSym cov = r->GetCovarianceMatrix(); // to access the covariance matrix
1218 /// Double_t chi2 = r->Chi2(); // to retrieve the fit chi2
1219 /// Double_t par0 = r->Value(0); // retrieve the value for the parameter 0
1220 /// Double_t err0 = r->ParError(0); // retrieve the error for the parameter 0
1221 /// r->Print("V"); // print full information of fit including covariance matrix
1222 /// r->Write(); // store the result in a file
1223 ///
1224 /// The fit parameters, error and chi2 (but not covariance matrix) can be retrieved also
1225 /// from the fitted function.
1226 /// If the histogram is made persistent, the list of
1227 /// associated functions is also persistent. Given a pointer (see above)
1228 /// to an associated function myfunc, one can retrieve the function/fit
1229 /// parameters with calls such as:
1230 ///
1231 /// Double_t chi2 = myfunc->GetChisquare();
1232 /// Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
1233 /// Double_t err0 = myfunc->GetParError(0); //error on first parameter
1234 ///
1235 ///
1236 /// ### Access to the fit status
1237 /// The status of the fit can be obtained converting the TFitResultPtr to an integer
1238 /// independently if the fit option "S" is used or not:
1239 ///
1240 /// TFitResultPtr r = h->Fit(myFunc,opt);
1241 /// Int_t fitStatus = r;
1242 ///
1243 /// The fitStatus is 0 if the fit is OK (i.e. no error occurred).
1244 /// The value of the fit status code is negative in case of an error not connected with the
1245 /// minimization procedure, for example when a wrong function is used.
1246 /// Otherwise the return value is the one returned from the minimization procedure.
1247 /// When TMinuit (default case) or Minuit2 are used as minimizer the status returned is :
1248 /// fitStatus = migradResult + 10*minosResult + 100*hesseResult + 1000*improveResult.
1249 /// TMinuit will return 0 (for migrad, minos, hesse or improve) in case of success and 4 in
1250 /// case of error (see the documentation of TMinuit::mnexcm). So for example, for an error
1251 /// only in Minos but not in Migrad a fitStatus of 40 will be returned.
1252 /// Minuit2 will return also 0 in case of success and different values in migrad, minos or
1253 /// hesse depending on the error. See in this case the documentation of
1254 /// Minuit2Minimizer::Minimize for the migradResult, Minuit2Minimizer::GetMinosError for the
1255 /// minosResult and Minuit2Minimizer::Hesse for the hesseResult.
1256 /// If other minimizers are used see their specific documentation for the status code
1257 /// returned. For example in the case of Fumili, for the status returned see TFumili::Minimize.
1258 ///
1259 /// ### Associated functions:
1260 /// One or more object (typically a TF1*) can be added to the list
1261 /// of functions (fFunctions) associated with each graph.
1262 /// When TGraph::Fit is invoked, the fitted function is added to this list.
1263 /// Given a graph gr, one can retrieve an associated function
1264 /// with: TF1 *myfunc = gr->GetFunction("myfunc");
1265 ///
1266 /// If the graph is made persistent, the list of associated functions is also
1267 /// persistent. Given a pointer (see above) to an associated function myfunc,
1268 /// one can retrieve the function/fit parameters with calls such as:
1269 ///
1270 /// Double_t chi2 = myfunc->GetChisquare();
1271 /// Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
1272 /// Double_t err0 = myfunc->GetParError(0); //error on first parameter
1273 ///
1274 /// ### Fit Statistics
1275 /// You can change the statistics box to display the fit parameters with
1276 /// the TStyle::SetOptFit(mode) method. This mode has four digits.
1277 /// mode = pcev (default = 0111)
1278 ///
1279 /// v = 1; print name/values of parameters
1280 /// e = 1; print errors (if e=1, v must be 1)
1281 /// c = 1; print Chisquare/Number of degrees of freedom
1282 /// p = 1; print Probability
1283 ///
1284 /// For example: gStyle->SetOptFit(1011);
1285 /// prints the fit probability, parameter names/values, and errors.
1286 /// You can change the position of the statistics box with these lines
1287 /// (where g is a pointer to the TGraph):
1288 ///
1289 /// Root > TPaveStats *st = (TPaveStats*)g->GetListOfFunctions()->FindObject("stats")
1290 /// Root > st->SetX1NDC(newx1); //new x start position
1291 /// Root > st->SetX2NDC(newx2); //new x end position
1292 ///
1293 
1294 TFitResultPtr TGraph::Fit(TF1 *f1, Option_t *option, Option_t *goption, Axis_t rxmin, Axis_t rxmax)
1295 {
1296  Foption_t fitOption;
1297  ROOT::Fit::FitOptionsMake(ROOT::Fit::kGraph, option, fitOption);
1298  // create range and minimizer options with default values
1299  ROOT::Fit::DataRange range(rxmin, rxmax);
1300  ROOT::Math::MinimizerOptions minOption;
1301  return ROOT::Fit::FitObject(this, f1 , fitOption , minOption, goption, range);
1302 }
1303 
1304 ////////////////////////////////////////////////////////////////////////////////
1305 /// Display a GUI panel with all graph fit options.
1306 ///
1307 /// See class TFitEditor for example
1308 
1310 {
1311  if (!gPad)
1312  gROOT->MakeDefCanvas();
1313 
1314  if (!gPad) {
1315  Error("FitPanel", "Unable to create a default canvas");
1316  return;
1317  }
1318 
1319  // use plugin manager to create instance of TFitEditor
1320  TPluginHandler *handler = gROOT->GetPluginManager()->FindHandler("TFitEditor");
1321  if (handler && handler->LoadPlugin() != -1) {
1322  if (handler->ExecPlugin(2, gPad, this) == 0)
1323  Error("FitPanel", "Unable to crate the FitPanel");
1324  } else
1325  Error("FitPanel", "Unable to find the FitPanel plug-in");
1326 }
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1329 /// Return graph correlation factor
1330 
1332 {
1333  Double_t rms1 = GetRMS(1);
1334  if (rms1 == 0) return 0;
1335  Double_t rms2 = GetRMS(2);
1336  if (rms2 == 0) return 0;
1337  return GetCovariance() / rms1 / rms2;
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Return covariance of vectors x,y
1342 
1344 {
1345  if (fNpoints <= 0) return 0;
1346  Double_t sum = fNpoints, sumx = 0, sumy = 0, sumxy = 0;
1347 
1348  for (Int_t i = 0; i < fNpoints; i++) {
1349  sumx += fX[i];
1350  sumy += fY[i];
1351  sumxy += fX[i] * fY[i];
1352  }
1353  return sumxy / sum - sumx / sum * sumy / sum;
1354 }
1355 
1356 ////////////////////////////////////////////////////////////////////////////////
1357 /// Return mean value of X (axis=1) or Y (axis=2)
1358 
1360 {
1361  if (axis < 1 || axis > 2) return 0;
1362  if (fNpoints <= 0) return 0;
1363  Double_t sumx = 0;
1364  for (Int_t i = 0; i < fNpoints; i++) {
1365  if (axis == 1) sumx += fX[i];
1366  else sumx += fY[i];
1367  }
1368  return sumx / fNpoints;
1369 }
1370 
1371 ////////////////////////////////////////////////////////////////////////////////
1372 /// Return RMS of X (axis=1) or Y (axis=2)
1373 
1375 {
1376  if (axis < 1 || axis > 2) return 0;
1377  if (fNpoints <= 0) return 0;
1378  Double_t sumx = 0, sumx2 = 0;
1379  for (Int_t i = 0; i < fNpoints; i++) {
1380  if (axis == 1) {
1381  sumx += fX[i];
1382  sumx2 += fX[i] * fX[i];
1383  } else {
1384  sumx += fY[i];
1385  sumx2 += fY[i] * fY[i];
1386  }
1387  }
1388  Double_t x = sumx / fNpoints;
1389  Double_t rms2 = TMath::Abs(sumx2 / fNpoints - x * x);
1390  return TMath::Sqrt(rms2);
1391 }
1392 
1393 ////////////////////////////////////////////////////////////////////////////////
1394 /// This function is called by GraphFitChisquare.
1395 /// It always returns a negative value. Real implementation in TGraphErrors
1396 
1398 {
1399  return -1;
1400 }
1401 
1402 ////////////////////////////////////////////////////////////////////////////////
1403 /// This function is called by GraphFitChisquare.
1404 /// It always returns a negative value. Real implementation in TGraphErrors
1405 
1407 {
1408  return -1;
1409 }
1410 
1411 ////////////////////////////////////////////////////////////////////////////////
1412 /// This function is called by GraphFitChisquare.
1413 /// It always returns a negative value. Real implementation in TGraphErrors
1414 /// and TGraphAsymmErrors
1415 
1417 {
1418  return -1;
1419 }
1420 
1421 ////////////////////////////////////////////////////////////////////////////////
1422 /// This function is called by GraphFitChisquare.
1423 /// It always returns a negative value. Real implementation in TGraphErrors
1424 /// and TGraphAsymmErrors
1425 
1427 {
1428  return -1;
1429 }
1430 
1431 ////////////////////////////////////////////////////////////////////////////////
1432 /// This function is called by GraphFitChisquare.
1433 /// It always returns a negative value. Real implementation in TGraphErrors
1434 /// and TGraphAsymmErrors
1435 
1437 {
1438  return -1;
1439 }
1440 
1441 ////////////////////////////////////////////////////////////////////////////////
1442 /// This function is called by GraphFitChisquare.
1443 /// It always returns a negative value. Real implementation in TGraphErrors
1444 /// and TGraphAsymmErrors
1445 
1447 {
1448  return -1;
1449 }
1450 
1451 ////////////////////////////////////////////////////////////////////////////////
1452 /// Return pointer to function with name.
1453 ///
1454 /// Functions such as TGraph::Fit store the fitted function in the list of
1455 /// functions of this graph.
1456 
1457 TF1 *TGraph::GetFunction(const char *name) const
1458 {
1459  if (!fFunctions) return 0;
1460  return (TF1*)fFunctions->FindObject(name);
1461 }
1462 
1463 ////////////////////////////////////////////////////////////////////////////////
1464 /// Returns a pointer to the histogram used to draw the axis
1465 /// Takes into account the two following cases.
1466 /// 1. option 'A' was specified in TGraph::Draw. Return fHistogram
1467 /// 2. user had called TPad::DrawFrame. return pointer to hframe histogram
1468 
1470 {
1471  Double_t rwxmin, rwxmax, rwymin, rwymax, maximum, minimum, dx, dy;
1472  Double_t uxmin, uxmax;
1473 
1474  ComputeRange(rwxmin, rwymin, rwxmax, rwymax); //this is redefined in TGraphErrors
1475 
1476  // (if fHistogram exist) && (if the log scale is on) &&
1477  // (if the computed range minimum is > 0) && (if the fHistogram minimum is zero)
1478  // then it means fHistogram limits have been computed in linear scale
1479  // therefore they might be too strict and cut some points. In that case the
1480  // fHistogram limits should be recomputed ie: the existing fHistogram
1481  // should not be returned.
1482  TH1F *historg = 0;
1483  if (fHistogram) {
1484  if (!TestBit(kResetHisto)) {
1485  if (gPad && gPad->GetLogx()) {
1486  if (rwxmin <= 0 || fHistogram->GetXaxis()->GetXmin() != 0) return fHistogram;
1487  } else if (gPad && gPad->GetLogy()) {
1488  if (rwymin <= 0 || fHistogram->GetMinimum() != 0) return fHistogram;
1489  } else {
1490  return fHistogram;
1491  }
1492  } else {
1493  historg = fHistogram;
1494  const_cast <TGraph*>(this)->ResetBit(kResetHisto);
1495  }
1496  }
1497 
1498  if (rwxmin == rwxmax) rwxmax += 1.;
1499  if (rwymin == rwymax) rwymax += 1.;
1500  dx = 0.1 * (rwxmax - rwxmin);
1501  dy = 0.1 * (rwymax - rwymin);
1502  uxmin = rwxmin - dx;
1503  uxmax = rwxmax + dx;
1504  minimum = rwymin - dy;
1505  maximum = rwymax + dy;
1506 
1507  if (fMinimum != -1111) minimum = fMinimum;
1508  if (fMaximum != -1111) maximum = fMaximum;
1509 
1510  // the graph is created with at least as many channels as there are points
1511  // to permit zooming on the full range
1512  if (uxmin < 0 && rwxmin >= 0) {
1513  if (gPad && gPad->GetLogx()) uxmin = 0.9 * rwxmin;
1514  else uxmin = 0;
1515  }
1516  if (uxmax > 0 && rwxmax <= 0) {
1517  if (gPad && gPad->GetLogx()) uxmax = 1.1 * rwxmax;
1518  else uxmax = 0;
1519  }
1520 
1521  if (minimum < 0 && rwymin >= 0) minimum = 0.9 * rwymin;
1522 
1523  if (minimum <= 0 && gPad && gPad->GetLogy()) minimum = 0.001 * maximum;
1524  if (uxmin <= 0 && gPad && gPad->GetLogx()) {
1525  if (uxmax > 1000) uxmin = 1;
1526  else uxmin = 0.001 * uxmax;
1527  }
1528 
1529  rwxmin = uxmin;
1530  rwxmax = uxmax;
1531  Int_t npt = 100;
1532  if (fNpoints > npt) npt = fNpoints;
1533  const char *gname = GetName();
1534  if (!gname[0]) gname = "Graph";
1535  ((TGraph*)this)->fHistogram = new TH1F(gname, GetTitle(), npt, rwxmin, rwxmax);
1536  if (!fHistogram) return 0;
1537  fHistogram->SetMinimum(minimum);
1539  fHistogram->SetMaximum(maximum);
1540  fHistogram->GetYaxis()->SetLimits(minimum, maximum);
1542  // Restore the axis attributes if needed
1543  if (historg) {
1544  fHistogram->GetXaxis()->SetTitle(historg->GetXaxis()->GetTitle());
1557 
1558  fHistogram->GetYaxis()->SetTitle(historg->GetYaxis()->GetTitle());
1571  delete historg;
1572  }
1573  return fHistogram;
1574 }
1575 
1576 ////////////////////////////////////////////////////////////////////////////////
1577 /// Get x and y values for point number i.
1578 /// The function returns -1 in case of an invalid request or the point number otherwise
1579 
1581 {
1582  if (i < 0 || i >= fNpoints) return -1;
1583  if (!fX || !fY) return -1;
1584  x = fX[i];
1585  y = fY[i];
1586  return i;
1587 }
1588 
1589 ////////////////////////////////////////////////////////////////////////////////
1590 /// Get x axis of the graph.
1591 
1593 {
1594  TH1 *h = GetHistogram();
1595  if (!h) return 0;
1596  return h->GetXaxis();
1597 }
1598 
1599 ////////////////////////////////////////////////////////////////////////////////
1600 /// Get y axis of the graph.
1601 
1603 {
1604  TH1 *h = GetHistogram();
1605  if (!h) return 0;
1606  return h->GetYaxis();
1607 }
1608 
1609 ////////////////////////////////////////////////////////////////////////////////
1610 /// Compute Initial values of parameters for a gaussian.
1611 
1613 {
1614  Double_t allcha, sumx, sumx2, x, val, rms, mean;
1615  Int_t bin;
1616  const Double_t sqrtpi = 2.506628;
1617 
1618  // Compute mean value and RMS of the graph in the given range
1619  if (xmax <= xmin) {
1620  xmin = fX[0];
1621  xmax = fX[fNpoints-1];
1622  }
1623  Int_t np = 0;
1624  allcha = sumx = sumx2 = 0;
1625  for (bin = 0; bin < fNpoints; bin++) {
1626  x = fX[bin];
1627  if (x < xmin || x > xmax) continue;
1628  np++;
1629  val = fY[bin];
1630  sumx += val * x;
1631  sumx2 += val * x * x;
1632  allcha += val;
1633  }
1634  if (np == 0 || allcha == 0) return;
1635  mean = sumx / allcha;
1636  rms = TMath::Sqrt(sumx2 / allcha - mean * mean);
1637  Double_t binwidx = TMath::Abs((xmax - xmin) / np);
1638  if (rms == 0) rms = 1;
1640  TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1641  f1->SetParameter(0, binwidx * allcha / (sqrtpi * rms));
1642  f1->SetParameter(1, mean);
1643  f1->SetParameter(2, rms);
1644  f1->SetParLimits(2, 0, 10 * rms);
1645 }
1646 
1647 ////////////////////////////////////////////////////////////////////////////////
1648 /// Compute Initial values of parameters for an exponential.
1649 
1651 {
1652  Double_t constant, slope;
1653  Int_t ifail;
1654  if (xmax <= xmin) {
1655  xmin = fX[0];
1656  xmax = fX[fNpoints-1];
1657  }
1658  Int_t nchanx = fNpoints;
1659 
1660  LeastSquareLinearFit(-nchanx, constant, slope, ifail, xmin, xmax);
1661 
1663  TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1664  f1->SetParameter(0, constant);
1665  f1->SetParameter(1, slope);
1666 }
1667 
1668 ////////////////////////////////////////////////////////////////////////////////
1669 /// Compute Initial values of parameters for a polynom.
1670 
1672 {
1673  Double_t fitpar[25];
1674 
1676  TF1 *f1 = (TF1*)grFitter->GetUserFunc();
1677  Int_t npar = f1->GetNpar();
1678  if (xmax <= xmin) {
1679  xmin = fX[0];
1680  xmax = fX[fNpoints-1];
1681  }
1682 
1683  LeastSquareFit(npar, fitpar, xmin, xmax);
1684 
1685  for (Int_t i = 0; i < npar; i++) f1->SetParameter(i, fitpar[i]);
1686 }
1687 
1688 ////////////////////////////////////////////////////////////////////////////////
1689 /// Insert a new point at the mouse position
1690 
1692 {
1693  Int_t px = gPad->GetEventX();
1694  Int_t py = gPad->GetEventY();
1695 
1696  //localize point where to insert
1697  Int_t ipoint = -2;
1698  Int_t i, d = 0;
1699  // start with a small window (in case the mouse is very close to one point)
1700  for (i = 0; i < fNpoints - 1; i++) {
1701  d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
1702  if (d < 5) {
1703  ipoint = i + 1;
1704  break;
1705  }
1706  }
1707  if (ipoint == -2) {
1708  //may be we are far from one point, try again with a larger window
1709  for (i = 0; i < fNpoints - 1; i++) {
1710  d = DistancetoLine(px, py, gPad->XtoPad(fX[i]), gPad->YtoPad(fY[i]), gPad->XtoPad(fX[i+1]), gPad->YtoPad(fY[i+1]));
1711  if (d < 10) {
1712  ipoint = i + 1;
1713  break;
1714  }
1715  }
1716  }
1717  if (ipoint == -2) {
1718  //distinguish between first and last point
1719  Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[0]));
1720  Int_t dpy = py - gPad->YtoAbsPixel(gPad->XtoPad(fY[0]));
1721  if (dpx * dpx + dpy * dpy < 25) ipoint = 0;
1722  else ipoint = fNpoints;
1723  }
1724  Double_t **ps = ExpandAndCopy(fNpoints + 1, ipoint);
1725  CopyAndRelease(ps, ipoint, fNpoints++, ipoint + 1);
1726 
1727  // To avoid redefinitions in descendant classes
1728  FillZero(ipoint, ipoint + 1);
1729 
1730  fX[ipoint] = gPad->PadtoX(gPad->AbsPixeltoX(px));
1731  fY[ipoint] = gPad->PadtoY(gPad->AbsPixeltoY(py));
1732  gPad->Modified();
1733  return ipoint;
1734 }
1735 
1736 ////////////////////////////////////////////////////////////////////////////////
1737 /// Integrate the TGraph data within a given (index) range.
1738 /// Note that this function computes the area of the polygon enclosed by the points of the TGraph.
1739 /// The polygon segments, which are defined by the points of the TGraph, do not need to form a closed polygon,
1740 /// since the last polygon segment, which closes the polygon, is taken as the line connecting the last TGraph point
1741 /// with the first one. It is clear that the order of the point is essential in defining the polygon.
1742 /// Also note that the segments should not intersect.
1743 ///
1744 /// NB:
1745 /// - if last=-1 (default) last is set to the last point.
1746 /// - if (first <0) the first point (0) is taken.
1747 ///
1748 /// ### Method:
1749 ///
1750 /// There are many ways to calculate the surface of a polygon. It all depends on what kind of data
1751 /// you have to deal with. The most evident solution would be to divide the polygon in triangles and
1752 /// calculate the surface of them. But this can quickly become complicated as you will have to test
1753 /// every segments of every triangles and check if they are intersecting with a current polygon's
1754 /// segment or if it goes outside the polygon. Many calculations that would lead to many problems...
1755 ///
1756 /// ### The solution (implemented by R.Brun)
1757 /// Fortunately for us, there is a simple way to solve this problem, as long as the polygon's
1758 /// segments don't intersect.
1759 /// It takes the x coordinate of the current vertex and multiply it by the y coordinate of the next
1760 /// vertex. Then it subtracts from it the result of the y coordinate of the current vertex multiplied
1761 /// by the x coordinate of the next vertex. Then divide the result by 2 to get the surface/area.
1762 ///
1763 /// ### Sources
1764 /// - http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00462.html
1765 /// - http://stackoverflow.com/questions/451426/how-do-i-calculate-the-surface-area-of-a-2d-polygon
1766 
1768 {
1769  if (first < 0) first = 0;
1770  if (last < 0) last = fNpoints - 1;
1771  if (last >= fNpoints) last = fNpoints - 1;
1772  if (first >= last) return 0;
1773  Int_t np = last - first + 1;
1774  Double_t sum = 0.0;
1775  //for(Int_t i=first;i<=last;i++) {
1776  // Int_t j = first + (i-first+1)%np;
1777  // sum += TMath::Abs(fX[i]*fY[j]);
1778  // sum -= TMath::Abs(fY[i]*fX[j]);
1779  //}
1780  for (Int_t i = first; i <= last; i++) {
1781  Int_t j = first + (i - first + 1) % np;
1782  sum += (fY[i] + fY[j]) * (fX[j] - fX[i]);
1783  }
1784  return 0.5 * TMath::Abs(sum);
1785 }
1786 
1787 ////////////////////////////////////////////////////////////////////////////////
1788 /// Return 1 if the point (x,y) is inside the polygon defined by
1789 /// the graph vertices 0 otherwise.
1790 ///
1791 /// Algorithm:
1792 ///
1793 /// The loop is executed with the end-point coordinates of a line segment
1794 /// (X1,Y1)-(X2,Y2) and the Y-coordinate of a horizontal line.
1795 /// The counter inter is incremented if the line (X1,Y1)-(X2,Y2) intersects
1796 /// the horizontal line. In this case XINT is set to the X-coordinate of the
1797 /// intersection point. If inter is an odd number, then the point x,y is within
1798 /// the polygon.
1799 
1801 {
1802  return (Int_t)TMath::IsInside(x, y, fNpoints, fX, fY);
1803 }
1804 
1805 ////////////////////////////////////////////////////////////////////////////////
1806 /// Least squares polynomial fitting without weights.
1807 ///
1808 /// \param [in] m number of parameters
1809 /// \param [in] ma array of parameters
1810 /// \param [in] mfirst 1st point number to fit (default =0)
1811 /// \param [in] mlast last point number to fit (default=fNpoints-1)
1812 ///
1813 /// based on CERNLIB routine LSQ: Translated to C++ by Rene Brun
1814 
1816 {
1817  const Double_t zero = 0.;
1818  const Double_t one = 1.;
1819  const Int_t idim = 20;
1820 
1821  Double_t b[400] /* was [20][20] */;
1822  Int_t i, k, l, ifail;
1823  Double_t power;
1824  Double_t da[20], xk, yk;
1825  Int_t n = fNpoints;
1826  if (xmax <= xmin) {
1827  xmin = fX[0];
1828  xmax = fX[fNpoints-1];
1829  }
1830 
1831  if (m <= 2) {
1832  LeastSquareLinearFit(n, a[0], a[1], ifail, xmin, xmax);
1833  return;
1834  }
1835  if (m > idim || m > n) return;
1836  da[0] = zero;
1837  for (l = 2; l <= m; ++l) {
1838  b[l-1] = zero;
1839  b[m + l*20 - 21] = zero;
1840  da[l-1] = zero;
1841  }
1842  Int_t np = 0;
1843  for (k = 0; k < fNpoints; ++k) {
1844  xk = fX[k];
1845  if (xk < xmin || xk > xmax) continue;
1846  np++;
1847  yk = fY[k];
1848  power = one;
1849  da[0] += yk;
1850  for (l = 2; l <= m; ++l) {
1851  power *= xk;
1852  b[l-1] += power;
1853  da[l-1] += power * yk;
1854  }
1855  for (l = 2; l <= m; ++l) {
1856  power *= xk;
1857  b[m + l*20 - 21] += power;
1858  }
1859  }
1860  b[0] = Double_t(np);
1861  for (i = 3; i <= m; ++i) {
1862  for (k = i; k <= m; ++k) {
1863  b[k - 1 + (i-1)*20 - 21] = b[k + (i-2)*20 - 21];
1864  }
1865  }
1866  H1LeastSquareSeqnd(m, b, idim, ifail, 1, da);
1867 
1868  if (ifail < 0) {
1869  a[0] = fY[0];
1870  for (i = 1; i < m; ++i) a[i] = 0;
1871  return;
1872  }
1873  for (i = 0; i < m; ++i) a[i] = da[i];
1874 }
1875 
1876 ////////////////////////////////////////////////////////////////////////////////
1877 /// Least square linear fit without weights.
1878 ///
1879 /// Fit a straight line (a0 + a1*x) to the data in this graph.
1880 ///
1881 /// \param [in] ndata if ndata<0, fits the logarithm of the graph (used in InitExpo() to set
1882 /// the initial parameter values for a fit with exponential function.
1883 /// \param [in] a0 constant
1884 /// \param [in] a1 slope
1885 /// \param [in] ifail return parameter indicating the status of the fit (ifail=0, fit is OK)
1886 /// \param [in] xmin, xmax fitting range
1887 ///
1888 /// extracted from CERNLIB LLSQ: Translated to C++ by Rene Brun
1889 
1891 {
1892  Double_t xbar, ybar, x2bar;
1893  Int_t i;
1894  Double_t xybar;
1895  Double_t fn, xk, yk;
1896  Double_t det;
1897  if (xmax <= xmin) {
1898  xmin = fX[0];
1899  xmax = fX[fNpoints-1];
1900  }
1901 
1902  ifail = -2;
1903  xbar = ybar = x2bar = xybar = 0;
1904  Int_t np = 0;
1905  for (i = 0; i < fNpoints; ++i) {
1906  xk = fX[i];
1907  if (xk < xmin || xk > xmax) continue;
1908  np++;
1909  yk = fY[i];
1910  if (ndata < 0) {
1911  if (yk <= 0) yk = 1e-9;
1912  yk = TMath::Log(yk);
1913  }
1914  xbar += xk;
1915  ybar += yk;
1916  x2bar += xk * xk;
1917  xybar += xk * yk;
1918  }
1919  fn = Double_t(np);
1920  det = fn * x2bar - xbar * xbar;
1921  ifail = -1;
1922  if (det <= 0) {
1923  if (fn > 0) a0 = ybar / fn;
1924  else a0 = 0;
1925  a1 = 0;
1926  return;
1927  }
1928  ifail = 0;
1929  a0 = (x2bar * ybar - xbar * xybar) / det;
1930  a1 = (fn * xybar - xbar * ybar) / det;
1931 }
1932 
1933 ////////////////////////////////////////////////////////////////////////////////
1934 /// Draw this graph with its current attributes.
1935 
1937 {
1939  if (painter) painter->PaintHelper(this, option);
1940 }
1941 
1942 ////////////////////////////////////////////////////////////////////////////////
1943 /// Draw the (x,y) as a graph.
1944 
1945 void TGraph::PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
1946 {
1948  if (painter) painter->PaintGraph(this, npoints, x, y, chopt);
1949 }
1950 
1951 ////////////////////////////////////////////////////////////////////////////////
1952 /// Draw the (x,y) as a histogram.
1953 
1954 void TGraph::PaintGrapHist(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
1955 {
1957  if (painter) painter->PaintGrapHist(this, npoints, x, y, chopt);
1958 }
1959 
1960 ////////////////////////////////////////////////////////////////////////////////
1961 /// Draw the stats
1962 
1964 {
1966  if (painter) painter->PaintStats(this, fit);
1967 }
1968 
1969 ////////////////////////////////////////////////////////////////////////////////
1970 /// Print graph values.
1971 
1973 {
1974  for (Int_t i = 0; i < fNpoints; i++) {
1975  printf("x[%d]=%g, y[%d]=%g\n", i, fX[i], i, fY[i]);
1976  }
1977 }
1978 
1979 ////////////////////////////////////////////////////////////////////////////////
1980 /// Recursively remove object from the list of functions
1981 
1983 {
1984  if (fFunctions) {
1986  }
1987  if (fHistogram == obj) fHistogram = 0;
1988 }
1989 
1990 ////////////////////////////////////////////////////////////////////////////////
1991 /// Delete point close to the mouse position
1992 
1994 {
1995  Int_t px = gPad->GetEventX();
1996  Int_t py = gPad->GetEventY();
1997 
1998  //localize point to be deleted
1999  Int_t ipoint = -2;
2000  Int_t i;
2001  // start with a small window (in case the mouse is very close to one point)
2002  for (i = 0; i < fNpoints; i++) {
2003  Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
2004  Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
2005  if (dpx * dpx + dpy * dpy < 100) {
2006  ipoint = i;
2007  break;
2008  }
2009  }
2010  return RemovePoint(ipoint);
2011 }
2012 
2013 ////////////////////////////////////////////////////////////////////////////////
2014 /// Delete point number ipoint
2015 
2017 {
2018  if (ipoint < 0) return -1;
2019  if (ipoint >= fNpoints) return -1;
2020 
2021  Double_t **ps = ShrinkAndCopy(fNpoints - 1, ipoint);
2022  CopyAndRelease(ps, ipoint + 1, fNpoints--, ipoint);
2023  if (gPad) gPad->Modified();
2024  return ipoint;
2025 }
2026 
2027 ////////////////////////////////////////////////////////////////////////////////
2028 /// Save primitive as a C++ statement(s) on output stream out
2029 
2030 void TGraph::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2031 {
2032  char quote = '"';
2033  out << " " << std::endl;
2034  static Int_t frameNumber = 0;
2035  frameNumber++;
2036 
2037  if (fNpoints >= 1) {
2038  Int_t i;
2039  TString fXName = TString(GetName()) + Form("_fx%d",frameNumber);
2040  TString fYName = TString(GetName()) + Form("_fy%d",frameNumber);
2041  out << " Double_t " << fXName << "[" << fNpoints << "] = {" << std::endl;
2042  for (i = 0; i < fNpoints-1; i++) out << " " << fX[i] << "," << std::endl;
2043  out << " " << fX[fNpoints-1] << "};" << std::endl;
2044  out << " Double_t " << fYName << "[" << fNpoints << "] = {" << std::endl;
2045  for (i = 0; i < fNpoints-1; i++) out << " " << fY[i] << "," << std::endl;
2046  out << " " << fY[fNpoints-1] << "};" << std::endl;
2047  if (gROOT->ClassSaved(TGraph::Class())) out << " ";
2048  else out << " TGraph *";
2049  out << "graph = new TGraph(" << fNpoints << "," << fXName << "," << fYName << ");" << std::endl;
2050  } else {
2051  if (gROOT->ClassSaved(TGraph::Class())) out << " ";
2052  else out << " TGraph *";
2053  out << "graph = new TGraph();" << std::endl;
2054  }
2055 
2056  out << " graph->SetName(" << quote << GetName() << quote << ");" << std::endl;
2057  out << " graph->SetTitle(" << quote << GetTitle() << quote << ");" << std::endl;
2058 
2059  SaveFillAttributes(out, "graph", 0, 1001);
2060  SaveLineAttributes(out, "graph", 1, 1, 1);
2061  SaveMarkerAttributes(out, "graph", 1, 1, 1);
2062 
2063  if (fHistogram) {
2064  TString hname = fHistogram->GetName();
2065  hname += frameNumber;
2066  fHistogram->SetName(Form("Graph_%s", hname.Data()));
2067  fHistogram->SavePrimitive(out, "nodraw");
2068  out << " graph->SetHistogram(" << fHistogram->GetName() << ");" << std::endl;
2069  out << " " << std::endl;
2070  }
2071 
2072  // save list of functions
2073  TIter next(fFunctions);
2074  TObject *obj;
2075  while ((obj = next())) {
2076  obj->SavePrimitive(out, Form("nodraw #%d\n",++frameNumber));
2077  if (obj->InheritsFrom("TPaveStats")) {
2078  out << " graph->GetListOfFunctions()->Add(ptstats);" << std::endl;
2079  out << " ptstats->SetParent(graph->GetListOfFunctions());" << std::endl;
2080  } else {
2081  out << " graph->GetListOfFunctions()->Add("
2082  << Form("%s%d",obj->GetName(),frameNumber) << ");" << std::endl;
2083  }
2084  }
2085 
2086  const char *l;
2087  l = strstr(option, "multigraph");
2088  if (l) {
2089  out << " multigraph->Add(graph," << quote << l + 10 << quote << ");" << std::endl;
2090  return;
2091  }
2092  l = strstr(option, "th2poly");
2093  if (l) {
2094  out << " " << l + 7 << "->AddBin(graph);" << std::endl;
2095  return;
2096  }
2097  out << " graph->Draw(" << quote << option << quote << ");" << std::endl;
2098 }
2099 
2100 ////////////////////////////////////////////////////////////////////////////////
2101 /// Set number of points in the graph
2102 /// Existing coordinates are preserved
2103 /// New coordinates above fNpoints are preset to 0.
2104 
2106 {
2107  if (n < 0) n = 0;
2108  if (n == fNpoints) return;
2109  Double_t **ps = Allocate(n);
2110  CopyAndRelease(ps, 0, TMath::Min(fNpoints, n), 0);
2111  if (n > fNpoints) {
2112  FillZero(fNpoints, n, kFALSE);
2113  }
2114  fNpoints = n;
2115 }
2116 
2117 ////////////////////////////////////////////////////////////////////////////////
2118 /// Return kTRUE if kNotEditable bit is not set, kFALSE otherwise.
2119 
2121 {
2122  return TestBit(kNotEditable) ? kFALSE : kTRUE;
2123 }
2124 
2125 ////////////////////////////////////////////////////////////////////////////////
2126 /// if editable=kFALSE, the graph cannot be modified with the mouse
2127 /// by default a TGraph is editable
2128 
2130 {
2131  if (editable) ResetBit(kNotEditable);
2132  else SetBit(kNotEditable);
2133 }
2134 
2135 ////////////////////////////////////////////////////////////////////////////////
2136 /// Set the maximum of the graph.
2137 
2139 {
2140  fMaximum = maximum;
2141  GetHistogram()->SetMaximum(maximum);
2142 }
2143 
2144 ////////////////////////////////////////////////////////////////////////////////
2145 /// Set the minimum of the graph.
2146 
2148 {
2149  fMinimum = minimum;
2150  GetHistogram()->SetMinimum(minimum);
2151 }
2152 
2153 ////////////////////////////////////////////////////////////////////////////////
2154 /// Set x and y values for point number i.
2155 
2157 {
2158  if (i < 0) return;
2160 
2161  if (i >= fMaxSize) {
2162  Double_t **ps = ExpandAndCopy(i + 1, fNpoints);
2163  CopyAndRelease(ps, 0, 0, 0);
2164  }
2165  if (i >= fNpoints) {
2166  // points above i can be not initialized
2167  // set zero up to i-th point to avoid redefinition
2168  // of this method in descendant classes
2169  FillZero(fNpoints, i + 1);
2170  fNpoints = i + 1;
2171  }
2172  fX[i] = x;
2173  fY[i] = y;
2174  if (gPad) gPad->Modified();
2175 }
2176 
2177 ////////////////////////////////////////////////////////////////////////////////
2178 /// Set graph title.
2179 
2180 void TGraph::SetTitle(const char* title)
2181 {
2182  fTitle = title;
2183  if (fHistogram) fHistogram->SetTitle(title);
2184 }
2185 
2186 ////////////////////////////////////////////////////////////////////////////////
2187 /// if size*2 <= fMaxSize allocate new arrays of size points,
2188 /// copy points [0,oend).
2189 /// Return newarray (passed or new instance if it was zero
2190 /// and allocations are needed)
2191 
2193 {
2194  if (size * 2 > fMaxSize || !fMaxSize) {
2195  return 0;
2196  }
2197  Double_t **newarrays = Allocate(size);
2198  CopyPoints(newarrays, 0, oend, 0);
2199  return newarrays;
2200 }
2201 
2202 ////////////////////////////////////////////////////////////////////////////////
2203 /// Sorts the points of this TGraph using in-place quicksort (see e.g. older glibc).
2204 /// To compare two points the function parameter greaterfunc is used (see TGraph::CompareX for an
2205 /// example of such a method, which is also the default comparison function for Sort). After
2206 /// the sort, greaterfunc(this, i, j) will return kTRUE for all i>j if ascending == kTRUE, and
2207 /// kFALSE otherwise.
2208 ///
2209 /// The last two parameters are used for the recursive quick sort, stating the range to be sorted
2210 ///
2211 /// Examples:
2212 /// ~~~ {.cpp}
2213 /// // sort points along x axis
2214 /// graph->Sort();
2215 /// // sort points along their distance to origin
2216 /// graph->Sort(&TGraph::CompareRadius);
2217 ///
2218 /// Bool_t CompareErrors(const TGraph* gr, Int_t i, Int_t j) {
2219 /// const TGraphErrors* ge=(const TGraphErrors*)gr;
2220 /// return (ge->GetEY()[i]>ge->GetEY()[j]); }
2221 /// // sort using the above comparison function, largest errors first
2222 /// graph->Sort(&CompareErrors, kFALSE);
2223 /// ~~~
2224 
2225 void TGraph::Sort(Bool_t (*greaterfunc)(const TGraph*, Int_t, Int_t) /*=TGraph::CompareX()*/,
2226  Bool_t ascending /*=kTRUE*/, Int_t low /* =0 */, Int_t high /* =-1111 */)
2227 {
2228 
2229  // set the bit in case of an ascending =sort in X
2230  if (greaterfunc == TGraph::CompareX && ascending && low == 0 && high == -1111)
2232 
2233  if (high == -1111) high = GetN() - 1;
2234  // Termination condition
2235  if (high <= low) return;
2236 
2237  int left, right;
2238  left = low; // low is the pivot element
2239  right = high;
2240  while (left < right) {
2241  // move left while item < pivot
2242  while (left <= high && greaterfunc(this, left, low) != ascending)
2243  left++;
2244  // move right while item > pivot
2245  while (right > low && greaterfunc(this, right, low) == ascending)
2246  right--;
2247  if (left < right && left < high && right > low)
2248  SwapPoints(left, right);
2249  }
2250  // right is final position for the pivot
2251  if (right > low)
2252  SwapPoints(low, right);
2253  Sort(greaterfunc, ascending, low, right - 1);
2254  Sort(greaterfunc, ascending, right + 1, high);
2255 }
2256 
2257 ////////////////////////////////////////////////////////////////////////////////
2258 /// Stream an object of class TGraph.
2259 
2260 void TGraph::Streamer(TBuffer &b)
2261 {
2262  if (b.IsReading()) {
2263  UInt_t R__s, R__c;
2264  Version_t R__v = b.ReadVersion(&R__s, &R__c);
2265  if (R__v > 2) {
2266  b.ReadClassBuffer(TGraph::Class(), this, R__v, R__s, R__c);
2268  TIter next(fFunctions);
2269  TObject *obj;
2270  while ((obj = next())) {
2271  if (obj->InheritsFrom(TF1::Class())) {
2272  TF1 *f1 = (TF1*)obj;
2273  f1->SetParent(this);
2274  }
2275  }
2276  fMaxSize = fNpoints;
2277  return;
2278  }
2279  //====process old versions before automatic schema evolution
2280  TNamed::Streamer(b);
2281  TAttLine::Streamer(b);
2282  TAttFill::Streamer(b);
2283  TAttMarker::Streamer(b);
2284  b >> fNpoints;
2285  fMaxSize = fNpoints;
2286  fX = new Double_t[fNpoints];
2287  fY = new Double_t[fNpoints];
2288  if (R__v < 2) {
2289  Float_t *x = new Float_t[fNpoints];
2290  Float_t *y = new Float_t[fNpoints];
2291  b.ReadFastArray(x, fNpoints);
2292  b.ReadFastArray(y, fNpoints);
2293  for (Int_t i = 0; i < fNpoints; i++) {
2294  fX[i] = x[i];
2295  fY[i] = y[i];
2296  }
2297  delete [] y;
2298  delete [] x;
2299  } else {
2300  b.ReadFastArray(fX, fNpoints);
2301  b.ReadFastArray(fY, fNpoints);
2302  }
2303  b >> fFunctions;
2304  b >> fHistogram;
2305  if (fHistogram) fHistogram->SetDirectory(0);
2306  if (R__v < 2) {
2307  Float_t mi, ma;
2308  b >> mi;
2309  b >> ma;
2310  fMinimum = mi;
2311  fMaximum = ma;
2312  } else {
2313  b >> fMinimum;
2314  b >> fMaximum;
2315  }
2316  b.CheckByteCount(R__s, R__c, TGraph::IsA());
2317  //====end of old versions
2318 
2319  } else {
2320  b.WriteClassBuffer(TGraph::Class(), this);
2321  }
2322 }
2323 
2324 ////////////////////////////////////////////////////////////////////////////////
2325 /// Swap points.
2326 
2328 {
2329  SwapValues(fX, pos1, pos2);
2330  SwapValues(fY, pos1, pos2);
2331 }
2332 
2333 ////////////////////////////////////////////////////////////////////////////////
2334 /// Swap values.
2335 
2336 void TGraph::SwapValues(Double_t* arr, Int_t pos1, Int_t pos2)
2337 {
2338  Double_t tmp = arr[pos1];
2339  arr[pos1] = arr[pos2];
2340  arr[pos2] = tmp;
2341 }
2342 
2343 ////////////////////////////////////////////////////////////////////////////////
2344 /// Set current style settings in this graph
2345 /// This function is called when either TCanvas::UseCurrentStyle
2346 /// or TROOT::ForceStyle have been invoked.
2347 
2349 {
2350  if (gStyle->IsReading()) {
2359  } else {
2368  }
2370 
2371  TIter next(GetListOfFunctions());
2372  TObject *obj;
2373 
2374  while ((obj = next())) {
2375  obj->UseCurrentStyle();
2376  }
2377 }
2378 
2379 ////////////////////////////////////////////////////////////////////////////////
2380 /// Adds all graphs from the collection to this graph.
2381 /// Returns the total number of poins in the result or -1 in case of an error.
2382 
2384 {
2385  TIter next(li);
2386  while (TObject* o = next()) {
2387  TGraph *g = dynamic_cast<TGraph*>(o);
2388  if (!g) {
2389  Error("Merge",
2390  "Cannot merge - an object which doesn't inherit from TGraph found in the list");
2391  return -1;
2392  }
2393  DoMerge(g);
2394  }
2395  return GetN();
2396 }
2397 ////////////////////////////////////////////////////////////////////////////////
2398 /// protected function to perform the merge operation of a graph
2399 
2401 {
2402  Double_t x, y;
2403  for (Int_t i = 0 ; i < g->GetN(); i++) {
2404  g->GetPoint(i, x, y);
2405  SetPoint(GetN(), x, y);
2406  }
2407  return kTRUE;
2408 }
2409 ////////////////////////////////////////////////////////////////////////////////
2410 /// Find zero of a continuous function.
2411 /// This function finds a real zero of the continuous real
2412 /// function Y(X) in a given interval (A,B). See accompanying
2413 /// notes for details of the argument list and calling sequence
2414 
2416  , Int_t maxiterations)
2417 {
2418  static Double_t a, b, ya, ytest, y1, x1, h;
2419  static Int_t j1, it, j3, j2;
2420  Double_t yb, x2;
2421  yb = 0;
2422 
2423  // Calculate Y(X) at X=AZ.
2424  if (k <= 0) {
2425  a = AZ;
2426  b = BZ;
2427  X = a;
2428  j1 = 1;
2429  it = 1;
2430  k = j1;
2431  return;
2432  }
2433 
2434  // Test whether Y(X) is sufficiently small.
2435 
2436  if (TMath::Abs(Y) <= E2) {
2437  k = 2;
2438  return;
2439  }
2440 
2441  // Calculate Y(X) at X=BZ.
2442 
2443  if (j1 == 1) {
2444  ya = Y;
2445  X = b;
2446  j1 = 2;
2447  return;
2448  }
2449  // Test whether the signs of Y(AZ) and Y(BZ) are different.
2450  // if not, begin the binary subdivision.
2451 
2452  if (j1 != 2) goto L100;
2453  if (ya * Y < 0) goto L120;
2454  x1 = a;
2455  y1 = ya;
2456  j1 = 3;
2457  h = b - a;
2458  j2 = 1;
2459  x2 = a + 0.5 * h;
2460  j3 = 1;
2461  it++; //*-*- Check whether (maxiterations) function values have been calculated.
2462  if (it >= maxiterations) k = j1;
2463  else X = x2;
2464  return;
2465 
2466  // Test whether a bracket has been found .
2467  // If not,continue the search
2468 
2469 L100:
2470  if (j1 > 3) goto L170;
2471  if (ya*Y >= 0) {
2472  if (j3 >= j2) {
2473  h = 0.5 * h;
2474  j2 = 2 * j2;
2475  a = x1;
2476  ya = y1;
2477  x2 = a + 0.5 * h;
2478  j3 = 1;
2479  } else {
2480  a = X;
2481  ya = Y;
2482  x2 = X + h;
2483  j3++;
2484  }
2485  it++;
2486  if (it >= maxiterations) k = j1;
2487  else X = x2;
2488  return;
2489  }
2490 
2491  // The first bracket has been found.calculate the next X by the
2492  // secant method based on the bracket.
2493 
2494 L120:
2495  b = X;
2496  yb = Y;
2497  j1 = 4;
2498 L130:
2499  if (TMath::Abs(ya) > TMath::Abs(yb)) {
2500  x1 = a;
2501  y1 = ya;
2502  X = b;
2503  Y = yb;
2504  } else {
2505  x1 = b;
2506  y1 = yb;
2507  X = a;
2508  Y = ya;
2509  }
2510 
2511  // Use the secant method based on the function values y1 and Y.
2512  // check that x2 is inside the interval (a,b).
2513 
2514 L150:
2515  x2 = X - Y * (X - x1) / (Y - y1);
2516  x1 = X;
2517  y1 = Y;
2518  ytest = 0.5 * TMath::Min(TMath::Abs(ya), TMath::Abs(yb));
2519  if ((x2 - a)*(x2 - b) < 0) {
2520  it++;
2521  if (it >= maxiterations) k = j1;
2522  else X = x2;
2523  return;
2524  }
2525 
2526  // Calculate the next value of X by bisection . Check whether
2527  // the maximum accuracy has been achieved.
2528 
2529 L160:
2530  x2 = 0.5 * (a + b);
2531  ytest = 0;
2532  if ((x2 - a)*(x2 - b) >= 0) {
2533  k = 2;
2534  return;
2535  }
2536  it++;
2537  if (it >= maxiterations) k = j1;
2538  else X = x2;
2539  return;
2540 
2541 
2542  // Revise the bracket (a,b).
2543 
2544 L170:
2545  if (j1 != 4) return;
2546  if (ya * Y < 0) {
2547  b = X;
2548  yb = Y;
2549  } else {
2550  a = X;
2551  ya = Y;
2552  }
2553 
2554  // Use ytest to decide the method for the next value of X.
2555 
2556  if (ytest <= 0) goto L130;
2557  if (TMath::Abs(Y) - ytest <= 0) goto L150;
2558  goto L160;
2559 }
const int ndata
TString fTitle
Definition: TNamed.h:33
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
Definition: TGraph.cxx:1050
void PaintGrapHist(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
Draw the (x,y) as a histogram.
Definition: TGraph.cxx:1954
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TH1.cxx:6472
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:262
Int_t fNpoints
Number of points <= fMaxSize.
Definition: TGraph.h:46
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void PaintHelper(TGraph *theGraph, Option_t *option)=0
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Bool_t IsReading() const
Definition: TBuffer.h:81
virtual Double_t GetErrorYhigh(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1436
Abstract interface to a histogram painter.
static long int sum(long int i)
Definition: Factory.cxx:2162
float xmin
Definition: THbookFile.cxx:93
Double_t * fX
[fNpoints] array of X points
Definition: TGraph.h:47
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Int_t GetNpx() const
Definition: TF1.h:444
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition: TGraph.cxx:1309
virtual Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1406
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:375
double Chisquare(const TH1 &h1, TF1 &f1, bool useRange, bool usePL=false)
compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation) ...
Definition: HFitImpl.cxx:997
static Bool_t CompareRadius(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"&#39;s distance to origin is bigger than that of point number "right"...
Definition: TGraph.cxx:636
void UseCurrentStyle()
Copy current attributes from/to current style.
Definition: TH1.cxx:6699
TGraph()
Graph default constructor.
Definition: TGraph.cxx:86
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
Definition: TGraph.cxx:1457
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:154
Double_t Log(Double_t x)
Definition: TMath.h:649
virtual Double_t ** Allocate(Int_t newsize)
Definition: TGraph.h:181
short Version_t
Definition: RtypesCore.h:61
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1001
void PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
Draw the (x,y) as a graph.
Definition: TGraph.cxx:1945
TLine * line
float Float_t
Definition: RtypesCore.h:53
virtual void DrawPanelHelper(TGraph *theGraph)=0
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8053
virtual Float_t GetLabelOffset() const
Definition: TAttAxis.h:40
const char Option_t
Definition: RtypesCore.h:62
float ymin
Definition: THbookFile.cxx:93
virtual void InitPolynom(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a polynom.
Definition: TGraph.cxx:1671
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
double Axis_t
Definition: RtypesCore.h:72
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:640
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum of the graph.
Definition: TGraph.cxx:2147
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
void SetHistLineWidth(Width_t width=1)
Definition: TStyle.h:357
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
Int_t GetLwb() const
Definition: TVectorT.h:73
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:311
TH1 * h
Definition: legend2.C:5
static Bool_t CompareX(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if fX[left] > fX[right]. Can be used by Sort.
Definition: TGraph.cxx:619
Base class for spline implementation containing the Draw/Paint methods.
Definition: TSpline.h:20
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition: TString.cxx:1845
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4639
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:229
void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b)
Extracted from CERN Program library routine DSEQN.
Definition: TH1.cxx:4452
TVectorT.
Definition: TMatrixTBase.h:77
TList * GetListOfFunctions() const
Definition: TGraph.h:116
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph.cxx:1602
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1112
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:376
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
#define gROOT
Definition: TROOT.h:375
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:587
Int_t LoadPlugin()
Load the plugin library for this handler.
virtual TObject * FindObject(const char *name) const
Search object named name in the list of functions.
Definition: TGraph.cxx:1023
Basic string class.
Definition: TString.h:129
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:551
Int_t GetNrows() const
Definition: TVectorT.h:75
virtual void DrawPanel()
Display a panel with all graph drawing options.
Definition: TGraph.cxx:842
virtual void LeastSquareFit(Int_t m, Double_t *a, Double_t xmin=0, Double_t xmax=0)
Least squares polynomial fitting without weights.
Definition: TGraph.cxx:1815
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition: TAttAxis.cxx:290
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:168
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
virtual Double_t GetCovariance() const
Return covariance of vectors x,y.
Definition: TGraph.cxx:1343
TList * fFunctions
Pointer to list of functions (fits and user)
Definition: TGraph.h:49
void Copy(TAttMarker &attmarker) const
Copy this marker attributes to a new TAttMarker.
Definition: TAttMarker.cxx:209
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SetTitle(const char *title="")
Set graph title.
Definition: TGraph.cxx:2180
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
Definition: TObject.cxx:708
virtual Float_t GetLabelSize() const
Definition: TAttAxis.h:41
TH1F * fHistogram
Pointer to histogram used for drawing axis.
Definition: TGraph.h:50
#define NULL
Definition: RtypesCore.h:88
static std::string format(double x, double y, int digits, int width)
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of functions.
Definition: TGraph.cxx:1982
virtual Double_t Integral(Int_t first=0, Int_t last=-1) const
Integrate the TGraph data within a given (index) range.
Definition: TGraph.cxx:1767
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
Definition: TAxis.h:184
virtual Double_t GetErrorYlow(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1446
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
virtual void Apply(TF1 *f)
Apply function f to all the data points f may be a 1-D function TF1 or 2-d function TF2 The Y values ...
Definition: TGraph.cxx:552
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels The distance is expressed in per cent of the pad width...
Definition: TAttAxis.cxx:193
Short_t Abs(Short_t d)
Definition: TMathBase.h:108
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:745
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:501
Width_t GetHistLineWidth() const
Definition: TStyle.h:221
Class to create third splines to interpolate knots Arbitrary conditions can be introduced for first a...
Definition: TSpline.h:191
if object in a list can be deleted
Definition: TObject.h:58
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:630
virtual void SetLabelFont(Style_t font=62)
Set labels&#39; font.
Definition: TAttAxis.cxx:183
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:112
virtual Int_t Merge(TCollection *list)
Adds all graphs from the collection to this graph.
Definition: TGraph.cxx:2383
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:32
Marker Attributes class.
Definition: TAttMarker.h:19
virtual Style_t GetTitleFont() const
Definition: TAttAxis.h:46
virtual Bool_t CopyPoints(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy points from fX and fY to arrays[0] and arrays[1] or to fX and fY if arrays == 0 and ibegin != ie...
Definition: TGraph.cxx:693
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
virtual Int_t GetDimension() const
Definition: TH1.h:263
Double_t ** ShrinkAndCopy(Int_t size, Int_t iend)
if size*2 <= fMaxSize allocate new arrays of size points, copy points [0,oend).
Definition: TGraph.cxx:2192
virtual void SetParent(TObject *p=0)
Definition: TF1.h:609
Double_t GetXmin() const
Definition: TAxis.h:133
static const double x2[5]
Fill Area Attributes class.
Definition: TAttFill.h:19
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:1936
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:2345
void Class()
Definition: Class.C:29
virtual Double_t Chisquare(TF1 *f1, Option_t *option="") const
Return the chisquare of this graph with respect to f1.
Definition: TGraph.cxx:591
TGraph & operator=(const TGraph &)
Equal operator for this graph.
Definition: TGraph.cxx:187
void SetHistFillColor(Color_t color=1)
Definition: TStyle.h:353
virtual Bool_t GetTimeDisplay() const
Definition: TAxis.h:126
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:162
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:29
virtual void Sort(Bool_t(*greater)(const TGraph *, Int_t, Int_t)=&TGraph::CompareX, Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111)
Sorts the points of this TGraph using in-place quicksort (see e.g.
Definition: TGraph.cxx:2225
clip to the frame boundary
Definition: TGraph.h:70
virtual void Print(Option_t *chopt="") const
Print graph values.
Definition: TGraph.cxx:1972
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum of the graph.
Definition: TGraph.cxx:2138
void Zero(Int_t &k, Double_t AZ, Double_t BZ, Double_t E2, Double_t &X, Double_t &Y, Int_t maxiterations)
Find zero of a continuous function.
Definition: TGraph.cxx:2415
virtual Double_t GetErrorX(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1397
Double_t fMinimum
Minimum value for plotting along y.
Definition: TGraph.h:51
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
virtual Double_t Eval(Double_t x, TSpline *spline=0, Option_t *option="") const
Interpolate points in this graph at x using a TSpline.
Definition: TGraph.cxx:863
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
Style_t GetHistFillStyle() const
Definition: TStyle.h:219
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMath.h:1151
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:33
Double_t ATan2(Double_t, Double_t)
Definition: TMath.h:581
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:244
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Definition: TMath.h:1205
virtual Int_t RemovePoint()
Delete point close to the mouse position.
Definition: TGraph.cxx:1993
virtual const char * GetTimeFormat() const
Definition: TAxis.h:127
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
Bool_t GetRotateTitle() const
Definition: TAxis.h:124
virtual Int_t GetNdivisions() const
Definition: TAttAxis.h:36
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TGraph.cxx:966
A doubly linked list.
Definition: TList.h:43
virtual void Expand(Int_t newsize)
If array sizes <= newsize, expand storage to 2*newsize.
Definition: TGraph.cxx:975
Bool_t CtorAllocate()
In constructors set fNpoints than call this method.
Definition: TGraph.cxx:719
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
don&#39;t draw stats box
Definition: TH1.h:148
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TGraph.cxx:2030
float ymax
Definition: THbookFile.cxx:93
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
Definition: TF1.cxx:3267
virtual Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1426
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:42
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
Definition: TGraph.cxx:1580
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:561
bit set if graph is non editable
Definition: TGraph.h:72
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
Definition: TGraph.cxx:2327
void SetHistFillStyle(Style_t styl=0)
Definition: TStyle.h:355
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
Class to manage histogram axis.
Definition: TAxis.h:30
R__EXTERN TSystem * gSystem
Definition: TSystem.h:539
if object ctor succeeded but object should not be used
Definition: TObject.h:65
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
Long_t ExecPlugin(int nargs, const T &... params)
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:482
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:679
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:31
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
Definition: TGraph.cxx:2336
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:436
virtual Int_t DistancetoPrimitiveHelper(TGraph *theGraph, Int_t px, Int_t py)=0
Collection abstract base class.
Definition: TCollection.h:42
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
Definition: TGraph.cxx:2400
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
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:42
TMarker * m
Definition: textangle.C:8
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
char * Form(const char *fmt,...)
Ssiz_t Length() const
Definition: TString.h:388
virtual Int_t InsertPoint()
Insert a new point at the mouse position.
Definition: TGraph.cxx:1691
static TVirtualFitter * GetFitter()
static: return the current Fitter
Int_t GetN() const
Definition: TGraph.h:122
TLine * l
Definition: textangle.C:4
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
virtual Double_t Eval(Double_t x) const =0
TAxis * GetYaxis()
Definition: TH1.h:301
float xmax
Definition: THbookFile.cxx:93
Bool_t GetEditable() const
Return kTRUE if kNotEditable bit is not set, kFALSE otherwise.
Definition: TGraph.cxx:2120
virtual Double_t GetXmin() const
Definition: TF1.h:506
virtual Double_t GetRMS(Int_t axis=1) const
Return RMS of X (axis=1) or Y (axis=2)
Definition: TGraph.cxx:1374
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:204
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
TGraphErrors * gr
Definition: legend1.C:25
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title The size is expressed in per cent of the pad width.
Definition: TAttAxis.cxx:272
#define Printf
Definition: TGeoToOCC.h:18
graph is sorted in X points
Definition: TGraph.h:73
TAxis * GetXaxis() const
Get x axis of the graph.
Definition: TGraph.cxx:1592
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void SetName(const char *name)
Change the name of this histogram.
Definition: TH1.cxx:8073
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
int Ssiz_t
Definition: RtypesCore.h:63
virtual void InitGaus(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a gaussian.
Definition: TGraph.cxx:1612
Color_t GetHistFillColor() const
Definition: TStyle.h:217
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
Definition: TF1.cxx:1197
virtual Double_t GetMean(Int_t axis=1) const
Return mean value of X (axis=1) or Y (axis=2)
Definition: TGraph.cxx:1359
virtual Bool_t IsEmpty() const
Definition: TCollection.h:93
void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag By default, an exponent of the form 10^N is used when the label value are eit...
Definition: TAxis.h:223
static const double x1[5]
static TVirtualGraphPainter * GetPainter()
Static function returning a pointer to the current graph painter.
#define ClassImp(name)
Definition: Rtypes.h:336
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition: DataRange.h:34
double f(double x)
TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases...
Definition: TGraph.cxx:1469
double Double_t
Definition: RtypesCore.h:55
void SetHistLineStyle(Style_t styl=0)
Definition: TStyle.h:356
Bool_t GetCenterTitle() const
Definition: TAxis.h:115
virtual void PaintStats(TF1 *fit)
Draw the stats.
Definition: TGraph.cxx:1963
Color_t GetHistLineColor() const
Definition: TStyle.h:218
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a graph.
Definition: TGraph.cxx:789
R__EXTERN TEnv * gEnv
Definition: TEnv.h:170
Double_t y[n]
Definition: legend1.C:17
double func(double *x, double *p)
Definition: stressTF1.cxx:213
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
virtual Double_t GetXmax() const
Definition: TF1.h:510
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
Definition: TAttLine.cxx:196
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:572
The TH1 histogram class.
Definition: TH1.h:56
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual ~TGraph()
Graph default destructor.
Definition: TGraph.cxx:505
Double_t fMaximum
Maximum value for plotting along y.
Definition: TGraph.h:52
virtual Float_t GetTitleSize() const
Definition: TAttAxis.h:43
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
Double_t ** ExpandAndCopy(Int_t size, Int_t iend)
if size > fMaxSize allocate new arrays of 2*size points and copy iend first points.
Definition: TGraph.cxx:1000
Bool_t IsNull() const
Definition: TString.h:385
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Definition: HFitImpl.cxx:678
Abstract Base Class for Fitting.
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void UseCurrentStyle()
Set current style settings in this graph This function is called when either TCanvas::UseCurrentStyle...
Definition: TGraph.cxx:2348
Bool_t IsReading() const
Definition: TStyle.h:274
virtual void Browse(TBrowser *b)
Browse.
Definition: TGraph.cxx:565
virtual Int_t GetNpar() const
Definition: TF1.h:435
Style_t GetHistLineStyle() const
Definition: TStyle.h:220
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
Set zero values for point arrays in the range [begin, end) Should be redefined in descendant classes...
Definition: TGraph.cxx:1014
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2156
Double_t * fY
[fNpoints] array of Y points
Definition: TGraph.h:48
virtual void InitExpo(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for an exponential.
Definition: TGraph.cxx:1650
void RotateTitle(Bool_t rotate=kTRUE)
Rotate title by 180 degrees.
Definition: TAxis.h:193
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TList.cxx:639
virtual void LeastSquareLinearFit(Int_t n, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin=0, Double_t xmax=0)
Least square linear fit without weights.
Definition: TGraph.cxx:1890
static Bool_t CompareArg(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"&#39;s argument (angle with respect to positive x-axis) is bigger than...
Definition: TGraph.cxx:608
1-Dim function class
Definition: TF1.h:150
void MakeZombie()
Definition: TObject.h:49
Bool_t GetNoExponent() const
Definition: TAxis.h:122
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2544
TF1 * f1
Definition: legend1.C:11
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 gPad
Definition: TVirtualPad.h:284
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1975
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy points from fX and fY to arrays[0] and arrays[1] or to fX and fY if arrays == 0 and ibegin != ie...
Definition: TGraph.cxx:676
Double_t Atof() const
Return floating-point value contained in string.
Definition: TString.cxx:2041
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1817
virtual void DrawGraph(Int_t n, const Int_t *x, const Int_t *y, Option_t *option="")
Draw this graph with new attributes.
Definition: TGraph.cxx:799
double result[121]
void ResetBit(UInt_t f)
Definition: TObject.h:158
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:578
virtual void SetTitle(const char *title)
Change (i.e.
Definition: TH1.cxx:6028
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 Double_t GetCorrelationFactor() const
Return graph correlation factor.
Definition: TGraph.cxx:1331
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1250
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:31
Definition: first.py:1
Int_t fMaxSize
!Current dimension of arrays fX and fY
Definition: TGraph.h:45
Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TBrowser.h:104
virtual Int_t IsInside(Double_t x, Double_t y) const
Return 1 if the point (x,y) is inside the polygon defined by the graph vertices 0 otherwise...
Definition: TGraph.cxx:1800
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
Double_t Sqrt(Double_t x)
Definition: TMath.h:591
virtual void ExecuteEventHelper(TGraph *theGraph, Int_t event, Int_t px, Int_t py)=0
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute the x/y range of the points in this graph.
Definition: TGraph.cxx:645
virtual void PaintStats(TGraph *theGraph, TF1 *fit)=0
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
Definition: TGraph.cxx:2105
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
void SetHistLineColor(Color_t color=1)
Definition: TStyle.h:354
virtual TObject * GetUserFunc() const
Double_t GetMinimum() const
Definition: TGraph.h:142
virtual void SetEditable(Bool_t editable=kTRUE)
if editable=kFALSE, the graph cannot be modified with the mouse by default a TGraph is editable ...
Definition: TGraph.cxx:2129
const Bool_t kTRUE
Definition: RtypesCore.h:91
Double_t Eval(Double_t x) const
Eval this spline at x.
Definition: TSpline.cxx:782
Double_t ** AllocateArrays(Int_t Narrays, Int_t arraySize)
Allocate arrays.
Definition: TGraph.cxx:529
const Int_t n
Definition: legend1.C:16
virtual Double_t GetErrorXhigh(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1416
Line Attributes class.
Definition: TAttLine.h:18
virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMath.h:1093
virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
TAxis * GetXaxis()
Definition: TH1.h:300
virtual Style_t GetLabelFont() const
Definition: TAttAxis.h:39
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:200
fHistogram must be reset in GetHistogram
Definition: TGraph.h:71
static Bool_t CompareY(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if fY[left] > fY[right]. Can be used by Sort.
Definition: TGraph.cxx:627
const char * Data() const
Definition: TString.h:347
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:657