Ejemplo n.º 1
0
def plotTurnOnData(datasets,
                   name,
                   pathAll,
                   pathPassed1,
                   pathPassed2,
                   dataText1,
                   dataText2,
                   rebin=1,
                   ratio=False):
    dataLabel1 = "Data: " + dataText1
    dataLabel2 = "Data: " + dataText2

    dataset = datasets.getDataset("Data")
    all = dataset.getDatasetRootHisto(pathAll).getHistogram()
    passed1 = dataset.getDatasetRootHisto(pathPassed1).getHistogram()
    passed2 = dataset.getDatasetRootHisto(pathPassed2).getHistogram()

    data_eff_gr1 = ROOT.TGraphAsymmErrors(passed1, all,
                                          "cp")  # 0.683 cl is default
    data_eff_gr2 = ROOT.TGraphAsymmErrors(passed2, all,
                                          "cp")  # 0.683 cl is default

    p = plots.ComparisonPlot(
        histograms.HistoGraph(data_eff_gr1, "Data1", "p", "P"),
        histograms.HistoGraph(data_eff_gr2, "Data2", "p", "P"))
    p.histoMgr.forEachHisto(
        styles.generator2(styles.StyleMarker(markerSizes=[1.0, 2.0]),
                          [styles.dataStyle, styles.mcStyle2]))
    p.histoMgr.setHistoLegendLabelMany({
        "Data1": dataLabel1,
        "Data2": dataLabel2,
    })
    p.setLuminosity(dataset.getLuminosity())

    opts = {"ymin": 0.0, "ymax": 1.1}
    #opts2 = {"ymin": 0.5, "ymax": 1.5}
    opts2 = {"ymin": 0.8, "ymax": 1.2}

    name = "calomet_turnon_" + runs + "_data_" + name
    p.createFrame(name,
                  createRatio=ratio,
                  invertRatio=True,
                  opts=opts,
                  opts2=opts2)
    if ratio:
        p.getFrame2().GetYaxis().SetTitle("Ratio")

    p.setLegend(
        histograms.moveLegend(
            histograms.createLegend(y1=0.95, y2=0.85),
            #dx=-0.55, dy=-0.05
            dx=-0.44,
            dy=-0.58))

    common(p, "Uncorrected PF E_{T}^{miss} (GeV)", "Efficiency")
Ejemplo n.º 2
0
def addConfigInfo(of, dataset):
    d = of.mkdir("configInfo")
    d.cd()

    # configinfo histogram
    configinfo = ROOT.TH1F("configinfo", "configinfo", 3, 0, 3)
    axis = configinfo.GetXaxis()

    def setValue(bin, name, value):
        axis.SetBinLabel(bin, name)
        configinfo.SetBinContent(bin, value)

    setValue(1, "control", 1)
    if dataset.isData():
        setValue(2, "luminosity", dataset.getLuminosity())
        setValue(3, "isData", 1)
    elif dataset.isMC():
        setValue(2, "crossSection", dataset.getCrossSection())
        setValue(3, "isData", 0)

    configinfo.Write()
    configinfo.Delete()

    # dataVersion
    ds = dataset
    if dataset.isData():
        ds = dataset.datasets[0]

    dataVersion = ROOT.TNamed("dataVersion", ds.dataVersion)
    dataVersion.Write()
    dataVersion.Delete()

    # codeVersion
    codeVersion = ROOT.TNamed("codeVersion", git.getCommitId())
    codeVersion.Write()
    codeVersion.Delete()

    of.cd()
def addConfigInfo(of, dataset):
    d = of.mkdir("configInfo")
    d.cd()

    # configinfo histogram
    configinfo = ROOT.TH1F("configinfo", "configinfo", 3, 0, 3)
    axis = configinfo.GetXaxis()

    def setValue(bin, name, value):
        axis.SetBinLabel(bin, name)
        configinfo.SetBinContent(bin, value)

    setValue(1, "control", 1)
    if dataset.isData():
        setValue(2, "luminosity", dataset.getLuminosity())
        setValue(3, "isData", 1)
    elif dataset.isMC():
        setValue(2, "crossSection", dataset.getCrossSection())
        setValue(3, "isData", 0)

    configinfo.Write()
    configinfo.Delete()

    # dataVersion
    ds = dataset
    if dataset.isData():
        ds = dataset.datasets[0]

    dataVersion = ROOT.TNamed("dataVersion", ds.dataVersion)
    dataVersion.Write()
    dataVersion.Delete()

    # codeVersion
    codeVersion = ROOT.TNamed("codeVersion", git.getCommitId())
    codeVersion.Write()
    codeVersion.Delete()

    of.cd()
Ejemplo n.º 4
0
def plotTurnOnData(datasets, name, pathAll, pathPassed1, pathPassed2, dataText1, dataText2, rebin=1, ratio=False):
    dataLabel1 = "Data: "+dataText1
    dataLabel2 = "Data: "+dataText2

    dataset = datasets.getDataset("Data")
    all = dataset.getDatasetRootHisto(pathAll).getHistogram()
    passed1 = dataset.getDatasetRootHisto(pathPassed1).getHistogram()
    passed2 = dataset.getDatasetRootHisto(pathPassed2).getHistogram()

    data_eff_gr1 = ROOT.TGraphAsymmErrors(passed1, all, "cp") # 0.683 cl is default
    data_eff_gr2 = ROOT.TGraphAsymmErrors(passed2, all, "cp") # 0.683 cl is default

    p = plots.ComparisonPlot(
        histograms.HistoGraph(data_eff_gr1, "Data1", "p", "P"),
        histograms.HistoGraph(data_eff_gr2, "Data2", "p", "P")
        )
    p.histoMgr.forEachHisto(styles.generator2(styles.StyleMarker(markerSizes=[1.0, 2.0]), [styles.dataStyle, styles.mcStyle2]))
    p.histoMgr.setHistoLegendLabelMany({
            "Data1": dataLabel1,
            "Data2": dataLabel2,
            })
    p.setLuminosity(dataset.getLuminosity())

    opts = {"ymin": 0.0, "ymax": 1.1}
    #opts2 = {"ymin": 0.5, "ymax": 1.5}
    opts2 = {"ymin": 0.8, "ymax": 1.2}

    name = "calomet_turnon_"+runs+"_data_"+name
    p.createFrame(name, createRatio=ratio, invertRatio=True, opts=opts, opts2=opts2)
    if ratio:
        p.getFrame2().GetYaxis().SetTitle("Ratio")

    p.setLegend(histograms.moveLegend(histograms.createLegend(y1=0.95, y2=0.85),
                                      #dx=-0.55, dy=-0.05
                                      dx=-0.44, dy=-0.58
                                      ))

    common(p, "Uncorrected PF E_{T}^{miss} (GeV)", "Efficiency")
Ejemplo n.º 5
0
def plotTurnOn(datasets,
               pathAll,
               pathPassed,
               commonText,
               dataText=None,
               mcText=None,
               rebin=1,
               ratio=False):
    dataLabel = "Data"
    mcLabel = "Simulation"
    if dataText != None and mcText == None:
        raise Exception("mcText must not be None when dataText is not")
    if dataText == None and mcText != None:
        raise Exception("dataText must not be None when mcText is not")


#    if dataText != None:
#        dataLabel += ": "+dataText
#        mcLabel += ": "+mcText

    mc_effs = []
    data_eff_gr = None
    binWidth = None
    luminosity = 0
    for dataset in datasets.getAllDatasets():
        all = dataset.getDatasetRootHisto(pathAll).getHistogram()
        passed = dataset.getDatasetRootHisto(pathPassed).getHistogram()

        if rebin > 1:
            all.Rebin(rebin)
            passed.Rebin(rebin)
        binWidth = all.GetBinWidth(1)

        if dataset.isMC() and not "TTTo" in dataset.getName():
            #if dataset.isMC() and not "TTTo" in dataset.getName() and not "QCD" in dataset.getName():
            #if dataset.isMC() and "QCD" in dataset.getName():
            mc_effs.append(HistoEff(all, passed, dataset))

        elif dataset.isData():
            data_eff_gr = ROOT.TGraphAsymmErrors(passed, all,
                                                 "cp")  # 0.683 cl is default
            luminosity += dataset.getLuminosity()

    mc_eff_gr = combineHistoEffs(mc_effs)

    p = plots.ComparisonPlot(
        histograms.HistoGraph(data_eff_gr, "Data", "p", "P"),
        histograms.HistoGraph(mc_eff_gr, "Simulation", "p", "P"))
    p.histoMgr.forEachHisto(
        styles.generator2(styles.StyleMarker(markerSizes=[1.0, 1.5]),
                          plotStyles))
    p.histoMgr.setHistoLegendLabelMany({
        "Data": dataLabel,
        "Simulation": mcLabel,
    })
    p.setLuminosity(luminosity)
    #p.addGraph(data_eff_gr, "Data")
    #p.addGraph(mc_eff_gr, "Simulation")
    #p.finalize()

    opts = {"ymin": 0.0, "ymax": 1.1}
    #opts2 = {"ymin": 0.5, "ymax": 1.5}
    opts2 = {"ymin": 0.7, "ymax": 1.3}

    name = "calomet_turnon_" + runs
    if not mcDataDefinition:
        name += "_McSummer11"
    if caloMetNoHF:
        name += "_caloMetNoHF"

    p.createFrame(name, createRatio=ratio, opts=opts, opts2=opts2)
    if ratio:
        p.getFrame2().GetYaxis().SetTitle("Ratio")
        p.cf.canvas.cd(2)
        p.line1 = plots._createRatioLine(p.cf.frame.getXmin(),
                                         p.cf.frame.getXmax(), 0.9)
        p.line2 = plots._createRatioLine(p.cf.frame.getXmin(),
                                         p.cf.frame.getXmax(), 1.1)
        p.line1.SetLineColor(ROOT.kBlue)
        p.line2.SetLineColor(ROOT.kBlue)
        p.line1.Draw("L")
        p.line2.Draw("L")
        p.cf.canvas.cd(1)

    p.setLegend(
        histograms.moveLegend(
            histograms.createLegend(y1=0.95, y2=0.85),
            #dx=-0.55, dy=-0.05
            #dx=-0.44, dy=-0.58
            dx=-0.3,
            dy=-0.4))

    x = 0.25
    y = 0.3
    dy = 0.035
    mcColor = mc_eff_gr.GetMarkerColor()
    size = 17
    p.appendPlotObject(
        histograms.PlotText(x, y, "Data (runs %s):" % runs, size=size))
    y -= dy
    p.appendPlotObject(histograms.PlotText(x, y, dataText, size=size))
    y -= dy

    y -= 0.01
    p.appendPlotObject(
        histograms.PlotText(x, y, "Simulation:", size=size, color=mcColor))
    y -= dy
    p.appendPlotObject(
        histograms.PlotText(x, y, mcText, size=size, color=mcColor))
    y -= dy

    def text():
        l = ROOT.TLatex()
        l.SetNDC()
        #        l.SetTextFont(l.GetTextFont()-20) # bold -> normal
        l.SetTextSize(l.GetTextSize() * 0.65)
        #l.DrawLatex(0.35, 0.4, commonText)
        l.DrawLatex(0.48, 0.32, commonText)

    textFunction = text
    if dataText != None:
        textFunction = None
    #common(p, "PF E_{T}^{miss} (GeV)", "Efficiency / %.0f GeV"%binWidth, afterDraw=textFunction)
    common(p,
           "Uncorrected PF E_{T}^{miss} (GeV)",
           "Efficiency",
           afterDraw=textFunction)
Ejemplo n.º 6
0
def plotTurnOn(datasets, pathAll, pathPassed, commonText, dataText=None, mcText=None, rebin=1, ratio=False):
    dataLabel = "Data"
    mcLabel = "Simulation"
    if dataText != None and mcText == None:
        raise Exception("mcText must not be None when dataText is not")
    if dataText == None and mcText != None:
        raise Exception("dataText must not be None when mcText is not")
#    if dataText != None:
#        dataLabel += ": "+dataText
#        mcLabel += ": "+mcText

    mc_effs = []
    data_eff_gr = None
    binWidth = None
    luminosity = 0
    for dataset in datasets.getAllDatasets():
        all = dataset.getDatasetRootHisto(pathAll).getHistogram()
        passed = dataset.getDatasetRootHisto(pathPassed).getHistogram()

        if rebin > 1:
            all.Rebin(rebin)
            passed.Rebin(rebin)
        binWidth = all.GetBinWidth(1)

        if dataset.isMC() and not "TTTo" in dataset.getName():
        #if dataset.isMC() and not "TTTo" in dataset.getName() and not "QCD" in dataset.getName():
        #if dataset.isMC() and "QCD" in dataset.getName():
            mc_effs.append(HistoEff(all, passed, dataset))

        elif dataset.isData():
            data_eff_gr = ROOT.TGraphAsymmErrors(passed, all, "cp") # 0.683 cl is default
            luminosity += dataset.getLuminosity()

    mc_eff_gr = combineHistoEffs(mc_effs)

    p = plots.ComparisonPlot(
        histograms.HistoGraph(data_eff_gr, "Data", "p", "P"),
        histograms.HistoGraph(mc_eff_gr, "Simulation", "p", "P")
        )
    p.histoMgr.forEachHisto(styles.generator2(styles.StyleMarker(markerSizes=[1.0, 1.5]), plotStyles))
    p.histoMgr.setHistoLegendLabelMany({
            "Data": dataLabel,
            "Simulation": mcLabel,
            })
    p.setLuminosity(luminosity)
    #p.addGraph(data_eff_gr, "Data")
    #p.addGraph(mc_eff_gr, "Simulation")
    #p.finalize()

    opts = {"ymin": 0.0, "ymax": 1.1}
    #opts2 = {"ymin": 0.5, "ymax": 1.5}
    opts2 = {"ymin": 0.7, "ymax": 1.3}

    name = "calomet_turnon_"+runs
    if not mcDataDefinition:
        name += "_McSummer11"
    if caloMetNoHF:
        name += "_caloMetNoHF"
    
    p.createFrame(name, createRatio=ratio, opts=opts, opts2=opts2)
    if ratio:
        p.getFrame2().GetYaxis().SetTitle("Data / MC")
        p.cf.canvas.cd(2)
        p.line1 = plots._createRatioLine(p.cf.frame.getXmin(), p.cf.frame.getXmax(), 0.9)
        p.line2 = plots._createRatioLine(p.cf.frame.getXmin(), p.cf.frame.getXmax(), 1.1)
        p.line1.SetLineColor(ROOT.kBlue)
        p.line2.SetLineColor(ROOT.kBlue)
        p.line1.Draw("L")
        p.line2.Draw("L")
        p.cf.canvas.cd(1)

    p.setLegend(histograms.moveLegend(histograms.createLegend(y1=0.95, y2=0.85),
                                      #dx=-0.55, dy=-0.05
                                      #dx=-0.44, dy=-0.58
                                      dx=-0.3, dy=-0.4
                                      ))

    x = 0.25
    y = 0.3
    dy = 0.035
    mcColor = mc_eff_gr.GetMarkerColor()
    size = 17
    p.appendPlotObject(histograms.PlotText(x, y, "Data (runs %s):"%runs, size=size)); y -= dy
    p.appendPlotObject(histograms.PlotText(x, y, dataText, size=size)); y -= dy

    y -= 0.01
    p.appendPlotObject(histograms.PlotText(x, y, "Simulation:", size=size, color=mcColor)); y -= dy
    p.appendPlotObject(histograms.PlotText(x, y, mcText, size=size, color=mcColor)); y -= dy
                       


    def text():
        l = ROOT.TLatex()
        l.SetNDC()
#        l.SetTextFont(l.GetTextFont()-20) # bold -> normal
        l.SetTextSize(l.GetTextSize()*0.65)
        #l.DrawLatex(0.35, 0.4, commonText)
        l.DrawLatex(0.48, 0.32, commonText)
    textFunction = text
    if dataText != None:
        textFunction = None
    #common(p, "PF E_{T}^{miss} (GeV)", "Efficiency / %.0f GeV"%binWidth, afterDraw=textFunction)
    common(p, "Uncorrected PF E_{T}^{miss} (GeV)", "Efficiency", afterDraw=textFunction)