Merge many RooFitResults from many files

Is there an easy way to merge many files containing each one a similar, but different, RooFitResult? I just want to merge the results of floatParsFinal(), which returns a RooArgList

hadd is not merging them
There is not Merge method

At the end I would prefer a TTree as output

I guess @moneta can help you.


What do you mean merging RooFitResults ? Combine statistically the results of fits with same model but different data sets ?
This is not a operation which cannot be defined uniquely. You can use for example a normal approximation on the resulting values and combine the result, but it might not be fully correct for low statistics.

I think it is something a user can easily do according to his needs

Best Regards


My final goal is to all the informations in one file, easily accessible, as in a TTree where I can draw, dump, … all the information easily. For example I would like to have 1 branch for each fitted central value, one branch for each error hi, …

If I were able to merge all the RooFitResult::floatParsFinal(), now in thousands of files, into a single container (a RooDataset, a TTree, …) it would be then easier to use it.

Of course every user can do by themself, but having some sugar as RooFitResults::RooFitResults(std::vector<RooFitResult>) will help. For example usually what I do for each toy I save a TTree with one entry and then use hadd.


I have still not understood exactly what you want. Do you want to save in a TTree the fit result of n toys , i.e. a std::vector and then merge the Trees using hadd and append the RooFitResult ?
This should work out of the box, you would not need to implement anything


That is what I usually do (1 toy = 1 file = 1 ttree with one entry, then hadd, plot, …) and yes, it works out of the box and it is very convenient. Now I have 1 toy = 1 file = 1 RooFitResult. Do I really need to loop on the files, open for each the RooFitResult, check which are the parameters, save in a structure which I can easily loop and plot (a TTree, a csv file, …)? Isn’t something useful I can use? A tool to merge several RooFitResult? For example RooStats::HypoTestResult are mergeable.


I think the easiest solution for you is exactly what done in HypoTestResult for the detailed output.
You should save not the RooFitResult ut a RooDataSet containing the final result of the fit and maybe extra information you need (e.g. likelihood at the minimum) and then merge those using RooDataSet::append()

There is in RooStats a static function that does this basically for you, in DetailedOutputAggregator.cxx,


Yes, that would be nice… but I have just the output of the toys, not the code… so ok, nevermind I can do something by hand (if it were not crashing: Looping on many files, memory leak (RooFitResult))

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