Пример #1
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
Пример #2
0
 def DefaultPlotStyle(self):
     gStyle.SetPalette(55)  # 55 is kRainBow. 53 is kDarkBodyRadiator
     gStyle.SetOptStat(self.optStat1D)
     gStyle.SetOptFit(11111)
     gStyle.SetStatH(0.12)
     gStyle.SetStatW(0.15)
     gStyle.SetPadBottomMargin(0.15)
     gStyle.SetPadTopMargin(0.15)
Пример #3
0
def setStyle():
    gStyle.SetOptStat(0)
    gStyle.SetPadRightMargin(0.18)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetPadBottomMargin(0.1)
    gStyle.SetPadTopMargin(0.06)
    gStyle.SetOptTitle(0)
    gStyle.SetPalette(55)
Пример #4
0
 def loadstyle():
     gROOT.SetStyle("Plain")
     gStyle.SetOptStat(0)
     gStyle.SetOptStat(0000)
     gStyle.SetPalette(0)
     gStyle.SetCanvasColor(0)
     gStyle.SetFrameFillColor(0)
     gStyle.SetOptTitle(0)
Пример #5
0
def load_root_style_simple():
    """
    Set basic ROOT style for histograms
    """
    gStyle.SetOptStat(0)
    gStyle.SetPalette(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetFrameFillColor(0)
Пример #6
0
def Draw2Dhisto(tag='exp', pname='limits', lim=[0, 2.5]):
    zmin, zmax = lim
    h = Get2Dhisto(pname + '.p', tag)
    c = TCanvas('c', 'c', 10, 10, 1200, 800)
    #h.SetMaximum(zmax);
    h.SetMinimum(zmin)
    gStyle.SetPalette(51)  #58)
    h.Draw('colz')
    for f in ['png', 'pdf']:
        c.Print('%s.%s' % (pname.replace('limits', 'scan'), f))
Пример #7
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))
Пример #8
0
def PlotDeposit(hist, outname):

    from ROOT import TCanvas, gStyle, kBird, TLine
    gStyle.SetPalette(kBird)

    canvas = TCanvas('canvas', 'canvas', 800, 500)
    canvas.SetRightMargin(0.15)
    hist.GetXaxis().SetTitle("Depth from Calorimeter Center [mm]")
    hist.GetYaxis().SetTitle("#eta direction [mm]")
    hist.GetZaxis().SetTitle("Local Energy Deposit [MeV]")
    hist.Draw('colz')

    # taken from: https://github.com/jodafons/lorenzet/blob/master/src/SteppingAction.cc
    vertical_lines = [(150, 0, 150, 480), (450, 0, 450, 480),
                      (480, 0, 480, 480), (880, 0, 880, 480),
                      (1280, 0, 1280, 480)]
    first_em_layer = []
    second_em_layer = []
    third_em_layer = []
    first_had_layer = []
    second_had_layer = []
    third_had_layer = []

    # horizontal lines
    for y in range(0, 480, int(480 / 96)):
        # (x1,y,x2,y)
        first_em_layer.append((0, y, 150, y))
    for y in range(0, 480, int(480 / 12)):
        # (x1,y,x2,y)
        second_em_layer.append((150, y, 450, y))
    for y in range(0, 480, int(480 / 6)):
        # (x1,y,x2,y)
        third_em_layer.append((450, y, 480, y))

    # horizontal lines
    for y in range(0, 480, int(480 / 8)):
        # (x1,y,x2,y)
        first_had_layer.append((480, y, 880, y))
    for y in range(0, 480, int(480 / 8)):
        # (x1,y,x2,y)
        second_had_layer.append((880, y, 1280, y))
    for y in range(0, 480, int(480 / 4)):
        # (x1,y,x2,y)
        third_had_layer.append((1280, y, 1480, y))

    objects = []
    for l in vertical_lines + first_em_layer + second_em_layer + third_em_layer + first_had_layer + second_had_layer + third_had_layer:
        obj = TLine(l[0], l[1], l[2], l[3])
        obj.Draw('sames')
        objects.append(obj)

    #hist.GetXaxis().SetLimits(0,480)
    #hist.GetYaxis().SetLimits(0,480)
    canvas.SaveAs(outname)
Пример #9
0
def PlotCells(hist, outname, zlabel="Energy Deposit Average [MeV]"):

    from ROOT import TCanvas, gStyle, kBird, TLine
    gStyle.SetPalette(kBird)
    canvas = TCanvas('canvas', 'canvas', 500, 500)
    canvas.SetRightMargin(0.15)
    hist.GetXaxis().SetTitle("#phi Cell")
    hist.GetYaxis().SetTitle("#eta Cell")
    hist.GetZaxis().SetTitle(zlabel)
    hist.Draw('colz')
    canvas.SaveAs(outname)
Пример #10
0
def setColorPalette():
	nGradients = 100
	palette = []
	r = [0, 0/255., 227./255., 255/255., 244/255.]
	g = [0,0/255.,0/255.,237/255.,244/255.]
	b = [0,159/255.,102/255.,0/255.,244/255.]
	stop = [0,.25,.55,.9,1]
	FI = TColor.CreateGradientColorTable(5,array('d',stop),array('d',r),array('d',g),array('d',b),nGradients)
	for i in range(0,nGradients):
		palette.append(FI+i)
	gStyle.SetPalette(nGradients,array('i',palette))
Пример #11
0
    def draw_syst(self, save_dir, results_dir, root_dir=None):
        """Draw all fits one-by-one

        Args:
            save_dir: directory where to save plots
            results_dir: where to find intermediate results of the multi trial
            root_dir: TDirectory where to save summary plots
        """

        gStyle.SetOptStat(0)
        gStyle.SetOptStat(0000)
        gStyle.SetPalette(1)
        gStyle.SetCanvasColor(0)
        gStyle.SetFrameFillColor(0)

        bins1_ranges = self.pars_factory.bins1_edges_low.copy()
        bins1_ranges.append(self.pars_factory.bins1_edges_up[-1])

        for (ibin1, ibin2), fit in self.syst_fits.items():
            if not fit:
                self.logger.warning(
                    "No systematic fit for bins (%i, %i). Skip...", ibin1,
                    ibin2)
                continue
            bin_id_match = self.pars_factory.bin_matching[ibin1]

            # Some variables set for drawing
            title = f"{self.pars_factory.bins1_edges_low[ibin1]:.1f} < #it{{p}}_{{T}} < " \
                    f"{self.pars_factory.bins1_edges_up[ibin1]:.1f}" \
                    f"(prob > {self.pars_factory.prob_cut_fin[bin_id_match]:.2f})"

            suffix_write = self.pars_factory.make_suffix(ibin1, ibin2)

            fit.results_path = os.path.join(
                results_dir, f"multi_trial_bin1_{ibin1}_bin2_{ibin2}.root")

            # Central fits
            canvas = TCanvas("fit_canvas", suffix_write, 1400, 800)
            fit.draw(canvas, title=title)

            if self.pars_factory.apply_weights is False:
                canvas.SaveAs(
                    make_file_path(save_dir, "multi_trial", "eps", None,
                                   suffix_write))
            else:
                canvas.SaveAs(
                    make_file_path(save_dir, "multi_trial_weights", "eps",
                                   None, suffix_write))

            if root_dir:
                root_dir.cd()
                canvas.Write(f"multi_trial_{suffix_write}")

            canvas.Close()
Пример #12
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)
Пример #13
0
def RenderHisto(histo, canvas):

    if ("ELE_LOGY" in histo.GetOption() and histo.GetMaximum() > 0):
        canvas.SetLogy(1)
    histo_name_flag = 1
    # use 0 to switch off
    if (histo.InheritsFrom("TH2")):
        gStyle.SetPalette(1)
        gStyle.SetOptStat(110 + histo_name_flag)
    elif (histo.InheritsFrom("TProfile")):
        gStyle.SetOptStat(110 + histo_name_flag)
    else:  # TH1
        gStyle.SetOptStat(111110 + histo_name_flag)
Пример #14
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)
Пример #15
0
def plot_correction( h2, slope, offset, x_points, y_points, error_points, outname, 
                     xlabel='',
                     etBinIdx=None, 
                     etaBinIdx=None, 
                     etBins=None,
                     etaBins=None, 
                     label='Internal',
                     ref_value=None, 
                     pd_value=None,
                     palette=kBlackBody):

    def toStrBin(etlist = None, etalist = None, etidx = None, etaidx = None):
        if etlist and etidx is not None:
            etlist=copy(etlist)
            if etlist[-1]>9999:  etlist[-1]='#infty'
            binEt = (str(etlist[etidx]) + ' < E_{T} [GeV] < ' + str(etlist[etidx+1]) if etidx+1 < len(etlist) else
                                     'E_{T} > ' + str(etlist[etidx]) + ' GeV')
            return binEt
        if etalist and etaidx is not None:
            binEta = (str(etalist[etaidx]) + ' < |#eta| < ' + str(etalist[etaidx+1]) if etaidx+1 < len(etalist) else
                                        str(etalist[etaidx]) + ' <|#eta| < 2.47')
            return binEta

    canvas = TCanvas("canvas","canvas",500,500)
    rpl.set_figure(canvas)
    gStyle.SetPalette(palette)
    canvas.SetRightMargin(0.15)
    canvas.SetTopMargin(0.15)
    canvas.SetLogz()
    h2.GetXaxis().SetTitle('Neural Network output (Discriminant)')
    h2.GetYaxis().SetTitle(xlabel)
    h2.GetZaxis().SetTitle('Count')
    h2.Draw('colz')
    g = TGraphErrors(len(x_points), array.array('d',x_points), array.array('d',y_points), array.array('d',error_points), array.array('d',[0]*len(x_points)))
    g.SetMarkerColor(kBlue)
    g.SetMarkerStyle(8)
    g.SetMarkerSize(1)
    g.Draw("P same")
    line = TLine(slope*h2.GetYaxis().GetXmin()+offset,h2.GetYaxis().GetXmin(), slope*h2.GetYaxis().GetXmax()+offset, h2.GetYaxis().GetXmax())
    line.SetLineColor(kBlack)
    line.SetLineWidth(2)
    line.Draw()
    # Add text labels into the canvas
    text = toStrBin(etlist=etBins, etidx=etBinIdx)
    text+= ', '+toStrBin(etalist=etaBins, etaidx=etaBinIdx)
    if ref_value and pd_value:
        text+=', P_{D} = %1.2f (%1.2f) [%%]'%(pd_value*100, ref_value*100)
    rpl.add_text(0.15, 0.885, text, textsize=.03)
    rpl.set_atlas_label(0.15, 0.94, label)
    rpl.format_canvas_axes(XLabelSize=16, YLabelSize=16, XTitleOffset=0.87, ZLabelSize=16,ZTitleSize=16, YTitleOffset=0.87, ZTitleOffset=1.1)
    canvas.SaveAs(outname)
Пример #16
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)
Пример #17
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])
Пример #18
0
def setNormalColorTable(diverging=False):
    if diverging:
        gStyle.SetPalette(54)
    else:
        ## My old GYR colors
        #rArray = array.array('d',[0.0,1.0,1.0])
        #gArray = array.array('d',[1.0,1.0,0.0])
        #bArray = array.array('d',[0.0,0.0,0.0])
        #stopArray = array.array('d',[0.,0.5,1.])
        #nTabColors = 500
        #root.TColor.CreateGradientColorTable(len(stopArray),
        #          stopArray,rArray,gArray,bArray,nTabColors
        #       )

        ## nice grey scale
        #alpha = 1.
        #stops = [ 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000]
        #red   = [ 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.];
        #green = [ 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.];
        #blue  = [ 0./255., 32./255., 64./255., 96./255., 128./255., 160./255., 192./255., 224./255., 255./255.];
        #root.TColor.CreateGradientColorTable(len(stops),
        #              array.array('d',stops), array.array('d',red),
        #              array.array('d',green), array.array('d',blue), 255, alpha
        #          )

        # bird color palette from root 6
        alpha = 1.
        stops = [
            0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750,
            1.0000
        ]
        red = [
            0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956,
            0.9764
        ]
        green = [
            0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862,
            0.9832
        ]
        blue = [
            0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968,
            0.0539
        ]
        root.TColor.CreateGradientColorTable(len(stops),
                                             array.array('d', stops),
                                             array.array('d', red),
                                             array.array('d', green),
                                             array.array('d',
                                                         blue), 255, alpha)
Пример #19
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)
Пример #20
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)
Пример #21
0
    def DepositPlots(self):
        #Rstyle = TStyle(ROOT.TStyle)
        #gStyle.SetOptStat(0)
        gStyle.SetPalette(1)
        RootDirectory = 'MCFTDepositCreator'
        EdgePlotList = [
            "FibreAttenuationMap", "RadiationAttMap",
            "ReflectionContributionMap", "ReflectionAttenuationMap",
            "FinalAttenuationMap", "FinalReflectedAttenuationMap"
        ]
        #gROOT.SetStyle("Rstyle")
        for files in self.ListOfFiles:
            tfile = TFile.Open(files)
            OutFileMantisse = files[:files.find(
                '-histos')] + "/" + RootDirectory + "_" + time.strftime(
                    '%y-%m-%d_%H-%M', time.localtime())
            self.CreateDir(OutFileMantisse)
            tdir = tfile.GetDirectory(RootDirectory)
            histo1D = []
            histo2D = []
            histo2DQuarterEdge = []
            DepositCvs = TCanvas("Depositcvs", "Depositcvs")

            dirlist = tdir.GetListOfKeys()
            iter = dirlist.MakeIterator()
            key = iter.Next()
            td = None
            while key:
                if key.GetClassName() == 'TH1D':
                    td = key.ReadObj()
                    #objName = td.GetName()
                    #print "found TH1D", objName
                    histo1D.append(td)
                if key.GetClassName() == 'TH2D':
                    td = key.ReadObj()
                    #objName = td.GetName()
                    if td.GetName() in EdgePlotList:
                        histo2DQuarterEdge.append(td)
                    else:
                        histo2D.append(td)
                key = iter.Next()

            self.Draw2DHisto(histo2D, DepositCvs, OutFileMantisse)

            self.Draw2DHisto(histo2DQuarterEdge, DepositCvs, OutFileMantisse,
                             "QE")

            self.Draw1DHistoBar(histo1D, DepositCvs, OutFileMantisse)
Пример #22
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)
Пример #23
0
def createPlot(datasets, name, **kwargs):
    ''' 
    def createPlot(name, **kwargs):
    '''

    args = {}
    args.update(kwargs)
    if not ("normalizeToOne" in args and args["normalizeToOne"]):
        args["normalizeToLumi"] = McOnlyLumi
    p = plots.MCPlot(datasets, name, **args)
    p.setDefaultStyles()
    p.histoMgr.setHistoDrawStyleAll("COLZ")  #COLZ, LEGO2, SURF2, SCAT
    p.histoMgr.setHistoLegendStyleAll("P")  # "L", "P"
    gStyle.SetPalette(1)

    return p
Пример #24
0
def SetAtlasStyle():
  from ROOT import TROOT, gROOT, TStyle, gStyle
  atlasStyle = TStyle("ATLAS","Atlas style")
  icol=0
  atlasStyle.SetFrameBorderMode(icol)
  atlasStyle.SetFrameFillColor(icol)
  atlasStyle.SetCanvasBorderMode(icol)
  atlasStyle.SetCanvasColor(icol)
  atlasStyle.SetPadBorderMode(icol)
  atlasStyle.SetPadColor(icol)
  atlasStyle.SetStatColor(icol)
  atlasStyle.SetPaperSize(20,26)
  atlasStyle.SetPadTopMargin(0.04)
  atlasStyle.SetPadRightMargin(0.04)
  atlasStyle.SetPadBottomMargin(0.13)
  atlasStyle.SetPadLeftMargin(0.13)
  atlasStyle.SetTitleXOffset(1.0)
  atlasStyle.SetTitleYOffset(1.4)
  font=42
  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(1)
  atlasStyle.SetMarkerSize(1)
  atlasStyle.SetHistLineWidth(2)
  atlasStyle.SetLineStyleString(2,"[12 12]")
  atlasStyle.SetEndErrorSize(2)
  atlasStyle.SetOptTitle(0)
  atlasStyle.SetOptStat(0)
  atlasStyle.SetOptFit(0)
  atlasStyle.SetPadTickX(0)
  atlasStyle.SetPadTickY(0)
  gROOT.SetStyle("ATLAS")
  gROOT.ForceStyle()
  gStyle.SetPalette(1)
Пример #25
0
def Plot2DHist( th2, slope, offset, x_points, y_points, error_points, outname, xlabel='',
            etBinIdx=None, etaBinIdx=None, etBins=None,etaBins=None):

    from ROOT import TCanvas, gStyle, TLegend, kRed, kBlue, kBlack,TLine,kBird, kOrange,kGray
    from ROOT import TGraphErrors,TF1,TColor
    import array

    def AddTopLabels(can, etlist = None, etalist = None, etidx = None, etaidx = None, logger=None):

        extraText = [GetAtlasInternalText()]
        if etlist and etidx is not None:
            etlist=copy(etlist)
            if etlist[-1]>9999:  etlist[-1]='#infty'
            binEt = (str(etlist[etidx]) + ' < E_{T} [GeV] < ' + str(etlist[etidx+1]) if etidx+1 < len(etlist) else
                                     'E_{T} > ' + str(etlist[etidx]) + ' GeV')
            extraText.append(binEt)
        if etalist and etaidx is not None:
            binEta = (str(etalist[etaidx]) + ' < #eta < ' + str(etalist[etaidx+1]) if etaidx+1 < len(etalist) else
                                        str(etalist[etaidx]) + ' < #eta < 2.47')
            extraText.append(binEta)
        DrawText(can,extraText,.14,.68,.35,.93,totalentries=4)

    gStyle.SetPalette(kBird)
    drawopt='lpE2'
    canvas = TCanvas('canvas','canvas',500, 500)
    canvas.SetRightMargin(0.15)
    th2.GetXaxis().SetTitle('Neural Network output (Discriminant)')
    th2.GetYaxis().SetTitle(xlabel)
    th2.GetZaxis().SetTitle('Count')
    th2.Draw('colz')
    canvas.SetLogz()
    g = TGraphErrors(len(x_points), array.array('d',x_points), array.array('d',y_points), array.array('d',error_points), array.array('d',[0]*len(x_points)))
    g.SetLineWidth(1)
    g.SetLineColor(kBlue)
    g.SetMarkerColor(kBlue)
    g.Draw("P same")
    line = TLine(slope*th2.GetYaxis().GetXmin()+offset,th2.GetYaxis().GetXmin(), slope*th2.GetYaxis().GetXmax()+offset, th2.GetYaxis().GetXmax())
    line.SetLineColor(kBlack)
    line.SetLineWidth(2)
    line.Draw()
    AddTopLabels( canvas, etlist=etBins,etalist=etaBins,etidx=etBinIdx,etaidx=etaBinIdx)
    FormatCanvasAxes(canvas, XLabelSize=16, YLabelSize=16, XTitleOffset=0.87, ZLabelSize=14,ZTitleSize=14, YTitleOffset=0.87, ZTitleOffset=1.1)
    SetAxisLabels(canvas,'Neural Network output (Discriminant)',xlabel)
    canvas.SaveAs(outname+'.pdf')
    canvas.SaveAs(outname+'.C')
    return outname+'.pdf'
Пример #26
0
def PDFSummary(histname, timeid):
    print "histo", histname
    c = canvasL.EPCanvas2DLongXColz()
    gStyle.SetPalette(1)
    fin = TFile("gapFlag_errorFrac.root", "READ")
    h2 = fin.Get(histname)
    h2.Draw("colz")
    h2.GetXaxis().SetTitle("TCC Id")
    h2.GetYaxis().SetTitle("Channel #")

    latextext = "Gap Flag data                                            " + Era + " 2018"
    latexL.EPLatex(latextext)

    latexL.EPLatex(timeid, 0.48, 0.8)

    c.SaveAs("plots/" + histname + ".pdf")
    print "will work here"
Пример #27
0
def draw(h1, plotName, title):
    gStyle.SetPalette(55)
    c = TCanvas("c", "", 800, 600)
    h1.SetStats(0)
    h1.SetTitle(title)
    h1.GetXaxis().CenterTitle(1)
    h1.GetYaxis().CenterTitle(1)
    h1.GetXaxis().SetTitleSize(.04)
    h1.GetYaxis().SetTitleSize(.04)
    h1.GetYaxis().SetTitleOffset(1.1)
    h1.GetXaxis().SetTitleOffset(1.1)
    h1.GetXaxis().SetLimits(0, 4)
    h1.GetYaxis().SetLimits(0, 4)
    c.SetRightMargin(0.13)
    h1.Draw("COLZ")
    # h1.SetMaxDigits(2)
    c.SaveAs(plotName)
Пример #28
0
 def __init__(self, run=22011, sourceDir='./', outputDir=''):
     print 'Creating AnalyseTransparentArea instance for run:', run
     self.run = run
     self.sourceDir = sourceDir
     self.outputDir = outputDir if outputDir != '' else '{s}/{r}/transparentAnalysis/'.format(
         r=self.run, s=self.sourceDir)
     self.rootFile1 = TFile(
         sourceDir +
         '/{r}/transparentAnalysis/root/hLandau1HighestHitProfile_1OutOf10.{r}.root'
         .format(r=self.run))
     self.rootFile2 = TFile(
         sourceDir +
         '/{r}/transparentAnalysis/root/hLandau2HighestHitProfile_2OutOf10.{r}.root'
         .format(r=self.run))
     self.histo2D_1 = TProfile2D(
         self.rootFile1.Get('cRoot_hLandau1HighestHitProfile_1OutOf10').
         GetPrimitive('hLandau1HighestHitProfile_1OutOf10'))
     self.histo2D_2 = TProfile2D(
         self.rootFile2.Get('cRoot_hLandau2HighestHitProfile_2OutOf10').
         GetPrimitive('hLandau2HighestHitProfile_2OutOf10'))
     self.histo2D_1_fid = 0
     self.histo2D_2_fid = 0
     self.histo2D_1.GetXaxis().SetTitle('X/\mu m')
     self.histo2D_1.GetYaxis().SetTitle('Y/\mu m')
     self.histo2D_2.GetXaxis().SetTitle('X/\mu m')
     self.histo2D_2.GetYaxis().SetTitle('Y/\mu m')
     self.histo1D_1 = 0
     self.histo1D_2 = 0
     self.sel_old = {
         'x_low': self.histo2D_1.GetXaxis().GetXmin(),
         'x_high': self.histo2D_1.GetXaxis().GetXmax(),
         'y_low': self.histo2D_1.GetYaxis().GetXmin(),
         'y_high': self.histo2D_1.GetYaxis().GetXmax()
     }
     self.fidcut_1 = 0
     self.fidcut_2 = 0
     self.fidpoints = []
     self.nameFid = ''
     if not os.path.isdir('{dir}/Plots'.format(dir=self.outputDir)):
         os.makedirs('{dir}/Plots'.format(dir=self.outputDir))
     if not os.path.isdir('{dir}/root'.format(dir=self.outputDir)):
         os.makedirs('{dir}/root'.format(dir=self.outputDir))
     gStyle.SetPalette(55)
     gStyle.SetNumberContours(999)
     self.bla = []
Пример #29
0
def createTH2Plot(datasets, name, **kwargs):
    ''' 
    def createTH2Plot(name, **kwargs):
    '''

    ### Copy arguments to a new dictionary
    args = {}
    args.update(kwargs)
        
    ### Proceed differently for MC-only plots and Data-MC plots
    if not ("normalizeToOne" in args and args["normalizeToOne"]):
        args["normalizeToLumi"] = McOnlyLumi
    p = plots.DataMCPlot(datasets, name, **args)
    p.setDefaultStyles()
    p.histoMgr.setHistoDrawStyleAll("COLZ")
    gStyle.SetPalette(1)
  
    return p
Пример #30
0
def main():
    # configure and run
    _MGR = sf2r_manager(DEBUG)
    _MGR.ff_type_detector()
    plots = _MGR.run()
    file = None
    if not os.path.exists('fluka2root.root'):
        file = TFile('fluka2root.root', 'new')
    else:
        file = TFile('fluka2root.root', 'recreate')

    # set for apperance
    c = TCanvas('USRTRACK CARTESIAN REFERENCE FRAME 2D - XY',
                'USRTRACK CARTESIAN REFERENCE FRAME 2D - XY', 670, 400)
    gStyle.SetPalette(1)
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(0)

    # make a test plot and store plots in file
    for plot in plots:
        if plot.get_type() == '1DPLOT':
            if PLOT1D:
                plot.get_histo().Draw()
                plot.get_histo().Write()
        if plot.get_type() == '2DPLOT':
            if PLOT2D:
                #gPad.SetLogz()
                #gPad.SetGridx()
                #gPad.SetGridy()
                #plot.get_histo().Draw('P')
                plot.get_histo().Write()
        if plot.get_type() == '3DPLOT':
            if PLOT3D:
                #gPad.SetLogz();
                #gPad.SetGridx();
                #gPad.SetGridy();
                #plot.get_histo().Draw('P')
                plot.get_histo().Write()

    file.Close()

    print ' --> Press enter to finish... '
    raw_input()