Accessing automatically generated RooRealVars

Dear all,

I am continuing to use the RooSimPdfBuilder class and the tutorial here:

roofit.sourceforge.net/docs/clas … t2.cc.html

…and have everything working happily

When I build the pdf:

  // Build the PDF
  RooSimultaneous* simSum  = mgr.buildPdf(*config,&data) ;

  simSum->Print("v") ;
  simSum->getParameters(&data)->Print("v") ;

and print, I see output like the following:

  Plot label is "simPdf"
--- RooAbsPdf ---
Cached value = 0
  1) 0x46e4aa0 RooRealVar:: a_a_param_a1 = 0.5  L(0 - 1)  "a_a_param (a1)"
  2) 0x46e6f20 RooRealVar:: a_a_param_a2 = 0.5  L(0 - 1)  "a_a_param (a2)"
  3) 0x46e3d80 RooRealVar:: a_d_param_a1 = 0.5  L(0 - 1)  "a_d_param (a1)"
  4) 0x46fb020 RooRealVar:: a_d_param_a2 = 0.5  L(0 - 1)  "a_d_param (a2)"
  5) 0x7fff9465a020 RooRealVar::        gamma = 0.5  L(0 - 1)  "gamma"
  6) 0x46ef570 RooRealVar:: h_a_param_h1 = 0.5  L(0 - 1)  "h_a_param (h1)"
  7) 0x4704bc0 RooRealVar:: h_a_param_h2 = 0.5  L(0 - 1)  "h_a_param (h2)"
  8) 0x46fc120 RooRealVar:: h_d_param_h1 = 0.5  L(0 - 1)  "h_d_param (h1)"
  9) 0x47176d0 RooRealVar:: h_d_param_h2 = 0.5  L(0 - 1)  "h_d_param (h2)"

But, I’m failing to work out how to access/edit the parameters that have been automatically generated e.g. a_a_param_a1

e.g:

a_a_param_a1.getVal();

doesn’t work…

Could anyone help me with the correct syntax?

Follow up question: I’d like to get at these values so I can e.g.

  • constrain them in the fit ( sum over a_a_param_a(i) = 1) - is this possible?
  • print fitted parameters etc etc

Thanks! :slight_smile:

S

HI,

Try with

auto params  = simSum->getParameters(&data);
auto var = dynamic_cast<RooRealVar*> ( params->findObject("a_a_param_a1") );

Lorenzo

Hi Lorenzo,

Thank you for the response!

Your method works with some minor adjustments:

    auto params  = simSum->getParameters(data);
    auto variable = dynamic_cast<RooRealVar*> ( params->find("a_param_660") );
    cout << "var exists = " << variable << endl;

I.e. using find() instead of findObject()

  1) 0x3b800c0 RooRealVar:: a_param_660 = 0.5  L(0 - 2)  "a_param (660)"
  2) 0x3b32540 RooRealVar:: a_param_662 = 0.5  L(0 - 2)  "a_param (662)"
  3) 0x3b20270 RooRealVar:: d_param_660 = 0.5  L(0 - 2)  "d_param (660)"
  4) 0x3b33290 RooRealVar:: d_param_662 = 0.5  L(0 - 2)  "d_param (662)"
  5) 0x7ffe19aefe40 RooRealVar::       gamma = 0.5  L(0 - 1)  "gamma"
  6) 0x7ffe19af0260 RooRealVar::         rho = 1  L(-1 - 1)  "rho"
var exists = 0x3b800c0

Now I just need to work on forcing the fit to have a constraint on the a_params

i.e. (1/n) *sum over i (a_param_i) = 1

Is it easy to impose such a constraint in RooFit?

Best and thank you so much again,

S