I have tried this method. It works for RooFit’s official PDF such as RooGaussian, but when I apply it to my DIY PDF (for test), It reports an error:
[#1] INFO:Fitting – RooAbsPdf::fitTo(pdf) fixing normalization set for coefficient determination to observables in data
[#1] INFO:Fitting – using CPU computation library compiled with -mavx512
This functionality is not yet implemented for tree data stores.
terminate called after throwing an instance of ‘std::logic_error’ what(): getBatches() not implemented in RooTreeDataStore.
The ROOT version is v6-26-10, RooFit version is v3.60.
Does anyone know why? I am looking forward to your reply.
Note that for ROOT 6.28.00 that was just released, the BatchMode got improved yet again and you don’t need to do this. I would strongly suggest you to use this new release because many things got fixed and were made faster. Also, I would be very happy to get some feedback on the BatchMode for the new release, because maybe for ROOT 6.30 we’ll make it the default. Also I’m curious, what is your DIY PDF looking like, and do you get a performance improvement with the BatchMode?
And sorry for my late reply, I was trying to download and compile ROOT v6.28 these two days, but I have encountered many issues, therefore I can’t give test result under v6.28 now.
After I added “data->convertToVectorStore()” in my fitting under ROOT v6.26, I still got the same error. I’m worried about whether there are some problems with the constructure of my DIY PDF. For your convenience, I rewrote a simplified pdf, but the structure is the same as my PDF. The detailed code is attached in the attachment, pealse check it. You just need to “make” and test toy MC in the fold “toyMC_test”.
Sorry for the naive mistake. I wrote the wrong code due to the automatic completion function of vim. The fit works fine after I add the correct line data->convertToVectorStore();. As a test, I used my PDF(a full angular distribution amplitude) to fit toy data(3.2e6 events) with a normalization PHSP toy MC sample(1.5e8 events) and compared the fitting time of the following three cases:
1. Nominal fit:
RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), Timer(true));
Cost time = 1 hour and 36 minutes
2. BatchMod fit:
RooFitResult *result = pdf.fitTo(*data, Save(kTRUE), BatchMode(“CPU”), Timer(true));
Cost time = 1 hour and 40 minutes
It seems that BatchMode(“CPU”) not works here. I also compare the results of RooGaussian with 3.2e7 toy data sample. The fitting cost time of Nominal fit is 1:30 minute, while the cost time of BatchMod fit is 24 seconds. Therefore the BatchMode(“CPU”) works well for RooGaussian.