Hello,
I use Root version 5.22/00
To plot systematic errors, I was generally using TGraphErrors with P3 drawing
option. This fills the systematic error (plus-minus) region symmetrically
around an offset I determine. Recently, I was asked to plot systematic errors
only as an absolute value (not symmetric around an offset but only from offset
to sysErr value). I tried TGraphAsymmErrors for that purpose, assigning 0
error values for the negative side errors. If I could not express myself,
please take a look at a simple code I wrote to replicate the problem I will
describe.
TGraphAsymmErrors sometime gives erratic fill behavior, it fill places it should not. After a long trial and error, I believe I pinpointed the source of the problem: If the frame's maximum x range is smaller than the array's x range I put into the TGraphAsymmErrors, then I see this behavior. But, I would like my frame's x range to be a variable, to be able to zoom in certain parts, so the frames minimum and maximum x ranges can be smaller or larger than the array's x ranges. But TGraphAsymmErrors does not like that. Maybe I am missing an important piece of information on how to use TGraphAsymmErrors.
I am printing the sample code below to replicate the problem. I will appreciate your help if there is a way around this. Or, you can tell me if there is a better way to plot various systematic error (from offset to sysErrvalue), for various offsets. Thank you very much.
{
double x[15] = {
0.1,0.2,0.3,0.4,0.5, 0.6,0.7,0.8,0.9,1.0 1.1,1.2,1.3,1.4,1.5};
double y[15] = {
0.1,0.2,0.3,0.4,0.3 0.1,0.2,0.3,0.4,0.3 0.1,0.2,0.3,0.4,0.3}; double ySys[15] = { 0.00,0.05,0.06,0.07,0.06, 0.07,0.05,0.00,0.00,0.07, 0.08,0.00,0.00,0.00,0.00}; double yErr[15] = {0.0}; double yOff1[15] = {0.0}; double yOff2[15] = {0.0}; for(int i=0;i<15;i++){ yErr[i] = 0.1; yOff1[i] = -0.8; yOff2[i] = -0.5; }
TCanvas *c1 = new TCanvas("c1","c1",0,0,400,400);
c1->Modified();
c1->Update();
TH1 *frame1 = c1->DrawFrame(0,-1,1,1);
//// above gives erratic fill behavior for sys error
//// because maximum x range is smaller than the value of highest x
//TH1 *frame1 = c1->DrawFrame(0,-1,2,1);
//// this one works fine apparently
frame1->GetXaxis()->SetTitle("x"); frame1->GetXaxis()->CenterTitle(); frame1->GetYaxis()->SetTitle("y"); frame1->GetYaxis()->CenterTitle();
TGraphErrors *TG1 = new TGraphErrors(15,x,y,xErr,yErr);
TG1->SetMarkerColor(kRed); TG1->SetLineColor(kRed); TG1->SetMarkerStyle(20); TG1->Draw("P");
//// this draws sys symmetrically around the offset
TGraphErrors *TG2 = new TGraphErrors(15,x,yOff1,xErr,ySys);
TG2->SetMarkerColor(kBlue); TG2->SetFillColor(kBlue); TG2->Draw("P3");
//// this draws sys one sided from offset to up
//// this is what we want
TGraphAsymmErrors *TG3 = new TGraphAsymmErrors(15,x,yOff2,0,xErr,0,ySys);
TG3->SetMarkerColor(kRed); TG3->SetFillColor(kRed); TG3->Draw("P3");
} Received on Tue Nov 03 2009 - 03:41:46 CET
This archive was generated by hypermail 2.2.0 : Tue Nov 03 2009 - 11:50:03 CET