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')) {
260 }
else if (ncol < 4) {
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 =
nullptr;
313 for (
Int_t k = 0; k < 4; k++)
319 while (std::getline(infile,
line,
'\n')) {
321 if (
line[
line.size() - 1] ==
char(13)) {
324 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()),
option, &rest);
325 while (token !=
nullptr && value_idx < ntokensToBeSaved) {
326 if (isTokenToBeSaved[token_idx]) {
330 isLineToBeSkipped =
kTRUE ;
337 token = R__STRTOK_R(
nullptr,
option, &rest);
340 if (!isLineToBeSkipped && value_idx > 1) {
350 isLineToBeSkipped =
kFALSE;
358 delete [] isTokenToBeSaved;
444 while ((fmt = strchr(fmt,
'%'))) {
448 if (*++fmt &&
'^' == *fmt) ++fmt;
449 if (*++fmt &&
']' == *fmt) ++fmt;
450 while (*fmt && *fmt !=
']')
455 if (
'%' == *fmt)
break;
458 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
530 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
531 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
533 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
534 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
567 if (
g->GetN() == 0)
return kFALSE;
571 if (
ex ==
nullptr ||
ey ==
nullptr) {
573 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
576 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
596 memset(
fEX + begin, 0,
n);
597 memset(
fEY + begin, 0,
n);
606 if (i < 0 || i >=
fNpoints)
return -1;
617 if (i < 0 || i >=
fNpoints)
return -1;
629 if (i < 0 || i >=
fNpoints)
return -1;
641 if (i < 0 || i >=
fNpoints)
return -1;
653 if (i < 0 || i >=
fNpoints)
return -1;
665 if (i < 0 || i >=
fNpoints)
return -1;
681 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
685 int n1 = n0+
g->GetN();
691 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
706 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;
720 auto fXName =
SaveArray(out,
"fx", frameNumber,
fX);
721 auto fYName =
SaveArray(out,
"fy", frameNumber,
fY);
728 out <<
" TGraphErrors *";
729 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
730 << fXName <<
"," << fYName <<
","
731 << fEXName <<
"," << fEYName <<
");"
764 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
778 if (dpx * dpx + dpy * dpy < 25) {
783 if (ipoint == -2)
return;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Buffer base class used for serializing objects.
Collection abstract base class.
A TGraphErrors is a TGraph with error bars.
void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Compute range.
Double_t GetErrorY(Int_t bin) const override
It returns the error along Y at point i.
Double_t * GetEX() const override
Double_t GetErrorX(Int_t bin) const override
It returns the error along X at point i.
Double_t * fEY
[fNpoints] array of Y errors
~TGraphErrors() override
TGraphErrors default destructor.
void Scale(Double_t c1=1., Option_t *option="y") override
Multiply the values and errors of a TGraphErrors by a constant c1.
static Int_t CalculateScanfFields(const char *fmt)
Calculate scan fields.
void Streamer(TBuffer &) override
Stream an object of class TGraphErrors.
void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE) override
Set zero values for point arrays in the range [begin, end].
Double_t * fEX
[fNpoints] array of X errors
void Print(Option_t *chopt="") const override
Print graph and errors values.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
Bool_t DoMerge(const TGraph *g) override
Protected function to perform the merge operation of a graph with errors.
Double_t * GetEY() const override
void SwapPoints(Int_t pos1, Int_t pos2) override
Swap points.
virtual void ApplyX(TF1 *f)
Apply function to all the data points .
Double_t GetErrorXhigh(Int_t bin) const override
It returns the error along X at point i.
Double_t GetErrorYlow(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const override
It returns the error along Y at point i.
TGraphErrors & operator=(const TGraphErrors &gr)
TGraphErrors assignment operator.
Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy errors from fEX and fEY to arrays[0] and arrays[1] or to fEX and fEY if arrays == 0 and ibegin !...
TClass * IsA() const override
Int_t Merge(TCollection *list) override
Adds all graphs with errors from the collection to this graph.
void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy and release.
TGraphErrors()
TGraphErrors default constructor.
Double_t GetErrorXlow(Int_t bin) const override
It returns the error along X at point i.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Apply(TF1 *f) override
Apply function to all the data points .
Bool_t CtorAllocate()
Constructor allocate.
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
void SaveHistogramAndFunctions(std::ostream &out, const char *varname, Int_t &frameNumber, Option_t *option)
Save histogram and list of functions of TGraph as C++ statement Used in all TGraph-derived classes.
TH1F * fHistogram
Pointer to histogram used for drawing axis.
Double_t * fY
[fNpoints] array of Y points
TString SaveArray(std::ostream &out, const char *suffix, Int_t frameNumber, Double_t *arr)
Save array as C++ code Returns name of created array.
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.
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
void Streamer(TBuffer &) override
Stream an object of class TGraph.
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.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
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.
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)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.