Sorry for the ambiguous question.
My question is how to draw histogram pdf, not histogram. For histogram pdf, there is not Draw
member function.
Alternatively, I found components
argument for plotOn
function. Here is my fixed code:
TFile* f = TFile::Open("test_file.root");
RooWorkspace* w = (RooWorkspace*)f->Get("w");
w->Print();
RooAbsData* data = w->data("obsData");
ModelConfig* sbModel = (ModelConfig*)w->obj("ModelConfig");
RooFitResult* fitres = sbModel->GetPdf()->fitTo(*data);
RooSimultaneous* simPdf = (RooSimultaneous*)sbModel->GetPdf();
TCanvas* cdata = new TCanvas("sPlot", "sPlot demo", 700, 700);
RooPlot* frame = w->var("obs_x_channel")->frame();
data->plotOn(frame, RooFit::DataError(RooAbsData::SumW2));
w->pdf("channel_model")->plotOn(frame, DrawOption("F"), FillColor(kRed));
w->pdf("channel_model")->plotOn(frame, DrawOption("F"), FillColor(kBlue), Components("L_x_signal_sample_channel_overallSyst_x_HistSyst"));
frame->Draw();
However, I found some problem.
For ROOT Version: 6.16/00
, the above fixed code works fine:
red histogram is
Background1
, and blue histogram is Signal
. Though, when I run the same code at ROOT Version: 6.24/00
, It showsblue and red histograms are normalized by the number of data, respectively. I carefully guess it is a bug, because there was a similar bug at past (HistFactory plotting of components broken in ROOT 6.16/00).