The following tool is used in ProtoDUNE-SP dataprep to fit pedestals for each channel:
We would like to improve the speed of this code. Gianluca made the following suggestions:
You can definitely use `hit::CompiledGausFitCache<1U>`, which works great as long as do not attempt multithreading with it, or else you'll need to take the usual multithreading precautions with complicate caching by a lot. But that helps only if creating the TF1 is the task that is devouring your processing time. This may end up not being your case. Just taking a look at the code, it seems it's doing a lot of things: allocating and filling two new ROOT histogram, creating a ROOT function (a Gaussian), cloning it, running a fit, and possibly opening a ROOT file, cloning an histogram, writing it into that file, and cleaning up. The best action depends on what of this is essential and what is not. For example, histogramming may be done without ROOT for some gain in resource usage, and simple single-Gaussian fit may be done with alternative methods (e.g. using `lar::util::GaussianFit` if its requirements are satisfied). As you can well imagine, each choice comes with a price.
I am also adding Kyle and Saba for their inputs on any other potential improvements.