I am working on a project that requires me to fit data points to an exponential function. I am using the ROOT framework for the finding the best-fit parameters. I have done that part and I am exporting the best-fit values into a text file along with some descriptive statistics like errors on the fitted parameters, the chi-squared and reduced chi-squared values etc. I am also trying to transfer a covariance matrix to the output file but I am not able to do it. So, how do I transfer the covariance matrix to an output file in ROOT?

I would highly appreciate it if I could get some help on this issue.

Thank you for your response. As of now, I am able to transfer the covariance matrix into a .root file. However, I would like to export the covariance matrices to a .txt file. Is there a way to do that?

Any helpful suggestions will be highly appreciated!

Thank you very much! It worked! I made some changes to your code as I wanted to calculate and append the multiple covariance matrices to the text file. But I used your code heavily as a reference. Thank you very much once again!