RooFit problems

I have two problems with RooFit that I can’t figure out myself:
a) I have a RooMCStudy object created with an extended pdf and a conditional observable. Using generateAndFit gives me nice pull distributions.
However, using fit(int, char*) just leaves the yields at their initial values and simply computes an error matrix without adjusting any parameters.

b) Using AbsPdf::generate, I get many events that are outside of the allowed range of the AbsPdf variables. So I have one variable with a range of 0-0.55, but several entries in the DataSet I get with AbsPdf::generate are larger than 0.55. The Pdf is a RooProdPdf with a conditional observable.

I want to avoid packing my whole current setup, but I’d be happy to supply more specific information and macros.


I hope that Wouter will answer your mail soon.


Hi Jan,

I suspect this is related to ConditionalObservables(). I need
to be able to reproduce this to understand what is going on.

As a first iteration, send me a few more details on the p.d.f that you are using and how exactly you’re invoking the functions mentioned


Hi Wouter,

I suspect you’re right.
I have a 4d fit. One of the pdfs needs a conditional observable.

I build my 4d model with a RooProdPdf. Using the RooFit::Conditional parameter. Just to make sure: It takes the pdf and the variables that are supposed to be normalized, unlike ConditionalObservables, which takes the Variables that are not normalized, right?

Then I have five components, each a 4d RooProdPdf, but only one of them is created with the aforementioned Conditional parameter.
I add them in a RooAddPdf.

I create a RooMCStudy:

RooMCStudy manager(bf.pdf
                     , bf.observables.getAllObservables()
                     , RooFit::FitOptions(RooFit::Extended(kTRUE)
                                        , RooFit::Minos(kFALSE)
                                        , RooFit::Save(kTRUE)
                                        , RooFit::ConditionalObservables(bf.observables.endpoint)
                                        , RooFit::ProtoData(*dataset, kTRUE)
                                        , RooFit::InitialHesse(kTRUE))
                     , RooFit::Extended(kTRUE)
                     , RooFit::ConditionalObservables(bf.observables.endpoint)
                     , RooFit::ProtoData(*dataset, kTRUE)

And call it with the following lines:

// This gives reasonable pulls
//manager.generateAndFit(1000, 5200+120+140+20+20, kTRUE, “work/”);
// this doesn’t, “EmbeddedToys/”);

I think I found the source of the generate problem. I have a dataset that contains RooRealVars with the same names as the dependent variables of my pdf and it appears that RooFit takes all variables from the dataset instead of only the ones that are not part of the RooArgSet parameter to RooAbsPdf::generate.
(The variables have the same names, but different labels, maybe that’s the reason?)
Changing the var names in my pdf then creates of course a larger dataset, but it appears that the vars generated from the pdf are indeed within the specified range.

I am using ROOT 5.14e with the default version of RooFit (2.10).

Please let me know if you need more information.


Hi Jan,

I think what you do is OK. Your use of ConditionalObservables
is correct to answer you first question.

The fact that the variables in the dataset do have the same name as the ones should not be a problem, they should be overwritten if they are requested to be generated. But your observation might hold a clue to what goes wrong: Perhaps somethings doesn’t work right in the combination with ConditionalObservables(). I need to run a few checks myself to see if I can understand what’s happening. (May take a 1-2 days,
this is a busy week for me)


Hi Wouter,

did you have a chance to find out, what the problem could be?
I am getting a ERROR: unrecognized command: ProjectedObservables.
I don’t understand that. Nowhere in my source does this term appear.

I am also getting a warning about accept/reject not being accurate in 4d.

Taking out the variable with the conditional observable gives me pulls that are just fine, even on embedded toys. (Both 3d and 4d pure toys are fine)

I really don’t understand what’s going on at all…
Any insight you can provide here is appreciated.

Hi Jan,

Sorry, I had more or less back-to-back meetings (dutch atlas,
atlas trigger & physics) that kept me out of the office nearly
2 weeks straight. Your problem is not so simple , so I need a free afternoon to debug it. This week looks pretty good as I need to work
on RooFit anyway.


Hi Wouter,
any updates on this?