98 for (
Int_t i = 0; i <
n; i++) {
119 else memset(
fEX, 0,
n);
121 else memset(
fEY, 0,
n);
133 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
139 fEX[i] = vex(i + ivexlow);
140 fEY[i] = vey(i + iveylow);
153 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
159 fEX[i] = vex(i + ivexlow);
160 fEY[i] = vey(i + iveylow);
209 fEY[i] =
h->GetBinError(i + 1);
237 std::ifstream infile(fname.
Data());
238 if (!infile.good()) {
240 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie", filename);
247 if (strcmp(option,
"") == 0) {
251 while (std::getline(infile,
line,
'\n')) {
254 res = sscanf(
line.c_str(), format, &
x, &
y);
255 }
else if (ncol < 4) {
256 res = sscanf(
line.c_str(), format, &
x, &
y, &
ey);
258 res = sscanf(
line.c_str(), format, &
x, &
y, &
ex, &
ey);
280 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
285 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
288 Int_t ntokensToBeSaved = 0 ;
290 for (
Int_t idx = 0; idx < ntokens; idx++) {
292 if (isTokenToBeSaved[idx] == 1) {
296 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
297 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
298 delete [] isTokenToBeSaved ;
304 char * token = NULL ;
306 Int_t token_idx = 0 ;
308 for (
Int_t k = 0; k < 4; k++) {
311 Int_t value_idx = 0 ;
315 while (std::getline(infile,
line,
'\n')) {
317 if (
line[
line.size() - 1] ==
char(13)) {
320 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()), option, &rest);
321 while (token != NULL && value_idx < ntokensToBeSaved) {
322 if (isTokenToBeSaved[token_idx]) {
326 isLineToBeSkipped =
kTRUE ;
329 value[value_idx] = token_str.
Atof() ;
333 token = R__STRTOK_R(NULL, option, &rest);
336 if (!isLineToBeSkipped && value_idx > 1) {
346 isLineToBeSkipped =
kFALSE ;
354 delete [] isTokenToBeSaved ;
442 while ((fmt = strchr(fmt,
'%'))) {
446 if (*++fmt &&
'^' == *fmt) ++fmt;
447 if (*++fmt &&
']' == *fmt) ++fmt;
448 while (*fmt && *fmt !=
']')
453 if (
'%' == *fmt)
break;
456 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
528 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
529 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
531 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
532 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
564 if (
g->GetN() == 0)
return kFALSE;
568 if (
ex == 0 ||
ey == 0 ) {
569 if (
g->IsA() != TGraph::Class() )
570 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
573 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
593 memset(
fEX + begin, 0,
n);
594 memset(
fEY + begin, 0,
n);
604 if (i < 0 || i >=
fNpoints)
return -1;
616 if (i < 0 || i >=
fNpoints)
return -1;
628 if (i < 0 || i >=
fNpoints)
return -1;
640 if (i < 0 || i >=
fNpoints)
return -1;
652 if (i < 0 || i >=
fNpoints)
return -1;
664 if (i < 0 || i >=
fNpoints)
return -1;
680 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
684 int n1 = n0+
g->GetN();
690 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
705 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]);
716 out <<
" " << std::endl;
717 static Int_t frameNumber = 1000;
725 out <<
" Double_t " << fXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
726 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fX[i] <<
"," << std::endl;
727 out <<
" " <<
fX[
fNpoints-1] <<
"};" << std::endl;
728 out <<
" Double_t " << fYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
729 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fY[i] <<
"," << std::endl;
730 out <<
" " <<
fY[
fNpoints-1] <<
"};" << std::endl;
731 out <<
" Double_t " << fEXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
732 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEX[i] <<
"," << std::endl;
733 out <<
" " <<
fEX[
fNpoints-1] <<
"};" << std::endl;
734 out <<
" Double_t " << fEYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
735 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEY[i] <<
"," << std::endl;
736 out <<
" " <<
fEY[
fNpoints-1] <<
"};" << std::endl;
738 if (
gROOT->ClassSaved(TGraphErrors::Class())) out <<
" ";
739 else out <<
" TGraphErrors *";
740 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
741 << fXName <<
"," << fYName <<
","
742 << fEXName <<
"," << fEYName <<
");"
745 out <<
" gre->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
746 out <<
" gre->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
754 hname += frameNumber;
758 out <<
" " << std::endl;
764 while ((obj = next())) {
767 out <<
" gre->GetListOfFunctions()->Add(ptstats);" << std::endl;
768 out <<
" ptstats->SetParent(gre->GetListOfFunctions());" << std::endl;
773 out <<
" " << objname <<
"->SetParent(gre);\n";
775 out <<
" gre->GetListOfFunctions()->Add("
776 << objname <<
");" << std::endl;
780 const char *
l = strstr(option,
"multigraph");
782 out <<
" multigraph->Add(gre," << quote <<
l + 10 << quote <<
");" << std::endl;
784 out <<
" gre->Draw(" << quote << option << quote <<
");" << std::endl;
804 if (dpx * dpx + dpy * dpy < 25) {
809 if (ipoint == -2)
return;
835void TGraphErrors::Streamer(
TBuffer &
b)
841 b.ReadClassBuffer(TGraphErrors::Class(),
this, R__v, R__s, R__c);
863 b.CheckByteCount(R__s, R__c, TGraphErrors::IsA());
867 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
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.
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.
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)