RooMCStudy: question

I want to use RooMCStudy to generate and fit toys but I have a problem in the constructor.
This is how my model is defined (which is basically a convolution of expo decay with gaussian with error event by event times another gaussian for another independent variable):

RooGaussian bmass(“bmass”,“mass of the Bs”,*bsmass,*mass,*width);
// generation of protodata
RooGaussian sigerr(“sigerr”,“error on dectime”,*errdectime,*mean_err,*sigma_err);
RooExponential sigerr2(“sigerr2”,“error on dectime”,*errdectime,*slope);
RooFFTConvPdf ErrDt(“ErrDt”," theory (x) resolution",errdectime,sigerr2,sigerr,0);
protodata = ErrDt.generate(RooArgSet(*errdectime),100);
// end of the generation

RooGaussModel resolution(“gauss”,“dectime resolution”,*dectime,*mean,*sigma,*errdectime,*errdectime);
RooDecay modelC(“modelC”,“theory (x) resolution”,*dectime,*g,resolution,RooDecay::Flipped);
RooProdPdf model(“model”,“decay rate * bsmass”,RooArgList(modelC,bmass));

Then I call

RooMCStudy *mgr = new RooMCStudy(model,model,RooArgSet(*dectime,*bsmass),"","",*protodata,RooArgSet(*errdectime));

Doing this I get the error while compiling: error: no matching function for call to `RooMCStudy::RooMCStudy(RooProdPdf&, RooProdPdf&, RooArgSet, const char[1], const char[1], RooDataSet&, RooArgSet)’
/auto/nfs/home/cerizza/root_5_23_4_64/root/include/RooMCStudy.h:43: note: RooMCStudy::RooMCStudy(const RooAbsPdf&, const RooAbsPdf&, const RooArgSet&, const char*, const char*, const RooDataSet*, const RooArgSet&)

So I tried replacing “*protodata” with “protodata” but it crashes with “segmentation violation”.
What am I doing wrong in the constructor?

Thanks a lot in advance

Hi Giordano,

(Sorry for the late reply, I was on vacation)

The constructor form that you use indeed wants a RooDataSet
pointer for historical reasons rather than a reference. I will
investigate your SEGV, could you please send me a self-contained
example macro?


Hi Wouter,
I wrote you a macro that reproduces my SEGV.
Thanks a lot for looking at it.

macro.C (1.77 KB)

Hi Giordano,

Thanks for the macro. I have found the problem. It was a cut-and-paste error on my side. It is specific to the ‘second’ RooMCStudy constructor form that you use (the one without named arguments). A fix is now in the dev/roostats branch and will be propagated to pro release 5.24 later this month. Meanwhile you should be able to sidestep this issue by using the named argument constructor of RooMCStudy, i.e.

RooMCStudy mcs(model,RooArgSet(dectime,bsmass),ProtoData(*protodata),ConditionalObservables(errdectime)) ;