Skip to content

Getting access to fit function from histogram in root file #1011

Answered by jpivarski
bblidaru asked this question in Q&A
Discussion options

You must be logged in to vote

I don't know if anyone has done this before, and we haven't written a nice interface to extract fitted values, but the fit results appear to be in the Uproot deserialization, if you dig.

>>> import uproot
>>> h = uproot.open("output.root:histogram_with_improved_fit")   # the histogram
>>> f = h.member("fFunctions")[0]                                # the fit function

>>> f.member("fFormula").member("fFormula")                      # fit function as a string
<TString '[Constant]*exp(-0.5*((x-[Mean])/[Sigma])*((x-[Mean])/[Sigma]))' at 0x7f76607bfa70>

>>> f.member("fFormula").member("fParams")                       # mapping from name to index
<STLMap {'Constant': 0, 'Mean': 1, 'Sigma': 2} at

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@bblidaru
Comment options

@jpivarski
Comment options

@bblidaru
Comment options

@jpivarski
Comment options

Answer selected by bblidaru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants