Created
December 16, 2014 12:18
-
-
Save alexpearce/cd826f2bc807cf405cca to your computer and use it in GitHub Desktop.
Test smeared log IP chi^2 shape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ROOT | |
from ROOT import RooFit as RF | |
ROOT.gROOT.ProcessLine('#include "charmproduction/fitting/shape_classes/RooSmearedLogChiSquared.cxx"') | |
w = ROOT.RooWorkspace('w') | |
w.factory('x[-5, 5]') | |
w.factory('mu_ip[2, -10, 10]') | |
w.factory('alphaL_ip[1, 0.1, 10]') | |
w.factory('alphaR_ip[1, 0.1, 10]') | |
w.factory('RooSmearedLogChiSquared::pdf_ip(x, mu_ip, alphaL_ip, alphaR_ip)') | |
xset = ROOT.RooArgSet(w.var('x')) | |
ds = w.pdf('pdf_ip').generate(xset, 10000) | |
w.pdf('pdf_ip').fitTo(ds) | |
xframe = w.var('x').frame() | |
ds.plotOn(xframe) | |
w.pdf('pdf_ip').plotOn(xframe) | |
c = ROOT.TCanvas('single_fit', 'single_fit', 400, 400) | |
xframe.Draw() | |
c.SaveAs('test_smeared_chisq_single.pdf') | |
# Generator PDF, fitting PDF, observables, generator options, fitting options | |
study = ROOT.RooMCStudy( | |
w.pdf('pdf_ip'), | |
xset, | |
RF.Silence(), | |
RF.FitOptions(RF.Save(True), RF.PrintEvalErrors(0)) | |
) | |
study.generateAndFit(1000, 10000) | |
params = ['mu_ip', 'alphaL_ip', 'alphaR_ip'] | |
nparams = len(params) | |
c = ROOT.TCanvas('params', 'params', nparams*200, 400) | |
c.Divide(nparams, 2) | |
idx = 1 | |
for param in params: | |
plot_param = study.plotParam(w.var(param), RF.Bins(40)) | |
plot_pull = study.plotPull(w.var(param), RF.Bins(40), RF.FitGauss(True)) | |
c.cd(idx) | |
plot_param.Draw() | |
c.cd(idx + nparams) | |
plot_pull.Draw() | |
idx += 1 | |
c.SaveAs('test_smeared_chisq.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment