Accessing genData() in RooFit

Hi, I’m following the tutorial rf_801_mcstudy and trying to extract a profile likelihood for the generated data in my model. I do the following:

RooMCStudy* mcstudy = new RooMCStudy(model,Mjj,Binned(kFALSE),Silence(),Extended(kTRUE),
FitOptions(Save(kTRUE),PrintEvalErrors(0))) ;
mcstudy->generateAndFit(1000,0,kTRUE,0) ;

where the kTRUE should keep the generated data in memory via genData() but then when I try to get the Profile Likelihood for “model”, via
RooStats::ProfileLikelihoodCalculator* PLL = new RooStats::ProfileLikelihoodCalculator(mcstudy->genData(),model,RooArgSet(mu,c2))

I get:
no known conversion from ‘const RooAbsData *’ to ‘RooAbsData &’ for 1st argument

Any suggestions?

This looks like a deficiency in the current interfaces. I have opened a pull request to allow your code to compile and work here.

In the meanwhile, you could work around the mentioned problem by:

RooMCStudy* mcstudy = new RooMCStudy(...);
mcstudy->generateAndFit(1000,0,kTRUE,0) ;

const RooAbsData& data = *mcstudy->genData();

auto PLL = new RooStats::ProfileLikelihoodCalculator(const_cast<RooAbsData&>(data),model,RooArgSet(mu,c2))

Thank you. This fixed the reported error.

Thanks for the timely response!


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