Details
-
Bug
-
Status: Resolved (View Workflow)
-
High
-
Resolution: Fixed
-
5.34/00
-
None
-
All
-
bugs100209
Description
Hi,
In the RooStats::Factorize() function, I notice that typeId is used to determine whether an object is a RooProdPdf or a RooSimultaneousPdf. This has caused a problem for me because I have a class that inherits from RooProdPdf (so that I can evaluate the sum of log values rather than the product of values) and this is not picked up by the factorization algorithm. This creates a problem in i.e. RooStats::AsymptoticCalculator where it can't extract the generating function for GlobalObservables.
Below is a proposed fix that just uses dynamic_cast instead of typeId (this is for an older version that doesn't have the RooExtendPdf in it but that's a very similar idea):
FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints) {
RooProdPdf *prod = dynamic_cast<RooProdPdf *>(&pdf);
if (prod) {
RooArgList list(prod->pdfList());
for (int i = 0, n = list.getSize(); i < n; ++i) {
RooAbsPdf *pdfi = (RooAbsPdf *) list.at;
FactorizePdf(observables, *pdfi, obsTerms, constraints);
}
} else {
RooSimultaneous *sim = dynamic_cast<RooSimultaneous *>(&pdf);
if (sim) {
RooAbsCategoryLValue *cat = (RooAbsCategoryLValue *) sim->indexCat().Clone();
for (int ic = 0, nc = cat->numBins((const char *)0); ic < nc; ++ic) {
cat->setBin(ic);
FactorizePdf(observables, *sim->getPdf(cat->getLabel()), obsTerms, constraints);
}
delete cat;
} else if (pdf.dependsOn(observables)) {
if (!obsTerms.contains(pdf)) obsTerms.add(pdf);
} else {
if (!constraints.contains(pdf)) constraints.add(pdf);
}
}
}
Cheers,
Luke