Пример #1
0
def plot_roc_curve(roc_b, roc_c, comp_roc_b, comp_roc_c, xlimits, ylimits,
                   type, filename):
    canv = TCanvas("c1", "c1", 800, 600)
    mg = TMultiGraph()
    roc_b.SetLineColor(1)
    roc_c.SetLineColor(4)
    comp_roc_b.SetLineColor(1)
    comp_roc_c.SetLineColor(4)
    roc_b.SetMarkerColor(1)
    roc_c.SetMarkerColor(4)
    comp_roc_b.SetMarkerColor(1)
    comp_roc_c.SetMarkerColor(4)
    roc_b.SetMarkerStyle(20)
    roc_c.SetMarkerStyle(20)
    comp_roc_b.SetMarkerStyle(22)
    comp_roc_c.SetMarkerStyle(22)
    mg.Add(roc_b)
    mg.Add(roc_c)
    mg.Add(comp_roc_b)
    mg.Add(comp_roc_c)
    mg.SetTitle("; " + type + " efficiency; " + type + " fake rate")
    mg.Draw("ALP")
    mg.GetXaxis().SetLimits(xlimits[0], xlimits[1])
    mg.SetMinimum(ylimits[0])
    mg.SetMaximum(ylimits[1])
    legend = TLegend(0.15, 0.88 - 0.08 * 4, 0.3, 0.88, '', 'NDC')
    legend.AddEntry(roc_b, "b-jets (GNN)", "lp")
    legend.AddEntry(roc_c, "c-jets (GNN)", "lp")
    legend.AddEntry(comp_roc_b, "b-jets (SV1)", "p")
    legend.AddEntry(comp_roc_c, "c-jets (SV1)", "p")
    legend.SetTextSize(0.025)
    legend.SetFillStyle(0)
    legend.SetBorderSize(0)
    legend.Draw("SAME")
    canv.SaveAs(filename)
    canv.Clear()
    del canv
Пример #2
0
def TwoFileSAME3VsLumi(F1graph1, F1graph2, F1graph3, F2graph1, F2graph2, F2graph3, title, type, DoInclusive):
    canvas = makeCMSCanvas(str(random.random()),"canvas",900,700)
    canvas.cd()
    F1graph1.SetMarkerColor(kBlack)#electrons
    F1graph2.SetMarkerColor(kBlue)#electrons
    F1graph3.SetMarkerColor(kRed)#muons
    F2graph1.SetMarkerColor(kBlack)#electrons
    F2graph2.SetMarkerColor(kBlue)#electrons
    F2graph3.SetMarkerColor(kRed)#muons
    F2graph1.SetMarkerStyle(kOpenStar)#inclusive
    F2graph2.SetMarkerStyle(kOpenStar)#electrons
    F2graph3.SetMarkerStyle(kOpenStar)#muons
    multigraph = TMultiGraph()
    if(DoInclusive or type == "ZmassBARELL" or type == "ZwidthBARELL" or type == "ZmultBARELL"):
        multigraph.Add(F1graph1,"AP")
        multigraph.Add(F2graph1,"AP")
    multigraph.Add(F1graph2,"AP")
    multigraph.Add(F1graph3,"AP")
    multigraph.Add(F2graph2,"AP")
    multigraph.Add(F2graph3,"AP")
    multigraph.Draw("AP")
    multigraph.GetXaxis().SetTitle("L [fb^{-1}]")
    multigraph.GetXaxis().SetLimits(0.,40.)
    multigraph.GetYaxis().SetTitleOffset(1.4)
    gPad.Modified()

    if(type == "Zmass" or type == "ZmassBARELL"):
        multigraph.SetMaximum(1.008*gPad.GetUymax())
        multigraph.GetYaxis().SetTitle("M_{l^{+}l^{-}} [GeV]")
    elif(type == "Zwidth" or type == "ZwidthBARELL"):
        multigraph.SetMaximum(1.1*gPad.GetUymax())
        multigraph.GetYaxis().SetTitle("#Gamma [GeV]")
    elif(type == "Zmult" or type == "ZmultBARELL"):
        multigraph.SetMaximum(1.2*gPad.GetUymax())
        multigraph.GetYaxis().SetTitle("#Z")
    elif(type == "SIP"):
        multigraph.GetYaxis().SetTitle("SIP")
        multigraph.SetMaximum(1.1*gPad.GetUymax())
    printLumiPrelOut(canvas)
    canvas.Update()
    down = gPad.GetUymin()
    up = gPad.GetUymax()
    MC_muMass = 90.92
    MC_eleMass = 90.63
    Data_muMass = 90.95
    Data_eleMass = 90.68
    lineB = TLine(5.57,down,5.57, up)
    lineB.SetLineColor(kBlack)
    lineB.SetLineStyle(2)
    lineB.Draw()
    lineC = TLine(8.58,down,8.58,up)
    lineC.SetLineColor(kBlack)
    lineC.SetLineStyle(2)
    lineC.Draw()
    lineD = TLine(12.9,down,12.9,up)
    lineD.SetLineColor(kBlack)
    lineD.SetLineStyle(2)
    lineD.Draw()
    lineE = TLine(16.57,down,16.57,up)
    lineE.SetLineColor(kBlack)
    lineE.SetLineStyle(2)
    lineE.Draw()
    lineF = TLine(19.7,down,19.7,up)
    lineF.SetLineColor(kBlack)
    lineF.SetLineStyle(2)
    lineF.Draw()
    lineG = TLine(26.9,down,26.9,up)
    lineG.SetLineColor(kBlack)
    lineG.SetLineStyle(2)
    lineG.Draw()
    if(type == "Zmass"):
        lineMC_ele = TLine(0.,MC_eleMass,40., MC_eleMass)
        lineMC_ele.SetLineColor(kBlue)
        lineMC_ele.SetLineStyle(1)
        lineMC_ele.Draw()
        lineMC_mu = TLine(0.,MC_muMass,40., MC_muMass)
        lineMC_mu.SetLineColor(kRed)
        lineMC_mu.SetLineStyle(1)
        lineMC_mu.Draw()
        lineData_ele = TLine(0.,Data_eleMass,40., Data_eleMass)
        lineData_ele.SetLineColor(kBlue)
        lineData_ele.SetLineStyle(2)
        lineData_ele.Draw()
        lineData_mu = TLine(0.,Data_muMass,40., Data_muMass)
        lineData_mu.SetLineColor(kRed)
        lineData_mu.SetLineStyle(2)
        lineData_mu.Draw()
    legend = TLegend(0.80,0.75,0.965,0.93)
    if(type == "Zmass" or type == "Zwidth" or type == "Zmult"):
        legend.AddEntry(F1graph2,"e^{+}e^{-}","P")
        legend.AddEntry(F1graph3,"#mu^{+}#mu^{-}","P")
        legend.AddEntry(F2graph2,"e^{+}e^{-} ICHEP","P")
        legend.AddEntry(F2graph3,"#mu^{+}#mu^{-} ICHEP","P")
    else:
        legend.AddEntry(F1graph1,"EBEB","P")
        legend.AddEntry(F2graph1,"EBEB ICHEP","P")
        legend.AddEntry(F1graph2,"EBEE","P")
        legend.AddEntry(F1graph3,"EEEE","P")
        legend.AddEntry(F2graph2,"EBEE ICHEP","P")
        legend.AddEntry(F2graph3,"EEEE ICHEP","P")
    legend.SetTextFont(32)
    legend.Draw()
    canvas.SaveAs(title + ".pdf")
    canvas.SaveAs(title + ".png")
    return;
Пример #3
0
def SAME2VsLumi(g1, g2,title, ptype, dataPeriod):
    canvas = makeCMSCanvas(str(random.random()),"canvas",900,700)
    canvas.cd()
    graph1=copy.deepcopy(g1)
    graph2=copy.deepcopy(g2)
    graph1.SetMarkerColor(kBlue)#electrons
    graph2.SetMarkerColor(kRed)#muons
    multigraph = TMultiGraph()
    multigraph.Add(graph1,"AP")
    multigraph.Add(graph2,"AP")
    multigraph.Draw("AP")
    TGaxis.SetMaxDigits(2)
    TGaxis.SetExponentOffset(-0.06, 0.02, "y")
    multigraph.GetXaxis().SetTitle("L [fb^{-1}]")
    multigraph.GetYaxis().SetTitleOffset(1.4)
    if(ptype == "ISO"):
        multigraph.GetYaxis().SetTitle("Isolation")
        gPad.Modified()
        multigraph.SetMinimum(0.5*gPad.GetUymin())
        multigraph.SetMaximum(1.5*gPad.GetUymax())
    elif(ptype == "SIP"):
        multigraph.GetYaxis().SetTitle("SIP")
        multigraph.SetMinimum(min(multigraph.GetHistogram().GetMinimum(),1.))
        multigraph.SetMaximum(max(multigraph.GetHistogram().GetMinimum(),2.2))

        min(multigraph.GetHistogram().GetMinimum(),1.)
    printLumiPrelOut(canvas)

    
    # Draw legend 
    legend = TLegend(0.93,0.84,0.99,0.93)
    legend.AddEntry(graph1,"e^{+}e^{-}","P")
    legend.AddEntry(graph2,"#mu^{+}#mu^{-}","P")
    legend.SetFillColor(kWhite)
    legend.SetLineColor(kBlack)
    legend.SetTextFont(43)
    legend.SetTextSize(20)
    legend.Draw()
    canvas.Update()

    

    # Draw letters for data-taking periods
    if(dataPeriod == "data2017"):
        textLetters = TLatex()
        textLetters.SetTextColor(kGray+1)
        textLetters.SetTextSize(0.03)
        if(ptype == "ISO"):
            textLetters.DrawLatex(2.,  0.8*gPad.GetUymax(),"B")
            textLetters.DrawLatex(9.5, 0.8*gPad.GetUymax(),"C")
            textLetters.DrawLatex(16., 0.8*gPad.GetUymax(),"D")
            textLetters.DrawLatex(23., 0.8*gPad.GetUymax(),"E")
            textLetters.DrawLatex(36., 0.8*gPad.GetUymax(),"F")
        elif(ptype == "SIP"):
            textLetters.DrawLatex(2.,  1.5,"B")    
            textLetters.DrawLatex(9.5, 1.5,"C")
            textLetters.DrawLatex(16., 1.5,"D")
            textLetters.DrawLatex(23., 1.5,"E")
            textLetters.DrawLatex(36., 1.5,"F")

    if(dataPeriod == "data2018"):
        textLetters = TLatex()
        textLetters.SetTextColor(kGray+1)
        textLetters.SetTextSize(0.03)
        if(ptype == "ISO"):
            textLetters.DrawLatex(6.,   0.8*gPad.GetUymax(), "A")
            textLetters.DrawLatex(16.,  0.8*gPad.GetUymax(), "B")
            textLetters.DrawLatex(23.,  0.8*gPad.GetUymax(), "C")
            textLetters.DrawLatex(43.,  0.8*gPad.GetUymax(), "D")
        elif(ptype == "SIP"):
            textLetters.DrawLatex(6.,  1.5, "A")    
            textLetters.DrawLatex(16., 1.5, "B")
            textLetters.DrawLatex(23., 1.5, "C")
            textLetters.DrawLatex(43., 1.5, "D")
         


    # ****
    if(dataPeriod == "data2018"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineA = TLine(13.48, down, 13.48, up) # Run2018A up to 13.48 fb-1
        lineA.SetLineColor(kBlack)
        lineA.SetLineStyle(2)
        lineA.Draw()
        
        lineB = TLine(20.265, down, 20.265, up) # Run2018B up to 20.265 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()
        
        lineC = TLine(26.877, down, 26.877, up) # Run2018C up to 26.877 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw()
        
    # ****
    if(dataPeriod == "data2017"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineB = TLine(4.793, down, 4.793, up) # Run2017B up to 4.793 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()
        
        lineC = TLine(14.549, down, 14.549, up) # Run2017C up to 14.549 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw()
        
        lineD = TLine(18.868, down, 18.868, up) # Run2017D up to 18.868 fb-1
        lineD.SetLineColor(kBlack)
        lineD.SetLineStyle(2)
        lineD.Draw()
        
        lineE = TLine(28.293, down, 28.293, up) # Run2017E up to 28.293 fb-1
        lineE.SetLineColor(kBlack)
        lineE.SetLineStyle(2)
        lineE.Draw()
    
    # ****
    if(dataPeriod == "data2016"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineB = TLine(5.789, down, 5.789, up) # Run2016B up to 5.789 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()
        
        lineC = TLine(8.366, down, 8.366, up) # Run2016C up to 8.366 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw() 
        
        lineD = TLine(12.616, down, 12.616, up) # Run2016D up to 12.616 fb-1
        lineD.SetLineColor(kBlack)
        lineD.SetLineStyle(2)
        lineD.Draw()    
        
        lineE = TLine(16.624, down, 16.624, up) # Run2016E up to 16.624 fb-1
        lineE.SetLineColor(kBlack)
        lineE.SetLineStyle(2)
        lineE.Draw()    
        
        lineF = TLine(19.725, down, 19.725, up) # Run2016F up to 19.725 fb-1
        lineF.SetLineColor(kBlack)
        lineF.SetLineStyle(2)
        lineF.Draw()    
        
        lineG = TLine(27.268, down, 27.268, up) # Run2016G up to 27.268 fb-1
        lineG.SetLineColor(kBlack)
        lineG.SetLineStyle(2)
        lineG.Draw()       
    # ****
    

    canvas.SaveAs(title + ".root")
    canvas.SaveAs(title + ".pdf")
    canvas.SaveAs(title + ".png")
    return;
Пример #4
0
def SAME3VsLumi(g1, g2, g3, title, ptype, lineMC1, lineDATA1, lineMC2, lineDATA2, lineMC3, lineDATA3, DoInclusive, dataPeriod):
    canvas = makeCMSCanvas(str(random.random()),"canvas",900,700)
    canvas.cd()
    graph2=copy.deepcopy(g2)
    graph3=copy.deepcopy(g3)
    graph2.SetMarkerColor(kBlue)#electrons
    graph3.SetMarkerColor(kRed)#muons
    multigraph = TMultiGraph()
    if(DoInclusive):
        graph1=copy.deepcopy(g1)
        multigraph.Add(graph1,"AP")
    multigraph.Add(graph2,"AP")
    multigraph.Add(graph3,"AP")
    multigraph.Draw("AP")
    TGaxis.SetMaxDigits(2)
    TGaxis.SetExponentOffset(-0.05, 0.02, "y")
    multigraph.GetXaxis().SetTitle("L [fb^{-1}]")
    multigraph.GetYaxis().SetTitleOffset(1.4)
    if(ptype == "Zmass"):
        multigraph.GetYaxis().SetTitle("M_{Z} [GeV]")
        # multigraph.GetYaxis().SetTitle("M_{l^{+}l^{-}} [GeV]")
        multigraph.SetMaximum(max(multigraph.GetHistogram().GetMaximum(),91.4))
        multigraph.SetMinimum(min(multigraph.GetHistogram().GetMinimum(),89.6))
    elif(ptype == "Zwidth"):
        multigraph.GetYaxis().SetTitle("#Gamma_{Z} [GeV]")
    elif(ptype == "Zmult"):
        multigraph.GetYaxis().SetTitle("#Z / fb^{-1}")
        if(not DoInclusive) :
            multigraph.SetMaximum(max(multigraph.GetHistogram().GetMaximum(),60000.)) # set y axis minimum at 60000.
            multigraph.SetMinimum(0.)     # set y axis minimum at 0. 
            # multigraph.SetMaximum(60000.)  #second type: vs 2016 plots 
            # multigraph.SetMinimum(25000.)      
    printLumiPrelOut(canvas)

    
    # Draw legend 
    legend = TLegend(0.93,0.84,0.99,0.93)
    if(DoInclusive):
        #legend.AddEntry(graph1,"inclusive","P")
        legend.AddEntry(graph1,"BB","P")
        legend.AddEntry(graph2,"BE","P")
        legend.AddEntry(graph3,"EE","P")
    else :
        legend.AddEntry(graph2,"e^{+}e^{-}","P")
        legend.AddEntry(graph3,"#mu^{+}#mu^{-}","P")
    legend.SetFillColor(kWhite)
    legend.SetLineColor(kBlack)
    legend.SetTextFont(43)
    legend.SetTextSize(20)
    legend.Draw()
    canvas.Update()

    
    # Draw letters for data-taking periods
    if(dataPeriod == "data2017"):
        textLetters = TLatex()
        textLetters.SetTextColor(kGray+1)
        textLetters.SetTextSize(0.03)
        if(ptype == "Zmass"):
            textLetters.DrawLatex(2.,  gPad.GetUymin()+0.2,"B")
            textLetters.DrawLatex(9.5, gPad.GetUymin()+0.2,"C")
            textLetters.DrawLatex(16., gPad.GetUymin()+0.2,"D")
            textLetters.DrawLatex(23., gPad.GetUymin()+0.2,"E")
            textLetters.DrawLatex(36., gPad.GetUymin()+0.2,"F")
        elif(ptype == "Zwidth"):
            textLetters.DrawLatex(2.,  gPad.GetUymin()+0.3,"B")
            textLetters.DrawLatex(9.5, gPad.GetUymin()+0.3,"C")
            textLetters.DrawLatex(16., gPad.GetUymin()+0.3,"D")
            textLetters.DrawLatex(23., gPad.GetUymin()+0.3,"E")
            textLetters.DrawLatex(36., gPad.GetUymin()+0.3,"F")
        elif(ptype == "Zmult") :
            textLetters.DrawLatex(2.,  260000,"B")
            textLetters.DrawLatex(9.5, 260000,"C")
            textLetters.DrawLatex(16., 260000,"D")
            textLetters.DrawLatex(23., 260000,"E")
            textLetters.DrawLatex(36., 260000,"F")

    if(dataPeriod == "data2018"):
        textLetters = TLatex()
        textLetters.SetTextColor(kGray+1)
        textLetters.SetTextSize(0.03)
        if(ptype == "Zmass"):
            textLetters.DrawLatex(6.,  gPad.GetUymin() + 0.6,"A")
            textLetters.DrawLatex(16., gPad.GetUymin() + 0.6,"B")
            textLetters.DrawLatex(23., gPad.GetUymin() + 0.6,"C")
            textLetters.DrawLatex(43., gPad.GetUymin() + 0.6,"D")
        elif(ptype == "Zwidth"):
            textLetters.DrawLatex(6.,  gPad.GetUymin() +0.3,"A")
            textLetters.DrawLatex(16., gPad.GetUymin() +0.3,"B")
            textLetters.DrawLatex(23., gPad.GetUymin() +0.3,"C")
            textLetters.DrawLatex(43., gPad.GetUymin() +0.3,"D")
        elif(ptype == "Zmult") :
            textLetters.DrawLatex(6.,  260000,"A")
            textLetters.DrawLatex(16., 260000,"B")
            textLetters.DrawLatex(23., 260000,"C")
            textLetters.DrawLatex(43., 260000,"D")

    
    # ****
    if(dataPeriod == "data2018"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineA = TLine(13.48, down, 13.48, up) # Run2018A up to 13.48 fb-1
        lineA.SetLineColor(kBlack)
        lineA.SetLineStyle(2)
        lineA.Draw()    
        
        lineB = TLine(20.265, down, 20.265, up) # Run2018B up to 20.265 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()
        
        lineC = TLine(26.877, down, 26.877, up) # Run2018C up to 26.877 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw()
        

    if(dataPeriod == "data2017"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineB = TLine(4.793, down, 4.793, up) # Run2017B up to 4.793 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()    
        
        lineC = TLine(14.549, down, 14.549, up) # Run2017C up to 14.549 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw()
        
        lineD = TLine(18.868, down, 18.868, up) # Run2017D up to 18.868 fb-1
        lineD.SetLineColor(kBlack)
        lineD.SetLineStyle(2)
        lineD.Draw()
        
        lineE = TLine(28.293, down, 28.293, up) # Run2017E up to 28.293 fb-1
        lineE.SetLineColor(kBlack)
        lineE.SetLineStyle(2)
        lineE.Draw()

    if(dataPeriod == "data2016"):
        # draw vertical lines that divide different data taking periods
        down    = gPad.GetUymin()
        up      = gPad.GetUymax()
        
        lineB = TLine(5.789, down, 5.789, up) # Run2016B up to 5.789 fb-1
        lineB.SetLineColor(kBlack)
        lineB.SetLineStyle(2)
        lineB.Draw()
        
        lineC = TLine(8.366, down, 8.366, up) # Run2016C up to 8.366 fb-1
        lineC.SetLineColor(kBlack)
        lineC.SetLineStyle(2)
        lineC.Draw() 
        
        lineD = TLine(12.616, down, 12.616, up) # Run2016D up to 12.616 fb-1
        lineD.SetLineColor(kBlack)
        lineD.SetLineStyle(2)
        lineD.Draw()    
        
        lineE = TLine(16.624, down, 16.624, up) # Run2016E up to 16.624 fb-1
        lineE.SetLineColor(kBlack)
        lineE.SetLineStyle(2)
        lineE.Draw()    
        
        lineF = TLine(19.725, down, 19.725, up) # Run2016F up to 19.725 fb-1
        lineF.SetLineColor(kBlack)
        lineF.SetLineStyle(2)
        lineF.Draw()    
        
        lineG = TLine(27.268, down, 27.268, up) # Run2016G up to 27.268 fb-1
        lineG.SetLineColor(kBlack)
        lineG.SetLineStyle(2)
        lineG.Draw()       
    # ****
    
    # draw orizontal lines for MC and DATA fit
    if(ptype == "Zmass" or ptype == "Zwidth") :

        leftEnd  = gPad.GetUxmin()
        rightEnd = gPad.GetUxmax()

        if(DoInclusive):
            line1 = TLine(leftEnd,lineMC1,rightEnd,lineMC1)
            line1.SetLineColor(kBlack)
            line1.SetLineStyle(1) 
            line1.Draw()

            line2 = TLine(leftEnd,lineDATA1,rightEnd,lineDATA1)
            line2.SetLineColor(kBlack)
            line2.SetLineStyle(2)
            line2.Draw()
        
        # line for graph 2: color blue
        line3 = TLine(leftEnd,lineMC2,rightEnd,lineMC2)
        line3.SetLineColor(kBlue)
        line3.SetLineStyle(1) 
        line3.Draw()

        line4 = TLine(leftEnd,lineDATA2,rightEnd,lineDATA2)
        line4.SetLineColor(kBlue)
        line4.SetLineStyle(2)
        line4.Draw()
    
        # line for graph 3: color red
        line5 = TLine(leftEnd,lineMC3,rightEnd,lineMC3)
        line5.SetLineColor(kRed)
        line5.SetLineStyle(1) 
        line5.Draw()

        line6 = TLine(leftEnd,lineDATA3,rightEnd,lineDATA3)
        line6.SetLineColor(kRed)
        line6.SetLineStyle(2)
        line6.Draw()
    # ***    

    canvas.SaveAs(title + ".root")
    canvas.SaveAs(title + ".pdf")
    canvas.SaveAs(title + ".png")
    return;
Пример #5
0
def eta_plot(X0W, Y0W, X1W, Y1W, X2W, Y2W, X3W, Y3W, X4W, Y4W, X5W, Y5W, X6W,
             Y6W, X7W, Y7W, X8W, Y8W, X9W, Y9W, X10W, Y10W, X11W, Y11W, X12W,
             Y12W, X13W, Y13W, X0E, Y0E, X1E, Y1E, X2E, Y2E, X3E, Y3E, X4E,
             Y4E, X5E, Y5E, X6E, Y6E, X7E, Y7E, X8E, Y8E, X9E, Y9E, X10E, Y10E,
             X11E, Y11E, X12E, Y12E, X13E, Y13E):
    print "------ Setting Up Format ----------"
    tdrstyle.setTDRStyle()
    #change the CMS_lumi variables (see CMS_lumi.py)
    CMS_lumi.writeExtraText = 1
    CMS_lumi.extraText = "Preliminary"
    CMS_lumi.extraText2 = "2018 pp data"
    CMS_lumi.lumi_sqrtS = "13 TeV"  # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
    CMS_lumi.writeTitle = 1
    CMS_lumi.textTitle = 'title'

    iPos = 11
    if (iPos == 0): CMS_lumi.relPosX = 0.12

    H_ref = 600
    W_ref = 800
    W = W_ref
    H = H_ref
    iPeriod = 0
    # references for T, B, L, R
    T = 0.08 * H_ref
    B = 0.12 * H_ref
    L = 0.12 * W_ref
    R = 0.04 * W_ref

    print "------ Creating Wheel TGraph ----------"
    n0W = len(X0W)
    gr0W = TGraph(n0W, X0W, Y0W)
    gr0W.SetMarkerColor(kRed)
    gr0W.SetMarkerStyle(20)
    gr0W.SetMarkerSize(1.5)
    gr0W.SetTitle('RB1 in')
    gr0W.GetXaxis().SetTitle('#eta')
    gr0W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n1W = len(X1W)
    gr1W = TGraph(n1W, X1W, Y1W)
    gr1W.SetLineColor(2)
    gr1W.SetLineWidth(4)
    gr1W.SetMarkerColor(kBlue)
    gr1W.SetMarkerStyle(29)
    gr1W.SetMarkerSize(1.7)
    gr1W.SetTitle('Layer 1 Wheel')
    gr1W.GetXaxis().SetTitle('#eta')
    gr1W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n2W = len(X2W)
    gr2W = TGraph(n2W, X2W, Y2W)
    gr2W.SetLineColor(3)
    gr2W.SetLineWidth(5)
    gr2W.SetMarkerColor(kRed + 2)
    gr2W.SetMarkerStyle(21)
    gr2W.SetMarkerSize(1.5)
    gr2W.SetTitle('Layer 2 Wheel')
    gr2W.GetXaxis().SetTitle('#eta')
    gr2W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n3W = len(X3W)
    gr3W = TGraph(n3W, X3W, Y3W)
    gr3W.SetLineColor(4)
    gr3W.SetLineWidth(6)
    gr3W.SetMarkerColor(kRed)
    gr3W.SetMarkerStyle(21)
    gr3W.SetMarkerSize(1.5)
    gr3W.SetTitle('Layer 3 Wheel')
    gr3W.GetXaxis().SetTitle('#eta')
    gr3W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n4W = len(X4W)
    gr4W = TGraph(n4W, X4W, Y4W)
    gr4W.SetLineColor(5)
    gr4W.SetLineWidth(7)
    gr4W.SetMarkerColor(kBlue)
    gr4W.SetMarkerStyle(23)
    gr4W.SetMarkerSize(1.5)
    gr4W.SetTitle('Layer 4 Wheel')
    gr4W.GetXaxis().SetTitle('#eta')
    gr4W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    print "------ Creating Endcap TGraph ----------"
    n0E = len(X0E)
    gr0E = TGraph(n0E, X0E, Y0E)
    gr0E.SetLineColor(2)
    gr0E.SetLineWidth(4)
    gr0E.SetMarkerColor(kRed)
    gr0E.SetMarkerStyle(24)
    gr0E.SetMarkerSize(1.5)
    gr0E.SetTitle('Layer 1 Endcap')
    gr0E.GetXaxis().SetTitle('#eta')
    gr0E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n1E = len(X1E)
    gr1E = TGraph(n1E, X1E, Y1E)
    gr1E.SetLineColor(2)
    gr1E.SetLineWidth(4)
    gr1E.SetMarkerColor(kBlue)
    gr1E.SetMarkerStyle(30)
    gr1E.SetMarkerSize(1.5)
    gr1E.SetTitle('Layer 1 Endcap')
    gr1E.GetXaxis().SetTitle('#eta')
    gr1E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n2E = len(X2E)
    gr2E = TGraph(n2E, X2E, Y2E)
    gr2E.SetLineColor(3)
    gr2E.SetLineWidth(5)
    gr2E.SetMarkerColor(kRed + 2)
    gr2E.SetMarkerStyle(25)
    gr2E.SetMarkerSize(1.5)
    gr2E.SetTitle('Layer 2 Endcap')
    gr2E.GetXaxis().SetTitle('#eta')
    gr2E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n3E = len(X3E)
    gr3E = TGraph(n3E, X3E, Y3E)
    gr3E.SetLineColor(4)
    gr3E.SetLineWidth(6)
    gr3E.SetMarkerColor(kRed)
    gr3E.SetMarkerStyle(25)
    gr3E.SetMarkerSize(1.5)
    gr3E.SetTitle('Layer 3 Endcap')
    gr3E.GetXaxis().SetTitle('#eta')
    gr3E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n4E = len(X4E)
    gr4E = TGraph(n4E, X4E, Y4E)
    gr4E.SetLineColor(5)
    gr4E.SetLineWidth(7)
    gr4E.SetMarkerColor(kBlue)
    gr4E.SetMarkerStyle(32)
    gr4E.SetMarkerSize(1.5)
    gr4E.SetTitle('Layer 4 Endcap')
    gr4E.GetXaxis().SetTitle('#eta')
    gr4E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    print "------ Creating Wheel TGraph ----------"
    n5W = len(X5W)
    gr5W = TGraph(n5W, X5W, Y5W)
    gr5W.SetLineColor(2)
    gr5W.SetLineWidth(4)
    gr5W.SetMarkerColor(6)
    gr5W.SetMarkerStyle(22)
    gr5W.SetMarkerSize(1.5)
    gr5W.SetTitle('Layer 1 Wheel')
    gr5W.GetXaxis().SetTitle('#eta')
    gr5W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n6W = len(X6W)
    gr6W = TGraph(n6W, X6W, Y6W)
    gr6W.SetLineColor(3)
    gr6W.SetLineWidth(5)
    gr6W.SetMarkerColor(28)
    gr6W.SetMarkerStyle(23)
    gr6W.SetMarkerSize(1.7)
    gr6W.SetTitle('Layer 2 Wheel')
    gr6W.GetXaxis().SetTitle('#eta')
    gr6W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n7W = len(X7W)
    gr7W = TGraph(n7W, X7W, Y7W)
    gr7W.SetLineColor(4)
    gr7W.SetLineWidth(6)
    gr7W.SetMarkerColor(kRed)
    gr7W.SetMarkerStyle(20)
    gr7W.SetMarkerSize(1.5)
    gr7W.SetTitle('Layer 3 Wheel')
    gr7W.GetXaxis().SetTitle('#eta')
    gr7W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n8W = len(X8W)
    gr8W = TGraph(n8W, X8W, Y8W)
    gr8W.SetLineColor(5)
    gr8W.SetLineWidth(7)
    gr8W.SetMarkerColor(kBlue)
    gr8W.SetMarkerStyle(29)
    gr8W.SetMarkerSize(1.5)
    gr8W.SetTitle('Layer 4 Wheel')
    gr8W.GetXaxis().SetTitle('#eta')
    gr8W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n9W = len(X9W)
    gr9W = TGraph(n9W, X9W, Y9W)
    gr9W.SetLineColor(5)
    gr9W.SetLineWidth(7)
    gr9W.SetMarkerColor(kRed + 2)
    gr9W.SetMarkerStyle(21)
    gr9W.SetMarkerSize(1.5)
    gr9W.SetTitle('Layer 4 Wheel')
    gr9W.GetXaxis().SetTitle('#eta')
    gr9W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n10W = len(X10W)
    gr10W = TGraph(n10W, X10W, Y10W)
    gr10W.SetLineColor(5)
    gr10W.SetLineWidth(7)
    gr10W.SetMarkerColor(kRed)
    gr10W.SetMarkerStyle(21)
    gr10W.SetMarkerSize(1.5)
    gr10W.SetTitle('Layer 4 Wheel')
    gr10W.GetXaxis().SetTitle('#eta')
    gr10W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n11W = len(X11W)
    gr11W = TGraph(n11W, X11W, Y11W)
    gr11W.SetLineColor(5)
    gr11W.SetLineWidth(7)
    gr11W.SetMarkerColor(kBlue)
    gr11W.SetMarkerStyle(23)
    gr11W.SetMarkerSize(1.5)
    gr11W.SetTitle('Layer 4 Wheel')
    gr11W.GetXaxis().SetTitle('#eta')
    gr11W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n12W = len(X12W)
    gr12W = TGraph(n12W, X12W, Y12W)
    gr12W.SetLineColor(5)
    gr12W.SetLineWidth(7)
    gr12W.SetMarkerColor(6)
    gr12W.SetMarkerStyle(22)
    gr12W.SetMarkerSize(1.5)
    gr12W.SetTitle('Layer 4 Wheel')
    gr12W.GetXaxis().SetTitle('#eta')
    gr12W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n13W = len(X13W)
    gr13W = TGraph(n13W, X13W, Y13W)
    gr13W.SetLineColor(5)
    gr13W.SetLineWidth(7)
    gr13W.SetMarkerColor(28)
    gr13W.SetMarkerStyle(23)
    gr13W.SetMarkerSize(1.5)
    gr13W.SetTitle('Layer 4 Wheel')
    gr13W.GetXaxis().SetTitle('#eta')
    gr13W.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    print "------ Creating Endcap TGraph ----------"
    n5E = len(X5E)
    gr5E = TGraph(n5E, X5E, Y5E)
    gr5E.SetLineColor(2)
    gr5E.SetLineWidth(4)
    gr5E.SetMarkerColor(6)
    gr5E.SetMarkerStyle(26)
    gr5E.SetMarkerSize(1.5)
    gr5E.SetTitle('Layer 1 Endcap')
    gr5E.GetXaxis().SetTitle('#eta')
    gr5E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n6E = len(X6E)
    gr6E = TGraph(n6E, X6E, Y6E)
    gr6E.SetLineColor(3)
    gr6E.SetLineWidth(5)
    gr6E.SetMarkerColor(28)
    gr6E.SetMarkerStyle(32)
    gr6E.SetMarkerSize(1.5)
    gr6E.SetTitle('Layer 2 Endcap')
    gr6E.GetXaxis().SetTitle('#eta')
    gr6E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n7E = len(X7E)
    gr7E = TGraph(n7E, X7E, Y7E)
    gr7E.SetLineColor(4)
    gr7E.SetLineWidth(6)
    gr7E.SetMarkerColor(kRed)
    gr7E.SetMarkerStyle(24)
    gr7E.SetMarkerSize(1.5)
    gr7E.SetTitle('Layer 3 Endcap')
    gr7E.GetXaxis().SetTitle('#eta')
    gr7E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n8E = len(X8E)
    gr8E = TGraph(n8E, X8E, Y8E)
    gr8E.SetLineColor(5)
    gr8E.SetLineWidth(7)
    gr8E.SetMarkerColor(kBlue)
    gr8E.SetMarkerStyle(30)
    gr8E.SetMarkerSize(1.5)
    gr8E.SetTitle('Layer 4 Endcap')
    gr8E.GetXaxis().SetTitle('#eta')
    gr8E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n9E = len(X9E)
    gr9E = TGraph(n9E, X9E, Y9E)
    gr9E.SetLineColor(5)
    gr9E.SetLineWidth(7)
    gr9E.SetMarkerColor(kRed + 2)
    gr9E.SetMarkerStyle(25)
    gr9E.SetMarkerSize(1.5)
    gr9E.SetTitle('Layer 4 Endcap')
    gr9E.GetXaxis().SetTitle('#eta')
    gr9E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n10E = len(X10E)
    gr10E = TGraph(n10E, X10E, Y10E)
    gr10E.SetLineColor(5)
    gr10E.SetLineWidth(7)
    gr10E.SetMarkerColor(kRed)
    gr10E.SetMarkerStyle(25)
    gr10E.SetMarkerSize(1.5)
    gr10E.SetTitle('Layer 4 Endcap')
    gr10E.GetXaxis().SetTitle('#eta')
    gr10E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n11E = len(X11E)
    gr11E = TGraph(n11E, X11E, Y11E)
    gr11E.SetLineColor(5)
    gr11E.SetLineWidth(7)
    gr11E.SetMarkerColor(kBlue)
    gr11E.SetMarkerStyle(32)
    gr11E.SetMarkerSize(1.5)
    gr11E.SetTitle('Layer 4 Endcap')
    gr11E.GetXaxis().SetTitle('#eta')
    gr11E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n12E = len(X12E)
    gr12E = TGraph(n12E, X12E, Y12E)
    gr12E.SetLineColor(5)
    gr12E.SetLineWidth(7)
    gr12E.SetMarkerColor(6)
    gr12E.SetMarkerStyle(26)
    gr12E.SetMarkerSize(1.5)
    gr12E.SetTitle('Layer 4 Endcap')
    gr12E.GetXaxis().SetTitle('#eta')
    gr12E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    n13E = len(X13E)
    gr13E = TGraph(n13E, X13E, Y13E)
    gr13E.SetLineColor(5)
    gr13E.SetLineWidth(7)
    gr13E.SetMarkerColor(28)
    gr13E.SetMarkerStyle(32)
    gr13E.SetMarkerSize(1.5)
    gr13E.SetTitle('Layer 4 Endcap')
    gr13E.GetXaxis().SetTitle('#eta')
    gr13E.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')

    print "----- Reading Fluka Info -----"
    f = TFile.Open("../FlukaEta.root")
    flukaRB1 = f.RB1
    flukaRB1.SetMarkerColor(2)
    flukaRB1.SetMarkerStyle(20)
    flukaRB2 = f.RB2
    flukaRB2.SetMarkerColor(2)
    flukaRB2.SetMarkerStyle(20)
    flukaRB3 = f.RB3
    flukaRB3.SetMarkerColor(2)
    flukaRB3.SetMarkerStyle(20)
    flukaRB4 = f.RB4
    flukaRB4.SetMarkerColor(2)
    flukaRB4.SetMarkerStyle(20)

    flukaRE1 = f.RE1
    flukaRE1.SetMarkerColor(2)
    flukaRE1.SetMarkerStyle(4)
    flukaRE2 = f.RE2
    flukaRE2.SetMarkerColor(2)
    flukaRE2.SetMarkerStyle(4)
    flukaRE3 = f.RE3
    flukaRE3.SetMarkerColor(2)
    flukaRE3.SetMarkerStyle(4)
    flukaRE4 = f.RE4
    flukaRE4.SetMarkerColor(2)
    flukaRE4.SetMarkerStyle(4)

    print "I did open the file"
    print flukaRB1, flukaRE4

    print "----- Creating TCanvas -----"
    H = 800
    W = 1600
    canv = TCanvas("c1", "Canvas", 50, 50, W, H)
    canv.SetFillColor(0)
    canv.SetBorderMode(0)
    canv.SetFrameFillStyle(0)
    canv.SetFrameBorderMode(0)
    canv.SetLeftMargin(L / W)
    canv.SetRightMargin(R / W)
    canv.SetTopMargin(T / H)
    canv.SetBottomMargin(B / H)
    canv.SetTickx(0)
    canv.SetTicky(0)
    canv.Divide(3, 2, 0.001, 0.001)
    CMS_lumi.CMS_lumi(canv, iPeriod, iPos)
    canv.cd()
    canv.Update()
    maxY = 1000

    canv.cd(1)
    gPad.SetLogy()
    print " ------------ Creating TMultiGraph -----------"
    mg1 = TMultiGraph()

    gr0E.SetMarkerColor(4)
    gr0W.SetMarkerColor(4)
    gr7E.SetMarkerColor(4)
    gr7W.SetMarkerColor(4)

    mg1.Add(gr0E, "AP")
    mg1.Add(gr0W, "AP")
    mg1.Add(gr7E, "AP")
    mg1.Add(gr7W, "AP")
    mg1.Add(flukaRB1, "AP")
    mg1.Add(flukaRE1, "AP")
    mg1.Draw("a")
    mg1.SetTitle('RB1in')
    mg1.GetXaxis().SetTitle('#eta')
    mg1.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg1.SetMaximum(maxY)
    mg1.GetXaxis().SetLabelFont(42)
    mg1.GetXaxis().SetLabelOffset(0.007)
    mg1.GetXaxis().SetLabelSize(0.043)
    mg1.GetXaxis().SetTitleSize(0.05)
    mg1.GetXaxis().SetTitleOffset(1.06)
    mg1.GetXaxis().SetTitleFont(42)
    mg1.GetYaxis().SetLabelFont(42)
    mg1.GetYaxis().SetLabelOffset(0.008)
    mg1.GetYaxis().SetLabelSize(0.05)
    mg1.GetYaxis().SetTitleSize(0.06)
    mg1.GetYaxis().SetTitleOffset(0.87)
    mg1.GetYaxis().SetTitleFont(42)

    pvtxt = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvtxt.AddText('CMS Preliminary')
    pvtxt.SetFillStyle(0)
    pvtxt.SetBorderSize(0)
    pvtxt.SetTextSize(0.03)
    pvtxt.Draw()
    pvtxt100 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvtxt100.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvtxt100.SetFillStyle(0)
    pvtxt100.SetBorderSize(0)
    pvtxt100.SetTextSize(0.03)
    pvtxt100.Draw()

    canv.cd(2)
    gPad.SetLogy()
    gr00 = TGraph()
    gr00.SetMarkerColor(kBlack)
    gr00.SetMarkerStyle(20)
    gr00.SetMarkerSize(1.5)
    gr01 = TGraph()
    gr01.SetMarkerColor(kBlack)
    gr01.SetMarkerStyle(24)
    gr01.SetMarkerSize(1.5)

    legend0 = TLegend(0.2, 0.75, .8, .95)
    legend0.SetNColumns(1)
    legend0.AddEntry(gr00, "Barrel", "p")
    legend0.AddEntry(gr01, "Endcaps", "p")
    legend0.Draw("a same")

    legendi = TLegend(0.2, 0.15, .8, .69)
    legendi.SetNColumns(1)
    legendi.AddEntry(gr7W, "RB1in  + RE1", "p")
    legendi.AddEntry(gr8W, "RB1out + RE1", "p")
    legendi.AddEntry(gr9W, "RB2 + RE2", "p")
    #  legendi.AddEntry(gr10W, "RB2in  + RE2" , "p")
    #  legendi.AddEntry(gr11W, "RB2out + RE2" , "p")
    legendi.AddEntry(gr12W, "RB3 + RE3", "p")
    legendi.AddEntry(gr13W, "RB4 + RE4", "p")
    legendi.AddEntry(flukaRB1, "Fluka Simulation", "p")
    legendi.SetTextSize(0.05)
    legendi.Draw("a")

    canv.cd(3)
    gPad.SetLogy()
    mg2 = TMultiGraph()

    gr1E.SetMarkerColor(4)
    gr1W.SetMarkerColor(4)
    gr8E.SetMarkerColor(4)
    gr8W.SetMarkerColor(4)

    mg2.Add(gr1E, "AP")
    mg2.Add(gr1W, "AP")
    mg2.Add(gr8E, "AP")
    mg2.Add(gr8W, "AP")
    mg2.Add(flukaRB1, "AP")
    mg2.Add(flukaRE1, "AP")
    mg2.Draw("a")
    mg2.SetTitle('RB1out')
    mg2.GetXaxis().SetTitle('#eta')
    mg2.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg2.SetMaximum(maxY)
    mg2.GetXaxis().SetLabelFont(42)
    mg2.GetXaxis().SetLabelOffset(0.007)
    mg2.GetXaxis().SetLabelSize(0.043)
    mg2.GetXaxis().SetTitleSize(0.05)
    mg2.GetXaxis().SetTitleOffset(1.06)
    mg2.GetXaxis().SetTitleFont(42)
    mg2.GetYaxis().SetLabelFont(42)
    mg2.GetYaxis().SetLabelOffset(0.008)
    mg2.GetYaxis().SetLabelSize(0.05)
    mg2.GetYaxis().SetTitleSize(0.06)
    mg2.GetYaxis().SetTitleOffset(0.87)
    mg2.GetYaxis().SetTitleFont(42)

    pvtxt3 = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvtxt3.AddText('CMS Preliminary')
    pvtxt3.SetFillStyle(0)
    pvtxt3.SetBorderSize(0)
    pvtxt3.SetTextSize(0.03)
    pvtxt3.Draw()
    pvtxt4 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvtxt4.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvtxt4.SetFillStyle(0)
    pvtxt4.SetBorderSize(0)
    pvtxt4.SetTextSize(0.03)
    pvtxt4.Draw()

    canv.cd(4)
    gPad.SetLogy()
    mg3 = TMultiGraph()
    #graphAxis(mg3)

    gr2E.SetMarkerColor(4)
    gr2W.SetMarkerColor(4)
    gr9E.SetMarkerColor(4)
    gr9W.SetMarkerColor(4)

    mg3.Add(gr2E, "AP")
    mg3.Add(gr2W, "AP")
    mg3.Add(gr9E, "AP")
    mg3.Add(gr9W, "AP")
    mg3.Add(flukaRB2, "AP")
    mg3.Add(flukaRE2, "AP")
    mg3.Draw("a")
    mg3.SetTitle('RB2')
    mg3.GetXaxis().SetTitle('#eta')
    mg3.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg3.SetMaximum(maxY)
    mg3.GetXaxis().SetLabelFont(42)
    mg3.GetXaxis().SetLabelOffset(0.007)
    mg3.GetXaxis().SetLabelSize(0.043)
    mg3.GetXaxis().SetTitleSize(0.05)
    mg3.GetXaxis().SetTitleOffset(1.06)
    mg3.GetXaxis().SetTitleFont(42)
    mg3.GetYaxis().SetLabelFont(42)
    mg3.GetYaxis().SetLabelOffset(0.008)
    mg3.GetYaxis().SetLabelSize(0.05)
    mg3.GetYaxis().SetTitleSize(0.06)
    mg3.GetYaxis().SetTitleOffset(0.87)
    mg3.GetYaxis().SetTitleFont(42)

    pvtxt5 = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvtxt5.AddText('CMS Preliminary')
    pvtxt5.SetFillStyle(0)
    pvtxt5.SetBorderSize(0)
    pvtxt5.SetTextSize(0.03)
    pvtxt5.Draw()
    pvtxt6 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvtxt6.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvtxt6.SetFillStyle(0)
    pvtxt6.SetBorderSize(0)
    pvtxt6.SetTextSize(0.03)
    pvtxt6.Draw()

    canv.cd(5)
    gPad.SetLogy()
    mg4 = TMultiGraph()
    #graphAxis(mg4)

    gr5E.SetMarkerColor(4)
    gr5W.SetMarkerColor(4)
    gr12E.SetMarkerColor(4)
    gr12W.SetMarkerColor(4)

    mg4.Add(gr5E, "AP")
    mg4.Add(gr5W, "AP")
    mg4.Add(gr12E, "AP")
    mg4.Add(gr12W, "AP")
    mg4.Add(flukaRB3, "AP")
    mg4.Add(flukaRE3, "AP")
    mg4.Draw("a")
    mg4.SetTitle('RB3')
    mg4.GetXaxis().SetTitle('#eta')
    mg4.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg4.SetMaximum(maxY)
    mg4.GetXaxis().SetLabelFont(42)
    mg4.GetXaxis().SetLabelOffset(0.007)
    mg4.GetXaxis().SetLabelSize(0.043)
    mg4.GetXaxis().SetTitleSize(0.05)
    mg4.GetXaxis().SetTitleOffset(1.06)
    mg4.GetXaxis().SetTitleFont(42)
    mg4.GetYaxis().SetLabelFont(42)
    mg4.GetYaxis().SetLabelOffset(0.008)
    mg4.GetYaxis().SetLabelSize(0.05)
    mg4.GetYaxis().SetTitleSize(0.06)
    mg4.GetYaxis().SetTitleOffset(0.87)
    mg4.GetYaxis().SetTitleFont(42)

    pvtxt7 = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvtxt7.AddText('CMS Preliminary')
    pvtxt7.SetFillStyle(0)
    pvtxt7.SetBorderSize(0)
    pvtxt7.SetTextSize(0.03)
    pvtxt7.Draw()
    pvtxt8 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvtxt8.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvtxt8.SetFillStyle(0)
    pvtxt8.SetBorderSize(0)
    pvtxt8.SetTextSize(0.03)
    pvtxt8.Draw()

    canv.cd(6)
    gPad.SetLogy()
    mg5 = TMultiGraph()
    #graphAxis(mg5)

    gr6E.SetMarkerColor(4)
    gr6W.SetMarkerColor(4)
    gr13E.SetMarkerColor(4)
    gr13W.SetMarkerColor(4)

    mg5.Add(gr6E, "AP")
    mg5.Add(gr6W, "AP")
    mg5.Add(gr13E, "AP")
    mg5.Add(gr13W, "AP")
    mg5.Add(flukaRB4, "AP")
    mg5.Add(flukaRE4, "AP")
    mg5.Draw("a")
    mg5.SetTitle('RB4')
    mg5.GetXaxis().SetTitle('#eta')
    mg5.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg5.SetMaximum(maxY)
    mg5.GetXaxis().SetLabelFont(42)
    mg5.GetXaxis().SetLabelOffset(0.007)
    mg5.GetXaxis().SetLabelSize(0.043)
    mg5.GetXaxis().SetTitleSize(0.05)
    mg5.GetXaxis().SetTitleOffset(1.06)
    mg5.GetXaxis().SetTitleFont(42)
    mg5.GetYaxis().SetLabelFont(42)
    mg5.GetYaxis().SetLabelOffset(0.008)
    mg5.GetYaxis().SetLabelSize(0.05)
    mg5.GetYaxis().SetTitleSize(0.06)
    mg5.GetYaxis().SetTitleOffset(0.87)
    mg5.GetYaxis().SetTitleFont(42)

    pvtxt10 = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvtxt10.AddText('CMS Preliminary')
    pvtxt10.SetFillStyle(0)
    pvtxt10.SetBorderSize(0)
    pvtxt10.SetTextSize(0.03)
    pvtxt10.Draw()
    pvtxt9 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvtxt9.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvtxt9.SetFillStyle(0)
    pvtxt9.SetBorderSize(0)
    pvtxt9.SetTextSize(0.03)
    pvtxt9.Draw()

    canv.SaveAs("etaDistro.gif")
    canv.SaveAs("etaDistro.png")
    canv.SaveAs("etaDistro.pdf")
    canv.SaveAs("etaDistro.C")

    canv.Close()

    print "----- Creating Second TCanvas -----"
    H = 800
    W = 800
    c = TCanvas("c1", "Canvas", 50, 50, W, H)
    c.SetFillColor(0)
    c.SetBorderMode(0)
    c.SetFrameFillStyle(0)
    c.SetFrameBorderMode(0)
    c.SetLeftMargin(L / W)
    c.SetRightMargin(R / W)
    c.SetTopMargin(T / H)
    c.SetBottomMargin(B / H)
    c.SetTickx(0)
    c.SetTicky(0)
    gPad.SetLogy()

    print " ------------ Creating TMultiGraph -----------"
    mg = TMultiGraph()
    mg.Add(gr0E, "AP")
    mg.Add(gr0W, "AP")
    mg.Add(gr7E, "AP")
    mg.Add(gr7W, "AP")
    mg.Add(gr1W, "AP")
    mg.Add(gr8W, "AP")
    mg.Add(flukaRB1, "AP")
    mg.Add(flukaRE1, "AP")
    mg.Draw("a")
    mg.SetTitle('RB1in')
    mg.GetXaxis().SetTitle('#eta')
    mg.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mg.SetMaximum(maxY)
    mg.GetXaxis().SetLabelFont(42)
    mg.GetXaxis().SetLabelOffset(0.007)
    mg.GetXaxis().SetLabelSize(0.043)
    mg.GetXaxis().SetTitleSize(0.05)
    mg.GetXaxis().SetTitleOffset(1.06)
    mg.GetXaxis().SetTitleFont(42)
    mg.GetYaxis().SetLabelFont(42)
    mg.GetYaxis().SetLabelOffset(0.008)
    mg.GetYaxis().SetLabelSize(0.05)
    mg.GetYaxis().SetTitleSize(0.06)
    mg.GetYaxis().SetTitleOffset(0.87)
    mg.GetYaxis().SetTitleFont(42)

    pvt = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pvt.AddText('CMS Preliminary')
    pvt.SetFillStyle(0)
    pvt.SetBorderSize(0)
    pvt.SetTextSize(0.03)
    pvt.Draw()
    pvt1 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pvt1.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pvt1.SetFillStyle(0)
    pvt1.SetBorderSize(0)
    pvt1.SetTextSize(0.03)
    pvt1.Draw()

    legenda = TLegend(0.4, 0.7, .7, .9)
    legenda.SetNColumns(1)
    legenda.AddEntry(gr0E, "RE1", "p")
    legenda.AddEntry(gr0W, "RB1in", "p")
    legenda.AddEntry(gr1W, "RB1out", "p")
    legenda.AddEntry(flukaRB1, "Fluka Simulation", "p")
    legenda.SetTextSize(0.05)
    legenda.Draw("a")

    c.SaveAs("etaDistroDetailRB1.png")
    c.SaveAs("etaDistroDetailRB1.gif")
    c.SaveAs("etaDistroDetailRB1.pdf")
    c.SaveAs("etaDistroDetailRB1.C")

    c.Close()

    print "----- Creating Second TCanvas -----"
    c1 = TCanvas("c1", "Canvas", 50, 50, W, H)
    c1.SetFillColor(0)
    c1.SetBorderMode(0)
    c1.SetFrameFillStyle(0)
    c1.SetFrameBorderMode(0)
    c1.SetLeftMargin(L / W)
    c1.SetRightMargin(R / W)
    c1.SetTopMargin(T / H)
    c1.SetBottomMargin(B / H)
    c1.SetTickx(0)
    c1.SetTicky(0)
    gPad.SetLogy()

    print " ------------ Creating TMultiGraph -----------"
    mgd2 = TMultiGraph()

    gr3E.SetMarkerColor(4)
    gr3W.SetMarkerColor(4)
    gr10E.SetMarkerColor(4)
    gr10W.SetMarkerColor(4)
    gr4W.SetMarkerColor(4)
    gr11W.SetMarkerColor(4)

    mgd2.Add(gr3E, "AP")
    mgd2.Add(gr3W, "AP")
    mgd2.Add(gr10E, "AP")
    mgd2.Add(gr10W, "AP")
    mgd2.Add(gr4W, "AP")
    mgd2.Add(gr11W, "AP")
    mgd2.Add(flukaRB2, "AP")
    mgd2.Add(flukaRE2, "AP")
    mgd2.Draw("a")
    mgd2.SetTitle('RB1in')
    mgd2.GetXaxis().SetTitle('#eta')
    mgd2.GetYaxis().SetTitle('RPC single hit rate (Hz/cm^{2})')
    mgd2.SetMaximum(maxY)
    mgd2.GetXaxis().SetLabelFont(42)
    mgd2.GetXaxis().SetLabelOffset(0.007)
    mgd2.GetXaxis().SetLabelSize(0.043)
    mgd2.GetXaxis().SetTitleSize(0.05)
    mgd2.GetXaxis().SetTitleOffset(1.06)
    mgd2.GetXaxis().SetTitleFont(42)
    mgd2.GetYaxis().SetLabelFont(42)
    mgd2.GetYaxis().SetLabelOffset(0.008)
    mgd2.GetYaxis().SetLabelSize(0.05)
    mgd2.GetYaxis().SetTitleSize(0.06)
    mgd2.GetYaxis().SetTitleOffset(0.87)
    mgd2.GetYaxis().SetTitleFont(42)

    pv = TPaveText(.1, 0.97, .55, 0.97, "NDC")  #(.06,.4,.55,.73)
    pv.AddText('CMS Preliminary')
    pv.SetFillStyle(0)
    pv.SetBorderSize(0)
    pv.SetTextSize(0.03)
    pv.Draw()
    pv1 = TPaveText(.7, 0.97, .9, 0.97, "NDC")
    pv1.AddText('1.5 #times 10^{34} Hz/cm^{2} (13 TeV)')
    pv1.SetFillStyle(0)
    pv1.SetBorderSize(0)
    pv1.SetTextSize(0.03)
    pv1.Draw()

    legendd2 = TLegend(0.4, 0.6, .7, .8)
    legendd2.SetNColumns(1)
    legendd2.AddEntry(gr3E, "RE2", "p")
    legendd2.AddEntry(gr3W, "RB2in", "p")
    legendd2.AddEntry(gr4W, "RB2out", "p")
    legendd2.AddEntry(flukaRB2, "Fluka Simulation", "p")
    legendd2.SetTextSize(0.05)
    legendd2.Draw("a")

    c1.SaveAs("etaDistroDetailRB2.png")
    c1.SaveAs("etaDistroDetailRB2.pdf")
    c1.SaveAs("etaDistroDetailRB2.gif")
    c1.SaveAs("etaDistroDetailRB2.C")
Пример #6
0
    coutn += 1

gr1 = TGraph(n, xx, yy)
gr1.SetLineColor(1)
gr1.SetLineWidth(1)
gr1.SetLineStyle(3)
gr1.SetMarkerColor(1)
gr1.SetMarkerStyle(21)
##gr1.SetTitle( 'a simple graph' )
##gr1.GetXaxis().SetTitle( 'X title' )
##gr1.GetYaxis().SetTitle( 'Y title' )
#gr1.Draw( 'CP' )

mg.Add(gr)
mg.Add(gr1)
mg.SetMaximum(0.55)
mg.SetMinimum(-0.55)

#mg.GetXaxis().SetTitle("M_{WW} (GeV) CutOff Scale")
#mg.GetYaxis().SetTitle("FT0 (95% CL)")
mg.SetTitle(";M_{VV} cut-off scale (TeV);FT0 (#times 10^{-12} TeV^{-4})")

from ROOT import TPad, TH1F

pad1 = TPad("pad1", "pad1", 0.0, 0.0, 0.8, 1.0)
pad1.SetTopMargin(0.07)  # joins upper and lower plot
pad1.SetBottomMargin(0.13)  # joins upper and lower plot
pad1.SetLeftMargin(0.15)
pad1.SetRightMargin(0.0)
#pad1.SetLogy(1)
#pad1.SetGridx()
Пример #7
0
    print(' i %f %f %f ' % (coutn, xx[coutn], yy[coutn]))
    coutn += 1

gr1 = TGraph(n, xx, yy)
gr1.SetLineColor(2)
gr1.SetLineWidth(4)
gr1.SetMarkerColor(4)
gr1.SetMarkerStyle(21)
##gr1.SetTitle( 'a simple graph' )
##gr1.GetXaxis().SetTitle( 'X title' )
##gr1.GetYaxis().SetTitle( 'Y title' )
#gr1.Draw( 'CP' )

mg.Add(gr)
mg.Add(gr1)
mg.SetMaximum(0.4)
mg.SetMinimum(-0.4)

#mg.GetXaxis().SetTitle("M_{WW} (GeV) CutOff Scale")
#mg.GetYaxis().SetTitle("FT0 (95% CL)")
mg.SetTitle(";M_{WW} (GeV) CutOff Scale;FT0 (95% CL)")

from ROOT import TPad, TH1F

pad1 = TPad("pad1", "pad1", 0.0, 0.0, 0.8, 1.0)
pad1.SetTopMargin(0.07)  # joins upper and lower plot
pad1.SetBottomMargin(0.13)  # joins upper and lower plot
pad1.SetLeftMargin(0.15)
pad1.SetRightMargin(0.0)
#pad1.SetLogy(1)
pad1.SetGridx()
Пример #8
0
def printmultigraph(grs, sortk, plotoptions, outn, title, year, doext,
                    ploterror, ymax):
    import CMS_lumi, tdrstyle
    import array
    #set the tdr style
    tdrstyle.setTDRStyle()

    #change the CMS_lumi variables (see CMS_lumi.py)
    CMS_lumi.writeExtraText = 1
    CMS_lumi.extraText = "Preliminary"
    if year == 2018:
        CMS_lumi.extraText2 = "2018 pp data"
    if year == 2017:
        CMS_lumi.extraText2 = "2017 pp data"
    if year == 2016:
        CMS_lumi.extraText2 = "2016 pp data"
    CMS_lumi.lumi_sqrtS = "13 TeV"  # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
    CMS_lumi.writeTitle = 1
    CMS_lumi.textTitle = title

    iPos = 11
    if (iPos == 0): CMS_lumi.relPosX = 0.12

    H_ref = 600
    W_ref = 800
    W = W_ref
    H = H_ref

    iPeriod = 0
    # references for T, B, L, R
    T = 0.08 * H_ref
    B = 0.12 * H_ref
    L = 0.12 * W_ref
    R = 0.04 * W_ref

    c = TCanvas("c", "c", 50, 50, W, H)
    #gStyle.SetOptStat(0)
    c.SetFillColor(0)
    c.SetBorderMode(0)
    c.SetFrameFillStyle(0)
    c.SetFrameBorderMode(0)
    c.SetLeftMargin(L / W)
    c.SetRightMargin(R / W)
    c.SetTopMargin(T / H)
    c.SetBottomMargin(B / H)
    c.SetTickx(0)
    c.SetTicky(0)
    #canvassettings(c)

    mg = TMultiGraph()
    #mg  = grs['main']
    mg.SetTitle(title)
    #gStyle.SetTitleAlign(33)
    #gStyle.SetTitleX(0.99)
    leg = TLegend(
        0.345, 0.68, 0.645, 0.88
    )  #TLegend(1. - c.GetRightMargin() - 0.8, 1. - c.GetTopMargin() - 0.40,1. - c.GetRightMargin()- 0.60, 1. - c.GetTopMargin() -0.02)
    leg.SetFillStyle(0)
    leg.SetBorderSize(0)
    leg.SetMargin(0.1)
    #ymax = 0;
    ratesFromFit = {}
    evVal = 15000
    if doext:
        evVal = 50000

    #f=TFile.Open(outn+".root","RECREATE")


#  for name,value in plotoptions.iteritems():
    for name in sortk:
        if name != 'main': continue
        value = plotoptions[name]
        #print grs
        gr = grs[name]
        #print gr
        gr.SetName(title)
        #extrate = fitGraph(gr,evVal)
        #ratesFromFit[name] = extrate
        if doext:
            #print name, extrate[0], extrate[1]
            NN = gr.GetN()
            gr.Set(NN + 1)
            gr.SetPoint(NN + 1, 50000.0, extrate["rate"][0])
            yErr = extrate["rate"][1]
            if not ploterror:
                yErr = 0.0
            gr.SetPointError(NN + 1, 0.0, yErr)
        gr.SetMarkerColor(value['color'])
        gr.SetMarkerStyle(value['markst'])
        gr.SetLineColor(value['color'])
        gr.SetMarkerSize(1.15)  #1.05
        gr.SetMinimum(0.1)
        #gr.Write()
        mg.Add(gr)
        text = title  #name #+plotoptions[name]['leg']
        leg.AddEntry(gr, text, "p")
        continue

    mg.SetName(outn)
    mg.SetMinimum(0.1)
    mg.SetMaximum(ymax)  #1.6*ymax
    mg.Draw("AP")
    mg.GetXaxis().SetRangeUser(2000, 20000)
    c.Update()
    graphAxis(mg)

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)
    c.cd()
    c.Update()
    frame = c.GetFrame()
    frame.Draw()

    leg.Draw()
    c.SaveAs(outn + ".png")
    #c.SaveAs(outn+".C")
    del c

    return ratesFromFit
Пример #9
0
class PlotGraphs:
    def __init__(self,
                 data,
                 xlow,
                 xhigh,
                 ylow,
                 yhigh,
                 xlabel="",
                 ylabel="",
                 xLegend=.45,
                 yLegend=.60,
                 legendWidth=0.20,
                 legendHeight=0.45,
                 fillStyle=3395,
                 drawOption='APL3',
                 make_tfile=False):

        self.graph_index = {}
        self.ngraphs = 0

        self.data = data
        self.drawOption = drawOption
        self.xlow = xlow
        self.xhigh = xhigh
        self.ylow = ylow
        self.yhigh = yhigh
        self.xlabel = xlabel
        self.ylabel = ylabel
        self.multigraph = TMultiGraph("MultiGraph", "")
        self.legend_type = {}

        if make_tfile:
            self.tfile = TFile('tgraphs.root', 'recreate')

        self.legend = TLegend(xLegend, yLegend, xLegend + legendWidth,
                              yLegend + legendHeight)

        self.g_ = {}
        self.g2_ = {}
        self.g3_ = {}
        for cat in data.cat:
            if data.type[cat] == 'observed':
                #self.g_[cat] = TGraph(len(data.x[cat]), data.x[cat], data.y[cat])
                self.g_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat],
                                                 data.y[cat], data.exl[cat],
                                                 data.exh[cat], data.eyl[cat],
                                                 data.eyh[cat])
                self.g_[cat].SetName(cat)
                if make_tfile:
                    _gcopy = self.g_[cat].Clone()
                    self.tfile.Append(_gcopy)
                if data.dofit[cat]:
                    #self.g_[cat].Fit("pol3", "M", "", data.fit_min[cat], data.fit_max[cat])
                    f1 = TF1(
                        "f1",
                        "[0]+[1]*(x-1000.0)/1000.0+[2]*(x-1000.0)*(x-1000.0)/1000000.0+[3]*(x-1000.0)*(x-1000.0)*(x-1000.0)/1000000000.0",
                        data.fit_min[cat], data.fit_max[cat])
                    f2 = TF1(
                        "f2",
                        "[0]+[1]*(x-1000.0)/1000.0+[2]*(x-1000.0)*(x-1000.0)/1000000.0",
                        data.fit_min[cat], data.fit_max[cat])
                    f3 = TF1("f3", "[0]+[1]*(x-1000.0)/1000.0",
                             data.fit_min[cat], data.fit_max[cat])
                    _fr = self.g_[cat].Fit("f2", "MEWS", "", data.fit_min[cat],
                                           data.fit_max[cat])
                    _fr.Print()

            elif data.type[cat] == 'expected':
                self.g_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat],
                                                 data.y[cat], data.exl[cat],
                                                 data.exh[cat], data.eyl[cat],
                                                 data.eyh[cat])
                self.g2_[cat] = TGraphAsymmErrors(
                    len(data.x[cat]), data.x[cat], data.y[cat], data.exl2[cat],
                    data.exh2[cat], data.eyl2[cat], data.eyh2[cat])

                self.g3_[cat] = TGraphAsymmErrors(len(data.x[cat]),
                                                  data.x[cat], data.y[cat],
                                                  data.exl2[cat],
                                                  data.exh2[cat], data.y[cat],
                                                  data.exl2[cat])
                self.g3_[cat].SetFillStyle(1002)
                #self.g3_[cat].SetFillStyle(3008)

                # 95% quantile
                self.g2_[cat].SetMarkerColor(data.fill2_color[cat])
                self.g2_[cat].SetMarkerStyle(data.marker_style[cat])
                self.g2_[cat].SetMarkerSize(data.marker_size[cat])
                self.g2_[cat].SetLineColor(data.fill2_color[cat])
                self.g2_[cat].SetLineStyle(data.line_style[cat])
                self.g2_[cat].SetLineWidth(data.line_width[cat])
                #self.g2_[cat].SetFillColor(data.marker_color[cat]+2)
                self.g2_[cat].SetFillColor(data.fill2_color[cat])
                #self.g2_[cat].SetFillStyle(3008)
                #self.g2_[cat].SetFillStyle(3003)
                self.g2_[cat].SetFillStyle(data.fill2_style[cat])

            self.g_[cat].SetMarkerColor(data.marker_color[cat])
            self.g_[cat].SetMarkerStyle(data.marker_style[cat])
            self.g_[cat].SetMarkerSize(data.marker_size[cat])
            self.g_[cat].SetLineColor(data.line_color[cat])
            self.g_[cat].SetLineStyle(data.line_style[cat])
            self.g_[cat].SetLineWidth(data.line_width[cat])
            self.g_[cat].SetFillColor(data.fill_color[cat])
            if data.fill_style[cat] == None:
                self.g_[cat].SetFillStyle(fillStyle)
            else:
                self.g_[cat].SetFillStyle(data.fill_style[cat])

            if data.type[cat] == 'observed':
                # only the main observed limit is a line,
                # everything else is a filled area
                if cat[0:3] == 'obs':
                    _legend_type = 'lp'
                    if 'PC' in drawOption:
                        _draw_option = 'PC'
                    else:
                        _draw_option = 'PL'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                elif cat[0:3] == 'SSM':
                    _legend_type = 'lp'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                    # print theory curve
                    #self.g_[cat].Print()
                elif cat[0:3] == 'Psi':
                    _legend_type = 'lp'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                elif cat[0:3] == 'Stu':
                    _legend_type = 'lp'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                elif cat[0:2] == 'RS':
                    _legend_type = 'f'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                else:
                    _legend_type = 'f'
                    self.multigraph.Add(self.g_[cat])

                #self.multigraph.Add(self.g_[cat])
                self.graph_index[cat] = self.ngraphs
                self.ngraphs += 1

                #self.legend . AddEntry( self.g_[cat], data.tlegend[cat], _legend_type);
                self.legend_type[cat] = _legend_type

            elif data.type[cat] == 'expected':
                self.g3_[cat].SetFillColor(0)
                self.g3_[cat].SetMinimum(self.ylow)
                self.g3_[cat].SetMaximum(self.yhigh)
                self.g3_[cat].GetXaxis().SetLimits(self.xlow, self.xhigh)
                self.multigraph.Add(self.g3_[cat], 'C3')
                self.ngraphs += 1

                # 95 expected band
                self.multigraph.Add(self.g2_[cat], 'C4L')
                self.ngraphs += 1

                self.multigraph.Add(self.g_[cat], 'C4L')
                self.graph_index[cat] = self.ngraphs
                self.ngraphs += 1

                # median line
                gline = self.g_[cat].Clone()
                gline.SetLineWidth(3)
                gline.SetLineColor(ROOT.kBlue)
                gline.SetLineStyle(2)
                # median expected marker
                gline.SetMarkerStyle(8)
                gline.SetMarkerSize(1)
                # print graph contents
                #gline.Print()
                #self.multigraph.Add(gline, 'LXC')
                self.multigraph.Add(gline, 'C3X')

                self.ngraphs += 1

                # median expected legend
                #self.legend . AddEntry( gline, 'median expected', "l");
                self.legend_type[cat] = "l"
                _g = self.g_[cat]
                self.g_[cat] = gline

                # 68% expected band legend
                #self.legend . AddEntry( self.g_[cat], '68% expected', "f");
                self.legend_type[cat + '1sig'] = "f"
                self.g_[cat + '1sig'] = _g

                # 95% expected band legend
                #self.legend . AddEntry( self.g2_[cat], '95% expected', "f");
                self.legend_type[cat + '2sig'] = "f"
                self.g_[cat + '2sig'] = self.g2_[cat]

        keylist = data.legend_index.keys()  # keys are indices
        keylist.sort()
        for key in keylist:
            print key, data.legend_index[key]
            self.legend.AddEntry(self.g_[data.legend_index[key]],
                                 data.tlegend[data.legend_index[key]],
                                 self.legend_type[data.legend_index[key]])

        self.legend.SetShadowColor(0)
        self.legend.SetFillColor(0)
        self.legend.SetLineColor(0)

        if make_tfile:
            self.tfile.Write()
            self.tfile.Close()

    def draw(self, yLabelSize=0.055):

        self.multigraph.SetMinimum(self.ylow)
        self.multigraph.SetMaximum(self.yhigh)
        self.multigraph.Draw(self.drawOption)

        self.multigraph.GetXaxis().SetNdivisions(405)
        self.multigraph.GetYaxis().SetNdivisions(405)

        self.multigraph.GetXaxis().SetLimits(self.xlow, self.xhigh)
        #self.multigraph.GetYaxis().SetTitle("")

        self.multigraph.GetYaxis().SetLabelSize(yLabelSize)
        self.multigraph.GetXaxis().SetLabelSize(yLabelSize)

        latex = TLatex()
        latex.SetNDC()
        #latex.SetTextSize(0.04)
        latex.SetTextSize(yLabelSize)
        latex.SetTextAlign(31)  # align right

        latex.DrawLatex(0.95, 0.01, self.xlabel)

        latex.SetTextAngle(90)

        latex.DrawLatex(0.03, 0.9, self.ylabel)

        self.legend.SetFillStyle(0)
        self.legend.SetBorderSize(0)
        #self.legend.SetTextSize(0.04)
        #self.legend.SetTextSize(yLabelSize)
        self.legend.SetTextSize(yLabelSize * 0.7)
        self.legend.SetTextFont(42)
        self.legend.SetTextAlign(11)
        self.legend.Draw()

        return self.multigraph

    def draw_line(self, xline, ymin=-0.02, ymax=0.20):

        if xline == None:
            return

        #print 'XXXX', xline
        _x = array('d')
        _y = array('d')
        _x.append(xline)
        _y.append(ymin)
        _x.append(float(xline))
        _y.append(ymax)
        g_ = TGraph(len(_x), _x, _y)
        self.multigraph.Add(g_, 'L')

    def print_values(self, cat1, cat2):

        legend = 'PlotGraphs::print_values():'

        if cat1 in self.data.cat:
            graph1 = self.multigraph.GetListOfGraphs().At(
                self.graph_index[cat1])
        else:
            return None

        if cat2 in self.data.cat:
            graph2 = self.multigraph.GetListOfGraphs().At(
                self.graph_index[cat2])
        else:
            return None

        for x in range(750, 1150, 50):
            dmax = 0.0
            drelmax = 0.0
            v1 = graph1.Eval(x)
            v2 = graph2.Eval(x)
            d = math.fabs(v2 - v1)
            drel = math.fabs((v2 - v1) / v1)
            if d > dmax:
                dmax = d
            if drel > drelmax:
                drelmax = drel
            print legend, 'x =', x
            print legend, cat1, 'value =', v1
            print legend, cat2, 'value =', v2
            print legend, 'abs diff =', d
            print legend, 'abs relative diff =', drel

        print legend, 'max abs diff =', dmax
        print legend, 'max abs relative diff =', drelmax

    def find_intersection(self,
                          cat1,
                          cat2,
                          xmin=350,
                          xmax=3500,
                          precision=0.000000001):
        legend = 'PlotGraphs::find_intersection(%s,%s):' % (cat1, cat2)
        #always put "exp" or "obs" in cat1
        if cat1 is "exp" or cat1 is "obs":
            if cat1 in self.data.cat:
                graph1 = self.multigraph.GetListOfGraphs().At(
                    self.graph_index[cat1])
            else:
                print "Failed to get ", cat1
                return ["None"]
        else:
            print cat1, " is not obs/exp limit."
            return ["None"]
        if cat2 in self.data.cat:
            graph2 = self.multigraph.GetListOfGraphs().At(
                self.graph_index[cat2])
            #graph2.Print()
        else:
            print "Failed to get ", cat2
            return ["None"]

        _x = xmin

        print legend, graph1.Eval(_x) - graph2.Eval(_x)

        if graph1.Eval(_x) > graph2.Eval(_x):
            result = ["lowlimit"]
        else:
            result = []

        _interval = 1

        _sign1 = graph1.Eval(_x) > graph2.Eval(_x)
        while _x < xmax:
            _x += _interval
            _sign2 = graph1.Eval(_x) > graph2.Eval(_x)
            if _sign1 != _sign2:
                _d = 100000
                _step = -0.5 * _interval
                _crosspt = _x

                while abs(_d) > precision:

                    _crosspt += _step
                    _d = graph1.Eval(_crosspt) - graph2.Eval(_crosspt)
                    _sign2 = _d > 0
                    if _sign1 != _sign2:
                        _step = -0.5 * abs(_step)
                    else:
                        _step = 0.5 * abs(_step)
                _sign1 = not (_sign1)
                result.append(_crosspt)
        if result:
            print "Allowed region:",
            _x = 0
            while _x < len(result):
                if _x + 1 < len(result):
                    print "[", result[_x], ",", result[_x + 1], "];",
                else:
                    if _x + 1 == len(result):
                        print "[", result[_x], ", inf ];"
                if _x + 2 == len(result):
                    print
                _x += 2
        else:
            print "[", xmin, "~", xmax, "] is excluded."
        del graph1
        del graph2
        return result
Пример #10
0
theCanvas = TCanvas()

if (graphHolder.GetListOfGraphs().GetSize() == 1):
    graphHolder.SetTitle(
        "#omega vs. #eta_{i} (%s %s);#eta_{i};#omega(#eta_{i})" %
        (taggerType, originSuffix))
else:
    graphHolder.SetTitle(
        "#omega vs. #eta_{i} (%d data sets) (%s %s);#eta_{i};#omega(#eta_{i})"
        % (numP, taggerType, originSuffix))

graphHolder.Draw("ap")
graphHolder.GetXaxis().SetLimits(0.0, 0.5)
graphHolder.SetMinimum(0.0)
graphHolder.SetMaximum(0.5)
#graphHolder.Draw("ap")

graphHolder.GetYaxis().SetTitleSize(0.05)
graphHolder.GetXaxis().SetTitleSize(0.05)

leg = TLegend(0.1, 0.7, 0.4, 0.9)
#,"a f*****g header","tlNDC");
ROOT.SetOwnership(leg, False)
#leg.AddEntry(TObject(),"crap");

p0E = pDataSet.meanVar(pDataSet.get().find('p0Var')).getError()
p0V = pDataSet.meanVar(pDataSet.get().find('p0Var')).getValV()
p1E = pDataSet.meanVar(pDataSet.get().find('p1Var')).getError()
p1V = pDataSet.meanVar(pDataSet.get().find('p1Var')).getValV()
etaE = pDataSet.meanVar(pDataSet.get().find('etaAvgVar')).getError()
Пример #11
0
from mytools import *

f_bdt = TFile("scanbdtx.root")
f_bdtx = TFile("scanbdtxMuonOLR.root")

gr_bdt = f_bdt.Get("Graph")
gr_bdtx = f_bdtx.Get("Graph")

SetAtlasStyle()
gROOT.SetBatch(True)

c = createCanvas()
gr_bdt.SetLineColor(kBlue)
gr_bdtx.SetLineColor(kRed)
mg = TMultiGraph()
mg.Add(gr_bdt)
mg.Add(gr_bdtx)
mg.SetMaximum(2.0)
mg.Draw("ALP")
leg = TLegend(0.75, 0.70, 0.95, 0.80)
leg.SetFillStyle(0)
leg.SetBorderSize(0)
leg.AddEntry(gr_bdt, "w/o MuonOLR", "l")
leg.AddEntry(gr_bdtx, "w/ MuonOLR", "l")
leg.Draw("same")
mg.GetXaxis().SetTitle("> BDT score")
mg.GetYaxis().SetTitle("Z0")
createLabels()
myText(0.60, 0.85, kBlack, "t#bar{t}H vs. All bkg (MC)")
c.SaveAs("plots/bdtxvsMuonOLRbdtx.pdf")
Пример #12
0
    coutn += 1

gr1 = TGraph(n, xx, yy)
gr1.SetLineColor(1)
gr1.SetLineWidth(1)
gr1.SetLineStyle(3)
gr1.SetMarkerColor(1)
gr1.SetMarkerStyle(21)
##gr1.SetTitle( 'a simple graph' )
##gr1.GetXaxis().SetTitle( 'X title' )
##gr1.GetYaxis().SetTitle( 'Y title' )
#gr1.Draw( 'CP' )

mg.Add(gr)
mg.Add(gr1)
mg.SetMaximum(8.0)
mg.SetMinimum(-8.0)

#mg.GetXaxis().SetTitle("M_{WW} (GeV) CutOff Scale")
#mg.GetYaxis().SetTitle("FS0 (95% CL)")
mg.SetTitle(";M_{VV} cut-off scale (TeV);FS0 (#times 10^{-12} TeV^{-4})")

from ROOT import TPad, TH1F

pad1 = TPad("pad1", "pad1", 0.0, 0.0, 0.8, 1.0)
pad1.SetTopMargin(0.07)  # joins upper and lower plot
pad1.SetBottomMargin(0.13)  # joins upper and lower plot
pad1.SetLeftMargin(0.15)
pad1.SetRightMargin(0.0)
#pad1.SetLogy(1)
#pad1.SetGridx()
Пример #13
0
#histos["h_xi_acc_phase2_trident"].Draw("e1p")
#histos["h_xi_acc_jeti40_trident"].Draw("e1p same")
#histos["h_xi_acc_phase2_bppp"].Draw("e1p same")
#histos["h_xi_acc_jeti40_bppp"].Draw("e1p same")

g_jeti40_trident.SetMaximum(5e+4)
g_jeti40_trident.SetMinimum(5e-4)

mgr = TMultiGraph()
mgr.Add(g_jeti40_trident, "p0")
mgr.Add(g_phase2_trident, "p0")
mgr.Add(g_jeti40_bppp, "p0")
mgr.Add(g_phase2_bppp, "p0")
mgr.Draw("ap0")
mgr.SetMaximum(5e+4)
mgr.SetMinimum(5e-4)
mgr.GetXaxis().SetTitle(g_jeti40_trident.GetXaxis().GetTitle())
mgr.GetYaxis().SetTitle(g_jeti40_trident.GetYaxis().GetTitle())
mgr.GetXaxis().SetRangeUser(0., 6.1)

#g_jeti40_trident.Draw("AP0")
#g_phase2_trident.Draw("AC")
#g_jeti40_bppp.Draw("AC")
#g_phase2_bppp.Draw("AC")

leg_xi_trident.Draw("same")

LUXE(0.18, 0.85, ROOT.kBlack)

#s = TLatex()
Пример #14
0
def TwoFileSAME2VsLumi(F1graph1, F1graph2, F2graph1, F2graph2, title, type):
    canvas = makeCMSCanvas(str(random.random()),"canvas",900,700)
    canvas.cd()
    F1graph1.SetMarkerColor(kBlue)#electrons
    F1graph2.SetMarkerColor(kRed)#muons
    F2graph1.SetMarkerColor(kBlue)#electrons
    F2graph2.SetMarkerColor(kRed)#muons
    F2graph1.SetMarkerStyle(kOpenStar)
    F2graph2.SetMarkerStyle(kOpenStar)
    multigraph = TMultiGraph()
    multigraph.Add(F1graph1,"AP")
    multigraph.Add(F1graph2,"AP")
    multigraph.Add(F2graph1,"AP")
    multigraph.Add(F2graph2,"AP")
    multigraph.Draw("AP")
    multigraph.GetXaxis().SetLimits(0.,40.)
    #TGaxis.SetMaxDigits(2)
    #TGaxis.SetExponentOffset(-0.06, 0.02, "y")
    multigraph.GetXaxis().SetTitle("L [fb^{-1}]")
    multigraph.GetYaxis().SetTitleOffset(1.4)
    if(type == "ISO"):
        multigraph.GetYaxis().SetTitle("Isolation")
        gPad.Modified()
        multigraph.SetMinimum(0.5*gPad.GetUymin())
        multigraph.SetMaximum(1.5*gPad.GetUymax())
    elif(type == "SIP"):
        multigraph.GetYaxis().SetTitle("SIP")
    printLumiPrelOut(canvas)
    canvas.Update()
    down = gPad.GetUymin()
    up = gPad.GetUymax()
    lineB = TLine(5.57,down,5.57, up)
    lineB.SetLineColor(kBlack)
    lineB.SetLineStyle(2)
    lineB.Draw()
    lineC = TLine(8.58,down,8.58,up)
    lineC.SetLineColor(kBlack)
    lineC.SetLineStyle(2)
    lineC.Draw()
    lineD = TLine(12.9,down,12.9,up)
    lineD.SetLineColor(kBlack)
    lineD.SetLineStyle(2)
    lineD.Draw()
    lineE = TLine(16.57,down,16.57,up)
    lineE.SetLineColor(kBlack)
    lineE.SetLineStyle(2)
    lineE.Draw()
    lineF = TLine(19.7,down,19.7,up)
    lineF.SetLineColor(kBlack)
    lineF.SetLineStyle(2)
    lineF.Draw()
    lineG = TLine(26.9,down,26.9,up)
    lineG.SetLineColor(kBlack)
    lineG.SetLineStyle(2)
    lineG.Draw()
    legend = TLegend(0.80,0.75,0.965,0.93)
    legend.AddEntry(F1graph1,"e^{+}e^{-}","P")
    legend.AddEntry(F1graph2,"#mu^{+}#mu^{-}","P")
    legend.AddEntry(F2graph1,"e^{+}e^{-} ICHEP","P")
    legend.AddEntry(F2graph2,"#mu^{+}#mu^{-} ICHEP","P")
    legend.SetTextFont(32)
    legend.Draw()

    canvas.SaveAs(title + ".pdf")
    canvas.SaveAs(title + ".png")
    return;
Пример #15
0
def calc_punzi_FOM_vs_ctau(cutlist, labellist=[],mass_point=40,additional_string="",n_sigma=1,FOM='punzi'):
    file = {}
    nevt = {}
    tree = {}
    effs = {}
    chain = {}
    hist = {}
    eff_dict = { k:{} for k in cutlist}
    back_int = { k:{} for k in cutlist}
    back_int_weight = { k:{} for k in cutlist}
    back_eff = { k:{} for k in cutlist}
    punzi_dict = { k:{} for k in cutlist}
    graph = {}
    back_graph = {}
    ncuts = len(cutlist)
    if labellist == []:
        labellist=cutlist
    print NTUPLEDIR
    print "............."
    #prepare ctau ordered array for 1D plot                                                                
    mass_array = []
    ctau_array = []


    #for signal we have the normal efficiency                                                               
    for i, s in enumerate(sign):
        file[s] = TFile(NTUPLEDIR + samples[s]['files'][0] + ".root", "READ") # Read TFile                  
        tree[s] = file[s].Get("ntuple/tree") # Read TTree                                                   
        nevt[s] = (file[s].Get('counter/c_nEvents')).GetBinContent(1)# all gen events before cuts!
#        tree[s] = file[s].Get("skim") # TODO: add with global variable for skimmed tree 
#        nevt[s] = (file[s].Get('c_nEvents')).GetBinContent(1) # TODO: add with global variable for skimmed tree
        effs[s] = [0]*(ncuts+1)
        if samples[s]['mass'] not in mass_array: mass_array.append(samples[s]['mass'])
        if samples[s]['ctau'] not in ctau_array: ctau_array.append(samples[s]['ctau'])
        for j, c in enumerate(cutlist):
            tot_gen = nevt[s]
            n = tree[s].GetEntries("(" + cutlist[j] + ")")
            if tot_gen==0:
                effs[s][j] = float(0.)
            else:
                effs[s][j] = (float(n)/(tot_gen))
            eff_dict[c][s] = {'mass' : samples[s]['mass'], 'ctau' : samples[s]['ctau'], 'eff' :effs[s][j]}


    #sort mass array
    masses = np.array(mass_array)
    masses.sort()

    ctaus = np.array(ctau_array)
    ctaus.sort()


    #define multigraph
    mg = TMultiGraph()
    leg = TLegend(0.78, 0.7, 0.98, 0.98)
    leg2 = TLegend(0., 0.4, 0.98, 0.98)
    leg.SetTextSize(0.03)
    leg2.SetTextSize(0.03)
    leg.SetBorderSize(0)
    leg2.SetBorderSize(0)
    leg.SetHeader("m_{#pi}=" +str(mass_point)+" GeV")
    leg2.SetHeader("m_{#pi}=" +str(mass_point)+" GeV")

    #for background let's first consider the cut
    for j, c in enumerate(cutlist):
        print "cut: ", c
        #then loop over background
        integral = 0
        weighted_integral = 0
        back_tot_events = 0
        for i, s in enumerate(back):
            chain[s] = TChain("ntuple/tree")
#            chain[s] = TChain("skim") # TODO: add with global variable for skimmed tree
            #print "back: ", s
            back_file = {}
            for p, ss in enumerate(samples[s]['files']):
                back_file[ss] = TFile(NTUPLEDIR + ss + ".root", "READ") # Read TFile                  
                if verbose: print "file: ", ss
                if verbose: print "gen events: ", (back_file[ss].Get('counter/c_nEvents')).GetBinContent(1)
                if verbose: print "tree events: ", (back_file[ss].Get('ntuple/tree')).GetEntries()
                back_tot_events += (back_file[ss].Get('counter/c_nEvents')).GetBinContent(1)
#                back_tot_events += (back_file[ss].Get('c_nEvents')).GetBinContent(1) # TODO: add with global variable for skimmed tree
                chain[s].Add(NTUPLEDIR + ss + ".root")
            weight = "EventWeight"
            var = "nPV"
#            var = "nCHSJets" # TODO: add with global variable for skimmed tree
            hist[s] = TH1F(s, ";"+variable[var]['title'], variable[var]['nbins'], variable[var]['min'], variable[var]['max'])
            hist[s].Sumw2()
            cutstring = "("+weight+")" + ("*("+cutlist[j]+")" if len(cutlist[j])>0 else "")
            chain[s].Project(s, var, "")#"1*"+"("+weight+")")
            hist[s].SetOption("%s" % chain[s].GetTree().GetEntriesFast())
            if verbose: print "events in the histo with get entries with empty project: ", hist[s].GetEntries()
            if verbose: print "area under histo with empty project: ", hist[s].Integral()
            chain[s].Project(s, var, cutstring)#"1*"+"("+weight+")")
            hist[s].SetOption("%s" % chain[s].GetTree().GetEntriesFast())
            hist[s].Scale(samples[s]['weight'] if hist[s].Integral() >= 0 else 0)
            if verbose: print "events in the histo with get entries after project: ", hist[s].GetEntries()
            if verbose: print "area under histo after project: ", hist[s].Integral()
            integral += hist[s].GetEntries()
            weighted_integral += hist[s].Integral()
        back_int[c] = integral
        back_int_weight[c] = weighted_integral
        if back_tot_events==0:
            back_eff[c] = float(0.)
        else:
            back_eff[c] = float(integral)/float(back_tot_events)
        if verbose: print "cut: ", c
        if verbose: print "back tot events (unweighted):", back_tot_events
        if verbose: print "back integral (unweighted): ", back_int[c]
        if verbose: print "back integral (weighted): ", back_int_weight[c]
        if verbose: print "back eff (unweighted): ", back_eff[c]*100
        if FOM=="signaleff":
            punzi_dict[c]['back'] = {'back' : back_eff[c]*100}
        for i, s in enumerate(sign):
            if FOM=="punzi":
                punzi_dict[c][s] = {'sign': eff_dict[c][s]['eff']/(n_sigma*0.5 + math.sqrt(back_int_weight[c]))}
            elif FOM=="signaleff":
                punzi_dict[c][s] = {'sign': eff_dict[c][s]['eff']*100}
            else:
                print "not punzi FOM, aborting!"
                exit()



    #for each cut, we need a graph                                                                          
    for j, c in enumerate(cutlist):
    #first let's build the ordered punzi vector w.r.t. masses, for a chosen ctau                            
        punzi_array = []
        back_array = []
        for la in ctaus:
            #la = str(a)
            if la== 0.001:
                st = "VBFH_M"+str(mass_point)+"_ctau0"
            elif la==0.05 or la==0.1:
                st = "VBFH_M"+str(mass_point)+"_ctau"+str(str(la).replace("0.","0p"))
            else:
                st = "VBFH_M"+str(mass_point)+"_ctau"+str(int(la))
            #st = "VBFH_M"+str(mass_point)+"_ctau"+str(a)                                                        
            punzi_array.append(punzi_dict[c][st]['sign'])
        mass = array('d', masses)
        ct = array('d', ctaus)
        p_array = array('d',punzi_array)
        #graph[c] = TGraph(len(mass),mass, np.array(p_array))                                                   
        graph[c] = TGraph(len(ct),ct, np.array(p_array))
        graph[c].SetMarkerStyle(21)
        graph[c].SetLineWidth(2)
        graph[c].SetMarkerSize(1.)
        graph[c].SetMarkerColor(colors[j])
        graph[c].SetLineColor(colors[j])
        graph[c].SetFillColor(colors[j])
        #graph[c].SetLogx()                                                                                 
        leg.AddEntry(graph[c],labellist[j],'PL')
        leg2.AddEntry(graph[c],labellist[j],'PL')
        mg.Add(graph[c])

        if FOM=="signaleff":
        #add plot for background                                                                            
            for a in ctaus:
                back_array.append(punzi_dict[c]['back']['back'])
            mass = array('d', masses)
            ct = array('d', ctaus)
            e_array = array('d',back_array)
            #back_graph[c] = TGraph(len(mass),mass, np.array(e_array))
            back_graph[c] = TGraph(len(ct),ct, np.array(e_array))
            back_graph[c].SetMarkerStyle(0)
            back_graph[c].SetLineWidth(2)
            back_graph[c].SetMarkerSize(1.)
            back_graph[c].SetMarkerColor(colors[j])
            back_graph[c].SetLineColor(colors[j])
            back_graph[c].SetLineStyle(2)
            back_graph[c].SetFillColor(colors[j])
            #back_graph[c].SetLogx()                                                                        
            leg.AddEntry(back_graph[c],labellist[j]+" bkg.",'PL')
            #leg2.AddEntry(back_graph[c],labellist[j]+" bkg.",'PL')                                         
            mg.Add(back_graph[c])

    if FOM=="signaleff":
        dummy = TGraph(len(ct),ct, np.array(e_array))
        dummy.SetMarkerStyle(0)
        dummy.SetLineWidth(2)
        dummy.SetMarkerSize(1.)
        dummy.SetLineColor(15)
        dummy.SetLineStyle(2)
        leg2.AddEntry(dummy, 'cuts on bkg.','PL')


    cmg = TCanvas("cmg", "cmg", 2000, 800)
    cmg.cd()
    cmg.SetGrid()
    if FOM=="signaleff":
        cmg.SetLogx()
    pad1 = TPad("pad1", "pad1", 0, 0., 0.75, 1.0)
    pad1.SetGrid()
    pad1.SetLogx()
    if FOM=="signaleff":
        #print "LOL"
        pad1.SetLogy()
    pad1.Draw()
    pad1.cd()

    if FOM=="signaleff":
        mg.SetMaximum(101)
        #mg.SetMinimum(1.e-50)
    mg.Draw("APL")
    mg.GetXaxis().SetTitle('c#tau_{#pi} (mm)')
    mg.GetYaxis().SetTitleOffset(1.2);
    if FOM=="punzi":
        mg.GetYaxis().SetTitle('Punzi significance @ '+str(n_sigma)+' #sigma, VBF cuts')
        mg.GetYaxis().SetTitleOffset(1.5)
    elif FOM=="signaleff":
        mg.GetYaxis().SetTitle('Signal (background) efficiency, VBF cuts (%)')
    else:
        print "not punzi FOM, aborting"

    cmg.cd()
    pad2 = TPad("pad2", "pad2", 0.75, 0., 1, 1.0)
    pad2.SetGrid()
    pad2.SetLogx()
    pad2.Draw()
    pad2.cd()
    leg2.SetTextSize(0.07)
    leg.Clear()#?????????
    leg2.Draw()
    cmg.Update()

    if FOM=="punzi":
        cmg.Print("$CMSSW_BASE/src/Analyzer/LLP2018/macro/Efficiency/Punzi_m"+str(mass_point)+"_"+str(n_sigma)+"sigma"+additional_string+"_v0_pfXTag.pdf")
        cmg.Print("$CMSSW_BASE/src/Analyzer/LLP2018/macro/Efficiency/Punzi_m"+str(mass_point)+"_"+str(n_sigma)+"sigma"+additional_string+"_v0_pfXTag.png")
    elif FOM=="signaleff":
        cmg.Print("$CMSSW_BASE/src/Analyzer/LLP2018/macro/Efficiency/SignalEff_m"+str(mass_point)+additional_string+"_v0_pfXTag.pdf")
        cmg.Print("$CMSSW_BASE/src/Analyzer/LLP2018/macro/Efficiency/SignalEff_m"+str(mass_point)+additional_string+"_v0_pfXTag.png")
    else:
        print "not punzi FOM, aborting"

    if not options.bash: raw_input("Press Enter to continue...")
    cmg.Close()
Пример #16
0
def make_time_rod_evo(error_dict, rod_dict, results, doLock):
 
    c2 = TCanvas( 'c2', 'c2', 1000, 600)
    leg = TLegend(0.18,0.85,0.45,0.55)
    leg.SetLineColor(0)
    leg.SetFillStyle(0)
    leg.SetShadowColor(0)
    leg.SetBorderSize(0)
    leg.SetNColumns(2)
     
    R15 = TLine(431,0,431,60)
    R15.SetLineColorAlpha(kPink+10,0.4)
    R15.SetLineWidth(4)

    R16 = TLine(1820,0,1820,60)
    R16.SetLineColorAlpha(kMagenta+10,0.4)
    R16.SetLineWidth(4)

    R17 = TLine(3376,0,3376,60)
    R17.SetLineColorAlpha(kGreen-3,0.4)
    R17.SetLineWidth(4)


    TS1 = TLine(431,0,432,60)
    TS1.SetLineColorAlpha(kPink+10,0.5)
    TS1.SetLineWidth(5)

    TS2 = TLine(1415,0,1415,60)
    TS2.SetLineColorAlpha(kMagenta+3,0.5)
    TS2.SetLineWidth(5)

    leg2 = TLegend(0.18,0.45,0.35,0.55)
    leg2.SetLineColor(0)
    leg2.SetFillStyle(0)
    leg2.SetShadowColor(0)
    leg2.SetBorderSize(0)
    gStyle.SetLegendTextSize(0.030)

    leg2.AddEntry(R15, "End of 2015", 'lf')
    leg2.AddEntry(R16, "End of 2016", 'lf')
    leg2.AddEntry(R17, "End of 2017", 'lf')
    #leg2.AddEntry(TS2, "TS2", 'lf')


    for key,val in rod_dict.items(): 
        TS1.SetY2(val*0.5)
        TS2.SetY2(val+1)

        R15.SetY2(val*0.3)
        R16.SetY2(val*0.5)
        R17.SetY2(val*0.8)

        times = {}
        times.clear()
        for e in error_bits:
            times['0x'+e] = [0] 
        for error in results:
            pos_rod  = error.text.find("ROD") + 4
            pos_lock = error.text.find("Lock") + 15
            pos_buff = error.text.find("buffer") + 17

            if error.msgID == 'TRT::ROD05Module':
                rod  = '0x'+str(error.text[pos_rod:pos_rod+6])
            else:
                rod  = str(error.text[pos_rod:pos_rod+8])

            lock = str(error.text[pos_lock:pos_lock+3])
            buff = str(error.text[pos_buff:pos_buff+3])

            if key == rod and doLock and lock != '0xf':
                times[lock].append(error.sb_total_time)


        leg.Clear()
        mg = TMultiGraph()

        for e in error_bits:
            errs = []
            for i,x in enumerate(times['0x'+e]):
                errs.append(i+0.0)
            errs.append(errs[-1])
            #times['0x'+e].append(1800.0)
            times['0x'+e].append(results[-1].sb_total_time)
            gr = TGraph(len(times['0x'+e]), array(times['0x'+e]), array(errs))
            gr.SetMarkerSize(0.7)
            if bin(int('0x'+e, 16))[2:].zfill(4) == '0111':
                leg.AddEntry(gr,'GOL 3',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1011':
                leg.AddEntry(gr,'GOL 2',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1101':
                leg.AddEntry(gr,'GOL 1',"lp");
            elif bin(int('0x'+e, 16))[2:].zfill(4) == '1110':
                leg.AddEntry(gr,'GOL 0',"lp");
            else:
                leg.AddEntry(gr,bin(int('0x'+e, 16))[2:].zfill(4),"lp");
            mg.Add(gr,"pl");

        mg.SetTitle("; Hours of stable beams; # of rocketio io lock errors");
        mg.Draw("PMC PLC a");
        R15.Draw()
        R16.Draw()
        R17.Draw()
        #TS1.Draw()
        #TS2.Draw()
        
        AtlasStyle.ATLAS_LABEL(0.19,.88, 1, "Internal")
        leg.Draw()
        leg2.Draw()
        AtlasStyle.myText(0.4, 0.88, kBlack, "ROD: " + key)
        
        
        leg.SetMargin(0.5)
        gPad.Modified()
        mg.GetXaxis().SetLimits(0,results[-1].sb_total_time)
        mg.SetMinimum(0.)
        mg.SetMaximum(val+1)
        c2.Update()
        c2.Print("plots/time_"+key+".pdf")
        c2.Clear()
Пример #17
0
def main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-i", "--inputfile", dest="inputfile")
    parser.add_option("-m", "--model", dest="model", type="string")
    (options, args) = parser.parse_args()

    from ROOT import TFile, TMultiGraph, TCanvas, TLegend
    from Styles import formatXsecCL
    import configurations as config
    from ROOT import gStyle

    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadRightMargin(0.05)

    infile = TFile(options.inputfile, "READ")
    infile_xsec = TFile(config.bh_xsec, "READ")

    store = []
    for n in config.extraDim_list:
        c = TCanvas("%s-n%d" % (options.model,n),\
              "%s-n%d" % (options.model,n),\
              500, 500)
        store.append(c)

        graphs = TMultiGraph()
        store.append(graphs)

        legend = TLegend(0.5266129, 0.5360169, 0.9476613, 0.9364407)
        legend.SetTextSize(0.02966102)
        legend.SetFillColor(0)
        legend.SetLineColor(0)
        legend.SetHeader("n = %d" % n)
        store.append(legend)

        for i, MD in enumerate(config.MD_list):
            gCL95 = infile.Get("%s-MD%.1f_n%d-CL95" % (options.model, MD, n))
            gXsec = infile_xsec.Get("%s-MD%.1f_n%d" % (options.model, MD, n))

            if gCL95 and gXsec:
                legend.AddEntry(gCL95, "M_{D} = %.1f TeV Observed" % MD, "l")
                formatXsecCL(gCL95, i, 1)
                graphs.Add(gCL95, "l")

                legend.AddEntry(gXsec, "M_{D} = %.1f TeV Theoretical" % MD,
                                "l")
                formatXsecCL(gXsec, i, 2)
                graphs.Add(gXsec, "c")

        graphs.Draw("a")
        graphs.GetXaxis().SetTitle("M_{BH}^{ min} (TeV)")
        graphs.GetYaxis().SetTitle("#sigma (pb)")
        graphs.GetYaxis().SetTitleOffset(1.2)
        graphs.GetXaxis().SetRangeUser(4.5, 7.5)
        graphs.SetMinimum(1e-4)
        graphs.SetMaximum(1)
        c.SetLogy()
        legend.Draw("plain")
        c.Print("MassLimit_%s_n%d.pdf" % (options.model, n))
        c.Print("MassLimit_%s_n%d.png" % (options.model, n))
        c.Update()

    raw_input("Press Enter to continue...")
Пример #18
0
class PlotGraphs:
    def __init__(self, data,
                 xlow, xhigh, ylow, yhigh,
                 xlabel = "", ylabel = "",
                 xLegend = .45, yLegend = .60,
                 legendWidth = 0.20, legendHeight = 0.45,
                 fillStyle = 3395,
                 drawOption = 'APL3',
                 make_tfile = False):

        self.graph_index = {}
        self.ngraphs = 0

        self.data = data
        self.drawOption = drawOption
        self.xlow=xlow
        self.xhigh=xhigh
        self.ylow=ylow
        self.yhigh=yhigh
        self.xlabel = xlabel
        self.ylabel = ylabel
        self.multigraph=TMultiGraph("MultiGraph", "")
        self.legend_type = {}

        if make_tfile:
            self.tfile = TFile('tgraphs.root', 'recreate')

        self.legend = TLegend(xLegend, yLegend,
                              xLegend + legendWidth, yLegend + legendHeight)

        self.g_ = {}
        self.g2_ = {}
        self.g3_ = {}
        for cat in data.cat:
            if data.type[cat] == 'observed':
                #self.g_[cat] = TGraph(len(data.x[cat]), data.x[cat], data.y[cat])
                self.g_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat], data.y[cat], data.exl[cat], data.exh[cat], data.eyl[cat], data.eyh[cat])
                self.g_[cat].SetName(cat)
                if make_tfile:
                    _gcopy = self.g_[cat].Clone()
                    self.tfile.Append(_gcopy)
                if data.dofit[cat]:
                    #self.g_[cat].Fit("pol3", "M", "", data.fit_min[cat], data.fit_max[cat])
                    f1 = TF1("f1", "[0]+[1]*(x-1000.0)/1000.0+[2]*(x-1000.0)*(x-1000.0)/1000000.0+[3]*(x-1000.0)*(x-1000.0)*(x-1000.0)/1000000000.0", data.fit_min[cat], data.fit_max[cat])
                    f2 = TF1("f2", "[0]+[1]*(x-1000.0)/1000.0+[2]*(x-1000.0)*(x-1000.0)/1000000.0", data.fit_min[cat], data.fit_max[cat])
                    f3 = TF1("f3", "[0]+[1]*(x-1000.0)/1000.0", data.fit_min[cat], data.fit_max[cat])
                    _fr = self.g_[cat].Fit("f2", "MEWS", "", data.fit_min[cat], data.fit_max[cat])
                    _fr.Print()
                    
            elif data.type[cat] == 'expected':
                self.g_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat], data.y[cat], data.exl[cat], data.exh[cat], data.eyl[cat], data.eyh[cat])
                self.g2_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat], data.y[cat], data.exl2[cat], data.exh2[cat], data.eyl2[cat], data.eyh2[cat])

                self.g3_[cat] = TGraphAsymmErrors(len(data.x[cat]), data.x[cat], data.y[cat], data.exl2[cat], data.exh2[cat], data.y[cat], data.exl2[cat])
                self.g3_[cat].SetFillStyle(1002)
                #self.g3_[cat].SetFillStyle(3008)

                # 95% quantile 
                self.g2_[cat].SetMarkerColor(data.fill2_color[cat])
                self.g2_[cat].SetMarkerStyle(data.marker_style[cat])
                self.g2_[cat].SetMarkerSize(data.marker_size[cat])
                self.g2_[cat].SetLineColor(data.fill2_color[cat])
                self.g2_[cat].SetLineStyle(data.line_style[cat])
                self.g2_[cat].SetLineWidth(data.line_width[cat])
                #self.g2_[cat].SetFillColor(data.marker_color[cat]+2)
                self.g2_[cat].SetFillColor(data.fill2_color[cat])
                #self.g2_[cat].SetFillStyle(3008)
                #self.g2_[cat].SetFillStyle(3003)
                self.g2_[cat].SetFillStyle(data.fill2_style[cat])

                
            self.g_[cat].SetMarkerColor(data.marker_color[cat])
            self.g_[cat].SetMarkerStyle(data.marker_style[cat])
            self.g_[cat].SetMarkerSize(data.marker_size[cat])
            self.g_[cat].SetLineColor(data.line_color[cat])
            self.g_[cat].SetLineStyle(data.line_style[cat])
            self.g_[cat].SetLineWidth(data.line_width[cat])
            self.g_[cat].SetFillColor(data.fill_color[cat])
            if data.fill_style[cat] == None:
                self.g_[cat].SetFillStyle(fillStyle)
            else:
                self.g_[cat].SetFillStyle(data.fill_style[cat])

            if data.type[cat] == 'observed':
                # only the main observed limit is a line,
                # everything else is a filled area
                if cat[0:3] == 'obs':
                    _legend_type = 'lp'
                    if 'PC' in drawOption:
                        _draw_option = 'PC'
                    else:
                        _draw_option = 'PL'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                elif cat[0:3] == 'SSM':
                    _legend_type = 'lp'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                    # print theory curve
                    #self.g_[cat].Print()
                elif cat[0:3] == 'Psi':
                    _legend_type = 'lp'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                elif cat[0:2] == 'RS':
                    _legend_type = 'f'
                    _draw_option = '3'
                    self.multigraph.Add(self.g_[cat], _draw_option)
                else:
                    _legend_type = 'f'
                    self.multigraph.Add(self.g_[cat])

                #self.multigraph.Add(self.g_[cat])
                self.graph_index[cat] = self.ngraphs
                self.ngraphs += 1

                #self.legend . AddEntry( self.g_[cat], data.tlegend[cat], _legend_type);
                self.legend_type[cat] = _legend_type
                
            elif data.type[cat] == 'expected':
                self.g3_[cat].SetFillColor(0)
                self.g3_[cat].SetMinimum(self.ylow)
                self.g3_[cat].SetMaximum(self.yhigh)
                self.g3_[cat].GetXaxis().SetLimits(self.xlow, self.xhigh)
                self.multigraph.Add(self.g3_[cat], 'C3')
                self.ngraphs += 1

                # 95 expected band
                self.multigraph.Add(self.g2_[cat])
                self.ngraphs += 1

                self.multigraph.Add(self.g_[cat], 'C3L')
                self.graph_index[cat] = self.ngraphs
                self.ngraphs += 1

                # median line
                gline = self.g_[cat].Clone()
                gline.SetLineWidth(3)
                gline.SetLineColor(ROOT.kBlue)
                gline.SetLineStyle(2)
                # print graph contents
                #gline.Print()
                #self.multigraph.Add(gline, 'LXC')
                self.multigraph.Add(gline, 'C3X')
                self.legend . AddEntry( gline, 'median expected', "l");
                self.ngraphs += 1

                #self.legend . AddEntry( self.g_[cat], data.tlegend[cat], "f");
                self.legend . AddEntry( self.g_[cat], '68% expected', "f");

                # 95% expected band legend
                self.legend . AddEntry( self.g2_[cat], '95% expected', "f");


        keylist = data.legend_index.keys() # keys are indices
        keylist.sort()
        for key in keylist:
            self.legend . AddEntry( self.g_[data.legend_index[key]],
                                    data.tlegend[data.legend_index[key]],
                                    self.legend_type[data.legend_index[key]]);

        self.legend . SetShadowColor(0)
        self.legend . SetFillColor(0)
        self.legend . SetLineColor(0)

        if make_tfile:
            self.tfile.Write()
            self.tfile.Close()



    def draw(self, yLabelSize = 0.045):

        self.multigraph.SetMinimum(self.ylow)
        self.multigraph.SetMaximum(self.yhigh)
        self.multigraph . Draw(self.drawOption)

        self.multigraph.GetXaxis().SetNdivisions(405)
        self.multigraph.GetYaxis().SetNdivisions(405)

        self.multigraph.GetXaxis().SetLimits(self.xlow, self.xhigh)
        #self.multigraph.GetYaxis().SetTitle("")

        #self.multigraph.GetYaxis().SetLabelSize(yLabelSize)
        #self.multigraph.GetXaxis().SetLabelSize(yLabelSize)

        # axis labels
        #latex = TLatex()
        #latex.SetNDC()
        ##latex.SetTextSize(0.04)
        #latex.SetTextSize(yLabelSize)
        #latex.SetTextAlign(31) # align right
        #latex.DrawLatex(0.95,0.01, self.xlabel)
        #latex.SetTextAngle(90)
        #latex.DrawLatex(0.04,0.95, self.ylabel)
        XLabel(self.xlabel, 0.95, 0.03, text_size = 0.07)
        YLabel(self.ylabel, 0.04,0.9, text_size = 0.07)

        self.legend.SetFillStyle(0)
        self.legend.SetBorderSize(0)
        #self.legend.SetTextSize(0.04)
        self.legend.SetTextSize(yLabelSize)
        self.legend.SetTextFont(22)
        self.legend . Draw()

        return self.multigraph


    def draw_line(self, xline, ymin = -0.02, ymax = 0.20):

        if xline == None:
            return
        
        #print 'XXXX', xline
        _x = array('d')
        _y = array('d')
        _x.append(xline)
        _y.append(ymin)
        _x.append(float(xline))
        _y.append(ymax)
        g_ = TGraph(len(_x), _x, _y)
        self.multigraph.Add(g_, 'L')



    def print_values(self, cat1, cat2):

        legend = 'PlotGraphs::print_values():'

        if cat1 in self.data.cat:
            graph1 = self.multigraph.GetListOfGraphs().At(self.graph_index[cat1])
        else:
            return None

        if cat2 in self.data.cat:
            graph2 = self.multigraph.GetListOfGraphs().At(self.graph_index[cat2])
        else:
            return None

        for x in range (750, 1150, 50):
            dmax = 0.0
            drelmax = 0.0
            v1 = graph1.Eval(x)
            v2 = graph2.Eval(x)
            d = math.fabs(v2-v1)
            drel = math.fabs((v2-v1)/v1)
            if d>dmax:
                dmax = d
            if drel>drelmax:
                drelmax = drel
            print legend, 'x =', x
            print legend, cat1, 'value =', v1
            print legend, cat2, 'value =', v2
            print legend, 'abs diff =', d
            print legend, 'abs relative diff =', drel
            
        print legend, 'max abs diff =', dmax
        print legend, 'max abs relative diff =', drelmax


    def find_intersection(self, cat1, cat2,
                          xmin = 250, xmax = 2500,
                          precision = 0.00001):

        legend = 'PlotGraphs::find_intersection():'

        if cat1 in self.data.cat:
            graph1 = self.multigraph.GetListOfGraphs().At(self.graph_index[cat1])
        else:
            return None

        if cat2 in self.data.cat:
            graph2 = self.multigraph.GetListOfGraphs().At(self.graph_index[cat2])
            #graph2.Print()
        else:
            return None

        _x = xmin

        print legend, graph1.Eval(_x) - graph2.Eval(_x)

        _d = graph1.Eval(_x) - graph2.Eval(_x)
        _step = xmax - xmin

        
        while abs(_d) > precision:
            
            _x += _step

            if _x > xmax or _x < xmin:
                return None
            
            _d2 = graph1.Eval(_x) - graph2.Eval(_x)

            _sign1 = _d > 0
            _sign2 = _d2 > 0

            if _sign1 != _sign2:
                _step = -0.5*_step

            _d = _d2

            if abs(_d2) < precision:

                return _x
Пример #19
0
def draw_syst_unc_envelope(unc_type, added):
    print "Drawing uncertainty vs mass"
    with open(OUT + "signal_" + unc_type + "_unc" + added + ".yaml", "r") as f:
        results = yaml.load(f, Loader=yaml.Loader)
        f.close()
    samp = results.keys()
    masses = []
    ctaus = []
    for s in samp:
        masses.append(samples[s]['mass'])
        ctaus.append(samples[s]['ctau'])
    masses = np.unique(np.sort(np.array(masses)))
    ctaus = np.unique(np.sort(np.array(ctaus)))
    print masses
    print ctaus

    mg = TMultiGraph()
    leg1 = TLegend(0.6, 0.2, 0.9, 0.5)
    #leg1 = TLegend(0.15+0.5, 0.6+0.2, 0.3+0.5, 0.9)
    colors = [2, 418, 801, 856, 602, 920, 881]
    diff_up = {}
    diff_down = {}
    count_c = 0
    print "$c \\tau$ (m) & $m_{\chi}$ (GeV) & uncertainty (\%)" + "\\" + "\\"
    for m in masses:
        string = ""
        nt = 0
        for c in ctaus:
            for s in samp:
                if "mh" + str(m) + "_ctau" + str(c) in s:
                    string += str(c / 1000.) + " & " + str(m) + " & " + str(
                        "%.1f" % results[s]['diff_y2_up'])
                    if nt == 0: string += " & "
            nt += 1
        print string + "\\" + "\\"

    for c in ctaus:
        diff_up[c] = TGraph()
        n = 0
        for m in masses:
            for s in samp:
                if "mh" + str(m) + "_ctau" + str(c) in s:
                    diff_up[c].SetPoint(n, m, results[s]['diff_y2_up'])
                    n += 1
        diff_up[c].SetMarkerStyle(24)
        diff_up[c].SetMarkerColor(colors[count_c])
        diff_up[c].SetLineColor(colors[count_c])
        diff_up[c].SetLineWidth(2)
        diff_up[c].GetXaxis().SetTitle("m_{#chi} (GeV)")
        diff_up[c].GetYaxis().SetTitle("Uncertainty (%)")
        diff_up[c].GetYaxis().SetTitleSize(0.05)
        diff_up[c].SetMinimum(0)
        if unc_type == "PDF":
            leg1.AddEntry(diff_up[c],
                          "c_{#tau} = " + str(c / 1000.) + " m; PDF envelope",
                          "PL")
        if unc_type == "QCD_scales":
            leg1.AddEntry(
                diff_up[c],
                "c_{#tau} = " + str(c / 1000.) + " m; QCD scales envelope",
                "PL")
        mg.Add(diff_up[c])
        count_c += 1

    c1 = TCanvas("c1", "c1", 800, 600)
    c1.SetGrid()
    c1.SetTopMargin(0.06)
    c1.SetBottomMargin(0.12)
    c1.SetRightMargin(0.05)
    c1.SetLeftMargin(0.12)
    c1.SetTicks(1, 1)
    mg.GetXaxis().SetTitle("m_{#chi} (GeV)")
    mg.GetYaxis().SetTitle("Uncertainty (%)")
    mg.GetXaxis().SetTitleSize(0.05)
    mg.GetYaxis().SetTitleSize(0.05)
    mg.SetMinimum(0.)
    mg.SetMaximum(16.)
    mg.Draw("APL")
    leg1.Draw()
    drawCMS_simple(LUMI, "Preliminary", ERA=ERA, onTop=True)
    #drawAnalysis("LL"+CHAN)
    drawRegion(SEL)
    #c1.SetLogx()
    c1.Print(OUT + "signal_" + unc_type + "_uncertainty" + added + ".pdf")
    c1.Print(OUT + "signal_" + unc_type + "_uncertainty" + added + ".png")
    c1.Close()
Пример #20
0
def Draw_2D_Comp(rootfile_name,
                 var_x,
                 var_y,
                 min,
                 max,
                 WP_list,
                 leg,
                 isTgraph=False):
    gStyle.SetErrorX(0.5)

    ## Creating a multigraph for the canvas if we are looking at TGraphs
    if isTgraph:
        stack = TMultiGraph()
        args = "AP"

    ## Creating a stack for the canvas if we are looking at TPofiles
    else:
        stack = THStack("stack", var_x.name + var_y.name)
        args = "nostack "

    stack.SetMinimum(min)
    stack.SetMaximum(max)

    for wp in WP_list:

        ## Generating the graph name
        graph_name = "{}_vs_{}_{}".format(var_x.name, var_y.name, wp.name)
        if isTgraph:
            graph_name += "_res"

        ## Loading the graph using its name and file location
        graph = GetGraphFromFile(rootfile_name, graph_name)
        if graph == -1:
            continue

        ## Setting the colors specific to the working point
        graph.SetLineColor(wp.colour)
        graph.SetMarkerColor(wp.colour)
        graph.SetMarkerStyle(wp.marker)

        ## Adding the legend entry
        leg.AddEntry(graph, wp.name, "p")

        ## Adding the object to the stack
        stack.Add(graph)
        del graph

    ## Checking to see if any graphs were found for this variable
    nhists = stack.GetListOfGraphs().GetSize(
    ) if isTgraph else stack.GetNhists()
    if nhists == 0:
        print("\n\n\nNo graphs found for working point {}\n\n\n".format(
            wp.name))
        return -1

    ## Drawing the stack on the currrent canvas
    stack.Draw(args)
    leg.Draw()

    ## Setting axis labels
    stack.GetXaxis().SetTitle(var_x.x_label + " " + var_x.units)
    stack.GetYaxis().SetTitle(var_y.x_label + " " + var_y.units)

    ## Moving axis tick marks
    stack.GetYaxis().SetMaxDigits(3)
    stack.GetXaxis().SetLabelOffset(0.017)

    return stack
Пример #21
0
def combinedDraw(frescoGraph, goodPID, badPID, goodCORR, badCORR):
    #print "combinedDraw start"
    canvas = TCanvas('canvas', 'shouldnotseethis', 0, 0, 1280, 720)

    MG = TMultiGraph()
    legend = ROOT.TLegend(0.55, .55, .9, .9)
    ##legend.SetBorderSize(0)
    #underHisto.SetLineColor(ROOT.kBlack)
    #underHisto.SetMinimum(0)
    ##underHisto.SetMaximum(underHisto.GetMaximum() * 1.5)
    #underHisto.GetXaxis().SetRangeUser(0,180)
    #underHisto.SetTitle(title)
    #underHisto.SetLineColor(ROOT.kBlack)
    #underHisto.SetTitle(title)
    #underHisto.GetYaxis().SetTitle("Counts in Arb. Units")
    #legend.AddEntry(underHisto,"Simulated Angular Distribution")
    #underHisto.SetStats(ROOT.kFALSE)
    #underHisto.Draw()

    if frescoGraph:
        #print "frescoGraph"
        frescoGraph.SetMarkerColor(ROOT.kBlack)
        frescoGraph.SetLineColor(ROOT.kBlack)
        frescoGraph.SetFillColor(ROOT.kBlack)
        #frescoGraph.SetMarkerStyle(33)
        MG.Add(frescoGraph, "L")
        legend.AddEntry(frescoGraph, "Fresco Output")
    else:
        print "No FrescoGraph!!!"
        return

    if goodPID:
        #print "goodPID"
        goodPID.SetMarkerColor(ROOT.kGreen)
        goodPID.SetLineColor(ROOT.kGreen)
        goodPID.SetFillColor(ROOT.kGreen)
        #goodPID.SetMarkerStyle(33)
        MG.Add(goodPID, "P")
        legend.AddEntry(goodPID, "ScaledPID")
    else:
        print "No goodPID in Draw()"

    if goodCORR:
        #print "goodCORR"
        goodCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetLineColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetFillColor(TColor.GetColorDark(ROOT.kGreen))
        goodCORR.SetMarkerStyle(21)
        #afterHisto.Draw("PLsame")
        MG.Add(goodCORR, "P")
        legend.AddEntry(goodCORR, "Good Dual Det")
    else:
        print "No goodCORR in Draw()"

    if badPID:
        #print "badPID"
        badPID.SetMarkerColor(ROOT.kRed)
        badPID.SetLineColor(ROOT.kRed)
        badPID.SetFillColor(ROOT.kRed)
        badPID.SetMarkerStyle(33)
        MG.Add(badPID, "P")
        legend.AddEntry(badPID, "Discard PID")
    else:
        print "No badPID in Draw()"

    if badCORR:
        #print "badCORR"
        badCORR.SetMarkerColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetLineColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetFillColor(TColor.GetColorDark(ROOT.kRed))
        badCORR.SetMarkerStyle(21)
        MG.Add(badCORR, "P")
        legend.AddEntry(badCORR, "Discard Dual Det")
    else:
        print "No badCORR in Draw()"

    MG.SetTitle(
        "Scaled Elastic Distribution for detector {};Center of Mass Angle in Degrees;Cross section in mb/sr"
        .format(det))
    MG.SetName("MG_d{}".format(det))
    MG.Draw("AP")
    legend.Draw()
    MG.Write()
    MG.SetMaximum(500)
    MG.SetMinimum(0)

    canvas.SetLogy()
    #MG.GetYaxis().SetRangeUser(0,500)

    MG.Draw()
    canvas.SaveAs(MG.GetName() + '.png')