Example #1
0
                    default="./",
                    help='base dir for analysis tree files')
parser.add_argument('-t',
                    '--tag',
                    dest='tag',
                    default="",
                    help='tag name for analysis tree files')

args = parser.parse_args()

minitrees = combineTools.AnalysisResultsInterface(
    base=args.basedir,
    tag=args.tag,
)

customROOTstyle()
c = ROOT.TCanvas("c", "c", 600, 600)
c.SetLeftMargin(.2)
c.SetRightMargin(.05)
ROOT.gStyle.SetOptTitle(0)
ROOT.gStyle.SetTitleYOffset(1.5)

for channel in ["ee", "mumu"]:
    for mass in combineTools.mass_cut[channel]:
        try:
            h = minitrees.getMassHisto(mass, channel, "signal")
            for p in [.9]:
                #for p in [.7, .8, .9]:
                low, hi, a_p = getRange(h, p)
                print channel, p, '%04d' % mass, low, hi, a_p
            h.SetXTitle("M_{lljj} [GeV]")
Example #2
0
    def draw(self,
             h,
             filename,
             zrange,
             ztitle,
             logz=False,
             cont=None,
             isObserved=False):
        customROOTstyle()
        ROOT.gStyle.SetOptTitle(0)
        ROOT.gROOT.SetBatch(True)
        ROOT.gStyle.SetPalette(55)

        c1 = ROOT.TCanvas("c1", "c1", 800, 800)
        c1.SetTopMargin(0.05)
        c1.SetLeftMargin(0.2)
        c1.SetRightMargin(0.2)
        c1.SetBottomMargin(0.13)
        c1.SetTicks(1, 1)
        #c1.SetLogz()

        c1.SetLogz(logz)
        h.Draw("colz")
        h.SetAxisRange(zrange[0], zrange[1], "Z")
        h.SetXTitle("W_{R} Mass [GeV]")
        h.SetYTitle("N_{l} Mass [GeV]")
        h.SetZTitle(ztitle)
        h.GetYaxis().SetTitleOffset(2)
        h.GetZaxis().SetTitleOffset(1.7)
        h.GetXaxis().SetLabelSize(.027)

        if cont:
            x = np.array([700, 4950, 700, 700], dtype=float)
            y = np.array([700, 4950, 4950, 700], dtype=float)

            area = ROOT.TPolyLine(4, x, y)
            area.SetFillColor(ROOT.kWhite)
            area.SetLineWidth(0)
            area.Draw("F")
            latex2 = ROOT.TLatex()
            latex2.SetTextSize(0.05)
            #specify the lower left corner in x, y coordinates
            latex2.DrawLatex(1400, 3600, "M_{N_{l}} > M_{W_{R}} ")
            cont.SetLineStyle(1)  #solid
            cont.SetLineColor(ROOT.kBlue)
            cont.SetLineWidth(3)
            cont.Draw("L")

            x1 = 900
            y1 = 4000
            xw = 1200
            yw = 200

            leg = ROOT.TLegend(x1, y1, x1 + xw, y1 + yw, "", "")
            if not isObserved: leg.AddEntry(cont, "Expected", "l")
            if isObserved: leg.AddEntry(cont, "Observed", "l")
            leg.SetTextFont(42)
            leg.SetTextSize(0.032)
            leg.SetFillStyle(0)
            leg.SetBorderSize(0)
            leg.Draw()

        latex = ROOT.TLatex()
        latex.SetNDC(True)
        latex.SetTextSize(0.03)
        latex.SetTextFont(42)
        latex.DrawLatex(0.62, 0.96, "35.9 fb^{-1} (13 TeV)")

        text = ROOT.TText(0.2, 0.96, "CMS Preliminary")
        text.SetNDC()
        text.SetTextFont(42)
        text.SetTextSize(0.03)
        text.Draw()
        c1.RedrawAxis()
        c1.SaveAs(filename + ".png")
        c1.SaveAs(filename + ".pdf")
        c1.SaveAs(filename + ".C")
Example #3
0
    def drawOverlay(self,
                    hOne,
                    filename,
                    zrange,
                    ztitle,
                    logz=False,
                    contOne=None,
                    hTwo=None,
                    contTwo=None,
                    contExpMinusOneSigma=None,
                    contExpPlusOneSigma=None,
                    hExpMinusOneSigma=None,
                    hExpPlusOneSigma=None):
        customROOTstyle()
        ROOT.gStyle.SetOptTitle(0)
        ROOT.gROOT.SetBatch(True)
        ROOT.gStyle.SetPalette(55)

        c1 = ROOT.TCanvas("c1", "c1", 800, 800)
        c1.SetTopMargin(0.05)
        c1.SetLeftMargin(0.2)
        c1.SetRightMargin(0.2)
        c1.SetBottomMargin(0.13)
        c1.SetTicks(1, 1)
        #c1.SetLogz()

        c1.SetLogz(logz)
        hOne.Draw("colz")
        hOne.SetAxisRange(zrange[0], zrange[1], "Z")
        hOne.SetXTitle("W_{R} Mass [GeV]")
        hOne.SetYTitle("N_{l} Mass [GeV]")
        hOne.SetZTitle(ztitle)
        hOne.GetYaxis().SetTitleOffset(2)
        hOne.GetZaxis().SetTitleOffset(1.7)
        hOne.GetXaxis().SetLabelSize(.027)

        if hExpMinusOneSigma:
            hExpMinusOneSigma.Draw("colzsame")
            hExpMinusOneSigma.SetAxisRange(zrange[0], zrange[1], "Z")
            hExpMinusOneSigma.SetXTitle("W_{R} Mass [GeV]")
            hExpMinusOneSigma.SetYTitle("N_{l} Mass [GeV]")
            hExpMinusOneSigma.SetZTitle(ztitle)
            hExpMinusOneSigma.GetYaxis().SetTitleOffset(2)
            hExpMinusOneSigma.GetZaxis().SetTitleOffset(1.7)

        if hExpPlusOneSigma:
            hExpPlusOneSigma.Draw("colzsame")
            hExpPlusOneSigma.SetAxisRange(zrange[0], zrange[1], "Z")
            hExpPlusOneSigma.SetXTitle("W_{R} Mass [GeV]")
            hExpPlusOneSigma.SetYTitle("N_{l} Mass [GeV]")
            hExpPlusOneSigma.SetZTitle(ztitle)
            hExpPlusOneSigma.GetYaxis().SetTitleOffset(2)
            hExpPlusOneSigma.GetZaxis().SetTitleOffset(1.7)

        if hTwo:
            hTwo.Draw("colzsame")
            hTwo.SetAxisRange(zrange[0], zrange[1], "Z")
            hTwo.SetXTitle("W_{R} Mass [GeV]")
            hTwo.SetYTitle("N_{l} Mass [GeV]")
            hTwo.SetZTitle(ztitle)
            hTwo.GetYaxis().SetTitleOffset(2)
            hTwo.GetZaxis().SetTitleOffset(1.7)

        #set the legend box size
        #yw of 550 worked well when showing expected limit, observed limit, and expected +/- 1 sigma limit curves
        x1 = 900
        y1 = 4000
        xw = 1200
        yw = 200

        leg = ROOT.TLegend(x1, y1, x1 + xw, y1 + yw, "", "")
        if contExpMinusOneSigma and contExpPlusOneSigma:
            leg = ROOT.TLegend(x1, y1, x1 + xw, y1 + 3 * yw, "", "")

        if contOne:
            #draw kinematic region which cannot be probed, MNu > MWR, before any 2D limit curves
            #these two arrays define the four points of an area which will be colored yellow
            x = np.array([700, 4950, 700, 700], dtype=float)
            y = np.array([700, 4950, 4950, 700], dtype=float)

            #this is the area which cannot be excluded by this analysis, where MNu is greater than MWR
            area = ROOT.TPolyLine(4, x, y)
            area.SetFillColor(ROOT.kWhite)
            area.SetLineWidth(0)
            area.Draw("F")
            latex2 = ROOT.TLatex()
            latex2.SetTextSize(
                0.045
            )  #original value was 0.05 when X and Y axes extended to 4.0 TeV
            #specify the lower left corner in x, y coordinates
            latex2.DrawLatex(1400, 3600, "M_{N_{l}} > M_{W_{R}} ")

            #update style of expected limit line, then draw it
            contOne.SetLineStyle(7)  #small dashes
            contOne.SetLineColor(ROOT.kRed)
            contOne.SetLineWidth(3)
            contOne.Draw("Lsame")
            leg.AddEntry(contOne, "Expected", "l")
        #end if contOne

        if contExpMinusOneSigma:
            contExpMinusOneSigma.SetLineStyle(7)  #small dashes
            contExpMinusOneSigma.SetLineColor(ROOT.kViolet)
            contExpMinusOneSigma.SetLineWidth(3)
            contExpMinusOneSigma.Draw("Lsame")
            leg.AddEntry(contExpMinusOneSigma, "Expected-1#sigma", "l")
        #end if contExpMinusOneSigma

        if contExpPlusOneSigma:
            contExpPlusOneSigma.SetLineStyle(7)  #small dashes
            contExpPlusOneSigma.SetLineColor(ROOT.kGreen + 1)
            contExpPlusOneSigma.SetLineWidth(3)
            contExpPlusOneSigma.Draw("Lsame")
            leg.AddEntry(contExpPlusOneSigma, "Expected+1#sigma", "l")
        #end if contExpPlusOneSigma

        #draw contTwo, the observed limit contour, last
        if contTwo:
            contTwo.SetLineStyle(1)  #solid
            contTwo.SetLineColor(ROOT.kBlue)
            contTwo.SetLineWidth(3)
            contTwo.Draw("Lsame")
            leg.AddEntry(contTwo, "Observed", "l")
        #end if contTwo

        leg.SetTextFont(42)
        leg.SetTextSize(0.032)
        leg.SetFillStyle(0)
        leg.SetBorderSize(0)
        leg.Draw()

        latex = ROOT.TLatex()
        latex.SetNDC(True)
        latex.SetTextSize(0.03)
        latex.SetTextFont(42)
        latex.DrawLatex(0.62, 0.96, "35.9 fb^{-1} (13 TeV)")

        text = ROOT.TText(0.2, 0.96, "CMS Preliminary")
        text.SetNDC()
        text.SetTextFont(42)
        text.SetTextSize(0.03)
        text.Draw()
        c1.RedrawAxis()
        c1.SaveAs(filename + ".png")
        c1.SaveAs(filename + ".pdf")
        c1.SaveAs(filename + ".C")
Example #4
0
    def plot(self,
             filename,
             x_title="",
             y_title="",
             x_limits=(600, 6000),
             y_limits=(1e-3, 1e-1),
             leg_x=.55,
             leg_y=.66,
             SetLogx=False):
        customROOTstyle()
        #ROOT.gROOT.LoadMacro("scripts/tdrStyle.C")
        c1 = ROOT.TCanvas("c1", "c1", 800, 800)
        c1.SetTopMargin(0.05)
        c1.SetLeftMargin(0.15)
        c1.SetRightMargin(0.05)
        c1.SetBottomMargin(0.13)
        c1.SetTicks(1, 1)
        c1.SetLogy()
        if SetLogx:
            c1.SetLogx()

        mass_array = np.array(self.masses, dtype=float)
        expected_limit_array = np.array(self.medians, dtype=float)
        expected_limit_error_array = np.array(self.errors, dtype=float)
        onesig_array = np.array(self.plus1sig + self.min1sig[::-1] +
                                [self.plus1sig[0]],
                                dtype=float)
        twosig_array = np.array(self.plus2sig + self.min2sig[::-1] +
                                [self.plus2sig[0]],
                                dtype=float)
        mass_band_array = np.array(self.masses + self.masses[::-1] +
                                   [self.masses[0]],
                                   dtype=float)

        if self.theory:
            #expected_limit_array = np.array([ l*self.theory[mass] for mass, l in zip(mass_array, expected_limit_array)], dtype=float)
            #onesig_array         = np.array([ l*self.theory[mass] for mass, l in zip(mass_band_array, onesig_array)   ], dtype=float)
            #twosig_array         = np.array([ l*self.theory[mass] for mass, l in zip(mass_band_array, twosig_array)   ], dtype=float)
            expected_limit_array *= self.xs
            onesig_array *= self.xs
            twosig_array *= self.xs

        dummy = ROOT.TH1F("dummy", "", 30, x_limits[0], x_limits[1])
        dummy.SetMinimum(y_limits[0])
        dummy.SetMaximum(y_limits[1])
        dummy.SetStats(0)
        dummy.GetXaxis().SetNdivisions(507)
        dummy.GetXaxis().SetTitle(x_title)
        dummy.GetYaxis().SetLabelSize(.03)
        #dummy.GetYaxis().SetTitleSize(.038)
        dummy.GetYaxis().SetTitleOffset(1.25)
        dummy.GetYaxis().SetTitle(y_title)

        dummy.Draw("HIST")
        leg_w = .44
        leg_h = .21
        leg = ROOT.TLegend(leg_x, leg_y, leg_x + leg_w, leg_y + leg_h)
        latex = ROOT.TLatex(
            leg_x + 0.02, leg_y + 0.23,
            "M_{#scale[1.25]{N_{#scale[1.5]{#mu}}}}= M_{#scale[1.25]{W_{R}}}/2"
        )
        latex.SetNDC()
        latex.SetTextSize(0.032)
        latex.SetTextFont(42)
        latex.Draw()

        leg.SetTextFont(42)
        leg.SetTextSize(0.032)
        leg.SetFillStyle(0)
        leg.SetBorderSize(0)

        n = len(self.masses)

        g_twosig = ROOT.TGraph(n * 2 + 1, mass_band_array, twosig_array)
        g_twosig.SetFillColor(ROOT.kYellow)
        g_twosig.SetLineWidth(0)
        g_twosig.Draw("F SAME")

        g_onesig = ROOT.TGraph(n * 2 + 1, mass_band_array, onesig_array)
        g_onesig.SetFillColor(ROOT.kGreen)
        g_onesig.SetLineWidth(0)
        g_onesig.Draw("F SAME")

        g_exp = ROOT.TGraph(n, mass_array, expected_limit_array)
        g_exp.SetLineWidth(2)
        g_exp.SetLineColor(ROOT.kBlue)
        g_exp.SetLineStyle(2)
        g_exp.Draw("L SAME")

        if self.theory:
            ntheory = len(self.theory)
            theory_mass = np.array(sorted(self.theory.keys()), dtype=float)
            theory_limit = np.array(
                [self.theory[mass] for mass in theory_mass], dtype=float)
            print theory_limit
            g_theory = ROOT.TGraph(ntheory, theory_mass, theory_limit)
            g_theory.SetLineWidth(3)
            g_theory.SetLineColor(ROOT.kRed + 2)
            g_theory.SetLineStyle(0)
            g_theory.SetFillStyle(3002)
            g_theory.SetFillColor(ROOT.kRed)
            g_theory.Draw("LSAME")

        if self.observed:
            nobs = len(self.observed)
            observed_limit_array = np.array(self.observed, dtype=float)
            if self.theory:
                #observed_limit_array = np.array([ l*self.theory[mass] for mass, l in zip(mass_array, observed_limit_array)], dtype=float)
                observed_limit_array *= self.xs
            g_obs = ROOT.TGraph(nobs, mass_array, observed_limit_array)
            g_obs.SetLineWidth(3)
            g_obs.SetLineColor(ROOT.kBlue + 2)
            g_obs.SetLineStyle(0)
            g_obs.SetFillStyle(3002)
            g_obs.SetFillColor(ROOT.kBlue + 2)
            g_obs.Draw("L SAME")

        if self.observed:
            leg.AddEntry(g_obs, "Observed limit", "L")
        leg.AddEntry(g_exp, "Expected limit", "L")
        leg.AddEntry(g_onesig, "Expected #pm 1 #sigma", "F")
        leg.AddEntry(g_twosig, "Expected #pm 2 #sigma", "F")
        if self.theory:
            leg.AddEntry(g_theory, "Theory (g_{R}= g_{L})", "L")
        leg.Draw("same")

        text = ROOT.TText(0.17, 0.97, "CMS Preliminary")
        text.SetNDC()
        text.SetTextFont(42)
        text.SetTextSize(0.04)
        text.Draw()
        text2 = ROOT.TLatex(0.72, 0.97, "35.9 fb^{-1} (13 TeV)")
        text2.SetNDC()
        text2.SetTextFont(42)
        text2.SetTextSize(0.03)
        text2.Draw("same")

        c1.RedrawAxis()
        c1.SaveAs(filename + ".png")
        c1.SaveAs(filename + ".pdf")
        c1.SaveAs(filename + ".C")
Example #5
0
    def draw(self, h, filename, zrange, ztitle, logz=False, cont=None):
        customROOTstyle()
        ROOT.gStyle.SetOptTitle(0)

        c1 = ROOT.TCanvas("c1", "c1", 800, 800)
        c1.SetTopMargin(0.05)
        c1.SetLeftMargin(0.2)
        c1.SetRightMargin(0.2)
        c1.SetBottomMargin(0.13)
        c1.SetTicks(1, 1)
        #c1.SetLogz()

        c1.SetLogz(logz)
        h.Draw("colz")
        h.SetAxisRange(zrange[0], zrange[1], "Z")
        h.SetXTitle("W_{R} Mass [GeV]")
        h.SetYTitle("N_{l} Mass [GeV]")
        h.SetZTitle(ztitle)
        h.GetYaxis().SetTitleOffset(2)
        h.GetZaxis().SetTitleOffset(1.7)

        if cont:
            x = np.array([700, 4050, 700, 700], dtype=float)
            y = np.array([700, 4050, 4050, 700], dtype=float)
            area = ROOT.TPolyLine(4, x, y)
            area.SetFillColor(ROOT.kYellow)
            area.SetLineWidth(0)
            area.Draw("F")
            latex2 = ROOT.TLatex()
            latex2.SetTextSize(0.05)
            latex2.DrawLatex(1400, 3200, "M_{N_{l}} > M_{W_{R}} ")
            cont.Draw("L")

            x1 = 900
            y1 = 3700
            xw = 1200
            yw = 200

            leg = ROOT.TLegend(x1, y1, x1 + xw, y1 + yw, "", "")
            leg.AddEntry(cont, "Expected", "l")
            leg.SetTextFont(42)
            leg.SetTextSize(0.032)
            leg.SetFillStyle(0)
            leg.SetBorderSize(0)

            leg.Draw()

        latex = ROOT.TLatex()
        latex.SetNDC(True)
        latex.SetTextSize(0.03)
        latex.SetTextFont(42)
        latex.DrawLatex(0.62, 0.96, "2.64 fb^{-1} (13 TeV)")

        text = ROOT.TText(0.2, 0.96, "CMS Preliminary")
        text.SetNDC()
        text.SetTextFont(42)
        text.SetTextSize(0.03)
        text.Draw()
        c1.RedrawAxis()
        c1.SaveAs(filename + ".png")
        c1.SaveAs(filename + ".pdf")
        c1.SaveAs(filename + ".C")