void drawSystErrors(TH1* h, Float_t err, Int_t style=0, Int_t color=16) { // cap sizes Float_t dx = 0.03; Float_t dy = 0.006; TGraph* band1 = new TGraph(); TGraph* band2 = new TGraph(); Int_t p=0; for (Int_t b=1; bGetNbinsX(); b++) { Float_t w = h->GetBinWidth(b); Float_t x = h->GetBinCenter(b); Float_t y = h->GetBinContent(b); Float_t ye = h->GetBinError(b); Float_t x1 = x+dx; Float_t x2 = x-dx; Float_t y1 = y+TMath::Sqrt(ye*ye + y*err*y*err); Float_t y2 = y-TMath::Sqrt(ye*ye + y*err*y*err); if (ye==0 && y==0) continue; // boxes if (style==0||style==1) { TBox* box; if(style==0) box = new TBox(x-0.5*w,y+y*err,x+0.5*w,y-y*err); box->SetFillColor(color); box->SetLineColor(color); box->SetFillStyle(1001); box->Draw(); } // caps if (style==2) { TLine* lu = new TLine(x1,y1,x2,y1); TLine* ll = new TLine(x1,y2,x2,y2); lu->Draw(); ll->Draw(); TLine* lu1 = new TLine(x1,y1,x1,y1-dy); TLine* lu2 = new TLine(x2,y1,x2,y1-dy); lu1->Draw(); lu2->Draw(); TLine* ll1 = new TLine(x1,y2,x1,y2+dy); TLine* ll2 = new TLine(x2,y2,x2,y2+dy); ll1->Draw(); ll2->Draw(); } // bands if (style==3||style==4) { band1->SetPoint(p,x,y1); band2->SetPoint(p,x,y2); p++; } } if (style==3||style==4) { band1->SetLineColor(color); band2->SetLineColor(color); band1->SetFillColor(color); band2->SetFillColor(color); TGraph* band= new TGraph(2*p); band->SetLineColor(color); band->SetFillColor(color); for (Int_t i=0; iGetPoint(i,xval,yval); band->SetPoint(i,xval,yval); band2->GetPoint(i,xval,yval); band->SetPoint(2*p-i-1,xval,yval); } if (style==3) { band1->Draw(); band2->Draw(); } else band->Draw("f"); } } void drawSystErrors(TGraphAsymmErrors* g, Float_t err, Int_t style=0, Int_t color=16, Bool_t c=kFALSE) { // cap sizes Float_t dx = 0.03; Float_t dy = 0.006; TGraph* band1 = new TGraph(); TGraph* band2 = new TGraph(); Int_t p=0; for (Int_t b=0; bGetN(); b++) { Double_t x = g->GetX()[b]; Double_t y = g->GetY()[b]; Double_t xh = x + g->GetEXhigh()[b]; Double_t xl = x - g->GetEXlow()[b]; Double_t yh = y + g->GetEYhigh()[b]; Double_t yl = y - g->GetEYlow()[b]; if (c) { yh = y+TMath::Sqrt((g->GetEYhigh()[b]*g->GetEYhigh()[b])+(y*err*y*err)); yl = y-TMath::Sqrt((g->GetEYlow()[b]*g->GetEYlow()[b]) +(y*err*y*err)); } // boxes if (style==0) { TBox* box = new TBox(xl,yl,xh,yh); box->SetFillColor(color); box->SetLineColor(color); box->SetFillStyle(1001); box->Draw(); } // bands if (style==1||style==2) { band1->SetPoint(p,x,yl); band2->SetPoint(p,x,yh); p++; } } if (style==1||style==2) { band1->SetLineColor(color); band2->SetLineColor(color); band1->SetFillColor(color); band2->SetFillColor(color); TGraph* band= new TGraph(2*p); band->SetLineColor(color); band->SetFillColor(color); for (Int_t i=0; iGetX()[i]; band->SetPoint(i,band1->GetX()[i],band1->GetY()[i]); band->SetPoint(2*p-i-1,band2->GetX()[i],band2->GetY()[i]); } if (style==1) { band1->Draw(); band2->Draw(); } else band->Draw("f"); } }