Hello,
I am trying to fit two signal peaks with two gaussians, and the background with a decaying exponential. I have consulted the relevant tutorials: a couple of relevant examples illustrate how to fit a two-component signal PDF with two gaussians differing in sigma
but not in mean
. In addition, another example llustrates how to plot a model in a specific range. However, my issue differs from these cases in that I am trying to create a composite model with two gaussians with different parameters, so as to fit two different peaks.
Please find a snippet from my attempt below, in PyRoot
#ROOT file
fin = TFile('outfile_2CEP.root')
tdata = fin.Get('t1')
m_Psi_2S = 3686.09
m_JPsi = 3096
#//mass range
mass = RooRealVar("M","M",2500,4000)
## getting the data
data = RooDataSet("data","data",tdata,RooArgSet(mass))
#bkg
c_exp = RooRealVar("#tau_{bkg}","Exp arg constant",-0.01,0)
BkgPDF = RooExponential("BkgPDF","BkgPDF",mass,c_exp)
#//signals PDF (gaussian)
J_mass = RooRealVar("#mu1","#mu1", m_JPsi, 3096-65, 3096+65)
J_width = RooRealVar("#sigma1","#sigma1",30,0,200)
psi2s_mass = RooRealVar("#mu2","#mu2", m_Psi_2S, m_Psi_2S-65, m_Psi_2S+65) #mean of gaussian
psi2s_width = RooRealVar("#sigma2","#sigma2",30,0,100) #find width, 1 std dev
SigPDF1 = RooGaussian("SigPDF1","SigPDF1",mass, J_mass, J_width) #<----maybe a problem with mass?
SigPDF2 = RooGaussian("SigPDF2","SigPDF2",mass, psi2s_mass, psi2s_width) #see above
#only way the whole thing does not crach is using this below, probably bug!
NSig = RooRealVar("Signal yield","Signal yield",4000, 0, 10000)
NBkg = RooRealVar("Bkg yield","Background yield",500000, 0, 1000000)
sig1frac = RooRealVar("sig1frac", "sig 1 fraction", 0.9, 0., 1.)
sig2frac = RooRealVar("sig2frac", "sig 2 fraction", 0.1, 0., 1.)
SigPDF = RooAddPdf("sig", "sig composite pdf", RooArgList(SigPDF1, SigPDF2), RooArgList(sig1frac, sig2frac) )
bkg_frac = RooRealVar("bkg_frac", "bkg_frac", 0.3, 0., 1.)
model = RooAddPdf("model","model",RooArgList(SigPDF, BkgPDF), RooArgList(NSig, NBkg))
I would love to understand where am I going wrong here, or even better, how to fix it.
Thanks,
Blaise