• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tdrstyle.setTDRStyle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tdrstyle.setTDRStyle函数的典型用法代码示例。如果您正苦于以下问题:Python setTDRStyle函数的具体用法?Python setTDRStyle怎么用?Python setTDRStyle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setTDRStyle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_canvas

def get_canvas(cname):

  tdrstyle.setTDRStyle()
  CMS_lumi.lumi_8TeV = "19.7 fb^{-1}"
  CMS_lumi.writeExtraText = 1
  CMS_lumi.extraText = "Preliminary"

  iPos = 0
  if( iPos==0 ): CMS_lumi.relPosX = 0.16

  H_ref = 800; 
  W_ref = 800; 
  W = W_ref
  H  = H_ref

  T = 0.08*H_ref
  B = 0.12*H_ref 
  L = 0.12*W_ref
  R = 0.04*W_ref

  canvas = ROOT.TCanvas(cname,cname,50,50,W,H)
  canvas.SetFillColor(0)
  canvas.SetBorderMode(0)
  canvas.SetFrameFillStyle(0)
  canvas.SetFrameBorderMode(0)
  canvas.SetLeftMargin( L/W+0.02 )
  canvas.SetRightMargin( R/W )
  canvas.SetTopMargin( T/H )
  canvas.SetBottomMargin( B/H )
  canvas.SetGrid()
  canvas.SetLogy()
  
  return canvas
开发者ID:jngadiub,项目名称:EXOVVVHLimitsComparison,代码行数:33,代码来源:CombineEXOVVLimits.py


示例2: get_canvas

def get_canvas(text):

   tdrstyle.setTDRStyle()
   CMS_lumi.lumi_13TeV = "2.1 fb^{-1}," + text
   CMS_lumi.writeExtraText = 1
   CMS_lumi.extraText = ""

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

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

   T = 0.08*H_ref
   B = 0.12*H_ref 
   L = 0.12*W_ref
   R = 0.04*W_ref

   canvas = ROOT.TCanvas("c2","c2",50,50,W,H)
   canvas.SetFillColor(0)
   canvas.SetBorderMode(0)
   canvas.SetFrameFillStyle(0)
   canvas.SetFrameBorderMode(0)
   canvas.SetLeftMargin( L/W+0.01 )
   canvas.SetRightMargin( R/W+0.03 )
   canvas.SetTopMargin( T/H )
   canvas.SetBottomMargin( B/H+0.03 )
   canvas.SetGrid()
   canvas.SetLogy()
   
   return canvas
开发者ID:jstupak,项目名称:EXOVVFitter,代码行数:33,代码来源:runLimitsEXO_g1.py


示例3: get_canvas

def get_canvas():

   tdrstyle.setTDRStyle()
   CMS_lumi.lumi_13TeV = "13 TeV"
   CMS_lumi.writeExtraText = 0
   CMS_lumi.extraText = "Preliminary"

   iPos = 0
   if( iPos==0 ): CMS_lumi.relPosX = 0.07

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

   T = 0.08*H_ref
   B = 0.12*H_ref 
   L = 0.12*W_ref
   R = 0.04*W_ref

   #canvas = ROOT.TCanvas("c2","c2",50,50,W,H)
   canvas = ROOT.TCanvas("c2","c2",W,H)
   canvas.SetFillColor(0)
   canvas.SetBorderMode(0)
   canvas.SetFrameFillStyle(0)
   canvas.SetFrameBorderMode(0)
   canvas.SetLeftMargin( L/W )
   canvas.SetRightMargin( R/W )
   canvas.SetTopMargin( T/H )
   canvas.SetBottomMargin( B/H )
   canvas.SetTickx()
   canvas.SetTicky()
   
   return canvas
开发者ID:jngadiub,项目名称:ExoDiBosonAnalysis,代码行数:34,代码来源:plot-xsec.py


示例4: get_canvas

def get_canvas(cname,lumi8,lumi13):

   tdrstyle.setTDRStyle()
   CMS_lumi.lumi_13TeV = "%s fb^{-1}"%lumi13
   CMS_lumi.lumi_8TeV = "%s fb^{-1}"%lumi8
   CMS_lumi.writeExtraText = 1
   CMS_lumi.extraText = "Preliminary"
   CMS_lumi.lumi_sqrtS = "13 TeV" # used with iPeriod = 0, e.g. for simulation-only plots (default is an empty string)
   iPos = 0
   if( iPos==0 ): CMS_lumi.relPosX = 0.13
   iPeriod=4

   H_ref = 630 
   W_ref = 600 
   W = W_ref
   H  = H_ref

   T = 0.08*H_ref
   B = 0.12*H_ref 
   L = 0.12*W_ref
   R = 0.04*W_ref

   canvas = ROOT.TCanvas(cname,cname,50,50,W,H)
   canvas.SetFillColor(0)
   canvas.SetBorderMode(0)
   canvas.SetFrameFillStyle(0)
   canvas.SetFrameBorderMode(0)
   canvas.SetLeftMargin( L/W+0.01 )
   canvas.SetRightMargin( R/W+0.03 )
   canvas.SetTopMargin( 0.07 ) #/T/H
   canvas.SetBottomMargin( B/H )
   #canvas.SetGrid()
   canvas.SetLogy()
   
   return canvas
开发者ID:jngadiub,项目名称:ExoDiBosonCombination,代码行数:35,代码来源:plot_limits_B2G16007.py


示例5: get_canvas

def get_canvas(cname):

   tdrstyle.setTDRStyle()
   iPos = 0
   if( iPos==0 ): CMS_lumi.relPosX = 0.13
   iPeriod=4

   H_ref = 500
   W_ref = 500
   W = W_ref
   H  = H_ref

   T = 0.08*H_ref
   B = 0.12*H_ref 
   L = 0.12*W_ref
   R = 0.04*W_ref

   canvas = ROOT.TCanvas(cname,cname,50,50,W,H)
   canvas.SetFillColor(0)
   canvas.SetBorderMode(0)
   canvas.SetFrameFillStyle(0)
   canvas.SetFrameBorderMode(0)
   canvas.SetLeftMargin( 0.35 )
   canvas.SetRightMargin( 0.02 )
   canvas.SetTopMargin( 0.01 ) #/T/H
   canvas.SetBottomMargin( B/H )
   
   return canvas
开发者ID:jngadiub,项目名称:ExoDiBosonCombination,代码行数:28,代码来源:plot_pulls_signal_13TeV.py


示例6: __init__

    def __init__(self, OutDir):
        self.OutDir = OutDir
        if not os.path.isdir(self.OutDir):
            try:
                os.makedirs(self.OutDir)
            except OSError:
                pass

        self.lumi = Lumi
        tdrstyle.setTDRStyle()
        self.canvas = self.CreatCanvas()
开发者ID:zhenbinwu,项目名称:SuperTopTagger,代码行数:11,代码来源:PyDraw.py


示例7: setTDRStyle

def setTDRStyle(canvas, luminosity, energy, printCMS):
    tdrstyle.setTDRStyle() 
    if printCMS == "right" or printCMS == "left":
        if energy == 13:
            CMS_lumi.lumi_13TeV = "%s fb^{-1}" % luminosity
            if printCMS == "left":
                iPos = 11
            else:
                iPos = 13
            CMS_lumi.writeExtraText = 1
            CMS_lumi.extraText = "Very Preliminary"
            CMS_lumi.CMS_lumi(canvas, 4, iPos)
开发者ID:truggles,项目名称:Z_to_TauTau_13TeV,代码行数:12,代码来源:plot_functions.py


示例8: __init__

    def __init__(self):
        '''
        Set up PlotStyle, set gStyle for things we always want no matter what.
        '''
        # CMS-approved everything
        tdrstyle.setTDRStyle()

        ### Differences from TDR standard:

        # Big canvas (can always shrink later)
        gStyle.SetCanvasDefH(1200)
        gStyle.SetCanvasDefW(1200)

        # Tick marks on all sides
        gStyle.SetPadTickX(1)
        gStyle.SetPadTickY(1)
    
        # Everything has white backgrounds
        gStyle.SetLegendFillColor(0)

        # Colors that don't suck
        gStyle.SetPalette(1)

        # Make axis title and labels just a little smaller and (for Y) closer to the axis
        gStyle.SetTitleSize(0.048, "X")
        gStyle.SetTitleSize(0.044, "YZ")
        gStyle.SetLabelSize(0.033, "XYZ")
        gStyle.SetTitleYOffset(1.15)
        gStyle.SetTitleXOffset(0.86)
        gStyle.SetPadLeftMargin(0.1)
        gStyle.SetPadRightMargin(0.025)
        gStyle.SetPadBottomMargin(0.095)
        gStyle.SetTitleAlign(12)

        # Apply changes
        gROOT.ForceStyle()

        # Force exponentials when axes are over 3 digits
        TGaxis.SetMaxDigits(3)
        TGaxis.SetExponentOffset(-0.060, 0.008, "y")
        TGaxis.SetExponentOffset(-0.055, -0.062, "x") # will overlap with title unless title is centered
开发者ID:nwoods,项目名称:ZZAnalyzer,代码行数:41,代码来源:PlotStyle.py


示例9: DrawPUperFile

def DrawPUperFile(filedir, l1seed, key=None):
    global mcdf
    allfiles = glob.glob(filedir)
    if not os.path.exists("plots"):
        os.mkdir("plots")

    tdrstyle.setTDRStyle()
    ROOT.gStyle.SetOptStat(000000000)
    df = pd.DataFrame()
    flist = [ ]
    for file_ in allfiles:
        df_ = pd.read_csv(file_, index_col=None, header=0)
        flist.append(df_)
    df = pd.concat(flist)
    mcdf = GetMCDataFrame(allfiles)

    if l1seed == "All":
        for seed in pd.unique(df.L1Seed):
            DrawPU(df, seed)
    else:
        return DrawPU(df, l1seed, key)
开发者ID:cms-l1-dpg,项目名称:L1Menu,代码行数:21,代码来源:PU_CSV.py


示例10: makeComparisonPlots

def makeComparisonPlots(patTuple_list, ntuple_l1recoMuonTree, label, handle,
                        plottingVariables):
    ROOT.gROOT.SetBatch()        # don't pop up canvases
    ROOT.gStyle.SetErrorX(0)

    tdrstyle.setTDRStyle()

    muonHists_patTree = plotMuQuantities_pat(patTuple_list, label, handle,
                                             plottingVariables)
    muonHists_l1muRecoTree = plotMuQuantities_l1(ntuple_l1recoMuonTree,
                                                 plottingVariables)

    for muonHist_patTree, muonHist_l1muRecoTree, plotVar in izip(muonHists_patTree,
                                                                 muonHists_l1muRecoTree,
                                                                 plottingVariables):
        # Draw histograms
        c1 = ROOT.TCanvas("", "", 1024, 786)
        muonHist_l1muRecoTree.SetLineColor(ROOT.kBlue)
        muonHist_l1muRecoTree.DrawCopy("E1HIST")
        muonHist_patTree.SetLineColor(ROOT.kRed)
        muonHist_patTree.DrawCopy("E1HISTSAME")
        c1.Print(plotVar.title + ".pdf")
开发者ID:dinyar,项目名称:ComparePat2L1RecoTreePlotter,代码行数:22,代码来源:ComparePat2L1RecoTreePlotter.py


示例11: drawPlots_tdrstyle

def drawPlots_tdrstyle(data, signal, signalSF, signalName, background, backgroundSF, backgroundName, xlo, xhi, name, xaxisLabel, axisMin, axisMax, doLogy):

    tdrstyle.setTDRStyle()
    CMS_lumi.lumi_8TeV = '19.7 fb^{-1}'
    CMS_lumi.extraText = 'Preliminary'
    CMS_lumi.writeExtraText = 1
    CMS_lumi.lumi_sqrtS = '8 TeV'

    iPos = 11
    H = 600
    W = 800
    # iPeriod = 1*(0/1 7 TeV) + 2*(0/1 8 TeV)  + 4*(0/1 13 TeV) 
    iPeriod = 2

    # references for T, B, L, R
    T = 0.08*H
    B = 0.12*H
    L = 0.12*W
    R = 0.04*W
    
    can = ROOT.TCanvas('can', 'plot', 50, 50, W, H)

    padFraction = 0.3
    
    padhi = ROOT.TPad('padhi', 'padhi', 0, padFraction, 1, 1)
    padhi.SetLeftMargin( L/W )
    padhi.SetRightMargin( R/W )
    padhi.SetTopMargin(T/H/(1.0 - padFraction))
    padhi.SetBottomMargin(0)
    padhi.SetTickx(0)
    padhi.SetTicky(0)    
    padhi.SetLogy(doLogy)
    
    padlo = ROOT.TPad('padlo', 'padlo', 0, 0, 1, padFraction)
    padlo.SetLeftMargin( L/W )
    padlo.SetRightMargin( R/W )
    padlo.SetTopMargin(0)
    padlo.SetBottomMargin(B/H/padFraction)
    padlo.SetTickx(0)
    padlo.SetTicky(0)

    padhi.Draw()
    padlo.Draw()
        
    signal.Scale(signalSF)
    background.Scale(backgroundSF)

    background.SetFillColor(8)
    
    sumHist = signal.Clone('sumHist')
    sumHist.Add(background)
    sumHist.SetFillColor(ROOT.kGray)
    sumHist.GetXaxis().SetRangeUser(xlo, xhi)
    sumHist.GetYaxis().SetRangeUser(axisMin, axisMax)
    sumHist.GetYaxis().SetTitle('Events / 10 GeV')

    ratio = data.Clone('ratio')
    ratio.Reset()
    for ibin in range(ratio.GetNbinsX()):
        if(sumHist.GetBinContent(ibin+1) == 0):
            continue
        ratio.SetBinContent(ibin+1, data.GetBinContent(ibin+1) / sumHist.GetBinContent(ibin+1))
        ratio.SetBinError(ibin+1, data.GetBinError(ibin+1) / sumHist.GetBinContent(ibin+1))

    ratio.GetYaxis().SetRangeUser(0.45, 1.55)
    ratio.GetYaxis().SetTitle('Data / Background')
    ratio.GetYaxis().SetLabelSize(0.06)
    ratio.GetYaxis().SetTitleSize(0.06)
    ratio.GetYaxis().SetTitleOffset(0.5)
    #ratio.GetYaxis().SetNdivisions(512)

    ratio.GetXaxis().SetRangeUser(xlo, xhi)
    ratio.GetXaxis().SetTitle(xaxisLabel)
    ratio.GetXaxis().SetLabelSize(0.10)
    ratio.GetXaxis().SetTitleSize(0.12)
    ratio.GetXaxis().SetTitleOffset(1.2)

    oneLine = ROOT.TLine(xlo, 1.0, xhi + 10.0, 1.0)
    oneLine.SetLineStyle(2)

    reqtitle = ''
    if 'ele_bjj' in name or 'ele_jjj' in name:
        if 'z_mass' in name:
            reqtitle = 'ee'
        else:
            reqtitle = 'e#gamma'
    else:
        if 'z_mass' in name:
            reqtitle = '#mu#mu'
        else:
            reqtitle = '#mu#gamma'

    if 'bjj' in name:
        reqtitle = reqtitle + '+bjj'
    else:
        reqtitle = reqtitle + '+jjj'

    #leg = ROOT.TLegend(0.7, 0.6, 0.85, 0.85, '', 'brNDC')
    leg = ROOT.TLegend(0.72, 0.6, 0.89, 0.85, '', 'brNDC')
    leg.SetFillColor(0)
#.........这里部分代码省略.........
开发者ID:bpf6qc,项目名称:leptonAnalysis,代码行数:101,代码来源:utils.py


示例12: DrawPU

def DrawPU(f, l1seed, key=None):
    df = f[(f.L1Seed == l1seed )]
    RetVar = None

    for i in range(0, len(pubins) -1):
        pumap[pubins[i]] = []
        pumap[pubins[i]].append(df[np.logical_and(df.PileUp > pubins[i], df.PileUp <= pubins[i+1])].Fired.sum())
        pumap[pubins[i]].append(df[np.logical_and(df.PileUp > pubins[i], df.PileUp <= pubins[i+1])].Total.sum())

    # # No merging
    # PileUp = pd.unique(df.PileUp)
    # for i in PileUp:
        # pumap[i] = []
        # pumap[i].append(df[df.PileUp == i].Fired.sum())
        # pumap[i].append(df[df.PileUp == i].Total.sum())

    x = []
    y = []
    yerr = []
    for k, v in pumap.iteritems():
        if v[1] != 0:
            x.append(k)
            if unit == "Hz":
                y.append(float(v[0])/v[1] * freq * nBunches )
                yerr.append( math.sqrt(float(v[0]))/v[1] * freq * nBunches )
            if unit == "kHz":
                y.append(float(v[0])/v[1] * freq * nBunches / 1000)
                yerr.append( math.sqrt(float(v[0]))/v[1] * freq * nBunches / 1000)

    ## Draw the plot
    graph = ROOT.TGraphErrors(len(x))
    minx = min(x)
    maxx = 31
    for i, (xx, yy, yee) in enumerate(zip(x, y, yerr)):
        graph.SetPoint(i, xx, yy)
        graph.SetPointError(i, 0, yee)

    c1 = ROOT.TCanvas("fd","Fdf", 600, 500)
    ROOT.gStyle.SetOptStat(000000000)
    tdrstyle.setTDRStyle()
    graph.Draw("AP")
    graph.SetTitle(l1seed)
    graph.GetXaxis().SetTitle("PileUp")
    graph.GetXaxis().SetLimits(0, 50)
    if unit == "Hz":
        graph.GetYaxis().SetTitle("Rate (nBunches = %d) [Hz]" % nBunches)
    if unit == "kHz":
        graph.GetYaxis().SetTitle("Rate (nBunches = %d) [kHz]" % nBunches)

    leg = ROOT.TLegend(0.7432886,0.1733615,0.9949664,0.3530655)
    leg.SetFillColor(0)
    leg.SetBorderSize(0)
    leg.SetBorderSize(0)
    leg.SetFillStyle(0)
    leg.SetTextFont(62)
    leg.AddEntry(graph, "Data", "p")

    ## Get Stage1
    s1fun = GetStage1Fun(l1seed)
    if DrawStage1 and s1fun is not None:
        s1fun.SetLineColor(ROOT.kGreen+2)
        s1fun.SetLineWidth(2)
        s1fun.Draw("same")
        tex = ROOT.TLatex(0.19, 0.81, s1fun.GetName())
        tex.SetNDC()
        tex.SetTextAlign(13)
        tex.SetTextFont(61)
        tex.SetTextSize(0.04)
        tex.SetTextColor(ROOT.kGreen+2)
        tex.SetLineWidth(2)
        tex.Draw()


    tex = ROOT.TLatex(0.19, 0.9, l1seed)
    tex.SetNDC()
    tex.SetTextAlign(13)
    tex.SetTextFont(61)
    tex.SetTextSize(0.05)
    tex.SetTextColor(ROOT.kBlack)
    tex.SetLineWidth(2)
    tex.Draw()
    ## Pol2
    fitname = "pol2"
    graph.Fit("pol2", "QF", "", minx, maxx)
    f2 = graph.GetFunction(fitname).Clone()
    f2.SetLineColor(ROOT.kBlue)
    f2.SetLineWidth(2)
    fun = "f2 = %.2f + %.2f*x + %.3f*x^2" % (f2.GetParameter(0), f2.GetParameter(1), f2.GetParameter(2) )
    RetVar = f2.GetParameter(2) 
    tex = ROOT.TLatex(0.19, 0.75, fun)
    f2.Draw("same")
    tex.SetNDC()
    tex.SetTextAlign(13)
    tex.SetTextFont(61)
    tex.SetTextSize(0.04)
    tex.SetTextColor(ROOT.kBlue)
    tex.SetLineWidth(2)
    tex.Draw()

    ## Pol1
#.........这里部分代码省略.........
开发者ID:cms-l1-dpg,项目名称:L1Menu,代码行数:101,代码来源:PU_CSV.py


示例13: DrawPU

def DrawPU(canvas, f, l1seed, count, key=None):
    df = f[(f.L1Seed == l1seed )]
    RetVar = None

    for i in range(0, len(pubins) -1):
        pumap[pubins[i]] = []
        pumap[pubins[i]].append(df[np.logical_and(df.PileUp > pubins[i], df.PileUp <= pubins[i+1])].Fired0.sum())
        pumap[pubins[i]].append(df[np.logical_and(df.PileUp > pubins[i], df.PileUp <= pubins[i+1])].Total.sum())

    x = []
    y = []
    yerr = []
    for k, v in pumap.iteritems():
        if v[1] != 0:
            x.append(k)
            if unit == "Hz":
                y.append(float(v[0])/v[1] * freq * nBunches )
                yerr.append( math.sqrt(float(v[0]))/v[1] * freq * nBunches )
            if unit == "kHz":
                y.append(float(v[0])/v[1] * freq * nBunches / 1000)
                yerr.append( math.sqrt(float(v[0]))/v[1] * freq * nBunches / 1000)

    ## Draw the plot
    graph = ROOT.TGraphErrors(len(x))

    for i, (xx, yy, yee) in enumerate(zip(x, y, yerr)):
        # if yy != 0 and yee/yy >0.3:
            # continue
	#if i == 22 or i == 23 or i == 24:
	    # continue
        graph.SetPoint(i, xx, yy)
	#print (i,xx,yy,yee)
        #print "h1->SetBinContent( %d, %f);" %(xx,yy)
        #print "h1->SetBinError( %d, %f);" %(xx,yee)
        graph.SetPointError(i, 0, yee)

    graph.SetMarkerStyle(20+count)
    graph.SetMarkerSize(1.5)
    graph.SetMarkerColor(1+count)
    graph.SetLineColor(1+count)
    graph.SetLineWidth(2)
    tdrstyle.setTDRStyle()
    canvas.cd()
    canvas.Update()
    if count == 0:
        graph.Draw("AP")
        graph.GetXaxis().SetTitle("PileUp")
        graph.GetXaxis().SetLimits(plot_min, maxx)
        graph.GetYaxis().SetRangeUser(0, maxy)
        graph.GetYaxis().SetTitle("Rate (nBunches = %d) [%s]" % (nBunches, unit))
    else:
        graph.Draw("P")
    canvas.Update()
    leg.AddEntry(graph, l1seed, "p")

    result_ptr = graph.Fit(fitname, "SQ", "", fit_min, fit_max)
    error_vec = result_ptr.GetConfidenceIntervals()
    print ("error vec size = %d, fitted PU = %d" % (error_vec.size(), fit_max - fit_min + 1))
    f2 = graph.GetFunction("fitname").Clone()
    #f2 = graph.GetFunction(fitname).Clone()
    f2.SetLineColor(1+count)
    f2.SetLineWidth(2)
    f2.SetRange(plot_min, fit_min)
    f2.SetLineStyle(5)
    minChi = f2.GetChisquare() / f2.GetNDF()
    #fun = "Fit = %.2f + %.2f*x + %.3f*x^2" % (f2.GetParameter(0), f2.GetParameter(1), f2.GetParameter(2) )
    #fun = "Fit = %f*x + %f*x^2" % (f2.GetParameter(0), f2.GetParameter(1) )
    #print fun
    f2.Draw("same")
    f2_2 = f2.Clone("dashline2")
    f2_2.SetRange(fit_max, plot_max)
    f2_2.Draw("same")
    if config == 2017:
        if PU <= fit_max: key = "Rate(PU=%d): %.2f +- %.2f, chi2/NDF=%.2f" %(PU, f2_2.Eval(PU), error_vec.at(PU-fit_min), minChi)
        else: key = "Rate(PU=%d): %.2f +- %.2f, chi2/NDF=%.2f" %(PU, f2_2.Eval(PU), error_vec.back(), minChi)
    if config == 2018:
	#key = ""
        key = "Rate: %.2f +- %.2f @PU50, %.2f +- %.2f @PU56, %.2f +- %.2f @PU62" %(f2_2.Eval(50), error_vec.at(50-fit_min), f2_2.Eval(56), error_vec.at(56-fit_min), f2_2.Eval(62), error_vec.at(62-fit_min))

    if key is not None:
        tex = ROOT.TLatex(0.2, 0.85, key)
        tex.SetNDC()
        tex.SetTextFont(61)
        tex.SetTextSize(0.055)
        tex.SetTextColor(ROOT.kGreen+2)
        tex.SetLineWidth(2)
        tex.Draw()

    canvas.Update()
开发者ID:cms-l1-dpg,项目名称:L1Menu,代码行数:89,代码来源:CompPUDep.py


示例14: PlotDataMCPAS

def PlotDataMCPAS(hdictlist_bg, hdict_data, hdictlist_sig=0, legdict=0
               , outputdir="plots", outfile=0, cname="canvas", plotinfo="Selection X"
               , ratiotitle="ratio", logscale=False, scale="No", scalefactor=1, intlumi=19.7, style="CMS"):

    # CMS style plots
    if style == "CMS":
        tdrstyle.setTDRStyle()

    # First do some checks on the input
    if outfile == 0:
        print "You did not pass me a root file to store the plots. I will only produce pdf files."
    if not os.path.isdir(outputdir):
        print "Output directory doesn't exist yet. \nWill create directory %s" % (outputdir)
        os.makedirs(outputdir)

    # Get clones of all the mc histograms and put them in a list
    hQCD_index = -1 # will need this if we want to scale QCD only
    histos = []
    for i,hdict in enumerate(hdictlist_bg):
        # first check that the histogram exists
        if not hdict["histogram"]:
            print "Histogram for sample", hdict["name"], "and canvas", cname, "doesn't exist, will stop making this plot now"
            return
        h = hdict["histogram"].Clone() 
        h.Sumw2()
        h.SetFillColor(hdict["color"])
        h.SetLineColor(hdict["color"])
        h.GetYaxis().SetTitle(hdict["ytitle"])
        h.GetXaxis().SetTitle(hdict["xtitle"])
        h.SetTitle(hdict["title"])
        histos.append(h)
        if "QCD" in hdict["name"]:
            hQCD_index = i

    # Get data histogram
    hdata = 0
    if hdict_data == 0:
        print "Will make plots without data"
    else:
        if not hdict_data["histogram"]:
            print hdict["name"], "doesn't exist, will stop making this plot now"
            return
        hdata = hdict_data["histogram"].Clone()
        hdata.Sumw2()
        hdata.SetMarkerStyle(hdict_data["markerstyle"])
        hdata.SetLineColor(hdict_data["color"])
        hdata.GetYaxis().SetTitle(hdict_data["ytitle"])
        hdata.SetTitle(hdict_data["title"])

    # Get signal histograms
    hsignal = []
    if hdictlist_sig != 0:
        for hdict in hdictlist_sig:
            if not hdict["histogram"]:
                print hdict["name"], "doesn't exist, will stop making this plot now"
                return
            h = hdict["histogram"].Clone()
            h.Sumw2()
            h.SetFillColor(hdict["color"])
            h.SetLineColor(hdict["color"])
            hsignal.append(h)

    # make a stack of all the mc, will use the reverse order of the list
    mc = rt.THStack()
    for h in reversed(histos):
        mc.Add(h,"hist")
    for h in hsignal:
        mc.Add(h,"hist")
        
    # make the total mc histogram, used for the ratio plot
    htotal = histos[0].Clone()
    for h in histos[1:]:
        htotal.Add(h)

    # scale MC to data if required
    if scale == "Yes" and hdata != 0:
        sf = scalefactor
        if sf == 1: # we should rescale to match data
            mc_int = htotal.Integral(0,htotal.GetNbinsX()+1)
            if mc_int == 0:
                mc_int = 1.
            data_int = hdata.Integral()
            sf = data_int/mc_int
        for h in histos:
            h.Scale(sf)
        print "Scaled all histograms by factor", sf

    # Scale everything according to the bin width
    if scale == "Width":
        for h in histos:
            h.Scale(scalefactor,"width")
        if hdata != 0:
            hdata.Scale(scalefactor,"width")
        for h in hsignal:
            h.Scale(scalefactor,"width")
        print "Will plot per bin width"
        
    # scale only QCD to match data in the first non-empty bin
    if scale == "QCD" and hdata != 0:
        sf = scalefactor
#.........这里部分代码省略.........
开发者ID:nstrobbe,项目名称:RazorBoost,代码行数:101,代码来源:plotTools.py


示例15: Plot2DPAS

def Plot2DPAS(hdict,outputdir="plots",outfile=0,cname="canvas"
           ,logscale=False,scale="No",lumitext="Preliminary"):

    # CMS style plots
    tdrstyle.setTDRStyle()

    # First do some checks on the input
    if outfile == 0:
        print "You did not pass me a root file to store the plots. I will only produce pdf files."
    if not os.path.isdir(outputdir):
        print "Output directory doesn't exist yet"
        print "Will create directory %s" % (outputdir)
        os.makedirs(outputdir)

    # placeholder for draw objects
    rootEvil = []

    # Make the canvas
    canvas = rt.TCanvas(cname,"",50,50,800,600)
    CMS_lumi.lumi_8TeV = "19.7 fb^{-1}"
    CMS_lumi.writeExtraText = 1
    CMS_lumi.extraText = lumitext

    iPos = 0#11
    if( iPos==0 ): CMS_lumi.relPosX = 0.12
    iPeriod = 2
    H_ref = 600 
    W_ref = 800 
    W = W_ref
    H  = H_ref
    
    # references for T, B, L, R
    T = 0.08*H_ref
    B = 0.12*H_ref 
    L = 0.12*W_ref
    R = 0.12*W_ref

    canvas.SetLeftMargin( L/W )
    canvas.SetRightMargin( R/W )
    canvas.SetTopMargin( T/H )
    canvas.SetBottomMargin( B/H )

    #canvas.SetLeftMargin(0.13)
    #canvas.SetRightMargin(0.17)
    #canvas.SetBottomMargin(0.13)
    if logscale:
        canvas.SetLogz(1)
    canvas.cd()
    
    # Get histogram from dictionary, and plot it 
    print "Getting histogram"

    h = hdict["histogram"] # Get the histogram
    if scale == "Yes":
        sf = h.Integral(0,h.GetNbinsX()+1,0,h.GetNbinsY()+1)
        h.Scale(1./sf)
    if scale == "Width":
        h.Scale(1,"width")
            
    if scale == "Yes":
        h.GetZaxis().SetTitle("A.U.")
    else:
        h.GetZaxis().SetTitle("Events")
    
    maxi = h.GetMaximum()
    if logscale:
        h.SetMaximum(maxi*2)
    else:
        h.SetMaximum(maxi*1.2)
    if scale == "Yes":
        h.SetMaximum(1)
    h.GetXaxis().SetTitle(hdict["xtitle"])
    h.GetXaxis().SetTitleSize(0.05)
    h.GetXaxis().SetTitleOffset(1.05)
    h.GetXaxis().SetLabelSize(0.04)
    h.GetYaxis().SetTitle(hdict["ytitle"])
    h.GetYaxis().SetTitleSize(0.05)
    h.GetYaxis().SetTitleOffset(1.05)
    h.GetYaxis().SetLabelSize(0.04)
    #h.GetZaxis().SetTitleSize(0.05)
    #h.GetZaxis().SetTitleOffset(1.1)
    #h.GetZaxis().SetLabelSize(0.04)
    h.SetTitle(hdict["title"])

    
    drawoption = hdict["drawoption"]
    palette = hdict["palette"]
    if "colz" in drawoption and palette == "SMS":
        print "change color palette"
        SetColorPaletteSMS()
    if "colz" in drawoption and palette == "2DRatio":
        SetColorPalette2DRatio()
    rootEvil.append(h.DrawClone(drawoption))
            
    print "Drew histogram"
    print hdict["name"]
    if hdict["name"] != "":
        t = '#scale[1.1]{%s}' % (hdict["name"])
        if len(hdict["name"]) > 20:
            tex = rt.TLatex(0.45,0.82,t)
#.........这里部分代码省略.........
开发者ID:nstrobbe,项目名称:RazorBoost,代码行数:101,代码来源:plotTools.py


示例16: setTDRStyle

#!/usr/bin/env python

#execfile('loadPyRoot.py')

from ROOT import TFile, TCanvas, TGraphErrors, TH1D, TF1, gStyle, TAxis, TH1F
from tdrstyle import setTDRStyle
setTDRStyle(False)

gStyle.SetOptFit(True)

file_official = TFile("/home/home2/institut_3b/kargoll/TauAnalysis/H2TauLimits/CMSSW_7_1_5/src/auxiliaries/shapes/CERN/htt_mt.inputs-sm-8TeV.root","READ")
channels = ["0jet_high", "0jet_medium",
            "1jet_high_mediumhiggs", "1jet_high_lowhiggs", "1jet_medium",
            "vbf_loose", "vbf_tight"]

mLow   = 90
mHigh  = 160
mStep  = 5

for channel in channels:
    can = TCanvas()
    
    NPoints = (mHigh-mLow)/mStep + 1
    graph = TGraphErrors(NPoints)
    graph.SetTitle(channel)
    
    m = mLow
    while m <= mHigh:
        i = (m-mLow)/5
        x = m
        
开发者ID:bkargoll,项目名称:AnalysisTools,代码行数:30,代码来源:plot_svFitMassRegression.py


示例17: elif

        ofile.write("Events after minDPhi cut  : %.2f\n" %(h.GetBinContent(9)) )
        if(h.GetBinContent(0)!=0):ofile.write("Selection efficiency      : %.2f\n" %(h.GetBinContent(9)/h.GetBinContent(0)) )
    elif(channel == "fullhadronic"):
        ofile.write("Events after minDPhi cut  : %.2f\n" %(h.GetBinContent(7)) )
        if(h.GetBinContent(0)!=0):ofile.write("Selection efficiency      : %.2f\n" %(h.GetBinContent(7)/h.GetBinContent(0)) )


ROOT.gROOT.Reset();
ROOT.gROOT.SetStyle('Plain')
ROOT.gStyle.SetPalette(1)
ROOT.gStyle.SetOptStat(0)
ROOT.gROOT.SetBatch()        # don't pop up canvases
ROOT.TH1.SetDefaultSumw2()
ROOT.TH1.AddDirectory(False)

tdrstyle.setTDRStyle();

settings = {}
store = []

settings.update(plots.common_SR.settings)
store += plots.common_SR.store

if opt.channel == 'semileptonic':
    # Add semileptonic specific settings and plots to store
    settings.update(plots.semileptonic_SR.settings)
    store += plots.semileptonic_SR.store

    # Define sl output paths
    outhistos = 'output/sl/histos_SR'
    outpdfs = 'output/sl/pdfs_SR'
开发者ID:oiorio,项目名称:NAAnaFW,代码行数:31,代码来源:makePlots_SR.py


示例18: main

def main():

    # ROOT.gROOT.SetBatch(True)
    sys.path.insert(0, "~/CMSstyle/")
    import tdrstyle

    tdrstyle.setTDRStyle()

    # ROOT.LoadMacro("~/bbH/atlasstyle-00-03-05/AtlasStyle.C")
    # SetAtlasStyle()

    gStyle.SetStatColor(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    # gStyle.SetOptStat(1110)
    gStyle.SetOptStat(0)
    gStyle.SetStatH(0.2)
    gStyle.SetStatW(0.2)
    gStyle.SetStatX(0.99)
    gStyle.SetTitleColor(1)
    gStyle.SetTitleFillColor(0)
    # gStyle.SetTitleY(1.)
    # gStyle.SetTitleX(.15)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPalette(1)
    #   gStyle.SetMarkerStyle(20);
    # gStyle.SetMarkerSize(2);
    # gStyle.SetLineWidth(2);
    #   gStyle.SetLineStyleString(2,"[12 12]"); # postscript dashes

    v_samples = ["7_4_6.patch1", "7_5_0.pre6"]
    prefix = "ExoVVAnalysis."

    directories = ["AK4_low", "AK4_high", "AK8_low", "AK8_high"]
    histNames = [
        "Jet_pt",
        "Jet_eta",
        "Jet_m",
        "Jet_phi",
        "Jet_e",
        "Jet_muf",
        "Jet_phf",
        "Jet_emf",
        "Jet_nhf",
        "Jet_chf",
        "Jet_area",
        "Jet_cm",
        "Jet_nm",
    ]
    histNamesAK8 = [
        "Jet_tau1",
        "Jet_tau2",
        "Jet_tau3",
        "Jet_tau21",
        "Jet_tau32",
        "Jet_tau31",
        "Jet_pruned_m",
        "Jet_softdrop_m",
        "Jet_pruned_Wwindow_m",
        "Jet_softdrop_Wwindow_m",
    ]

    _files = {}
    for sample in v_samples:

        inFile = "%s%s.root" % (prefix, sample)

        print "Opening " + inFile
        _files[sample] = TFile.Open(inFile, "READ")

    canvasList = []

    for i in range(len(histNames)):
        for direct in directories:
            hists = {}
            for sample in v_samples:
                hist = _files[sample].Get("%s/%s" % (direct, histNames[i]))
                print "names: %s" % ("%s/%s" % (direct, histNames[i]))
                hists["%s_%s_%s" % (sample, direct, histNames[i])] = hist.Clone(
                    "%s_%s_%s" % (sample, direct, histNames[i])
                )
                hist.Delete()

                # scale to unity
                hists["%s_%s_%s" % (sample, direct, histNames[i])].Scale(
                    1.0
                    / (
                        hists["%s_%s_%s" % (sample, direct, histNames[i])].Integral(
                            0, hists["%s_%s_%s" % (sample, direct, histNames[i])].GetNbinsX() + 1
                        )
                    )
                )
            MakeRatioPlot(
                hists["%s_%s_%s" % (v_samples[0], direct, histNames[i])],
                hists["%s_%s_%s" % (v_samples[1], direct, histNames[i])],
#.........这里部分代码省略.........
开发者ID:cgalloni,项目名称:SFrameAnalysis,代码行数:101,代码来源:ratioPlots.py


示例19: main

def main():
    f = ROOT.TFile.Open(sys.argv[1])
    t = f.Get('tree')
    eff_csv = ROOT.TEfficiency('h_csv', 'Highest CSV Higgs;p_{T}(V) (GeV);Efficiency', 20, 0, 500)
    eff_dijet = ROOT.TEfficiency('h_dijet', 'Highest Dijet Higgs;p_{T}(V) (GeV);Efficiency', 20, 0, 500)
    # Creating references to instance methods avoids spending time on attribute lookup in the for loop.
    fill_csv = eff_csv.Fill
    fill_dijet = eff_dijet.Fill
    # Preload threshold value for simplified function call.
    isdRMatch = functools.partial(ROOT.isdRMatch, 0.5)
    for i, e in enumerate(t):
        if i % 10000 == 0:
            print 'Processing event {!s}'.format(i)
        # Generator level selection cuts.
        min_GenBQuarkFromH_pt = min(e.GenBQuarkFromH_pt[0], e.GenBQuarkFromH_pt[1])
        max_abs_GenBQuarkFromH_eta = max(abs(e.GenBQuarkFromH_eta[0]), abs(e.GenBQuarkFromH_eta[1]))
        if min_GenBQuarkFromH_pt < 20 or max_abs_GenBQuarkFromH_eta > 2.5:
            continue
        # Higgs candidate dR matching. Note that GenHiggsBoson is a PyFloatBuffer,
        # so it must be accessed by index as opposed to the Higgs candidate.
        match_csv = isdRMatch(e.GenHiggsBoson_eta[0], e.GenHiggsBoson_phi[0], e.HCSV_eta, e.HCSV_phi)
        fill_csv(match_csv, e.V_pt)
        match_dijet = isdRMatch(e.GenHiggsBoson_eta[0], e.GenHiggsBoson_phi[0], e.H_eta, e.H_phi)
        fill_dijet(match_dijet, e.V_pt)
    # Format plotting style.
    tdrstyle.setTDRStyle()
    CMS_lumi.extraText = 'Simulation'
    CMS_lumi.lumi_sqrtS = '13 TeV'
    c = ROOT.TCanvas('c', 'c', 50, 50, 800, 600)
    c.SetFillColor(0)
    c.SetBorderMode(0)
    c.SetFrameFillStyle(0)
    c.SetFrameBorderMode(0)
    c.SetLeftMargin(0.12)
    c.SetRightMargin(0.04)
    c.SetTopMargin(0.08)
    c.SetBottomMargin(0.12)
    c.SetTickx(0)
    c.SetTicky(0)
    eff_csv.SetLineColor(ROOT.kRed)
    eff_csv.SetFillColor(ROOT.kRed)
    eff_csv.Draw()
    eff_dijet.SetLineColor(ROOT.kBlue)
    eff_dijet.SetFillColor(ROOT.kBlue)
    eff_dijet.Draw('same')
    ROOT.gPad.Update()
    graph_csv = eff_csv.GetPaintedGraph()
    graph_dijet = eff_dijet.GetPaintedGraph()
    graph_csv.SetMaximum(1.3)
    x_axis = graph_csv.GetXaxis()
    line_unity = ROOT.TLine(x_axis.GetXmin(), 1, x_axis.GetXmax(), 1)
    line_unity.SetLineStyle(2)
    line_unity.Draw('same')
    y_axis = graph_csv.GetYaxis()
    y_axis.SetTitleOffset(1)
    legend = ROOT.TLegend(0.75, 0.18, 0.95, 0.35)
    legend.AddEntry(graph_csv, 'Highest CSV', 'le')
    legend.AddEntry(graph_dijet, 'Highest Dijet', 'le')
    legend.Draw('same')
    latex = ROOT.TLatex()
    latex.SetNDC()
    latex.SetTextFont(42)
    latex.SetTextAngle(0)
    latex.SetTextColor(ROOT.kBlack)
    latex.SetTextSize(0.57 * ROOT.gPad.GetTopMargin())
    latex.SetTextAlign(12)
    latex.DrawLatex(0.78, 0.88, 'WH #rightarrow l#nu b#bar{b}')
    CMS_lumi.CMS_lumi(pad=c, iPeriod=0, iPosX=11)
    c.cd()
    c.Update()
    c.RedrawAxis()
    frame = c.GetFrame()
    frame.Draw()
    c.SaveAs('higgs_efficiency_WlnH.png')
    c.SaveAs('higgs_efficiency_WlnH.pdf')
    f.Close()
开发者ID:swang373,项目名称:Projects,代码行数:76,代码来源:higgs_efficiency.py


示例20: drawTH1

def drawTH1(name, cmsLumi, mclist, data, x_name, y_name, doLog=False, doRatio=True, ratioRange=0.45):
    #leg = ROOT.TLegend(0.58,0.78,0.8,0.9)
    leg = ROOT.TLegend(0.71,0.68,0.88,0.91)
    leg.SetBorderSize(0)
    #leg.SetNColumns(2)
    leg.SetTextSize(0.029)
    leg.SetTextFont(42)
    leg.SetLineColor(0)
    leg.SetFillColor(0)
    leg.AddEntry(data,"Data","lp")

    hs = ROOT.THStack("hs_%s_mc"%(name), "hs_%s_mc"%(name))
    hratio = mclist[0].Clone("hratio")
    hratio.Reset()
    leghist = []
    for i, mc in enumerate(mclist):
        hnew = mc.Clone("hnew"+mc.GetName())
        hnew.Sumw2(False)
        hs.Add(hnew)
        hratio.Add(mc)
        inversed = mclist[len(mclist)-1-i]
        if not any(inversed.GetTitle() == s for s in leghist):
            leg.AddEntry(inversed, inversed.GetTitle(), "f")
            leghist.append(inversed.GetTitle())
                        
    hratio.Divide(data,hratio,1.,1.,"B")

    tdrstyle.setTDRStyle()

    setDefTH1Style(data, x_name, y_name)
    data.SetMaximum(data.GetMaximum()*1.8)
    if doLog:
        #data.SetMaximum(10**7)
        data.SetMaximum(data.GetMaximum()*100)
        
    ratio_fraction = 0
    if doRatio:
        ratio_fraction = 0.3        
        data.GetXaxis().SetLabelSize(0)
        data.GetXaxis().SetTitleSize(0)
        data.GetYaxis().CenterTitle()
        setDefTH1Style(hratio, x_name, "Data/MC")
        hratio.GetYaxis().SetNdivisions(5)
            
    canv = makeCanvas(name, doRatio)
    pads=[canv]
    pads = rootplotcore.divide_canvas(canv, ratio_fraction)
    pads[0].cd()
    
    setMargins(pads[0],doRatio)
    if doLog:
        pads[0].SetLogy()

    data.Draw()
    hs.Draw("same")
    data.Draw("same")
    data.Draw("esamex0")
    leg.Draw("same")
    pads[0].Update()

    if doRatio:
        pads[1].cd()
        pads[1].SetGridy()
        setMargins(pads[1],doRatio)
        hratio.SetLineColor(1)
        hratio.SetMarkerStyle(10)
        hratio.Draw("ep")
        hratio.SetMaximum(1.+ratioRange)
        hratio.SetMinimum(1.-ratioRange)

    for p in pads:
        p.RedrawAxis()
        p.Modified()
        p.Update()

    canv.cd()    
    iPos = 11
    if( iPos==0 ):
        cmsLumi.relPosX = 0.12    
    cmsLumi.CMS_lumi(canv, 0, iPos)
    
    canv.Modified()
    canv.Update()
    canv.SaveAs(name)
开发者ID:hcwhwang,项目名称:ttbb,代码行数:84,代码来源:histoHelper.py



注:本文中的tdrstyle.setTDRStyle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python art.box函数代码示例发布时间:2022-05-27
下一篇:
Python html.from_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap