Is there a way to extract the best fit line in fitting a 2D histogram

Thank you for your patience and assistance

How can i automatically save the parameters of the best-fit line in an ascii/txt file using the same macro?

root [0]  .> param.txt
.x basichist.C 
.>
root [3]