Saving parameters from RooFitResult

Hey All

I have a function:

[code]def make_parameters_text_file(fit_result, path_to_save_text_file):
""“Print the RooFitResult printed all nicely to the file ‘pars.txt’”""

# check the path makes sense and fix if nessicary
if not path_to_save_text_file.endswith("/pars.txt"):
  if path_to_save_text_file.endswith("/"):
    path_to_save_text_file += "pars.txt"
  else:
    path_to_save_text_file += "/pars.txt"
print "saving parameters to:", path_to_save_text_file

# (re)create output file
text_file = open(path_to_save_text_file, "w")

# print the RooFitResult
fit_result.floatParsFinal().printMultiline(text_file.write, 1111    , True);

text_file.close()
return

[/code]

Which, of course, won’t work because “text_file” is not a C++ ostream. Is there a way to use the RooFitResult’s nice print options?

Hi,

you can just create a C++ output stream, no? I’m not familiar with this particular roofit functionality, but something like this:text_file = ROOT.std.ofstream(path_to_save_text_file)should just work?

Cheers,
Wim

Yep your suggestion works just fine, nice one.
Thanks!
Sam