Logo ROOT   6.18/05
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"
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"
42
43extern 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
51A Graph is a graphics object made of two arrays X and Y with npoints each.
52The TGraph painting is performed thanks to the TGraphPainter
53class. 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
66The picture below gives an example:
67
68Begin_Macro(source)
69{
70 TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,500,300);
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}
80End_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(0, 1000), TAttMarker()
98{
99 fNpoints = n;
100 if (!CtorAllocate()) return;
101 FillZero(0, fNpoints);
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Graph normal constructor with ints.
106
108 : TNamed("Graph", "Graph"), TAttLine(), TAttFill(0, 1000), 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(0, 1000), 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(0, 1000), 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
162{
166 else fFunctions = new TList;
168 else fHistogram = 0;
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) {
194
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
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
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
248TGraph::TGraph(const TVectorF &vx, const TVectorF &vy)
249 : TNamed("Graph", "Graph"), TAttLine(), TAttFill(0, 1000), 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
267TGraph::TGraph(const TVectorD &vx, const TVectorD &vy)
268 : TNamed("Graph", "Graph"), TAttLine(), TAttFill(0, 1000), 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(0, 1000), 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
325TGraph::TGraph(const TF1 *f, Option_t *option)
326 : TNamed("Graph", "Graph"), TAttLine(), TAttFill(0, 1000), 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
384TGraph::TGraph(const char *filename, const char *format, Option_t *option)
385 : TNamed("Graph", filename), TAttLine(), TAttFill(0, 1000), 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 char *rest;
460 while (std::getline(infile, line, '\n')) {
461 if (line != "") {
462 if (line[line.size() - 1] == char(13)) { // removing DOS CR character
463 line.erase(line.end() - 1, line.end()) ;
464 }
465 //token = R__STRTOK_R(const_cast<char *>(line.c_str()), option, rest);
466 token = R__STRTOK_R(const_cast<char *>(line.c_str()), option, &rest);
467 while (token != NULL && value_idx < 2) {
468 if (isTokenToBeSaved[token_idx]) {
469 token_str = TString(token) ;
470 token_str.ReplaceAll("\t", "") ;
471 if (!token_str.IsFloat()) {
472 isLineToBeSkipped = kTRUE ;
473 break ;
474 } else {
475 value[value_idx] = token_str.Atof() ;
476 value_idx++ ;
477 }
478 }
479 token = R__STRTOK_R(NULL, option, &rest); // next token
480 token_idx++ ;
481 }
482 if (!isLineToBeSkipped && value_idx == 2) {
483 x = value[0] ;
484 y = value[1] ;
485 SetPoint(np, x, y) ;
486 np++ ;
487 }
488 }
489 isLineToBeSkipped = kFALSE ;
490 token = NULL ;
491 token_idx = 0 ;
492 value_idx = 0 ;
493 }
494 Set(np) ;
495
496 // Cleaning
497 delete [] isTokenToBeSaved ;
498 delete [] value ;
499 delete token ;
500 }
501 infile.close();
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Graph default destructor.
506
508{
509 delete [] fX;
510 delete [] fY;
511 if (fFunctions) {
513 //special logic to support the case where the same object is
514 //added multiple times in fFunctions.
515 //This case happens when the same object is added with different
516 //drawing modes
517 TObject *obj;
518 while ((obj = fFunctions->First())) {
519 while (fFunctions->Remove(obj)) { }
520 delete obj;
521 }
522 delete fFunctions;
523 fFunctions = 0; //to avoid accessing a deleted object in RecursiveRemove
524 }
525 delete fHistogram;
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Allocate arrays.
530
532{
533 if (arraySize < 0) {
534 arraySize = 0;
535 }
536 Double_t **newarrays = new Double_t*[Narrays];
537 if (!arraySize) {
538 for (Int_t i = 0; i < Narrays; ++i)
539 newarrays[i] = 0;
540 } else {
541 for (Int_t i = 0; i < Narrays; ++i)
542 newarrays[i] = new Double_t[arraySize];
543 }
544 fMaxSize = arraySize;
545 return newarrays;
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Apply function f to all the data points
550/// f may be a 1-D function TF1 or 2-d function TF2
551/// The Y values of the graph are replaced by the new values computed
552/// using the function
553
555{
557
558 for (Int_t i = 0; i < fNpoints; i++) {
559 fY[i] = f->Eval(fX[i], fY[i]);
560 }
561 if (gPad) gPad->Modified();
562}
563
564////////////////////////////////////////////////////////////////////////////////
565/// Browse
566
568{
569 TString opt = gEnv->GetValue("TGraph.BrowseOption", "");
570 if (opt.IsNull()) {
571 opt = b ? b->GetDrawOption() : "alp";
572 opt = (opt == "") ? "alp" : opt.Data();
573 }
574 Draw(opt.Data());
575 gPad->Update();
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Return the chisquare of this graph with respect to f1.
580/// The chisquare is computed as the sum of the quantity below at each point:
581/// \f[
582/// \frac{(y-f1(x))^{2}}{ey^{2}+(\frac{1}{2}(exl+exh)f1'(x))^{2}}
583/// \f]
584/// where x and y are the graph point coordinates and f1'(x) is the derivative of function f1(x).
585/// This method to approximate the uncertainty in y because of the errors in x, is called
586/// "effective variance" method.
587/// In case of a pure TGraph, the denominator is 1.
588/// In case of a TGraphErrors or TGraphAsymmErrors the errors are taken
589/// into account.
590/// By default the range of the graph is used whatever function range.
591/// Use option "R" to use the function range
592
594{
595 if (!func) {
596 Error("Chisquare","Function pointer is Null - return -1");
597 return -1;
598 }
599
600 TString opt(option); opt.ToUpper();
601 bool useRange = opt.Contains("R");
602
603 return ROOT::Fit::Chisquare(*this, *func,useRange);
604}
605
606////////////////////////////////////////////////////////////////////////////////
607/// Return kTRUE if point number "left"'s argument (angle with respect to positive
608/// x-axis) is bigger than that of point number "right". Can be used by Sort.
609
611{
612 Double_t xl, yl, xr, yr;
613 gr->GetPoint(left, xl, yl);
614 gr->GetPoint(right, xr, yr);
615 return (TMath::ATan2(yl, xl) > TMath::ATan2(yr, xr));
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Return kTRUE if fX[left] > fX[right]. Can be used by Sort.
620
622{
623 return gr->fX[left] > gr->fX[right];
624}
625
626////////////////////////////////////////////////////////////////////////////////
627/// Return kTRUE if fY[left] > fY[right]. Can be used by Sort.
628
630{
631 return gr->fY[left] > gr->fY[right];
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Return kTRUE if point number "left"'s distance to origin is bigger than
636/// that of point number "right". Can be used by Sort.
637
639{
640 return gr->fX[left] * gr->fX[left] + gr->fY[left] * gr->fY[left]
641 > gr->fX[right] * gr->fX[right] + gr->fY[right] * gr->fY[right];
642}
643
644////////////////////////////////////////////////////////////////////////////////
645/// Compute the x/y range of the points in this graph
646
648{
649 if (fNpoints <= 0) {
650 xmin = xmax = ymin = ymax = 0;
651 return;
652 }
653 xmin = xmax = fX[0];
654 ymin = ymax = fY[0];
655
656 Double_t xminl = 0; // Positive minimum. Used in case of log scale along X axis.
657 Double_t yminl = 0; // Positive minimum. Used in case of log scale along Y axis.
658
659 for (Int_t i = 1; i < fNpoints; i++) {
660 if (fX[i] < xmin) xmin = fX[i];
661 if (fX[i] > xmax) xmax = fX[i];
662 if (fY[i] < ymin) ymin = fY[i];
663 if (fY[i] > ymax) ymax = fY[i];
664 if (ymin>0 && (yminl==0 || ymin<yminl)) yminl = ymin;
665 if (xmin>0 && (xminl==0 || xmin<xminl)) xminl = xmin;
666 }
667
668 if (gPad && gPad->GetLogy() && yminl>0) ymin = yminl;
669 if (gPad && gPad->GetLogx() && xminl>0) xmin = xminl;
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Copy points from fX and fY to arrays[0] and arrays[1]
674/// or to fX and fY if arrays == 0 and ibegin != iend.
675/// If newarrays is non null, replace fX, fY with pointers from newarrays[0,1].
676/// Delete newarrays, old fX and fY
677
678void TGraph::CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend,
679 Int_t obegin)
680{
681 CopyPoints(newarrays, ibegin, iend, obegin);
682 if (newarrays) {
683 delete[] fX;
684 fX = newarrays[0];
685 delete[] fY;
686 fY = newarrays[1];
687 delete[] newarrays;
688 }
689}
690
691////////////////////////////////////////////////////////////////////////////////
692/// Copy points from fX and fY to arrays[0] and arrays[1]
693/// or to fX and fY if arrays == 0 and ibegin != iend.
694
696 Int_t obegin)
697{
698 if (ibegin < 0 || iend <= ibegin || obegin < 0) { // Error;
699 return kFALSE;
700 }
701 if (!arrays && ibegin == obegin) { // No copying is needed
702 return kFALSE;
703 }
704 Int_t n = (iend - ibegin) * sizeof(Double_t);
705 if (arrays) {
706 memmove(&arrays[0][obegin], &fX[ibegin], n);
707 memmove(&arrays[1][obegin], &fY[ibegin], n);
708 } else {
709 memmove(&fX[obegin], &fX[ibegin], n);
710 memmove(&fY[obegin], &fY[ibegin], n);
711 }
712 return kTRUE;
713}
714
715////////////////////////////////////////////////////////////////////////////////
716/// In constructors set fNpoints than call this method.
717/// Return kFALSE if the graph will contain no points.
718///Note: This function should be called only from the constructor
719/// since it does not delete previously existing arrays
720
722{
723 fHistogram = 0;
724 fMaximum = -1111;
725 fMinimum = -1111;
727 fFunctions = new TList;
728 if (fNpoints <= 0) {
729 fNpoints = 0;
730 fMaxSize = 0;
731 fX = 0;
732 fY = 0;
733 return kFALSE;
734 } else {
736 fX = new Double_t[fMaxSize];
737 fY = new Double_t[fMaxSize];
738 }
739 return kTRUE;
740}
741
742////////////////////////////////////////////////////////////////////////////////
743/// Draw this graph with its current attributes.
744///
745/// The options to draw a graph are described in TGraphPainter class.
746
748{
749 TString opt = option;
750 opt.ToLower();
751
752 if (opt.Contains("same")) {
753 opt.ReplaceAll("same", "");
754 }
755
756 // in case of option *, set marker style to 3 (star) and replace
757 // * option by option P.
758 Ssiz_t pos;
759 if ((pos = opt.Index("*")) != kNPOS) {
761 opt.Replace(pos, 1, "p");
762 }
763
764 // If no option is specified, it is defined as "alp" in case there
765 // no current pad or if the current pad as no axis defined.
766 if (!strlen(option)) {
767 if (gPad) {
768 if (!gPad->GetListOfPrimitives()->FindObject("TFrame")) opt = "alp";
769 } else {
770 opt = "alp";
771 }
772 }
773
774 if (gPad) {
775 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
776 if (opt.Contains("a")) gPad->Clear();
777 }
778
779 AppendPad(opt);
780
781 gPad->IncrementPaletteColor(1, opt);
782
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Compute distance from point px,py to a graph.
787///
788/// Compute the closest distance of approach from point px,py to this line.
789/// The distance is computed in pixels units.
790
792{
794 if (painter) return painter->DistancetoPrimitiveHelper(this, px, py);
795 else return 0;
796}
797
798////////////////////////////////////////////////////////////////////////////////
799/// Draw this graph with new attributes.
800
801void TGraph::DrawGraph(Int_t n, const Int_t *x, const Int_t *y, Option_t *option)
802{
803 TGraph *newgraph = new TGraph(n, x, y);
804 TAttLine::Copy(*newgraph);
805 TAttFill::Copy(*newgraph);
806 TAttMarker::Copy(*newgraph);
807 newgraph->SetBit(kCanDelete);
808 newgraph->AppendPad(option);
809}
810
811////////////////////////////////////////////////////////////////////////////////
812/// Draw this graph with new attributes.
813
814void TGraph::DrawGraph(Int_t n, const Float_t *x, const Float_t *y, Option_t *option)
815{
816 TGraph *newgraph = new TGraph(n, x, y);
817 TAttLine::Copy(*newgraph);
818 TAttFill::Copy(*newgraph);
819 TAttMarker::Copy(*newgraph);
820 newgraph->SetBit(kCanDelete);
821 newgraph->AppendPad(option);
822}
823
824////////////////////////////////////////////////////////////////////////////////
825/// Draw this graph with new attributes.
826
827void TGraph::DrawGraph(Int_t n, const Double_t *x, const Double_t *y, Option_t *option)
828{
829 const Double_t *xx = x;
830 const Double_t *yy = y;
831 if (!xx) xx = fX;
832 if (!yy) yy = fY;
833 TGraph *newgraph = new TGraph(n, xx, yy);
834 TAttLine::Copy(*newgraph);
835 TAttFill::Copy(*newgraph);
836 TAttMarker::Copy(*newgraph);
837 newgraph->SetBit(kCanDelete);
838 newgraph->AppendPad(option);
839}
840
841////////////////////////////////////////////////////////////////////////////////
842/// Display a panel with all graph drawing options.
843
845{
847 if (painter) painter->DrawPanelHelper(this);
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Interpolate points in this graph at x using a TSpline.
852///
853/// - if spline==0 and option="" a linear interpolation between the two points
854/// close to x is computed. If x is outside the graph range, a linear
855/// extrapolation is computed.
856/// - if spline==0 and option="S" a TSpline3 object is created using this graph
857/// and the interpolated value from the spline is returned.
858/// the internally created spline is deleted on return.
859/// - if spline is specified, it is used to return the interpolated value.
860///
861/// If the points are sorted in X a binary search is used (significantly faster)
862/// One needs to set the bit TGraph::SetBit(TGraph::kIsSortedX) before calling
863/// TGraph::Eval to indicate that the graph is sorted in X.
864
866{
867
868 if (spline) {
869 //spline interpolation using the input spline
870 return spline->Eval(x);
871 }
872
873 if (fNpoints == 0) return 0;
874 if (fNpoints == 1) return fY[0];
875
876 if (option && *option) {
877 TString opt = option;
878 opt.ToLower();
879 // create a TSpline every time when using option "s" and no spline pointer is given
880 if (opt.Contains("s")) {
881
882 // points must be sorted before using a TSpline
883 std::vector<Double_t> xsort(fNpoints);
884 std::vector<Double_t> ysort(fNpoints);
885 std::vector<Int_t> indxsort(fNpoints);
886 TMath::Sort(fNpoints, fX, &indxsort[0], false);
887 for (Int_t i = 0; i < fNpoints; ++i) {
888 xsort[i] = fX[ indxsort[i] ];
889 ysort[i] = fY[ indxsort[i] ];
890 }
891
892 // spline interpolation creating a new spline
893 TSpline3 s("", &xsort[0], &ysort[0], fNpoints);
894 Double_t result = s.Eval(x);
895 return result;
896 }
897 }
898 //linear interpolation
899 //In case x is < fX[0] or > fX[fNpoints-1] return the extrapolated point
900
901 //find points in graph around x assuming points are not sorted
902 // (if point are sorted use a binary search)
903 Int_t low = -1;
904 Int_t up = -1;
907 if (low == -1) {
908 // use first two points for doing an extrapolation
909 low = 0;
910 }
911 if (fX[low] == x) return fY[low];
912 if (low == fNpoints-1) low--; // for extrapolating
913 up = low+1;
914 }
915 else {
916 // case TGraph is not sorted
917
918 // find neighbours simply looping all points
919 // and find also the 2 adjacent points: (low2 < low < x < up < up2 )
920 // needed in case x is outside the graph ascissa interval
921 Int_t low2 = -1;
922 Int_t up2 = -1;
923
924 for (Int_t i = 0; i < fNpoints; ++i) {
925 if (fX[i] < x) {
926 if (low == -1 || fX[i] > fX[low]) {
927 low2 = low;
928 low = i;
929 } else if (low2 == -1) low2 = i;
930 } else if (fX[i] > x) {
931 if (up == -1 || fX[i] < fX[up]) {
932 up2 = up;
933 up = i;
934 } else if (up2 == -1) up2 = i;
935 } else // case x == fX[i]
936 return fY[i]; // no interpolation needed
937 }
938
939 // treat cases when x is outside graph min max abscissa
940 if (up == -1) {
941 up = low;
942 low = low2;
943 }
944 if (low == -1) {
945 low = up;
946 up = up2;
947 }
948 }
949 // do now the linear interpolation
950 assert(low != -1 && up != -1);
951
952 if (fX[low] == fX[up]) return fY[low];
953 Double_t yn = fY[up] + (x - fX[up]) * (fY[low] - fY[up]) / (fX[low] - fX[up]);
954 return yn;
955}
956
957////////////////////////////////////////////////////////////////////////////////
958/// Execute action corresponding to one event.
959///
960/// This member function is called when a graph is clicked with the locator
961///
962/// If Left button clicked on one of the line end points, this point
963/// follows the cursor until button is released.
964///
965/// if Middle button clicked, the line is moved parallel to itself
966/// until the button is released.
967
969{
971 if (painter) painter->ExecuteEventHelper(this, event, px, py);
972}
973
974////////////////////////////////////////////////////////////////////////////////
975/// If array sizes <= newsize, expand storage to 2*newsize.
976
978{
979 Double_t **ps = ExpandAndCopy(newsize, fNpoints);
980 CopyAndRelease(ps, 0, 0, 0);
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// If graph capacity is less than newsize points then make array sizes
985/// equal to least multiple of step to contain newsize points.
986
987void TGraph::Expand(Int_t newsize, Int_t step)
988{
989 if (newsize <= fMaxSize) {
990 return;
991 }
992 Double_t **ps = Allocate(step * (newsize / step + (newsize % step ? 1 : 0)));
993 CopyAndRelease(ps, 0, fNpoints, 0);
994}
995
996////////////////////////////////////////////////////////////////////////////////
997/// if size > fMaxSize allocate new arrays of 2*size points and copy iend first
998/// points.
999/// Return pointer to new arrays.
1000
1002{
1003 if (size <= fMaxSize) {
1004 return 0;
1005 }
1006 Double_t **newarrays = Allocate(2 * size);
1007 CopyPoints(newarrays, 0, iend, 0);
1008 return newarrays;
1009}
1010
1011////////////////////////////////////////////////////////////////////////////////
1012/// Set zero values for point arrays in the range [begin, end)
1013/// Should be redefined in descendant classes
1014
1016{
1017 memset(fX + begin, 0, (end - begin)*sizeof(Double_t));
1018 memset(fY + begin, 0, (end - begin)*sizeof(Double_t));
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Search object named name in the list of functions
1023
1025{
1026 if (fFunctions) return fFunctions->FindObject(name);
1027 return 0;
1028}
1029
1030////////////////////////////////////////////////////////////////////////////////
1031/// Search object obj in the list of functions
1032
1034{
1035 if (fFunctions) return fFunctions->FindObject(obj);
1036 return 0;
1037}
1038
1039////////////////////////////////////////////////////////////////////////////////
1040/// Fit this graph with function with name fname.
1041///
1042/// interface to TGraph::Fit(TF1 *f1...
1043///
1044/// fname is the name of an already predefined function created by TF1 or TF2
1045/// Predefined functions such as gaus, expo and poln are automatically
1046/// created by ROOT.
1047///
1048/// fname can also be a formula, accepted by the linear fitter (linear parts divided
1049/// by "++" sign), for example "x++sin(x)" for fitting "[0]*x+[1]*sin(x)"
1050
1052{
1053 char *linear;
1054 linear = (char*) strstr(fname, "++");
1055 if (linear) {
1056 TF1 f1(fname, fname, xmin, xmax);
1057 return Fit(&f1, option, "", xmin, xmax);
1058 }
1059 TF1 * f1 = (TF1*)gROOT->GetFunction(fname);
1060 if (!f1) {
1061 Printf("Unknown function: %s", fname);
1062 return -1;
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
1294TFitResultPtr 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);
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
1457TF1 *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 const_cast <TGraph*>(this)->ResetBit(kResetHisto);
1494 }
1495 historg = fHistogram;
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
1725
1726 InsertPointBefore(ipoint, gPad->AbsPixeltoX(px), gPad->AbsPixeltoY(py));
1727
1728 gPad->Modified();
1729 return ipoint;
1730}
1731
1732
1733////////////////////////////////////////////////////////////////////////////////
1734/// Insert a new point with coordinates (x,y) before the point number `ipoint`.
1735
1737{
1738 if (ipoint < 0) {
1739 Error("TGraph", "Inserted point index should be >= 0");
1740 return;
1741 }
1742
1743 if (ipoint > fNpoints-1) {
1744 Error("TGraph", "Inserted point index should be <= %d", fNpoints-1);
1745 return;
1746 }
1747
1748 Double_t **ps = ExpandAndCopy(fNpoints + 1, ipoint);
1749 CopyAndRelease(ps, ipoint, fNpoints++, ipoint + 1);
1750
1751 // To avoid redefinitions in descendant classes
1752 FillZero(ipoint, ipoint + 1);
1753
1754 fX[ipoint] = x;
1755 fY[ipoint] = y;
1756}
1757
1758
1759////////////////////////////////////////////////////////////////////////////////
1760/// Integrate the TGraph data within a given (index) range.
1761/// Note that this function computes the area of the polygon enclosed by the points of the TGraph.
1762/// The polygon segments, which are defined by the points of the TGraph, do not need to form a closed polygon,
1763/// since the last polygon segment, which closes the polygon, is taken as the line connecting the last TGraph point
1764/// with the first one. It is clear that the order of the point is essential in defining the polygon.
1765/// Also note that the segments should not intersect.
1766///
1767/// NB:
1768/// - if last=-1 (default) last is set to the last point.
1769/// - if (first <0) the first point (0) is taken.
1770///
1771/// ### Method:
1772///
1773/// There are many ways to calculate the surface of a polygon. It all depends on what kind of data
1774/// you have to deal with. The most evident solution would be to divide the polygon in triangles and
1775/// calculate the surface of them. But this can quickly become complicated as you will have to test
1776/// every segments of every triangles and check if they are intersecting with a current polygon's
1777/// segment or if it goes outside the polygon. Many calculations that would lead to many problems...
1778///
1779/// ### The solution (implemented by R.Brun)
1780/// Fortunately for us, there is a simple way to solve this problem, as long as the polygon's
1781/// segments don't intersect.
1782/// It takes the x coordinate of the current vertex and multiply it by the y coordinate of the next
1783/// vertex. Then it subtracts from it the result of the y coordinate of the current vertex multiplied
1784/// by the x coordinate of the next vertex. Then divide the result by 2 to get the surface/area.
1785///
1786/// ### Sources
1787/// - http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00462.html
1788/// - http://stackoverflow.com/questions/451426/how-do-i-calculate-the-surface-area-of-a-2d-polygon
1789
1791{
1792 if (first < 0) first = 0;
1793 if (last < 0) last = fNpoints - 1;
1794 if (last >= fNpoints) last = fNpoints - 1;
1795 if (first >= last) return 0;
1796 Int_t np = last - first + 1;
1797 Double_t sum = 0.0;
1798 //for(Int_t i=first;i<=last;i++) {
1799 // Int_t j = first + (i-first+1)%np;
1800 // sum += TMath::Abs(fX[i]*fY[j]);
1801 // sum -= TMath::Abs(fY[i]*fX[j]);
1802 //}
1803 for (Int_t i = first; i <= last; i++) {
1804 Int_t j = first + (i - first + 1) % np;
1805 sum += (fY[i] + fY[j]) * (fX[j] - fX[i]);
1806 }
1807 return 0.5 * TMath::Abs(sum);
1808}
1809
1810////////////////////////////////////////////////////////////////////////////////
1811/// Return 1 if the point (x,y) is inside the polygon defined by
1812/// the graph vertices 0 otherwise.
1813///
1814/// Algorithm:
1815///
1816/// The loop is executed with the end-point coordinates of a line segment
1817/// (X1,Y1)-(X2,Y2) and the Y-coordinate of a horizontal line.
1818/// The counter inter is incremented if the line (X1,Y1)-(X2,Y2) intersects
1819/// the horizontal line. In this case XINT is set to the X-coordinate of the
1820/// intersection point. If inter is an odd number, then the point x,y is within
1821/// the polygon.
1822
1824{
1825 return (Int_t)TMath::IsInside(x, y, fNpoints, fX, fY);
1826}
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Least squares polynomial fitting without weights.
1830///
1831/// \param [in] m number of parameters
1832/// \param [in] ma array of parameters
1833/// \param [in] mfirst 1st point number to fit (default =0)
1834/// \param [in] mlast last point number to fit (default=fNpoints-1)
1835///
1836/// based on CERNLIB routine LSQ: Translated to C++ by Rene Brun
1837
1839{
1840 const Double_t zero = 0.;
1841 const Double_t one = 1.;
1842 const Int_t idim = 20;
1843
1844 Double_t b[400] /* was [20][20] */;
1845 Int_t i, k, l, ifail;
1846 Double_t power;
1847 Double_t da[20], xk, yk;
1848 Int_t n = fNpoints;
1849 if (xmax <= xmin) {
1850 xmin = fX[0];
1851 xmax = fX[fNpoints-1];
1852 }
1853
1854 if (m <= 2) {
1855 LeastSquareLinearFit(n, a[0], a[1], ifail, xmin, xmax);
1856 return;
1857 }
1858 if (m > idim || m > n) return;
1859 da[0] = zero;
1860 for (l = 2; l <= m; ++l) {
1861 b[l-1] = zero;
1862 b[m + l*20 - 21] = zero;
1863 da[l-1] = zero;
1864 }
1865 Int_t np = 0;
1866 for (k = 0; k < fNpoints; ++k) {
1867 xk = fX[k];
1868 if (xk < xmin || xk > xmax) continue;
1869 np++;
1870 yk = fY[k];
1871 power = one;
1872 da[0] += yk;
1873 for (l = 2; l <= m; ++l) {
1874 power *= xk;
1875 b[l-1] += power;
1876 da[l-1] += power * yk;
1877 }
1878 for (l = 2; l <= m; ++l) {
1879 power *= xk;
1880 b[m + l*20 - 21] += power;
1881 }
1882 }
1883 b[0] = Double_t(np);
1884 for (i = 3; i <= m; ++i) {
1885 for (k = i; k <= m; ++k) {
1886 b[k - 1 + (i-1)*20 - 21] = b[k + (i-2)*20 - 21];
1887 }
1888 }
1889 H1LeastSquareSeqnd(m, b, idim, ifail, 1, da);
1890
1891 if (ifail < 0) {
1892 a[0] = fY[0];
1893 for (i = 1; i < m; ++i) a[i] = 0;
1894 return;
1895 }
1896 for (i = 0; i < m; ++i) a[i] = da[i];
1897}
1898
1899////////////////////////////////////////////////////////////////////////////////
1900/// Least square linear fit without weights.
1901///
1902/// Fit a straight line (a0 + a1*x) to the data in this graph.
1903///
1904/// \param [in] ndata if ndata<0, fits the logarithm of the graph (used in InitExpo() to set
1905/// the initial parameter values for a fit with exponential function.
1906/// \param [in] a0 constant
1907/// \param [in] a1 slope
1908/// \param [in] ifail return parameter indicating the status of the fit (ifail=0, fit is OK)
1909/// \param [in] xmin, xmax fitting range
1910///
1911/// extracted from CERNLIB LLSQ: Translated to C++ by Rene Brun
1912
1914{
1915 Double_t xbar, ybar, x2bar;
1916 Int_t i;
1917 Double_t xybar;
1918 Double_t fn, xk, yk;
1919 Double_t det;
1920 if (xmax <= xmin) {
1921 xmin = fX[0];
1922 xmax = fX[fNpoints-1];
1923 }
1924
1925 ifail = -2;
1926 xbar = ybar = x2bar = xybar = 0;
1927 Int_t np = 0;
1928 for (i = 0; i < fNpoints; ++i) {
1929 xk = fX[i];
1930 if (xk < xmin || xk > xmax) continue;
1931 np++;
1932 yk = fY[i];
1933 if (ndata < 0) {
1934 if (yk <= 0) yk = 1e-9;
1935 yk = TMath::Log(yk);
1936 }
1937 xbar += xk;
1938 ybar += yk;
1939 x2bar += xk * xk;
1940 xybar += xk * yk;
1941 }
1942 fn = Double_t(np);
1943 det = fn * x2bar - xbar * xbar;
1944 ifail = -1;
1945 if (det <= 0) {
1946 if (fn > 0) a0 = ybar / fn;
1947 else a0 = 0;
1948 a1 = 0;
1949 return;
1950 }
1951 ifail = 0;
1952 a0 = (x2bar * ybar - xbar * xybar) / det;
1953 a1 = (fn * xybar - xbar * ybar) / det;
1954}
1955
1956////////////////////////////////////////////////////////////////////////////////
1957/// Draw this graph with its current attributes.
1958
1960{
1962 if (painter) painter->PaintHelper(this, option);
1963}
1964
1965////////////////////////////////////////////////////////////////////////////////
1966/// Draw the (x,y) as a graph.
1967
1968void TGraph::PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
1969{
1971 if (painter) painter->PaintGraph(this, npoints, x, y, chopt);
1972}
1973
1974////////////////////////////////////////////////////////////////////////////////
1975/// Draw the (x,y) as a histogram.
1976
1977void TGraph::PaintGrapHist(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
1978{
1980 if (painter) painter->PaintGrapHist(this, npoints, x, y, chopt);
1981}
1982
1983////////////////////////////////////////////////////////////////////////////////
1984/// Draw the stats
1985
1987{
1989 if (painter) painter->PaintStats(this, fit);
1990}
1991
1992////////////////////////////////////////////////////////////////////////////////
1993/// Print graph values.
1994
1996{
1997 for (Int_t i = 0; i < fNpoints; i++) {
1998 printf("x[%d]=%g, y[%d]=%g\n", i, fX[i], i, fY[i]);
1999 }
2000}
2001
2002////////////////////////////////////////////////////////////////////////////////
2003/// Recursively remove object from the list of functions
2004
2006{
2007 if (fFunctions) {
2009 }
2010 if (fHistogram == obj) fHistogram = 0;
2011}
2012
2013////////////////////////////////////////////////////////////////////////////////
2014/// Delete point close to the mouse position
2015
2017{
2018 Int_t px = gPad->GetEventX();
2019 Int_t py = gPad->GetEventY();
2020
2021 //localize point to be deleted
2022 Int_t ipoint = -2;
2023 Int_t i;
2024 // start with a small window (in case the mouse is very close to one point)
2025 for (i = 0; i < fNpoints; i++) {
2026 Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
2027 Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
2028 if (dpx * dpx + dpy * dpy < 100) {
2029 ipoint = i;
2030 break;
2031 }
2032 }
2033 return RemovePoint(ipoint);
2034}
2035
2036////////////////////////////////////////////////////////////////////////////////
2037/// Delete point number ipoint
2038
2040{
2041 if (ipoint < 0) return -1;
2042 if (ipoint >= fNpoints) return -1;
2043
2044 Double_t **ps = ShrinkAndCopy(fNpoints - 1, ipoint);
2045 CopyAndRelease(ps, ipoint + 1, fNpoints--, ipoint);
2046 if (gPad) gPad->Modified();
2047 return ipoint;
2048}
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Save primitive as a C++ statement(s) on output stream out
2052
2053void TGraph::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2054{
2055 char quote = '"';
2056 out << " " << std::endl;
2057 static Int_t frameNumber = 0;
2058 frameNumber++;
2059
2060 if (fNpoints >= 1) {
2061 Int_t i;
2062 TString fXName = TString(GetName()) + Form("_fx%d",frameNumber);
2063 TString fYName = TString(GetName()) + Form("_fy%d",frameNumber);
2064 out << " Double_t " << fXName << "[" << fNpoints << "] = {" << std::endl;
2065 for (i = 0; i < fNpoints-1; i++) out << " " << fX[i] << "," << std::endl;
2066 out << " " << fX[fNpoints-1] << "};" << std::endl;
2067 out << " Double_t " << fYName << "[" << fNpoints << "] = {" << std::endl;
2068 for (i = 0; i < fNpoints-1; i++) out << " " << fY[i] << "," << std::endl;
2069 out << " " << fY[fNpoints-1] << "};" << std::endl;
2070 if (gROOT->ClassSaved(TGraph::Class())) out << " ";
2071 else out << " TGraph *";
2072 out << "graph = new TGraph(" << fNpoints << "," << fXName << "," << fYName << ");" << std::endl;
2073 } else {
2074 if (gROOT->ClassSaved(TGraph::Class())) out << " ";
2075 else out << " TGraph *";
2076 out << "graph = new TGraph();" << std::endl;
2077 }
2078
2079 out << " graph->SetName(" << quote << GetName() << quote << ");" << std::endl;
2080 out << " graph->SetTitle(" << quote << GetTitle() << quote << ");" << std::endl;
2081
2082 SaveFillAttributes(out, "graph", 0, 1001);
2083 SaveLineAttributes(out, "graph", 1, 1, 1);
2084 SaveMarkerAttributes(out, "graph", 1, 1, 1);
2085
2086 if (fHistogram) {
2087 TString hname = fHistogram->GetName();
2088 hname += frameNumber;
2089 fHistogram->SetName(Form("Graph_%s", hname.Data()));
2090 fHistogram->SavePrimitive(out, "nodraw");
2091 out << " graph->SetHistogram(" << fHistogram->GetName() << ");" << std::endl;
2092 out << " " << std::endl;
2093 }
2094
2095 // save list of functions
2096 TIter next(fFunctions);
2097 TObject *obj;
2098 while ((obj = next())) {
2099 obj->SavePrimitive(out, Form("nodraw #%d\n",++frameNumber));
2100 if (obj->InheritsFrom("TPaveStats")) {
2101 out << " graph->GetListOfFunctions()->Add(ptstats);" << std::endl;
2102 out << " ptstats->SetParent(graph->GetListOfFunctions());" << std::endl;
2103 } else {
2104 TString objname;
2105 objname.Form("%s%d",obj->GetName(),frameNumber);
2106 if (obj->InheritsFrom("TF1")) {
2107 out << " " << objname << "->SetParent(graph);\n";
2108 }
2109 out << " graph->GetListOfFunctions()->Add("
2110 << objname << ");" << std::endl;
2111 }
2112 }
2113
2114 const char *l;
2115 l = strstr(option, "multigraph");
2116 if (l) {
2117 out << " multigraph->Add(graph," << quote << l + 10 << quote << ");" << std::endl;
2118 return;
2119 }
2120 l = strstr(option, "th2poly");
2121 if (l) {
2122 out << " " << l + 7 << "->AddBin(graph);" << std::endl;
2123 return;
2124 }
2125 out << " graph->Draw(" << quote << option << quote << ");" << std::endl;
2126}
2127
2128////////////////////////////////////////////////////////////////////////////////
2129/// Set number of points in the graph
2130/// Existing coordinates are preserved
2131/// New coordinates above fNpoints are preset to 0.
2132
2134{
2135 if (n < 0) n = 0;
2136 if (n == fNpoints) return;
2137 Double_t **ps = Allocate(n);
2139 if (n > fNpoints) {
2141 }
2142 fNpoints = n;
2143}
2144
2145////////////////////////////////////////////////////////////////////////////////
2146/// Return kTRUE if kNotEditable bit is not set, kFALSE otherwise.
2147
2149{
2150 return TestBit(kNotEditable) ? kFALSE : kTRUE;
2151}
2152
2153////////////////////////////////////////////////////////////////////////////////
2154/// if editable=kFALSE, the graph cannot be modified with the mouse
2155/// by default a TGraph is editable
2156
2158{
2159 if (editable) ResetBit(kNotEditable);
2160 else SetBit(kNotEditable);
2161}
2162
2163////////////////////////////////////////////////////////////////////////////////
2164/// Set highlight (enable/disble) mode for the graph
2165/// by default highlight mode is disable
2166
2168{
2169 if (IsHighlight() == set) return;
2170
2172 if (!painter) return;
2173 SetBit(kIsHighlight, set);
2174 painter->SetHighlight(this);
2175}
2176
2177////////////////////////////////////////////////////////////////////////////////
2178/// Set the maximum of the graph.
2179
2181{
2182 fMaximum = maximum;
2183 GetHistogram()->SetMaximum(maximum);
2184}
2185
2186////////////////////////////////////////////////////////////////////////////////
2187/// Set the minimum of the graph.
2188
2190{
2191 fMinimum = minimum;
2192 GetHistogram()->SetMinimum(minimum);
2193}
2194
2195////////////////////////////////////////////////////////////////////////////////
2196/// Set x and y values for point number i.
2197
2199{
2200 if (i < 0) return;
2202
2203 if (i >= fMaxSize) {
2204 Double_t **ps = ExpandAndCopy(i + 1, fNpoints);
2205 CopyAndRelease(ps, 0, 0, 0);
2206 }
2207 if (i >= fNpoints) {
2208 // points above i can be not initialized
2209 // set zero up to i-th point to avoid redefinition
2210 // of this method in descendant classes
2211 FillZero(fNpoints, i + 1);
2212 fNpoints = i + 1;
2213 }
2214 fX[i] = x;
2215 fY[i] = y;
2216 if (gPad) gPad->Modified();
2217}
2218
2219////////////////////////////////////////////////////////////////////////////////
2220/// Set graph name.
2221void TGraph::SetName(const char *name)
2222{
2223 fName = name;
2225}
2226
2227////////////////////////////////////////////////////////////////////////////////
2228/// Change (i.e. set) the title
2229///
2230/// if title is in the form `stringt;stringx;stringy;stringz`
2231/// the graph title is set to `stringt`, the x axis title to `stringx`,
2232/// the y axis title to `stringy`, and the z axis title to `stringz`.
2233///
2234/// To insert the character `;` in one of the titles, one should use `#;`
2235/// or `#semicolon`.
2236
2237void TGraph::SetTitle(const char* title)
2238{
2239 fTitle = title;
2240 fTitle.ReplaceAll("#;",2,"#semicolon",10);
2241 Int_t p = fTitle.Index(";");
2242
2243 if (p>0) {
2244 if (!fHistogram) GetHistogram();
2245 fHistogram->SetTitle(title);
2246 Int_t n = fTitle.Length()-p;
2247 if (p>0) fTitle.Remove(p,n);
2248 fTitle.ReplaceAll("#semicolon",10,"#;",2);
2249 } else {
2250 if (fHistogram) fHistogram->SetTitle(title);
2251 }
2252}
2253
2254////////////////////////////////////////////////////////////////////////////////
2255/// Set graph name and title
2256
2257void TGraph::SetNameTitle(const char *name, const char *title)
2258{
2259 SetName(name);
2260 SetTitle(title);
2261}
2262
2263////////////////////////////////////////////////////////////////////////////////
2264/// if size*2 <= fMaxSize allocate new arrays of size points,
2265/// copy points [0,oend).
2266/// Return newarray (passed or new instance if it was zero
2267/// and allocations are needed)
2268
2270{
2271 if (size * 2 > fMaxSize || !fMaxSize) {
2272 return 0;
2273 }
2274 Double_t **newarrays = Allocate(size);
2275 CopyPoints(newarrays, 0, oend, 0);
2276 return newarrays;
2277}
2278
2279////////////////////////////////////////////////////////////////////////////////
2280/// Sorts the points of this TGraph using in-place quicksort (see e.g. older glibc).
2281/// To compare two points the function parameter greaterfunc is used (see TGraph::CompareX for an
2282/// example of such a method, which is also the default comparison function for Sort). After
2283/// the sort, greaterfunc(this, i, j) will return kTRUE for all i>j if ascending == kTRUE, and
2284/// kFALSE otherwise.
2285///
2286/// The last two parameters are used for the recursive quick sort, stating the range to be sorted
2287///
2288/// Examples:
2289/// ~~~ {.cpp}
2290/// // sort points along x axis
2291/// graph->Sort();
2292/// // sort points along their distance to origin
2293/// graph->Sort(&TGraph::CompareRadius);
2294///
2295/// Bool_t CompareErrors(const TGraph* gr, Int_t i, Int_t j) {
2296/// const TGraphErrors* ge=(const TGraphErrors*)gr;
2297/// return (ge->GetEY()[i]>ge->GetEY()[j]); }
2298/// // sort using the above comparison function, largest errors first
2299/// graph->Sort(&CompareErrors, kFALSE);
2300/// ~~~
2301
2302void TGraph::Sort(Bool_t (*greaterfunc)(const TGraph*, Int_t, Int_t) /*=TGraph::CompareX()*/,
2303 Bool_t ascending /*=kTRUE*/, Int_t low /* =0 */, Int_t high /* =-1111 */)
2304{
2305
2306 // set the bit in case of an ascending =sort in X
2307 if (greaterfunc == TGraph::CompareX && ascending && low == 0 && high == -1111)
2309
2310 if (high == -1111) high = GetN() - 1;
2311 // Termination condition
2312 if (high <= low) return;
2313
2314 int left, right;
2315 left = low; // low is the pivot element
2316 right = high;
2317 while (left < right) {
2318 // move left while item < pivot
2319 while (left <= high && greaterfunc(this, left, low) != ascending)
2320 left++;
2321 // move right while item > pivot
2322 while (right > low && greaterfunc(this, right, low) == ascending)
2323 right--;
2324 if (left < right && left < high && right > low)
2325 SwapPoints(left, right);
2326 }
2327 // right is final position for the pivot
2328 if (right > low)
2329 SwapPoints(low, right);
2330 Sort(greaterfunc, ascending, low, right - 1);
2331 Sort(greaterfunc, ascending, right + 1, high);
2332}
2333
2334////////////////////////////////////////////////////////////////////////////////
2335/// Stream an object of class TGraph.
2336
2337void TGraph::Streamer(TBuffer &b)
2338{
2339 if (b.IsReading()) {
2340 UInt_t R__s, R__c;
2341 Version_t R__v = b.ReadVersion(&R__s, &R__c);
2342 if (R__v > 2) {
2343 b.ReadClassBuffer(TGraph::Class(), this, R__v, R__s, R__c);
2345 TIter next(fFunctions);
2346 TObject *obj;
2347 while ((obj = next())) {
2348 if (obj->InheritsFrom(TF1::Class())) {
2349 TF1 *f1 = (TF1*)obj;
2350 f1->SetParent(this);
2351 }
2352 }
2354 return;
2355 }
2356 //====process old versions before automatic schema evolution
2357 TNamed::Streamer(b);
2358 TAttLine::Streamer(b);
2359 TAttFill::Streamer(b);
2360 TAttMarker::Streamer(b);
2361 b >> fNpoints;
2363 fX = new Double_t[fNpoints];
2364 fY = new Double_t[fNpoints];
2365 if (R__v < 2) {
2366 Float_t *x = new Float_t[fNpoints];
2367 Float_t *y = new Float_t[fNpoints];
2368 b.ReadFastArray(x, fNpoints);
2369 b.ReadFastArray(y, fNpoints);
2370 for (Int_t i = 0; i < fNpoints; i++) {
2371 fX[i] = x[i];
2372 fY[i] = y[i];
2373 }
2374 delete [] y;
2375 delete [] x;
2376 } else {
2377 b.ReadFastArray(fX, fNpoints);
2378 b.ReadFastArray(fY, fNpoints);
2379 }
2380 b >> fFunctions;
2381 b >> fHistogram;
2383 if (R__v < 2) {
2384 Float_t mi, ma;
2385 b >> mi;
2386 b >> ma;
2387 fMinimum = mi;
2388 fMaximum = ma;
2389 } else {
2390 b >> fMinimum;
2391 b >> fMaximum;
2392 }
2393 b.CheckByteCount(R__s, R__c, TGraph::IsA());
2394 //====end of old versions
2395
2396 } else {
2397 b.WriteClassBuffer(TGraph::Class(), this);
2398 }
2399}
2400
2401////////////////////////////////////////////////////////////////////////////////
2402/// Swap points.
2403
2405{
2406 SwapValues(fX, pos1, pos2);
2407 SwapValues(fY, pos1, pos2);
2408}
2409
2410////////////////////////////////////////////////////////////////////////////////
2411/// Swap values.
2412
2414{
2415 Double_t tmp = arr[pos1];
2416 arr[pos1] = arr[pos2];
2417 arr[pos2] = tmp;
2418}
2419
2420////////////////////////////////////////////////////////////////////////////////
2421/// Set current style settings in this graph
2422/// This function is called when either TCanvas::UseCurrentStyle
2423/// or TROOT::ForceStyle have been invoked.
2424
2426{
2427 if (gStyle->IsReading()) {
2436 } else {
2445 }
2447
2448 TIter next(GetListOfFunctions());
2449 TObject *obj;
2450
2451 while ((obj = next())) {
2452 obj->UseCurrentStyle();
2453 }
2454}
2455
2456////////////////////////////////////////////////////////////////////////////////
2457/// Adds all graphs from the collection to this graph.
2458/// Returns the total number of poins in the result or -1 in case of an error.
2459
2461{
2462 TIter next(li);
2463 while (TObject* o = next()) {
2464 TGraph *g = dynamic_cast<TGraph*>(o);
2465 if (!g) {
2466 Error("Merge",
2467 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
2468 return -1;
2469 }
2470 DoMerge(g);
2471 }
2472 return GetN();
2473}
2474////////////////////////////////////////////////////////////////////////////////
2475/// protected function to perform the merge operation of a graph
2476
2478{
2479 Double_t x, y;
2480 for (Int_t i = 0 ; i < g->GetN(); i++) {
2481 g->GetPoint(i, x, y);
2482 SetPoint(GetN(), x, y);
2483 }
2484 return kTRUE;
2485}
2486////////////////////////////////////////////////////////////////////////////////
2487/// Find zero of a continuous function.
2488/// This function finds a real zero of the continuous real
2489/// function Y(X) in a given interval (A,B). See accompanying
2490/// notes for details of the argument list and calling sequence
2491
2493 , Int_t maxiterations)
2494{
2495 static Double_t a, b, ya, ytest, y1, x1, h;
2496 static Int_t j1, it, j3, j2;
2497 Double_t yb, x2;
2498 yb = 0;
2499
2500 // Calculate Y(X) at X=AZ.
2501 if (k <= 0) {
2502 a = AZ;
2503 b = BZ;
2504 X = a;
2505 j1 = 1;
2506 it = 1;
2507 k = j1;
2508 return;
2509 }
2510
2511 // Test whether Y(X) is sufficiently small.
2512
2513 if (TMath::Abs(Y) <= E2) {
2514 k = 2;
2515 return;
2516 }
2517
2518 // Calculate Y(X) at X=BZ.
2519
2520 if (j1 == 1) {
2521 ya = Y;
2522 X = b;
2523 j1 = 2;
2524 return;
2525 }
2526 // Test whether the signs of Y(AZ) and Y(BZ) are different.
2527 // if not, begin the binary subdivision.
2528
2529 if (j1 != 2) goto L100;
2530 if (ya * Y < 0) goto L120;
2531 x1 = a;
2532 y1 = ya;
2533 j1 = 3;
2534 h = b - a;
2535 j2 = 1;
2536 x2 = a + 0.5 * h;
2537 j3 = 1;
2538 it++; //*-*- Check whether (maxiterations) function values have been calculated.
2539 if (it >= maxiterations) k = j1;
2540 else X = x2;
2541 return;
2542
2543 // Test whether a bracket has been found .
2544 // If not,continue the search
2545
2546L100:
2547 if (j1 > 3) goto L170;
2548 if (ya*Y >= 0) {
2549 if (j3 >= j2) {
2550 h = 0.5 * h;
2551 j2 = 2 * j2;
2552 a = x1;
2553 ya = y1;
2554 x2 = a + 0.5 * h;
2555 j3 = 1;
2556 } else {
2557 a = X;
2558 ya = Y;
2559 x2 = X + h;
2560 j3++;
2561 }
2562 it++;
2563 if (it >= maxiterations) k = j1;
2564 else X = x2;
2565 return;
2566 }
2567
2568 // The first bracket has been found.calculate the next X by the
2569 // secant method based on the bracket.
2570
2571L120:
2572 b = X;
2573 yb = Y;
2574 j1 = 4;
2575L130:
2576 if (TMath::Abs(ya) > TMath::Abs(yb)) {
2577 x1 = a;
2578 y1 = ya;
2579 X = b;
2580 Y = yb;
2581 } else {
2582 x1 = b;
2583 y1 = yb;
2584 X = a;
2585 Y = ya;
2586 }
2587
2588 // Use the secant method based on the function values y1 and Y.
2589 // check that x2 is inside the interval (a,b).
2590
2591L150:
2592 x2 = X - Y * (X - x1) / (Y - y1);
2593 x1 = X;
2594 y1 = Y;
2595 ytest = 0.5 * TMath::Min(TMath::Abs(ya), TMath::Abs(yb));
2596 if ((x2 - a)*(x2 - b) < 0) {
2597 it++;
2598 if (it >= maxiterations) k = j1;
2599 else X = x2;
2600 return;
2601 }
2602
2603 // Calculate the next value of X by bisection . Check whether
2604 // the maximum accuracy has been achieved.
2605
2606L160:
2607 x2 = 0.5 * (a + b);
2608 ytest = 0;
2609 if ((x2 - a)*(x2 - b) >= 0) {
2610 k = 2;
2611 return;
2612 }
2613 it++;
2614 if (it >= maxiterations) k = j1;
2615 else X = x2;
2616 return;
2617
2618
2619 // Revise the bracket (a,b).
2620
2621L170:
2622 if (j1 != 4) return;
2623 if (ya * Y < 0) {
2624 b = X;
2625 yb = Y;
2626 } else {
2627 a = X;
2628 ya = Y;
2629 }
2630
2631 // Use ytest to decide the method for the next value of X.
2632
2633 if (ytest <= 0) goto L130;
2634 if (TMath::Abs(Y) - ytest <= 0) goto L150;
2635 goto L160;
2636}
void Class()
Definition: Class.C:29
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define g(i)
Definition: RSha256.hxx:105
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
static const double x2[5]
static const double x1[5]
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
int Int_t
Definition: RtypesCore.h:41
short Version_t
Definition: RtypesCore.h:61
int Ssiz_t
Definition: RtypesCore.h:63
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Axis_t
Definition: RtypesCore.h:72
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
char * R__STRTOK_R(char *str, const char *delim, char **saveptr)
Definition: Rtypes.h:486
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
char name[80]
Definition: TGX11.cxx:109
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:4695
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
Binding & operator=(OUT(*fun)(void))
#define gROOT
Definition: TROOT.h:414
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
R__EXTERN TSystem * gSystem
Definition: TSystem.h:560
#define gPad
Definition: TVirtualPad.h:286
class describing the range in the coordinates it supports multiple range in a coordinate.
Definition: DataRange.h:34
virtual Int_t GetNdivisions() const
Definition: TAttAxis.h:36
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:294
virtual Style_t GetTitleFont() const
Definition: TAttAxis.h:46
virtual Float_t GetLabelOffset() const
Definition: TAttAxis.h:40
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 Style_t GetLabelFont() const
Definition: TAttAxis.h:39
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition: TAttAxis.cxx:322
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
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
Definition: TAttAxis.cxx:183
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:304
virtual Float_t GetTitleSize() const
Definition: TAttAxis.h:43
virtual Float_t GetLabelSize() const
Definition: TAttAxis.h:41
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:42
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:229
Fill Area Attributes class.
Definition: TAttFill.h:19
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:202
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition: TAttFill.cxx:234
Line Attributes class.
Definition: TAttLine.h:18
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:164
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:198
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:262
Marker Attributes class.
Definition: TAttMarker.h:19
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition: TAttMarker.cxx:245
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:32
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:31
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:33
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
void Copy(TAttMarker &attmarker) const
Copy this marker attributes to a new TAttMarker.
Definition: TAttMarker.cxx:210
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
Class to manage histogram axis.
Definition: TAxis.h:30
virtual Bool_t GetTimeDisplay() const
Definition: TAxis.h:126
Bool_t GetRotateTitle() const
Definition: TAxis.h:124
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
Bool_t GetCenterTitle() const
Definition: TAxis.h:115
Bool_t GetNoExponent() const
Definition: TAxis.h:122
virtual void SetTimeDisplay(Int_t value)
Definition: TAxis.h:161
void RotateTitle(Bool_t rotate=kTRUE)
Rotate title by 180 degrees.
Definition: TAxis.h:193
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
Definition: TAxis.h:184
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
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:154
virtual const char * GetTimeFormat() const
Definition: TAxis.h:127
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1002
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
Collection abstract base class.
Definition: TCollection.h:63
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
virtual Bool_t IsEmpty() const
Definition: TCollection.h:186
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
1-Dim function class
Definition: TF1.h:211
virtual void SetParent(TObject *p=0)
Definition: TF1.h:659
virtual Int_t GetNpar() const
Definition: TF1.h:475
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
Definition: TF1.cxx:3497
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:628
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:31
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:41
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:1790
Int_t fNpoints
Number of points <= fMaxSize.
Definition: TGraph.h:46
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:1823
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:1838
virtual Double_t Chisquare(TF1 *f1, Option_t *option="") const
Return the chisquare of this graph with respect to f1.
Definition: TGraph.cxx:593
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2198
virtual Int_t Merge(TCollection *list)
Adds all graphs from the collection to this graph.
Definition: TGraph.cxx:2460
Int_t fMaxSize
!Current dimension of arrays fX and fY
Definition: TGraph.h:45
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:2269
virtual Double_t GetRMS(Int_t axis=1) const
Return RMS of X (axis=1) or Y (axis=2)
Definition: TGraph.cxx:1374
TH1F * fHistogram
Pointer to histogram used for drawing axis.
Definition: TGraph.h:50
@ kNotEditable
bit set if graph is non editable
Definition: TGraph.h:72
@ kIsHighlight
bit set if graph is highlight
Definition: TGraph.h:74
@ kIsSortedX
graph is sorted in X points
Definition: TGraph.h:73
@ kClipFrame
clip to the frame boundary
Definition: TGraph.h:70
@ kResetHisto
fHistogram must be reset in GetHistogram
Definition: TGraph.h:71
virtual Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1426
virtual void SetName(const char *name="")
Set graph name.
Definition: TGraph.cxx:2221
virtual Double_t GetErrorYlow(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1446
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 !...
Definition: TGraph.cxx:678
Double_t GetMinimum() const
Definition: TGraph.h:143
virtual void SetNameTitle(const char *name="", const char *title="")
Set graph name and title.
Definition: TGraph.cxx:2257
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum of the graph.
Definition: TGraph.cxx:2180
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:629
virtual TObject * FindObject(const char *name) const
Search object named name in the list of functions.
Definition: TGraph.cxx:1024
static Bool_t CompareRadius(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"'s distance to origin is bigger than that of point number "right".
Definition: TGraph.cxx:638
virtual Double_t GetErrorYhigh(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1436
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:621
Int_t GetN() const
Definition: TGraph.h:123
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
Definition: TGraph.cxx:1457
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:1913
virtual void SetTitle(const char *title="")
Change (i.e.
Definition: TGraph.cxx:2237
Double_t * fY
[fNpoints] array of Y points
Definition: TGraph.h:48
Bool_t CtorAllocate()
In constructors set fNpoints than call this method.
Definition: TGraph.cxx:721
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:801
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:1051
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:2302
static Bool_t CompareArg(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"'s argument (angle with respect to positive x-axis) is bigger than...
Definition: TGraph.cxx:610
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:647
Double_t ** AllocateArrays(Int_t Narrays, Int_t arraySize)
Allocate arrays.
Definition: TGraph.cxx:531
TList * fFunctions
Pointer to list of functions (fits and user)
Definition: TGraph.h:49
virtual Double_t GetCovariance() const
Return covariance of vectors x,y.
Definition: TGraph.cxx:1343
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
Definition: TGraph.cxx:2413
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:2492
virtual Double_t ** Allocate(Int_t newsize)
Definition: TGraph.h:187
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition: TGraph.cxx:1309
virtual void Print(Option_t *chopt="") const
Print graph values.
Definition: TGraph.cxx:1995
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
Definition: TGraph.cxx:2477
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:747
virtual void InsertPointBefore(Int_t ipoint, Double_t x, Double_t y)
Insert a new point with coordinates (x,y) before the point number ipoint.
Definition: TGraph.cxx:1736
TList * GetListOfFunctions() const
Definition: TGraph.h:117
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TGraph.cxx:2053
virtual void InitExpo(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for an exponential.
Definition: TGraph.cxx:1650
virtual Int_t RemovePoint()
Delete point close to the mouse position.
Definition: TGraph.cxx:2016
virtual void InitGaus(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a gaussian.
Definition: TGraph.cxx:1612
virtual Bool_t IsHighlight() const
Definition: TGraph.h:155
virtual void Paint(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:1959
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:554
virtual void SetHighlight(Bool_t set=kTRUE)
Set highlight (enable/disble) mode for the graph by default highlight mode is disable.
Definition: TGraph.cxx:2167
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
Definition: TGraph.cxx:2404
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of functions.
Definition: TGraph.cxx:2005
TAxis * GetXaxis() const
Get x axis of the graph.
Definition: TGraph.cxx:1592
Bool_t GetEditable() const
Return kTRUE if kNotEditable bit is not set, kFALSE otherwise.
Definition: TGraph.cxx:2148
virtual Double_t GetCorrelationFactor() const
Return graph correlation factor.
Definition: TGraph.cxx:1331
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:1015
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:865
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:1001
virtual void Expand(Int_t newsize)
If array sizes <= newsize, expand storage to 2*newsize.
Definition: TGraph.cxx:977
virtual void UseCurrentStyle()
Set current style settings in this graph This function is called when either TCanvas::UseCurrentStyle...
Definition: TGraph.cxx:2425
virtual Double_t GetMean(Int_t axis=1) const
Return mean value of X (axis=1) or Y (axis=2)
Definition: TGraph.cxx:1359
Double_t * fX
[fNpoints] array of X points
Definition: TGraph.h:47
virtual void PaintStats(TF1 *fit)
Draw the stats.
Definition: TGraph.cxx:1986
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph.cxx:1602
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a graph.
Definition: TGraph.cxx:791
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
virtual Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1406
Double_t fMinimum
Minimum value for plotting along y.
Definition: TGraph.h:51
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:1968
virtual Int_t InsertPoint()
Insert a new point at the mouse position.
Definition: TGraph.cxx:1691
virtual void Browse(TBrowser *b)
Browse.
Definition: TGraph.cxx:567
virtual void DrawPanel()
Display a panel with all graph drawing options.
Definition: TGraph.cxx:844
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:1977
virtual ~TGraph()
Graph default destructor.
Definition: TGraph.cxx:507
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:2133
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 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:2157
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TGraph.cxx:968
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum of the graph.
Definition: TGraph.cxx:2189
TGraph()
Graph default constructor.
Definition: TGraph.cxx:86
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 !...
Definition: TGraph.cxx:695
Double_t fMaximum
Maximum value for plotting along y.
Definition: TGraph.h:52
virtual Double_t GetErrorXhigh(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1416
TGraph & operator=(const TGraph &)
Equal operator for this graph.
Definition: TGraph.cxx:187
virtual void InitPolynom(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a polynom.
Definition: TGraph.cxx:1671
virtual Double_t GetErrorX(Int_t bin) const
This function is called by GraphFitChisquare.
Definition: TGraph.cxx:1397
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
The TH1 histogram class.
Definition: TH1.h:56
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:8351
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TH1.cxx:6753
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Definition: TH1.cxx:6309
@ kNoStats
don't draw stats box
Definition: TH1.h:160
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
void UseCurrentStyle()
Copy current attributes from/to current style.
Definition: TH1.cxx:6986
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2664
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
TAxis * GetYaxis()
Definition: TH1.h:317
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:395
virtual void SetName(const char *name)
Change the name of this histogram.
Definition: TH1.cxx:8374
A doubly linked list.
Definition: TList.h:44
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:819
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:575
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TList.cxx:761
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:656
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TString fTitle
Definition: TNamed.h:33
TString fName
Definition: TNamed.h:32
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
Definition: TObject.cxx:715
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:664
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
void MakeZombie()
Definition: TObject.h:49
void ResetBit(UInt_t f)
Definition: TObject.h:171
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition: TObject.h:68
Long_t ExecPlugin(int nargs, const T &... params)
Int_t LoadPlugin()
Load the plugin library for this handler.
Class to create third splines to interpolate knots Arbitrary conditions can be introduced for first a...
Definition: TSpline.h:192
Base class for spline implementation containing the Draw/Paint methods.
Definition: TSpline.h:22
virtual Double_t Eval(Double_t x) const =0
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1921
Double_t Atof() const
Return floating-point value contained in string.
Definition: TString.cxx:1987
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Definition: TString.cxx:1791
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:677
const char * Data() const
Definition: TString.h:364
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1763
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1138
Bool_t IsNull() const
Definition: TString.h:402
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
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:2311
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
void SetHistFillColor(Color_t color=1)
Definition: TStyle.h:356
Color_t GetHistLineColor() const
Definition: TStyle.h:220
Bool_t IsReading() const
Definition: TStyle.h:277
void SetHistLineStyle(Style_t styl=0)
Definition: TStyle.h:359
Style_t GetHistFillStyle() const
Definition: TStyle.h:221
Color_t GetHistFillColor() const
Definition: TStyle.h:219
void SetHistLineColor(Color_t color=1)
Definition: TStyle.h:357
Style_t GetHistLineStyle() const
Definition: TStyle.h:222
void SetHistFillStyle(Style_t styl=0)
Definition: TStyle.h:358
Width_t GetHistLineWidth() const
Definition: TStyle.h:223
void SetHistLineWidth(Width_t width=1)
Definition: TStyle.h:360
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1264
TVectorT.
Definition: TVectorT.h:27
Int_t GetNrows() const
Definition: TVectorT.h:75
Int_t GetLwb() const
Definition: TVectorT.h:73
Abstract Base Class for Fitting.
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
Abstract interface to a histogram painter.
virtual void DrawPanelHelper(TGraph *theGraph)=0
virtual void ExecuteEventHelper(TGraph *theGraph, Int_t event, Int_t px, Int_t py)=0
virtual void SetHighlight(TGraph *theGraph)=0
virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
virtual Int_t DistancetoPrimitiveHelper(TGraph *theGraph, Int_t px, Int_t py)=0
virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
virtual void PaintStats(TGraph *theGraph, TF1 *fit)=0
virtual void PaintHelper(TGraph *theGraph, Option_t *option)=0
static TVirtualGraphPainter * GetPainter()
Static function returning a pointer to the current graph painter.
TLine * line
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
TGraphErrors * gr
Definition: legend1.C:25
TF1 * f1
Definition: legend1.C:11
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:964
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Definition: HFitImpl.cxx:681
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:1018
static constexpr double s
static constexpr double ps
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Definition: TMath.h:1197
Double_t ATan2(Double_t, Double_t)
Definition: TMath.h:667
Double_t Log(Double_t x)
Definition: TMath.h:748
Double_t Sqrt(Double_t x)
Definition: TMath.h:679
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMathBase.h:362
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMathBase.h:278
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Definition: first.py:1
auto * m
Definition: textangle.C:8
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12
static long int sum(long int i)
Definition: Factory.cxx:2258