Example #1
0
def MakeMuMuPlots( save=False, detail=100, ph_cuts='', dirPostfix='', activate_data=False ) :

    subdir='TAndPMuMuPlots'

    cmd_loose = ' muprobe_pt > 0 '
    cmd_tight = ' muprobe_passTight == 1 '
    cmd_trig  = ' muprobe_triggerMatch == 1 && muprobe_passTight==1 '

    eta_bins_lowpt  = [0.0, 0.1, 0.2, 0.3, 0.4, 0.8, 1.2, 1.6, 1.8, 2.1, 2.3, 2.4]
    eta_bins_highpt = [0.0, 0.1, 0.2, 0.3, 0.4, 0.8, 1.2, 1.6, 1.8, 2.4]
    low_pt_bins_tight = range( 10, 30, 5) 
    low_pt_bins_trig = range( 24, 30, 2)
    med_pt_bins = [30, 40, 50]
    high_pt_bins = [100, 200, 1000000]

    pt_eta_bins_tight = pair_pt_eta_bins( [ (low_pt_bins_tight, eta_bins_lowpt ), (med_pt_bins, eta_bins_lowpt), ( high_pt_bins, eta_bins_highpt ) ] )
    pt_eta_bins_trig  = pair_pt_eta_bins( [ (low_pt_bins_trig, eta_bins_lowpt ) , (med_pt_bins, eta_bins_lowpt), ( high_pt_bins, eta_bins_highpt ) ] )
    pt_eta_bins_comb = pair_pt_eta_bins( [(low_pt_bins_tight, eta_bins_lowpt), (low_pt_bins_trig, eta_bins_lowpt), (med_pt_bins, eta_bins_lowpt), ( high_pt_bins, eta_bins_highpt )  ]  )

    PTMAX = high_pt_bins[-1]

    #------------------------------------
    # Make plots in each pt and eta region
    # for loose muons
    # use combined bins because
    # loose is the denominator for both 
    # tight and trig
    #------------------------------------
    for (ptmin, ptmax), etabins in pt_eta_bins_comb.iteritems() :
        for etamin, etamax in etabins :

            samplesMuMu.Draw('m_mutagprobe', 'PUWeight * ( muprobe_pt > %d && muprobe_pt < %d && fabs( muprobe_eta ) > %f && fabs(muprobe_eta) < %f  )' %(ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{#mu probe, #mu tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'Loose muons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesMuMu.config_legend(  legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_mutagprobe__loose__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_mutagprobe__loose__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesMuMu.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)


    #------------------------------------
    # Make plots in each pt and eta region
    # for tight muons
    #------------------------------------
    for (ptmin, ptmax), etabins in pt_eta_bins_tight.iteritems() :
        for etamin, etamax in etabins :

            samplesMuMu.Draw('m_mutagprobe', 'PUWeight * ( %s && muprobe_pt > %d && muprobe_pt < %d && fabs( muprobe_eta ) > %f && fabs(muprobe_eta) < %f  )' %(cmd_tight, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{#mu probe, #mu tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'Tight muons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesMuMu.config_legend(  legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_mutagprobe__tight__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_mutagprobe__tight__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesMuMu.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)

    #------------------------------------
    # Make plots in each pt and eta region
    # for trig muons
    #------------------------------------
    for (ptmin, ptmax), etabins in pt_eta_bins_trig.iteritems() :
        for etamin, etamax in etabins :

            samplesMuMu.Draw('m_mutagprobe', 'PUWeight * ( %s && muprobe_pt > %d && muprobe_pt < %d && fabs( muprobe_eta ) > %f && fabs(muprobe_eta) < %f  )' %(cmd_trig, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{#mu probe, #mu tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'Trigger muons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesMuMu.config_legend(  legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_mutagprobe__trig__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_mutagprobe__trig__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesMuMu.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)
Example #2
0
def MakeElElPlots( ) :

    subdir = 'TAndPElElPlots'

    cmd_loose = 'elprobe_isPh==1'
    cmd_obj   = 'elprobe_isEl==1 && elprobe_isPh==1'
    cmd_tight = 'elprobe_isEl==1 && elprobe_isPh==0 && elprobe_passMVANonTrig==1'
    cmd_trig  = 'elprobe_isEl==1 && elprobe_isPh==0 && elprobe_passMVATrig==1 && elprobe_triggerMatch==1 '



    eta_bins_lowpt  = [0.0, 0.1, 0.2, 0.3, 0.4, 0.8, 1.2, 1.6, 1.8, 2.1, 2.3, 2.4]
    eta_bins_highpt = [0.0, 0.1, 0.2, 0.3, 0.4, 0.8, 1.2, 1.6, 1.8, 2.4]
    low_pt_bins_tight = range( 10, 30, 5) + [30, 40, 50 ] 
    low_pt_bins_trig = range( 24, 30, 2) + [30, 40, 50 ]
    high_pt_bins = [50, 100, 200, 1000000]

    pt_eta_bins_tight = pair_pt_eta_bins( [ (low_pt_bins_tight, eta_bins_lowpt ), ( high_pt_bins, eta_bins_highpt ) ] )
    pt_eta_bins_trig  = pair_pt_eta_bins( [ (low_pt_bins_trig, eta_bins_lowpt ), ( high_pt_bins, eta_bins_highpt ) ] )

    pt_eta_bins_tight = pair_pt_eta_bins( [ (low_pt_bins_tight, eta_bins_lowpt ), ( high_pt_bins, eta_bins_highpt ) ] )
    pt_eta_bins_trig  = pair_pt_eta_bins( [ (low_pt_bins_trig, eta_bins_lowpt ) , ( high_pt_bins, eta_bins_highpt ) ] )
    pt_eta_bins_comb = pair_pt_eta_bins( [(low_pt_bins_tight, eta_bins_lowpt), (low_pt_bins_trig, eta_bins_lowpt), ( high_pt_bins, eta_bins_highpt )  ]  )

    PTMAX = high_pt_bins[-1]

    #------------------------------------
    # Make plots in each pt and eta region
    # for loose electrons
    # use combined bins because
    #------------------------------------
    for (ptmin, ptmax), etabins in pt_eta_bins_tight.iteritems() :
        for etamin, etamax in etabins :

            samplesElEl.Draw('m_eltagprobe', 'PUWeight * ( %s && elprobe_pt > %d && elprobe_pt < %d && fabs( elprobe_eta ) > %f && fabs(elprobe_eta) < %f  )' %(cmd_loose, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{e probe, e tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'SC Electrons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesElEl.config_legend( legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_eltagprobe__loose__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_eltagprobe__loose__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesElEl.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)


    #------------------------------------
    # Make plots in each pt and eta region
    # for obj electrons
    # use combined bins because
    # obj is the denominator for both 
    # tight and trig
    #------------------------------------

    for (ptmin, ptmax), etabins in pt_eta_bins_comb.iteritems() :
        for etamin, etamax in etabins :

            samplesElEl.Draw('m_eltagprobe', 'PUWeight * ( %s && elprobe_pt > %d && elprobe_pt < %d && fabs( elprobe_eta ) > %f && fabs(elprobe_eta) < %f  )' %(cmd_obj, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{e probe, e tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'Reco Electrons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesElEl.config_legend( legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_eltagprobe__obj__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_eltagprobe__obj__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesElEl.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)

    #------------------------------------
    # Make plots in each pt and eta region
    # for tight electrons
    #------------------------------------

    for (ptmin, ptmax), etabins in pt_eta_bins_tight.iteritems() :
        for etamin, etamax in etabins :

            samplesElEl.Draw('m_eltagprobe', 'PUWeight * ( %s && elprobe_pt > %d && elprobe_pt < %d && fabs( elprobe_eta ) > %f && fabs(elprobe_eta) < %f  )' %(cmd_tight, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{e probe, e tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'MVA Electrons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesElEl.config_legend( legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_eltagprobe__tight__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_eltagprobe__tight__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesElEl.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)

    #------------------------------------
    # Make plots in each pt and eta region
    # for trig electrons
    #------------------------------------

    for (ptmin, ptmax), etabins in pt_eta_bins_trig.iteritems() :
        for etamin, etamax in etabins :

            samplesElEl.Draw('m_eltagprobe', 'PUWeight * ( %s && elprobe_pt > %d && elprobe_pt < %d && fabs( elprobe_eta ) > %f && fabs(elprobe_eta) < %f  )' %(cmd_trig, ptmin, ptmax, etamin, etamax ), (50, 60, 160) , hist_config={'ymin': 0.1, 'ymax':10000, 'logy':1, 'xlabel':'M_{e probe, e tag}',}, label_config={'labelStyle':'fancy', 'extra_label':'Trigger Electrons', 'extra_label_loc':(0.2, 0.87)}, legend_config=samplesElEl.config_legend( legendCompress=1.2, legendWiden=1.2 ) )

            if  ptmax >= PTMAX :
                name = 'm_eltagprobe__trig__eta_%.2f-%.2f__pt_%d-max' %(etamin, etamax, ptmin)
            else :
                name = 'm_eltagprobe__trig__eta_%.2f-%.2f__pt_%d-%d' %(etamin, etamax, ptmin, ptmax)
            samplesElEl.SaveStack( name, options.outputDir +'/' +subdir, 'base', write_command=True)