RooCategory in RooMCStudy

Hi all,

the very same code that I have been using successfully in ROOT 5.28 (RooFit 3.17?) now crashes with ROOT 5.32 (RooFit 3.50) :

roughly, the code is designed as following :

  RooRealVar Nsig,Nbck,x,y,z,u,v;

  RooCategory cat("cat","Number of X");
  cat.defineType("N0", 0);
  cat.defineType("N1", 1);
  cat.defineType("N2",2);

  // C o n s t r u c t   f o r m u l a s
  // -------------------------------------------------------------------------------
  
  RooFormulaVar formula_0_1("formula_0_1","formula_0_1","some formula f(x,y,z)",RooArgList(x,y,z));
  RooFormulaVar formula_0_2("formula_0_2","formula_0_2","some formula f'(x,y,z)",RooArgList(x,y,z));

  RooFormulaVar formula_1_1("formula_1_1","formula_1_1","some formula f''(u,v,z)",RooArgList(u,v,z));
  RooFormulaVar formula_1_2("formula_1_2","formula_1_2","some formula f'''(u,v,z)",RooArgList(u,v,z));

  // C o n s t r u c t   p . d . f 's
  // -------------------------------------------------------------------------------

  RooGenericPdf pdf_0("pdf_0","pdf_0","(cat==0)*formula_0_1+(cat==1)*formula_0_2",RooArgList(cat,formula_0_1,formula_0_2));
  RooExtendPdf  pdf_0_ext("pdf_0_ext","pdf_0_ext",pdf_0,Nsig);

  RooGenericPdf pdf_1("pdf_1","pdf_1","(cat==0)*formula_1_1+(cat==1)*formula_1_2",RooArgList(cat,formula_1_1,formula_1_2));
  RooExtendPdf  pdf_1_ext("pdf_1_ext","pdf_1_ext",pdf_1,Nbck);

  RooAddPdf model("model","model",RooArgList(pdf_0_ext,pdf_1_ext));
  RooMCStudy* mcstudy = new RooMCStudy(model, cat, Binned(1), Extended(1), FitOptions(Save(0), Minos(1), Extended(1), Strategy(2)));

My code now crashes with the following error message ;
[#0] ERROR:InputArguments – RooCategory::isStateInRange(cat) ERROR: must specificy valid range name and state name

What I also noticed is that in order to fit a dataset (no MCStudy this time) ;

RooDataSet* data = model->generate(cat,some nb));
model->fitTo(*data,Optimize(0))

, I now need to specify Optimize(0) as option otherwise the category cat is set to a fixed value and the fit procedure does not converge anymore.

Could someone tell me what has changed in RooFit that now prevents me to use this kind of pdf ?

Suggestions about how to treat a discrete variable in a pdf are also welcome.

Best regards.

Hi all,

as I don’t have any control over the ROOT version installed on the machine I use, I simply cannot run my analysis code anymore. So any help is more than welcome.

Regards.

Y.

Hi all,
after several tests, it seems that the problem comes from the option “Binned”. If I disable this option, it seems to work. But, unfortunately, this is not a viable option as the generation and fit of N pseudo-experience then takes too much time if one wishes to do 10k PE.

Anyway, the problem remains as this option was possible with the former ROOT version.

Regards.

You can compile your preferred version of ROOT yourself: [url]Installing ROOT from Source
The only problem is the disk space. You will need something like 640 MB in order to build it (you can unpack and build ROOT in “/tmp”, for example) but afterwards you will just need something like 220MB for the “installed binary distribution” (and the “source code and building” subdirectory can be removed).

Hello,

Did you ever resolve this problem:

ERROR: must specificy valid range name and state name

without recompiling ROOT?

I get the same error, although in my case I am using a RooEfficiency pdf to try and fit an efficiency. Like you, the code was working in ROOT 5.28 but has broken on moving to 5.32.

Thanks,
Evan