98 for (
Int_t i = 0; i <
n; i++) {
119 else memset(
fEX, 0,
n);
121 else memset(
fEY, 0,
n);
134 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
140 fEX[i] = vex(i + ivexlow);
141 fEY[i] = vey(i + iveylow);
155 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
161 fEX[i] = vex(i + ivexlow);
162 fEY[i] = vey(i + iveylow);
211 fEY[i] =
h->GetBinError(i + 1);
242 std::ifstream infile(fname.
Data());
243 if (!infile.good()) {
245 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie", filename);
252 if (strcmp(option,
"") == 0) {
256 while (std::getline(infile,
line,
'\n')) {
259 res = sscanf(
line.c_str(), format, &
x, &
y);
260 }
else if (ncol < 4) {
261 res = sscanf(
line.c_str(), format, &
x, &
y, &
ey);
263 res = sscanf(
line.c_str(), format, &
x, &
y, &
ex, &
ey);
285 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
290 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
293 Int_t ntokensToBeSaved = 0 ;
295 for (
Int_t idx = 0; idx < ntokens; idx++) {
297 if (isTokenToBeSaved[idx] == 1) {
301 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
302 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
303 delete [] isTokenToBeSaved ;
309 char * token = NULL ;
311 Int_t token_idx = 0 ;
313 for (
Int_t k = 0; k < 4; k++) {
316 Int_t value_idx = 0 ;
320 while (std::getline(infile,
line,
'\n')) {
322 if (
line[
line.size() - 1] ==
char(13)) {
325 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()), option, &rest);
326 while (token != NULL && value_idx < ntokensToBeSaved) {
327 if (isTokenToBeSaved[token_idx]) {
331 isLineToBeSkipped =
kTRUE ;
334 value[value_idx] = token_str.
Atof() ;
338 token = R__STRTOK_R(NULL, option, &rest);
341 if (!isLineToBeSkipped && value_idx > 1) {
351 isLineToBeSkipped =
kFALSE ;
359 delete [] isTokenToBeSaved ;
446 while ((fmt = strchr(fmt,
'%'))) {
450 if (*++fmt &&
'^' == *fmt) ++fmt;
451 if (*++fmt &&
']' == *fmt) ++fmt;
452 while (*fmt && *fmt !=
']')
457 if (
'%' == *fmt)
break;
460 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
532 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
533 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
535 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
536 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
569 if (
g->GetN() == 0)
return kFALSE;
573 if (
ex == 0 ||
ey == 0 ) {
574 if (
g->IsA() != TGraph::Class() )
575 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
578 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
598 memset(
fEX + begin, 0,
n);
599 memset(
fEY + begin, 0,
n);
608 if (i < 0 || i >=
fNpoints)
return -1;
619 if (i < 0 || i >=
fNpoints)
return -1;
631 if (i < 0 || i >=
fNpoints)
return -1;
643 if (i < 0 || i >=
fNpoints)
return -1;
655 if (i < 0 || i >=
fNpoints)
return -1;
667 if (i < 0 || i >=
fNpoints)
return -1;
683 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
687 int n1 = n0+
g->GetN();
693 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
708 printf(
"x[%d]=%g, y[%d]=%g, ex[%d]=%g, ey[%d]=%g\n", i,
fX[i], i,
fY[i], i,
fEX[i], i,
fEY[i]);
719 out <<
" " << std::endl;
720 static Int_t frameNumber = 1000;
728 out <<
" Double_t " << fXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
729 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fX[i] <<
"," << std::endl;
730 out <<
" " <<
fX[
fNpoints-1] <<
"};" << std::endl;
731 out <<
" Double_t " << fYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
732 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fY[i] <<
"," << std::endl;
733 out <<
" " <<
fY[
fNpoints-1] <<
"};" << std::endl;
734 out <<
" Double_t " << fEXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
735 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEX[i] <<
"," << std::endl;
736 out <<
" " <<
fEX[
fNpoints-1] <<
"};" << std::endl;
737 out <<
" Double_t " << fEYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
738 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEY[i] <<
"," << std::endl;
739 out <<
" " <<
fEY[
fNpoints-1] <<
"};" << std::endl;
741 if (
gROOT->ClassSaved(TGraphErrors::Class())) out <<
" ";
742 else out <<
" TGraphErrors *";
743 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
744 << fXName <<
"," << fYName <<
","
745 << fEXName <<
"," << fEYName <<
");"
748 out <<
" gre->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
749 out <<
" gre->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
757 hname += frameNumber;
761 out <<
" " << std::endl;
767 while ((obj = next())) {
770 out <<
" gre->GetListOfFunctions()->Add(ptstats);" << std::endl;
771 out <<
" ptstats->SetParent(gre->GetListOfFunctions());" << std::endl;
776 out <<
" " << objname <<
"->SetParent(gre);\n";
778 out <<
" gre->GetListOfFunctions()->Add("
779 << objname <<
");" << std::endl;
783 const char *
l = strstr(option,
"multigraph");
785 out <<
" multigraph->Add(gre," << quote <<
l + 10 << quote <<
");" << std::endl;
787 out <<
" gre->Draw(" << quote << option << quote <<
");" << std::endl;
827 if (dpx * dpx + dpy * dpy < 25) {
832 if (ipoint == -2)
return;
858void TGraphErrors::Streamer(
TBuffer &
b)
864 b.ReadClassBuffer(TGraphErrors::Class(),
this, R__v, R__s, R__c);
886 b.CheckByteCount(R__s, R__c, TGraphErrors::IsA());
890 b.WriteClassBuffer(TGraphErrors::Class(),
this);
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
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.
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.
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.
Buffer base class used for serializing objects.
Collection abstract base class.
A TGraphErrors is a TGraph with error bars.
Double_t GetErrorXhigh(Int_t bin) const
It returns the error along X at point i.
Double_t GetErrorXlow(Int_t bin) const
It returns the error along X at point i.
virtual Int_t Merge(TCollection *list)
Adds all graphs with errors from the collection to this graph.
Double_t GetErrorYlow(Int_t bin) const
It returns the error along Y at point i.
Double_t * fEY
[fNpoints] array of Y errors
Double_t GetErrorX(Int_t bin) const
It returns the error along X at point i.
static Int_t CalculateScanfFields(const char *fmt)
Calculate scan fields.
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute range.
Double_t * fEX
[fNpoints] array of X errors
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
virtual void Apply(TF1 *f)
Apply function to all the data points .
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].
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
virtual Bool_t DoMerge(const TGraph *g)
Protected function to perform the merge operation of a graph with errors.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual void ApplyX(TF1 *f)
Apply function to all the data points .
Double_t GetErrorY(Int_t bin) const
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const
It returns the error along Y at point i.
TGraphErrors & operator=(const TGraphErrors &gr)
TGraphErrors assignment operator.
virtual Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy errors from fEX and fEY to arrays[0] and arrays[1] or to fEX and fEY if arrays == 0 and ibegin !...
virtual void Print(Option_t *chopt="") const
Print graph and errors values.
virtual ~TGraphErrors()
TGraphErrors default destructor.
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values and errors of a TGraphErrors by a constant c1.
TGraphErrors()
TGraphErrors default constructor.
Bool_t CtorAllocate()
Constructor allocate.
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy and release.
A TGraph is an object made of two arrays X and Y with npoints each.
Int_t fNpoints
Number of points <= fMaxSize.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Int_t fMaxSize
!Current dimension of arrays fX and fY
TH1F * fHistogram
Pointer to histogram used for drawing axis.
Double_t * fY
[fNpoints] array of Y points
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.
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values of a TGraph by a constant c1.
TList * fFunctions
Pointer to list of functions (fits and user)
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
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.
Double_t * fX
[fNpoints] array of X points
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
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 !...
TGraph & operator=(const TGraph &)
Equal operator for this graph.
TH1 is the base class of all histogram classes in ROOT.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual void SetName(const char *name)
Change the name of this histogram.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Float_t GetErrorX() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Short_t Min(Short_t a, Short_t b)