95 for (
Int_t i = 0; i <
n; i++) {
116 else memset(
fEX, 0,
n);
118 else memset(
fEY, 0,
n);
130 :
TGraph(
TMath::
Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
136 fEX[i] = vex(i + ivexlow);
137 fEY[i] = vey(i + iveylow);
150 :
TGraph(
TMath::
Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
156 fEX[i] = vex(i + ivexlow);
157 fEY[i] = vey(i + iveylow);
206 fEY[i] =
h->GetBinError(i + 1);
234 std::ifstream infile(fname.
Data());
235 if (!infile.good()) {
237 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie", filename);
244 if (strcmp(option,
"") == 0) {
248 while (std::getline(infile,
line,
'\n')) {
251 res = sscanf(
line.c_str(), format, &
x, &
y);
252 }
else if (ncol < 4) {
253 res = sscanf(
line.c_str(), format, &
x, &
y, &
ey);
255 res = sscanf(
line.c_str(), format, &
x, &
y, &
ex, &
ey);
277 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
282 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
285 Int_t ntokensToBeSaved = 0 ;
287 for (
Int_t idx = 0; idx < ntokens; idx++) {
289 if (isTokenToBeSaved[idx] == 1) {
293 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
294 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
295 delete [] isTokenToBeSaved ;
301 char * token = NULL ;
303 Int_t token_idx = 0 ;
305 for (
Int_t k = 0; k < 4; k++) {
308 Int_t value_idx = 0 ;
312 while (std::getline(infile,
line,
'\n')) {
314 if (
line[
line.size() - 1] ==
char(13)) {
318 while (token != NULL && value_idx < ntokensToBeSaved) {
319 if (isTokenToBeSaved[token_idx]) {
323 isLineToBeSkipped =
kTRUE ;
326 value[value_idx] = token_str.
Atof() ;
333 if (!isLineToBeSkipped && value_idx > 1) {
343 isLineToBeSkipped =
kFALSE ;
351 delete [] isTokenToBeSaved ;
439 while ((fmt = strchr(fmt,
'%'))) {
443 if (*++fmt &&
'^' == *fmt) ++fmt;
444 if (*++fmt &&
']' == *fmt) ++fmt;
445 while (*fmt && *fmt !=
']')
450 if (
'%' == *fmt)
break;
453 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
525 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
526 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
528 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
529 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
561 if (
g->GetN() == 0)
return kFALSE;
565 if (
ex == 0 ||
ey == 0 ) {
567 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
570 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
590 memset(
fEX + begin, 0,
n);
591 memset(
fEY + begin, 0,
n);
601 if (i < 0 || i >=
fNpoints)
return -1;
613 if (i < 0 || i >=
fNpoints)
return -1;
625 if (i < 0 || i >=
fNpoints)
return -1;
637 if (i < 0 || i >=
fNpoints)
return -1;
649 if (i < 0 || i >=
fNpoints)
return -1;
661 if (i < 0 || i >=
fNpoints)
return -1;
677 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
681 int n1 = n0+
g->GetN();
687 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
702 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]);
713 out <<
" " << std::endl;
714 static Int_t frameNumber = 1000;
722 out <<
" Double_t " << fXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
723 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fX[i] <<
"," << std::endl;
724 out <<
" " <<
fX[
fNpoints-1] <<
"};" << std::endl;
725 out <<
" Double_t " << fYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
726 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fY[i] <<
"," << std::endl;
727 out <<
" " <<
fY[
fNpoints-1] <<
"};" << std::endl;
728 out <<
" Double_t " << fEXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
729 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEX[i] <<
"," << std::endl;
730 out <<
" " <<
fEX[
fNpoints-1] <<
"};" << std::endl;
731 out <<
" Double_t " << fEYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
732 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEY[i] <<
"," << std::endl;
733 out <<
" " <<
fEY[
fNpoints-1] <<
"};" << std::endl;
736 else out <<
" TGraphErrors *";
737 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
738 << fXName <<
"," << fYName <<
","
739 << fEXName <<
"," << fEYName <<
");"
742 out <<
" gre->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
743 out <<
" gre->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
751 hname += frameNumber;
755 out <<
" " << std::endl;
761 while ((obj = next())) {
764 out <<
" gre->GetListOfFunctions()->Add(ptstats);" << std::endl;
765 out <<
" ptstats->SetParent(gre->GetListOfFunctions());" << std::endl;
770 out <<
" " << objname <<
"->SetParent(gre);\n";
772 out <<
" gre->GetListOfFunctions()->Add("
773 << objname <<
");" << std::endl;
777 const char *
l = strstr(option,
"multigraph");
779 out <<
" multigraph->Add(gre," << quote <<
l + 10 << quote <<
");" << std::endl;
781 out <<
" gre->Draw(" << quote << option << quote <<
");" << std::endl;
801 if (dpx * dpx + dpy * dpy < 25) {
806 if (ipoint == -2)
return;
832void TGraphErrors::Streamer(
TBuffer &
b)
860 b.CheckByteCount(R__s, R__c, TGraphErrors::IsA());
char * R__STRTOK_R(char *str, const char *delim, char **saveptr)
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
This function is called by GraphFitChisquare.
Double_t GetErrorXlow(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Int_t Merge(TCollection *list)
Adds all graphs with errors from the collection to this graph.
Double_t GetErrorYlow(Int_t bin) const
This function is called by GraphFitChisquare.
Double_t * fEY
[fNpoints] array of Y errors
Double_t GetErrorX(Int_t bin) const
This function is called by GraphFitChisquare.
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 y = f(x,y)
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 x = f(x,y)
Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
Double_t GetErrorYhigh(Int_t bin) const
This function is called by GraphFitChisquare.
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 fX and fY.
virtual void Print(Option_t *chopt="") const
Print graph and errors values.
virtual ~TGraphErrors()
TGraphErrors default destructor.
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.
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.
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.
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.
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)