Example #1
0
def plot_shape_comparison(n, mass, gg = False):
    add_txt = ''
    if gg:
        add_txt = 'gg_'
    if n == 1:
        chp_1_500 = create_histos('/net/scratch_cms/institut_3a/13TeV_rpv_LFV_resonances/QBH_emu/CalcHEP_n_%i_RS/QBH_n%i_RS_Mth-MPL%i.lhe'%(n, n, mass), gg)
        qbh_1_500 = create_histos('/disk1/erdweg/QBH/lhes/LHEFQBH_n%i_RS_%s%i.lhe'%(n, add_txt, mass), gg)
    else:
        chp_1_500 = create_histos('/net/scratch_cms/institut_3a/13TeV_rpv_LFV_resonances/QBH_emu/CalcHEP_n_%i_PDG/QBH_n%i_ADD_Mth-MPL%i.lhe'%(n, n, mass), gg)
        qbh_1_500 = create_histos('/disk1/erdweg/QBH/lhes/LHEFQBH_n%i_ADD_%s%i.lhe'%(n, add_txt, mass), gg)

    hists = [[0,'ele_pT','$p_{T}^{ele}$ (GeV)'],
             [1,'ele_phi','$\phi_{ele}$ (GeV)'],
             [2,'ele_eta','$\eta_{ele}$ (GeV)'],
             [3,'muo_pT','$p_{T}^{muo}$ (GeV)'],
             [4,'muo_phi','$\phi_{muo}$ (GeV)'],
             [5,'muo_eta','$\eta_{muo}$ (GeV)'],
             [6,'emu_mass','$M_{ele,muo}$ (GeV)']]

    for item in hists:
        hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Linegraphs', cmsPositon = "upper right", legendPosition = 'lower left', lumi = 0, cms = 13)

        hist_style.Set_additional_text('Simulation')
    
        # hist_style.Set_axis(logy = True, grid = True, xmin = 200, xmax = 2000, histaxis_ymin = 1.0, histaxis_ymax = 1.5)

        ratio = chp_1_500[item[0]].Clone('ratio')
        ratio.Divide(qbh_1_500[item[0]])

        dummy_chp = Graph(chp_1_500[item[0]])
        dummy_qbh = Graph(qbh_1_500[item[0]])

        dummy_chp.SetLineColor('red')
        dummy_chp.SetTitle('CalcHEP, n = %i, M = %i'%(n, mass))
        dummy_chp.xaxis.SetTitle('%s'%(item[2]))
        dummy_qbh.SetLineColor('green')
        dummy_qbh.SetTitle('QBH, n = %i, M = %i'%(n, mass))
        dummy_qbh.xaxis.SetTitle('%s'%(item[2]))

        test = plotter(hist = [dummy_chp, dummy_qbh], style=hist_style)

        test.Add_plot('Empty',pos=1, height=15, label='CalcHEP/QBH')

        test.create_plot()

        duke_errorbar(ratio, xerr = hist_style.Get_xerr(), emptybins = False, axes = test.Get_axis2(),
                      markersize = hist_style.Get_marker_size(),
                      marker = hist_style.Get_marker_style(),
                      ecolor = hist_style.Get_marker_color(),
                      markerfacecolor = hist_style.Get_marker_color(),
                      markeredgecolor = hist_style.Get_marker_color(),
                      capthick = hist_style.Get_marker_error_cap_width(),
                      zorder = 2.2)

        test.Get_axis2().set_ylim(ymin = 0, ymax = 2)

        test.SavePlot(item[1] + '_%i_%i_comparison.pdf'%(n, mass))
Example #2
0
    def __init__(self,
                 sc_obj=style_class.style_container(useRoot=True),
                 extraText=None,
                 additionalText=None,
                 lumiText="19.7 fb^{-1} (8 TeV)",
                 position=None,
                 vspace=0,
                 hspace=0,
                 referenceHeight=None,
                 pad=None):
        import style_class
        self._style = sc_obj
        #self._style.InitStyle()
        self.relPosX = 0.055  #relative padding
        self.relPosY = 0.035  #55
        self.relExtraDY = 1.3  #line height

        self.lumiText = lumiText
        self.lumiTextOffset = 0.2
        self.extraTextOffset = 2.5  # only used in outOfFrame version

        if extraText != None:
            self.extraText = extraText
        else:
            self.extraText = ""
        if additionalText != None:
            self.additionalText = additionalText
        else:
            self.additionalText = ""

        if pad:
            self.pad = pad
        else:
            for i in range(1000):
                self.pad = ROOT.gROOT.GetSelectedPad()
                #print "mark",self.pad
                if repr(self.pad) != "<ROOT.TVirtualPad object at 0x(nil)>":
                    break

        if position is None:
            self._style._cmsTextPosition = style_class.position(
                positiontext="lower left", isText=True)
        if type(position) == str:
            self._style._cmsTextPosition = style_class.position(
                positiontext=position, isText=True)
        else:
            self._style._cmsTextPosition = position

        self.align_ = 2
        if self._style._cmsTextPosition.getX() <= 0.3:
            self.align_ += 10
        elif self._style._cmsTextPosition.getX(
        ) > 0.3 and self._style._cmsTextPosition.getX() < 0.7:
            self.align_ += 20
        elif self._style._cmsTextPosition.getX() >= 0.7:
            self.align_ += 30
Example #3
0
def main():

    basedir="/disk1/erdweg/out/output2015_8_3_16_34/merged/"

    colors = ['lime', 'deepskyblue', 'magenta', 'orangered', 'lightblue', 'gray']

    bglist=OrderedDict()

    bglist = ['QCD_Pt-15TTo7000-Flat_13TeV_P6']

    # bglist = ['QCD_Pt_5to10_13TeV_P8',
     # 'QCD_Pt_80to120_13TeV_P8',
     # 'QCD_Pt_120to170_13TeV_P8',
     # 'QCD_Pt_170to300_13TeV_P8',
     # 'QCD_Pt_300to470_13TeV_P8',
     # 'QCD_Pt_1000to1400_13TeV_P8',
     # 'QCD_Pt_1400to1800_13TeV_P8',
     # 'QCD_Pt_1800to2400_13TeV_P8',
     # 'QCD_Pt_2400to3200_13TeV_P8',
     # 'QCD_Pt_3200toInf_13TeV_P8',
    # ]

    hists2D=['JetFakeRate/eff_JetFakeRate_vs_pT_vs_eta'
    ]

    titles={
     'HLT_Effs/eff_HLT_HLT_Mu40_v1_vs_Nvtx':['HLT_Mu40_v1 efficiency','$N_{vtx}$','efficiency $\epsilon$']
    }

    yranges={
     'ID_Effs/eff_Muon_ID_vs_pT':[0.8,1.02],
    }

    for hist in hists2D:

        print("Now plotting: " + hist)

        hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower right', lumi = 0, cms = 13)

        hist_style.Set_additional_text('Simulation')

        name=hist.replace("/","")

        tfile = root_open(basedir + bglist[0] + ".root", "READ")
        t_eff = tfile.Get(hist)

        for i in range(1,len(bglist)-1):
            tfile = root_open(basedir + bglist[i] + ".root", "READ")
            t_eff = eff_adder(t_eff, tfile.Get(hist))

        ################################################################
        #
        # Projection along the xaxis:
        # Fake rate as a function of pT
        #
        ################################################################
        print('\t--> X-Projections')
        x_proj = project_x(t_eff)
        x_proj = Graph(x_proj.CreateGraph())
        x_proj.SetTitle('Combined')
        x_proj.SetColor(colors[0])
        x_proj.xaxis.SetTitle('$E_{T}$ (GeV)')
        x_proj.yaxis.SetTitle('Fake rate')

        x_proj_barrel = project_x(t_eff,1,15)
        x_proj_barrel = Graph(x_proj_barrel.CreateGraph())
        x_proj_barrel.SetTitle('Barrel')
        x_proj_barrel.SetColor(colors[1])

        x_proj_endcap = project_x(t_eff,16,-1)
        x_proj_endcap = Graph(x_proj_endcap.CreateGraph())
        x_proj_endcap.SetTitle('Endcap')
        x_proj_endcap.SetColor(colors[2])

        test = plotter(hist = [x_proj,x_proj_barrel,x_proj_endcap], style = hist_style)

        test.Set_axis(logy = True, xmin = 0, xmax = 1500, ymin = 1e-4, ymax = 1e0)

        test.create_plot()

        test.SavePlot('plots/%s_%s_x.pdf'%(bglist[0],name))

        ################################################################
        #
        # Projection along the yaxis:
        # Fake rate as a function of eta
        #
        ################################################################

        print('\t--> Y-Projections')
        y_proj = project_y(t_eff)
        y_proj = Graph(y_proj.CreateGraph())
        y_proj.SetTitle('Combined')
        y_proj.SetColor(colors[0])
        y_proj.xaxis.SetTitle('$|\eta|$')
        y_proj.yaxis.SetTitle('Fake rate')

        y_proj_100 = project_y(t_eff,1,10)
        y_proj_100 = Graph(y_proj_100.CreateGraph())
        y_proj_100.SetTitle('$E_{T} < 100\,$GeV')
        y_proj_100.SetColor(colors[1])

        y_proj_200 = project_y(t_eff,11,20)
        y_proj_200 = Graph(y_proj_200.CreateGraph())
        y_proj_200.SetTitle('$100\,$GeV$ < E_{T} < 200\,$GeV')
        y_proj_200.SetColor(colors[2])

        y_proj_500 = project_y(t_eff,21,50)
        y_proj_500 = Graph(y_proj_500.CreateGraph())
        y_proj_500.SetTitle('$200\,$GeV$ < E_{T} < 500\,$GeV')
        y_proj_500.SetColor(colors[3])

        y_proj_1000 = project_y(t_eff,51,100)
        y_proj_1000 = Graph(y_proj_1000.CreateGraph())
        y_proj_1000.SetTitle('$500\,$GeV$ < E_{T} < 1000\,$GeV')
        y_proj_1000.SetColor(colors[4])

        y_proj_inf = project_y(t_eff,101,-1)
        y_proj_inf = Graph(y_proj_inf.CreateGraph())
        y_proj_inf.SetTitle('$1000\,$GeV$ < E_{T}$')
        y_proj_inf.SetColor(colors[5])

        test = plotter(hist = [y_proj, y_proj_100, y_proj_200, y_proj_500, y_proj_1000, y_proj_inf], style = hist_style)

        test.Set_axis(logy = True, xmin = 0, xmax = 2.5, ymin = 1e-4, ymax = 1e0)

        test.create_plot()

        test.SavePlot('plots/%s_%s_y.pdf'%(bglist[0],name))

        ################################################################
        #
        # 2D Plot
        # Fake rate as a function of eta and pT
        #
        ################################################################

        print('\t--> 2D Plot')
        hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "outside left", legendPosition = 'lower middle', lumi = 0, cms = 13)

        hist_style.Set_additional_text('Simulation')

        t_eff = t_eff.CreateHistogram()
        t_eff.SetTitle(bglist[0])

        test = plotter2D(hist = t_eff, style = hist_style)

        test.Set_axis(xmin = 0, xmax = 1500, ymin = 0, ymax = 2.6, zmin = 0, zmax = 1)

        test.create_plot()

        test.save_plot('plots/%s_%s.pdf'%(bglist[0],name))

    return 42
Example #4
0
def main():

    basedir="/disk1/erdweg/out/output2015_3_24_14_16/merged/"
    # lumi=19712

    # xs= ConfigObj("/disk1/erdweg/plotting/xs_Phys14.cfg")
    # bghists=HistStorage(xs,lumi,path=basedir,isData=True)

    bglist=OrderedDict()

    bglist["PU20bx25"]=['ZprimeToTauTau_M-1000_PU20bx25_PHYS14',
     'ZprimeToTauTau_M-5000_PU20bx25_PHYS14'
    ]
    bglist["AVE30BX50"]=['ZprimeToTauTau_M-1000_AVE30BX50_PHYS14',
     'ZprimeToTauTau_M-5000_AVE30BX50_PHYS14',
     ]
    bglist["PU40bx25"]=['ZprimeToTauTau_M-1000_PU40bx25_PHYS14',
     'ZprimeToTauTau_M-5000_PU40bx25_PHYS14',
    ]

    # bghists.addFileList(bglist)

    colorList={}
    colorList["PU20bx25"]=["lightblue","cornflowerblue"]
    colorList["AVE30BX50"]=["lightgreen","limegreen"]
    colorList["PU40bx25"]=["darkmagenta","orchid"]

    hists=[['RECO_Effs/eff_Ele_RECO_vs_Nvtx','RECO_Effs/eff_Ele_RECO_vs_Nvtx_in_Acc'],
     ['RECO_Effs/eff_Ele_RECO_vs_pT','RECO_Effs/eff_Ele_RECO_vs_pT_in_Acc'],
     ['RECO_Effs/eff_MET_RECO_vs_Nvtx'],
     ['RECO_Effs/eff_MET_RECO_vs_pT'],
     ['RECO_Effs/eff_Muon_RECO_vs_Nvtx','RECO_Effs/eff_Muon_RECO_vs_Nvtx_in_Acc'],
     ['RECO_Effs/eff_Muon_RECO_vs_pT','RECO_Effs/eff_Muon_RECO_vs_pT_in_Acc'],
     ['RECO_Effs/eff_Tau_RECO_vs_Nvtx','RECO_Effs/eff_Tau_RECO_vs_Nvtx_in_Acc'],
     ['RECO_Effs/eff_Tau_RECO_vs_pT','RECO_Effs/eff_Tau_RECO_vs_pT_in_Acc'],
    ]

    hists2D_eff=['RECO_Effs/eff_Tau_RECO_vs_eta_vs_phi',
     'RECO_Effs/eff_Tau_RECO_vs_eta_vs_phi_in_Acc',
     'RECO_Effs/eff_Muon_RECO_vs_eta_vs_phi',
     'RECO_Effs/eff_Muon_RECO_vs_eta_vs_phi_in_Acc',
     'RECO_Effs/eff_MET_RECO_vs_eta_vs_phi',
     'RECO_Effs/eff_Ele_RECO_vs_eta_vs_phi',
     'RECO_Effs/eff_Ele_RECO_vs_eta_vs_phi_in_Acc',
    ]

    hists2D=['RECO_Effs/h2_Tau_RECO_vs_gendm_vs_recodm_0_500',
     'RECO_Effs/h2_Tau_RECO_vs_gendm_vs_recodm_1000_1500',
     'RECO_Effs/h2_Tau_RECO_vs_gendm_vs_recodm_1500_2000',
     'RECO_Effs/h2_Tau_RECO_vs_gendm_vs_recodm_2000',
     'RECO_Effs/h2_Tau_RECO_vs_gendm_vs_recodm_500_1000',
    ]

    if False:
        for hist in hists:
            print("Now plotting: " + hist[0])

            histlist = []
            for item in bglist:
                counter = 0
                for it in hist:
                    tfile = root_open(basedir + bglist[item][1] + ".root", "READ")
                    t_eff = Graph(tfile.Get(it).CreateGraph())
                    t_eff.SetLineColor(colorList[item][counter])
                    if counter == 1:
                        t_eff.SetTitle(item+" in Acc.")
                    else:
                        t_eff.SetTitle(item)
                    if 'Nvtx' in it:
                        t_eff.xaxis.SetTitle('$N_{vtx}$')
                    if 'pT' in it:
                        t_eff.xaxis.SetTitle('$p_{T}$ (GeV)')
                    t_eff.yaxis.SetTitle('$\epsilon$')
                    histlist.append(t_eff)
                    counter += 1

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper right", legendPosition = 'lower middle', lumi = 1000, cms = 13)

            hist_style.Set_additional_text('work in progress')

            test = plotter(hist = histlist, style=hist_style)

            test.Set_axis(logy = False, grid = True)

            test._cms_text_x         = 0.12
            test._cms_text_y         = 0.91

            name=hist[0].replace("/","")

            test.make_plot('plots/%s.pdf'%(name))

    if False:
        for hist in hists2D_eff:
            print("Now plotting: " + hist)

            histlist = []
            for item in bglist:
                tfile = root_open(basedir + bglist[item][1] + ".root", "READ")
                t_eff = tfile.Get(hist).CreateHistogram()
                # t_eff.SetLineColor(colorList[item])
                t_eff.SetTitle(item)
                # t_eff.xaxis.SetTitle(t_eff.GetXaxis().GetTitle())
                # t_eff.yaxis.SetTitle(t_eff.GetYaxis().GetTitle())
                histlist.append(t_eff)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 1000, cms = 13)

            hist_style.Set_additional_text('work in progress')

            test = plotter2D(hist = histlist[0], style = hist_style)

            # test.Set_axis(xmin = -2.5, xmax = 2.5, ymin = 0, ymax = 3.1, zmin = 0, zmax = 1)

            name=hist.replace("/","")

            test.create_plot()

            test.save_plot('plots/%s.pdf'%(name))

    if True:
        for hist in hists2D:
            print("Now plotting: " + hist)

            histlist = []
            for item in bglist:
                tfile = root_open(basedir + bglist[item][1] + ".root", "READ")
                t_eff = tfile.Get(hist)
                # t_eff.SetLineColor(colorList[item])
                t_eff.SetTitle(item)
                # t_eff.xaxis.SetTitle(t_eff.GetXaxis().GetTitle())
                # t_eff.yaxis.SetTitle(t_eff.GetYaxis().GetTitle())
                histlist.append(t_eff)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 1000, cms = 13)

            hist_style.Set_additional_text('work in progress')
            hist_style.Set_y_label_offset(-0.5)

            test = plotter2D(hist = histlist[0], style = hist_style)

            test.Add_y_projection(15)
            test.Add_x_projection(15)

            # test.Set_axis(xmin = -2.5, xmax = 2.5, ymin = 0, ymax = 3.1, zmin = 0, zmax = 1)

            name=hist.replace("/","")

            test.create_plot()

            x_bin_labels = []
            for i in range(1,histlist[0].GetNbinsX()+1):
                x_bin_labels.append(histlist[0].GetXaxis().GetBinLabel(i))
            print(x_bin_labels)
            y_bin_labels = []
            for i in range(1,histlist[0].GetNbinsY()+1):
                label = histlist[0].GetYaxis().GetBinLabel(i)
                label = label.replace('tauDecay','')
                label = label.replace('ChargedPion','Pi')
                label = label.replace('Zero','0')
                y_bin_labels.append(label)
            print(y_bin_labels)
            test.Get_x_projection_axis().xaxis.set_major_locator(mticker.MaxNLocator(nbins=histlist[0].GetNbinsX()))
            xtickNames = plt.setp(test.Get_x_projection_axis(), xticklabels=x_bin_labels)
            plt.setp(xtickNames, rotation=-45, fontsize=8, va='top', ha='left')
            test.Get_x_projection_axis().tick_params('x', length=0, width=0, which='major')

            test.Get_y_projection_axis().yaxis.set_major_locator(mticker.MaxNLocator(nbins=histlist[0].GetNbinsY()))
            ytickNames = plt.setp(test.Get_y_projection_axis(), yticklabels=y_bin_labels)
            plt.setp(ytickNames, fontsize=8, va='bottom', ha='right')
            test.Get_y_projection_axis().tick_params('y', length=0, width=0, which='major')

            #test.Get_z_axis().yaxis.set_major_formatter(FixedOrderFormatter(0))
            # test.Get_z_axis().yaxis.set_major_formatter(FormatStrFormatter('%.2f'))
            test.Get_x_projection_axis().ticklabel_format(style='sci', axis='y', scilimits=(0,0), useMathText=True)
            test.Get_y_projection_axis().ticklabel_format(style='sci', axis='x', scilimits=(0,0), useMathText=True)

            plt.subplots_adjust(left = .1, bottom = .13, right =  .86, top = .95)

            test.save_plot('plots/%s.pdf'%(name))

    return 42
def main():
    ####################################################################
    # Individual cross section plots
    ####################################################################

    print("Now plotting: cross section comparison")

    x_vals =[]
    y_vals_8 = []
    y_vals_8_k = []
    y_vals_13 = []
    y_vals_13_k = []
    for item in masslist:
        x_vals.append(item)
        y_vals_8.append(eight_TeV_xs[item][0])
        y_vals_8_k.append(eight_TeV_xs[item][1])
        y_vals_13.append(thirteen_TeV_xs[item][0]/1000)
        y_vals_13_k.append(thirteen_TeV_xs[item][1])

    x_vals = np.array(x_vals)
    y_vals_8 = np.array(y_vals_8)
    y_vals_8_k = np.array(y_vals_8_k)
    y_vals_13 = np.array(y_vals_13)
    y_vals_13_k = np.array(y_vals_13_k)

    graph_8 = Graph(x_vals.shape[0])
    graph_8_k = Graph(x_vals.shape[0])
    graph_13 = Graph(x_vals.shape[0])
    graph_13_k = Graph(x_vals.shape[0])
    for i, (xx, y1, y2, y3, y4) in enumerate(zip(x_vals, y_vals_8, y_vals_8_k, y_vals_13, y_vals_13_k)):
        graph_8.SetPoint(i, xx, y1)
        graph_8.SetPointError(i, 0, 0, 0, 0)
        graph_8_k.SetPoint(i, xx, y2)
        graph_8_k.SetPointError(i, 0, 0, 0, 0)
        graph_13.SetPoint(i, xx, y3)
        graph_13.SetPointError(i, 0, 0, 0, 0)
        graph_13_k.SetPoint(i, xx, y4)
        graph_13_k.SetPointError(i, 0, 0, 0, 0)

    graph_8.SetTitle('LO xs (8 TeV)')
    graph_8.xaxis.SetTitle('M (GeV)')
    graph_8.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_8_k.SetTitle('NLO k-factor (8 TeV)')
    graph_8_k.xaxis.SetTitle('$M_{\tilde{\nu}_{\tau}}$ (GeV)')
    graph_8_k.yaxis.SetTitle('k-factor')

    graph_13.SetTitle('LO xs (13 TeV)')
    graph_13.xaxis.SetTitle('$M_{\tilde{\nu}_{\tau}}$ (GeV)')
    graph_13.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_13_k.SetTitle('NLO k-factor (13 TeV)')
    graph_13_k.xaxis.SetTitle('$M_{\tilde{\nu}_{\tau}}$ (GeV)')
    graph_13_k.yaxis.SetTitle('k-factor')

    graph_8.SetLineColor('red')
    graph_8_k.SetLineColor('red')
    graph_8_k.SetLineStyle(2)
    graph_13.SetLineColor('blue')
    graph_13_k.SetLineColor('blue')
    graph_13_k.SetLineStyle(2)

    hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Linegraphs', cmsPositon = "upper right", legendPosition = 'lower left', lumi = 0, cms = 13)

    hist_style.Set_additional_text('Simulation')
    hist_style.AddAxisTitle(graph_8)

    hist_style.Set_axis(logy = True, grid = True, xmin = 200, xmax = 2000, histaxis_ymin = 1.0, histaxis_ymax = 1.5)

    test = plotter(hist = [graph_8, graph_13], hist_axis = [graph_8_k, graph_13_k], style=hist_style)
    # test = plotter(hist = [graph_8_k, graph_13_k], style=hist_style)
    # test.Add_plot(plot = 'Empty', pos = 1, height = 40, label = 'k-factor')

    test.create_plot()

    test.SavePlot('plots/xs_comparison.pdf')

    return 42
Example #6
0
def main():

    basedir="/disk1/erdweg/television/SIGNAL/merged/"
    # lumi=19712

    # xs= ConfigObj("/disk1/erdweg/plotting/xs_Phys14.cfg")
    # bghists=HistStorage(xs,lumi,path=basedir,isData=True)

    colors = ['lime', 'deepskyblue', 'magenta', 'orangered']

    bglist=OrderedDict()

    bglist = [
     'RPVresonantToEMu_M-200_LLE_LQD-001_13TeV_CA-skimid1965',
     'RPVresonantToEMu_M-300_LLE_LQD-001_13TeV_CA-skimid1829',
     'RPVresonantToEMu_M-400_LLE_LQD-001_13TeV_CA-skimid1954',
     'RPVresonantToEMu_M-500_LLE_LQD-001_13TeV_CA-skimid1827',
     'RPVresonantToEMu_M-600_LLE_LQD-001_13TeV_CA-skimid1888',
     'RPVresonantToEMu_M-700_LLE_LQD-001_13TeV_CA-skimid1884',
     'RPVresonantToEMu_M-800_LLE_LQD-001_13TeV_CA-skimid1935',
     'RPVresonantToEMu_M-900_LLE_LQD-001_13TeV_CA-skimid1966',
     'RPVresonantToEMu_M-1000_LLE_LQD-001_13TeV_CA-skimid1891',
     'RPVresonantToEMu_M-1200_LLE_LQD-001_13TeV_CA-skimid1892',
     'RPVresonantToEMu_M-1400_LLE_LQD-001_13TeV_CA-skimid1857',
     'RPVresonantToEMu_M-1600_LLE_LQD-001_13TeV_CA-skimid1859',
     'RPVresonantToEMu_M-1800_LLE_LQD-001_13TeV_CA-skimid1834',
     'RPVresonantToEMu_M-2000_LLE_LQD-001_13TeV_CA-skimid1831',
     'RPVresonantToEMu_M-2500_LLE_LQD-001_13TeV_CA-skimid1974',
     'RPVresonantToEMu_M-3000_LLE_LQD-01_13TeV_CA-skimid1835',
     'RPVresonantToEMu_M-3000_LLE_LQD-001_13TeV_CA-skimid1960',
     'RPVresonantToEMu_M-3500_LLE_LQD-001_13TeV_CA-skimid1889',
     'RPVresonantToEMu_M-3500_LLE_LQD-01_13TeV_CA-skimid2064',
     'RPVresonantToEMu_M-4000_LLE_LQD-001_13TeV_CA-skimid1833',
     'RPVresonantToEMu_M-4000_LLE_LQD-01_13TeV_CA-skimid1984',
     'RPVresonantToEMu_M-4000_LLE_LQD-02_13TeV_CA-skimid1929',
     'RPVresonantToEMu_M-4000_LLE_LQD-05_13TeV_CA-skimid1976',
     'RPVresonantToEMu_M-4500_LLE_LQD-001_13TeV_CA-skimid1832',
     'RPVresonantToEMu_M-4500_LLE_LQD-02_13TeV_CA-skimid1964',
     'RPVresonantToEMu_M-4500_LLE_LQD-05_13TeV_CA-skimid1977',
     'RPVresonantToEMu_M-5000_LLE_LQD-001_13TeV_CA-skimid1983',
     'RPVresonantToEMu_M-5000_LLE_LQD-02_13TeV_CA-skimid1975',
     'RPVresonantToEMu_M-5000_LLE_LQD-05_13TeV_CA-skimid1828',
     'RPVresonantToEMu_M-5500_LLE_LQD-001_13TeV_CA-skimid1869',
     'RPVresonantToEMu_M-5500_LLE_LQD-02_13TeV_CA-skimid1858',
     'RPVresonantToEMu_M-5500_LLE_LQD-05_13TeV_CA-skimid1830',
     'RPVresonantToEMu_M-6000_LLE_LQD-001_13TeV_CA-skimid1887',
     'RPVresonantToEMu_M-6000_LLE_LQD-02_13TeV_CA-skimid1927',
     'RPVresonantToEMu_M-6000_LLE_LQD-05_13TeV_CA-skimid1890',
     'RPVresonantToEMu_M-6500_LLE_LQD-001_13TeV_CA-skimid1967',
     'RPVresonantToEMu_M-6500_LLE_LQD-02_13TeV_CA-skimid1873',
     'RPVresonantToEMu_M-6500_LLE_LQD-05_13TeV_CA-skimid1886',
    ]

    colorList={}
    colorList['RPVresonantToEMu_M-200_LLE_LQD-001_13TeV_CA-skimid1965'] = 'lightblue'
    colorList['RPVresonantToEMu_M-300_LLE_LQD-001_13TeV_CA-skimid1829'] = 'lightblue'
    colorList['RPVresonantToEMu_M-400_LLE_LQD-001_13TeV_CA-skimid1954'] = 'lightblue'
    colorList['RPVresonantToEMu_M-500_LLE_LQD-001_13TeV_CA-skimid1827'] = 'lightblue'
    colorList['RPVresonantToEMu_M-600_LLE_LQD-001_13TeV_CA-skimid1888'] = 'lightblue'
    colorList['RPVresonantToEMu_M-700_LLE_LQD-001_13TeV_CA-skimid1884'] = 'lightblue'
    colorList['RPVresonantToEMu_M-800_LLE_LQD-001_13TeV_CA-skimid1935'] = 'lightblue'
    colorList['RPVresonantToEMu_M-900_LLE_LQD-001_13TeV_CA-skimid1966'] = 'lightblue'
    colorList['RPVresonantToEMu_M-1000_LLE_LQD-001_13TeV_CA-skimid1891'] = 'lightblue'
    colorList['RPVresonantToEMu_M-1200_LLE_LQD-001_13TeV_CA-skimid1892'] = 'lightblue'
    colorList['RPVresonantToEMu_M-1400_LLE_LQD-001_13TeV_CA-skimid1857'] = 'lightblue'
    colorList['RPVresonantToEMu_M-1600_LLE_LQD-001_13TeV_CA-skimid1859'] = 'lightblue'
    colorList['RPVresonantToEMu_M-1800_LLE_LQD-001_13TeV_CA-skimid1834'] = 'lightblue'
    colorList['RPVresonantToEMu_M-2000_LLE_LQD-001_13TeV_CA-skimid1831'] = 'lightblue'
    colorList['RPVresonantToEMu_M-2500_LLE_LQD-001_13TeV_CA-skimid1974'] = 'lightblue'
    colorList['RPVresonantToEMu_M-3000_LLE_LQD-01_13TeV_CA-skimid1835'] = 'lightblue'
    colorList['RPVresonantToEMu_M-3000_LLE_LQD-001_13TeV_CA-skimid1960'] = 'lightblue'
    colorList['RPVresonantToEMu_M-3500_LLE_LQD-001_13TeV_CA-skimid1889'] = 'lightblue'
    colorList['RPVresonantToEMu_M-3500_LLE_LQD-01_13TeV_CA-skimid2064'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4000_LLE_LQD-001_13TeV_CA-skimid1833'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4000_LLE_LQD-01_13TeV_CA-skimid1984'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4000_LLE_LQD-02_13TeV_CA-skimid1929'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4000_LLE_LQD-05_13TeV_CA-skimid1976'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4500_LLE_LQD-001_13TeV_CA-skimid1832'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4500_LLE_LQD-02_13TeV_CA-skimid1964'] = 'lightblue'
    colorList['RPVresonantToEMu_M-4500_LLE_LQD-05_13TeV_CA-skimid1977'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5000_LLE_LQD-001_13TeV_CA-skimid1983'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5000_LLE_LQD-02_13TeV_CA-skimid1975'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5000_LLE_LQD-05_13TeV_CA-skimid1828'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5500_LLE_LQD-001_13TeV_CA-skimid1869'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5500_LLE_LQD-02_13TeV_CA-skimid1858'] = 'lightblue'
    colorList['RPVresonantToEMu_M-5500_LLE_LQD-05_13TeV_CA-skimid1830'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6000_LLE_LQD-001_13TeV_CA-skimid1887'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6000_LLE_LQD-02_13TeV_CA-skimid1927'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6000_LLE_LQD-05_13TeV_CA-skimid1890'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6500_LLE_LQD-001_13TeV_CA-skimid1967'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6500_LLE_LQD-02_13TeV_CA-skimid1873'] = 'lightblue'
    colorList['RPVresonantToEMu_M-6500_LLE_LQD-05_13TeV_CA-skimid1886'] = 'lightblue'

    hists=['HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_pT(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_pT(Ele)',
     #'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_Nvtx',
     #'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_Nvtx',

     'RECO_Effs/eff_Ele_RECO_vs_Nvtx',
     'RECO_Effs/eff_Ele_RECO_vs_pT',
     # 'RECO_Effs/eff_MET_RECO_vs_Nvtx',
     # 'RECO_Effs/eff_MET_RECO_vs_pT',
     'RECO_Effs/eff_Muon_RECO_vs_Nvtx',
     'RECO_Effs/eff_Muon_RECO_vs_pT',
     # 'RECO_Effs/eff_Tau_RECO_vs_Nvtx',
     # 'RECO_Effs/eff_Tau_RECO_vs_pT',

     'RECO_Effs/eff_Ele_RECO_vs_Nvtx_in_Acc',
     'RECO_Effs/eff_Ele_RECO_vs_pT_in_Acc',
     'RECO_Effs/eff_Muon_RECO_vs_Nvtx_in_Acc',
     'RECO_Effs/eff_Muon_RECO_vs_pT_in_Acc',
     # 'RECO_Effs/eff_Tau_RECO_vs_Nvtx_in_Acc',
     # 'RECO_Effs/eff_Tau_RECO_vs_pT_in_Acc',

     'ID_Effs/eff_Ele_ID_vs_Nvtx',
     'ID_Effs/eff_Ele_ID_vs_Nvtx_in_Acc',
     'ID_Effs/eff_Ele_ID_vs_pT',
     'ID_Effs/eff_Ele_ID_vs_pT_gen',
     'ID_Effs/eff_Ele_ID_vs_pT_in_Acc',
     'ID_Effs/eff_Ele_ID_vs_pT_in_Acc_gen',

     'ID_Effs/eff_Muon_ID_vs_Nvtx',
     'ID_Effs/eff_Muon_ID_vs_Nvtx_in_Acc',
     'ID_Effs/eff_Muon_ID_vs_pT',
     'ID_Effs/eff_Muon_ID_vs_pT_gen',
     'ID_Effs/eff_Muon_ID_vs_pT_in_Acc',
     'ID_Effs/eff_Muon_ID_vs_pT_in_Acc_gen',

     # 'ID_Effs/eff_Tau_ID_vs_Nvtx',
     # 'ID_Effs/eff_Tau_ID_vs_Nvtx_in_Acc',
     # 'ID_Effs/eff_Tau_ID_vs_pT',
     # 'ID_Effs/eff_Tau_ID_vs_pT_gen',
     # 'ID_Effs/eff_Tau_ID_vs_pT_in_Acc',
     # 'ID_Effs/eff_Tau_ID_vs_pT_in_Acc_gen',
    ]

    overall_hists = [
     ['emu/eff_emu_Acc_vs_Mass','emu/eff_emu_RECO_vs_Mass','emu/eff_emu_Eff_vs_Mass'],
     ['emu/eff_emu_Acc_vs_Nvtx','emu/eff_emu_RECO_vs_Nvtx','emu/eff_emu_Eff_vs_Nvtx'],
    ]

    eff_colorList={}
    eff_colorList['emu/eff_emu_Acc_vs_Mass'] = 'deepskyblue'
    eff_colorList['emu/eff_emu_RECO_vs_Mass'] = 'darkgreen'
    eff_colorList['emu/eff_emu_Eff_vs_Mass'] = 'red'
    eff_colorList['emu/eff_emu_Acc_vs_Nvtx'] = 'deepskyblue'
    eff_colorList['emu/eff_emu_RECO_vs_Nvtx'] = 'darkgreen'
    eff_colorList['emu/eff_emu_Eff_vs_Nvtx'] = 'red'

    hists2D=['HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_pT(Mu,Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_eta_vs_phi(Ele)',
     #'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_pT(Mu,Ele)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_pT(Mu,Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_pT(Mu,Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_pT(Mu,Mu)',
     #'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_eta_vs_phi(Mu)',
     #'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_eta_vs_phi(Tau)',
     #'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_pT(Mu,Tau)',
     #'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_eta_vs_phi(Ele)',
     #'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_eta_vs_phi(Ele)',
     #'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_pT(Ele,Ele)',
     #'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_eta_vs_phi(Ele)',
     #'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_eta_vs_phi(Tau)',
     #'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_pT(Ele,Tau)',

     'RECO_Effs/eff_Ele_RECO_vs_eta_vs_phi',
     # 'RECO_Effs/eff_MET_RECO_vs_eta_vs_phi',
     'RECO_Effs/eff_Muon_RECO_vs_eta_vs_phi',
     # 'RECO_Effs/eff_Tau_RECO_vs_eta_vs_phi',

     'RECO_Effs/eff_Ele_RECO_vs_eta_vs_phi_in_Acc',
     'RECO_Effs/eff_Muon_RECO_vs_eta_vs_phi_in_Acc',
     # 'RECO_Effs/eff_Tau_RECO_vs_eta_vs_phi_in_Acc',

     'ID_Effs/eff_Ele_ID_vs_eta_vs_phi',
     'ID_Effs/eff_Ele_ID_vs_eta_vs_phi_gen',
     'ID_Effs/eff_Ele_ID_vs_eta_vs_phi_in_Acc',
     'ID_Effs/eff_Ele_ID_vs_eta_vs_phi_in_Acc_gen',

     'ID_Effs/eff_Muon_ID_vs_eta_vs_phi',
     'ID_Effs/eff_Muon_ID_vs_eta_vs_phi_gen',
     'ID_Effs/eff_Muon_ID_vs_eta_vs_phi_in_Acc',
     'ID_Effs/eff_Muon_ID_vs_eta_vs_phi_in_Acc_gen',

     # 'ID_Effs/eff_Tau_ID_vs_eta_vs_phi',
     # 'ID_Effs/eff_Tau_ID_vs_eta_vs_phi_gen',
     # 'ID_Effs/eff_Tau_ID_vs_eta_vs_phi_in_Acc',
     # 'ID_Effs/eff_Tau_ID_vs_eta_vs_phi_in_Acc_gen',
    ]

    res_histos = [
     'emu/Stage_0/h2_0_emu_Mass_resolution'
    ]

    res_histos1D = [
     'emu/Stage_0/h1_0_emu_Mass_resolution'
    ]

    binning={
            "_vs_pT":10,
            "_vs_Mass":10,
    }

    titles={
     'HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_Nvtx':['HLT_Mu50_v1 efficiency','$N_{vtx}$','efficiency $\epsilon$'],
     'HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_pT(Mu)':['HLT_Mu50_v1 efficiency','$p_{T}^{\mu}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'RECO_Effs/eff_Ele_RECO_vs_Nvtx':['Electron reco efficiency','$N_{vtx}$','efficiency $\epsilon$'],
     'RECO_Effs/eff_Ele_RECO_vs_pT':['Electron reco efficiency','$p_{T}^{e (gen)}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'RECO_Effs/eff_Muon_RECO_vs_Nvtx':['Muon reco efficiency','$N_{vtx}$','efficiency $\epsilon$'],
     'RECO_Effs/eff_Muon_RECO_vs_pT':['Muon reco efficiency','$p_{T}^{\mu (gen)}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'ID_Effs/eff_Ele_ID_vs_Nvtx':['HEEP ID efficiency','$N_{vtx}$','efficiency $\epsilon$'],
     'ID_Effs/eff_Ele_ID_vs_pT':['HEEP ID efficiency','$p_{T}^{e}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'ID_Effs/eff_Ele_ID_vs_pT_gen':['HEEP ID efficiency','$p_{T}^{e (gen)}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'ID_Effs/eff_Muon_ID_vs_Nvtx':['High p_T muon ID efficiency','$N_{vtx}$','efficiency $\epsilon$'],
     'ID_Effs/eff_Muon_ID_vs_pT_gen':['High p_T muon ID efficiency','$p_{T}^{\mu (gen)}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'ID_Effs/eff_Muon_ID_vs_pT':['High p_T muon ID efficiency','$p_{T}^{\mu}\,(\mathrm{GeV})$','efficiency $\epsilon$'],
     'emu/eff_emu_Acc_vs_Mass':['Acceptance','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','efficiency $\epsilon$'],
     'emu/eff_emu_RECO_vs_Mass':['Trigger','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','efficiency $\epsilon$'],
     'emu/eff_emu_Eff_vs_Mass':['Selection','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','efficiency $\epsilon$'],
     'emu/eff_emu_Acc_vs_Nvtx':['Acceptance','$N_{vtx}$','efficiency $\epsilon$'],
     'emu/eff_emu_RECO_vs_Nvtx':['Trigger','$N_{vtx}$','efficiency $\epsilon$'],
     'emu/eff_emu_Eff_vs_Nvtx':['Selection','$N_{vtx}$','efficiency $\epsilon$'],
     'emu/Stage_0/h1_0_emu_Mass_resolution':['Mass resolution','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','$\sigma((M_{e\mu, reco} - M_{e\mu, gen}) / M_{e\mu, gen})$'],
    }

    yranges={
     'ID_Effs/eff_Muon_ID_vs_pT':[0.5,1.02],
     'ID_Effs/eff_Muon_ID_vs_pT_gen':[0.5,1.02],
     'ID_Effs/eff_Muon_ID_vs_pT_in_Acc':[0.5,1.02],
     'ID_Effs/eff_Muon_ID_vs_pT_in_Acc_gen':[0.5,1.02],
     'HLT_Effs/eff_HLT_HLT_Mu50_v1_vs_pT(Mu)':[0.6,1.02],
     'ID_Effs/eff_Ele_ID_vs_pT':[0.7,1.02],
     'ID_Effs/eff_Ele_ID_vs_pT_gen':[0.7,1.02],
     'ID_Effs/eff_Ele_ID_vs_pT_in_Acc':[0.7,1.02],
     'ID_Effs/eff_Ele_ID_vs_pT_in_Acc_gen':[0.7,1.02],
    }

    ####################################################################
    # Individual 1D plots
    ####################################################################

    if False:
        for hist in hists:
            print("Now plotting: " + hist)
    
            histlist = []
            for item in bglist:
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                binf = getDictValue(hist, binning)
                if binf is not None:
                    t_eff = eff_rebinner(t_eff,binf)

                i_titles = getDictValue(hist, titles)

                t_eff = Graph(t_eff.CreateGraph())
                t_eff.SetLineColor(colorList[item])
                if i_titles is not None:
                    t_eff.SetTitle(i_titles[0])
                else:
                    t_eff.SetTitle(item)
                if 'Nvtx' in hist:
                    t_eff.xaxis.SetTitle('$N_{vtx}$')
                if 'pT' in hist:
                    if i_titles is not None:
                        t_eff.xaxis.SetTitle(i_titles[1])
                    else:
                        t_eff.xaxis.SetTitle('$p_{T}$ (GeV)')
                if i_titles is not None:
                    t_eff.yaxis.SetTitle(i_titles[2])
                else:
                    t_eff.yaxis.SetTitle('$\epsilon$')
                
                histlist.append(t_eff)
    
            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')
            hist_style.Set_legend_font_size(12)

            test = plotter(hist = histlist,style=hist_style)

            if hist in yranges.keys():
                test.Set_axis(logy = False, grid = True, ymin=yranges[hist][0],ymax=yranges[hist][1])
            else:
                test.Set_axis(logy = False, grid = True)
    
            test._cms_text_x         = 0.12
            test._cms_text_y         = 0.91
    
            name=hist.replace("/","")
    
            test.make_plot('plots/%s.pdf'%(name))

    ####################################################################
    # Combined 1D plots
    ####################################################################

    if False:
        skip_list = []
        for hist in hists:
            if hist in skip_list:
                continue
            print("Now plotting: " + hist)
    
            histlist = []
            c_histo = r.TEfficiency()
            for item in bglist:
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                if len(histlist) == 0:
                    c_histo = t_eff
                else:
                    c_histo.Add(t_eff)
                histlist.append(t_eff)

            binf = getDictValue(hist, binning)
            if binf is not None:
                c_histo = eff_rebinner(c_histo,binf)

            i_titles = getDictValue(hist, titles)

            c_histo = Graph(c_histo.CreateGraph())

            c_histo.SetLineColor('deepskyblue')

            if i_titles is not None:
                # c_histo.SetTitle(i_titles[0] + ' in Acceptance')
                c_histo.SetTitle(i_titles[0] + ' ')
            else:
                c_histo.SetTitle(hist)
            if 'Nvtx' in hist:
                c_histo.xaxis.SetTitle('$N_{vtx}$')
            if 'pT' in hist:
                if i_titles is not None:
                    c_histo.xaxis.SetTitle(i_titles[1])
                else:
                    c_histo.xaxis.SetTitle('$p_{T}$ (GeV)')
            if i_titles is not None:
                c_histo.yaxis.SetTitle(i_titles[2])
            else:
                c_histo.yaxis.SetTitle('$\epsilon$')

            plots = [c_histo]

            if hist + '_in_Acc' in hists:
                skip_list.append(hist + '_in_Acc')
                histlist1 = []
                c_histo1 = r.TEfficiency()
                for item in bglist:
                    tfile = root_open(basedir + item + ".root", "READ")
                    t_eff = tfile.Get(hist + '_in_Acc')
                    if len(histlist1) == 0:
                        c_histo1 = t_eff
                    else:
                        c_histo1.Add(t_eff)
                    histlist1.append(t_eff)

                binf = getDictValue(hist, binning)
                if binf is not None:
                    c_histo1 = eff_rebinner(c_histo1,binf)

                c_histo1 = Graph(c_histo1.CreateGraph())
    
                c_histo1.SetLineColor('darkgreen')
                if i_titles is not None:
                    c_histo1.SetTitle(i_titles[0] + ' in Acceptance')
                else:
                    c_histo1.SetTitle(hist + '_in_Acc')
                plots.append(c_histo1)

            if hist[:-4] + '_in_Acc_gen' in hists and '_gen' in hist:
                skip_list.append(hist[:-4] + '_in_Acc_gen')
                histlist2 = []
                c_histo2 = r.TEfficiency()
                for item in bglist:
                    tfile = root_open(basedir + item + ".root", "READ")
                    t_eff = tfile.Get(hist[:-4] + '_in_Acc_gen')
                    if len(histlist2) == 0:
                        c_histo2 = t_eff
                    else:
                        c_histo2.Add(t_eff)
                    histlist2.append(t_eff)

                binf = getDictValue(hist, binning)
                if binf is not None:
                    c_histo2 = eff_rebinner(c_histo2,binf)

                c_histo2 = Graph(c_histo2.CreateGraph())
    
                c_histo2.SetLineColor('darkgreen')
                if i_titles is not None:
                    c_histo2.SetTitle(i_titles[0] + ' in Acceptance')
                else:
                    c_histo2.SetTitle(hist[:-4] + '_in_Acc_gen')

                plots.append(c_histo2)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')
            hist_style.Set_legend_font_size(12)

            test = plotter(hist = plots, style = hist_style)

            if hist in yranges.keys():
                test.Set_axis(logy = False, grid = True, ymin=yranges[hist][0],ymax=yranges[hist][1])
            else:
                test.Set_axis(logy = False, grid = True)
    
            test._cms_text_x         = 0.12
            test._cms_text_y         = 0.91
    
            name=hist.replace("/","")
    
            test.make_plot('plots/%s.pdf'%(name))

    ####################################################################
    # Combined 1D plots for overall efficiencies
    ####################################################################

    if True:
        for hist in overall_hists:
            print("Now plotting: " + hist[0])

            hists_to_plot = []
            for i_hist in hist:
                histlist = []
                c_histo = r.TEfficiency()
                for item in bglist:
                    tfile = root_open(basedir + item + ".root", "READ")
                    t_eff = tfile.Get(i_hist)
                    if len(histlist) == 0:
                        c_histo = t_eff
                    else:
                        c_histo.Add(t_eff)
                    histlist.append(t_eff)

                binf = getDictValue(i_hist, binning)
                if binf is not None:
                    c_histo = eff_rebinner(c_histo,binf)

                i_titles = getDictValue(i_hist, titles)

                c_histo = Graph(c_histo.CreateGraph())
                c_histo.SetLineColor(eff_colorList[i_hist])
                if i_titles is not None:
                    c_histo.SetTitle(i_titles[0])
                else:
                    c_histo.SetTitle(i_hist)

                if 'Nvtx' in i_hist:
                    c_histo.xaxis.SetTitle('$N_{vtx}$')
                if 'Mass' in i_hist:
                    if i_titles is not None:
                        c_histo.xaxis.SetTitle(i_titles[1])
                    else:
                        c_histo.xaxis.SetTitle('$M$ (GeV)')
                if i_titles is not None:
                    c_histo.yaxis.SetTitle(i_titles[2])
                else:
                    c_histo.yaxis.SetTitle('$\epsilon$')

                hists_to_plot.append(c_histo)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')
            hist_style.Set_legend_font_size(12)

            test = plotter(hist = hists_to_plot, style = hist_style)

            if hist in yranges.keys():
                test.Set_axis(logy = False, grid = True, ymin=yranges[hist][0],ymax=yranges[hist][1])
            else:
                test.Set_axis(logy = False, grid = True)
    
            test._cms_text_x         = 0.12
            test._cms_text_y         = 0.91
    
            name=hist[0].replace("/","")

            test.create_plot()

            if 'Mass' in hist[0]:
                plot_efficiency_fit(test.Get_axis1(), hists_to_plot[-1], xmin = 0, xmax = 6000, startvals = [0.78, -96, -85, -1.9e-5], plottrange = [100,6000])

            test.SavePlot('plots/%s.pdf'%(name))

    ####################################################################
    # Individual 2D plots
    ####################################################################

    if False:
        for hist in hists2D:
            print("Now plotting: " + hist)
    
            histlist = []
            for item in bglist:
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist).CreateHistogram()
                # t_eff.SetLineColor(colorList[item])
                t_eff.SetTitle(item)
                # t_eff.xaxis.SetTitle(t_eff.GetXaxis().GetTitle())
                # t_eff.yaxis.SetTitle(t_eff.GetYaxis().GetTitle())
                histlist.append(t_eff)

                hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "outside left", legendPosition = 'lower middle', lumi = 0, cms = 13)
    
                hist_style.Set_additional_text('Spring15 simulation')
    
                test = plotter2D(hist = t_eff, style = hist_style)
    
                # test.Set_axis(xmin = -2.5, xmax = 2.5, ymin = 0, ymax = 3.1, zmin = 0, zmax = 1)
    
                name=hist.replace("/","")
    
                test.create_plot()
    
                test.save_plot('plots/%s_%s.pdf'%(item,name))

    ####################################################################
    # Combined 2D plots
    ####################################################################

    if False:
        for hist in hists2D:
            print("Now plotting: " + hist)
    
            histlist = []
            c_histo = r.TEfficiency()
            for item in bglist:
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                if len(histlist) == 0:
                    c_histo = t_eff
                else:
                    c_histo.Add(t_eff)
                histlist.append(t_eff)

            c_histo = c_histo.CreateHistogram()
            c_histo.SetTitle(hist)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "outside left", legendPosition = 'lower middle', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')

            test = plotter2D(hist = c_histo, style = hist_style)

            # test.Set_axis(xmin = -2.5, xmax = 2.5, ymin = 0, ymax = 3.1, zmin = 0, zmax = 1)

            name=hist.replace("/","")

            test.create_plot()

            test.save_plot('plots/%s.pdf'%(name))

    ####################################################################
    # Resolution plot
    ####################################################################

    if False:
        for hist in res_histos:
            print("Now plotting: " + hist)
    
            histlist = []
            c_histo = r.TH2F()
            for item in bglist:
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                if len(histlist) == 0:
                    c_histo = t_eff
                else:
                    c_histo.Add(t_eff)
                histlist.append(t_eff)

            c_histo.SetTitle(hist)

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "outside left", legendPosition = 'lower middle', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')

            test = plotter2D(hist = c_histo, style = hist_style)
            # test.Add_x_projection()
            # test.Add_y_projection()

            test.Set_axis(ymin = -0.5, ymax = 0.5)

            name=hist.replace("/","")

            test.create_plot()

            test.save_plot('plots/%s.pdf'%(name))

    ####################################################################
    # Individual resolution plots
    ####################################################################

    if True:
        for hist in res_histos1D:
            print("Now plotting: " + hist)

            x_vals =[]
            y_vals = []
            y_errs = []
            for item in bglist:
                if 'LLE_LQD-001' not in item:
                    continue
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                t_eff.xaxis.SetTitle('$'+t_eff.xaxis.GetTitle()+'$')
                t_eff.yaxis.SetTitle('Events / %.2f'%t_eff.GetBinWidth(1))

                hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower left', lumi = 0, cms = 13)
                hist_style.Set_additional_text('Spring15 simulation')
                test = plotter(hist = [t_eff],style=hist_style)
                name=item.replace("/","")
                test.Set_axis(logy = True, grid = True, xmin = -1.01, xmax = 1.01, ymin = 0.9, ymax = 4000)
                test.create_plot()

                plot_gauss_fit(test.Get_axis1(), t_eff, color = 'red', write_results = True)

                test.SavePlot('plots/%s.pdf'%(name))

                fit_res = t_eff.Fit('gaus', 'N0S', '')
                y_vals.append(fit_res.Parameter(2))
                y_errs.append(fit_res.ParError(2))
                parts = item.split('_')
                for part in parts:
                    if 'M-'in part:
                        x_vals.append(int(part[2:]))

            x_vals = np.array(x_vals)
            y_vals = np.array(y_vals)
            y_errs = np.array(y_errs)

            graph = Graph(x_vals.shape[0])
            for i, (xx, yy, ye) in enumerate(zip(x_vals, y_vals, y_errs)):
                graph.SetPoint(i, xx, yy)
                graph.SetPointError(i, 0, 0, ye, ye)

            i_titles = getDictValue(hist, titles)

            if i_titles is not None:
                graph.SetTitle(i_titles[0])
                graph.xaxis.SetTitle(i_titles[1])
                graph.yaxis.SetTitle(i_titles[2])

            graph.SetLineColor('red')

            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower left', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')

            test = plotter(hist = [graph],style=hist_style)

            name=hist.replace("/","")

            test.Set_axis(logy = False, grid = True, xmin = 0, xmax = 6500)

            test.create_plot()

            func = plot_resolution_fit(test.Get_axis1(), graph, xmin = 0, xmax = 6000, startvals = [], plottrange = [], color = 'black')

            test.SavePlot('plots/%s.pdf'%(name))
            graph.SaveAs('plots/%s.root'%(name))
            func.SaveAs('plots/%s_func.root'%(name))

    return 42
def main():

    basedir="/.automount/home/home__home1/institut_3a/keller/Masterthesis/Results_MassResolution/"
    
    # lumi=19712

    # xs= ConfigObj("/disk1/erdweg/plotting/xs_Phys14.cfg")
    # bghists=HistStorage(xs,lumi,path=basedir,isData=True)

    colors = ['lime', 'deepskyblue', 'magenta', 'orangered']

    bglist=OrderedDict()

    bglist = [
     #'Asymptotic/Mass1000/SpecialHistos',
     #'Startup/Mass1000/SpecialHistos',
     #'Asymptotic/Mass1200/SpecialHistos',
     #'Startup/Mass1200/SpecialHistos',
     #'Asymptotic/Mass1400/SpecialHistos',
     #'Startup/Mass1400/SpecialHistos',
     'Asymptotic/Mass1600/SpecialHistos',
     'Startup/Mass1600/SpecialHistos',
     'Asymptotic/Mass1800/SpecialHistos',
     'Startup/Mass1800/SpecialHistos',
     'Asymptotic/Mass2000/SpecialHistos',
     'Startup/Mass2000/SpecialHistos',
      
    ]

    colorList={}
    colorList['SpecialHistos'] = 'lightblue'

    res_histos = [
     'emu/Stage_0/h2_0_emu_Mass_resolution'
    ]

    res_histos1D = [
     'emu/Stage_0/h1_0_emu_Mass_resolution'
    ]

    binning={
            "_vs_pT":10,
            "_vs_Mass":10,
    }

    titles={
     'emu/Stage_0/h1_0_emu_Mass_resolution':['Mass resolution asymptotic','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','$\sigma((M_{e\mu, reco} - M_{e\mu, gen}) / M_{e\mu, gen})$','Mass resolution startup','$M_{e\mu, gen}\,\,\mathrm{(GeV)}$','$\sigma((M_{e\mu, reco} - M_{e\mu, gen}) / M_{e\mu, gen})$'],
    }
   
    ####################################################################
    # Individual resolution plots
    ####################################################################

    if True:
        for hist in res_histos1D:
            print("Now plotting: " + hist)

            x_vals =[]
            y_vals = []
            y_errs = []
            x_vals_startup =[]
            y_vals_startup = []
            y_errs_startup = []
            for item in bglist:
                if 'SpecialHistos' not in item:
                    continue
                tfile = root_open(basedir + item + ".root", "READ")
                t_eff = tfile.Get(hist)
                t_eff.xaxis.SetTitle('$'+t_eff.xaxis.GetTitle()+'$')
                t_eff.yaxis.SetTitle('Events / %.2f'%t_eff.GetBinWidth(1))

                hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower left', lumi = 0, cms = 13)
                hist_style.Set_additional_text('Spring15 simulation')
                test = plotter(hist = [t_eff],style=hist_style)
                name=item.replace("/","")
                test.Set_axis(logy = False, grid = True, xmin = -1.01, xmax = 1.01, ymin = 0.9, ymax = 4000)
                test.create_plot()

                plot_gauss_fit(test.Get_axis1(), t_eff, color = 'red', write_results = True)

                test.SavePlot('plots/%s.pdf'%(name))

                fit_res = t_eff.Fit('gaus', 'N0S', '')
                if(item[0:-23] == "Asymptotic"):
		    y_vals.append(fit_res.Parameter(2))
		    y_errs.append(fit_res.ParError(2))
		    x_vals.append(int(item[15:-14]))
		if(item[0:-23] == "Startup"):
		    y_vals_startup.append(fit_res.Parameter(2))
		    y_errs_startup.append(fit_res.ParError(2))
		    x_vals_startup.append(int(item[12:-14]))
		
		
		
            x_vals = np.array(x_vals)
            y_vals = np.array(y_vals)
            y_errs = np.array(y_errs)
	    

	    x_vals_startup = np.array(x_vals_startup)
            y_vals_startup = np.array(y_vals_startup)
            y_errs_startup = np.array(y_errs_startup)
	    #print(len(x_vals))
	    #print(len(y_vals))
	    #print(len(y_errs))
	      
	    ### create plots for asymptotic
            graph = Graph(x_vals.shape[0])
            for i, (xx, yy, ye) in enumerate(zip(x_vals, y_vals, y_errs)):
                graph.SetPoint(i, xx, yy)
                graph.SetPointError(i, 0, 0, ye, ye)

            i_titles = getDictValue(hist, titles)

            if i_titles is not None:
                graph.SetTitle(i_titles[0])
                graph.xaxis.SetTitle(i_titles[1])
                graph.yaxis.SetTitle(i_titles[2])

            graph.SetLineColor('red')
	    
	    ### create plots for startup
            graph_startup = Graph(x_vals_startup.shape[0])
            for i, (xx, yy, ye) in enumerate(zip(x_vals_startup, y_vals_startup, y_errs_startup)):
                graph_startup.SetPoint(i, xx, yy)
                graph_startup.SetPointError(i, 0, 0, ye, ye)

            i_titles = getDictValue(hist, titles)

            if i_titles is not None:
                graph_startup.SetTitle(i_titles[3])
                graph_startup.xaxis.SetTitle(i_titles[4])
                graph_startup.yaxis.SetTitle(i_titles[5])

            graph_startup.SetLineColor('blue')
	      
            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper left", legendPosition = 'lower left', lumi = 0, cms = 13)

            hist_style.Set_additional_text('Spring15 simulation')

            test = plotter(hist = [graph, graph_startup],style=hist_style)

            name=hist.replace("/","")

            test.Set_axis(logy = False, grid = True, xmin = 0, xmax = 6500)

            test.create_plot()

            #func = plot_resolution_fit(test.Get_axis1(), graph, xmin = 0, xmax = 6000, startvals = [], plottrange = [], color = 'black')

            test.SavePlot('plots/%s.pdf'%(name))
            graph.SaveAs('plots/%s.root'%(name))
            #func.SaveAs('plots/%s_func.root'%(name))

    return 42
Example #8
0
def make_xs_plot():
    ####################################################################
    # Individual cross section plots
    ####################################################################

    print("Now plotting: cross section comparison")

    calchep_list = readin_calchep()
    qbh_list = readin_qbh()
    qbh_gg_list = add_qbh_gg(qbh_list)

    x_vals_1 =[]
    y_vals_qbh_1 = []
    y_vals_chp_1 = []
    y_vals_qbh_gg_1 = []

    for itemc,itemq,itemg in zip(calchep_list[dim_match['1']],qbh_list[dim_match['1']],qbh_gg_list[dim_match['1']]):
        x_vals_1.append(itemc[0])
        y_vals_qbh_1.append(itemq[1]*itemq[2])
        y_vals_chp_1.append(itemc[1]*itemc[2])
        y_vals_qbh_gg_1.append(itemg[1]*itemg[2])

    x_vals_4 =[]
    y_vals_qbh_4 = []
    y_vals_chp_4 = []
    y_vals_qbh_gg_4 = []

    for itemc,itemq,itemg in zip(calchep_list[dim_match['4']],qbh_list[dim_match['4']],qbh_gg_list[dim_match['4']]):
        x_vals_4.append(itemc[0])
        y_vals_qbh_4.append(itemq[1]*itemq[2])
        y_vals_chp_4.append(itemc[1]*itemc[2])
        y_vals_qbh_gg_4.append(itemg[1]*itemg[2])

    x_vals_5 =[]
    y_vals_qbh_5 = []
    y_vals_chp_5 = []
    y_vals_qbh_gg_5 = []

    for itemc,itemq,itemg in zip(calchep_list[dim_match['5']],qbh_list[dim_match['5']],qbh_gg_list[dim_match['5']]):
        x_vals_5.append(itemc[0])
        y_vals_qbh_5.append(itemq[1]*itemq[2])
        y_vals_chp_5.append(itemc[1]*itemc[2])
        y_vals_qbh_gg_5.append(itemg[1]*itemg[2])

    x_vals_6 =[]
    y_vals_qbh_6 = []
    y_vals_chp_6 = []
    y_vals_qbh_gg_6 = []

    for itemc,itemq,itemg in zip(calchep_list[dim_match['6']],qbh_list[dim_match['6']],qbh_gg_list[dim_match['6']]):
        x_vals_6.append(itemc[0])
        y_vals_qbh_6.append(itemq[1]*itemq[2])
        y_vals_chp_6.append(itemc[1]*itemc[2])
        y_vals_qbh_gg_6.append(itemg[1]*itemg[2])

    x_vals_1 = np.array(x_vals_1)
    y_vals_qbh_1 = np.array(y_vals_qbh_1)
    y_vals_chp_1 = np.array(y_vals_chp_1)
    y_vals_qbh_gg_1 = np.array(y_vals_qbh_gg_1)

    x_vals_4 = np.array(x_vals_4)
    y_vals_qbh_4 = np.array(y_vals_qbh_4)
    y_vals_chp_4 = np.array(y_vals_chp_4)
    y_vals_qbh_gg_4 = np.array(y_vals_qbh_gg_4)

    x_vals_5 = np.array(x_vals_5)
    y_vals_qbh_5 = np.array(y_vals_qbh_5)
    y_vals_chp_5 = np.array(y_vals_chp_5)
    y_vals_qbh_gg_5 = np.array(y_vals_qbh_gg_5)

    x_vals_6 = np.array(x_vals_6)
    y_vals_qbh_6 = np.array(y_vals_qbh_6)
    y_vals_chp_6 = np.array(y_vals_chp_6)
    y_vals_qbh_gg_6 = np.array(y_vals_qbh_gg_6)

    graph_qbh_1 = Graph(x_vals_1.shape[0])
    graph_chp_1 = Graph(x_vals_1.shape[0])
    graph_qbh_gg_1 = Graph(x_vals_1.shape[0])
    graph_ratio_1 = Graph(x_vals_1.shape[0])
    graph_ratio_gg_1 = Graph(x_vals_1.shape[0])
    for i, (xx, y1, y2, y3) in enumerate(zip(x_vals_1, y_vals_qbh_1, y_vals_chp_1, y_vals_qbh_gg_1)):
        graph_qbh_1.SetPoint(i, xx, y1)
        graph_qbh_1.SetPointError(i, 0, 0, 0, 0)
        graph_chp_1.SetPoint(i, xx, y2)
        graph_chp_1.SetPointError(i, 0, 0, 0, 0)
        graph_qbh_gg_1.SetPoint(i, xx, y3)
        graph_qbh_gg_1.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_1.SetPoint(i, xx, y2/y1)
        graph_ratio_1.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_gg_1.SetPoint(i, xx, y2/y3)
        graph_ratio_gg_1.SetPointError(i, 0, 0, 0, 0)

    graph_qbh_4 = Graph(x_vals_4.shape[0])
    graph_chp_4 = Graph(x_vals_4.shape[0])
    graph_qbh_gg_4 = Graph(x_vals_4.shape[0])
    graph_ratio_4 = Graph(x_vals_4.shape[0])
    graph_ratio_gg_4 = Graph(x_vals_4.shape[0])
    for i, (xx, y1, y2, y3) in enumerate(zip(x_vals_4, y_vals_qbh_4, y_vals_chp_4, y_vals_qbh_gg_4)):
        graph_qbh_4.SetPoint(i, xx, y1)
        graph_qbh_4.SetPointError(i, 0, 0, 0, 0)
        graph_chp_4.SetPoint(i, xx, y2)
        graph_chp_4.SetPointError(i, 0, 0, 0, 0)
        graph_qbh_gg_4.SetPoint(i, xx, y3)
        graph_qbh_gg_4.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_4.SetPoint(i, xx, y2/y1)
        graph_ratio_4.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_gg_4.SetPoint(i, xx, y2/y3)
        graph_ratio_gg_4.SetPointError(i, 0, 0, 0, 0)

    graph_qbh_5 = Graph(x_vals_5.shape[0])
    graph_chp_5 = Graph(x_vals_5.shape[0])
    graph_qbh_gg_5 = Graph(x_vals_5.shape[0])
    graph_ratio_5 = Graph(x_vals_5.shape[0])
    graph_ratio_gg_5 = Graph(x_vals_5.shape[0])
    for i, (xx, y1, y2, y3) in enumerate(zip(x_vals_5, y_vals_qbh_5, y_vals_chp_5, y_vals_qbh_gg_5)):
        graph_qbh_5.SetPoint(i, xx, y1)
        graph_qbh_5.SetPointError(i, 0, 0, 0, 0)
        graph_chp_5.SetPoint(i, xx, y2)
        graph_chp_5.SetPointError(i, 0, 0, 0, 0)
        graph_qbh_gg_5.SetPoint(i, xx, y3)
        graph_qbh_gg_5.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_5.SetPoint(i, xx, y2/y1)
        graph_ratio_5.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_gg_5.SetPoint(i, xx, y2/y3)
        graph_ratio_gg_5.SetPointError(i, 0, 0, 0, 0)

    graph_qbh_6 = Graph(x_vals_6.shape[0])
    graph_chp_6 = Graph(x_vals_6.shape[0])
    graph_qbh_gg_6 = Graph(x_vals_6.shape[0])
    graph_ratio_6 = Graph(x_vals_6.shape[0])
    graph_ratio_gg_6 = Graph(x_vals_6.shape[0])
    for i, (xx, y1, y2, y3) in enumerate(zip(x_vals_6, y_vals_qbh_6, y_vals_chp_6, y_vals_qbh_gg_6)):
        graph_qbh_6.SetPoint(i, xx, y1)
        graph_qbh_6.SetPointError(i, 0, 0, 0, 0)
        graph_chp_6.SetPoint(i, xx, y2)
        graph_chp_6.SetPointError(i, 0, 0, 0, 0)
        graph_qbh_gg_6.SetPoint(i, xx, y3)
        graph_qbh_gg_6.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_6.SetPoint(i, xx, y2/y1)
        graph_ratio_6.SetPointError(i, 0, 0, 0, 0)
        graph_ratio_gg_6.SetPoint(i, xx, y2/y3)
        graph_ratio_gg_6.SetPointError(i, 0, 0, 0, 0)

    graph_qbh_1.SetTitle('n = 1, QBH')
    graph_qbh_1.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_1.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_chp_1.SetTitle('n = 1, CalcHEP')
    graph_chp_1.xaxis.SetTitle('$M$ (GeV)')
    graph_chp_1.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_gg_1.SetTitle('n = 1, QBH(+gg)')
    graph_qbh_gg_1.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_gg_1.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_1.SetLineColor('red')
    graph_chp_1.SetLineColor('red')
    graph_qbh_gg_1.SetLineColor('red')
    graph_ratio_1.SetLineColor('red')
    graph_ratio_gg_1.SetLineColor('red')
    graph_qbh_1.SetLineStyle(2)
    graph_ratio_1.SetLineStyle(2)
    graph_qbh_gg_1.SetLineStyle(3)
    graph_ratio_gg_1.SetLineStyle(3)

    graph_qbh_4.SetTitle('n = 4, QBH')
    graph_qbh_4.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_4.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_chp_4.SetTitle('n = 4, CalcHEP')
    graph_chp_4.xaxis.SetTitle('$M$ (GeV)')
    graph_chp_4.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_gg_4.SetTitle('n = 4, QBH(+gg)')
    graph_qbh_gg_4.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_gg_4.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_4.SetLineColor('green')
    graph_chp_4.SetLineColor('green')
    graph_qbh_gg_4.SetLineColor('green')
    graph_ratio_4.SetLineColor('green')
    graph_ratio_gg_4.SetLineColor('green')
    graph_qbh_4.SetLineStyle(2)
    graph_qbh_gg_4.SetLineStyle(3)
    graph_ratio_4.SetLineStyle(2)
    graph_ratio_gg_4.SetLineStyle(3)

    graph_qbh_5.SetTitle('n = 5, QBH')
    graph_qbh_5.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_5.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_chp_5.SetTitle('n = 5, CalcHEP')
    graph_chp_5.xaxis.SetTitle('$M$ (GeV)')
    graph_chp_5.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_gg_5.SetTitle('n = 5, QBH(+gg)')
    graph_qbh_gg_5.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_gg_5.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_5.SetLineColor('black')
    graph_chp_5.SetLineColor('black')
    graph_qbh_gg_5.SetLineColor('black')
    graph_ratio_5.SetLineColor('black')
    graph_ratio_gg_5.SetLineColor('black')
    graph_qbh_5.SetLineStyle(2)
    graph_qbh_gg_5.SetLineStyle(3)
    graph_ratio_5.SetLineStyle(2)
    graph_ratio_gg_5.SetLineStyle(3)

    graph_qbh_6.SetTitle('n = 6, QBH')
    graph_qbh_6.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_6.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_chp_6.SetTitle('n = 6, CalcHEP')
    graph_chp_6.xaxis.SetTitle('$M$ (GeV)')
    graph_chp_6.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_gg_6.SetTitle('n = 6, QBH(+gg)')
    graph_qbh_gg_6.xaxis.SetTitle('$M$ (GeV)')
    graph_qbh_gg_6.yaxis.SetTitle('xs $\cdot$ BR (pb)')

    graph_qbh_6.SetLineColor('magenta')
    graph_chp_6.SetLineColor('magenta')
    graph_qbh_gg_6.SetLineColor('magenta')
    graph_ratio_6.SetLineColor('magenta')
    graph_ratio_gg_6.SetLineColor('magenta')
    graph_qbh_6.SetLineStyle(2)
    graph_qbh_gg_6.SetLineStyle(3)
    graph_ratio_6.SetLineStyle(2)
    graph_ratio_gg_6.SetLineStyle(3)

    hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Linegraphs', cmsPositon = "upper left", legendPosition = 'upper right', lumi = 0, cms = 13)
    hist_style.Set_n_legend_collumns(2)

    hist_style.Set_additional_text('Simulation')
 

    test = plotter(hist = [graph_qbh_1, graph_chp_1, graph_qbh_gg_1,graph_qbh_4, graph_chp_4, graph_qbh_gg_4,graph_qbh_5, graph_chp_5, graph_qbh_gg_5,graph_qbh_6, graph_chp_6, graph_qbh_gg_6], style=hist_style)

    # test = plotter(hist = [graph_qbh_1, graph_chp_1], style=hist_style)

    test.Add_plot('Empty',pos=1, height=25, label='CalcHEP/QBH')

    test.create_plot()

    test.Get_axis1().set_ylim(ymin = 1.6e-8, ymax = 1e5)

    x,y=[],[]
    for i in graph_ratio_1:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_1.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_1.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_gg_1:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_gg_1.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_gg_1.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_4:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_4.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_4.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_gg_4:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_gg_4.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_gg_4.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_5:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_5.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_5.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_gg_5:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_gg_5.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_gg_5.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_6:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_6.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_6.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    x,y=[],[]
    for i in graph_ratio_gg_1:
        x.append( i[0])
        y.append( i[1])
    test.Get_axis2().plot(x,y,'o-', markeredgewidth=0,
    color=graph_ratio_gg_1.GetLineColor(),
    linestyle = convert_linestyle(graph_ratio_gg_1.GetLineStyle(), 'mpl'),
    markersize = hist_style.Get_marker_size(),
    marker = hist_style.Get_marker_style())

    test.Get_axis2().set_ylim(ymin = 0.6, ymax = 1.6)

    test.SavePlot('xs_comparison.pdf')
Example #9
0
def main():

    basedir="/disk1/erdweg/out/output2015_3_24_14_16/merged/"
    # lumi=19712

    # xs= ConfigObj("/disk1/erdweg/plotting/xs_Phys14.cfg")
    # bghists=HistStorage(xs,lumi,path=basedir,isData=True)

    bglist=OrderedDict()

    bglist["PU20bx25"]=['ZprimeToTauTau_M-1000_PU20bx25_PHYS14',
     'ZprimeToTauTau_M-5000_PU20bx25_PHYS14'
    ]
    bglist["AVE30BX50"]=['ZprimeToTauTau_M-1000_AVE30BX50_PHYS14',
     'ZprimeToTauTau_M-5000_AVE30BX50_PHYS14',
     ]
    bglist["PU40bx25"]=['ZprimeToTauTau_M-1000_PU40bx25_PHYS14',
     'ZprimeToTauTau_M-5000_PU40bx25_PHYS14',
    ]

    # bghists.addFileList(bglist)

    colorList={}
    colorList["PU20bx25"]="lightblue"
    colorList["AVE30BX50"]="lightgreen"
    colorList["PU40bx25"]="darkmagenta"

    hists=['HLT_Effs/eff_HLT_HLT_Mu40_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu40_v1_vs_pT(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_pT(Ele)',
     'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_Nvtx',
     'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_Nvtx',
    ]

    hists2D=['HLT_Effs/eff_HLT_HLT_Mu40_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu30_TkMu11_v1_vs_pT(Mu,Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_eta_vs_phi(Ele)',
     'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu23_TrkIsoVVL_Ele12_Gsf_CaloId_TrackId_Iso_MediumWP_v1_vs_pT(Mu,Ele)',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v1_vs_pT(Mu,Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v1_vs_pT(Mu,Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_Mu17_Mu8_v1_vs_pT(Mu,Mu)',
     'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_eta_vs_phi(Mu)',
     'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_eta_vs_phi(Tau)',
     'HLT_Effs/eff_HLT_HLT_IsoMu17_eta2p1_LooseIsoPFTau20_v1_vs_pT(Mu,Tau)',
     'HLT_Effs/eff_HLT_HLT_Ele95_CaloIdVT_GsfTrkIdT_v1_vs_eta_vs_phi(Ele)',
     'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_eta_vs_phi(Ele)',
     'HLT_Effs/eff_HLT_HLT_Ele23_Ele12_CaloId_TrackId_Iso_v1_vs_pT(Ele,Ele)',
     'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_eta_vs_phi(Ele)',
     'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_eta_vs_phi(Tau)',
     'HLT_Effs/eff_HLT_HLT_Ele22_eta2p1_WP85_Gsf_LooseIsoPFTau20_v1_vs_pT(Ele,Tau)',
    ]

    if True:
        for hist in hists:
            print("Now plotting: " + hist)
    
            histlist = []
            for item in bglist:
                tfile = root_open(basedir + bglist[item][1] + ".root", "READ")
                t_eff = Graph(tfile.Get(hist).CreateGraph())
                t_eff.SetLineColor(colorList[item])
                t_eff.SetTitle(item)
                if 'Nvtx' in hist:
                    t_eff.xaxis.SetTitle('$N_{vtx}$')
                if 'pT' in hist:
                    t_eff.xaxis.SetTitle('$p_{T}$ (GeV)')
                t_eff.yaxis.SetTitle('$\epsilon$')
                histlist.append(t_eff)
    
            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Graphs', cmsPositon = "upper right", legendPosition = 'lower middle', lumi = 1000, cms = 13)
    
            test = plotter(hist = [histlist[0], histlist[1], histlist[2]],style=hist_style)
    
            test.Set_axis(logy = False, grid = True)
    
            test._cms_text_x         = 0.12
            test._cms_text_y         = 0.91
    
            name=hist.replace("/","")
    
            test.make_plot('plots/%s.pdf'%(name))

    if True:
        for hist in hists2D:
            print("Now plotting: " + hist)
    
            histlist = []
            for item in bglist:
                tfile = root_open(basedir + bglist[item][1] + ".root", "READ")
                t_eff = tfile.Get(hist).CreateHistogram()
                # t_eff.SetLineColor(colorList[item])
                t_eff.SetTitle(item)
                # t_eff.xaxis.SetTitle(t_eff.GetXaxis().GetTitle())
                # t_eff.yaxis.SetTitle(t_eff.GetYaxis().GetTitle())
                histlist.append(t_eff)
    
            hist_style = sc.style_container(style = 'CMS', useRoot = False, kind = 'Standard', cmsPositon = "upper left", legendPosition = 'lower middle', lumi = 1000, cms = 13)

            hist_style.Set_additional_text('plot dummy')

            test = plotter2D(hist = histlist[0], style = hist_style)

            # test.Set_axis(xmin = -2.5, xmax = 2.5, ymin = 0, ymax = 3.1, zmin = 0, zmax = 1)

            name=hist.replace("/","")

            test.create_plot()

            test.save_plot('plots/%s.pdf'%(name))

    return 42