Using RooUnfoldspec class

Dear experts,

I am using RooUnfold for implementing Iterative Bayesian unfolding. I recently came across the RooUnfoldspec (tutorial) and had some basic questions regarding that:

  1. How exactly should I fill my response?
    I have two separate ROOT files and here is what I have in mind: I should filter the events based on eventnumber and runnumber from reco and true level, fill a th2d with those events and this will be my migration matrix. I feel that I still need correction factors (acceptance and efficiency). Should my response be equal to R = (eff * migration)/acc? and will this response be one of the inputs in RooUnfoldspec object?

  2. Do I need an UnfoldingMatrix under RooUnfoldBayes while using RooUnfoldspec? If yes, how should I make use of it.


Hello Nilima,

RooUnfold is not part of ROOT. @vcroft is the author of this tutorial. He might be able to answer to you. You might also try to contact him directly

Best regards



Thank you for your reply. I found a RooUnfold support thread to which I emailed my issue.


Hi Nilima, thanks for reaching out. Since RooUnfold isn’t (yet) part of root proper we have a mailing list,

Answering question 2 first:
the RooUnfoldSpec is defined as:

spec = ROOT.RooUnfoldSpec("unfold", "unfold",

where the last two arguments are “includeUnderflow” which is false (otherwise the underflow would be included as a regular bin and unfolded alongside the others), and “-1” (threshold for pruning systematics, negative numbers mean “don’t prune”).

You use this as:

unfolding = spec.makeFunc(ROOT.RooUnfolding.kBayes, 4)
unfolded = unfolding.unfolding()

This performs the unfolding as described in the tutorial. With a vector representing the unfolded distribution given by:

Vunfolded = unfolded.Vunfold()

ok moving back to question 1. indeed the response histogram used in the definition above is typically a TH2D filled with matched truth and reco events. Acceptance/Efficiency is taken into account by necessitating the truth histogram which doesn’t have to be just the marginal distribution of the response. Similarly events that are expected in the measured distribution but aren’t included in the response are either subtracted from the data or included in the ‘recoBkgHist’ histogram. Nothing fancy is required, you just need your histograms as you would expect.

Some of these issues are also discussed in the slightly newer tutorial here but also in the tutorial that you reference. There are updated versions of all of these tutorials that are in progress that are evolving over these months so hopefully things will be a little more stable and better documented soon!

I hope this helps!

Dear Vincent,

Thank you very much for your detailed answer. It made things much clearer now. We tried constructing the spec object in the way you mentioned and the unfolded distribution indeed matches with the truth!

I was wondering now how to propagate the uncertainties to the unfolded distribution. One of the ways would be to have a covariance matrix or toy experiments but I was curious to know if there are any developments concerning RooUnfoldspec object and uncertainties?

P.S. Sorry for the late reply

no problem.

With the above code the options are as:

errors_vec = unfolded.EunfoldV(ROOT.RooUnfolding.kErrorsToys)

I think there’s also an option ROOT.RooUnfolding.kCov but I’m not 100% sure.

Thank you! I will try this