99 for (
Int_t i = 0; i <
n; i++) {
120 else memset(
fEX, 0,
n);
122 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);
154 :
TGraph(
TMath::
Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
160 fEX[i] = vex(i + ivexlow);
161 fEY[i] = vey(i + iveylow);
210 fEY[i] =
h->GetBinError(i + 1);
238 std::ifstream infile(fname.
Data());
239 if (!infile.good()) {
241 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie", filename);
248 if (strcmp(option,
"") == 0) {
252 while (std::getline(infile,
line,
'\n')) {
255 res = sscanf(
line.c_str(), format, &
x, &
y);
256 }
else if (ncol < 4) {
257 res = sscanf(
line.c_str(), format, &
x, &
y, &
ey);
259 res = sscanf(
line.c_str(), format, &
x, &
y, &
ex, &
ey);
281 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
286 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
289 Int_t ntokensToBeSaved = 0 ;
291 for (
Int_t idx = 0; idx < ntokens; idx++) {
293 if (isTokenToBeSaved[idx] == 1) {
297 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
298 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
299 delete [] isTokenToBeSaved ;
305 char * token = NULL ;
307 Int_t token_idx = 0 ;
309 for (
Int_t k = 0; k < 4; k++) {
312 Int_t value_idx = 0 ;
316 while (std::getline(infile,
line,
'\n')) {
318 if (
line[
line.size() - 1] ==
char(13)) {
322 while (token != NULL && value_idx < ntokensToBeSaved) {
323 if (isTokenToBeSaved[token_idx]) {
327 isLineToBeSkipped =
kTRUE ;
330 value[value_idx] = token_str.
Atof() ;
337 if (!isLineToBeSkipped && value_idx > 1) {
347 isLineToBeSkipped =
kFALSE ;
355 delete [] isTokenToBeSaved ;
412 while ((fmt = strchr(fmt,
'%'))) {
416 if (*++fmt &&
'^' == *fmt) ++fmt;
417 if (*++fmt &&
']' == *fmt) ++fmt;
418 while (*fmt && *fmt !=
']')
423 if (
'%' == *fmt)
break;
426 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
498 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
499 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
501 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
502 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
534 if (
g->GetN() == 0)
return kFALSE;
538 if (
ex == 0 ||
ey == 0 ) {
540 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
543 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
563 memset(
fEX + begin, 0,
n);
564 memset(
fEY + begin, 0,
n);
574 if (i < 0 || i >=
fNpoints)
return -1;
586 if (i < 0 || i >=
fNpoints)
return -1;
598 if (i < 0 || i >=
fNpoints)
return -1;
610 if (i < 0 || i >=
fNpoints)
return -1;
622 if (i < 0 || i >=
fNpoints)
return -1;
634 if (i < 0 || i >=
fNpoints)
return -1;
650 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
654 int n1 = n0+
g->GetN();
660 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
675 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]);
686 out <<
" " << std::endl;
687 static Int_t frameNumber = 1000;
695 out <<
" Double_t " << fXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
696 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fX[i] <<
"," << std::endl;
697 out <<
" " <<
fX[
fNpoints-1] <<
"};" << std::endl;
698 out <<
" Double_t " << fYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
699 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fY[i] <<
"," << std::endl;
700 out <<
" " <<
fY[
fNpoints-1] <<
"};" << std::endl;
701 out <<
" Double_t " << fEXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
702 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEX[i] <<
"," << std::endl;
703 out <<
" " <<
fEX[
fNpoints-1] <<
"};" << std::endl;
704 out <<
" Double_t " << fEYName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
705 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fEY[i] <<
"," << std::endl;
706 out <<
" " <<
fEY[
fNpoints-1] <<
"};" << std::endl;
709 else out <<
" TGraphErrors *";
710 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
711 << fXName <<
"," << fYName <<
","
712 << fEXName <<
"," << fEYName <<
");"
715 out <<
" gre->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
716 out <<
" gre->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
724 hname += frameNumber;
728 out <<
" " << std::endl;
734 while ((obj = next())) {
737 out <<
" gre->GetListOfFunctions()->Add(ptstats);" << std::endl;
738 out <<
" ptstats->SetParent(gre->GetListOfFunctions());" << std::endl;
743 out <<
" " << objname <<
"->SetParent(gre);\n";
745 out <<
" gre->GetListOfFunctions()->Add("
746 << objname <<
");" << std::endl;
750 const char *
l = strstr(option,
"multigraph");
752 out <<
" multigraph->Add(gre," << quote <<
l + 10 << quote <<
");" << std::endl;
754 out <<
" gre->Draw(" << quote << option << quote <<
");" << std::endl;
774 if (dpx * dpx + dpy * dpy < 25) {
779 if (ipoint == -2)
return;
805void TGraphErrors::Streamer(
TBuffer &
b)
833 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.
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 Graph is a graphics 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)