Test Histogramm Fitting in pyROOT
import numpy as np
import math
#import ROOT
from ROOT import TCanvas, TFile, TProfile, TNtuple, TH1D, TH2D, TF1
from ROOT import gROOT, gBenchmark, gRandom, gSystem
Read data previously used from text file and put it in a numpy array
data = np.genfromtxt('D0Mass.txt', dtype='d')
print(data)
Create histogramm and draw
d0 = TH1D( 'd0', 'D0 Mass ', 200, 1700. , 2000. )
for x in data :
d0.Fill(x)
c = TCanvas( 'myC', 'Dynamic Filling Example',700, 500 )
d0.Draw()
To display the notebook draw the canvas.
# %jsroot on
c.Draw()
perform Fit
func = TF1("func", 'gaus', 1840. , 1880.)
myfit = d0.Fit(func,"S")
c.Draw()