# Fill the data. print type(pass_histo) ## for binp, bina in zipBins(pass_histo, all_histo): ## bratio = binp.content/bina.content if bina.content <> 0 else 0 ## print "bin #%s: passed %s all %s ratio: %s" % (binp._binNum, binp.content, bina.content, bratio) graph = ROOT.TGraphAsymmErrors(pass_histo, all_histo) ## graph.SetMarkerColor(2) ## graph.GetYaxis().SetRangeUser(0,1) ## graph.SetMarkerStyle(20) ## graph.SetMarkerSize(1) ## canvas = ROOT.TCanvas("asdf", "asdf", 800, 600) ## graph.Draw('ap') ## canvas.Print( plot_name = args.output.replace('.root', 'TGraph.png') ) ## canvas.Delete() log.info("Building x-y RooDataSet") x = ROOT.RooRealVar('x', 'x', 0) x.setMin(graph.GetX()[0] - graph.GetEXlow()[0]) x.setMax(graph.GetX()[graph.GetN() - 1] + graph.GetEXhigh()[graph.GetN() - 1]) y = ROOT.RooRealVar('y', 'y', 0) xy_data = ROOT.RooDataSet("xy_data", "xy_data", ROOT.RooArgSet(x, y), ROOT.RooFit.StoreAsymError(ROOT.RooArgSet(y)), ROOT.RooFit.StoreError(ROOT.RooArgSet(x))) # Convert TGraph into x-y datasets for bin in range(graph.GetN()): xval = graph.GetX()[bin] yval = graph.GetY()[bin] xdown = graph.GetEXlow()[bin] xup = graph.GetEXhigh()[bin] ydown = graph.GetEYlow()[bin] yup = graph.GetEYhigh()[bin]
eff_map_statDown.SetBinContent(ibinx, ibiny, statDown) worse_rel_err.SetBinContent(ibinx, ibiny, worse_err) canvas = ROOT.TCanvas("asdf", "asdf", 800, 600) ROOT.gStyle.SetPalette(53) eff_map.Draw('colz') canvas.Print(args.output.replace(".root", ".png")) outFile = ROOT.TFile(args.output, 'recreate') #FIXME move to rootpy io outFile.cd() eff_map.Write() eff_map_statUp.Write() eff_map_statDown.Write() worse_rel_err.Write() base_dir = os.path.dirname(args.num) m = ROOT.RooRealVar('m', 'm', 55, 55, 200) os_trkMass = ROOT.RooDataHist( 'higgs_data', 'higgs_data', ROOT.RooArgList(m), input_view.Get(os.path.join(base_dir, 'os_trkMass'))) mean = ROOT.RooRealVar('mean', 'mean', 90, 80, 110) sigmaL = ROOT.RooRealVar('sigmaL', 'sigmaL', 30, 0, 100) sigmaR = ROOT.RooRealVar('sigmaR', 'sigmaR', 25, 0, 100) alphaL = ROOT.RooRealVar('alphaL', 'alphaL', 1, 0, 30) alphaR = ROOT.RooRealVar('alphaR', 'alphaR', 1, 0, 30) os_func = ROOT.RooCruijff('os_func', 'os_func', m, mean, sigmaL, sigmaR, alphaL, alphaR) fit_result = os_func.fitTo( os_trkMass, ROOT.RooFit.Save(True), ROOT.RooFit.PrintLevel(-1),
mc.Add(mc4, datalumi/mc_lumi[4]) mc.SetMarkerStyle(20) mc.SetMarkerColor(4) mc.SetLineColor(4) data.Scale(mc.Integral()/data.Integral() ) max_data = data.GetBinContent(data.GetMaximumBin()) max_mc = mc.GetBinContent(mc.GetMaximumBin()) mc.Draw() data.SetMarkerStyle(20) data.SetMarkerColor(2) data.SetLineColor(2) data.Draw() m = ROOT.RooRealVar('m', 'Collinear Mass', 90,40,250) os_data = ROOT.RooDataHist('z_data','z_data',ROOT.RooArgList(m),data) os_mc = ROOT.RooDataHist('z_mc','z_mc',ROOT.RooArgList(m),mc) mean = ROOT.RooRealVar('mean', 'mean', 90,70,110) sigmaL = ROOT.RooRealVar('sigmaL' ,'sigmaL' ,10 ,0 ,100) sigmaR = ROOT.RooRealVar('sigmaR' ,'sigmaR' ,10 ,0 ,100) alphaL = ROOT.RooRealVar('alphaL' ,'alphaL' ,1 ,0 ,30 ) alphaR = ROOT.RooRealVar('alphaR' ,'alphaR' ,1 ,0 ,30 ) command = ROOT.RooCruijff("os_func", "os_func",m, mean, sigmaL, sigmaR, alphaL, alphaR) frame = m.frame(ROOT.RooFit.Title("Z mass peak")) fit_result_mc = command.fitTo( os_mc, ROOT.RooFit.Save(True))