Example #1
0
def load_joeys_style():
    from ROOT import gStyle, gROOT
    font_id = 12
    gStyle.SetOptStat(0)
    gStyle.SetTitleFont(font_id, "X") # LaTeX typeface
    gStyle.SetTitleFont(font_id, "Y")
    gStyle.SetTitleFont(font_id, "Z")
    gStyle.SetTitleFont(font_id, "T")
    gStyle.SetLabelFont(font_id, "X") # LaTeX typeface
    gStyle.SetLabelFont(font_id, "Y")
    gStyle.SetLabelFont(font_id, "Z")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadTopMargin(0.13)
    gStyle.SetPadBottomMargin(0.25)
    gStyle.SetPadLeftMargin(0.17)
    gStyle.SetPadRightMargin(0.25)
    gStyle.SetCanvasDefW(1500)
    gStyle.SetCanvasDefH(900)
    gStyle.SetTitleSize(0.06,"X")
    gStyle.SetTitleSize(0.06,"Y")
    gStyle.SetTitleSize(0.06,"Z")
    gStyle.SetTitleSize(0.06,"T") # for title
    gStyle.SetLabelSize(0.04,"X")
    gStyle.SetLabelSize(0.04,"Y")
    gStyle.SetLabelSize(0.04,"Z")
    gStyle.SetTitleOffset(1.5,"X")
    gStyle.SetTitleOffset(1.1,"Y")
    gStyle.SetTitleOffset(1.3,"Z")
    gROOT.ForceStyle()
Example #2
0
def SetStyle():
    gROOT.SetStyle('Plain')
    gROOT.ForceStyle()
    gStyle.SetTextFont(42)

    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(1112)
    gStyle.SetOptStat(1110)

    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadTopMargin(0.11)
    gStyle.SetPadBottomMargin(0.12)

    gStyle.SetTitleFont(42, 'x')
    gStyle.SetTitleFont(42, 'y')
    gStyle.SetTitleFont(42, 'z')

    gStyle.SetTitleOffset(1.05, 'x')
    gStyle.SetTitleOffset(1.00, 'y')

    gStyle.SetTitleSize(0.05, 'x')
    gStyle.SetTitleSize(0.05, 'y')
    gStyle.SetTitleSize(0.05, 'z')

    gStyle.SetLabelFont(42, 'x')
    gStyle.SetLabelFont(42, 'y')
    gStyle.SetLabelFont(42, 'z')

    gStyle.SetLabelSize(0.05, 'x')
    gStyle.SetLabelSize(0.05, 'y')
    gStyle.SetLabelSize(0.05, 'z')

    TGaxis.SetMaxDigits(3)
    gStyle.SetStatY(0.9)
Example #3
0
    def Init():
        from ROOT import gStyle
        from ROOT import gROOT

        gROOT.ProcessLine("gErrorIgnoreLevel = 2000;")
        gStyle.SetCanvasColor(0);
        gStyle.SetCanvasBorderMode(0);
        gStyle.SetCanvasBorderSize(3);

        gStyle.SetPadLeftMargin(0.125);
        gStyle.SetPadBottomMargin(0.12);
        gStyle.SetPadColor(0);
        gStyle.SetPadBorderMode(0);

        gStyle.SetFrameBorderMode(0);
        gStyle.SetFrameBorderSize(0);
        gStyle.SetFrameFillColor(0);
        gStyle.SetOptStat(0);

        gStyle.SetLabelOffset(0.005,"X");
        gStyle.SetLabelSize(0.03,"X");
        gStyle.SetLabelFont(42,"X");

        gStyle.SetTitleOffset(.85,"X");
        gStyle.SetTitleSize(0.04,"X");
        gStyle.SetTitleFont(42,"X");

        gStyle.SetLabelOffset(0.005,"Y");
        gStyle.SetLabelSize(0.03,"Y");
        gStyle.SetLabelFont(42,"Y");

        gStyle.SetTitleOffset(.98,"Y");
        gStyle.SetTitleSize(0.04,"Y");
        gStyle.SetTitleFont(42,"Y");

        gStyle.SetStatColor(0);
        gStyle.SetStatBorderSize(0);
        gStyle.SetTextFont(2);
        gStyle.SetTextSize(.05);
        gStyle.SetLegendBorderSize(1);
        gStyle.SetHistLineWidth(2);
        gStyle.SetTitleFillColor(0);
        gStyle.SetTitleFontSize(0.06);
        gStyle.SetTitleBorderSize(0);
        gStyle.SetTitleAlign(13);
        gStyle.SetTextAlign(22);

	#RJ
	gStyle.SetPadTickX(1);                         
	gStyle.SetPadTickY(1);  

        gStyle.SetPadTopMargin(0.05);
        gStyle.SetPadBottomMargin(0.13);
        gStyle.SetPadLeftMargin(0.16);
        gStyle.SetPadRightMargin(0.03);
Example #4
0
def looks():
    gROOT.ProcessLine('TGaxis::SetMaxDigits(3)')
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(0)
    gStyle.SetStatColor(0)
    gStyle.SetTitleFont(42, '')
    gStyle.SetLabelFont(42, 'x')
    gStyle.SetTitleFont(42, 'x')
    gStyle.SetLabelFont(42, 'y')
    gStyle.SetTitleFont(42, 'y')
    gStyle.SetLabelFont(42, 'z')
    gStyle.SetTitleFont(42, 'z')
    gStyle.SetLabelSize(0.048, 'x')
    gStyle.SetTitleSize(0.048, 'x')
    gStyle.SetLabelSize(0.048, 'y')
    gStyle.SetTitleSize(0.048, 'y')
    gStyle.SetLabelSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, 'z')
    gStyle.SetTitleSize(0.048, '')
    gStyle.SetTitleAlign(23)
    gStyle.SetTitleX(0.5)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleStyle(0)
    gStyle.SetOptStat('emr')
    gStyle.SetOptStat(0)
    gStyle.SetStatBorderSize(0)
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.048)
    gStyle.SetStatY(0.9)
    gStyle.SetStatX(0.86)
    gStyle.SetHistLineColor(ROOT.kBlue + 2)
    gStyle.SetLegendBorderSize(0)
    gStyle.SetLegendFillColor(0)
    gStyle.SetFuncWidth(2)
    gStyle.SetFuncColor(2)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetPadRightMargin(0.06)
    gStyle.SetCanvasDefX(400)
    gStyle.SetCanvasDefY(20)
    gStyle.SetCanvasDefH(420)
    gStyle.SetCanvasDefW(610)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetHistLineWidth(2)
    gStyle.SetTitleOffset(1.16, 'y')
    gStyle.SetTitleOffset(1.20, 'x')
Example #5
0
def set_pub_style():
    from ROOT import gStyle
    # No Canvas Border
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasBorderSize(0)
    # White BG
    gStyle.SetCanvasColor(10)
    # Format for axes
    gStyle.SetLabelFont(42, 'xyz')
    gStyle.SetLabelSize(0.05, 'xyz')
    gStyle.SetLabelOffset(0.01, 'xyz')
    # gStyle->SetNdivisions(510, 'xyz')
    gStyle.SetTitleFont(42, 'xyz')
    gStyle.SetTitleColor(1, 'xyz')
    gStyle.SetTitleSize(0.06, 'xyz')
    gStyle.SetTitleOffset(1.25, 'xyz')
    # No pad borders
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBorderSize(0)
    # White BG
    gStyle.SetPadColor(10)
    # Margins for labels etc.
    gStyle.SetPadLeftMargin(0.155)
    gStyle.SetPadBottomMargin(0.155)
    gStyle.SetPadRightMargin(0.15)
    gStyle.SetPadTopMargin(0.1)
    # No error bars in x direction
    gStyle.SetErrorX(0)
    # Format legend
    gStyle.SetLegendBorderSize(0)
Example #6
0
def setStyle():
    gROOT.Reset()
    icol = 0
    # WHITE
    font = 42
    # Helvetica
    tsize = 0.05
    gStyle.SetFrameBorderMode(icol)
    gStyle.SetFrameFillColor(icol)
    gStyle.SetCanvasBorderMode(icol)
    gStyle.SetCanvasColor(icol)
    gStyle.SetPadBorderMode(icol)
    gStyle.SetPadColor(icol)
    gStyle.SetStatColor(icol)
    gStyle.SetPaperSize(20, 26)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadBottomMargin(0.15)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetTitleXOffset(1.05)
    gStyle.SetTitleYOffset(0.95)
    gStyle.SetTextFont(font)
    gStyle.SetTextSize(tsize)
    gStyle.SetLabelFont(font, "x")
    gStyle.SetTitleFont(font, "x")
    gStyle.SetLabelFont(font, "y")
    gStyle.SetTitleFont(font, "y")
    gStyle.SetLabelFont(font, "z")
    gStyle.SetTitleFont(font, "z")
    gStyle.SetLabelSize(tsize * 0.85, "x")
    gStyle.SetTitleSize(tsize * 1.10, "x")
    gStyle.SetLabelSize(tsize * 0.85, "y")
    gStyle.SetTitleSize(tsize * 1.10, "y")
    gStyle.SetLabelSize(tsize * 0.85, "z")
    gStyle.SetTitleSize(tsize * 1.10, "z")
    gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerSize(1.)
    gStyle.SetHistLineWidth(2)
    gStyle.SetLineStyleString(2, "[12 12]")
    # postscript dashes
    gStyle.SetEndErrorSize(0.)
    # gStyle.SetOptTitle(0);
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPaintTextFormat("4.1f")
Example #7
0
def Styling():
    # Center title
    gStyle.SetTitleAlign(22)
    gStyle.SetTitleX(.5)
    gStyle.SetTitleY(.95)
    gStyle.SetTitleBorderSize(0)
    # Remove stats box
    gStyle.SetOptStat(0)
    # Set background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)
    # No colored frames around plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    # Set the default line color for a fit function to be red
    gStyle.SetFuncColor(2)
    # Marker settings
    gStyle.SetMarkerStyle(20)
    # No border on legends
    gStyle.SetLegendBorderSize(0)
    # Disabled for violating NOvA style guidelines
    # Scientific notation on axes
    TGaxis.SetMaxDigits(3)
    # Axis titles
    gStyle.SetTitleSize(.055, "xyz")
    gStyle.SetTitleOffset(2.2, "xyz")
    gStyle.SetTitleOffset(2.2, "y")
    gStyle.SetTitleSize(.05, "")
    gStyle.SetTitleOffset(2.2, "")
    # Axis labels (numbering)
    gStyle.SetLabelSize(.05, "xyz")
    gStyle.SetLabelOffset(.005, "xyz")
    # Thicker lines
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    # Set the number of tick marks
    gStyle.SetNdivisions(506, "xyz")
    # Set tick marks on all sides
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    # Fonts
    kNovaFont = 42
    gStyle.SetStatFont(kNovaFont)
    gStyle.SetLabelFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "xyz")
    gStyle.SetTitleFont(kNovaFont, "")
    # Apply same settings to titles
    gStyle.SetTextFont(kNovaFont)
    gStyle.SetLegendFont(kNovaFont)
Example #8
0
def setPlotStyle():
	gStyle.SetPadGridX(1)
	gStyle.SetPadGridY(1)
	gStyle.SetOptStat(1110)
	gStyle.SetLineWidth(2)
	gStyle.SetHistLineWidth(3)
	gStyle.SetPadTickX(1)
	gStyle.SetPadTickY(1)
	gStyle.SetTextFont(62)
	gStyle.SetLabelFont(62)
	gStyle.SetTitleFont(62)
	gStyle.SetLegendBorderSize(1)
	gStyle.SetLegendFont(62)
 def loadstyle2():
     gROOT.SetStyle("Plain")
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(0)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
     gStyle.SetTitleOffset(1.15, "y")
     gStyle.SetTitleFont(42, "xy")
     gStyle.SetLabelFont(42, "xy")
     gStyle.SetTitleSize(0.042, "xy")
     gStyle.SetLabelSize(0.035, "xy")
     gStyle.SetPadTickX(1)
     gStyle.SetPadTickY(1)
Example #10
0
def load_root_style():
    """
    Set more advanced ROOT style for histograms
    """
    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetTitleOffset(1.15, "y")
    gStyle.SetTitleFont(42, "xy")
    gStyle.SetLabelFont(42, "xy")
    gStyle.SetTitleSize(0.042, "xy")
    gStyle.SetLabelSize(0.035, "xy")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
Example #11
0
def SetPaperStyle():

    ## histograms lines
    gStyle.SetHistFillColor(0)
    gStyle.SetHistFillStyle(0)

    gStyle.SetHistLineColor(1)
    gStyle.SetHistLineStyle(0)
    gStyle.SetHistLineWidth(1)

    ## suppress plot titles and fit box
    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(0)

    ## axis settings
    gStyle.SetLabelFont(142, "xyz")
    gStyle.SetLabelSize(0.04, "xyz")

    gStyle.SetTitleFont(142, "xyz")
    gStyle.SetTitleOffset(1.2, "xyz")
    gStyle.SetTitleSize(0.05, "xyz")

    ## stat box
    gStyle.SetOptStat(0)  # suppress the stats box
Example #12
0
def draw_model_perf():
    gROOT.SetBatch()
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTextFont(42)
    gStyle.SetTitleFont(42)
    gStyle.SetLabelFont(42)
    gStyle.SetPalette(kDarkBodyRadiator)

    trees_dir = "/mnt/temp/mkabus/val-20201209/trees"
    suffix = "filter4_poo0_drop0.00_depth4_batch0_scaler0_useSCMean1_useSCFluc1_pred_doR1" \
             "_dophi0_doz0/"
    pdf_dir_90 = "%s/phi90_r17_z17_%s" % (trees_dir, suffix)
    pdf_dir_180 = "%s/phi180_r33_z33_%s" % (trees_dir, suffix)

    filename = "model_perf_90-180"
    file_formats = ["png"]  # "pdf" - lasts long

    nevs_90 = [10000, 18000]  # 5000
    nevs_180 = [10000, 18000]
    nevs = nevs_90 + nevs_180
    pdf_files_90 = [
        "%s/pdfmaps_nEv%d.root" % (pdf_dir_90, nev) for nev in nevs_90
    ]
    pdf_files_180 = [
        "%s/pdfmaps_nEv%d.root" % (pdf_dir_180, nev) for nev in nevs_180
    ]
    pdf_file_names = pdf_files_90 + pdf_files_180

    grans = [90, 90, 180, 180]

    colors = [kBlue, kOrange, kGreen, kRed]
    markers_list = [(kFullSquare, kOpenSquare), (kFullCircle, kOpenCircle),
                    (kFullTriangleUp, kOpenTriangleUp),
                    (kFullDiamond, kOpenDiamond)]

    var_name = "flucDistRDiff"
    y_vars = ["rmsd", "means"]
    y_vars_names = ["RMSE", "#mu"]
    # y_labels = ["#it{RMSE} (cm)", "Mean (cm)"]
    x_vars = ["rBinCenter", "fsector"]
    x_vars_short = ["r"]  #, "fsector"]
    x_labels = ["#it{r} (cm)", "fsector"]  # TODO: what units?

    # "r_rmsd": 33, 195.0, 245.5, 20, # 83.5, 254.5, 200,
    # "r_rmsd": "33, 83.5, 110, 200, 0.000, 0.06",
    hist_strs = {
        "r_rmsd": "33, 83.5, 245.5, 200, 0.000, 0.06",
        "fsector_rmsd": "90, -1.0, 19, 200, 0.00, 0.1",
        "r_means": "33, 83.5, 245.5, 200, -0.06, 0.06",
        "fsector_means": "90, -1.0, 19, 200, -0.07, 0.01",
        "r_rmsd_means": "33, 83.5, 245.5, 200, -0.06, 0.06"
    }

    date = datetime.date.today().strftime("%Y%m%d")

    # flucDistR_entries>50
    # deltaSCBinCenter>0.0121 && deltaSCBinCenter<0.0122
    # deltaSCBinCenter>0.020 && deltaSCBinCenter<0.023
    # rBinCenter > 200.0 && deltaSCBinCenter>0.04 && deltaSCBinCenter<0.057
    # deltaSCBinCenter > 0.06 && deltaSCBinCenter < 0.07
    delta_sc_str = "#int_{#it{r}, #it{#varphi}, #it{z}} " +\
                   "#frac{#it{#rho}_{SC} - #it{<#rho>}_{SC}}{#it{<#rho>}_{SC}}"
    cuts = {
        "deltaSC": {
            "r_lim": (0.05, 0.07),
            "fsector_lim": (0.00, 0.05),
            "desc": lambda x: "%.2f < %s < %.2f" % (x[0], delta_sc_str, x[1])
        },
        "z": {
            "r_lim": (0.0, 5.0),
            "fsector_lim": (0.0, 5.0),
            "desc": lambda x: "%.2f < #it{z} < %.2f cm" % x
        },
        "r": {
            "r_lim": (0.0, 110.0),
            "fsector_lim": (86.0, 86.1),
            "desc": lambda x: "%.2f cm < #it{r} < %.2f cm" % x
        },
        "fsector": {
            "r_lim": (9.00, 9.05),
            "fsector_lim": (0.0, 20.0),
            "desc": lambda x: "sector %d" % int(round(x[0]))
        },
        "phi": {
            "r_lim": (3.1, 2.9),
            "fsector_lim": (3.1, 2.9),
            "desc": lambda x: "%.2f < #it{#varphi} < %.2f" % x
        }
    }
    cut_fsector = "zBinCenter > %.2f && zBinCenter < %.2f" % cuts["z"]["fsector_lim"] +\
                  " && rBinCenter > %.2f && rBinCenter < %.2f" % cuts["r"]["fsector_lim"] +\
                  " && deltaSCBinCenter > %.2f && deltaSCBinCenter < %.2f" %\
                      cuts["deltaSC"]["fsector_lim"] +\
                  " && %s_rmsd > 0.0" % var_name
    cut_r = "zBinCenter > %.2f && zBinCenter < %.2f" % cuts["z"]["r_lim"] +\
            " && abs(phiBinCenter - %.1f) < %.1f" % cuts["phi"]["r_lim"] +\
            " && deltaSCBinCenter > %.2f && deltaSCBinCenter < %.2f" %\
                cuts["deltaSC"]["r_lim"] +\
            " && %s_rmsd > 0.0" % var_name
    cuts_list = [cut_r, cut_fsector]

    # for y_var, y_label in zip(y_vars, y_labels):
    y_label = "#it{RMSE} and #it{#mu} (cm)"
    canvas, leg = setup_canvas("perf_%s" % y_label)
    pdf_files = [
        TFile.Open(pdf_file_name, "read") for pdf_file_name in pdf_file_names
    ]
    trees = [pdf_file.Get("pdfmaps") for pdf_file in pdf_files]
    variables = zip(x_vars, x_vars_short, x_labels, cuts_list)
    for x_var, x_var_short, x_label, cut in variables:
        hist_str = hist_strs["%s_%s_%s" % (x_var_short, y_vars[0], y_vars[1])]
        hists = []
        styles = enumerate(zip(nevs, colors, markers_list, trees, grans))
        for ind, (nev, color, markers, tree, gran) in styles:
            tree.SetMarkerColor(color)
            tree.SetMarkerSize(2)
            gran_str = "180#times 33 #times 33" if gran == 180 else "90#times 17 #times 17"

            for y_ind, (y_var, y_var_name,
                        marker) in enumerate(zip(y_vars, y_vars_names,
                                                 markers)):
                tree.SetMarkerStyle(marker)
                hist_def = "th_%d_%d(%s)" % (ind, y_ind, hist_str)
                tree.Draw("%s_%s:%s>>%s" % (var_name, y_var, x_var, hist_def),
                          cut, "prof")
                hists.append(tree.GetHistogram())
                leg.AddEntry(hists[-1], "%s" % y_var_name, "P")
            leg.AddEntry("", "%d, %s" % (nev, gran_str), "")

        for hist in hists:
            setup_hist(x_label, y_label, hist)
            hist.SetMaximum(0.06)
            hist.SetMinimum(-0.06)
            hist.Draw("same")
        leg.Draw()
        #tex = add_alice_text()
        #tex.Draw()
        txt = add_cut_desc(cuts, x_var_short)
        txt.Draw()
        for ff in file_formats:
            canvas.SaveAs(
                "%s_%s_%s_%s_%s.%s" %
                (date, filename, x_var_short, y_vars[0], y_vars[1], ff))
    for pdf_file in pdf_files:
        pdf_file.Close()
Example #13
0
    c.Print("plots/"+c.GetName()+"_cdf.png")
    c.Clear()



if __name__ == '__main__' :
    gStyle.SetOptStat(0)
    gStyle.SetTitleFont(42, "p")
    gStyle.SetTitleColor(1)
    gStyle.SetTitleTextColor(1)
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)
    gStyle.SetTitleOffset(1.2, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")

    effFile = ROOT.TFile("egTriggerEff.root", "r")
    rateFile = ROOT.TFile("egTriggerRates.root", "r")
    eff = effFile.Get("analyzer/crystal_tree")
    rate = rateFile.Get("analyzer/crystal_tree")

    c = ROOT.TCanvas("canvas", "canvas", 1200, 600)

    c.SetName("hovere")
    c.SetTitle("H/E Value")
    # endcap: "22./x+0."
    drawCDFs(c, rate, eff, "cluster_hovere", "", "14/x+.05", 5)

    c.SetName("isolation")
    c.SetTitle("Isolation Value")
Example #14
0
def plot_hfptspectrum_ratios_comb(case_num, case_den, arraytype):

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleOffset(1.15, "y")
    gStyle.SetTitleFont(42, "xy")
    gStyle.SetLabelFont(42, "xy")
    gStyle.SetTitleSize(0.042, "xy")
    gStyle.SetLabelSize(0.035, "xy")
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    with open("data/database_ml_parameters_%s.yml" % case_num,
              'r') as param_config_num:
        data_param_num = yaml.load(param_config_num, Loader=yaml.FullLoader)

    with open("data/database_ml_parameters_%s.yml" % case_den,
              'r') as param_config_den:
        data_param_den = yaml.load(param_config_den, Loader=yaml.FullLoader)

    folder_plots_num = data_param_num[case_num]["analysis"][
        "dir_general_plots"]
    folder_plots_den = data_param_den[case_den]["analysis"][
        "dir_general_plots"]
    if not os.path.exists(folder_plots_num):
        print("creating folder ", folder_plots_num)
        os.makedirs(folder_plots_num)
    if not os.path.exists(folder_plots_den):
        print("creating folder ", folder_plots_den)
        os.makedirs(folder_plots_den)

    folder_num_allperiods = \
        data_param_num[case_num]["analysis"][arraytype[0]]["data"]["resultsallp"]
    folder_den_allperiods = \
        data_param_den[case_den]["analysis"][arraytype[0]]["data"]["resultsallp"]
    folder_num_triggered = \
        data_param_num[case_num]["analysis"][arraytype[1]]["data"]["resultsallp"]
    folder_den_triggered = \
        data_param_den[case_den]["analysis"][arraytype[1]]["data"]["resultsallp"]

    binsmin_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["sel_binmin2"]
    binsmax_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["sel_binmax2"]
    name_num = data_param_num[case_num]["analysis"][
        arraytype[0]]["latexnamemeson"]
    name_den = data_param_den[case_den]["analysis"][
        arraytype[0]]["latexnamemeson"]
    latexbin2var = data_param_num[case_num]["analysis"][
        arraytype[0]]["latexbin2var"]
    plotbinMB = data_param_num[case_num]["analysis"][arraytype[0]]["plotbin"]
    plotbinHM = data_param_num[case_num]["analysis"][arraytype[1]]["plotbin"]
    br_num = data_param_num[case_num]["ml"]["opt"]["BR"]
    br_den = data_param_den[case_den]["ml"]["opt"]["BR"]
    sigmav0_num = data_param_num[case_num]["analysis"]["sigmav0"]
    sigmav0_den = data_param_den[case_den]["analysis"]["sigmav0"]

    file_num_allperiods = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                     (folder_num_allperiods, case_num, arraytype[0]))
    file_den_allperiods = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                     (folder_den_allperiods, case_den, arraytype[0]))
    file_num_triggered = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                      (folder_num_triggered, case_num, arraytype[1]))
    file_den_triggered = TFile.Open("%s/finalcross%s%smulttot.root" % \
                                      (folder_den_triggered, case_den, arraytype[1]))

    if not file_num_allperiods or not file_num_triggered:
        print("---Warning: Issue with %s merged files. Meson ratio plot skipped (%s, %s)---" % \
                 (case_num, arraytype[0], arraytype[1]))
        return
    if not file_den_allperiods or not file_den_triggered:
        print("---Warning: Issue with %s merged files. Meson ratio plot skipped (%s, %s)---" % \
                 (case_den, arraytype[0], arraytype[1]))
        return

    rootfilename = "%s/ComparisonRatios_%s%s_%scombined%s.root" % \
                     (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1])
    fileoutput = TFile.Open(rootfilename, "recreate")

    ccross = TCanvas('cRatioCross', 'The Fit Canvas')
    ccross.SetCanvasSize(1500, 1500)
    ccross.SetWindowSize(500, 500)
    maxplot = 1.0
    if case_num == "Dspp":
        maxplot = 0.5
    ccross.cd(1).DrawFrame(0.9, 0, 30, maxplot, ";#it{p}_{T} (GeV/#it{c});%s / %s" % \
                           (name_num, name_den))
    ccross.cd(1).SetLogx()

    legyield = TLegend(.4, .68, .8, .88)
    legyield.SetBorderSize(0)
    legyield.SetFillColor(0)
    legyield.SetFillStyle(0)
    legyield.SetTextFont(42)
    legyield.SetTextSize(0.025)

    colors = [kBlack, kRed, kGreen + 2, kBlue]
    for imult, iplot in enumerate(plotbinMB):
        if not iplot:
            continue
        hratio = file_num_allperiods.Get("histoSigmaCorr%d" % (imult))
        hratio.Scale(1. / (br_num * sigmav0_num * 1e12))
        hcross_den = file_den_allperiods.Get("histoSigmaCorr%d" % (imult))
        hcross_den.Scale(1. / (br_den * sigmav0_den * 1e12))
        hratio.Divide(hcross_den)
        hratio.SetLineColor(colors[imult % len(colors)])
        hratio.SetMarkerColor(colors[imult % len(colors)])
        hratio.SetMarkerStyle(21)
        hratio.SetTitle(";#it{p}_{T} (GeV/#it{c});%s / %s" %
                        (name_num, name_den))
        hratio.Draw("same")
        legyieldstring = "%.1f #leq %s < %.1f (MB)" % \
                    (binsmin_num[imult], latexbin2var, binsmax_num[imult])
        legyield.AddEntry(hratio, legyieldstring, "LEP")
        fileoutput.cd()
        hratio.Write("hratio_fromMB_%.1f_%s_%.1f" % \
                          (binsmin_num[imult], latexbin2var, binsmax_num[imult]))

    for imult, iplot in enumerate(plotbinHM):
        if not iplot:
            continue
        hratioHM = file_num_triggered.Get("histoSigmaCorr%d" % (imult))
        hratioHM.Scale(1. / (br_num * sigmav0_num * 1e12))
        hcrossHM_den = file_den_triggered.Get("histoSigmaCorr%d" % (imult))
        hcrossHM_den.Scale(1. / (br_den * sigmav0_den * 1e12))
        hratioHM.Divide(hcrossHM_den)
        hratioHM.SetLineColor(colors[imult % len(colors)])
        hratioHM.SetMarkerColor(colors[imult % len(colors)])
        hratioHM.SetTitle(";#it{p}_{T} (GeV/#it{c});%s / %s" %
                          (name_num, name_den))
        hratioHM.Draw("same")
        legyieldstring = "%.1f #leq %s < %.1f (HM)" % \
                (binsmin_num[imult], latexbin2var, binsmax_num[imult])
        legyield.AddEntry(hratioHM, legyieldstring, "LEP")
        fileoutput.cd()
        hratioHM.Write("hratio_fromHM_%.1f_%s_%.1f" % \
                          (binsmin_num[imult], latexbin2var, binsmax_num[imult]))
    legyield.Draw()

    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s_logx.eps" % \
                  (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1]))
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s_logx.eps" % \
                  (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1]))

    ccross.cd(1).SetLogx(0)
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s.eps" % \
                  (folder_plots_num, case_num, case_den, arraytype[0], arraytype[1]))
    ccross.SaveAs("%s/PtSpec_ComparisonRatios_%s%s_%scombined%s.eps" % \
                  (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1]))

    fileoutput.cd()
    ccross.Write()
    fileoutput.Close()

    rootfilenameden = "%s/ComparisonRatios_%s%s_%scombined%s.root" % \
                        (folder_plots_den, case_num, case_den, arraytype[0], arraytype[1])
    copyfile(rootfilename, rootfilenameden)
    print("---Output stored in:", rootfilename, "and", rootfilenameden, "---")
Example #15
0
def setStyle():
    TColor.InitializeColors()
    stops = array('d', [
        0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000
    ])
    red = array('d', [
        0.9764, 0.9956, 0.8186, 0.5301, 0.1802, 0.0232, 0.0780, 0.0592, 0.2082
    ])
    green = array('d', [
        0.9832, 0.7862, 0.7328, 0.7492, 0.7178, 0.6419, 0.5041, 0.3599, 0.1664
    ])
    blue = array('d', [
        0.0539, 0.1968, 0.3499, 0.4662, 0.6425, 0.7914, 0.8385, 0.8684, 0.5293
    ])
    TColor.CreateGradientColorTable(9, stops, red, green, blue, 255, 1.0)
    gStyle.SetHatchesLineWidth(1)
    gStyle.SetNumberContours(255)
    gStyle.SetNdivisions(505, "xyz")
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleColor(1)
    gStyle.SetTitleStyle(3013)
    gStyle.SetTitleFillColor(0)
    gStyle.SetTitleX(0.05)
    gStyle.SetTitleW(0.4)
    gStyle.SetTitleY(0.965)
    gStyle.SetTitleH(0.065)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasBorderSize(3)
    gStyle.SetCanvasColor(0)
    gStyle.SetPadColor(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetFuncWidth(3)
    gStyle.SetPadGridY(False)
    gStyle.SetPadGridX(False)
    gStyle.SetFrameLineWidth(1)
    gStyle.SetMarkerSize(5)
    gStyle.SetPadTickX(True)
    gStyle.SetPadTickY(True)
    #gStyle.SetPalette(1)
    gStyle.SetHistLineWidth(3)
    gStyle.SetHistLineColor(1)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetStatW(0.25)
    gStyle.SetStatH(0.25)
    gStyle.SetStatX(0.9)
    gStyle.SetStatY(0.9)
    gStyle.SetStatColor(0)
    gStyle.SetStatFormat("6.4g")
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadBottomMargin(0.16)
    gStyle.SetPadLeftMargin(0.12)
    font = 42
    gStyle.SetTextSize(.055)

    gStyle.SetTextFont(font)
    gStyle.SetLabelFont(font, "x")
    gStyle.SetTitleFont(font, "x")
    gStyle.SetLabelFont(font, "y")
    gStyle.SetTitleFont(font, "y")
    gStyle.SetLabelFont(font, "z")
    gStyle.SetTitleFont(font, "z")

    gStyle.SetTitleSize(.055, "x")
    gStyle.SetTitleSize(.055, "y")
    gStyle.SetTitleSize(.05, "z")
    gStyle.SetLabelSize(.05, "x")
    gStyle.SetLabelSize(.05, "y")
    gStyle.SetLabelSize(.05, "z")
    gStyle.SetLabelOffset(0.014, "x")
    gStyle.SetLabelOffset(0.006, "y")
    gStyle.SetLabelOffset(0.008, "z")
    gStyle.SetTitleOffset(1, "y")
    gStyle.SetTitleXOffset(1.2)

    # use bold lines and markers
    gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerColor(1)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetLineStyleString(2, "[12 12]")
    # postscript dashes

    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
Example #16
0
    def initStyle():
        gROOT.SetStyle("Plain")

        # For the canvas:
        gStyle.SetCanvasBorderMode(0)
        gStyle.SetCanvasColor(kWhite)
        gStyle.SetCanvasDefH(700)  #Height of canvas
        gStyle.SetCanvasDefW(700)  #Width of canvas
        gStyle.SetCanvasDefX(0)  #Position on screen
        gStyle.SetCanvasDefY(0)

        # For the line:
        gStyle.SetLineWidth(2)

        # For the Pad:
        gStyle.SetPadBorderMode(0)
        # gStyle.SetPadBorderSize(Width_t size = 1)
        gStyle.SetPadColor(kWhite)
        gStyle.SetPadGridX(True)
        gStyle.SetPadGridY(True)
        gStyle.SetGridColor(0)
        gStyle.SetGridStyle(3)
        gStyle.SetGridWidth(1)

        # For the frame:
        gStyle.SetFrameBorderMode(0)
        gStyle.SetFrameBorderSize(1)
        gStyle.SetFrameFillColor(0)
        gStyle.SetFrameFillStyle(0)
        gStyle.SetFrameLineColor(1)
        gStyle.SetFrameLineStyle(1)
        gStyle.SetFrameLineWidth(1)

        # For the histo:
        # gStyle.SetHistFillColor(1)
        # gStyle.SetHistFillStyle(0)
        gStyle.SetHistLineColor(1)
        gStyle.SetHistLineStyle(0)
        gStyle.SetHistLineWidth(2)
        # gStyle.SetLegoInnerR(Float_t rad = 0.5)
        # gStyle.SetNumberContours(Int_t number = 20)

        gStyle.SetEndErrorSize(2)
        #gStyle.SetErrorMarker(20)
        gStyle.SetErrorX(0.)

        gStyle.SetMarkerStyle(8)
        gStyle.SetMarkerSize(1)

        #For the fit/function:
        gStyle.SetOptFit(0)
        gStyle.SetFitFormat("5.4g")
        gStyle.SetFuncColor(2)
        gStyle.SetFuncStyle(1)
        gStyle.SetFuncWidth(1)

        #For the date:
        gStyle.SetOptDate(0)
        # gStyle.SetDateX(Float_t x = 0.01)
        # gStyle.SetDateY(Float_t y = 0.01)

        # For the statistics box:
        gStyle.SetOptFile(0)
        gStyle.SetOptStat(0)  # To display the mean and RMS:   SetOptStat("mr")
        gStyle.SetStatColor(kWhite)
        gStyle.SetStatFont(42)
        gStyle.SetStatFontSize(0.025)
        gStyle.SetStatTextColor(1)
        gStyle.SetStatFormat("6.4g")
        gStyle.SetStatBorderSize(1)
        gStyle.SetStatH(0.1)
        gStyle.SetStatW(0.15)
        # gStyle.SetStatStyle(Style_t style = 1001)
        # gStyle.SetStatX(Float_t x = 0)
        # gStyle.SetStatY(Float_t y = 0)

        # Margins:
        gStyle.SetPadTopMargin(0.11)
        gStyle.SetPadBottomMargin(0.13)
        gStyle.SetPadLeftMargin(0.17)
        gStyle.SetPadRightMargin(0.07)

        # For the Global title:
        gStyle.SetOptTitle(0)
        gStyle.SetTitleFont(42)
        gStyle.SetTitleColor(1)
        gStyle.SetTitleTextColor(1)
        gStyle.SetTitleFillColor(10)
        gStyle.SetTitleFontSize(0.04)
        # gStyle.SetTitleH(0) # Set the height of the title box
        # gStyle.SetTitleW(0) # Set the width of the title box
        #gStyle.SetTitleX(0.35) # Set the position of the title box
        #gStyle.SetTitleY(0.986) # Set the position of the title box
        # gStyle.SetTitleStyle(Style_t style = 1001)
        #gStyle.SetTitleBorderSize(0)

        # For the axis titles:
        gStyle.SetTitleColor(1, "XYZ")
        gStyle.SetTitleFont(42, "XYZ")
        gStyle.SetTitleSize(0.05, "XYZ")
        # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size?
        # gStyle.SetTitleYSize(Float_t size = 0.02)
        gStyle.SetTitleXOffset(1.)
        gStyle.SetTitleYOffset(1.3)
        #gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset

        # For the axis labels:

        gStyle.SetLabelColor(1, "XYZ")
        gStyle.SetLabelFont(42, "XYZ")
        gStyle.SetLabelOffset(0.007, "XYZ")
        gStyle.SetLabelSize(0.035, "XYZ")

        # For the axis:
        gStyle.SetAxisColor(1, "XYZ")
        gStyle.SetStripDecimals(True)
        gStyle.SetTickLength(0.03, "XYZ")
        gStyle.SetNdivisions(510, "XYZ")
        gStyle.SetPadTickX(
            1)  # To get tick marks on the opposite side of the frame
        gStyle.SetPadTickY(1)

        # Change for log plots:
        gStyle.SetOptLogx(0)
        gStyle.SetOptLogy(0)
        gStyle.SetOptLogz(0)

        gStyle.SetPalette(1)  #(1,0)

        # another top group addition
        gStyle.SetHatchesSpacing(1.0)

        # Postscript options:
        gStyle.SetPaperSize(20., 20.)
        #gStyle.SetPaperSize(TStyle.kA4)
        #gStyle.SetPaperSize(27., 29.7)
        #TGaxis.SetMaxDigits(3)
        # gStyle.SetLineScalePS(Float_t scale = 3)
        # gStyle.SetLineStyleString(Int_t i, const char* text)
        # gStyle.SetHeaderPS(const char* header)
        # gStyle.SetTitlePS(const char* pstitle)
        #gStyle.SetColorModelPS(1)

        # gStyle.SetBarOffset(Float_t baroff = 0.5)
        # gStyle.SetBarWidth(Float_t barwidth = 0.5)
        # gStyle.SetPaintTextFormat(const char* format = "g")
        # gStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0)
        # gStyle.SetTimeOffset(Double_t toffset)
        # gStyle.SetHistMinimumZero(kTRUE)

        #gStyle.cd()
        print "TDR Style initialized"
Example #17
0
def applyRootStyle():

    from ROOT import gROOT, gStyle, kWhite, kBlack, TColor

    # Start from a plain default
    gROOT.SetStyle("Plain")

    lhcbMarkerType = 8
    lhcbMarkerSize = 0.8
    lhcbFont = 62
    lhcbStatFontSize = 0.02
    lhcbStatBoxWidth = 0.12
    lhcbStatBoxHeight = 0.12
    lhcbWidth = 1
    lhcbTextSize = 0.05
    lhcbLabelSize = 0.035
    lhcbAxisLabelSize = 0.035
    lhcbForeColour = kBlack

    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBorderMode(0)

    # canvas options
    gStyle.SetCanvasBorderSize(0)
    gStyle.SetCanvasBorderMode(0)

    # fonts
    gStyle.SetTextFont(lhcbFont)
    gStyle.SetTextSize(lhcbTextSize)
    gStyle.SetLabelFont(lhcbFont, "x")
    gStyle.SetLabelFont(lhcbFont, "y")
    gStyle.SetLabelFont(lhcbFont, "z")
    gStyle.SetLabelSize(lhcbLabelSize, "x")
    gStyle.SetLabelSize(lhcbLabelSize, "y")
    gStyle.SetLabelSize(lhcbLabelSize, "z")
    gStyle.SetTitleFont(lhcbFont)
    gStyle.SetTitleSize(lhcbAxisLabelSize, "x")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "y")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "z")
    gStyle.SetTitleColor(kWhite)
    gStyle.SetTitleFillColor(kWhite)
    gStyle.SetTitleColor(kBlack)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(kBlack)

    # set title position
    gStyle.SetTitleX(0.15)
    gStyle.SetTitleY(0.97)
    # turn off Title box
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(lhcbForeColour)
    gStyle.SetTitleColor(lhcbForeColour)

    # use bold lines and markers
    gStyle.SetLineWidth(lhcbWidth)
    gStyle.SetFrameLineWidth(lhcbWidth)
    gStyle.SetHistLineWidth(lhcbWidth)
    gStyle.SetFuncWidth(lhcbWidth)
    gStyle.SetGridWidth(lhcbWidth)
    gStyle.SetLineStyleString(2, "[12 12]")
    gStyle.SetMarkerStyle(lhcbMarkerType)
    gStyle.SetMarkerSize(lhcbMarkerSize)

    # Grid
    # gStyle.SetGridStyle(3)

    # label offsets
    gStyle.SetLabelOffset(0.015)

    # by default, do not display histogram decorations:
    gStyle.SetOptStat(1111)
    # show probability, parameters and errors
    gStyle.SetOptFit(1011)

    # look of the statistics box:
    gStyle.SetStatBorderSize(1)
    gStyle.SetStatFont(lhcbFont)
    gStyle.SetStatFontSize(lhcbStatFontSize)
    gStyle.SetStatX(0.9)
    gStyle.SetStatY(0.9)
    gStyle.SetStatW(lhcbStatBoxWidth)
    gStyle.SetStatH(lhcbStatBoxHeight)

    # put tick marks on top and RHS of plots
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    # histogram divisions
    gStyle.SetNdivisions(505, "x")
    gStyle.SetNdivisions(510, "y")

    # Style for 2D zcol plots
    NRGBs = 5
    NCont = 255
    from array import array
    stops = array('d', [0.00, 0.34, 0.61, 0.84, 1.00])
    red = array('d', [0.00, 0.00, 0.87, 1.00, 0.51])
    green = array('d', [0.00, 0.81, 1.00, 0.20, 0.00])
    blue = array('d', [0.51, 1.00, 0.12, 0.00, 0.00])
    TColor().CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont)
    gStyle.SetNumberContours(NCont)

    # Force the style
    gROOT.ForceStyle()
Example #18
0
def main():
    # usage description
    usage = "Example: ./scripts/plotLimits.py -M Asymptotic -l logs -f qq --massrange 1200 7000 100"

    # input parameters
    parser = ArgumentParser(description='Script that plots limits for specified mass points',epilog=usage)
    parser.add_argument('analysis', type=str, help='Analysis name')
    parser.add_argument('model', type=str, help='Model name')

    parser.add_argument("-M", "--method", dest="method", required=True,
                        choices=['ProfileLikelihood', 'HybridNew', 'Asymptotic', 'MarkovChainMC', 'theta', 'HybridNewGrid'],
                        help="Method to calculate upper limits",
                        metavar="METHOD")
    parser.add_argument('--fit_function', type=str, default="f4", help="Name of fit function used for background estimate")
    parser.add_argument('--timesAE', action='store_true', help="Set y-axis to sigma*BR*A*e, instead of sigma*BR")
    parser.add_argument('--fitTrigger', action='store_true', help="Use trigger fit")
    parser.add_argument('--correctTrigger', action='store_true', help="Use trigger correction")
    parser.add_argument('--useMCTrigger', action='store_true', help="Use MC trigger emulation")
    #results_group = parser.add_mutually_exclusive_group(required=True)
    #results_group.add_argument("-l", "--logs_path", dest="logs_path",
    #                           help="Path to log files",
    #                           metavar="LOGS_PATH")
    #results_group.add_argument("-r", "--results_file", dest="results_file",
    #                           help="Path to a file containing results",
    #                           metavar="RESULTS_FILE")

    #parser.add_argument("-f", "--final_state", dest="final_state", required=True,
    #                    help="Final state (e.g. qq, qg, gg)",
    #                    metavar="FINAL_STATE")

    #parser.add_argument("-f2", "--finalstate2", dest="final_state2", required=True, help="hG,lG,hR, or lR", metavar="FINAL_STATE2")
    parser.add_argument("--noSyst", action="store_true", help="Make plots for limits without systematics")
    parser.add_argument("--freezeNuisances", type=str, help="Make plots for limits with frozen nuisance parameters")
    parser.add_argument("--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)")

    parser.add_argument("--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)")
    parser.add_argument("--saveObjects", type=str, help="Save plot objects")
    parser.add_argument("--extraText", dest="extraText", default='', help="Extra text on the plot (default: %(default)s)")

    parser.add_argument("--lumi_sqrtS", dest="lumi_sqrtS", default='19.7 fb^{-1} (8 TeV)', help="Integrated luminosity and center-of-mass energy (default: %(default)s)")

    parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen")

    mass_group = parser.add_mutually_exclusive_group(required=True)
    mass_group.add_argument("--mass",
                            type=int,
                            nargs = '*',
                            default = 1000,
                            help="Mass can be specified as a single value or a whitespace separated list (default: %(default)i)"
                            )
    mass_group.add_argument("--massrange",
                            type=int,
                            nargs = 3,
                            help="Define a range of masses to be produced. Format: min max step",
                            metavar = ('MIN', 'MAX', 'STEP')
                            )
    mass_group.add_argument("--masslist",
                            help = "List containing mass information"
                            )

    args = parser.parse_args()

    if args.method == 'HybridNew':
        searchmethod = 'Hybrid New'

    # mass points for which resonance shapes will be produced
    input_masses = []

    if args.massrange != None:
        MIN, MAX, STEP = args.massrange
        input_masses = range(MIN, MAX+STEP, STEP)
    elif args.masslist != None:
        # A mass list was provided
        print "Will create mass list according to", args.masslist
        masslist = __import__(args.masslist.replace(".py",""))
        input_masses = masslist.masses
    else:
        input_masses = args.mass
    # sort masses
    input_masses.sort()

    from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend, TF1, TFile
    from ROOT import kGreen, kYellow, kWhite

    # Make acc*eff TGraph
    ae_x = array('d',[325, 350, 400, 500, 600, 750, 900, 1200])
    if args.timesAE:
        ae_y = np.ones(len(ae_x))
    else:
        ae_y = array('d', [])
        for mass in ae_x:
            ae_y.append(analysis_config.simulation.get_signal_AE(args.analysis, args.model, int(mass)))
    acceptance_times_efficiency = TGraph(len(ae_x), ae_x, ae_y)
    #xs = array('d',[250,300,400,500,600,750,900,1200])

    #trigger_correctionl = TF1("trigbbl_efficiency", "(1. / (1. + TMath::Exp(-1. * (x - [0]) / [1])))**[2]", 175, 400)
    #trigger_correctionl.SetParameter(0, 1.82469e+02)
    #trigger_correctionl.SetParameter(1,  2.87768e+01)
    #trigger_correctionl.SetParameter(2,  9.11659e-01)

    #trigger_correctionh = TF1("trigbbh_efficiency", "(1. / (1. + TMath::Exp(-1. * (x - [0]) / [1])))**[2]", 300, 600)
    #trigger_correctionh.SetParameter(0, 3.61785e+02)
    #trigger_correctionh.SetParameter(1,  3.16523e+01)
    #trigger_correctionh.SetParameter(2,  4.84357e-01)
    #if args.timesAE:
    #    ys = np.ones(len(xs))
    #else:
    #    if args.analysis == "trigbbh_CSVTM" and args.model == "Hbb":
    #    	#ys = array('d',[188./19751.,1304./19993.,2697./49494.,881./19999.,534./19598.])
    #		ys = array('d',[24./19737.,188./19751.,1171./19984.,1419./19992.,1304./19993.,2697./49494.,881./19999.,534./19598.])
    #		#graphMod = trigger_correctionh
    #    elif args.analysis == "trigbbl_CSVTM" and args.model == "Hbb":
    #		#ys = array('d',[30./2797.,1583./19995.,1295./19996.,999./19996.,528./19999.])
    #		ys = array('d',[574./19737.,763./39502.,651./19984.,583./19992.,984./39986.,1905./98988.,656./39998.,369./39196.])
    #		#graphMod = trigger_correctionh
    #    elif args.analysis == "trigbbh_CSVTM" and args.model == "RSG":
    #		#ys = array('d',[109./19751.,488./19993.,954./49494.,328./19999.,182./19598.])
    #		ys = array('d',[40./19977.,30./2797.,1522./19991.,1640./19396.,1583./19995.,1295./19996.,999./19996.,528./19999.])
    #		#graphMod = trigger_correctionl
    #    elif args.analysis == "trigbbl_CSVTM" and args.model == "RSG":
    #		#ys = array('d',[23./2797.,599./19995.,448./19996.,338./19996.,190./19999.])
    #		ys = array('d',[696./19977.,137./5594.,797./19991.,652./19396.,1206./39990.,891./39992.,675./39992.,379./39998.])
    #		#graphMod = trigger_correctionl

    ##ys = array('d',[1,1,1,1,1,1,1,1,])   

    #acceptance_times_efficiency = TGraph(len(xs),xs,ys)


    # arrays holding results
    masses = array('d')
    xs_obs_limits = array('d')
    xs_exp_limits = array('d')
    masses_exp = array('d')
    xs_exp_limits_1sigma = array('d')
    xs_exp_limits_1sigma_up = array('d')
    xs_exp_limits_2sigma = array('d')
    xs_exp_limits_2sigma_up = array('d')

    for mass in input_masses:
        print ">> Reading results for %s %s resonance with m = %i GeV..."%(args.analysis, args.model, int(mass))
        masses.append(mass)
        masses_exp.append(mass)

        # For masses above 1100, you scaled down the signal by 10 by hand, to help the limit setting.
        #if args.analysis == "trigbbh_CSVTM" and mass >= 1100:
        input_xs = 1./100.
        #else:
        #    input_xs = 1.

        if args.method == "HybridNewGrid":
            found_limit = {"obs":False, "exp0":False, "exp1":False, "exp2":False, "exp-1":False, "exp-2":False}
            for what in found_limit.keys():
                log_file_path = limit_config.get_combine_log_path_grid(args.analysis, args.model, mass, args.fit_function, what, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger)
                print "Reading log file from " + log_file_path
                log_file = open(log_file_path, 'r')
                for line in log_file:
                    if re.search("^Limit: r <", line) and re.search("95%", line):
                        found_limit[what] = True
                        this_limit = float(line.split()[3])/acceptance_times_efficiency.Eval(mass)
                        print "Found limit for " + what + " = " + str(this_limit)
                        if what == "obs":
                            xs_obs_limits.append(this_limit * input_xs)
                        elif what == "exp0":
                            xs_exp_limits.append(this_limit * input_xs)
                        elif what == "exp1":
                            xs_exp_limits_1sigma_up.append(this_limit * input_xs)
                        elif what == "exp2":
                            xs_exp_limits_2sigma_up.append(this_limit * input_xs)
                        elif what == "exp-1":
                            xs_exp_limits_1sigma.append(this_limit * input_xs)
                        elif what == "exp-2":
                            xs_exp_limits_2sigma.append(this_limit * input_xs)
            if not found_limit["obs"]:
                xs_obs_limits.append(0)
            if not found_limit["exp0"]:
                xs_exp_limits.append(0)
            if not found_limit["exp1"]:
                xs_exp_limits_1sigma.append(0)
            if not found_limit["exp2"]:
                xs_exp_limits_1sigma_up.append(0)
            if not found_limit["exp-1"]:
                xs_exp_limits_2sigma.append(0)
            if not found_limit["exp-2"]:
                xs_exp_limits_2sigma_up.append(0)
            if len(masses) != len(xs_obs_limits):
                print "** ERROR: ** Could not find observed limit for m =", int(mass), "GeV. Aborting."
                sys.exit(1)
        else:
            print "Reading log file from " + limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger)
            if not os.path.exists((limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger))):
                print "[plot_limits] WARNING : Log file not found! Setting limits to zero and skipping this point."
                print "[plot_limits] WARNING : \t{}".format(limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger))
                xs_obs_limits.append(0)
                xs_exp_limits.append(0)
                xs_exp_limits_1sigma.append(0)
                xs_exp_limits_1sigma_up.append(0)
                xs_exp_limits_2sigma.append(0)
                xs_exp_limits_2sigma_up.append(0)
                continue
            log_file = open(limit_config.get_combine_log_path(args.analysis, args.model, mass, args.fit_function, args.method, systematics=(not args.noSyst), frozen_nps=args.freezeNuisances, fitTrigger=args.fitTrigger, correctTrigger=args.correctTrigger, useMCTrigger=args.useMCTrigger))

            foundMethod = False
            middle = 0
            # read the log file
            found_limit = {"obs":False, "exp":False, "exp+1":False, "exp+2":False, "exp-1":False, "exp-2":False}
            for line in log_file:
                if args.method == 'Asymptotic':
                    if re.search("^Observed Limit: r", line):
                        xs_obs_limits.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["obs"] = True
                        if mass == 325 and args.model == "ZPrime":
                            print "[debug] ZPrime 325 GeV limit = {}".format(xs_obs_limits[-1])
                            print "[debug] \tA*e={}, input_xs={}".format(acceptance_times_efficiency.Eval(mass), input_xs)
                    if re.search("^Expected 50.0%: r", line):
                        middle = float(line.split()[-1])
                        found_limit["exp"] = True
                        xs_exp_limits.append(middle/acceptance_times_efficiency.Eval(mass) * input_xs)
                    if re.search("^Expected 16.0%: r", line):
                        xs_exp_limits_1sigma.append((float(line.split()[-1]))/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["exp-1"] = True
                    if re.search("^Expected 84.0%: r", line):
                        xs_exp_limits_1sigma_up.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["exp+1"] = True
                    if re.search("^Expected  2.5%: r", line):
                        xs_exp_limits_2sigma.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["exp-2"] = True
                    if re.search("^Expected 97.5%: r", line):
                        xs_exp_limits_2sigma_up.append(float(line.split()[-1])/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["exp+2"] = True
                elif args.method == 'theta':
                    if re.search('^# x; y; yerror', line):
                        foundMethod = True
                    if line.split()[0] == '0' and foundMethod:
                        xs_obs_limits.append(float(line.split()[1])/acceptance_times_efficiency.Eval(mass) * input_xs)
                else:
                    searchmethod = "Hybrid New"
                    if re.search(' -- ' + searchmethod, line):
                        foundMethod = True
                    if re.search("^Limit: r", line) and foundMethod:
                        xs_obs_limits.append(float(line.split()[3])/acceptance_times_efficiency.Eval(mass) * input_xs)
                        found_limit["obs"] = True
                        print "[debug] Found limit " + str(xs_obs_limits[-1])

            if not found_limit["obs"]:
                xs_obs_limits.append(0)
            if not found_limit["exp"]:
                xs_exp_limits.append(0)
            if not found_limit["exp+1"]:
                xs_exp_limits_1sigma.append(0)
            if not found_limit["exp+2"]:
                xs_exp_limits_1sigma_up.append(0)
            if not found_limit["exp-1"]:
                xs_exp_limits_2sigma.append(0)
            if not found_limit["exp-2"]:
                xs_exp_limits_2sigma_up.append(0)
            if len(masses) != len(xs_obs_limits):
                print "** ERROR: ** Could not find observed limit for m =", int(mass), "GeV. Aborting."
                sys.exit(1)

        if args.method == 'Asymptotic' or args.method == 'HybridNewGrid':
            if len(masses) != len(xs_exp_limits):
                print "** ERROR: ** Could not find expected limit for m =", int(mass), "GeV. Aborting."
                print "masses = ",
                print masses
                print "xs_exp_limits = ",
                print xs_exp_limits
                sys.exit(1)

            if len(masses) != len(xs_exp_limits_1sigma):
                print "** ERROR: ** Could not find expected 1 sigma down limit for m =", int(mass), "GeV. Aborting."
                print "masses = ",
                print masses
                print "xs_exp_limits_1sigma = ",
                print xs_exp_limits_1sigma
                sys.exit(1)

            if len(masses) != len(xs_exp_limits_1sigma_up):
                print "** ERROR: ** Could not find expected 1 sigma up limit for m =", int(mass), "GeV. Aborting."
                print "masses = ",
                print masses
                print "xs_exp_limits_1sigma_up = ",
                print xs_exp_limits_1sigma_up
                sys.exit(1)

            if len(masses) != len(xs_exp_limits_2sigma):
                print "** ERROR: ** Could not find expected 2 sigma down limit for m =", int(mass), "GeV. Aborting."
                sys.exit(1)

            if len(masses) != len(xs_exp_limits_2sigma_up):
                print "** ERROR: ** Could not find expected 2 sigma up limit for m =", int(mass), "GeV. Aborting."
                sys.exit(1)
    if args.method == 'Asymptotic' or args.method == 'HybridNewGrid':
        # complete the expected limit arrays
        for i in range(0,len(masses)):
            masses_exp.append( masses[len(masses)-i-1] )
            xs_exp_limits_1sigma.append( xs_exp_limits_1sigma_up[len(masses)-i-1] )
            xs_exp_limits_2sigma.append( xs_exp_limits_2sigma_up[len(masses)-i-1] )

    if args.printResults:
        print "masses =", masses.tolist()
        print "xs_obs_limits =", xs_obs_limits.tolist()
        print "xs_exp_limits =", xs_exp_limits.tolist()
        print ""
        print "masses_exp =", masses_exp.tolist()
        print "xs_exp_limits_1sigma =", xs_exp_limits_1sigma.tolist()
        print "xs_exp_limits_2sigma =", xs_exp_limits_2sigma.tolist()


    gROOT.SetBatch(kTRUE);
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.05, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelSize(0.05, "XYZ")
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasColor(kWhite)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    gROOT.ForceStyle()

    # theory curves: gg
    massesS8 = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0])
    xsS8 = array('d', [5.46E+02,3.12E+02,1.85E+02,1.12E+02,7.19E+01,4.59E+01,3.02E+01,2.01E+01,1.37E+01,9.46E+00,6.55E+00,4.64E+00,3.27E+00,2.36E+00,1.70E+00,1.24E+00,9.11E-01,6.69E-01,4.97E-01,3.71E-01,2.78E-01,2.07E-01,1.55E-01,1.19E-01,9.26E-02,7.08E-02,5.43E-02,4.15E-02,3.22E-02,2.50E-02,1.92E-02,1.51E-02,1.19E-02,9.25E-03,7.35E-03,5.86E-03,4.53E-03,3.66E-03,2.91E-03,2.33E-03,1.86E-03,1.45E-03,1.12E-03,8.75E-04,6.90E-04,5.55E-04,4.47E-04,3.63E-04,2.92E-04,2.37E-04,1.97E-04])

    graph_xsS8 = TGraph(len(massesS8),massesS8,xsS8)
    graph_xsS8.SetLineWidth(3)
    graph_xsS8.SetLineStyle(8)
    graph_xsS8.SetLineColor(6)

    # theory curves: qg
    massesString = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0,9100.,9200.,9300.,9400.,9500.,9600.,9700.,9800.,9900.,10000.])
    xsString = array('d', [8316.184311558545,5312.93137758767,3435.0309937336524,2304.4139502741305,1569.8115447896687,1090.9516635659693,770.901859690924,551.9206062572061,399.69535383507633,293.77957451762086,218.15126842827823,162.87634729465125,123.17685479653694,93.63530805932386,71.53697229809124,55.37491301647483,42.75271508357369,33.36378355470234,26.06619302090876,20.311817606835643,16.1180931789545,12.768644973921226,10.142660425967444,8.057990848043234,6.400465846290908,5.115134438331436,4.132099789492928,3.3193854239538734,2.6581204529344302,2.157554604919995,1.7505176068913348,1.4049155245498584,1.140055677916783,0.9253251132104159,0.7522038169131606,0.6119747371392215,0.49612321727328523,0.40492020959456737,0.33091999402250655,0.27017917021492555,0.2201693919322846,0.17830700070267996,0.14564253802358157,0.11940534430331146,0.09694948234356839,0.0793065371847468,0.06446186373361917,0.05282660618352478,
                           0.0428516302310620888,0.0348997638039910363,0.0283334766442618227,0.0231416918363592127,0.0187417921340763783,0.0153501307395115115,0.0124396534127133717,0.0100542205744949455,0.0081744954858627415,0.0066338099362915941,0.0053365711503318145,0.00430912459914657443,0.00346381039244064343,0.00278602671711227174,0.00225154342228859257,0.0018082930150063248,0.00143929440338502119,0.0011581373956044489,0.00091869589873893118,0.00073410823691329855,0.00058669382997948734,0.0004661568745858897,0.000368716655469570365,0.000293168485206959169,0.000230224535021638668,0.000182317101888465142,0.000143263359883433282,0.000112630538527214965,0.000088189175598406759,0.000068708474367442343,0.000053931726669273556,0.0000416417855733682702,0.0000326529676755488658,0.0000254365480426201587,0.0000198410151166864761,0.0000154034425617473576,0.0000119095554601641413,9.2537574320108232e-6,7.2155417437856749e-6,5.6130924422251982e-6,4.36634755605624901e-6,3.39717456406994868e-6,2.6766018046173896e-6])

    massesQstar = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0])
    xsQstar = array('d', [0.4101E+03,0.2620E+03,0.1721E+03,0.1157E+03,0.7934E+02,0.5540E+02,0.3928E+02,0.2823E+02,0.2054E+02,0.1510E+02,0.1121E+02,0.8390E+01,0.6328E+01,0.4807E+01,0.3674E+01,0.2824E+01,0.2182E+01,0.1694E+01,0.1320E+01,0.1033E+01,0.8116E+00,0.6395E+00,0.5054E+00,0.4006E+00,0.3182E+00,0.2534E+00,0.2022E+00,0.1616E+00,0.1294E+00,0.1038E+00,0.8333E-01,0.6700E-01,0.5392E-01,0.4344E-01,0.3503E-01,0.2827E-01,0.2283E-01,0.1844E-01,0.1490E-01,0.1205E-01,0.9743E-02,0.7880E-02,0.6373E-02,0.5155E-02,0.4169E-02,0.3371E-02,0.2725E-02,0.2202E-02,0.1779E-02,0.1437E-02,0.1159E-02,0.9353E-03,0.7541E-03,0.6076E-03,0.4891E-03,0.3935E-03,0.3164E-03,0.2541E-03,0.2039E-03,0.1635E-03,0.1310E-03,0.1049E-03,0.8385E-04,0.6699E-04,0.5347E-04,0.4264E-04,0.3397E-04,0.2704E-04,0.2151E-04,0.1709E-04,0.1357E-04,0.1077E-04,0.8544E-05,0.6773E-05,0.5367E-05,0.4251E-05,0.3367E-05,0.2666E-05,0.2112E-05,0.1673E-05,0.1326E-05])

    graph_xsString = TGraph(len(massesString),massesString,xsString)
    graph_xsString.SetLineWidth(3)
    graph_xsString.SetLineStyle(8)
    graph_xsString.SetLineColor(9)

    graph_xsQstar = TGraph(len(massesQstar),massesQstar,xsQstar)
    graph_xsQstar.SetLineWidth(3)
    graph_xsQstar.SetLineStyle(2)
    graph_xsQstar.SetLineColor(1)

    # theory curves: qq
    massesTh = array('d', [1000.0,1100.0,1200.0,1300.0,1400.0,1500.0,1600.0,1700.0,1800.0,1900.0,2000.0,2100.0,2200.0,2300.0,2400.0,2500.0,2600.0,2700.0,2800.0,2900.0,3000.0,3100.0,3200.0,3300.0,3400.0,3500.0,3600.0,3700.0,3800.0,3900.0,4000.0,4100.0,4200.0,4300.0,4400.0,4500.0,4600.0,4700.0,4800.0,4900.0,5000.0,5100.0,5200.0,5300.0,5400.0,5500.0,5600.0,5700.0,5800.0,5900.0,6000.0,6100.0,6200.0,6300.0,6400.0,6500.0,6600.0,6700.0,6800.0,6900.0,7000.0,7100.0,7200.0,7300.0,7400.0,7500.0,7600.0,7700.0,7800.0,7900.0,8000.0,8100.0,8200.0,8300.0,8400.0,8500.0,8600.0,8700.0,8800.0,8900.0,9000.0])

    xsAxi = array('d', [0.1849E+03,0.1236E+03,0.8473E+02,0.5937E+02,0.4235E+02,0.3069E+02,0.2257E+02,0.1680E+02,0.1263E+02,0.9577E+01,0.7317E+01,0.5641E+01,0.4374E+01,0.3411E+01,0.2672E+01,0.2103E+01,0.1658E+01,0.1312E+01,0.1041E+01,0.8284E+00,0.6610E+00,0.5294E+00,0.4250E+00,0.3417E+00,0.2752E+00,0.2220E+00,0.1792E+00,0.1449E+00,0.1172E+00,0.9487E-01,0.7686E-01,0.6219E-01,0.5033E-01,0.4074E-01,0.3298E-01,0.2671E-01,0.2165E-01,0.1755E-01,0.1422E-01,0.1152E-01,0.9322E-02,0.7539E-02,0.6092E-02,0.4917E-02,0.3965E-02,0.3193E-02,0.2568E-02,0.2062E-02,0.1653E-02,0.1323E-02,0.1057E-02,0.8442E-03,0.6728E-03,0.5349E-03,0.4242E-03,0.3357E-03,0.2644E-03,0.2077E-03,0.1627E-03,0.1271E-03,0.9891E-04,0.7686E-04,0.5951E-04,0.4592E-04,0.3530E-04,0.2704E-04,0.2059E-04,0.1562E-04,0.1180E-04,0.8882E-05,0.6657E-05,0.4968E-05,0.3693E-05,0.2734E-05,0.2016E-05,0.1481E-05,0.1084E-05,0.7903E-06,0.5744E-06,0.4160E-06,0.3007E-06])
    xsDiquark = array('d', [0.5824E+02,0.4250E+02,0.3172E+02,0.2411E+02,0.1862E+02,0.1457E+02,0.1153E+02,0.9211E+01,0.7419E+01,0.6019E+01,0.4912E+01,0.4031E+01,0.3323E+01,0.2750E+01,0.2284E+01,0.1903E+01,0.1590E+01,0.1331E+01,0.1117E+01,0.9386E+00,0.7900E+00,0.6658E+00,0.5618E+00,0.4745E+00,0.4010E+00,0.3391E+00,0.2869E+00,0.2428E+00,0.2055E+00,0.1740E+00,0.1473E+00,0.1246E+00,0.1055E+00,0.8922E-01,0.7544E-01,0.6376E-01,0.5385E-01,0.4546E-01,0.3834E-01,0.3231E-01,0.2720E-01,0.2288E-01,0.1922E-01,0.1613E-01,0.1352E-01,0.1132E-01,0.9463E-02,0.7900E-02,0.6584E-02,0.5479E-02,0.4551E-02,0.3774E-02,0.3124E-02,0.2581E-02,0.2128E-02,0.1750E-02,0.1437E-02,0.1177E-02,0.9612E-03,0.7833E-03,0.6366E-03,0.5160E-03,0.4170E-03,0.3360E-03,0.2700E-03,0.2162E-03,0.1725E-03,0.1372E-03,0.1087E-03,0.8577E-04,0.6742E-04,0.5278E-04,0.4114E-04,0.3192E-04,0.2465E-04,0.1894E-04,0.1448E-04,0.1101E-04,0.8322E-05,0.6253E-05,0.4670E-05])
    xsWprime = array('d', [0.8811E+01,0.6024E+01,0.4216E+01,0.3010E+01,0.2185E+01,0.1610E+01,0.1200E+01,0.9043E+00,0.6875E+00,0.5271E+00,0.4067E+00,0.3158E+00,0.2464E+00,0.1932E+00,0.1521E+00,0.1201E+00,0.9512E-01,0.7554E-01,0.6012E-01,0.4792E-01,0.3827E-01,0.3059E-01,0.2448E-01,0.1960E-01,0.1571E-01,0.1259E-01,0.1009E-01,0.8090E-02,0.6483E-02,0.5193E-02,0.4158E-02,0.3327E-02,0.2660E-02,0.2125E-02,0.1695E-02,0.1351E-02,0.1075E-02,0.8546E-03,0.6781E-03,0.5372E-03,0.4248E-03,0.3353E-03,0.2642E-03,0.2077E-03,0.1629E-03,0.1275E-03,0.9957E-04,0.7757E-04,0.6027E-04,0.4670E-04,0.3610E-04,0.2783E-04,0.2140E-04,0.1641E-04,0.1254E-04,0.9561E-05,0.7269E-05,0.5510E-05,0.4167E-05,0.3143E-05,0.2364E-05,0.1774E-05,0.1329E-05,0.9931E-06,0.7411E-06,0.5523E-06,0.4108E-06,0.3055E-06,0.2271E-06,0.1687E-06,0.1254E-06,0.9327E-07,0.6945E-07,0.5177E-07,0.3863E-07,0.2888E-07,0.2162E-07,0.1622E-07,0.1218E-07,0.9156E-08,0.6893E-08])
    xsZprime = array('d', [0.5027E+01,0.3398E+01,0.2353E+01,0.1663E+01,0.1196E+01,0.8729E+00,0.6450E+00,0.4822E+00,0.3638E+00,0.2769E+00,0.2123E+00,0.1639E+00,0.1272E+00,0.9933E-01,0.7789E-01,0.6134E-01,0.4848E-01,0.3845E-01,0.3059E-01,0.2440E-01,0.1952E-01,0.1564E-01,0.1256E-01,0.1010E-01,0.8142E-02,0.6570E-02,0.5307E-02,0.4292E-02,0.3473E-02,0.2813E-02,0.2280E-02,0.1848E-02,0.1499E-02,0.1216E-02,0.9864E-03,0.8002E-03,0.6490E-03,0.5262E-03,0.4264E-03,0.3453E-03,0.2795E-03,0.2260E-03,0.1826E-03,0.1474E-03,0.1188E-03,0.9566E-04,0.7690E-04,0.6173E-04,0.4947E-04,0.3957E-04,0.3159E-04,0.2516E-04,0.2001E-04,0.1587E-04,0.1255E-04,0.9906E-05,0.7795E-05,0.6116E-05,0.4785E-05,0.3731E-05,0.2900E-05,0.2247E-05,0.1734E-05,0.1334E-05,0.1022E-05,0.7804E-06,0.5932E-06,0.4492E-06,0.3388E-06,0.2544E-06,0.1903E-06,0.1417E-06,0.1051E-06,0.7764E-07,0.5711E-07,0.4186E-07,0.3055E-07,0.2223E-07,0.1612E-07,0.1164E-07,0.8394E-08])

    graph_xsAxi = TGraph(len(massesTh),massesTh,xsAxi)
    graph_xsAxi.SetLineWidth(3)
    graph_xsAxi.SetLineStyle(3)
    graph_xsAxi.SetLineColor(63)

    graph_xsDiquark = TGraph(len(massesTh),massesTh,xsDiquark)
    graph_xsDiquark.SetLineWidth(3)
    graph_xsDiquark.SetLineStyle(9)
    graph_xsDiquark.SetLineColor(8)

    graph_xsWprime = TGraph(len(massesTh),massesTh,xsWprime)
    graph_xsWprime.SetLineWidth(3)
    graph_xsWprime.SetLineStyle(7)
    graph_xsWprime.SetLineColor(46)

    graph_xsZprime = TGraph(len(massesTh),massesTh,xsZprime)
    graph_xsZprime.SetLineWidth(3)
    graph_xsZprime.SetLineStyle(5)
    graph_xsZprime.SetLineColor(38)

    # limits
    if args.method == "Asymptotic" or args.method == "HybridNewGrid":
        graph_exp_2sigma = ( TGraph(len(masses_exp),masses_exp,xs_exp_limits_2sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) )
        graph_exp_2sigma.SetFillColor(kYellow)

        graph_exp_1sigma = ( TGraph(len(masses_exp),masses_exp,xs_exp_limits_1sigma) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) )
        graph_exp_1sigma.SetFillColor(kGreen+1)

        graph_exp = ( TGraph(len(masses),masses,xs_exp_limits) if len(xs_exp_limits_2sigma) > 0 else TGraph(0) )
        #graph_exp.SetMarkerStyle(24)
        graph_exp.SetLineWidth(3)
        graph_exp.SetLineStyle(2)
        graph_exp.SetLineColor(4)

    graph_obs = TGraph(len(masses),masses,xs_obs_limits)
    graph_obs.SetMarkerStyle(20)
    graph_obs.SetLineWidth(3)
    #graph_obs.SetLineStyle(1)
    graph_obs.SetLineColor(1)

    c = TCanvas("c", "",800,800)
    c.cd()

    legend = TLegend(.58,.72,.90,.90)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetFillStyle(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.03)
    legend.SetHeader('95% CL upper limits')

    if len(xs_exp_limits_2sigma) > 0 and (args.method == "Asymptotic" or args.method == "HybridNewGrid"):
        frame = graph_exp_2sigma.GetHistogram().Clone()
    else:
        frame = graph_obs.GetHistogram().Clone()
    frame.Reset()
    frame.GetXaxis().SetTitle("Resonance mass [GeV]")
    frame.GetXaxis().SetTitleOffset(1.05)
    if args.timesAE:
        #if args.model == "ZPrime":
        #    frame.GetYaxis().SetTitle("#sigma #times BR(c#bar{c},b#bar{b}) #times #it{A} #times #epsilon [pb]")
        #else:
        frame.GetYaxis().SetTitle("#sigma #times BR(b#bar{b}) #times #it{A} #times #epsilon [pb]")
    else:
        #if args.model == "ZPrime":
        #    frame.GetYaxis().SetTitle("#sigma #times BR(c#bar{c},b#bar{b}) [pb]")
        #else:
        frame.GetYaxis().SetTitle("#sigma #times BR(b#bar{b}) [pb]")
    frame.GetYaxis().SetTitleOffset(1.2)
    if args.timesAE:
        frame.GetYaxis().SetRangeUser(1e-03,1e+01)
    else:
        frame.GetYaxis().SetRangeUser(1e-01,5e+02)
    frame.Draw("axis")

    if len(xs_exp_limits_2sigma) > 0 and (args.method == "Asymptotic" or args.method == "HybridNewGrid"):
        graph_exp_2sigma.GetXaxis().SetTitle("Resonance mass [GeV]")
        graph_exp_2sigma.GetXaxis().SetTitleOffset(1.1)
        graph_exp_2sigma.GetYaxis().SetTitle("#sigma #times #it{B} [pb]")
        graph_exp_2sigma.GetYaxis().SetTitleOffset(1.1)
        #graph_exp_2sigma.GetYaxis().SetRangeUser(1e-03,1e+02)
        #graph_exp_2sigma.GetXaxis().SetNdivisions(1005)

        graph_exp_2sigma.Draw("F")
        graph_exp_1sigma.Draw("F")
        graph_exp.Draw("L")
        graph_obs.Draw("LP")

        legend.AddEntry(graph_obs,"Observed","lp")
        legend.AddEntry(graph_exp,"Expected","lp")
        legend.AddEntry(graph_exp_1sigma,"#pm 1#sigma","F")
        legend.AddEntry(graph_exp_2sigma,"#pm 2#sigma","F")
    else:
        graph_obs.GetXaxis().SetTitle("Resonance mass [GeV]")
        graph_obs.GetYaxis().SetTitle("#sigma #times #it{B} [pb]")
        graph_obs.GetYaxis().SetTitleOffset(1.1)
        graph_obs.GetYaxis().SetRangeUser(1e-02,1e+03)
        #graph_obs.GetXaxis().SetNdivisions(1005)

        graph_obs.Draw("LP")

        legend.AddEntry(graph_obs,"Observed","lp")

        #if args.final_state == 'gg' :
        #    graph_xsS8.Draw("L")
        #elif args.final_state == 'qg' :
        #    graph_xsQstar.Draw("L")
        #    graph_xsString.Draw("L")
        #elif args.final_state == 'qq' :
        #    graph_xsAxi.Draw("L")
        #    graph_xsDiquark.Draw("L")
        #    graph_xsWprime.Draw("L")
        #    graph_xsZprime.Draw("L")
        
    legend.Draw()

    #legendTh = TLegend(.60,.72,.90,.88)
    #legendTh.SetBorderSize(0)
    #legendTh.SetFillColor(0)
    #legendTh.SetFillStyle(0)
    #legendTh.SetTextFont(42)
    #legendTh.SetTextSize(0.03)
    #legendTh.AddEntry(graph_xsAxi,"Axigluon/coloron","l")
    #legendTh.AddEntry(graph_xsDiquark,"Scalar diquark","l")
    #legendTh.AddEntry(graph_xsWprime,"W' SSM","l")
    #legendTh.AddEntry(graph_xsZprime,"Z' SSM","l")
    #legendTh.Draw()

    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    gPad.RedrawAxis()

    c.SetLogy()
    postfix = ( ('_' + args.postfix) if args.postfix != '' else '' )
    if args.noSyst:
        postfix += "_noSyst"
    if args.freezeNuisances:
        postfix += "_" + args.freezeNuisances.replace(",", "_")
    if args.fitTrigger:
        postfix += "_fitTrigger"
    elif args.correctTrigger:
        postfix += "_correctTrigger"
    if args.useMCTrigger:
        postfix += "_useMCTrigger"
    fileName = limit_config.paths["limit_plots"] + '/xs_limit_%s_%s_%s_%s.%s'%(args.method,args.analysis, args.model + postfix, args.fit_function, args.fileFormat.lower())
    if args.timesAE:
        fileName = fileName.replace("xs_limit", "xsAE_limit")
    c.SaveAs(fileName)
    print "Plot saved to '%s'"%(fileName)

    graph_obs.Print("all")
    if args.saveObjects:
        output_file = args.saveObjects
        if args.timesAE:
            output_file = output_file.replace(".root", "_timesAE.root")
        f = TFile(output_file, "RECREATE")
        if args.method == "Asymptotic" or args.method == "HybridNewGrid":
            graph_exp_2sigma.SetName("graph_exp_2sigma")
            graph_exp_2sigma.Write()
            graph_exp_1sigma.SetName("graph_exp_1sigma")
            graph_exp_1sigma.Write()
            graph_exp.SetName("graph_exp")
            graph_exp.Write()
        graph_obs.SetName("graph_obs")
        graph_obs.Write()
        f.Close()
Example #19
0
def setTDRStyle(force):

  gStyle.SetCanvasBorderMode(0)
  gStyle.SetCanvasColor(kWhite)
  gStyle.SetCanvasDefH(600)
  gStyle.SetCanvasDefW(600)
  gStyle.SetCanvasDefX(0)
  gStyle.SetCanvasDefY(0)

  gStyle.SetPadBorderMode(0)
  gStyle.SetPadColor(kWhite)
  gStyle.SetPadGridX(False)
  gStyle.SetPadGridY(False)
  gStyle.SetGridColor(0)
  gStyle.SetGridStyle(3)
  gStyle.SetGridWidth(1)

  gStyle.SetFrameBorderMode(0)
  gStyle.SetFrameBorderSize(1)
  gStyle.SetFrameFillColor(0)
  gStyle.SetFrameFillStyle(0)
  gStyle.SetFrameLineColor(1)
  gStyle.SetFrameLineStyle(1)
  gStyle.SetFrameLineWidth(1)

  if force:
      gStyle.SetHistLineColor(1)
      gStyle.SetHistLineStyle(0)
      gStyle.SetHistLineWidth(1)


  gStyle.SetEndErrorSize(2)
  gStyle.SetErrorX(0.)

  gStyle.SetMarkerStyle(20)

  gStyle.SetOptFit(1)
  gStyle.SetFitFormat("5.4g")
  gStyle.SetFuncColor(2)
  gStyle.SetFuncStyle(1)
  gStyle.SetFuncWidth(1)

  gStyle.SetOptDate(0)

  gStyle.SetOptFile(0)
  gStyle.SetOptStat(0)
  gStyle.SetStatColor(kWhite)
  gStyle.SetStatFont(42)
  gStyle.SetStatFontSize(0.04)
  gStyle.SetStatTextColor(1)
  gStyle.SetStatFormat("6.4g")
  gStyle.SetStatBorderSize(1)
  gStyle.SetStatH(0.1)
  gStyle.SetStatW(0.2)


  gStyle.SetPadTopMargin(0.05)
  gStyle.SetPadBottomMargin(0.13)
  gStyle.SetPadLeftMargin(0.16)
  gStyle.SetPadRightMargin(0.04)


  gStyle.SetOptTitle(0)
  gStyle.SetTitleFont(42)
  gStyle.SetTitleColor(1)
  gStyle.SetTitleTextColor(1)
  gStyle.SetTitleFillColor(10)
  gStyle.SetTitleFontSize(0.05)


  gStyle.SetTitleColor(1, "XYZ")
  gStyle.SetTitleFont(42, "XYZ")
  gStyle.SetTitleSize(0.06, "XYZ")
  gStyle.SetTitleXOffset(0.9)
  gStyle.SetTitleYOffset(1.25)


  gStyle.SetLabelColor(1, "XYZ")
  gStyle.SetLabelFont(42, "XYZ")
  gStyle.SetLabelOffset(0.007, "XYZ")
  gStyle.SetLabelSize(0.05, "XYZ")


  gStyle.SetAxisColor(1, "XYZ")
  gStyle.SetStripDecimals(True)
  gStyle.SetTickLength(0.03, "XYZ")
  gStyle.SetNdivisions(510, "XYZ")
  gStyle.SetPadTickX(1)
  gStyle.SetPadTickY(1)

  gStyle.SetOptLogx(0)
  gStyle.SetOptLogy(0)
  gStyle.SetOptLogz(0)

  gStyle.SetPaperSize(20.,20.)


  gROOT.ForceStyle()
Example #20
0
    def initialize2(self):
        # For the canvas:
        gStyle.SetCanvasBorderMode(0)
        gStyle.SetCanvasColor(kWhite)
        gStyle.SetCanvasDefH(600)  #Height of canvas
        gStyle.SetCanvasDefW(600)  #Width of canvas
        gStyle.SetCanvasDefX(0)  #POsition on screen
        gStyle.SetCanvasDefY(0)

        # For the Pad:
        gStyle.SetPadBorderMode(0)
        # gStyle.SetPadBorderSize(Width_t size = 1)
        gStyle.SetPadColor(kWhite)
        gStyle.SetPadGridX(False)
        gStyle.SetPadGridY(False)
        gStyle.SetGridColor(0)
        gStyle.SetGridStyle(3)
        gStyle.SetGridWidth(1)

        # For the frame:
        gStyle.SetFrameBorderMode(0)
        gStyle.SetFrameBorderSize(1)
        gStyle.SetFrameFillStyle(1000)
        gStyle.SetFrameFillColor(0)
        gStyle.SetFrameFillStyle(0)
        gStyle.SetFrameLineColor(1)
        gStyle.SetFrameLineStyle(1)
        gStyle.SetFrameLineWidth(1)

        # For the histo:
        # gStyle.SetHistFillColor(1)
        # gStyle.SetHistFillStyle(0)
        gStyle.SetHistLineColor(1)
        gStyle.SetHistLineStyle(0)
        gStyle.SetHistLineWidth(1)
        # gStyle.SetLegoInnerR(Float_t rad = 0.5)
        # gStyle.SetNumberContours(Int_t number = 20)

        gStyle.SetEndErrorSize(2)
        # gStyle.SetErrorMarker(20)
        gStyle.SetErrorX(0.)

        gStyle.SetMarkerStyle(20)

        #For the fit/function:
        gStyle.SetOptFit(1)
        gStyle.SetFitFormat("5.4g")
        gStyle.SetFuncColor(2)
        gStyle.SetFuncStyle(1)
        gStyle.SetFuncWidth(1)

        #For the date:
        gStyle.SetOptDate(0)
        # gStyle.SetDateX(Float_t x = 0.01)
        # gStyle.SetDateY(Float_t y = 0.01)

        # For the statistics box:
        gStyle.SetOptFile(0)
        gStyle.SetOptStat(
            0)  # To display the mean and RMS:         SetOptStat("mr")
        gStyle.SetStatColor(kWhite)
        gStyle.SetStatFont(42)
        gStyle.SetStatFontSize(0.025)
        gStyle.SetStatTextColor(1)
        gStyle.SetStatFormat("6.4g")
        gStyle.SetStatBorderSize(1)
        gStyle.SetStatH(0.1)
        gStyle.SetStatW(0.15)
        # gStyle.SetStatStyle(Style_t style = 1001)
        # gStyle.SetStatX(Float_t x = 0)
        # gStyle.SetStatY(Float_t y = 0)

        # Margins:
        gStyle.SetPadTopMargin(0.05)
        gStyle.SetPadBottomMargin(0.13)
        gStyle.SetPadLeftMargin(0.16)
        gStyle.SetPadRightMargin(0.02)

        # For the Global title:

        gStyle.SetOptTitle(0)
        gStyle.SetTitleFont(42)
        gStyle.SetTitleColor(1)
        gStyle.SetTitleTextColor(1)
        gStyle.SetTitleFillColor(10)
        gStyle.SetTitleFontSize(0.05)
        # gStyle.SetTitleH(0) # Set the height of the title box
        # gStyle.SetTitleW(0) # Set the width of the title box
        # gStyle.SetTitleX(0) # Set the position of the title box
        # gStyle.SetTitleY(0.985) # Set the position of the title box
        # gStyle.SetTitleStyle(Style_t style = 1001)
        # gStyle.SetTitleBorderSize(2)

        # For the axis titles:

        gStyle.SetTitleColor(1, "XYZ")
        gStyle.SetTitleFont(42, "XYZ")
        gStyle.SetTitleSize(0.06, "XYZ")
        # gStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size?
        # gStyle.SetTitleYSize(Float_t size = 0.02)
        gStyle.SetTitleXOffset(0.9)
        gStyle.SetTitleYOffset(1.25)
        # gStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset

        # For the axis labels:

        gStyle.SetLabelColor(1, "XYZ")
        gStyle.SetLabelFont(42, "XYZ")
        gStyle.SetLabelOffset(0.007, "XYZ")
        gStyle.SetLabelSize(0.05, "XYZ")

        # For the axis:

        gStyle.SetAxisColor(1, "XYZ")
        gStyle.SetStripDecimals(True)
        gStyle.SetTickLength(0.03, "XYZ")
        gStyle.SetNdivisions(510, "XYZ")
        gStyle.SetPadTickX(
            1)  # To get tick marks on the opposite side of the frame
        gStyle.SetPadTickY(1)

        # Change for log plots:
        gStyle.SetOptLogx(0)
        gStyle.SetOptLogy(0)
        gStyle.SetOptLogz(0)

        # Postscript options:
        gStyle.SetPaperSize(20., 20.)
Example #21
0
def rootStyle(batchMode=True):
    from ROOT import gROOT, gStyle, kWhite, kBlack

    # No info messages
    gROOT.ProcessLine("gErrorIgnoreLevel = kWarning;")

    # Batch mode (no TCanvas)
    gROOT.SetBatch(batchMode)

    # Start from a plain default
    gROOT.SetStyle("Plain")

    lhcbMarkerType = 8
    lhcbMarkerSize = 0.8
    lhcbFont = 62
    lhcbStatFontSize = 0.02
    lhcbStatBoxWidth = 0.12
    lhcbStatBoxHeight = 0.12
    lhcbWidth = 1
    lhcbTextSize = 0.05
    lhcbLabelSize = 0.035
    lhcbAxisLabelSize = 0.035
    lhcbForeColour = kBlack

    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBorderMode(0)

    # canvas options
    gStyle.SetCanvasBorderSize(0)
    gStyle.SetCanvasBorderMode(0)

    # fonts
    gStyle.SetTextFont(lhcbFont)
    gStyle.SetTextSize(lhcbTextSize)
    gStyle.SetLabelFont(lhcbFont, "x")
    gStyle.SetLabelFont(lhcbFont, "y")
    gStyle.SetLabelFont(lhcbFont, "z")
    gStyle.SetLabelSize(lhcbLabelSize, "x")
    gStyle.SetLabelSize(lhcbLabelSize, "y")
    gStyle.SetLabelSize(lhcbLabelSize, "z")
    gStyle.SetTitleFont(lhcbFont)
    gStyle.SetTitleSize(lhcbAxisLabelSize, "x")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "y")
    gStyle.SetTitleSize(lhcbAxisLabelSize, "z")
    gStyle.SetTitleColor(kWhite)
    gStyle.SetTitleFillColor(kWhite)
    gStyle.SetTitleColor(kBlack)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(kBlack)

    # set title position
    gStyle.SetTitleX(0.15)
    gStyle.SetTitleY(0.97)
    # turn off Title box
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleTextColor(lhcbForeColour)
    gStyle.SetTitleColor(lhcbForeColour)

    # use bold lines and markers
    gStyle.SetLineWidth(lhcbWidth)
    gStyle.SetFrameLineWidth(lhcbWidth)
    gStyle.SetHistLineWidth(lhcbWidth)
    gStyle.SetFuncWidth(lhcbWidth)
    gStyle.SetGridWidth(lhcbWidth)
    gStyle.SetLineStyleString(2, "[12 12]")
    gStyle.SetMarkerStyle(lhcbMarkerType)
    gStyle.SetMarkerSize(lhcbMarkerSize)

    # label offsets
    gStyle.SetLabelOffset(0.015)

    # by default, do not display histogram decorations:
    gStyle.SetOptStat(1111)
    # show probability, parameters and errors
    gStyle.SetOptFit(1011)

    # look of the statistics box:
    gStyle.SetStatBorderSize(1)
    gStyle.SetStatFont(lhcbFont)
    gStyle.SetStatFontSize(lhcbStatFontSize)
    gStyle.SetStatX(0.9)
    gStyle.SetStatY(0.9)
    gStyle.SetStatW(lhcbStatBoxWidth)
    gStyle.SetStatH(lhcbStatBoxHeight)

    # put tick marks on top and RHS of plots
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    # histogram divisions
    gStyle.SetNdivisions(505, "x")
    gStyle.SetNdivisions(510, "y")

    # Force the style
    gROOT.ForceStyle()
def setStyle():

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetPadBottomMargin(0.12)
    gStyle.SetPadLeftMargin(0.12)
    gStyle.SetCanvasColor(ROOT.kWhite)
    gStyle.SetCanvasDefH(600)
    #Height of canvas
    gStyle.SetCanvasDefW(600)
    #Width of canvas
    gStyle.SetCanvasDefX(0)
    #POsition on screen
    gStyle.SetCanvasDefY(0)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    #0.13);
    gStyle.SetPadLeftMargin(0.11)
    #0.16);
    gStyle.SetPadRightMargin(0.05)
    #0.02);

    # For the Pad:
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadColor(ROOT.kWhite)
    gStyle.SetPadGridX(ROOT.kFALSE)
    gStyle.SetPadGridY(ROOT.kFALSE)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

    # For the frame:
    gStyle.SetFrameBorderMode(0)
    gStyle.SetFrameBorderSize(1)
    gStyle.SetFrameFillColor(0)
    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(1)
    gStyle.SetFrameLineWidth(1)

    gStyle.SetAxisColor(1, "XYZ")
    gStyle.SetStripDecimals(ROOT.kTRUE)
    gStyle.SetTickLength(0.03, "XYZ")
    gStyle.SetNdivisions(505, "XYZ")
    gStyle.SetPadTickX(1)
    # To get tick marks on the opposite side of the frame
    gStyle.SetPadTickY(1)
    gStyle.SetGridColor(0)
    gStyle.SetGridStyle(3)
    gStyle.SetGridWidth(1)

    gStyle.SetTitleColor(1, "XYZ")
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.05, "XYZ")
    gStyle.SetTitleXOffset(1.15)
    #0.9);
    gStyle.SetTitleYOffset(1.3)
    # => 1.15 if exponents

    gStyle.SetLabelColor(1, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelOffset(0.007, "XYZ")
    gStyle.SetLabelSize(0.045, "XYZ")

    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetTitleTextColor(1)
    gStyle.SetTitleFillColor(10)
    gStyle.SetTitleFontSize(0.05)

    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetOptFit(1)

    NRGBs = 5
    NCont = 255
    stops = [0.00, 0.34, 0.61, 0.84, 1.00]
    red = [0.00, 0.00, 0.87, 1.00, 0.51]
    green = [0.00, 0.81, 1.00, 0.20, 0.00]
    blue = [0.51, 1.00, 0.12, 0.00, 0.00]
    stopsArray = array('d', stops)
    redArray = array('d', red)
    greenArray = array('d', green)
    blueArray = array('d', blue)
    TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray,
                                    blueArray, NCont)
    gStyle.SetNumberContours(NCont)
def set_root_env():
    #//TStyle* genieStyle = new TStyle("genieStyle", "GENIE Style")
    #//set the background color to white
    gStyle.SetFillColor(10)
    gStyle.SetFrameFillColor(10)
    gStyle.SetCanvasColor(10)
    gStyle.SetPadColor(10)
    gStyle.SetTitleFillColor(0)
    gStyle.SetStatColor(10)

    #dont put a colored frame around the plots
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetLegendBorderSize(3)

    #use the primary color palette
    #gStyle.SetPalette(1,0)

    #set the default line color for a histogram to be black
    gStyle.SetHistLineColor(ROOT.kBlack)

    #set the default line color for a fit function to be red
    gStyle.SetFuncColor(ROOT.kRed)

    #make the axis labels black
    gStyle.SetLabelColor(ROOT.kBlack, "xyz")

    #set the default title color to be black
    gStyle.SetTitleColor(ROOT.kBlack)

    #set the margins
    gStyle.SetPadBottomMargin(0.18)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadLeftMargin(0.17)

    #set axis label and title text sizes
    gStyle.SetLabelFont(42, "xyz")
    gStyle.SetLabelSize(0.04, "xyz")
    gStyle.SetLabelOffset(0.015, "xyz")
    gStyle.SetTitleFont(42, "xyz")
    gStyle.SetTitleSize(0.04, "xyz")
    gStyle.SetTitleOffset(1.4, "y")
    gStyle.SetTitleOffset(1.3, "x")
    gStyle.SetStatFont(42)
    gStyle.SetStatFontSize(0.07)
    gStyle.SetTitleBorderSize(1)
    gStyle.SetStatBorderSize(0)
    gStyle.SetTextFont(42)
    gStyle.SetTitleW(0.5)
    gStyle.SetTitleH(0.1)

    #set line widths
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    gStyle.SetHistLineWidth(2)

    #set the number of divisions to show
    gStyle.SetNdivisions(506, "xy")
    #gStyle.SetPadTickX(-50202)

    #turn off xy grids
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    #set the tick mark style
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    #turn off stats
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    #marker/line settings
    #gStyle.SetMarkerStyle(20)
    gStyle.SetMarkerSize(.95)  #0.7
    gStyle.SetLineWidth(2)
    gStyle.SetErrorX(0)
    gStyle.SetHistLineStyle(0)  #It was 3 for a dotted line

    #done
    gStyle.cd()
    gROOT.ForceStyle()
Example #24
0
# pylint: disable=missing-function-docstring, missing-class-docstring
# pylint: disable=fixme
import datetime

import numpy as np

from root_numpy import fill_hist # pylint: disable=import-error
from ROOT import TH1F, TH2F, TFile, TCanvas, TLegend, TPaveText, gPad # pylint: disable=import-error, no-name-in-module
from ROOT import gStyle, kWhite, kBlue, kGreen, kRed, kCyan, kOrange, kMagenta # pylint: disable=import-error, no-name-in-module
from ROOT import gROOT  # pylint: disable=import-error, no-name-in-module

gROOT.SetStyle("Plain")
gROOT.SetBatch()
gStyle.SetOptStat(0)
gStyle.SetTextFont(42)
gStyle.SetLabelFont(42, "xyz")
gStyle.SetTitleFont(42, "xyz")

def create_apply_histos(config, suffix, infix=""):
    h_dist = TH2F("%s_%s%s" % (config.h_dist_name, infix, suffix),
                  "", 500, -5, 5, 500, -5, 5)
    h_deltas = TH1F("%s_%s%s" % (config.h_deltas_name, infix, suffix),  "", 1000, -1., 1.)
    h_deltas_vs_dist = TH2F("%s_%s%s" % \
                            (config.h_deltas_vs_dist_name, infix, suffix),
                            "", 500, -5.0, 5.0, 100, -0.5, 0.5)
    return h_dist, h_deltas, h_deltas_vs_dist

def fill_std_dev_apply_hist(h_deltas_vs_dist, hist_name, suffix, infix=""):
    h1tmp = h_deltas_vs_dist.ProjectionX("h1tmp")
    h_std_dev = h1tmp.Clone("%s_%s%s" % (hist_name, infix, suffix))
    h_std_dev.Reset()
Example #25
0
def setStyle():
    gStyle.SetCanvasColor(0)
    gStyle.SetCanvasBorderSize(10)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetCanvasDefH(700)
    gStyle.SetCanvasDefW(700)

    gStyle.SetPadColor(0)
    gStyle.SetPadBorderSize(10)
    gStyle.SetPadBorderMode(0)
    gStyle.SetPadBottomMargin(0.13)
    gStyle.SetPadTopMargin(0.08)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    gStyle.SetFrameFillStyle(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetFrameLineColor(1)
    gStyle.SetFrameLineStyle(0)
    gStyle.SetFrameLineWidth(1)
    gStyle.SetFrameBorderSize(10)
    gStyle.SetFrameBorderMode(0)

    gStyle.SetNdivisions(505)

    gStyle.SetLineWidth(2)
    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetLegendFillColor(root.kWhite)
    gStyle.SetLegendFont(42)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetMarkerStyle(20)

    gStyle.SetLabelSize(0.040, "X")
    gStyle.SetLabelSize(0.040, "Y")

    gStyle.SetLabelOffset(0.010, "X")
    gStyle.SetLabelOffset(0.010, "Y")

    gStyle.SetLabelFont(42, "X")
    gStyle.SetLabelFont(42, "Y")

    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFont(42)
    gStyle.SetTitleFont(42, "X")
    gStyle.SetTitleFont(42, "Y")

    gStyle.SetTitleSize(0.045, "X")
    gStyle.SetTitleSize(0.045, "Y")

    gStyle.SetTitleOffset(1.4, "X")
    gStyle.SetTitleOffset(1.4, "Y")

    gStyle.SetTextSize(0.055)
    gStyle.SetTextFont(42)

    gStyle.SetOptStat(0)
Example #26
0
def CLICdpStyle():
    gROOT.SetStyle("Plain")
    gStyle.SetCanvasColor(root.kWhite)
    gStyle.SetFrameFillColor(root.kWhite)
    gStyle.SetStatColor(root.kWhite)
    gStyle.SetPadColor(root.kWhite)
    gStyle.SetFillColor(10)
    gStyle.SetTitleFillColor(root.kWhite)

    gStyle.SetPaperSize(20, 26)

    gStyle.SetDrawBorder(0)
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetPadBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetLegendBorderSize(0)

    gStyle.SetTextSize(0.05)
    gStyle.SetTitleSize(0.06, "xyz")
    gStyle.SetLabelSize(0.06, "xyz")

    gStyle.SetLabelOffset(0.015, "xyz")
    gStyle.SetTitleOffset(1.2, "yz")
    gStyle.SetTitleOffset(1.17, "x")

    font = 42
    gStyle.SetTitleFont(font)
    gStyle.SetTitleFontSize(0.06)
    gStyle.SetStatFont(font)
    gStyle.SetStatFontSize(0.07)
    gStyle.SetTextFont(font)
    gStyle.SetLabelFont(font, "xyz")
    gStyle.SetTitleFont(font, "xyz")
    gStyle.SetTitleBorderSize(0)
    gStyle.SetStatBorderSize(1)
    gStyle.SetMarkerStyle(1)
    gStyle.SetLineWidth(2)
    gStyle.SetMarkerSize(1.2)
    gStyle.SetPalette(1)

    gStyle.SetOptTitle(0)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetEndErrorSize(5)

    gStyle.SetHistLineWidth(2)
    gStyle.SetFrameLineWidth(2)
    gStyle.SetFuncWidth(2)
    gStyle.SetHistLineColor(root.kBlack)
    gStyle.SetFuncColor(root.kBlack)
    gStyle.SetLabelColor(root.kBlack, "xyz")

    gStyle.SetPadBottomMargin(0.18)
    gStyle.SetPadTopMargin(0.11)
    gStyle.SetPadRightMargin(0.08)
    gStyle.SetPadLeftMargin(0.17)

    gStyle.SetNdivisions(506, "xy")

    gStyle.SetPadGridX(0)
    gStyle.SetPadGridY(0)

    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)

    gStyle.SetCanvasDefW(800)
    gStyle.SetCanvasDefH(700)

    gROOT.ForceStyle()
Example #27
0
def main(options, args):

    from ROOT import gSystem, gROOT, gStyle
    gROOT.SetBatch()
    gSystem.Load("libRooFitCore")

    if options.doWebPage:
        from lip.Tools.rootutils import loadToolsLib, apply_modifs
        loadToolsLib()

    from ROOT import TFile, RooFit, RooArgSet, RooDataHist, RooKeysPdf, RooHistPdf, TCanvas, TLegend, TLatex, TArrow, TPaveText, RooAddPdf, RooArgList
    from ROOT import kWhite, kBlue, kOpenSquare
    if options.doWebPage:
        from ROOT import HtmlHelper, HtmlTag, HtmlTable, HtmlPlot

    rootglobestyle.setTDRStyle()
    gStyle.SetMarkerSize(1.5)
    gStyle.SetTitleYOffset(1.5)

    gStyle.SetPadLeftMargin(0.16)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.13)

    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelOffset(0.007, "XYZ")
    gStyle.SetLabelSize(0.05, "XYZ")

    gStyle.SetTitleSize(0.06, "XYZ")
    gStyle.SetTitleXOffset(0.9)
    gStyle.SetTitleYOffset(1.24)
    gStyle.SetTitleFont(42, "XYZ")

    ##
    ## Read files
    ##
    options.outdir = "%s_m%1.0f" % (options.outdir, options.mH)
    if options.fp:
        options.outdir += "_fp"

    ncat = options.ncat
    cats = options.cats
    if cats is "":
        categories = ["_cat%d" % i for i in range(0, ncat)]
    else:
        categories = ["_cat%s" % i for i in cats.split(",")]

    if options.mva:
        clables = {
            "_cat0": ("MVA > 0.89", ""),
            "_cat1": ("0.74 #leq MVA", "MVA < 0.89"),
            "_cat2": ("0.545 #leq MVA", "MVA < 0.74"),
            "_cat3": ("0.05 #leq MVA", "MVA < 0.545"),
            "_cat4": ("Di-jet", "Tagged"),
            "_cat5": ("Di-jet", "Tagged"),
            "_combcat": ("All Classes", "Combined")
        }
    else:
        clables = {
            "_cat0": ("max(|#eta|<1.5", "min(R_{9})>0.94"),
            "_cat1": ("max(|#eta|<1.5", "min(R_{9})<0.94"),
            "_cat2": ("max(|#eta|>1.5", "min(R_{9})>0.94"),
            "_cat3": ("max(|#eta|>1.5", "min(R_{9})<0.94"),
            "_cat4": ("Di-jet", "Tagged"),
            "_cat5": ("Di-jet", "Tagged"),
            "_combcat": ("All Classes", "Combined")
        }
    helper = Helper()

    fin = TFile.Open(options.infile)
    helper.files.append(fin)
    ws = fin.Get("cms_hgg_workspace")
    mass = ws.var("CMS_hgg_mass")
    mass.SetTitle("m_{#gamma#gamma}")
    mass.setUnit("GeV")
    mass.setRange(100., 150.)
    mass.setBins(100, "plot")
    mass.setBins(5000)

    print ws

    aset = RooArgSet(mass)

    helper.objs.append(mass)
    helper.objs.append(aset)

    fitopt = (RooFit.Minimizer("Minuit2", ""), RooFit.Minos(False),
              RooFit.SumW2Error(False), RooFit.NumCPU(8))

    if not options.binned and not options.refit:
        finpdf = TFile.Open(options.infilepdf)
        helper.files.append(finpdf)
        wspdf = finpdf.Get("wsig")
    else:
        wspdf = ws

    for c in categories:
        processes = ["ggh", "vbf", "wzh"]
        if options.fp:
            processes = ["vbf", "wzh"]
        ### elif clables[c][0] == "Di-jet":
        ###     processes = [ "vbf", "ggh" ]

        dsname = "sig_mass_m%1.0f%s" % (options.mH, c)
        print dsname
        print ws
        ds = ws.data("sig_%s_mass_m%1.0f%s" %
                     (processes[0], options.mH, c)).Clone(dsname)
        for proc in processes[1:]:
            ds.append(ws.data("sig_%s_mass_m%1.0f%s" % (proc, options.mH, c)))
        helper.dsets.append(ds)

        if options.binned:
            binned_ds = RooDataHist("binned_%s" % dsname, "binned_%s" % dsname,
                                    aset, ds)
            pdf = RooKeysPdf("pdf_%s_%s" % (dsname, f), "pdf_%s" % dsname,
                             mass, ds)
            plot_pdf = RooHistPdf("pdf_%s" % dsname, "pdf_%s" % dsname, aset,
                                  plot_ds)
            helper.add(binned_ds, binned_ds.GetName())
        else:
            if options.refit:
                if options.refitall and clables[c][0] != "Di-jet":
                    rpdfs = []
                    for proc in processes:
                        for ngaus in range(1, 4):
                            pp = build_pdf(ws, "%s_%s" % (c, proc), ngaus,
                                           ngaus == 3)
                            pp.fitTo(
                                ws.data("sig_%s_mass_m%1.0f%s" %
                                        (proc, options.mH, c)),
                                RooFit.Strategy(0), *fitopt)
                        rpdfs.append(pp)
                    pdf = RooAddPdf("hggpdfrel%s" % c, "hggpdfrel%s" % c,
                                    RooArgList(*tuple(rpdfs)))
                else:
                    if options.refitall and clables[c][0] == "Di-jet":
                        for ngaus in range(1, 5):
                            pdf = build_pdf(ws, c, ngaus, ngaus == 5)
                            pdf.fitTo(ds, RooFit.Strategy(0), *fitopt)
                    else:
                        for ngaus in range(1, 4):
                            pdf = build_pdf(ws, c, ngaus, ngaus == 3)
                            pdf.fitTo(ds, RooFit.Strategy(0), *fitopt)
            else:
                pdfs = (wspdf.pdf("hggpdfrel%s_%s" % (c, p))
                        for p in processes)
                pdf = RooAddPdf("hggpdfrel%s" % c, "hggpdfrel%s" % c,
                                RooArgList(*pdfs))
            helper.add(pdf, pdf.GetName())
            plot_pdf = pdf.Clone("pdf_%s" % dsname)

        plot_ds = RooDataHist("plot_%s" % dsname, "plot_%s" % dsname, aset,
                              "plot")
        plot_ds.add(ds)

        cdf = pdf.createCdf(aset)
        hmin, hmax, hm = get_FWHM(mass, pdf, cdf, options.mH - 10.,
                                  options.mH + 10.)
        wmin, wmax = get_eff_sigma(mass, pdf, cdf, options.mH - 10.,
                                   options.mH + 10.)
        ### hmin, hmax, hm = get_FWHM( points )

        helper.add(plot_ds, plot_ds.GetName())
        helper.add(plot_pdf, plot_pdf.GetName())
        helper.add((wmin, wmax), "eff_sigma%s" % c)
        helper.add((hmin, hmax, hm), "FWHM%s" % c)
        helper.add(ds.sumEntries(),
                   "sumEntries%s" % c)  # signal model integral

        # data integral for PAS tables
        data = ws.data("data_mass%s" % c)
        helper.add(
            data.sumEntries("CMS_hgg_mass>=%1.4f && CMS_hgg_mass<=%1.4f" %
                            (options.mH - 10., options.mH + 10.)),
            "data_sumEntries%s" % c)

        del cdf
        del pdf

    dsname = "sig_mass_m%1.0f_combcat" % options.mH
    print dsname
    combined_ds = helper.dsets[0].Clone(dsname)
    for d in helper.dsets[1:]:
        combined_ds.append(d)

    if options.binned:
        binned_ds = RooDataHist("binned_%s" % dsname, "binned_%s" % dsname,
                                aset, combined_ds)
        pdf = RooKeysPdf("pdf_%s" % (dsname), "pdf_%s" % dsname, mass,
                         combined_ds)
        plot_pdf = RooHistPdf("pdf_%s" % dsname, "pdf_%s" % dsname, aset,
                              plot_ds)
        helper.add(binned_ds, binned_ds.GetName())
    else:
        #### pdf = build_pdf(ws,"_combcat")
        #### pdf.fitTo(combined_ds, RooFit.Strategy(0), *fitopt )
        #### plot_pdf = pdf.Clone( "pdf_%s" % dsname )
        pdf = RooAddPdf(
            "pdf_%s" % dsname, "pdf_%s" % dsname,
            RooArgList(*(helper.histos["hggpdfrel%s" % c]
                         for c in categories)))
        plot_pdf = pdf

    cdf = pdf.createCdf(aset)

    plot_ds = RooDataHist("plot_%s" % dsname, "plot_%s" % dsname, aset, "plot")
    plot_ds.add(combined_ds)

    wmin, wmax = get_eff_sigma(mass, pdf, cdf, options.mH - 10.,
                               options.mH + 10.)
    hmin, hmax, hm = get_FWHM(mass, pdf, cdf, options.mH - 10.,
                              options.mH + 10.)

    helper.add(plot_ds, plot_ds.GetName())
    helper.add(plot_pdf, plot_pdf.GetName())
    helper.add((wmin, wmax), "eff_sigma_combcat")
    helper.add((hmin, hmax, hm), "FWHM_combcat")
    helper.add(plot_ds.sumEntries(), "sumEntries_combcat")

    mass.setRange("higgsrange", options.mH - 25., options.mH + 15.)

    del cdf
    del pdf
    del helper.dsets

    ### label = TLatex(0.1812081,0.8618881,"#scale[0.8]{#splitline{CMS preliminary}{Simulation}}")
    label = TLatex(0.7, 0.86,
                   "#scale[0.65]{#splitline{CMS preliminary}{Simulation}}")
    label.SetNDC(1)

    ##
    ## Make web page with plots
    ##
    if options.doWebPage:
        hth = HtmlHelper(options.outdir)
        hth.navbar().cell(HtmlTag("a")).firstChild().txt("..").set(
            "href", "../?C=M;O=D")
        hth.navbar().cell(HtmlTag("a")).firstChild().txt("home").set(
            "href", "./")

        tab = hth.body().add(HtmlTable())

    ip = 0
    for c in ["_combcat"] + categories:
        ### for c in categories:
        if options.doWebPage and ip % 4 == 0:
            row = tab.row()
        ip = ip + 1

        dsname = "sig_mass_m%1.0f%s" % (options.mH, c)
        canv = TCanvas(dsname, dsname, 600, 600)
        helper.objs.append(canv)

        ### leg = TLegend(0.4345638,0.6835664,0.9362416,0.9178322)
        leg = TLegend(0.2, 0.96, 0.5, 0.55)
        #apply_modifs( leg, [("SetLineColor",kWhite),("SetFillColor",kWhite),("SetFillStyle",0),("SetLineStyle",0)] )

        hplotcompint = mass.frame(RooFit.Bins(250), RooFit.Range("higgsrange"))
        helper.objs.append(hplotcompint)
        helper.objs.append(leg)

        plot_ds = helper.histos["plot_%s" % dsname]
        plot_pdf = helper.histos["pdf_%s" % dsname]
        wmin, wmax = helper.histos["eff_sigma%s" % c]
        hmin, hmax, hm = helper.histos["FWHM%s" % c]
        print hmin, hmax, hm

        style = (RooFit.LineColor(kBlue), RooFit.LineWidth(2),
                 RooFit.FillStyle(0))
        style_seff = (
            RooFit.LineWidth(2),
            RooFit.FillStyle(1001),
            RooFit.VLines(),
            RooFit.LineColor(15),
        )
        style_ds = (RooFit.MarkerStyle(kOpenSquare), )

        plot_ds.plotOn(hplotcompint, RooFit.Invisible())

        plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"),
                        RooFit.Range(wmin, wmax), RooFit.FillColor(19),
                        RooFit.DrawOption("F"), *style_seff)
        seffleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1))
        plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"),
                        RooFit.Range(wmin, wmax), RooFit.LineColor(15),
                        *style_seff)

        plot_pdf.plotOn(hplotcompint, RooFit.NormRange("higgsrange"),
                        RooFit.Range("higgsrange"), *style)
        pdfleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1))

        plot_ds.plotOn(hplotcompint, *style_ds)
        pointsleg = hplotcompint.getObject(int(hplotcompint.numItems() - 1))

        iob = int(hplotcompint.numItems() - 1)
        leg.AddEntry(pointsleg, "Simulation", "pe")
        leg.AddEntry(pdfleg, "Parametric model", "l")
        leg.AddEntry(seffleg,
                     "#sigma_{eff} = %1.2f GeV " % (0.5 * (wmax - wmin)), "fl")

        clabel = TLatex(0.74, 0.65,
                        "#scale[0.65]{#splitline{%s}{%s}}" % clables[c])
        clabel.SetNDC(1)
        helper.objs.append(clabel)

        hm = hplotcompint.GetMaximum() * 0.5 * 0.9
        ### hm = pdfleg.GetMaximum()*0.5
        fwhmarrow = TArrow(hmin, hm, hmax, hm)
        fwhmarrow.SetArrowSize(0.03)
        helper.objs.append(fwhmarrow)
        fwhmlabel = TPaveText(0.20, 0.58, 0.56, 0.48, "brNDC")
        fwhmlabel.SetFillStyle(0)
        fwhmlabel.SetLineColor(kWhite)
        reducedFWHM = (hmax - hmin) / 2.3548200
        fwhmlabel.AddText("FWHM/2.35 = %1.2f GeV" % reducedFWHM)
        helper.objs.append(fwhmlabel)

        hplotcompint.SetTitle("")
        hplotcompint.GetXaxis().SetNoExponent(True)
        hplotcompint.GetXaxis().SetTitle("m_{#gamma#gamma} (GeV)")
        hplotcompint.GetXaxis().SetNdivisions(509)
        ## hplotcompint.GetYaxis().SetTitle("A.U.");
        ## hplotcompint.GetYaxis().SetRangeUser(0.,hplotcompint.GetMaximum()*1.4);
        hplotcompint.Draw()
        leg.Draw("same")
        label.Draw("same")
        clabel.Draw("same")
        fwhmarrow.Draw("<>")
        fwhmlabel.Draw("same")

        plot_ds.sumEntries()

        if options.doWebPage:
            hpl = HtmlPlot(canv, False, "", True, True, True)
            hpl.caption("<i>%s</i>" % canv.GetTitle())
            row.cell(hpl)
        else:
            if os.path.isdir(options.outdir) is False:
                os.mkdir(options.outdir)
            for ext in "C", "png", "pdf":
                canv.SaveAs(
                    os.path.join(options.outdir,
                                 "%s.%s" % (canv.GetName(), ext)))

        if "comb" in c:
            ip = 0

    if options.doWebPage:
        print "Creating pages..."
        hth.dump()

    for f in helper.files:
        f.Close()
    gROOT.Reset()

    from pprint import pprint
    pprint(helper)

    print 'Summary statistics per event class'
    print 'Cat\tSignal\t\tData/GeV (in %3.1f+/-10)\tsigEff\tFWHM/2.35' % options.mH
    sigTotal = 0.
    dataTotal = 0.
    for c in categories:
        sigVal = helper.histos["sumEntries%s" % c]
        datVal = helper.histos["data_sumEntries%s" % c]
        sigTotal += sigVal
        dataTotal += datVal
    for c in categories:
        sigVal = helper.histos["sumEntries%s" % c]
        datVal = helper.histos["data_sumEntries%s" % c]
        effSig = 0.5 * (helper.histos["eff_sigma%s" % c][1] -
                        helper.histos["eff_sigma%s" % c][0])
        fwhm = (helper.histos["FWHM%s" % c][1] -
                helper.histos["FWHM%s" % c][0]) / 2.3548200
        print c, '\t%3.1f (%3.1f%%)\t%3.1f (%3.1f%%)\t\t\t%2.2f\t%2.2f' % (
            sigVal, 100. * sigVal / sigTotal, datVal /
            (10. + 10.), 100. * datVal / dataTotal, effSig, fwhm)

    print "Done."
Example #28
0
### style parameters
gROOT.SetStyle("Plain")
gROOT.SetBatch(True)
gStyle.SetLegendFillColor(0)
gStyle.SetLegendBorderSize(0)
gStyle.SetStatBorderSize(0)
gStyle.SetTitleBorderSize(0)
gStyle.SetPadTickX(1)
gStyle.SetPadTickY(1)
gStyle.SetTitleX(0.14) ## to be changed to 0.15
gStyle.SetTitleY(0.96)
gStyle.SetTitleW(0.8)
gStyle.SetTextFont(42)
gStyle.SetLegendFont(42)
gStyle.SetLabelFont(42, 'xy')
gStyle.SetTitleFont(42, 'xy')

tauScale   = '0.03'
shiftedMet = 'sqrt(pow(mex+'+tauScale+'*l1Px+'+tauScale+'*l2Px,2)+pow(mey+'+tauScale+'*l1Py+'+tauScale+'*l2Py,2))' 

baseline           =  ' l1Pt>45 && l2Pt>45 && abs(l1Eta)<2.1 && abs(l2Eta)<2.1 && diTauCharge!=0 '

#### should be redundant once skimmed
baseline           += ' && l1LooseEle>0.5  && l2LooseEle>0.5 '
baseline           += ' && l1LooseMu >0.5  && l2LooseMu >0.5 '
baseline           += ' && l2againstElectronNewLooseMVA3>0.5 '
######################################

# baseline           += ' && nbJets == 0'
baseline           += ' && muon1Pt==-1 && electron1Pt==-1 '
def main():
    # usage description
    usage = "Example: ./scripts/plotSignificance.py -l logs -f qq --massrange 1200 6000 100"
    # input parameters
    parser = ArgumentParser(
        description='Script that plots significance for specified mass points',
        epilog=usage)
    parser.add_argument('analysis', type=str, help='Analysis name')
    parser.add_argument('model', type=str, help='Model name')

    parser.add_argument("-M",
                        "--method",
                        dest="method",
                        choices=['ProfileLikelihood', 'HybridNew', 'theta'],
                        default='ProfileLikelihood',
                        help="Method to calculate upper limits",
                        metavar="METHOD")
    parser.add_argument(
        '--fit_function',
        type=str,
        default="dijet4",
        help="Name of fit function used for background estimate")

    parser.add_argument(
        "--sigRange",
        dest="sigRange",
        type=float,
        default=2.5,
        help="Significance range to plot (default: %(default)f)")

    parser.add_argument(
        "--postfix",
        dest="postfix",
        default='',
        help="Postfix for the output plot name (default: %(default)s)")

    parser.add_argument(
        "--fileFormat",
        dest="fileFormat",
        default='pdf',
        help="Format of the output plot (default: %(default)s)")

    parser.add_argument("--extraText",
                        dest="extraText",
                        default='Preliminary',
                        help="Extra text on the plot (default: %(default)s)")

    parser.add_argument(
        "--lumi_sqrtS",
        dest="lumi_sqrtS",
        default='19.7 fb^{-1} (13 TeV)',
        help=
        "Integrated luminosity and center-of-mass energy (default: %(default)s)"
    )

    parser.add_argument("--printResults",
                        dest="printResults",
                        default=False,
                        action="store_true",
                        help="Print results to the screen")
    parser.add_argument('--fitTrigger',
                        action='store_true',
                        help="Use trigger fit")
    parser.add_argument('--correctTrigger',
                        action='store_true',
                        help="Use trigger correction")
    parser.add_argument('--useMCTrigger',
                        action='store_true',
                        help="Use MC trigger emulation")
    parser.add_argument("--noSyst",
                        action="store_true",
                        help="Make plots for limits without systematics")
    parser.add_argument(
        "--freezeNuisances",
        type=str,
        help="Make plots for limits with frozen nuisance parameters")

    mass_group = parser.add_mutually_exclusive_group(required=True)
    mass_group.add_argument(
        "--mass",
        type=int,
        nargs='*',
        default=1000,
        help=
        "Mass can be specified as a single value or a whitespace separated list (default: %(default)i)"
    )
    mass_group.add_argument(
        "--massrange",
        type=int,
        nargs=3,
        help="Define a range of masses to be produced. Format: min max step",
        metavar=('MIN', 'MAX', 'STEP'))
    mass_group.add_argument("--masslist",
                            help="List containing mass information")

    args = parser.parse_args()

    # mass points for which resonance shapes will be produced
    input_masses = []

    if args.massrange != None:
        MIN, MAX, STEP = args.massrange
        input_masses = range(MIN, MAX + STEP, STEP)
    elif args.masslist != None:
        # A mass list was provided
        print "Will create mass list according to", args.masslist
        masslist = __import__(args.masslist.replace(".py", ""))
        input_masses = masslist.masses
    else:
        input_masses = args.mass
    # sort masses
    input_masses.sort()

    # arrays holding results
    masses = array('d')
    significances = array('d')
    p0_values = array('d')

    for mass in input_masses:
        masses.append(mass)
        #print ">> Reading results for resonance with m = %i GeV..."%(int(mass))
        log_file = open(
            limit_config.get_combine_log_path(
                args.analysis,
                args.model,
                mass,
                args.fit_function,
                args.method,
                what="significance",
                systematics=(not args.noSyst),
                frozen_nps=args.freezeNuisances,
                fitTrigger=args.fitTrigger,
                correctTrigger=args.correctTrigger,
                useMCTrigger=args.useMCTrigger), 'r')

        if args.method == 'theta':
            logName = logName.replace('significance_', '')

        # read the log file
        for line in log_file:
            if args.method == 'theta':
                if re.search("^{'signal': {'Z':", line):
                    significances.append(
                        float(line.split()[-1].lstrip('[').rstrip('}').rstrip(
                            ']')))
            else:
                if re.search("^Significance:", line):
                    significances.append(float(line.split()[1]))
                elif re.search("^Null p-value:", line):
                    p0_values.append(float(line.split()[2]))

        if len(masses) != len(significances):
            print "** ERROR: ** Could not find significance for m =", int(
                mass), "GeV. Aborting."
            sys.exit(1)
        if len(masses) != len(p0_values):
            print "** ERROR: ** Could not find p0 value for m =", int(
                mass), "GeV. Aborting."
            sys.exit(1)
        # Allow only positive fluctuations
        if significances[-1] < 0:
            significances[-1] = 0.

    if args.printResults:
        print "masses =", masses.tolist()
        print "significances =", significances.tolist()
        print "p0_values =", p0_values.tolist()

    # import ROOT stuff
    from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend
    from ROOT import kGreen, kYellow, kWhite, kRed, kBlue

    gROOT.SetBatch(kTRUE)
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.06, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelSize(0.05, "XYZ")
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasColor(kWhite)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    gROOT.ForceStyle()

    graph_sig = TGraph(len(masses), masses, significances)
    graph_sig.GetXaxis().SetTitle("Resonance mass [GeV]")
    graph_sig.GetYaxis().SetTitle("p_0")
    graph_sig.GetYaxis().SetTitleOffset(1.2)
    graph_sig.GetYaxis().SetRangeUser(0., args.sigRange)
    graph_sig.SetLineWidth(2)
    graph_sig.SetLineColor(kRed)
    graph_sig.SetMarkerStyle(21)
    graph_sig.SetMarkerSize(1)
    graph_sig.SetMarkerColor(kBlue)

    c = TCanvas("c", "", 800, 800)
    c.cd()

    graph_sig.Draw("ALP")

    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS  # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    gPad.RedrawAxis()

    c.SetGridx()
    c.SetGridy()
    fileName = limit_config.paths[
        "limit_plots"] + '/significance_%s_%s_%s_%s.%s' % (
            args.method, args.analysis, args.model + args.postfix,
            args.fit_function, args.fileFormat.lower())
    c.SaveAs(fileName)
    #print "Significance plot saved to '%s'"%(fileName)

    graph_p0 = TGraph(len(masses), masses, p0_values)
    graph_p0.GetXaxis().SetTitle("Resonance mass [GeV]")
    graph_p0.GetYaxis().SetTitle("p_{0} (local)")
    graph_p0.GetYaxis().SetTitleOffset(1.2)
    graph_p0.GetYaxis().SetRangeUser(1.e-3, 1.)
    graph_p0.SetLineWidth(2)
    graph_p0.SetLineColor(kRed)
    graph_p0.SetMarkerStyle(21)
    graph_p0.SetMarkerSize(1)
    graph_p0.SetMarkerColor(kBlue)
    c_p0 = TCanvas("c_p0", "", 800, 800)
    c_p0.SetLogy()
    c_p0.cd()

    graph_p0.Draw("ALP")

    # draw the lumi text on the canvas
    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS  # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    #Root.CMSLabel(0.2, 0.2, "Internal", 1, 0.65)

    gPad.RedrawAxis()

    c_p0.SetGridx()
    c_p0.SetGridy()
    fileName = limit_config.paths["limit_plots"] + '/p0_%s_%s_%s_%s.%s' % (
        args.method, args.analysis, args.model + args.postfix,
        args.fit_function, args.fileFormat.lower())
    c_p0.SaveAs(fileName)
    print "p0 plot saved to '%s'" % (fileName)
Example #30
0
def main():
    # usage description
    usage = "Example: ./scripts/plotLimits.py -M Asymptotic -l logs -f qq --massrange 1200 7000 100"

    # input parameters
    parser = ArgumentParser(
        description='Script that plots limits for specified mass points',
        epilog=usage)

    parser.add_argument("-M",
                        "--method",
                        dest="method",
                        required=True,
                        choices=[
                            'ProfileLikelihood', 'HybridNew', 'Asymptotic',
                            'MarkovChainMC', 'theta'
                        ],
                        help="Method to calculate upper limits",
                        metavar="METHOD")

    results_group = parser.add_mutually_exclusive_group(required=True)
    results_group.add_argument("-l",
                               "--logs_path",
                               dest="logs_path",
                               help="Path to log files",
                               metavar="LOGS_PATH")
    results_group.add_argument("-r",
                               "--results_file",
                               dest="results_file",
                               help="Path to a file containing results",
                               metavar="RESULTS_FILE")

    parser.add_argument("-f",
                        "--final_state",
                        dest="final_state",
                        required=True,
                        help="Final state (e.g. qq, qg, gg)",
                        metavar="FINAL_STATE")

    parser.add_argument(
        "--postfix",
        dest="postfix",
        default='',
        help="Postfix for the output plot name (default: %(default)s)")

    parser.add_argument(
        "--fileFormat",
        dest="fileFormat",
        default='pdf',
        help="Format of the output plot (default: %(default)s)")

    parser.add_argument("--extraText",
                        dest="extraText",
                        default='Simulation Preliminary',
                        help="Extra text on the plot (default: %(default)s)")

    parser.add_argument(
        "--lumi_sqrtS",
        dest="lumi_sqrtS",
        default='1 fb^{-1} (13 TeV)',
        help=
        "Integrated luminosity and center-of-mass energy (default: %(default)s)"
    )

    parser.add_argument("--printResults",
                        dest="printResults",
                        default=False,
                        action="store_true",
                        help="Print results to the screen")

    mass_group = parser.add_mutually_exclusive_group(required=True)
    mass_group.add_argument(
        "--mass",
        type=int,
        nargs='*',
        default=1000,
        help=
        "Mass can be specified as a single value or a whitespace separated list (default: %(default)i)"
    )
    mass_group.add_argument(
        "--massrange",
        type=int,
        nargs=3,
        help="Define a range of masses to be produced. Format: min max step",
        metavar=('MIN', 'MAX', 'STEP'))
    mass_group.add_argument("--masslist",
                            help="List containing mass information")

    args = parser.parse_args()

    # mass points for which resonance shapes will be produced
    input_masses = []

    if args.massrange != None:
        MIN, MAX, STEP = args.massrange
        input_masses = range(MIN, MAX + STEP, STEP)
    elif args.masslist != None:
        # A mass list was provided
        print "Will create mass list according to", args.masslist
        masslist = __import__(args.masslist.replace(".py", ""))
        input_masses = masslist.masses
    else:
        input_masses = args.mass
    # sort masses
    input_masses.sort()

    # arrays holding results
    masses = array('d')
    xs_obs_limits = array('d')
    xs_exp_limits = array('d')
    masses_exp = array('d')
    xs_exp_limits_1sigma = array('d')
    xs_exp_limits_1sigma_up = array('d')
    xs_exp_limits_2sigma = array('d')
    xs_exp_limits_2sigma_up = array('d')

    if args.logs_path != None:

        logs_path = os.path.join(os.getcwd(), args.logs_path)

        for mass in input_masses:

            print ">> Reading results for %s resonance with m = %i GeV..." % (
                args.final_state, int(mass))

            masses.append(mass)
            if args.method == 'Asymptotic': masses_exp.append(mass)

            logName = 'limits_%s_%s_m%i.log' % (args.method, args.final_state,
                                                int(mass))

            if args.method == 'theta': logName = logName.replace('limits_', '')

            log_file = open(os.path.join(logs_path, logName), 'r')

            foundMethod = False

            # read the log file
            for line in log_file:
                if args.method == 'Asymptotic':
                    if re.search("^Observed Limit: r", line):
                        xs_obs_limits.append(float(line.split()[-1]))
                    if re.search("^Expected 50.0%: r", line):
                        xs_exp_limits.append(float(line.split()[-1]))
                    if re.search("^Expected 16.0%: r", line):
                        xs_exp_limits_1sigma.append(float(line.split()[-1]))
                    if re.search("^Expected 84.0%: r", line):
                        xs_exp_limits_1sigma_up.append(float(line.split()[-1]))
                    if re.search("^Expected  2.5%: r", line):
                        xs_exp_limits_2sigma.append(float(line.split()[-1]))
                    if re.search("^Expected 97.5%: r", line):
                        xs_exp_limits_2sigma_up.append(float(line.split()[-1]))
                elif args.method == 'theta':
                    if re.search('^# x; y; yerror', line):
                        foundMethod = True
                    if line.split()[0] == '0' and foundMethod:
                        xs_obs_limits.append(float(line.split()[1]))
                else:
                    if re.search(' -- ' + args.method, line):
                        foundMethod = True
                    if re.search("^Limit: r", line) and foundMethod:
                        xs_obs_limits.append(float(line.split()[3]))

            if len(masses) != len(xs_obs_limits):
                print "** ERROR: ** Could not find observed limit for m =", int(
                    mass), "GeV. Aborting."
                sys.exit(1)

            if args.method == 'Asymptotic':
                if len(masses) != len(xs_exp_limits):
                    print "** ERROR: ** Could not find expected limit for m =", int(
                        mass), "GeV. Aborting."
                    sys.exit(1)

                if len(masses) != len(xs_exp_limits_1sigma):
                    print "** ERROR: ** Could not find expected 1 sigma down limit for m =", int(
                        mass), "GeV. Aborting."
                    sys.exit(1)

                if len(masses) != len(xs_exp_limits_1sigma_up):
                    print "** ERROR: ** Could not find expected 1 sigma up limit for m =", int(
                        mass), "GeV. Aborting."
                    sys.exit(1)

                if len(masses) != len(xs_exp_limits_2sigma):
                    print "** ERROR: ** Could not find expected 2 sigma down limit for m =", int(
                        mass), "GeV. Aborting."
                    sys.exit(1)

                if len(masses) != len(xs_exp_limits_2sigma_up):
                    print "** ERROR: ** Could not find expected 2 sigma up limit for m =", int(
                        mass), "GeV. Aborting."
                    sys.exit(1)
        if args.method == 'Asymptotic':
            # complete the expected limit arrays
            for i in range(0, len(masses)):
                masses_exp.append(masses[len(masses) - i - 1])
                xs_exp_limits_1sigma.append(
                    xs_exp_limits_1sigma_up[len(masses) - i - 1])
                xs_exp_limits_2sigma.append(
                    xs_exp_limits_2sigma_up[len(masses) - i - 1])
    else:
        print ">> Importing results..."

        sys.path.insert(0, os.path.dirname(args.results_file))

        results = __import__(
            os.path.basename(args.results_file).replace(".py", ""))

        all_masses = np.array(results.masses)
        all_masses_exp = np.array(results.masses_exp)
        indices = []
        indices_exp = []

        # search for indices of input_masses
        for mass in input_masses:
            where = np.where(all_masses == mass)[0]
            if len(where) == 0:
                print "** WARNING: ** Cannot find results for m =", int(
                    mass
                ), "GeV in the provided results file. Skipping this mass point."
            indices.extend(where)
            if len(all_masses_exp) > 0:
                where = np.where(all_masses_exp == mass)[0]
                if len(where) == 0:
                    print "** WARNING: ** Cannot find results for m =", int(
                        mass
                    ), "GeV in the provided results file. Skipping this mass point."
                indices_exp.extend(where)

        # sort indices
        indices.sort()
        indices_exp.sort()

        for i in indices:
            masses.append(results.masses[i])
            xs_obs_limits.append(results.xs_obs_limits[i])
            if len(all_masses_exp) > 0:
                xs_exp_limits.append(results.xs_exp_limits[i])
        for i in indices_exp:
            masses_exp.append(results.masses_exp[i])
            xs_exp_limits_1sigma.append(results.xs_exp_limits_1sigma[i])
            xs_exp_limits_2sigma.append(results.xs_exp_limits_2sigma[i])

    if args.printResults:
        print "masses =", masses.tolist()
        print "xs_obs_limits =", xs_obs_limits.tolist()
        print "xs_exp_limits =", xs_exp_limits.tolist()
        print ""
        print "masses_exp =", masses_exp.tolist()
        print "xs_exp_limits_1sigma =", xs_exp_limits_1sigma.tolist()
        print "xs_exp_limits_2sigma =", xs_exp_limits_2sigma.tolist()

    # import ROOT stuff
    from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraph, TCanvas, TLegend
    from ROOT import kGreen, kYellow, kWhite

    gROOT.SetBatch(kTRUE)
    gStyle.SetOptStat(0)
    gStyle.SetOptTitle(0)
    gStyle.SetTitleFont(42, "XYZ")
    gStyle.SetTitleSize(0.06, "XYZ")
    gStyle.SetLabelFont(42, "XYZ")
    gStyle.SetLabelSize(0.05, "XYZ")
    gStyle.SetCanvasBorderMode(0)
    gStyle.SetFrameBorderMode(0)
    gStyle.SetCanvasColor(kWhite)
    gStyle.SetPadTickX(1)
    gStyle.SetPadTickY(1)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadRightMargin(0.05)
    gStyle.SetPadTopMargin(0.05)
    gStyle.SetPadBottomMargin(0.15)
    gROOT.ForceStyle()

    # theory curves: gg
    massesS8 = array('d', [
        1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0,
        1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0,
        2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0,
        3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0,
        4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0,
        5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0
    ])
    xsS8 = array('d', [
        5.46E+02, 3.12E+02, 1.85E+02, 1.12E+02, 7.19E+01, 4.59E+01, 3.02E+01,
        2.01E+01, 1.37E+01, 9.46E+00, 6.55E+00, 4.64E+00, 3.27E+00, 2.36E+00,
        1.70E+00, 1.24E+00, 9.11E-01, 6.69E-01, 4.97E-01, 3.71E-01, 2.78E-01,
        2.07E-01, 1.55E-01, 1.19E-01, 9.26E-02, 7.08E-02, 5.43E-02, 4.15E-02,
        3.22E-02, 2.50E-02, 1.92E-02, 1.51E-02, 1.19E-02, 9.25E-03, 7.35E-03,
        5.86E-03, 4.53E-03, 3.66E-03, 2.91E-03, 2.33E-03, 1.86E-03, 1.45E-03,
        1.12E-03, 8.75E-04, 6.90E-04, 5.55E-04, 4.47E-04, 3.63E-04, 2.92E-04,
        2.37E-04, 1.97E-04
    ])

    graph_xsS8 = TGraph(len(massesS8), massesS8, xsS8)
    graph_xsS8.SetLineWidth(3)
    graph_xsS8.SetLineStyle(8)
    graph_xsS8.SetLineColor(6)

    # theory curves: qg
    massesString = array('d', [
        1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0,
        1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0,
        2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0,
        3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0,
        4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0,
        5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0,
        6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0,
        7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0,
        8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0,
        9100., 9200., 9300., 9400., 9500., 9600., 9700., 9800., 9900., 10000.
    ])
    xsString = array('d', [
        8316.184311558545, 5312.93137758767, 3435.0309937336524,
        2304.4139502741305, 1569.8115447896687, 1090.9516635659693,
        770.901859690924, 551.9206062572061, 399.69535383507633,
        293.77957451762086, 218.15126842827823, 162.87634729465125,
        123.17685479653694, 93.63530805932386, 71.53697229809124,
        55.37491301647483, 42.75271508357369, 33.36378355470234,
        26.06619302090876, 20.311817606835643, 16.1180931789545,
        12.768644973921226, 10.142660425967444, 8.057990848043234,
        6.400465846290908, 5.115134438331436, 4.132099789492928,
        3.3193854239538734, 2.6581204529344302, 2.157554604919995,
        1.7505176068913348, 1.4049155245498584, 1.140055677916783,
        0.9253251132104159, 0.7522038169131606, 0.6119747371392215,
        0.49612321727328523, 0.40492020959456737, 0.33091999402250655,
        0.27017917021492555, 0.2201693919322846, 0.17830700070267996,
        0.14564253802358157, 0.11940534430331146, 0.09694948234356839,
        0.0793065371847468, 0.06446186373361917, 0.05282660618352478,
        0.0428516302310620888, 0.0348997638039910363, 0.0283334766442618227,
        0.0231416918363592127, 0.0187417921340763783, 0.0153501307395115115,
        0.0124396534127133717, 0.0100542205744949455, 0.0081744954858627415,
        0.0066338099362915941, 0.0053365711503318145, 0.00430912459914657443,
        0.00346381039244064343, 0.00278602671711227174, 0.00225154342228859257,
        0.0018082930150063248, 0.00143929440338502119, 0.0011581373956044489,
        0.00091869589873893118, 0.00073410823691329855, 0.00058669382997948734,
        0.0004661568745858897, 0.000368716655469570365,
        0.000293168485206959169, 0.000230224535021638668,
        0.000182317101888465142, 0.000143263359883433282,
        0.000112630538527214965, 0.000088189175598406759,
        0.000068708474367442343, 0.000053931726669273556,
        0.0000416417855733682702, 0.0000326529676755488658,
        0.0000254365480426201587, 0.0000198410151166864761,
        0.0000154034425617473576, 0.0000119095554601641413,
        9.2537574320108232e-6, 7.2155417437856749e-6, 5.6130924422251982e-6,
        4.36634755605624901e-6, 3.39717456406994868e-6, 2.6766018046173896e-6
    ])

    massesQstar = array('d', [
        1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0,
        1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0,
        2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0,
        3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0,
        4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0,
        5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0,
        6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0,
        7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0,
        8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0
    ])
    xsQstar = array('d', [
        0.4101E+03, 0.2620E+03, 0.1721E+03, 0.1157E+03, 0.7934E+02, 0.5540E+02,
        0.3928E+02, 0.2823E+02, 0.2054E+02, 0.1510E+02, 0.1121E+02, 0.8390E+01,
        0.6328E+01, 0.4807E+01, 0.3674E+01, 0.2824E+01, 0.2182E+01, 0.1694E+01,
        0.1320E+01, 0.1033E+01, 0.8116E+00, 0.6395E+00, 0.5054E+00, 0.4006E+00,
        0.3182E+00, 0.2534E+00, 0.2022E+00, 0.1616E+00, 0.1294E+00, 0.1038E+00,
        0.8333E-01, 0.6700E-01, 0.5392E-01, 0.4344E-01, 0.3503E-01, 0.2827E-01,
        0.2283E-01, 0.1844E-01, 0.1490E-01, 0.1205E-01, 0.9743E-02, 0.7880E-02,
        0.6373E-02, 0.5155E-02, 0.4169E-02, 0.3371E-02, 0.2725E-02, 0.2202E-02,
        0.1779E-02, 0.1437E-02, 0.1159E-02, 0.9353E-03, 0.7541E-03, 0.6076E-03,
        0.4891E-03, 0.3935E-03, 0.3164E-03, 0.2541E-03, 0.2039E-03, 0.1635E-03,
        0.1310E-03, 0.1049E-03, 0.8385E-04, 0.6699E-04, 0.5347E-04, 0.4264E-04,
        0.3397E-04, 0.2704E-04, 0.2151E-04, 0.1709E-04, 0.1357E-04, 0.1077E-04,
        0.8544E-05, 0.6773E-05, 0.5367E-05, 0.4251E-05, 0.3367E-05, 0.2666E-05,
        0.2112E-05, 0.1673E-05, 0.1326E-05
    ])

    graph_xsString = TGraph(len(massesString), massesString, xsString)
    graph_xsString.SetLineWidth(3)
    graph_xsString.SetLineStyle(8)
    graph_xsString.SetLineColor(9)

    graph_xsQstar = TGraph(len(massesQstar), massesQstar, xsQstar)
    graph_xsQstar.SetLineWidth(3)
    graph_xsQstar.SetLineStyle(2)
    graph_xsQstar.SetLineColor(1)

    # theory curves: qq
    massesTh = array('d', [
        1000.0, 1100.0, 1200.0, 1300.0, 1400.0, 1500.0, 1600.0, 1700.0, 1800.0,
        1900.0, 2000.0, 2100.0, 2200.0, 2300.0, 2400.0, 2500.0, 2600.0, 2700.0,
        2800.0, 2900.0, 3000.0, 3100.0, 3200.0, 3300.0, 3400.0, 3500.0, 3600.0,
        3700.0, 3800.0, 3900.0, 4000.0, 4100.0, 4200.0, 4300.0, 4400.0, 4500.0,
        4600.0, 4700.0, 4800.0, 4900.0, 5000.0, 5100.0, 5200.0, 5300.0, 5400.0,
        5500.0, 5600.0, 5700.0, 5800.0, 5900.0, 6000.0, 6100.0, 6200.0, 6300.0,
        6400.0, 6500.0, 6600.0, 6700.0, 6800.0, 6900.0, 7000.0, 7100.0, 7200.0,
        7300.0, 7400.0, 7500.0, 7600.0, 7700.0, 7800.0, 7900.0, 8000.0, 8100.0,
        8200.0, 8300.0, 8400.0, 8500.0, 8600.0, 8700.0, 8800.0, 8900.0, 9000.0
    ])

    xsAxi = array('d', [
        0.1849E+03, 0.1236E+03, 0.8473E+02, 0.5937E+02, 0.4235E+02, 0.3069E+02,
        0.2257E+02, 0.1680E+02, 0.1263E+02, 0.9577E+01, 0.7317E+01, 0.5641E+01,
        0.4374E+01, 0.3411E+01, 0.2672E+01, 0.2103E+01, 0.1658E+01, 0.1312E+01,
        0.1041E+01, 0.8284E+00, 0.6610E+00, 0.5294E+00, 0.4250E+00, 0.3417E+00,
        0.2752E+00, 0.2220E+00, 0.1792E+00, 0.1449E+00, 0.1172E+00, 0.9487E-01,
        0.7686E-01, 0.6219E-01, 0.5033E-01, 0.4074E-01, 0.3298E-01, 0.2671E-01,
        0.2165E-01, 0.1755E-01, 0.1422E-01, 0.1152E-01, 0.9322E-02, 0.7539E-02,
        0.6092E-02, 0.4917E-02, 0.3965E-02, 0.3193E-02, 0.2568E-02, 0.2062E-02,
        0.1653E-02, 0.1323E-02, 0.1057E-02, 0.8442E-03, 0.6728E-03, 0.5349E-03,
        0.4242E-03, 0.3357E-03, 0.2644E-03, 0.2077E-03, 0.1627E-03, 0.1271E-03,
        0.9891E-04, 0.7686E-04, 0.5951E-04, 0.4592E-04, 0.3530E-04, 0.2704E-04,
        0.2059E-04, 0.1562E-04, 0.1180E-04, 0.8882E-05, 0.6657E-05, 0.4968E-05,
        0.3693E-05, 0.2734E-05, 0.2016E-05, 0.1481E-05, 0.1084E-05, 0.7903E-06,
        0.5744E-06, 0.4160E-06, 0.3007E-06
    ])
    xsDiquark = array('d', [
        0.5824E+02, 0.4250E+02, 0.3172E+02, 0.2411E+02, 0.1862E+02, 0.1457E+02,
        0.1153E+02, 0.9211E+01, 0.7419E+01, 0.6019E+01, 0.4912E+01, 0.4031E+01,
        0.3323E+01, 0.2750E+01, 0.2284E+01, 0.1903E+01, 0.1590E+01, 0.1331E+01,
        0.1117E+01, 0.9386E+00, 0.7900E+00, 0.6658E+00, 0.5618E+00, 0.4745E+00,
        0.4010E+00, 0.3391E+00, 0.2869E+00, 0.2428E+00, 0.2055E+00, 0.1740E+00,
        0.1473E+00, 0.1246E+00, 0.1055E+00, 0.8922E-01, 0.7544E-01, 0.6376E-01,
        0.5385E-01, 0.4546E-01, 0.3834E-01, 0.3231E-01, 0.2720E-01, 0.2288E-01,
        0.1922E-01, 0.1613E-01, 0.1352E-01, 0.1132E-01, 0.9463E-02, 0.7900E-02,
        0.6584E-02, 0.5479E-02, 0.4551E-02, 0.3774E-02, 0.3124E-02, 0.2581E-02,
        0.2128E-02, 0.1750E-02, 0.1437E-02, 0.1177E-02, 0.9612E-03, 0.7833E-03,
        0.6366E-03, 0.5160E-03, 0.4170E-03, 0.3360E-03, 0.2700E-03, 0.2162E-03,
        0.1725E-03, 0.1372E-03, 0.1087E-03, 0.8577E-04, 0.6742E-04, 0.5278E-04,
        0.4114E-04, 0.3192E-04, 0.2465E-04, 0.1894E-04, 0.1448E-04, 0.1101E-04,
        0.8322E-05, 0.6253E-05, 0.4670E-05
    ])
    xsWprime = array('d', [
        0.8811E+01, 0.6024E+01, 0.4216E+01, 0.3010E+01, 0.2185E+01, 0.1610E+01,
        0.1200E+01, 0.9043E+00, 0.6875E+00, 0.5271E+00, 0.4067E+00, 0.3158E+00,
        0.2464E+00, 0.1932E+00, 0.1521E+00, 0.1201E+00, 0.9512E-01, 0.7554E-01,
        0.6012E-01, 0.4792E-01, 0.3827E-01, 0.3059E-01, 0.2448E-01, 0.1960E-01,
        0.1571E-01, 0.1259E-01, 0.1009E-01, 0.8090E-02, 0.6483E-02, 0.5193E-02,
        0.4158E-02, 0.3327E-02, 0.2660E-02, 0.2125E-02, 0.1695E-02, 0.1351E-02,
        0.1075E-02, 0.8546E-03, 0.6781E-03, 0.5372E-03, 0.4248E-03, 0.3353E-03,
        0.2642E-03, 0.2077E-03, 0.1629E-03, 0.1275E-03, 0.9957E-04, 0.7757E-04,
        0.6027E-04, 0.4670E-04, 0.3610E-04, 0.2783E-04, 0.2140E-04, 0.1641E-04,
        0.1254E-04, 0.9561E-05, 0.7269E-05, 0.5510E-05, 0.4167E-05, 0.3143E-05,
        0.2364E-05, 0.1774E-05, 0.1329E-05, 0.9931E-06, 0.7411E-06, 0.5523E-06,
        0.4108E-06, 0.3055E-06, 0.2271E-06, 0.1687E-06, 0.1254E-06, 0.9327E-07,
        0.6945E-07, 0.5177E-07, 0.3863E-07, 0.2888E-07, 0.2162E-07, 0.1622E-07,
        0.1218E-07, 0.9156E-08, 0.6893E-08
    ])
    xsZprime = array('d', [
        0.5027E+01, 0.3398E+01, 0.2353E+01, 0.1663E+01, 0.1196E+01, 0.8729E+00,
        0.6450E+00, 0.4822E+00, 0.3638E+00, 0.2769E+00, 0.2123E+00, 0.1639E+00,
        0.1272E+00, 0.9933E-01, 0.7789E-01, 0.6134E-01, 0.4848E-01, 0.3845E-01,
        0.3059E-01, 0.2440E-01, 0.1952E-01, 0.1564E-01, 0.1256E-01, 0.1010E-01,
        0.8142E-02, 0.6570E-02, 0.5307E-02, 0.4292E-02, 0.3473E-02, 0.2813E-02,
        0.2280E-02, 0.1848E-02, 0.1499E-02, 0.1216E-02, 0.9864E-03, 0.8002E-03,
        0.6490E-03, 0.5262E-03, 0.4264E-03, 0.3453E-03, 0.2795E-03, 0.2260E-03,
        0.1826E-03, 0.1474E-03, 0.1188E-03, 0.9566E-04, 0.7690E-04, 0.6173E-04,
        0.4947E-04, 0.3957E-04, 0.3159E-04, 0.2516E-04, 0.2001E-04, 0.1587E-04,
        0.1255E-04, 0.9906E-05, 0.7795E-05, 0.6116E-05, 0.4785E-05, 0.3731E-05,
        0.2900E-05, 0.2247E-05, 0.1734E-05, 0.1334E-05, 0.1022E-05, 0.7804E-06,
        0.5932E-06, 0.4492E-06, 0.3388E-06, 0.2544E-06, 0.1903E-06, 0.1417E-06,
        0.1051E-06, 0.7764E-07, 0.5711E-07, 0.4186E-07, 0.3055E-07, 0.2223E-07,
        0.1612E-07, 0.1164E-07, 0.8394E-08
    ])

    graph_xsAxi = TGraph(len(massesTh), massesTh, xsAxi)
    graph_xsAxi.SetLineWidth(3)
    graph_xsAxi.SetLineStyle(3)
    graph_xsAxi.SetLineColor(63)

    graph_xsDiquark = TGraph(len(massesTh), massesTh, xsDiquark)
    graph_xsDiquark.SetLineWidth(3)
    graph_xsDiquark.SetLineStyle(9)
    graph_xsDiquark.SetLineColor(8)

    graph_xsWprime = TGraph(len(massesTh), massesTh, xsWprime)
    graph_xsWprime.SetLineWidth(3)
    graph_xsWprime.SetLineStyle(7)
    graph_xsWprime.SetLineColor(46)

    graph_xsZprime = TGraph(len(massesTh), massesTh, xsZprime)
    graph_xsZprime.SetLineWidth(3)
    graph_xsZprime.SetLineStyle(5)
    graph_xsZprime.SetLineColor(38)

    # limits
    graph_exp_2sigma = (TGraph(len(masses_exp), masses_exp,
                               xs_exp_limits_2sigma)
                        if len(xs_exp_limits_2sigma) > 0 else TGraph(0))
    graph_exp_2sigma.SetFillColor(kYellow)

    graph_exp_1sigma = (TGraph(len(masses_exp), masses_exp,
                               xs_exp_limits_1sigma)
                        if len(xs_exp_limits_2sigma) > 0 else TGraph(0))
    graph_exp_1sigma.SetFillColor(kGreen + 1)

    graph_exp = (TGraph(len(masses), masses, xs_exp_limits)
                 if len(xs_exp_limits_2sigma) > 0 else TGraph(0))
    #graph_exp.SetMarkerStyle(24)
    graph_exp.SetLineWidth(3)
    graph_exp.SetLineStyle(2)
    graph_exp.SetLineColor(4)

    graph_obs = TGraph(len(masses), masses, xs_obs_limits)
    graph_obs.SetMarkerStyle(20)
    graph_obs.SetLineWidth(3)
    #graph_obs.SetLineStyle(1)
    graph_obs.SetLineColor(1)

    c = TCanvas("c", "", 800, 800)
    c.cd()

    legend = TLegend(.60, .55, .90, .70)
    legend.SetBorderSize(0)
    legend.SetFillColor(0)
    legend.SetFillStyle(0)
    legend.SetTextFont(42)
    legend.SetTextSize(0.03)
    legend.SetHeader('95% CL upper limits')

    if len(xs_exp_limits_2sigma) > 0:
        graph_exp_2sigma.GetXaxis().SetTitle("%s resonance mass [GeV]" %
                                             (args.final_state))
        graph_exp_2sigma.GetYaxis().SetTitle(
            "#sigma #times #it{B} #times #it{A} [pb]")
        graph_exp_2sigma.GetYaxis().SetTitleOffset(1.1)
        graph_exp_2sigma.GetYaxis().SetRangeUser(1e-02, 1e+03)
        #graph_exp_2sigma.GetXaxis().SetNdivisions(1005)

        graph_exp_2sigma.Draw("AF")
        graph_exp_1sigma.Draw("F")
        graph_exp.Draw("L")
        graph_obs.Draw("LP")

        legend.AddEntry(graph_obs, "Observed", "lp")
        legend.AddEntry(graph_exp, "Expected", "lp")
        legend.AddEntry(graph_exp_1sigma, "#pm 1#sigma", "F")
        legend.AddEntry(graph_exp_2sigma, "#pm 2#sigma", "F")
    else:
        graph_obs.GetXaxis().SetTitle("%s resonance mass [GeV]" %
                                      (args.final_state))
        graph_obs.GetYaxis().SetTitle(
            "#sigma #times #it{B} #times #it{A} [pb]")
        graph_obs.GetYaxis().SetTitleOffset(1.1)
        graph_obs.GetYaxis().SetRangeUser(1e-02, 1e+03)
        #graph_obs.GetXaxis().SetNdivisions(1005)

        graph_obs.Draw("ALP")

        legend.AddEntry(graph_obs, "Observed", "lp")

    if args.final_state == 'gg':
        graph_xsS8.Draw("L")
    elif args.final_state == 'qg':
        graph_xsQstar.Draw("L")
        graph_xsString.Draw("L")
    elif args.final_state == 'qq':
        graph_xsAxi.Draw("L")
        graph_xsDiquark.Draw("L")
        graph_xsWprime.Draw("L")
        graph_xsZprime.Draw("L")

    legend.Draw()

    if args.final_state == 'gg':
        legendTh = TLegend(.60, .80, .90, .84)
        legendTh.SetBorderSize(0)
        legendTh.SetFillColor(0)
        legendTh.SetFillStyle(0)
        legendTh.SetTextFont(42)
        legendTh.SetTextSize(0.03)
        legendTh.AddEntry(graph_xsS8, "S8", "l")
        legendTh.Draw()
    elif args.final_state == 'qg':
        legendTh = TLegend(.60, .80, .90, .88)
        legendTh.SetBorderSize(0)
        legendTh.SetFillColor(0)
        legendTh.SetFillStyle(0)
        legendTh.SetTextFont(42)
        legendTh.SetTextSize(0.03)
        legendTh.AddEntry(graph_xsString, "String", "l")
        legendTh.AddEntry(graph_xsQstar, "Excited quark", "l")
        legendTh.Draw()
    elif args.final_state == 'qq':
        legendTh = TLegend(.60, .72, .90, .88)
        legendTh.SetBorderSize(0)
        legendTh.SetFillColor(0)
        legendTh.SetFillStyle(0)
        legendTh.SetTextFont(42)
        legendTh.SetTextSize(0.03)
        legendTh.AddEntry(graph_xsAxi, "Axigluon/coloron", "l")
        legendTh.AddEntry(graph_xsDiquark, "Scalar diquark", "l")
        legendTh.AddEntry(graph_xsWprime, "W' SSM", "l")
        legendTh.AddEntry(graph_xsZprime, "Z' SSM", "l")
        legendTh.Draw()

    # draw the lumi text on the canvas
    CMS_lumi.extraText = args.extraText
    CMS_lumi.lumi_sqrtS = args.lumi_sqrtS  # used with iPeriod = 0 (free form)
    iPos = 11
    iPeriod = 0

    CMS_lumi.CMS_lumi(c, iPeriod, iPos)

    gPad.RedrawAxis()

    c.SetLogy()
    fileName = 'xs_limit_%s_%s.%s' % (args.method, args.final_state + (
        ('_' + args.postfix) if args.postfix != '' else ''),
                                      args.fileFormat.lower())
    c.SaveAs(fileName)
    print "Plot saved to '%s'" % (fileName)