I have a list of events that for each event I have to perform numerical minimization on with a function that takes in several parameters which are constants that are used to define the function (see below code). Following the tutorials on this page https://root.cern.ch/numerical-minimization, the below code is a general idea of what I want to accomplish.
I am hesitant to follow the multi-dimensional examples on that page since my function is not multi-dimensional since all I am doing is passing in constants used to to define a 1D function. I’ve gotten past this by setting global variables, but I would need to reset the global variables in every loop iteration for each event, so if at all possible I would like to know if there is a more elegant approach.
I also came across this page: https://root.cern.ch/doc/master/classTF1.html#F5 while looking around, and this comes close to what I want to accomplish but I would like to know if I can use a TF1 in my code below.
Concerning your question about TF1, yes, you can use a TF1, but you cannot really use the ROOT::Math::Functor1D, because you will not be able to see the parameters change later. The Functor1D performs a copy of the TF1 object.
The solution is to use the ROOT::Math::WrappedTF1 class and then use the 1D minimisation algorithm. Here is the example