thspeer
September 16, 2010, 6:48am
1
Hello,
I am plotting several things in a RooPlot (see below: data, signal and background pdf), and would need to put a legend on that plot. I could not find any hint on how to do that. Would anybody have a recipe?
Thanks!
Thomas.
RooPlot* frame3 = topMass->frame(Bins(20),Title(“Mass distribution MM”)) ;
data->plotOn(frame3,Cut(“sample==sample::MM”), DrawOption(“ZpE”)) ;
pdffit->plotOn(frame3,Components(“model”),ProjWData(*sample,*data)) ;
pdffit->plotOn(frame3,Components(“signal”),ProjWData(*sample,*data),LineStyle(kDotted)) ;
pdffit->plotOn(frame3,Components(“background”),ProjWData(*sample,*data),LineStyle(kDashed) ) ;
Bruno
September 23, 2010, 8:42am
2
Hi Thomas
This is how I create a legend:
data->plotOn(xframe_tmp,Name("data"));
model->plotOn(xframe_tmp,Name("signal only"),Components(RooArgList(sig1,psip)),LineColor(kRed),Range(
2.0,5.0));
model->plotOn(xframe_tmp,Name("model"),Range(2,5.0));
model->plotOn(xframe_tmp,Name("background"),Components(RooArgList(bkg_exp,bkg_exp3)),LineStyle(kDashed),Range(2,5.0));
TLegend *leg1 = new TLegend(0.65,0.73,0.86,0.87);
leg1->SetFillColor(kWhite);
leg1->SetLineColor(kWhite);
leg1->AddEntry("data","Data", "P");
leg1->AddEntry("model","Signal + background","LP");
leg1->AddEntry("background","Background only", "LP");
leg1->AddEntry("signal only","Signal only", "LP");
leg1->Draw();