RooCachedPDF Problems


I’m having some trouble using the RooCachedPDF class and was hoping someone here could give me some advice (documentation is very sparse). I’m working with a 2D dataset (a square dalitz plot) which I split into 8 different regions. In each region, I use a Roo2dKeysPDF to fit the distribution in that region. Originally, I then generated histograms directly from the KeysPDFs, but this took far too long. After some searching, I found a post on this forum ( … ocachedpdf) which recommended using a RooCachedPDF before generating. Unfortunately, even though this gave me a big speedup, it seems that the cached PDF is not being updated each time I try to create a new cached PDF (one for each of the 8 regions). In the output from my code, I see messages such as:

[#1] INFO:Caching -- RooAbsCachedPdf::getCache(CachedPDF_0) creating new cache 0x5b90280 with pdf dp_PDF_CACHE_Obs[m0Prime,thetaPrime] for nset (m0Prime,thetaPrime) with code 0 from preexisting content.

where the key phrase is “from preexisting content”. The relavant PyRoot code is below:

for regionNum in range(8):
    eventsToGenerate = int(round(generatedEvents[regionNum]))

    rns = "_" + str(regionNum)
    CachedPDF = RooCachedPdf("CachedPDF"+rns,"CachedPDF"+rns, dp_PDF_Array[regionNum])
    #dp_PDF_Array is an array of Roo2dKeysPDFs                                                                                                                                                   

    DP_ROODATASET_Array[regionNum] = CachedPDF.generate(RooArgSet(m0Prime,thetaPrime), eventsToGenerate)

Even though I declare a new CachedPDF each time through the loop and even change the titles of the CachedPDFs, RooFit behaves as though I’m still using the first one I created. Is there any option I can use to have the CachedPDF be regenerated each time I create a new one? Is this actually a bug in PyRoot?



Hi Tomo,

Whe you use RooCachedPdf objects it is important that all instances of RooCachedPdf that represent different contents have a different name because of the way the (global) caching is implemented. Once you make sure that happens I think you’ll be fine. If problems persist, please post another message.