23 ClassImp(TGraph2DErrors);
84 TGraph2DErrors::TGraph2DErrors(): TGraph2D()
96 TGraph2DErrors::TGraph2DErrors(Int_t n)
100 Error(
"TGraph2DErrors",
"Invalid number of points (%d)", n);
104 fEX =
new Double_t[n];
105 fEY =
new Double_t[n];
106 fEZ =
new Double_t[n];
108 for (Int_t i=0;i<n;i++) {
119 TGraph2DErrors::TGraph2DErrors(Int_t n, Double_t *x, Double_t *y, Double_t *z,
120 Double_t *ex, Double_t *ey, Double_t *ez, Option_t *)
121 :TGraph2D(n, x, y, z)
124 Error(
"TGraphErrors",
"Invalid number of points (%d)", n);
128 fEX =
new Double_t[n];
129 fEY =
new Double_t[n];
130 fEZ =
new Double_t[n];
132 for (Int_t i=0;i<n;i++) {
133 if (ex) fEX[i] = ex[i];
135 if (ey) fEY[i] = ey[i];
137 if (ez) fEZ[i] = ez[i];
146 TGraph2DErrors::~TGraph2DErrors()
157 TGraph2DErrors::TGraph2DErrors(
const TGraph2DErrors &g)
158 : TGraph2D(g), fEX(0), fEY(0), fEZ(0)
161 fEX =
new Double_t[fSize];
162 fEY =
new Double_t[fSize];
163 fEZ =
new Double_t[fSize];
164 for (Int_t n = 0; n < fSize; n++) {
176 TGraph2DErrors & TGraph2DErrors::operator=(
const TGraph2DErrors &g)
178 if (
this == &g)
return *
this;
181 this->TGraph2D::operator=(static_cast<const TGraph2D&>(g) );
184 if (fEX)
delete [] fEX;
185 if (fEY)
delete [] fEY;
186 if (fEZ)
delete [] fEZ;
188 fEX = (fSize > 0) ?
new Double_t[fSize] : 0;
189 fEY = (fSize > 0) ?
new Double_t[fSize] : 0;
190 fEZ = (fSize > 0) ?
new Double_t[fSize] : 0;
194 for (Int_t n = 0; n < fSize; n++) {
205 Double_t TGraph2DErrors::GetErrorX(Int_t i)
const
207 if (i < 0 || i >= fNpoints)
return -1;
208 if (fEX)
return fEX[i];
217 Double_t TGraph2DErrors::GetErrorY(Int_t i)
const
219 if (i < 0 || i >= fNpoints)
return -1;
220 if (fEY)
return fEY[i];
229 Double_t TGraph2DErrors::GetErrorZ(Int_t i)
const
231 if (i < 0 || i >= fNpoints)
return -1;
232 if (fEZ)
return fEZ[i];
240 Double_t TGraph2DErrors::GetXmaxE()
const
242 Double_t v = fX[0]+fEX[0];
243 for (Int_t i=1; i<fNpoints; i++) if (fX[i]+fEX[i]>v) v=fX[i]+fEX[i];
251 Double_t TGraph2DErrors::GetXminE()
const
253 Double_t v = fX[0]-fEX[0];
254 for (Int_t i=1; i<fNpoints; i++)
if (fX[i]-fEX[i]<v) v=fX[i]-fEX[i];
262 Double_t TGraph2DErrors::GetYmaxE()
const
264 Double_t v = fY[0]+fEY[0];
265 for (Int_t i=1; i<fNpoints; i++) if (fY[i]+fEY[i]>v) v=fY[i]+fEY[i];
273 Double_t TGraph2DErrors::GetYminE()
const
275 Double_t v = fY[0]+fEY[0];
276 for (Int_t i=1; i<fNpoints; i++)
if (fY[i]-fEY[i]<v) v=fY[i]-fEY[i];
284 Double_t TGraph2DErrors::GetZmaxE()
const
286 Double_t v = fZ[0]+fEZ[0];
287 for (Int_t i=1; i<fNpoints; i++) if (fZ[i]+fEZ[i]>v) v=fZ[i]+fEZ[i];
295 Double_t TGraph2DErrors::GetZminE()
const
297 Double_t v = fZ[0]+fEZ[0];
298 for (Int_t i=1; i<fNpoints; i++)
if (fZ[i]-fEZ[i]<v) v=fZ[i]-fEZ[i];
306 void TGraph2DErrors::Print(Option_t *)
const
308 for (Int_t i = 0; i < fNpoints; i++) {
309 printf(
"x[%d]=%g, y[%d]=%g, z[%d]=%g, ex[%d]=%g, ey[%d]=%g, ez[%d]=%g\n", i, fX[i], i, fY[i], i, fZ[i], i, fEX[i], i, fEY[i], i, fEZ[i]);
318 void TGraph2DErrors::Set(Int_t n)
321 if (n == fNpoints)
return;
322 if (n > fNpoints) SetPointError(n,0,0,0);
330 void TGraph2DErrors::SetPoint(Int_t i, Double_t x, Double_t y, Double_t z)
335 Double_t *savex =
new Double_t[i+1];
336 Double_t *savey =
new Double_t[i+1];
337 Double_t *savez =
new Double_t[i+1];
338 Double_t *saveex =
new Double_t[i+1];
339 Double_t *saveey =
new Double_t[i+1];
340 Double_t *saveez =
new Double_t[i+1];
342 memcpy(savex, fX, fNpoints*
sizeof(Double_t));
343 memcpy(savey, fY, fNpoints*
sizeof(Double_t));
344 memcpy(savez, fZ, fNpoints*
sizeof(Double_t));
345 memcpy(saveex,fEX,fNpoints*
sizeof(Double_t));
346 memcpy(saveey,fEY,fNpoints*
sizeof(Double_t));
347 memcpy(saveez,fEZ,fNpoints*
sizeof(Double_t));
349 if (fX)
delete [] fX;
350 if (fY)
delete [] fY;
351 if (fZ)
delete [] fZ;
352 if (fEX)
delete [] fEX;
353 if (fEY)
delete [] fEY;
354 if (fEZ)
delete [] fEZ;
372 void TGraph2DErrors::SetPointError(Int_t i, Double_t ex, Double_t ey, Double_t ez)
377 TGraph2DErrors::SetPoint(i,0,0,0);
388 void TGraph2DErrors::Streamer(TBuffer &b)
392 Version_t R__v = b.ReadVersion(&R__s, &R__c);
393 b.ReadClassBuffer(TGraph2DErrors::Class(),
this, R__v, R__s, R__c);
395 b.WriteClassBuffer(TGraph2DErrors::Class(),
this);