Central Values and error from RooFit

Hello,

I am trying to figure out how to print out specific central values from bins in RooFit. As in I have

TH1F* h1001;  //data
TH1F* h2001;  //background estimation 1
TH1F* h2002;  //background estimation 1

RooRealVar x("x","x",-8,2);
RooDataHist data("data","data",x,h1001);
RooDataHist bg1("bg1","bg1",x,h2001);
RooDataHist bg2("bg2","bg2",x,h2002);

RooHistPdf bg1Pdf("bg1Pdf","bg1Pdf",x,bg1);     
RooHistPdf bg2Pdf("bg2Pdf","bg2Pdf",x,bg2);

RooRealVar Nbg1("Nbg1","Nbg1",1000000,0,10000000);
RooRealVar Nbg2("Nbg2","Nbg2",650000,0,5000000);

RooAddPdf sum("sum","sum", RooArgSet(bg1Pdf,bg2Pdf), RooArgSet(Nbg1,Nbg2));

RooFitResult fit = sum.fitTo(data,Extended());

is there anyway to retrieve the value of a specific bin with it’s error after the fit similarly to something like

TH1F*h1001;
Int_t bin;
cout<<h1001->GetBinContent(bin)<<endl;
cout<<h1001->GetBinError(bin)<<endl;

Thanks for any help,
George Bassett

HI,

The easiest solution is to plot your data set in a RooPLot and then retrieve the RooHist object which is a TGraphError.
So in your example:

RooPlot * pl = x.frame(); 
data.plotOn(pl); 
RooHist * g = (RooHIst*) pl->getObject(0);

and then you can retrieve each value and error as

double pointValue = g->GetX()[bin];
double pointError = g->GetErrorY(bin);

Best Regards

Lorenzo