Exemple #1
0
        hNum = RebinHist(htmp, theBins, False)
        # print theBins

        intNum = hNum.Integral()
        intDen = hDen.Integral()
        hNum.Scale(intDen / intNum)

        hRat = hNum.Clone()
        hRat.SetName("Ratio")
        hRat.Divide(hNum, hDen, 1., 1., "")
        Hlist = TObjArray()
        Hlist.Add(hRat)

        cname = "pT"
        c1 = prepPlot("c1", cname, 300, 20, 500, 500)
        c1.SetLogy(False)

        # i1=90; i2=110
        i1 = 0
        i2 = 500
        hNum.GetXaxis().SetRange(i1, i2)
        hDen.SetLineColor(ROOT.kRed)
        hNum.Draw()
        hDen.Draw("same")

        c1.Update()
        cname = "Ratio"
        c2 = prepPlot("c2", cname, 750, 120, 500, 500)
        c2.SetLogy(0)
Exemple #2
0
    SetStyle()

    #===============================================================

    x, y, ex, ey = array('d'), array('d'), array('d'), array('d')

    for ptBin in ptBins:

        ptmin = ptBin[0]
        ptmax = ptBin[1]
        pt = (ptmax + ptmin) / 2.
        x.append(pt)
        ex.append(0)
        ey.append(0.1)

    c1 = prepPlot("c0", "c0", 700, 20, 500, 500)
    c1.SetLogy(False)

    y.append(1.08)
    y.append(1.1)
    y.append(1.15)
    y.append(1.2)
    y.append(1.2)
    y.append(1.22)
    y.append(1.22)

    n = len(x)
    gr0 = TGraphErrors(n, x, y, ex, ey)

    gr0.SetMarkerColor(ROOT.kBlue)
    gr0.SetMarkerStyle(20)
Exemple #3
0
def drawIt(h1,h2,h3,ptmin,ptmax):

    scl1=h1.Integral();
    scl2=h2.Integral();
    scl3=h3.Integral();
    if scl1>0: h1.Scale(1./scl1)
    if scl2>0: h2.Scale(1./scl2)
    if scl3>0: h3.Scale(1./scl3)

    ## h1.SetMinimum(1.1e-6)
    
    SetHistColorAndMarker(h1,ROOT.kBlue,20)
    SetHistColorAndMarker(h2,ROOT.kRed,20)
    SetHistColorAndMarker(h3,ROOT.kMagenta,20)

    h1.GetXaxis().SetTitle("Response")
    h1.SetMinimum(2.e-6)
    fName="GFit"
    fitfunc="gaus"
    h1fit = TF1(fName,fitfunc,1.,1.5);
    h1fit.SetParameter(0, 1)
    h1fit.SetParameter(1, 1)
    h1fit.SetParameter(2, .1)

    h2fit=h1fit.Clone()
    h3fit=h1fit.Clone()

    h1fit.SetLineColor(h1.GetLineColor())
    h2fit.SetLineColor(h2.GetLineColor())
    h3fit.SetLineColor(h3.GetLineColor())

    c1 = prepPlot("c0","c0",700,20,500,500)
    c1.SetLogy(1)
    
    h1.Draw()
    h2.Draw("same")
    ## h3.Scale(0.8)
    h3.Draw("same")

    h1.Fit(h1fit,"0R");    
    # h1fit.Draw("sames")
    h2.Fit(h2fit,"0R");    
    # h2fit.Draw("sames")
    h3.Fit(h3fit,"0R");    
    # h3fit.Draw("sames")

    
    print "XXX: ",h1.GetTitle(), h2.GetTitle()
    label=h1.GetTitle()

    ## h1overFlow=(h1.GetBinContent(h1.GetNbinsX()+1)/h1.Integral(1,h1.GetNbinsX()+1)) * 100
    ## h2overFlow=(h2.GetBinContent(h2.GetNbinsX()+1)/h2.Integral(1,h2.GetNbinsX()+1)) * 100
    ## h3overFlow=(h3.GetBinContent(h3.GetNbinsX()+1)/h3.Integral(1,h2.GetNbinsX()+1)) * 100
    ## # print h1overFlow,h2overFlow,h3overFlow
    ## # print h1.GetEntries(),h2.GetEntries(),h3.GetEntries()
    ## 
    ## # print h1.GetEntries(),h1.Integral(),h1.Integral(1,h1.GetNbinsX()),h1.Integral(1,h1.GetNbinsX()+1)
    ## # print h2.GetEntries(),h2.Integral(),h2.Integral(1,h2.GetNbinsX()),h2.Integral(1,h2.GetNbinsX()+1)
    ## # print h2.Integral(1,h2.GetNbinsX()+1) -h2.Integral(1,h2.GetNbinsX())
    ## 
    ## print "Reco underflows/overflows: ",h1.GetBinContent(h1.GetNbinsX()+1),h1overFlow
    ## print "CB underflows/overflows: ",  h2.GetBinContent(h2.GetNbinsX()+1),h2overFlow
    ## print "GS underflows/overflows: ",  h3.GetBinContent(h3.GetNbinsX()+1),h3overFlow
    ## print

    xl1=.15; yl1=0.75; xl2=xl1+.28; yl2=yl1+.15;
    leg =TLegend(xl1,yl1,xl2,yl2);
    leg.SetFillColor(0);
    leg.SetLineColor(0);
    leg.SetShadowColor(0);
    leg.SetTextSize(0.038)
    
    leg.AddEntry(h1,"Full Sim","lp");
    leg.AddEntry(h2,"Crystal Ball","lp");
    leg.AddEntry(h3,"Gaussian","lp");

    leg.Draw()
    
    t1 = TLatex();
    t1.SetNDC();
    txtsize=0.038;  t1.SetTextSize(txtsize); t1.SetTextAlign(22);

    if ymin == -ymax:
        leglabel2="|y| < " + str(ymax)
    else:
        leglabel2= str(ymin) + " < y < " + str(ymax)
    xtxt=.785; ytxt=.885;
    t1.DrawLatex(xtxt,ytxt,label);
    t1.DrawLatex(xtxt,ytxt-0.06,leglabel2);

    c1.Modified()    
    c1.Update()
    
    if SavePlots:
        outfile="SmearedResponse_" + str(int(ptmin)) + "pT" + str(int(ptmax))
        if wExtraSmearing:
            outfile=outfile + "_wExtraSmearing"
        outfile=outfile + ".pdf"
        c1.Print(outfile)
    
    return
Exemple #4
0
    hDen = f2.Get(hname)

    norm1=hNum.Integral();
    norm2=hDen.Integral();
    print norm1, norm2

    hNum.Scale(1./norm1)
    hDen.Scale(1./norm2)
    hRat= hNum.Clone()
    hRat.SetName("Ratio")
    hRat.Divide(hNum,hDen,1.,1.,"");
    Hlist=TObjArray()
    Hlist.Add(hRat);

    cname="pT"
    c1 = prepPlot("c1",cname,300,20,500,500)
    c1.SetLogy(0);    

    # i1=90; i2=110
    # i1=0; i2=500
    # hNum.GetXaxis().SetRange(i1,i2)
    hDen.SetLineColor(ROOT.kRed)
    hNum.SetMaximum(.11)
    hNum.Draw()
    hDen.Draw("same")

    cname="Ratio"
    c2 = prepPlot("c2",cname,750,120,500,500)
    c2.SetLogy(0);    

    min=0.; max=1.24
Exemple #5
0
    SetStyle()

    # ===============================================================

    x, y, ex, ey = array("d"), array("d"), array("d"), array("d")

    for ptBin in ptBins:

        ptmin = ptBin[0]
        ptmax = ptBin[1]
        pt = (ptmax + ptmin) / 2.0
        x.append(pt)
        ex.append(0)
        ey.append(0.1)

    c1 = prepPlot("c0", "c0", 700, 20, 500, 500)
    c1.SetLogy(False)

    y.append(1.08)
    y.append(1.1)
    y.append(1.15)
    y.append(1.2)
    y.append(1.2)
    y.append(1.22)
    y.append(1.22)

    n = len(x)
    gr0 = TGraphErrors(n, x, y, ex, ey)

    gr0.SetMarkerColor(ROOT.kBlue)
    gr0.SetMarkerStyle(20)
Exemple #6
0
def CompGT(Triggers,TriggerSet):


    runid="240923"
    HistFile1="Histograms_CompStage1_Any_"+runid+".root"

    f1 = TFile(HistFile1)
    f1.ls()

    hname="compStage1/hL1_1"
    hLegOrg    = f1.Get(hname)
    hname="compStage1/hL1_2"
    hStage1Org = f1.Get(hname)

    nlumi=129
    hLegOrg.Scale((nlumi*23.3));
    hStage1Org.Scale((nlumi*23.3));

    hLegOrg.Sumw2()
    hStage1Org.Sumw2()

    nchan=len(Triggers)
    
    hLegacy    = TH1F( 'hLegacy','EG Trigger Rates -- Legacy', nchan, 0, float(nchan) )
    hS1Emu     = TH1F( 'hS1Emu','EG Trigger Rates -- Stage1 Emulator', nchan, 0, float(nchan) )
    hStage1    = TH1F( 'hStage1','EG Trigger Rates -- Stage1', nchan, 0, float(nchan) )
    hLegEmu    = TH1F( 'hLegEmu','EG Trigger Rates -- Legacy Emulator', nchan, 0, float(nchan) )
    hLegacy.Sumw2()
    hS1Emu.Sumw2()
    hStage1.Sumw2()
    hLegEmu.Sumw2()
    
    ibin=-1
    for trig in Triggers:
        print trig
        ibin+=1
        hLegacy.GetXaxis().SetBinLabel(ibin+1,trig)
        ## hS1Emu.GetXaxis().SetBinLabel(ibin+1,trig)
        hStage1.GetXaxis().SetBinLabel(ibin+1,trig)
        ## hLegEmu.GetXaxis().SetBinLabel(ibin+1,trig)

        theBin=hLegOrg.GetXaxis().FindBin(trig)
        rate=hLegOrg.GetBinContent(theBin)
        err=hLegOrg.GetBinError(theBin)

        print "Legacy:  ",trig,theBin,rate,err
        # print rate,err
        hLegacy.SetBinContent(ibin+1,rate)
        hLegacy.SetBinError(ibin+1,err)

        ## theBin=hS1EmuOrg.GetXaxis().FindBin(trig)
        ## rate=hS1EmuOrg.GetBinContent(theBin)
        ## err=hS1EmuOrg.GetBinError(theBin)
        ## print "S1 Emu:  ",trig,theBin,rate,err
        ## # if trigName == "L1_SingleJet16":
        ## #    rate=rate*10
        ## #    err=err*10
        ## # print rate,err
        ## hS1Emu.SetBinContent(ibin+1,rate)
        ## hS1Emu.SetBinError(ibin+1,err)

        theBin=hStage1Org.GetXaxis().FindBin(trig)
        rate=hStage1Org.GetBinContent(theBin)
        err=hStage1Org.GetBinError(theBin)
        print "Stage1:  ",trig,theBin,rate,err

        hStage1.SetBinContent(ibin+1,rate)
        hStage1.SetBinError(ibin+1,err)

        ## theBin=hLegEmuOrg.GetXaxis().FindBin(trig)
        ## rate=hLegEmuOrg.GetBinContent(theBin)
        ## err=hLegEmuOrg.GetBinError(theBin)
        ## print "Leg Emu: ",trig,theBin,rate,err,"\n"
        ## 
        ## hLegEmu.SetBinContent(ibin+1,rate)
        ## hLegEmu.SetBinError(ibin+1,err)


    hRat= hLegacy.Clone()
    hRat.SetName("Leg/Stage1")
    hRat.Divide(hLegacy,hStage1,1.,1.,"");

    hRat1= hS1Emu.Clone()
    hRat1.SetName("S1Emu/Stage1")
    hRat1.Divide(hS1Emu,hStage1,1.,1.,"");

    hRat2= hS1Emu.Clone()
    hRat2.SetName("LegEmu/Legacy")
    hRat2.Divide(hLegEmu,hLegacy,1.,1.,"");

    Hlist=TObjArray()
    Hlist.Add(hRat);
    Hlist.Add(hRat1);
    Hlist.Add(hRat2);
     
    cname="Rates"
    c1 = prepPlot("c1",cname,100,20,850,500)
    c1.SetLogy(1);    

    lmargin=0.08;    c1.SetLeftMargin(lmargin);
    rmargin=0.08;    c1.SetRightMargin(rmargin);
    bmargin=0.15;     c1.SetBottomMargin(bmargin);

    # hLegacy.Scale(0.1)
    # hStage1.Scale(0.9)
    # hLegEmu.Scale(0.9)
    SetHistColorAndMarker(hStage1,kRed,20); hStage1.SetFillColor(kRed)
    SetHistColorAndMarker(hS1Emu,kGreen+3,24)
    SetHistColorAndMarker(hLegacy,kBlue,20); hLegacy.SetFillColor(kBlue)
    SetHistColorAndMarker(hLegEmu,kMagenta,24)
    # hNum.Draw()
    hLegacy.SetMinimum(0.1)
    hStage1.SetMinimum(0.1)
    hS1Emu.SetMinimum(0.1)
    hLegEmu.SetMinimum(0.1)

    if plotEmu:
        print "JEE"
        # maxContents=FindMaxContents(hS1Emu)
        # hS1Emu.SetMaximum(maxContents*2.)
        # hS1Emu.Draw("e")
        hStage1.Draw("hist")
        hLegacy.Draw("e,same")
        hLegEmu.Draw("e,same")
        hS1Emu.Draw("e,same")
        hS1Emu.Draw("axis,same")
    else:
        #maxContents=FindMaxContents(hLegacy)
        #hStage1.SetMaximum(maxContents*2.)
        #hLegacy.Draw("hist")
        maxContents=FindMaxContents(hStage1)
        hStage1.SetMaximum(maxContents*2.)
        hStage1.Draw("hist")
        hLegacy.Draw("e,same")
        hLegacy.Draw("axis,same")


    
    x1=0.4; y1=0.2; x2=x1+0.22; y2=y1+.2
    leg=PrepLegend(x1,y1,x2,y2,0.038)
    leg.SetHeader("Run " + runid)
    leg.AddEntry( hStage1, 'Stage1 (Fed809)'  , "l")
    leg.AddEntry( hLegacy, 'Legacy (Fed813)'  , "pl")
    if plotEmu:
        leg.AddEntry( hS1Emu,  'Stage1 Emulator', "pl")
        leg.AddEntry( hLegEmu, 'Legacy Emulator'  , "pl")
    leg.Draw()
    ## DrawText(0.4,0.2,"Run " + runid + " Splashes",0.04)

    c1.Update()
    if (PrintPlot):
        psname=TriggerSet + "_Run" + str(runid)
        c1.Print(psname + ".gif")

    
    cname="Ratio"
    c2 = prepPlot("c2",cname,900,40,850,500)
    c2.SetLogy(0);    

    
    min=0.; max=1.24
    
    hRat.SetMaximum(1.24)
    hRat.SetMinimum(0.0)
    hRat.Draw()
    ## hRat2.Draw("same")

    c2.Update()
    if (PrintPlot):
        psname="ratio_" + TriggerSet + "_Run" + str(runid)
        c2.Print(psname + ".gif")

    # f2=TFile(OutFile,"RECREATE")
    # f2.cd()
    # hRat.Write()
    # f2.Close()

#===============================================================

    ans=raw_input('\npress return to continue, \"e\" to exit...')
    if len(ans)>0:
        return 1

    return 0