Y Value of a point in TGraph or TGraphErrors?

Hi all. I’ve stored an analysis result in a TGraphErrors object, and I want to step over a subset of the points in it to calculate the mean of that subset. I think that if I just wanted to do the entire TGraphErrors, I could just use the GetMean() function passing it a 2 to get the average over the y axis. Unfortunately I need to skip over the first few points in the graph and capture the asymptotic behavior. Does anyone know how to pick out the values of a few specific points like this? I’m thinking this has to look something like: Graph->GetPointYValue(n), but I can’t seem to find anything in the Reference Guide. Any suggestions?


Vic Gehman

see example below


   TCanvas *c1 = new TCanvas("c1","gerrors2",200,10,700,500);

   const Int_t n = 10;
   Double_t x[]  = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
   Double_t y[]  = {1,2.9,5.6,7.4,9,9.6,9.7,9.75,9.78,9.80};
   Double_t ex[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
   Double_t ey[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
   TGraphErrors *gr = new TGraphErrors(n,x,y,ex,ey);
   //compute mean value in Y of the last 6 points
   Double_t ymean = TMath::Mean(6,gr->GetY()+n-6);

That did it! Thank you for your help.


Vic Gehman