示例#1
0
 def qcd_comp_plot(var, cut, plot_range, **kwargs):
     lumi = 6471
     hist_qcd_iso = samplesD_iso["QCDMu"].drawHistogram(var, str(cut), plot_range=plot_range)
     hist_qcd_iso.pretty_name = "simulation: %d ev." % hist_qcd_iso.hist.Integral()
     print "MC qcd events: %d" % hist_qcd_iso.hist.Integral()
     hist_qcd_iso.normalize_lumi(lumi)
     hist_data_aiso = samplesD_aiso["SingleMuD"].drawHistogram(var, str(cut), plot_range=plot_range)
     hist_data_aiso.pretty_name = "data driven"
     hist_data_aiso.normalize(hist_qcd_iso.hist.Integral())
     print hist_qcd_iso.hist.Integral()
     print hist_data_aiso.hist.Integral()
     canv = plot_hists([hist_qcd_iso, hist_data_aiso], **kwargs)
     B = legend([hist_qcd_iso, hist_data_aiso])
     canv.SaveAs(kwargs.get("filename", "qcd_comp.pdf"))
     return canv, B
示例#2
0
            cut_sequences.append(new_sequence)
        return cut_sequences

    sequences = makeSequences(cuts)

    hists = []
    for (cut, name) in zip(sequences, cuts.keys()):
        hist = sample.drawHistogram("cos_theta", cut.cut_str,
            plot_range=[40, -1, 1],
            weight="muon_IDWeight*muon_IsoWeight*pu_weight*b_weight_nominal"
        )
        lumi = 12210
        if args.normalize_lumi:
            hist.normalize_lumi(lumi)

        hist.hist.SetName(name)
        hist.hist.SetTitle("%s: %.3E" % (name, hist.hist.Integral()))
        hist.update()

        hists.append(hist)
        print "%s: %d" % (name, hist.hist.Integral())

    title = "%s cos-theta cutflow" % sample.name
    if args.normalize_lumi:
        title += " normalized to %.1f/fb" % (lumi/1000.0)

    canv = plot_hists(hists, do_log_y=False, title=title, x_label="cos #theta")
    leg = legend(hists, pos="top-right-small")
    canv.SaveAs("cutflow_%s.pdf" % sample.name)
    #canvas_margin(canv, 0.3)
示例#3
0
        "/Users/joosep/Documents/stpol/data/T_t.root",
        "/Users/joosep/Documents/stpol/data/step3_trees_Apr04/iso/mc/T_t.root",
        "/Users/joosep/Documents/stpol/data/step3_trees_Apr05_noPuClean/iso/mc/T_t.root",
    ]
    samples = [Sample.fromFile(f) for f in fnames]
    sample_names = ["Apr16 (fixed norm)", "Apr04", "Apr05 (no PU cl.)"]
    
    samps = zip(samples, sample_names)
    cut = Cuts.mt_mu*Cuts.n_jets(2)*Cuts.n_tags(1)*Cuts.eta_lj*Cuts.top_mass_sig

    hists = []
    for sample, name in samps:
        hist = sample.drawHistogram("cos_theta", cut.cut_str, plot_range=[40, -1, 1])
        
        #normalize to 20/fb
        hist.normalize_lumi(20000)
        
        hist.hist.SetName(name)
        hist.hist.SetTitle("%s: %.3E" % (name, hist.hist.Integral()))
        hist.update()
        
        hists.append(hist)
        print "%s: %.3E" % (name, hist.hist.Integral())

    title = "%s cos-theta with different processings" % sample.name
    title += " normalized to 20/fb"
        
    canv = plot_hists(hists, do_log_y=False, title=title, x_label="cos #theta")
    leg = legend(hists, pos="top-right-small")
    canv.SaveAs("final_plot.pdf")
    #canvas_margin(canv, 0.3)