I think that when I save a TF1 initialized with a functor (class with a operator() root.cern.ch/root/html/TF1.html#F4 ) in a ROOT file (for example in a TTree), I only save an array of values of TF1.
Is there a simple way to save really the function and not just an array of values…
For the moment, I have tried to create a Dictionnary with my functor, save the functor in the ROOT file and I save also an array of parameters. Then, each time I open the ROOT file , I recreate my TF1, set the parameters… but my code begins to be complicate and buggy for something that’s probably simple to do for somebody used to C++ …
I really need to save really the function (increase the size of the TF1 array is not a solution for what I need.)
so if this is indeed impossible directly with a TF1, is the method :
write() {
//Dictionnary of a functor + array of parameter
//saved in a ROOT file
}
/******************************************************************/
read() {
//Open the ROOT file
//recreate TF1 with functor + array of parameter
}
It is true a TF1 created from a functor object cannot be saved in a file. When it is cloned or saved it is only an array sampled of values for the current state is saved.
However, what you can do, if you have the dictionary, you can store the object used for the functor and then re-create the TF1 afterwards.