A question about Roounfolding way

Dear experts,

I am using the iterative (“Bayesian”) method based on the Roounfolding package to do unfolding for my analysis, and I already filled the response matrix R by response = ROOT.RooUnfoldResponse (hMeas, hTrue),

but now I want to do the backfolding test, which means I should get the R^(-1), I was wondering is there a way to get R^(-1) directly if I already have R prepared? Otherwise should I get the R^(-1) by filling it again with response = ROOT.RooUnfoldResponse (hTrue, hMeas)?

Thanks in advance.


I think @jonas can help

OK, @jonas

RooUnfold is a separate package which is not part of ROOT.
There is a support mailing list with the link provided in the RooUnfold page:


1 Like

I know there is a mail list, but since I didn’t get any reply from there, so I want to know if there are some experts know that in this forum.

Hi! As far as I see it on the GitLab history, the maintainer of RooUnfold is @cburgard. Let’s invite him here, maybe he can help.


Hi Jen!
Thanks @jonas for tagging me.
Indeed RooUnfold is a comparatively small project, and experts are usually in high demand - so sorry for dropping the ball on your question.

As for the matter at hand: the way in which the unfolding is done depends very much on the method you use. In principle, not all methods even need to have an “inverse migration matrix”, since whether the computation is done as a matrix or in a different way is very much up to the method.
Strictly speaking, R^-1 is only available for RooUnfoldInvert, which is the unregularized matrix-inversion method.
You are in luck though, because RooUnfoldBayes does provide a method called “UnfoldingMatrix”, which gives you back a matrix that is used to propagate the errors between the folded and the unfolded space - depending on what you’re trying to do, this might be just what you need.
In general, it would be interesting to understand what you’re trying to achieve, as the inverse of the folding matrix is strictly speaking only related to your unfolding method when you use RooUnfoldInvert.

Please feel free to follow up with further questions.

Hi Carsten,

Thanks for your reply.

So for the UnfoldingMatrix, will it give you the inverse of a matrix? I have the response matrix and want to get it inverse matrix now. Could you show me an example code how to do it?


Dear Carsten,

And what I am trying to achieve, is that I want to do backfolding test.

I already filled the response matrix R by
response = ROOT.RooUnfoldResponse (hMeas, hTrue),
and then as a closure test, I use Bayes method to do the unfolding to get the hTrue

unfold= ROOT.RooUnfoldBayes (response, hMeas, 1);

which is succeeded.

Then I want to do another test, which is use the inverse of the matrix and hGen to get hMeas, ie the backfolding test.

So I need to get the inverse of the matrix.

Or do you know any other way to do backfolding in the roounfolding?



HI Jen!

Okay, so then what you are looking for is not the inverse matrix, but rather the original (“forward”) folding matrix.

That can be easily retrieved from the response itself:

I hope this helps,


Hi Carsten,

Thanks for your reply. It helps a lot.

So I tried both :

hMresponse = response.Mresponse ();

hUMatrix = unfold.UnfoldingMatrix ();

and they give different matrix. What’s the difference between these two ways?



They are roughly inverses of one another.
hMresponse is the response matrix, e.g. the matrix that maps your unfolded space to your folded space. Depending on whether you put true or false as an argument, you will receive the normalized or non-normalized version.
hUMatrix is then the regularized unfolding matrix, that is, it’s basically the regularized form of the inverse of the matrix you get when you do Mresponse(true).

I hope this helps.


Hi Castern,

so I tried

hMresponseT = response.Mresponse (true);

but it shows:
NameError: name ‘true’ is not defined


true is the c++ syntax, in python you should say True

True also doesn’t work.

Traceback (most recent call last):
File “examples/RooUnfoldExample_pro2_zpt_test.py”, line 88, in
hMresponseT = response.Mresponse (True); #Response matrix true
TypeError: const TMatrixT& RooUnfoldResponse::Mresponse() =>
takes at most 0 arguments (1 given)

Are you sure you are using the latest version of RooUnfold?

Hi, the latest version works. Thanks a lot.


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