How to plot a RooFormulaVar?

What is the advised way to plot a RooFormulaVar, made in this way:

m_ws.factory("expr::dm('@0-@1', {Dstar_M, D0_M})");

Where the inputs are RooRealVars from data.

dataset = new RooDataSet("dm_data", "dm_data", tree, RooArgList(Dstar_M,D0_M));

So far nothing has worked, and there is no information online about how to do this. I have tried this so far:

 RooFormulaVar * dm = (RooFormulaVar*) m_ws.function("dm");
  RooRealVar * dm_plot = (RooRealVar*) dataset->addColumn(*dm);
  RooPlot *fr = dm_plot->frame(RooFit::Bins(50),RooFit::Range(139,160));
  m_dataset->plotOn(fr, RooFit::MarkerSize(0.9));
  fr->Draw()
  ...

But it just produces a blank canvas.

Nevermind, this does actually work.

  RooFormulaVar * dm = (RooFormulaVar*) ws.function("dm");
  RooRealVar * dm_plot = (RooRealVar*) dataset->addColumn(*dm);
  RooPlot *fr = dm_plot->frame(RooFit::Bins(50),RooFit::Range(139,160));
  dataset->plotOn(fr, RooFit::MarkerSize(0.9));
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.