Convert RooPlot to TH1 histogram

Dear Experts,

I’d like to know is there any way to convert RooPlot to TH1? I need the distribution of a variable like

RooRealVar particlePt(“particlePt”,“FirstPt”, 1.0, 99.);

TCanvas * c8=new TCanvas(“c8”,“c8”,800,600);
RooPlot* frame1 = particlePt.frame();
dataSetS->plotOn(frame1);

I need to save particlePt variable as TH1F. Thanks in advance.

I thin if you save your RooPLot Canavs as a .C file you will get that.