Hi all,
I am trying to implement a simultaneous fit in 4 categories, each fitting over the same variable (mass). I want to extend the mass fitting ranges for some of the categories, as they can be modelled at lower masses and give a better handle on the backgrounds.
I have seen the other posts and documentation about this, but cannot get it to work as the fit does not seem to converge, or is taking too long (> few hours). So want to check first that my approach is right before looking into other solutions.
The simultaneous fit is set up like this
w = ROOT.RooWorkspace("w")
m = ROOT.RooRealVar('{}'.format(B_mass), '{}'.format(B_mass), 3700., 6000.)
sample = ROOT.RooCategory("sample", "sample")
sample.defineType("LowQ2")
sample.defineType("HighQ2")
sample.defineType("LowQ2_SSB")
sample.defineType("HighQ2_SSB")
m.setRange("range_LowQ2", Lowq2LC, Lowq2HC)
m.setRange("range_HighQ2", Highq2LC, Highq2HC)
m.setRange("range_LowQ2_SSB", Lowq2_SSB_LC, Lowq2_SSB_HC)
m.setRange("range_HighQ2_SSB", Highq2_SSB_LC, Highq2_SSB_HC)
Where the cuts for each category are within the range of allowed values for m
w.Import(m)
lowq2Data = ROOT.RooDataSet("lowq2data", "lowq2data", lowq2TTree, ROOT.RooArgSet(m))
highq2Data = ROOT.RooDataSet("highq2data", "highq2data", highq2TTree, ROOT.RooArgSet(m))
lowq2_SSB_Data = ROOT.RooDataSet("lowq2_SSB_Data", "lowq2_SSB_Data", lowq2_SSBTTree, ROOT.RooArgSet(m))
highq2_SSB_Data = ROOT.RooDataSet("highq2_SSB_Data", "highq2_SSB_Data", highq2_SSBTTree, ROOT.RooArgSet(m))
*Fitting model*
combData = ROOT.RooDataSet("combData", "combined data",
ROOT.RooArgSet(m),
ROOT.RooFit.Index(sample),
ROOT.RooFit.Import("LowQ2", lowq2Data),
ROOT.RooFit.Import("HighQ2", highq2Data),
ROOT.RooFit.Import("LowQ2_SSB", lowq2_SSB_Data),
ROOT.RooFit.Import("HighQ2_SSB", highq2_SSB_Data),
)
simPdf = ROOT.RooSimultaneous("simPdf", "simultaneous pdf", sample)
simPdf.addPdf(LowQ2Model, "LowQ2")
simPdf.addPdf(HighQ2Model, "HighQ2")
simPdf.addPdf(model_HQ2_SSB, "HighQ2_SSB")
simPdf.addPdf(model_LQ2_SSB, "LowQ2_SSB")
fit_results = simPdf.fitTo(combData,
ROOT.RooFit.Save(),
ROOT.RooFit.Extended(ROOT.kTRUE),
ROOT.RooFit.Range("range"),
ROOT.RooFit.SplitRange(ROOT.kTRUE))
*Plotting*
The code works for when the ranges are the same, and also if I just have SplitRange(kTRUE), but it just ignores the ranges and will fit over [3700,6000] for all categories (obvious from yields and results).
I think @jonas has been active on similar threads and helped me before with a similar issue, so I assume you are the right person to ask.
Thanks in advance,
Nathan