I am performing some Monte Carlo simulation, where I am simulating a decay spectrum for a specific number of nuclei.
I need to smooth every decay spectrum with a gaussian function and compare it to the experimental spectrum and calculate the variance.
And I need to perform it for all the simulated nuclei.
Every simulated decay spectrum is saved as a Graph.
Please help, on how to perform this smoothing operation on a Graph. I need to make it automated, where it can automatically generate some mean and then fit it in within those limits.
You can get the maximum (for a TGraph gr of size n) with
Double_t max = TMath::MaxElement(n,gr->GetY());
then you can loop over all the n points of the graph and find the x corresponding to that y (there might be more than one such point, so take care of that), using GetPoint.