Exemple #1
0
def main(options,args) :
    
    print 'Loading c++...'
    anaplot.LoadRootCore()
    ROOT.gROOT.SetBatch(False)

    plotfunc.SetupStyle()
    style = ROOT.gROOT.GetStyle('mystyle')
    style.SetEndErrorSize(0)

    channel = 'all'
    if options.e :
        channel = 'Ele'
    if options.mu :
        channel = 'Mu'

    options.key = 'FFTool_ttt_%sNum'%(channel)
    
    #
    # Draw plots
    #
    print 'Drawing the plots'
    cans = []
    for v in options.variables.split(',') :
        if not v : continue
        xlabel = options.histformat[v][3]
        n,low,high = options.histformat[v][:3]

        bkg_hists = []
        sig_hists = []
        data_hist = None

        rebin = []
        if hasattr(options.usermodule,'rebin') and v in options.usermodule.rebin.keys() :
            rebin = options.usermodule.rebin[v]

        if options.file :
            bkg_processes = options.processes.replace('data','').replace(',,',',')
            #bkg_hists = anaplot.GetPassEventBkgHistos(v,options.key,bkg_processes,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)

            bkg_hists.append(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'vvv',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.05,0.20))[0])
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'tother',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.05,0.13))[0])
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'tz',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.05,0.15))[0])
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'ttv',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.05,0.13))[0])
#             bkg_hists[-1].Scale(3.15813/3.20905) # all other MC (but not ttbar) scaled down lumi-wise
            
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'ttbar',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.32)[0])
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'tw',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.32)[0])
            AddIf(bkg_hists[-1],anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'qqww',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.32))
            #bkg_hists[-1].SetTitle('t#bar{t}/Wt/WW/ttv/other')
            bkg_hists[-1].SetTitle('Others')

            bkg_hists.append(anaplot.GetPassEventBkgHistos(v,'FFTool_ttt_%sNum'%(channel),'zz',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.05,0.08,0.04))[0])
#             bkg_hists[-1].Scale(3.15813/3.20905) # ZZ scaled down lumi-wise
            bkg_hists[-1].SetTitle('ZZ')

            bkg_hists.append(anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'zjetdd' ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True)[0])
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'ttbar' ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True)[0],-1)
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'tw'    ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True)[0],-1)
            AddIf(bkg_hists[-1],anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'qqww',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True),-1)
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'wz'    ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True)[0],-1)
            bkg_hists[-1].Add(anaplot.GetPassEventBkgHistos(v,'FFTool_z_data_ltt_%sNum'%(channel),'zz'    ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.00,ltt_tlt_ttl=True)[0],-1)
            for i in range(bkg_hists[-1].GetNbinsX()) :
                bkg_hists[-1].SetBinError(i+1,bkg_hists[-1].GetBinContent(i+1)*0.38)
            
            bkg_hists[-1].SetTitle('Z+j / Z#gamma')
            import math
            pm = u"\u00B1"
            print '%s: %2.2f%s%2.2f'%('zjetdd',bkg_hists[-1].Integral(0,bkg_hists[-1].GetNbinsX()+1),pm,math.sqrt(sum(list(bkg_hists[-1].GetSumw2()))))

            bkg_hists += anaplot.GetPassEventBkgHistos(v,options.key,'wz',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=Q(0.07,0.05))
            bkg_hists[-1].Scale(1.17/1.15)
            bkg_hists[-1].SetTitle('W^{#pm}Z #times 1.17')

#             bkg_hists = []
#             bkg_hists.append(ROOT.TH1F('hist','hist',500,0,500))
#             for i in range(bkg_hists[-1].GetNbinsX()) :
#                 bkg_hists[-1].Fill(i+0.5)

#             for i in bkg_hists :
#                 taxisfunc.PutOverflowIntoLastBin(i,high)

#             for b in bkg_hists :
#                 if b.GetTitle() == 'zjetdd' :
#                     for i in range(b.GetNbinsX()) :
#                         b.SetBinError(i+1,b.GetBinContent(i+1)*0.38)
#                 if b.GetTitle() == 't#bar{t}/Wt/WW/ttv/other' :
#                     for i in range(b.GetNbinsX()) :
#                         b.SetBinError(i+1,b.GetBinContent(i+1)*0.32)
#                 if b.GetTitle() == '' :
#                     for i in range(b.GetNbinsX()) :
#                         b.SetBinError(i+1,b.GetBinContent(i+1)*0.32)

            anaplot.PrepareBkgHistosForStack(bkg_hists,colors_dict = colors_dict)

            for i in bkg_hists[:-1] :
                i.SetLineColor(i.GetFillColor())
            bkg_hists[-1].SetLineColor(ROOT.kRed)

            if 'data' in options.processes :
                data_hist = anaplot.GetPassEventBkgHistos(v,options.key,'data',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)[0]
                #data_hist = anaplot.GetPassEventBkgHistos(v,'FFTool_z_mccl_ltt_%sNum'%(channel),'zjetdd',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)[0]
                taxisfunc.PutOverflowIntoLastBin(data_hist,high)
                
        if options.susy :
            sig_hists = anaplot.GetPassEventSigHistos(v,options.key,options.susy,normalize=options.normalize,rebin=rebin)


        cans.append(DrawHistos('%s_%s'%(options.key,v),v,xlabel,bkg_hists,sig_hists,data_hist=data_hist,dostack=options.stack,log=options.log,ratio=options.ratio,fb=options.fb))
        taxisfunc.SetXaxisRanges(cans[-1],low,high)
        taxisfunc.SetYaxisRanges(cans[-1],0,57.15)

    #
    # Cutflow
    #
    f = ROOT.TFile(options.file)
    if f.IsZombie() :
        print 'exiting'
        return
    PrintCutflow(options.key
                 ,f.Get('PassEvent_%s/PassEvent_%s_PassW'%(options.key,options.key))
                 ,samp_list=options.processes.split(',')+['all']
                 ,scientific=True)
    f.Close()

    raw_input('Pausing. Press enter to exit.')
            
    if options.save :
        for can in cans :
            can.Print(can.GetName()+'.pdf')
            can.Print(can.GetName()+'.eps')

    print 'done.'
    return
Exemple #2
0
def main(options,args) :
    
    print 'Loading c++...'
    anaplot.LoadRootCore()
    ROOT.gROOT.SetBatch(False)

    plotfunc.SetupStyle()
    ROOT.gStyle.SetPaintTextFormat("4.3f ")
    
    #
    # Draw plots
    #
    print 'Drawing the plots'
    cans = []
    for v in options.variables.split(',') :
        if not v : continue
        xlabel = options.histformat[v][3]
        n,low,high = options.histformat[v][:3]

        bkg_hists = []
        sig_hists = []
        data_hist = None

        rebin = []
        if hasattr(options.usermodule,'rebin') and v in options.usermodule.rebin.keys() :
            rebin = options.usermodule.rebin[v]

        if options.file :
            bkg_processes = options.processes.replace('data','').replace(',,',',')
            bkg_hists = anaplot.GetPassEventBkgHistos(v,options.key,bkg_processes,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)
            anaplot.PrepareBkgHistosForStack(bkg_hists)
            if 'data' in options.processes :
                data_hist = anaplot.GetPassEventBkgHistos(v,options.key,'data',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)[0]
                #data_hist = anaplot.GetPassEventBkgHistos(v,'FFTool_z_mccl_ltt_allNum','zjetdd',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)[0]

                
        if options.susy :
            sig_hists = anaplot.GetPassEventSigHistos(v,options.key,options.susy,normalize=options.normalize,rebin=rebin)


        cans.append(anaplot.DrawHistos('%s_%s'%(options.key,v),v,xlabel,bkg_hists,sig_hists,data_hist=data_hist,dostack=options.stack,log=options.log,ratio=options.ratio,fb=options.fb))
        taxisfunc.SetXaxisRanges(cans[-1],low,high)

    #
    # Cutflow
    #
    f = ROOT.TFile(options.file)
    if f.IsZombie() :
        print 'exiting'
        return
    PrintCutflow(options.key
                 ,f.Get('PassEvent_%s/PassEvent_%s_PassW'%(options.key,options.key))
                 ,samp_list=options.processes.split(',')+['all']
                 ,scientific=True)
    f.Close()

    raw_input('Pausing. Press enter to exit.')
            
    if options.save :
        for can in cans :
            can.Print(can.GetName()+'.pdf')
            can.Print(can.GetName()+'.eps')

    print 'done.'
    return
Exemple #3
0
def main(options, args):

    print 'Loading c++...'
    anaplot.LoadRootCore()
    ROOT.gROOT.SetBatch(False)

    plotfunc.SetupStyle()
    style = ROOT.gROOT.GetStyle('mystyle')
    style.SetEndErrorSize(0)
    ROOT.gStyle.SetPaintTextFormat("4.3f ")

    #
    # Draw plots
    #
    print 'Drawing the plots'
    cans = []
    for v in options.variables.split(','):
        if not v: continue
        xlabel = options.histformat[v][3]
        n, low, high = options.histformat[v][:3]

        bkg_hists = []
        sig_hists = []
        data_hist = None

        rebin = []
        if hasattr(options.usermodule,
                   'rebin') and v in options.usermodule.rebin.keys():
            rebin = options.usermodule.rebin[v]

        if options.file:
            bkg_hists = []
            bkg_hists.append(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'zz',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=Q(0.05, 0.08,
                                                            0.04))[0])
            bkg_hists[-1].Add(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'vvv',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=Q(0.05, 0.20))[0])
            bkg_hists[-1].SetTitle('Others')
            bkg_hists.append(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'ttv',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=Q(0.05, 0.13))[0])
            bkg_hists[-1].SetTitle('tt+V')
            bkg_hists.append(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'wz',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=Q(0.05, 0.07))[0])
            bkg_hists[-1].Scale(1.17 / 1.15)
            bkg_hists[-1].SetTitle('W^{#pm}Z #times 1.17')
            bkg_hists.append(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'ttbar',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=0.)[0])
            bkg_hists[-1].Add(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'tw',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=0.)[0])
            bkg_hists[-1].Add(
                anaplot.GetPassEventBkgHistos(v,
                                              options.key,
                                              'qqww',
                                              options.file,
                                              normalize=options.normalize,
                                              rebin=rebin,
                                              n=n,
                                              low=low,
                                              high=high,
                                              globalError=0.)[0])
            bkg_hists[-1].SetTitle('t#bar{t} / Wt / WW')

            #bkg_hists.append(anaplot.GetPassEventBkgHistos(v,options.key,'zjet' ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.)[0])
            #bkg_hists.append(anaplot.GetPassEventBkgHistos(v,options.key,'zgam' ,options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high,globalError=0.)[0])

            anaplot.PrepareBkgHistosForStack(bkg_hists,
                                             colors_dict=colors_dict)

            for i in bkg_hists:
                i.SetLineColor(i.GetFillColor())

            data_hist = anaplot.GetPassEventBkgHistos(
                v,
                options.key,
                'data',
                options.file,
                normalize=options.normalize,
                rebin=rebin,
                n=n,
                low=low,
                high=high)[0]
            #data_hist = anaplot.GetPassEventBkgHistos(v,'FFTool_z_mccl_ltt_allNum','zjetdd',options.file,normalize=options.normalize,rebin=rebin,n=n,low=low,high=high)[0]

        if options.susy:
            sig_hists = anaplot.GetPassEventSigHistos(
                v,
                options.key,
                options.susy,
                normalize=options.normalize,
                rebin=rebin)

        #bkg_hists[0].GetXaxis().SetNdivisions(5,0,0)
        cans.append(
            DrawHistos('%s_%s' % (options.key, v),
                       v,
                       xlabel,
                       bkg_hists,
                       sig_hists,
                       data_hist=data_hist,
                       dostack=options.stack,
                       log=options.log,
                       ratio=options.ratio,
                       fb=options.fb))
        taxisfunc.SetXaxisRanges(cans[-1], low, high)
        taxisfunc.SetYaxisRanges(cans[-1], 0, 12 * 0.9525)
        taxisfunc.SetNdivisions(cans[-1], 9, 0, 0)

    #
    # Cutflow
    #
    f = ROOT.TFile(options.file)
    if f.IsZombie():
        print 'exiting'
        return
    PrintCutflow(options.key,
                 f.Get('PassEvent_%s/PassEvent_%s_PassW' %
                       (options.key, options.key)),
                 samp_list=options.processes.split(',') + ['all'],
                 scientific=True)
    f.Close()

    raw_input('Pausing. Press enter to exit.')

    if options.save:
        for can in cans:
            can.Print(can.GetName() + '.pdf')
            can.Print(can.GetName() + '.eps')

    print 'done.'
    return