Running macro stops without errors


I am performing an unbinned likelihood fit of 4 trees contained in 4 different .root files. After doing the fit of the 3rd file, the running macro just exits without giving any errors nor creating output files.
I am very thankful for any advise you can give me to solve this problem. I have attached the code and .root files.

Many thanks

anaTF2UnbinnedFit.C (3.6 KB) pseudo_data_bin_0.root (829.5 KB) pseudo_data_bin_1.root (692.7 KB) pseudo_data_bin_2.root (875.1 KB) pseudo_data_bin_3.root (844.7 KB)

A quick way to pinpoint where exactly the macro quits is adding debug print statements like std::cout << "Debug Message" << std::endl to your code. It should allow you to find the last line of code that is executed before the macro ends.

Trying to reproduce the problem, I actually could process your last file but it requires some 3.5G of RAM. Perhaps on your machine you simply ran out of memory. You can try processing the files one by one (instead of all in the same macro run). Perhaps @moneta has more ideas on how to reduce the memory.

Many thanks for your reply and testing the files. Yes, I run out memory. I would need to make the fits on the same macro. Is there any way to reduce the memory of perhaps clean up the memory after processing each file?

Since you are not doing a fit on all the 3 data sets at the same time, I would open the file, do the fit then close the file. This should reduce your memory usage


Forget my previous post. After looking at your code, I see you have a massive memory leak in the function definition. You create a TF2 object for each single event and the object is never deleted.
Attached you find a new version where I define a functor class for the fit function (NormalizedFunction) where both the function pointer and also the integral are cached. This not only avoids memory leaks, but the function integral is computed only when parameters change and this speeds up enormously the fit time.


anaTF2UnbinnedFit.C (4.1 KB)

Thank you so much Lorenzo! I am very grateful, your corrections and explanations were enormously helpful.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.