Hi all
I am having difficulty accessing different values from my pdf, given x-values.
I am using RooKeysPdfs and I am accessing a RooDataSet (all of which are held in a RooWorkspace).
I then want to loop over the RooDataSet and get the y-value of the pdf for each data point.
The following extract of code focuses on my problem. (The RooWorkspace* is w).
RooKeysPdf* pdf = w->pdf("mykeyspdf");
RooArgSet* set;
double val;
double prob;
RooDataSet* d0 = (RooDataSet*)w->data("data");
int entries = d0->numEntries();
cout << entries << endl;
for(int i = 0; i < entries; i++){
set = (RooArgSet*)d0->get(i);
xi = (RooRealVar*)set->find(xi->GetName());
val = xi->getVal();
xi->setVal(val);
prob = pdf->getVal(RooArgSet(*xi));
cout << val << " --- " << prob << endl;
}
(Nb: I’m pretty sure the xi->setVal(val) is redundant as xi is set to the value of that RooDataSet event.)
The value is working correctly in that it is looping through the dataset and reading different values for each iteration. However, the “prob” value is giving the same value for every single x-value, even though it is not a flat distribution. The value is also the same as that which is returned if I use pdf->Print(), so I am clearly not accessing the distribution correctly.
Could someone please provide some guidance, as I have worked my way through the documentation and posts here on RootTalk and have not been able to find a solution which works.
Many thanks,
Ian