I am sorry you are experiencing this issue.
Can you reduce the problem to a simple reproducer? It is a sophisticated program, and it is hard to say whether there is a problem due to ROOT at this point.

Let’s consider j=1. The first line in the loop sets the range to 55550 - 55650. The second line fits graphs[1], which holds the values in se2fe.txt. But these values are from 55950 to 56300. You have no data in the desired range of the function, ergo Warning in <Fit>: Fit data is empty

Hi @danilo, thank you.
I solved the problems due to the Empty fit errors.

Now I “only” have the problem that the total fit (red line) is not good (as you can see by the plot and by the results txt file.
I guess it is due to inizialization parameters, but even if I tried some values …I can’t find good ones.

@yus:
yes, in the meanwhile I fixed that bug (we wrote at the same moment).
I fixed by replcing graphs[j]->Fit(flareFits[j], "R+");

by mg->Fit(flareFits[j], "R+");

Unfortunately, even if I fixed it, I still don’t get a good total fit (see my first topic, because I updated code and plot)

I mean, I fit the subranges with the function written in the first topic, i.e. The number of subranges depends on the data file, then I wrote it dinamically, i.e.