void ex12() { TFile* f = TFile::Open("ex12.root") ; TH1* h_sig = f->Get("h_sig") ; TH1* h_bkg = f->Get("h_bkg") ; TH1* h_data = f->Get("h_data") ; // Create a workspace with observable x[0,120] RooWorkspace w("w",1) ; w.factory("x[0,120]") ; // Tie TF1 h_sig to observable x in RooFit binned dataset dh_sig RooDataHist dh_sig("dh_sig","dh_sig",w::x,h_sig) ; // Import both datasets in the workspace w.import(dh_sig) ; w.factory("HistFunc::hf_sig(x,dh_sig)") ; RooPlot* frame = w.var("x")->frame(); w.function("hf_sig")->plotOn(frame) ; frame->Draw() ; }