Ejemplo n.º 1
0
def histogram_plot(hist, outFile):

    ###############################
    # initialisation 
    ###############################
    gROOT.SetStyle("Plain") ;
    gStyle.SetOptStat(0)
    gStyle.SetTitleXOffset (1.25);
    gStyle.SetTitleYOffset (1.5);

    c1 = TCanvas('title', 'name', 600, 500)
    c1.SetTicks(1,1);
    #c1.SetBottomMargin(0.3);
    c1.SetLeftMargin(0.2);   
    c1.SetLogy(1); 
    ###############################

    key_list = hist.keys()
    nhist = len(key_list)

    for i in range(nhist):
        key = key_list[i]
        fName = outFile
        if i == 0: fName = outFile + '('
        if i == nhist - 1: fName = outFile + ')'
        hist[key].Draw()
        c1.Print(fName)

    return
Ejemplo n.º 2
0
def SetTuningStyle():
    print "\nApplying TuningTool style settings..."
    tuningStyle = TuningStyle()
    from ROOT import gROOT, kTRUE
    gROOT.SetStyle("Tuning")
    gROOT.ForceStyle()
    gROOT.SetBatch(kTRUE)
Ejemplo n.º 3
0
def SetStyle(styleName="MyStyle"):

    ## MyStyle or tdrStyle
    from ROOT import gROOT, gStyle

    gROOT.Reset()
    gROOT.ProcessLine(".x ~/rootmacros/myStyle.cc")
    gROOT.ProcessLine(".x ~/rootmacros/setTDRStyle.C")
    # gROOT.SetStyle("tdrStyle");
    # gROOT.SetStyle("MyStyle");
    gROOT.SetStyle(styleName)
    gStyle.SetOptLogy(0)
    gStyle.SetPalette(1)
    gStyle.SetOptTitle(0)
    gStyle.SetOptStat(0)
    gStyle.SetPadTopMargin(0.02)
    gStyle.SetPadTickX(1)

    gStyle.SetLabelSize(0.045, "XYZ")
    gStyle.SetLabelSize(0.04, "Y")
    gStyle.SetTitleSize(0.045, "XYZ")

    gROOT.ForceStyle()

    return
Ejemplo n.º 4
0
 def __init__(self):
     super(StyleClass, self).__init__("CRRootStyle", "CRRootStyle")
     self.root_style_settings()
     self.cd()
     gROOT.SetStyle("CRRootStyle")
     gROOT.ForceStyle()
     TGaxis.SetMaxDigits(3)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def loadstyle():
     gROOT.SetStyle("Plain")
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(0)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
     gStyle.SetOptTitle(0)
Ejemplo n.º 7
0
 def SetPalette(self, optstat=1111111):
     """Sets default plot settings."""
     gROOT.Reset()
     gROOT.SetStyle('Plain')
     gStyle.SetOptStat(optstat)
     gStyle.SetPalette(1)
     gStyle.SetLineColor(4)
     return
Ejemplo n.º 8
0
def SetAtlasStyle():
    """Applying ATLAS style settings globally.
    """
    print("\n{}\n".format(bcolor.green + "Applying ATLAS style settings..." +
                          bcolor.end))

    AtlasStyle()
    gROOT.SetStyle("ATLAS")
    gROOT.ForceStyle()
Ejemplo n.º 9
0
 def _initDefaultStyle(self):
     gROOT.Reset()
     gROOT.SetStyle("Plain")
     gStyle.SetOptStat(0)
     gStyle.SetOptFit(1111)
     gStyle.SetPadLeftMargin(0.12)
     gStyle.SetPadBottomMargin(0.12)
     gStyle.SetMarkerSize(1.)
     gStyle.SetHistLineWidth(1)
Ejemplo n.º 10
0
def ratiocase(case_num, case_den, typean):

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)

    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_num = data_param_num[case_num]["analysis"][typean]["data"]["resultsallp"]
    folder_den = data_param_den[case_den]["analysis"][typean]["data"]["resultsallp"]
    binsmin_num = data_param_num[case_num]["analysis"][typean]["sel_binmin2"]
    binsmax_num = data_param_num[case_num]["analysis"][typean]["sel_binmax2"]
    latexbin2var = data_param_num[case_num]["analysis"][typean]["latexbin2var"]
    plotbin = data_param_num[case_num]["analysis"][typean]["plotbin"]

    ccross = TCanvas('cCross', 'The Fit Canvas', 100, 600)
    ccross = TCanvas('cCross', 'The Fit Canvas')
    ccross.SetCanvasSize(1500, 1500)
    ccross.SetWindowSize(500, 500)
#    ccross.SetLogx()

    legyield = TLegend(.3, .65, .7, .85)
    legyield.SetBorderSize(0)
    legyield.SetFillColor(0)
    legyield.SetFillStyle(0)
    legyield.SetTextFont(42)
    legyield.SetTextSize(0.035)

    file_num = TFile.Open("%s/finalcross%s%s.root" % (folder_num, case_num, typean))
    file_den = TFile.Open("%s/finalcross%s%s.root" % (folder_den, case_den, typean))

    for imult, _ in enumerate(binsmax_num):
        print(imult)
        hratio = file_num.Get("hcross%d" % (imult))
        hcross_den = file_den.Get("hcross%d" % (imult))
        hratio.Divide(hcross_den)
        hratio.GetXaxis().SetTitle("p_{T} (GeV)")
        hratio.GetYaxis().SetTitle("Particle ratio")
        hratio.GetYaxis().SetRangeUser(0., 1.)
        if plotbin[imult] == 1:
            hratio.Draw("same")
            legyieldstring = "%.1f < %s < %.1f" % \
                    (binsmin_num[imult], latexbin2var, binsmax_num[imult])
            legyield.AddEntry(hratio, legyieldstring, "LEP")
    legyield.Draw()
    ccross.SaveAs("ComparisonRatios_%s%s_%s.eps" % \
                  (case_num, case_den, typean))
Ejemplo n.º 11
0
def configure_draw():
    gROOT.SetStyle('Plain')

    gStyle.SetEndErrorSize(0.)
    gStyle.SetOptStat(0)
    gStyle.SetPalette(1)
    gStyle.SetTitleBorderSize(0)
    gStyle.SetTitleFont(22, '')
    gStyle.SetTitleSize(0.06, '')
    gStyle.SetTitleX(0.1)
    gStyle.SetTitleW(0.8)
Ejemplo n.º 12
0
def plotcomparison(case):

    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)
    gStyle.SetOptStat(0000)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
    gStyle.SetOptTitle(0)

    with open("data/database_ml_parameters_%s.yml" % case,
              'r') as param_config:
        data_param = yaml.load(param_config, Loader=yaml.FullLoader)
Ejemplo n.º 13
0
def export(info, args, npull=15):
    from ROOT import TFile, gROOT, gStyle, TPad, TCanvas
    from math import ceil
    gROOT.SetStyle("Plain")
    gStyle.SetOptFit(1)
    gStyle.SetOptStat(0)
    gROOT.SetBatch(1)

    # outdir = outdir_base % info.year
    # outvar = '%s/%s/' % (outdir,info.variable)
    # if not os.path.isdir(outvar): os.mkdir(outvar)
    # outsys = '%s/%s' % (outvar,info.sysdir)
    # if not os.path.isdir(outsys): os.mkdir(outsys)

    # outname = 'pulls_%s.pdf' % info.variable
    # output = '%s/%s' % (outsys,outname)
    output = "pulls.pdf"
    pulls = TFile.Open(args.g)
    canvas = pulls.Get("nuisances")
    objlist = canvas.GetListOfPrimitives()
    prefit = objlist.At(0).Clone()
    fit_bg = objlist.At(2).Clone()
    fit_bs = objlist.At(3).Clone()
    legend = objlist.At(6).Clone()

    prefit.GetYaxis().SetRangeUser(-4, 4)

    legend.SetX1(0.76)
    legend.SetX2(0.99)

    npages = int(ceil(float(prefit.GetNbinsX()) / npull))
    for page in range(npages):
        canvas = TCanvas()
        canvas.SetBottomMargin(0.15)
        canvas.SetRightMargin(0.25)
        canvas.SetGridx()
        canvas.Draw()
        xlo = page * npull + 1
        xhi = page * npull + npull
        if xhi > prefit.GetNbinsX(): xhi = prefit.GetNbinsX()
        prefit.GetXaxis().SetRange(xlo, xhi)

        prefit.Draw("E2")
        prefit.Draw("histsame")
        fit_bg.Draw("EPsame")
        fit_bs.Draw("EPsame")
        legend.Draw()

        if page == 0: canvas.SaveAs(output + "(")
        elif page + 1 == npages: canvas.SaveAs(output + ")")
        else: canvas.SaveAs(output)
Ejemplo n.º 14
0
def initStyle(config):
    from ROOT import gROOT, gStyle, TStyle, TGaxis
    gROOT.SetBatch(True)        
    gROOT.SetStyle('Plain')
    gStyle.SetOptStat(0)
    gStyle.SetPalette(1)
    gStyle.SetPaintTextFormat(".2g")
    TGaxis.SetMaxDigits(3)
    pageSize = config.get("styleDefaults","pageSize")
    if    pageSize.lower() == "a4":     gStyle.SetPaperSize(TStyle.kA4)
    elif  pageSize.lower() == "letter": gStyle.SetPaperSize(TStyle.kUSLetter)
    else:
      pageSize = [int(i) for i in pageSize.split("x")]
      gStyle.SetPaperSize(pageSize[0],pageSize[1])
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 def initGraphics(self, ndet, nlb):
     "Initialise graphics and setup histogram for status matrix"
     from ROOT import gROOT, TCanvas, TH2F, gStyle
     hist = TH2F(
         "DetectorStatus", "%s tag %s runs %i to %i (%i LBs)" %
         (self.foldername, self.tag, self.runmin, self.runmax, nlb),
         ndet + 1, 0.5, ndet + 1.5, nlb, 0.5, nlb + 0.5)
     hist.Fill(ndet + 1, 1, 49.)
     hist.SetNdivisions(0)
     gROOT.SetStyle("Plain")
     gStyle.SetPalette(0)
     gStyle.SetOptStat(0)
     gStyle.SetOptFit(0)
     canvas = TCanvas(self.foldername, self.foldername, 0, 0, 500, 600)
     return (hist, canvas)
Ejemplo n.º 17
0
def set_root_env():
    from ROOT import gStyle, gROOT
    gROOT.Reset()
    gROOT.SetStyle('Plain')
    gStyle.SetCanvasColor(10)
    gStyle.SetStatBorderSize(1)
    gStyle.SetFillColor(10)
    gStyle.SetOptStat(1)
    gStyle.SetStatX(0.46)
    gStyle.SetStatY(0.9)
    gStyle.SetTitleYOffset(1.4)
    gStyle.SetPalette(45)
    gStyle.SetMarkerSize(0.8)
    gStyle.SetLineColor(1)
    gStyle.SetLineWidth(1)
Ejemplo n.º 18
0
def setAtlasStyle():
	from ROOT import TStyle
		
	atlasStyle = TStyle("ATLAS","Atlas style")

	atlasStyle.SetFrameBorderMode(0)
	atlasStyle.SetFrameFillColor(0)
	atlasStyle.SetCanvasBorderMode(0)
	atlasStyle.SetCanvasColor(0)
	atlasStyle.SetPadBorderMode(0)
	atlasStyle.SetPadColor(0)
	atlasStyle.SetStatColor(0)	
	atlasStyle.SetPaperSize(20,26)
	atlasStyle.SetPadTopMargin(0.07)
	atlasStyle.SetPadRightMargin(0.05)
	atlasStyle.SetPadBottomMargin(0.16)
	atlasStyle.SetPadLeftMargin(0.16)
	atlasStyle.SetTitleXOffset(1.4)
	atlasStyle.SetTitleYOffset(1.2)
	font=43
	tsize=0.05
	atlasStyle.SetTextFont(font)
	atlasStyle.SetTextSize(tsize)
	atlasStyle.SetLabelFont(font,"x")
	atlasStyle.SetTitleFont(font,"x")
	atlasStyle.SetLabelFont(font,"y")
	atlasStyle.SetTitleFont(font,"y")
	atlasStyle.SetLabelFont(font,"z")
	atlasStyle.SetTitleFont(font,"z")
	atlasStyle.SetLabelSize(tsize,"x")
	atlasStyle.SetTitleSize(tsize,"x")
	atlasStyle.SetLabelSize(tsize,"y")
	atlasStyle.SetTitleSize(tsize,"y")
	atlasStyle.SetLabelSize(tsize,"z")
	atlasStyle.SetTitleSize(tsize,"z")
	atlasStyle.SetMarkerStyle(20)
	atlasStyle.SetMarkerSize(1.2)
	atlasStyle.SetHistLineWidth(2)
	atlasStyle.SetLineStyleString(2,"[12 12]")
	atlasStyle.SetEndErrorSize(0.)
	atlasStyle.SetOptTitle(0)
	atlasStyle.SetOptStat(0)
	atlasStyle.SetOptFit(0)
	atlasStyle.SetPadTickX(1)
	atlasStyle.SetPadTickY(1)

	gROOT.SetStyle("ATLAS")
	gROOT.ForceStyle()
Ejemplo n.º 19
0
    def execute(self, ws, debug = 0):
        print self.legend, 'Profile Likelihood calculation started...'

        # time the action
        t = TStopwatch()
        t.Start()

        # model config is guaranteed to be here
        # the action won't configure without it
        # and this code will never run unless valid model config is found
        mconf = ws.obj(self._model_config_name)
            
        _poi = mconf.GetParametersOfInterest()

        plcInt = self._plc.GetInterval()

        # stop watch and print how long it took to get the interval
        t.Print()

        # iterate over all parameters of interest and print out the intervals
        # (could there be more than one?)
        _iter = _poi.createIterator()
        while True:
            _poi_name = _iter().GetTitle()
            
            lower_limit = plcInt.LowerLimit( _poi[_poi_name] )
            upper_limit = plcInt.UpperLimit( _poi[_poi_name] )
            
            print self.legend, 'Profile Likelihood interval for', _poi_name, 'is ['+ \
                  str(lower_limit) + ', ' + \
                  str(upper_limit) + ']'

            if _iter.Next() == None:
                break
            

        if self._scan_plot:
            # draw scan plot

            print self.legend, 'making the likelihood scan plot'
            _plot_name = _poi_name+'_plc_scan_exost.'+self._plot_format
            c1 = TCanvas("c1", "c1", 600, 600)
            plcPlot = RooStats.LikelihoodIntervalPlot(plcInt)
            gROOT.SetStyle("Plain")
            plcPlot.Draw()
            c1.SaveAs(_plot_name)
            
        return (lower_limit, upper_limit)
Ejemplo n.º 20
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)
Ejemplo n.º 21
0
 def _initDefaultStyle(self):
     gROOT.Reset()
     gROOT.SetStyle("Plain")
     #gStyle.SetOptStat(0)
     gStyle.SetOptFit(1111)
     gStyle.SetPadLeftMargin(0.1)
     gStyle.SetPadBottomMargin(0.1)
     gStyle.SetMarkerSize(1.5)
     gStyle.SetHistLineWidth(1)
     gStyle.SetStatFontSize(0.025)
     gStyle.SetTitleFontSize(0.05)
     gStyle.SetTitle(
         'CMS Preliminary tH, H#to#tau#tau, 19.7 fb^{-1} at 8 TeV')
     gStyle.SetTitleSize(0.06, "XYZ")
     gStyle.SetLabelSize(0.05, "XYZ")
     gStyle.SetNdivisions(510, "XYZ")
Ejemplo n.º 22
0
def main(extension, network_name, luminosity, output_flag, output_mod,
         veto_all_jets, generator, extra_text, fudge, text,
         Independant_Variable_List, Variable_list, WP_list, MC_list,
         Real_Data):
    gROOT.SetStyle("ATLAS")
    gROOT.ForceStyle()
    gStyle.SetErrorX(0.5)
    TH1.SetDefaultSumw2()

    OUTPUT_dir = os.path.join(os.environ["HOME_DIRECTORY"], "Output")

    ## Changing the name of the input file to match the generator
    if generator == "PowhegPythia":
        pass
    elif generator == "Sherpa":
        MC_list[0].file = "S" + MC_list[0].file
    elif generator == "MadGraph":
        MC_list[0].file = "MG" + MC_list[0].file
    else:
        print("\n\n\nUnknown Generator option\n\n\n")
        return 0

    ## Changing the name of the input files to match the jet selection
    if veto_all_jets:
        for mc in MC_list:
            mc.file = mc.file + "_NOJETS"
        Real_Data.file = Real_Data.file + "_NOJETS"
        extra_text += "0 Jets"

    ########## Plotting the independant variables ##########
    for ivar in Independant_Variable_List:
        STACK(extension, OUTPUT_dir, network_name, luminosity, output_flag,
              output_mod, generator, extra_text, fudge, text, MC_list,
              Real_Data, ivar, None)

    ########## Loading and Plotting the TH1Ds ##########
    for var in Variable_list:
        for wp in WP_list:

            STACK(extension, OUTPUT_dir, network_name, luminosity, output_flag,
                  output_mod, generator, extra_text, fudge, text, MC_list,
                  Real_Data, var, wp)

    return 0
Ejemplo n.º 23
0
def set_root_environment(abs_soft_path: str or None = None):
    """
    Set the root environment to work with TRUFA software

    :param abs_soft_path: Path to the full TRUFA code
    :return: Void Function
    """

    from ROOT import gROOT, gStyle, gSystem
    from os.path import join as join_path

    # ROOT Environment
    if abs_soft_path is None:
        abs_soft_path = "/home/mcruces/Documents/GitHub/TRAGALDABAS-fantastic-Cpp/soft_TT"

    libtunpacker_path = join_path(abs_soft_path, "libtunpacker.so")
    gSystem.Load("libGraf")
    gSystem.Load(libtunpacker_path)
    print("Unpacker for stand alone TRB loaded")
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)
    gStyle.SetPalette(55)
    gROOT.SetStyle("Plain")
Ejemplo n.º 24
0
def showme(figure, data, theory, ratio, X, Y, YB):
    """A function to draw and and theory as well as their ratio. S.Chekanov
   @param  figure Figure file
   @param: data   Histogram with data 
   @param: theory Histogram with theory
   @param: ratio  TGraph or Histogram with for bottom plot
   @param: X      X-axis attributes (Min,Max,Name,IsLog) 
   @param: Y      Y-axis attributes (Min,Max,Name,IsLog)  
   @param: YB     Bottom (lower) panel attributes (Min,Max,Name,IsLog)  
   @author S.Chekanov (ANL)
  """

    if (X[0] > X[1]):
        print("X min larger than X max")
        return
    if (Y[0] > Y[1]):
        print("X min larger than X mas")
        return
    if (YB[0] > YB[1]):
        print("X min larger than X mas")
        return

    inp = "plot"
    if (len(sys.argv) == 2):
        inp = sys.argv[1]
    print "Mode=", inp

    c1 = TCanvas("cv", "", 600, 500)
    c1.Divide()
    c1.SetTickx()
    c1.SetTicky()
    gROOT.SetStyle("Plain")
    gStyle.SetOptStat(0)

    cv1 = TPad("cv_a", "", 0.0, 0.20, 1.0, 1.0)
    cv1.SetTickx()
    cv1.SetTicky()
    cv1.SetTopMargin(0.05)
    cv1.SetBottomMargin(0.001)
    cv1.SetLeftMargin(0.12)
    cv1.SetRightMargin(0.05)
    cv1.Draw()
    cv2 = TPad("cv_b", "", 0.0, 0.0, 1.0, 0.275)
    cv2.SetTopMargin(0.0)
    cv2.SetTickx()
    cv2.SetTicky()
    cv2.SetLeftMargin(0.12)
    cv2.SetRightMargin(0.05)
    cv2.SetBottomMargin(0.35)
    cv2.Draw()

    if (Y[3] == 1): cv1.cd().SetLogy()
    if (X[3] == 1): cv1.cd().SetLogx()
    if (YB[3] == 1): cv2.cd().SetLogy()

    h1 = gPad.DrawFrame(X[0], Y[0], X[1], Y[1])
    h1.Draw()
    ay = h1.GetYaxis()
    ay.SetTitleOffset(1.1)
    ay.SetTitle(Y[2])

    data.Draw("same pe")
    theory.Draw("histo same")

    #########################################
    #cv2.cd().SetGridy()
    cv2.cd().SetGridx()
    h2 = gPad.DrawFrame(X[0], YB[0], X[1], YB[1])
    h2.Draw()
    ax = h2.GetXaxis()
    ax.SetTitleOffset(0.8)
    ax.SetTitle(X[2])
    ax.SetLabelSize(0.12)
    ax.SetTitleSize(0.14)
    ay = h2.GetYaxis()
    #ay.SetTitle("OOOO" )
    ay.SetNdivisions(505)
    ay.SetLabelSize(0.12)
    ay.SetTitleSize(0.14)
    ax.SetTitleOffset(1.1)
    ay.SetTitleOffset(0.0)
    ax.Draw("same")
    ay.Draw("same")

    ratio.SetMarkerColor(1)
    ratio.SetMarkerStyle(20)
    ratio.SetMarkerSize(1.0)
    ratio.SetMarkerColor(2)

    # plot depending on style
    if (type(ratio) == TGraphErrors or type(ratio) == TGraph
            or type(ratio) == TGraphAsymmErrors):
        ratio.Draw("P same")
    elif (type(ratio) == TH1F or type(ratio) == TH1D):
        ratio.SetFillColor(2)
        ratio.SetLineWidth(1)
        ratio.SetLineColor(1)
        ratio.Draw("same histo ][")
    else:
        ratio.Draw("P same")

    l1 = TLatex()
    l1.SetTextAngle(90)
    l1.SetTextSize(0.12)
    l1.SetNDC()
    l1.SetTextColor(1)
    l1.DrawLatex(0.06, 0.5, YB[2])

    # draw line
    x1 = c1.XtoPad(X[0])
    x2 = c1.XtoPad(X[1])
    ar5 = TLine(x1, 0, x2, 0)
    ar5.SetLineWidth(2)
    ar5.SetLineStyle(2)
    ar5.Draw("same")

    c1.Print(figure)

    if (inp != "-b"):
        if (raw_input("Press any key to exit") != "-9999"):
            c1.Close()
            sys.exit(1)
Ejemplo n.º 25
0
#get rid of X error bars and y error bar caps
#atlasStyle.SetErrorX(0.001)

#do not display any of the standard histogram decorations
atlasStyle.SetOptTitle(0)
#atlasStyle.SetOptStat(1111)
atlasStyle.SetOptStat(0)
#atlasStyle.SetOptFit(1111)
atlasStyle.SetOptFit(0)

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

gROOT.SetStyle("Plain")

#gStyle.SetPadTickX(1)
#gStyle.SetPadTickY(1)
gROOT.SetStyle("ATLAS")
gROOT.ForceStyle() 
gStyle.SetOptTitle(0)
gStyle.SetOptStat(0) 
gStyle.SetOptFit(0) 
# overwrite atlas styles

atlasStyle.SetMarkerSize(1.0)
atlasStyle.SetPadLeftMargin(0.14)  
atlasStyle.SetPadRightMargin(0.03)    
atlasStyle.SetPadBottomMargin(0.12)     
atlasStyle.SetPadTopMargin(0.05)  
Ejemplo n.º 26
0
def setLHCbStyle():
    # configuring the plot-style
    gROOT.SetStyle("Plain")
    lhcbStyle = TStyle("lhcbstyle", "LHCb plots style")
    GlobalLHCbTSize = 0.06
    lhcbTSize = 0.06
    kLHCbFont = 132
    lhcbWidth = 2

    lhcbStyle.SetFillColor(1)
    lhcbStyle.SetFillStyle(1001)
    lhcbStyle.SetFrameFillColor(0)
    lhcbStyle.SetFrameBorderMode(0)
    lhcbStyle.SetPadBorderMode(0)
    lhcbStyle.SetPadColor(0)
    lhcbStyle.SetCanvasBorderMode(0)
    lhcbStyle.SetCanvasColor(0)
    lhcbStyle.SetStatColor(0)
    lhcbStyle.SetLegendBorderSize(0)
    lhcbStyle.SetPalette(1)
    # colors = [0,5,7,3,6,2,4,1]
    # lhcbStyle.SetPalette(8,colors)
    lhcbStyle.SetPaperSize(20, 26)
    lhcbStyle.SetPadTopMargin(0.05)
    lhcbStyle.SetPadRightMargin(0.05)
    lhcbStyle.SetPadBottomMargin(0.16)
    lhcbStyle.SetPadLeftMargin(0.14)
    lhcbStyle.SetTextFont(kLHCbFont)
    lhcbStyle.SetTextSize(lhcbTSize)
    lhcbStyle.SetLabelFont(kLHCbFont, "x")
    lhcbStyle.SetLabelFont(kLHCbFont, "y")
    lhcbStyle.SetLabelFont(kLHCbFont, "z")
    lhcbStyle.SetLabelSize(lhcbTSize, "x")
    lhcbStyle.SetLabelSize(lhcbTSize, "y")
    lhcbStyle.SetLabelSize(lhcbTSize, "z")
    lhcbStyle.SetTitleFont(kLHCbFont)
    lhcbStyle.SetTitleFont(kLHCbFont, "x")
    lhcbStyle.SetTitleFont(kLHCbFont, "y")
    lhcbStyle.SetTitleFont(kLHCbFont, "z")
    lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "x")
    lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "y")
    lhcbStyle.SetTitleSize(1.2 * lhcbTSize, "z")
    lhcbStyle.SetLineWidth(lhcbWidth)
    lhcbStyle.SetHistLineWidth(lhcbWidth)
    lhcbStyle.SetFuncWidth(lhcbWidth)
    lhcbStyle.SetGridWidth(lhcbWidth)
    lhcbStyle.SetLineStyleString(2, "[12 12]")
    lhcbStyle.SetMarkerStyle(20)
    lhcbStyle.SetMarkerSize(1.0)
    lhcbStyle.SetLabelOffset(0.010, "X")
    lhcbStyle.SetLabelOffset(0.010, "Y")
    lhcbStyle.SetOptStat(0)
    lhcbStyle.SetStatFormat("6.3g")
    lhcbStyle.SetOptTitle(0)
    lhcbStyle.SetOptFit(0)
    lhcbStyle.SetTitleOffset(0.95, "X")
    lhcbStyle.SetTitleOffset(0.95, "Y")
    lhcbStyle.SetTitleOffset(1.2, "Z")
    lhcbStyle.SetTitleFillColor(0)
    lhcbStyle.SetTitleStyle(0)
    lhcbStyle.SetTitleBorderSize(0)
    lhcbStyle.SetTitleFont(kLHCbFont, "title")
    lhcbStyle.SetTitleX(0.0)
    lhcbStyle.SetTitleY(1.0)
    lhcbStyle.SetTitleW(1.0)
    lhcbStyle.SetTitleH(0.05)
    lhcbStyle.SetStatBorderSize(0)
    lhcbStyle.SetStatFont(kLHCbFont)
    lhcbStyle.SetStatFontSize(0.05)
    lhcbStyle.SetStatX(0.9)
    lhcbStyle.SetStatY(0.9)
    lhcbStyle.SetStatW(0.25)
    lhcbStyle.SetStatH(0.15)
    lhcbStyle.SetPadTickX(1)
    lhcbStyle.SetPadTickY(1)
    lhcbStyle.SetNdivisions(505, "x")
    lhcbStyle.SetNdivisions(510, "y")

    gROOT.SetStyle("lhcbstyle")
    gROOT.ForceStyle()
Ejemplo n.º 27
0
    def initialize(fitresults=True):
        gROOT.SetStyle("Plain")
        gStyle.SetOptFit()
        gStyle.SetOptStat(0)

        # 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.SetFrameFillColor(kWhite)
        gStyle.SetFrameFillStyle(1000)
        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(20)
        #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.15)
        gStyle.SetPadTopMargin(0.05)
        #gStyle.SetPadBottomMargin(0.13)
        gStyle.SetPadLeftMargin(0.16)
        gStyle.SetPadRightMargin(0.04)  # top group adaption, original is 0.02
        gStyle.SetPadBottomMargin(0.13)

        # 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.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.06, "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")
        #gStyle.SetLabelSize(0.04, "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.)
Ejemplo n.º 28
0
elif nj == "23":
    files["dat"] = 'susy_das_Inputfiles/data_eq23jets_das.txt'
elif nj == "4":
    files["dat"] = 'susy_das_Inputfiles/data_geq4jets_das.txt'

# Setup output directory for plots
if outd == "-1":
    outdir = "./"
else:
    outdir = outd + "/"
if not os.path.isdir(outdir): os.system("mkdir " + outdir)

# Setup ROOT
print "Setting ROOT options"
gROOT.SetBatch()
gROOT.SetStyle("Plain")
gStyle.SetOptStat(11111111)
gStyle.SetOptTitle(0)
gStyle.SetPalette(1)
gStyle.SetNdivisions(405, "x")
gStyle.SetEndErrorSize(0.)
gStyle.SetErrorX(0.001)

#########################################################
# Make fitFuncs dictionary containing all information
# for defining three fit functions
#########################################################

fitFuncs = {}

# Power law
Ejemplo n.º 29
0
# (the parameters should changed by hand in this file, look for 'User Options')
#

import os
from os.path import join, getsize
from ROOT import TFile, TProfile, TF1, TMath, TH1F, TCanvas, TPostScript, TGraphErrors
from ROOT import gDirectory
from math import fabs
from os import path
import sys
from ROOT import *
from ROOT import gROOT, gRandom, gStyle
from ROOT import TCanvas, TF1, TH1F, TH2F, TGLabel
gROOT.Reset()

gROOT.SetStyle("Pub")
gStyle.SetPadColor(10)
gStyle.SetGridColor(16)
gStyle.SetFrameFillColor(10)
gStyle.SetFillColor(10)
gStyle.SetTitleFillColor(10)
gStyle.SetTitleBorderSize(0)
gStyle.SetCanvasColor(10)
gStyle.SetStatColor(10)
gStyle.SetLabelSize(0.08, "xyz")
gStyle.SetTitleSize(0.08, "xyz")
gStyle.SetFrameLineWidth(1)
gStyle.SetHistLineWidth(1)
gStyle.SetNdivisions(510, "x")
gStyle.SetNdivisions(508, "y")
gStyle.SetNdivisions(8, "z")
Ejemplo n.º 30
0
def main():

    extension = "pdf"

    luminosity = 44307.4
    ymin = 0
    ymax = 0.024

    data_set_names = [
        (["SZee_all_susy_2l_0jets.root",
          "SZmumu_all_susy_2l_0jets.root"], "Z#rightarrowll", 860 + 0, 23),
        (["ZZ_1in3_susy_2l_0jets.root"], "ZZ#rightarrowll#nu#nu", 416 + 3, 43),
        (["WZ_1in3_susy_2l_0jets.root"], "WZ#rightarrowl#null", 416 - 8, 33),
        (["WW_1in3_susy_2l_0jets.root"], "WW#rightarrowl#nul#nu", 416 + 0, 20),
        ([
            "ttbar_1in3_susy_2l_0jets.root", "top_1in3_susy_2l_0jets.root",
            "antitop_1in3_susy_2l_0jets.root"
        ], "Top", 800 + 4, 21),
    ]

    DATA_dir = os.path.join(os.environ["HOME_DIRECTORY"], "Data", "SR_SUSY")

    ## Creating the plots
    gROOT.SetStyle("ATLAS")
    gROOT.ForceStyle()
    gStyle.SetErrorX(0.5)
    canvas = TCanvas("canvas", 'A basic canvas', 800, 600)
    # canvas.SetLogy()

    ## Adding in the legend
    leg = Plotting.Create_Legend(0.60, 0.60, 0.95, 0.95, ncols=1)

    ## Creating the stack
    stack = THStack("stack", "stack")
    stack.SetMinimum(ymin)
    stack.SetMaximum(ymax)

    ## Cycling through the different datasets
    for datasets, label, colour, style in data_set_names:

        ## Creating the total histogram which will be filled
        myhist = TH1D(label, label, 50, 0, 150)
        myhist.SetStats(True)
        myhist.StatOverflows(True)

        for dataset in datasets:

            ## The root file is opened
            rootfile_name = os.path.join(DATA_dir, dataset)
            print(rootfile_name)
            root_file = TFile.Open(rootfile_name, 'read')
            tree = root_file.Get("mt2_Truth")

            ## Creating the current histogram which will be filled
            thishist = TH1D(label, label, 50, 0, 150)
            thishist.SetStats(True)
            thishist.StatOverflows(True)

            ## Drawing the tree and saving the hist to the matrix
            execution = "mt2>>{}".format(label)
            tree.Draw(execution, "", "goff")

            thishist.SetDirectory(0)
            myhist.Add(thishist)

            ## We are dont with the file
            root_file.Close()
            del root_file

        ## Changing the properties of the histogram
        myhist.Scale(1 / myhist.Integral("width"))

        myhist.SetLineColor(colour)
        myhist.SetMarkerColor(colour)
        myhist.SetMarkerStyle(style)
        myhist.SetMarkerSize(1.5)

        ## Adding the legend entry
        leg.AddEntry(myhist, label, "p")

        ## Adding the object to the stack
        stack.Add(myhist)
        del myhist

    ## Drawing the stack on the currrent canvas
    stack.Draw("NOSTACK HIST P")
    leg.Draw()

    ## Setting axis labels
    stack.GetXaxis().SetTitle("m_{T2} (True #it{E}_{T}^{miss}) [GeV]")
    stack.GetYaxis().SetTitle("Normalised Distributions")

    ## Moving axis tick marks
    stack.GetYaxis().SetMaxDigits(3)
    stack.GetXaxis().SetLabelOffset(0.017)

    ## Drawing all text
    left = 0.2
    size = 1.0
    shift = 0.06
    pos = 0.88
    Plotting.Draw_ATLASLabel(left, pos, "Simulation", scale=1.0)
    pos -= shift
    Plotting.Draw_Text(left, pos, "work in progress", scale=size)
    pos -= shift
    Plotting.Draw_Lumi(left, pos, 0, scale=size)
    pos -= shift

    ## Updating the canvas
    canvas.Update()

    out_file = "true_strans.{}".format(extension)
    canvas.Print(out_file)

    del canvas

    return 0