def plot(plotInfo): tdrstyle.setTDRStyle() #ROOT.gROOT.ForceStyle() canvas = TCanvas("canvas", "canvas") #canvas.SetCanvasSize(600, 600) #canvas.SetLeftMargin(0.125) canvas.SetRightMargin(0.04) #canvas.SetBottomMargin(0.105) legend = ROOT.TLegend(0.5, 0.65, 0.925, 0.925) #legend.SetFillStyle(0) legend.SetBorderSize(0) #legend.SetBorderSize(1) legend.SetTextSize(0.0425) stack = THStack("stack", "stack") stack.SetTitle("#tau_{h} fake rate (%s)" % (era)) # Loose-Loose info_str = "looseLoose_dR03_SS" #h2_LL = inputFile.Get("%s/tau_pT_vs_DM_reco_%s" %(info_str, info_str)).Clone() h2_LL = getHist(l_inputFileName, "%s/%s_%s" % (info_str, plotInfo.histName, info_str)) h2_LL.Sumw2() # Tight-Loose info_str = "tightLoose_dR03_SS" #h2_TL = inputFile.Get("%s/tau_pT_vs_DM_reco_%s" %(info_str, info_str)).Clone() h2_TL = getHist(l_inputFileName, "%s/%s_%s" % (info_str, plotInfo.histName, info_str)) h2_TL.Sumw2() # Tight-Tight info_str = "tightTight_dR03_SS" #h2_TT = inputFile.Get("%s/tau_pT_vs_DM_reco_%s" %(info_str, info_str)).Clone() h2_TT = getHist(l_inputFileName, "%s/%s_%s" % (info_str, plotInfo.histName, info_str)) h2_TT.Sumw2() l_h1_LLtoTL = [] l_h1_TLtoTT = [] for iDM in range(0, len(l_DM)): DM = l_DM[iDM] iBin = h2_LL.GetXaxis().FindBin(DM) h1_LL = h2_LL.ProjectionY("_py", iBin, iBin) h1_LL.Sumw2() h1_LL = h1_LL.Rebin( len(plotInfo.l_rebin) - 1, "", array.array("d", plotInfo.l_rebin)) #print "h1_LL %f" %(h1_LL.GetBinContent(h1_LL.GetNbinsX())) h1_TL = h2_TL.ProjectionY("_py", iBin, iBin) h1_TL.Sumw2() h1_TL = h1_TL.Rebin( len(plotInfo.l_rebin) - 1, "", array.array("d", plotInfo.l_rebin)) #print "h1_TL %f" %(h1_TL.GetBinContent(h1_TL.GetNbinsX())) h1_TT = h2_TT.ProjectionY("_py", iBin, iBin) h1_TT.Sumw2() h1_TT = h1_TT.Rebin( len(plotInfo.l_rebin) - 1, "", array.array("d", plotInfo.l_rebin)) #print "h1_TT %f" %(h1_TT.GetBinContent(h1_TT.GetNbinsX())) # LL to TL h1_temp = h1_TL.Clone() h1_temp.Divide(h1_LL) h1_temp.SetLineColor(iDM + 1) h1_temp.SetLineWidth(3) h1_temp.SetLineStyle(2) l_h1_LLtoTL.append(h1_temp.Clone()) stack.Add(l_h1_LLtoTL[-1], "hist E") legend.AddEntry(l_h1_LLtoTL[-1], "LL #rightarrow TL (DM %d)" % (DM)) # TL to TT h1_temp = h1_TT.Clone() h1_temp.Divide(h1_TL) h1_temp.SetLineColor(iDM + 1) h1_temp.SetLineWidth(3) l_h1_TLtoTT.append(h1_temp.Clone()) stack.Add(l_h1_TLtoTT[-1], "hist E") legend.AddEntry(l_h1_TLtoTT[-1], "TL #rightarrow TT (DM %d)" % (DM)) stack.Draw("nostack") legend.Draw() stack.GetXaxis().SetTitle(plotInfo.xTitle) stack.GetYaxis().SetTitle("#tau_{h} misid. probability") stack.GetXaxis().SetLabelSize(0.05) stack.GetYaxis().SetLabelSize(0.05) stack.GetXaxis().SetTitleOffset(1.05) stack.GetYaxis().SetTitleOffset(1.25) stack.GetXaxis().SetTitleSize(0.055) stack.GetYaxis().SetTitleSize(0.055) stack.GetXaxis().CenterTitle(True) stack.GetYaxis().CenterTitle(True) if (plotInfo.setXmin): stack.GetXaxis().SetRangeUser(plotInfo.xMin, plotInfo.l_rebin[-1]) if (plotInfo.centerLabelsX): stack.GetXaxis().CenterLabels() stack.SetMinimum(0) stack.SetMaximum(1.5) if (len(plotInfo.l_rebin)): if (plotInfo.isXinteger): stack.GetXaxis().SetNdivisions(len(plotInfo.l_rebin), 1, 1) else: stack.GetXaxis().SetNdivisions(len(plotInfo.l_rebin), 5, 1) #canvas.SetGridx() #canvas.SetGridy() # CMS label CMS_lumi.CMS_lumi(pad=canvas, iPeriod=0, iPosX=0, CMSextraText=Common.getCMSextraText(era), lumiText=Common.getLumitext(era)) canvas.SaveAs(outDir + "/%s%s.pdf" % (plotInfo.outFileName, suffix)) canvas.Clear() legend.Clear() stack.Clear()
stack.GetXaxis().CenterTitle(True) stack.GetYaxis().CenterTitle(True) #stack.SetMinimum(10**-3) stack.SetMaximum(0.1) canvas.SetGridx() canvas.SetGridy() #canvas.SetLogy() canvas.SaveAs(outDir + "/tauh_pTfraction_gen.pdf") canvas.Clear() legend.Clear() stack.Clear() #################################################################################################### canvas = TCanvas("canvas", "canvas") canvas.SetCanvasSize(800, 800) legend = TLegend(0.55, 0.5, 0.895, 0.895) stack = THStack("stack", "stack") stack.SetTitle("#tau^{gen}_{h} E fraction [%s]" % (process)) tauTemplate_pTbin = [20, 30, 50, 100] for iBin in range(0, len(tauTemplate_pTbin)):