Ejemplo n.º 1
0
def drawTopoGeometry(geometry, is2016):

    outfn = "TopoLayout%s.pdf" % ("2016" if is2016 else "2015")

    global box, c, h, leg

    gROOT.Reset()
    gStyle.SetOptStat(0)

    c = TCanvas('c', "MuCTPi to Topo Geometry", 1400, 950)
    c.Draw()

    h = TH2F("h", "Muon Topo Geometry %s" % "2016" if is2016 else "2015", 10,
             -2.6, 2.6, 10, -0.15, 6.4)
    h.SetXTitle("#eta")
    h.SetYTitle("#phi")
    h.Draw()

    box = TBox()
    box.SetFillStyle(0)
    box.SetLineColor(3)

    circle = TArc()

    for colorIndex, MioctID in enumerate(drawOrder):
        MIOCT = geometry.getMIOCT(MioctID)
        color = colorMap[colorIndex % len(colorMap)]
        box.SetLineColor(color)
        box.SetFillColor(color)

        circle.SetLineColor(color)
        circle.SetFillColor(color)

        fillStyle = 3004
        for cellIdx, TopoCell in enumerate(MIOCT.Decode.TopoCells):
            # corner 1
            c1_x = float(TopoCell["etamin"])
            c1_y = float(TopoCell["phimin"])
            # corner 2
            c2_x = float(TopoCell["etamax"])
            c2_y = float(TopoCell["phimax"])
            # center rounded
            c_x = float(TopoCell["ieta"])
            c_y = float(TopoCell["iphi"])

            #print "cell %i : eta [%f - %f], phi [%f - %f]" % (cellIdx, c1_x, c2_x, c1_y, c2_y)

            if fillStyle == 3004:
                fillStyle = 3012
            else:
                fillStyle = 3004
            box.SetFillStyle(fillStyle)
            box.DrawBox(c1_x, c1_y, c2_x, c2_y)
            box.SetFillStyle(0)
            box.DrawBox(c1_x, c1_y, c2_x, c2_y)

            circle.DrawArc(c_x / 10., c_y / 10., 0.02)

    c.Update()
    c.SaveAs(outfn)
Ejemplo n.º 2
0
def drawFilledBox(ieta, iphi, canvas):
    canvas.cd()
    box = TBox(ieta - 0.5, iphi - 0.5, ieta + 0.5, iphi + 0.5)
    box.SetLineColor(ROOT.kBlack)
    box.SetFillStyle(3013)
    box.SetFillColor(ROOT.kBlack)
    box.Draw()
    return box
Ejemplo n.º 3
0
def draw(plot, channel='MuMu', plotprefix=None, SetLogy=0):
    # print plot
    Stack.STAT_ERRORS = True
    blindxmin = None
    blindxmax = None
    titles = xtitles
    if channel == 'TauEle':
        titles = xtitles_TauEle
    xtitle = titles.get(plot.varName, None)
    if xtitle is None:
        xtitle = ''
    global can, pad, padr, ratio
    if pad is None:
        can, pad, padr = buildCanvas()
    pad.cd()
    pad.SetLogy(SetLogy)
    plot.DrawStack('HIST')
    h = plot.supportHist
    h.GetXaxis().SetLabelColor(0)
    h.GetXaxis().SetLabelSize(0)
    gevperbin = h.GetXaxis().GetBinWidth(1)
    h.GetYaxis().SetTitle('Events')
    h.GetYaxis().SetTitleOffset(1.4)
    padr.cd()
    ratio = copy.deepcopy(plot)
    ratio.legendOn = False
    ratio.DrawRatioStack('HIST', ymin=0.4, ymax=1.6)
    hr = ratio.stack.totalHist
    # hr.weighted.Fit('pol1')
    hr.GetYaxis().SetNdivisions(4)
    hr.GetYaxis().SetTitle('Exp./Obs.')
    hr.GetYaxis().SetTitleSize(0.1)
    hr.GetYaxis().SetTitleOffset(0.5)
    hr.GetXaxis().SetTitle('{xtitle}'.format(xtitle=xtitle))
    hr.GetXaxis().SetTitleSize(0.13)
    hr.GetXaxis().SetTitleOffset(0.9)
    rls = 0.075
    hr.GetYaxis().SetLabelSize(rls)
    hr.GetXaxis().SetLabelSize(rls)
    hr.GetYaxis().SetRangeUser(0.5, 1.5)
    padr.Update()
    # blinding
    if plot.blindminx:
        pad.cd()
        max = plot.stack.totalHist.GetMaximum()
        box = TBox(plot.blindminx, 0, plot.blindmaxx, max)
        box.SetFillColor(1)
        box.SetFillStyle(3004)
        box.Draw()
        # import pdb; pdb.set_trace()
        keeper.append(box)
    print channel
    if channel == 'MuMu': CMSPrelim(plot, pad, '#mu#mu')
    can.cd()
    if plotprefix == None: plotname = plot.varName
    else: plotname = plotprefix + '_' + plot.varName
    can.SaveAs(plotname + '.png')
    pad.SetLogy(0)
Ejemplo n.º 4
0
def draw_box(boxList,xl,xr,yl,yr,opacity=1,color=1,style=1001,lstyle=1,lw=3):
    from ROOT import TBox
    b=TBox(xl,yl,xr,yr)
    b.SetBit(ROOT.kCanDelete)
    b.SetFillStyle(style)
    b.SetFillColorAlpha(color, opacity)
    b.SetLineColor(color)
    b.SetLineWidth(lw)
    b.SetLineStyle(lstyle)
    b.Draw()
    boxList.append(b)
Ejemplo n.º 5
0
def drawHcalBoxesHcalCoords(canvas):
	canvas.cd()
	boxes = []
	for i in range(-15,15):
		for j in range(0,72):
			box = TBox(i,j,(i+1),(j+1))
			box.SetFillStyle(0)
			box.SetLineColor(colorRwthMagenta)
			box.SetLineWidth(2)
			box.Draw()
			boxes.append(box)
	return boxes
Ejemplo n.º 6
0
def drawHoBoxes(canvas):
    canvas.cd()
    boxes = []
    for i in range(1, 6):
        for j in range(1, 6):
            box = TBox(-2.5 + i - 1, -2.5 + j - 1, -2.5 + i, -2.5 + j)
            box.SetFillStyle(0)
            box.SetLineColor(ROOT.kBlack)
            box.SetLineWidth(2)
            box.Draw()
            boxes.append(box)
    return boxes
Ejemplo n.º 7
0
def drawHoBoxes(canvas):
	canvas.cd()
	boxes = []
	for i in range(-1,2):
		for j in range(-1,2):
			box = TBox(i*0.087 - 0.0435,j*0.087 - 0.0435,(i*0.087+0.0435),(j*0.087+0.0435))
			box.SetFillStyle(0)
			box.SetLineColor(colorRwthMagenta)
			box.SetLineWidth(3)
			box.Draw()
			boxes.append(box)
	return boxes
Ejemplo n.º 8
0
def drawHoBoxes(canvas):
    canvas.cd()
    boxes = []
    for i in range(1, 8):
        for j in range(1, 8):
            box = TBox(-0.3045 + (i - 1) * 0.087, -0.3045 + (j - 1) * 0.087,
                       -0.3045 + i * 0.087, -0.3045 + j * 0.087)
            box.SetFillStyle(0)
            box.SetLineColor(ROOT.kBlack)
            box.SetLineWidth(2)
            box.Draw()
            boxes.append(box)
    return boxes
Ejemplo n.º 9
0
 def __init__(self, description):
     self.desc = description
     self.circles = []
     self.boxes = []
     self.circles.append( TEllipse(0., 0.,
                                   self.desc.volume.outer.rad,
                                   self.desc.volume.outer.rad) )
     dz = self.desc.volume.outer.z
     radius = self.desc.volume.outer.rad
     self.boxes.append( TBox(-dz, -radius, dz, radius) ) 
     
     if self.desc.volume.inner:
         self.circles.append( TEllipse(0., 0.,
                                       self.desc.volume.inner.rad,
                                       self.desc.volume.inner.rad))
         dz = self.desc.volume.inner.z
         radius = self.desc.volume.inner.rad
         self.boxes.append( TBox(-dz, -radius, dz, radius) ) 
     color = COLORS[self.desc.material.name]
     oc = self.circles[0]
     ob = self.boxes[0]
     for shape in [oc, ob]:
         if color: 
             shape.SetFillColor(color)
             shape.SetFillStyle(1001)
         else:
             shape.SetFillStyle(0)
         shape.SetLineColor(1)
         shape.SetLineStyle(1)                
     if len(self.circles)==2:
         ic = self.circles[1]
         ib = self.boxes[1]
         for shape in [ic, ib]:
             if color:
                 shape.SetFillColor(0)
                 shape.SetFillStyle(1001)
             else:
                 shape.SetFillStyle(0)
Ejemplo n.º 10
0
def drawBox(x1, y1, x2, y2, t=""):
    box = TBox(x1, y1, x2, y2)
    box.SetFillColor(1)
    box.SetFillStyle(3004)
    box.Draw()
    if not t == "":
        text = TLatex()
        text.SetTextColor(1)
        text.SetTextFont(42)
        text.SetTextAlign(23)
        text.SetTextSize(0.04)
        text.DrawLatex((x1 + x2) / 2., y2 / 1.15, t)
        text.Draw()
    return box
Ejemplo n.º 11
0
def drawOfficial(plot, doBlind=False, channel='TauMu', plotprefix = None, ymin = 0.1):
    global ocan
    print plot
    Stack.STAT_ERRORS = False
    blindxmin = None
    blindxmax = None
    doBlind = (plot.varName == 'svfitMass') and doBlind
    if doBlind:
        blindxmin = 100
        blindxmax = 160
        plot.Blind(blindxmin, blindxmax, False)
    titles = xtitles
    if channel=='TauEle':
        titles = xtitles_TauEle
    xtitle = titles.get( plot.varName, None )
    if xtitle is None:
        xtitle = ''
    global ocan
    if ocan is None:
        ocan = buildCanvasOfficial()
    ocan.cd()
    plot.DrawStack('HIST', ymin=ymin)
    h = plot.supportHist
    h.GetXaxis().SetTitle('{xtitle}'.format(xtitle=xtitle))
    # blinding
    if plot.blindminx:
        ocan.cd()
        max = plot.stack.totalHist.GetMaximum()
        box = TBox( plot.blindminx, 0,  plot.blindmaxx, max )
        box.SetFillColor(1)
        box.SetFillStyle(3004)
        box.Draw()
        # import pdb; pdb.set_trace()
        keeper.append(box)
    year, lumi, energy = datasetInfo( plot )
    datasetStr = "CMS Preliminary, #sqrt{{s}} = {energy} TeV, L = {lumi:3.2f} fb^{{-1}}".format(energy=energy, lumi=lumi)
    if channel == 'TauMu' : a,b = CMSPrelimOfficial( datasetStr, '#tau_{#mu}#tau_{h}',0.15,0.835)
    elif channel == 'TauEle' : a,b = CMSPrelimOfficial( datasetStr, '#tau_{e}#tau_{h}', 0.15, 0.835)
    a.Draw()
    b.Draw()
    save.extend([a,b])
    ocan.Modified()    
    ocan.Update()    
    ocan.cd()
    if plotprefix == None : plotname = plot.varName
    else : plotname = plotprefix + '_' + plot.varName
    ocan.SaveAs( plotname + '.png')
    ocan.SetLogy()
    ocan.SaveAs( plotname + '_log.png')
    ocan.SetLogy(0)
Ejemplo n.º 12
0
    def makeTimeVsEtaPlot(self, source, title=""):
        canvas = TCanvas(source)
        if title == "":
            title = source
        hist = TH2D(source, title + ";i#eta;Time / ns;#", 33, -16.5, 16.5, 201,
                    -100.5, 100.5)
        graph = self.fileHandler.getGraph('graphs/timingSupport_' + source)
        fillGraphIn2DHist(graph, hist)
        hist.SetStats(0)
        hist.Draw('colz')
        canvas.Update()
        setupAxes(hist)
        label = self.drawLabel()
        canvas.Update()
        fractionGraph, counterDict = self.printFractionsPerIEta(graph)
        self.debug('Integral of plot %20s: %d' % (source, hist.Integral()))
        medianTofZero = (counterDict[9]['median'] +
                         counterDict[11]['median']) / 2.
        tofFunction = TF1(
            'f',
            '4*sqrt(1+ 1/(tan(2*atan(exp(-x*0.087/2.)))**2))/300000000.*1e9 - 13.3 + [0]',
            -10, 10)
        tofFunction.SetParameter(0, medianTofZero)
        tofFunction.Draw('same')

        ###
        # Draw Boxes for the Intervals
        ###
        intervalBoxes = []
        for index, item in enumerate(counterDict):
            iEta = index - 10
            # Skip iEta 0
            if iEta == 0:
                continue
            box = TBox(iEta - 0.5, item['median'] - 12.5, iEta + 0.5,
                       item['median'] + 12.5)
            box.SetFillStyle(0)
            box.SetLineColor(colorRwthMagenta)
            box.SetLineWidth(2)
            box.Draw()
            intervalBoxes.append(box)

        return canvas, hist, label, fractionGraph, intervalBoxes, tofFunction
Ejemplo n.º 13
0
    def plot3x3MatchQualityCodesVsPt(self):
        c = TCanvas('cMatchQC3x3', 'Match QC 3x3', 0, 0, 900, 700)
        c.SetLogz()
        hist = self.fileHandler.getHistogram(
            'qualityCode/L1Muon3x3Match_QcVsPt')
        hist.SetStats(0)
        hist.Scale(1, 'width')
        hist.Draw('colz')
        c.Update()
        setupPalette(hist)
        c.Update()

        label = self.drawLabel()
        c.Update()

        box = TBox(0, 6.5, 180, 7.5)
        box.SetLineColor(3)
        box.SetLineWidth(2)
        box.Draw()

        c.Update()

        return hist, c, label, box
Ejemplo n.º 14
0
		Ya = (y2-yf)/(1-bm-to)-(y2-yf)
		LM = Xa*(lm/(lm+rm))
		RM = Xa*(rm/(lm+rm))
		BM = Ya*(bm/(bm+to))
		TM = Ya*(to/(bm+to))

		null = TPad("null","",0,0,1,1)
		null.SetFillStyle(0)
		null.SetFrameFillStyle(0)
		null.Draw()
		null.cd()
		null.Range(x1-LM,yf-BM,x2+RM,y2+TM)

		tri=TPolyLine(3,xx,yy)
		tri.SetFillColor(0)
		box1=TBox(-0.2,-0.2,1.05,0)
		box2=TBox(-0.2,-0.2,0,1.05)
		box1.SetFillColor(0)
		box2.SetFillColor(0)
		#p.Draw('atext')
		tri.Draw('f')
		box1.Draw('f')
		box2.Draw('f')
		tri.Draw('f')

		if tipo in ['obs','exp']:
			bm = c.GetBottomMargin()
			lm = c.GetLeftMargin()
			rm = c.GetRightMargin()
			to = c.GetTopMargin()
			x1 = p.GetXaxis().GetXmin()
Ejemplo n.º 15
0
    def draw(plot,
             do_ratio=True,
             channel='e#mu#mu',
             plot_dir='/plots/',
             plot_name=None,
             SetLogy=0,
             blindxmin=None,
             blindxmax=None,
             unit=None,
             server='starseeker',
             region='DY',
             channel_dir='mmm',
             dataset='2017'):
        print(plot)
        Stack.STAT_ERRORS = True

        can = pad = padr = None

        if do_ratio:
            can, pad, padr = HistDrawer.buildCanvas()
            pad.cd()
            pad.SetLogy(SetLogy)
        else:
            can = HistDrawer.buildCanvasSingle()
            pad = can
            pad.cd()
            pad.SetLogy(SetLogy)

        # plot.DrawStack('HIST', print_norm=plot.name=='_norm_', ymin=0.1) # magic word to print integrals in legend
        plot.DrawStack('HIST', print_norm=('_norm_' in plot.name),
                       ymin=0.1)  # magic word to print integrals in legend

        h = plot.supportHist
        h.GetXaxis().SetLabelColor(1)
        # h.GetXaxis().SetLabelSize(1)

        unitsperbin = h.GetXaxis().GetBinWidth(1)
        ytitle = 'Events'
        if unit:
            round_to_n = lambda x, n: round(
                x, -int(floor(log10(abs(x)))) + (n - 1))
            ytitle += round_to_n(unitsperbin, 3)

        h.GetYaxis().SetTitle('Events')
        h.GetYaxis().SetTitleOffset(1.4)
        h.GetXaxis().SetTitleOffset(2.0)

        if do_ratio:
            padr.cd()
            ratio = copy.deepcopy(plot)
            ratio.legendOn = True
            ratio.STAT_ERRORS = True

        if blindxmin or blindxmax:
            if not blindxmin:
                blindxmin = 0
            if not blindxmax:
                blindxmax = plot.stack.totalHist.GetXaxis().GetXmax()
            if do_ratio:
                ratio.Blind(blindxmin, blindxmax, True)
            plot.Blind(blindxmin, blindxmax, False)

        if do_ratio:
            # ratio.DrawDataOverMCMinus1(-0.5, 0.5)
            ratio.DrawDataOverMCMinus1(-0.9, 0.9)
            hr = ratio.dataOverMCHist

            # Gymnastics to get same label sizes etc in ratio and main plot
            ytp_ratio = 2.
            xtp_ratio = 2.

            # hr.GetYaxis().SetNdivisions(4)

            hr.GetYaxis().SetTitleSize(h.GetYaxis().GetTitleSize() * xtp_ratio)
            hr.GetXaxis().SetTitleSize(h.GetXaxis().GetTitleSize() * ytp_ratio)

            hr.GetYaxis().SetTitleOffset(h.GetYaxis().GetTitleOffset() /
                                         xtp_ratio)
            hr.GetXaxis().SetTitleOffset(h.GetXaxis().GetTitleOffset() /
                                         ytp_ratio)

            hr.GetYaxis().SetLabelSize(h.GetYaxis().GetLabelSize() * xtp_ratio)
            hr.GetXaxis().SetLabelSize(h.GetXaxis().GetLabelSize() * ytp_ratio)

            h.GetXaxis().SetLabelColor(0)
            h.GetXaxis().SetLabelSize(0)
            padr.Update()

        # blinding
        if blindxmin or blindxmax:
            pad.cd()
            max = plot.stack.totalHist.GetMaximum()
            box = TBox(blindxmin, 0, blindxmax, max)
            box.SetFillColor(1)
            box.SetFillStyle(3004)
            box.Draw()
            HistDrawer.keeper.append(box)

        HistDrawer.CMSPrelim(plot, pad, channel, legend=plot.legendPos)
        can.cd()

        gErrorIgnoreLevel = kWarning
        h.GetYaxis().SetRangeUser(0, pad.GetUymax() * 1.)
        plotname = plot_name if plot_name else plot.name

        if ('dz' in plotname) or ('logx' in plotname):
            pad.SetLogx(True)
            try:
                padr.SetLogx(True)
            except:
                pass

        if not os.path.exists(plot_dir + '/pdf/'):
            os.mkdir(plot_dir + '/pdf/')
            os.mkdir(plot_dir + '/pdf/linear/')
            os.mkdir(plot_dir + '/pdf/log/')
        if not os.path.exists(plot_dir + '/root/'):
            os.mkdir(plot_dir + '/root/')
            os.mkdir(plot_dir + '/root/linear/')
            os.mkdir(plot_dir + '/root/log')
        if not os.path.exists(plot_dir + '/png/'):
            os.mkdir(plot_dir + '/png/')
            os.mkdir(plot_dir + '/png/linear/')
            os.mkdir(plot_dir + '/png/log/')
        if not os.path.exists(plot_dir + '/datacards/'):
            os.mkdir(plot_dir + '/datacards/')
        can.SaveAs(plot_dir + '/pdf/linear/' + plotname + '.pdf')
        can.SaveAs(plot_dir + '/root/linear/' + plotname + '.root')
        can.SaveAs(plot_dir + '/png/linear/' + plotname + '.png')

        if server == "starseeker":
            if dataset == '2017':
                t3_dir = '/home/dehuazhu/t3work/3_figures/1_DataMC/FinalStates/' + channel_dir + '/' + region.name
            if dataset == '2018':
                t3_dir = '/home/dehuazhu/t3work/3_figures/1_DataMC/FinalStates/2018/' + channel_dir + '/' + region.name
            can.SaveAs(t3_dir + '/pdf/linear/' + plotname + '.pdf')
            can.SaveAs(t3_dir + '/root/linear/' + plotname + '.root')
            can.SaveAs(t3_dir + '/png/linear/' + plotname + '.png')

        # Also save with log y
        h.GetYaxis().SetRangeUser(pad.GetUymax() * 5. / 1000000.,
                                  pad.GetUymax() * 1000.)
        pad.SetLogy(True)
        can.SaveAs(plot_dir + '/png/log/' + plotname + '_log.png')
        can.SaveAs(plot_dir + '/root/log/' + plotname + '_log.root')
        can.SaveAs(plot_dir + '/pdf/log/' + plotname + '_log.pdf')
        if server == "starseeker":
            can.SaveAs(t3_dir + '/pdf/log/' + plotname + '_log.pdf')
            can.SaveAs(t3_dir + '/root/log/' + plotname + '_log.root')
            can.SaveAs(t3_dir + '/png/log/' + plotname + '_log.png')
        pad.SetLogy(0)
        # if 'dz' in plotname:
        if ('dz' in plotname) or ('logx' in plotname):
            pad.SetLogx(False)
            try:
                padr.SetLogx(False)
            except:
                pass
Ejemplo n.º 16
0
    else: yTitle += "sensitivity (90% CL) "
    yTitle += "[years]"
hiBGFunc.GetYaxis().SetTitle(yTitle)
hiBGFunc.GetYaxis().CenterTitle()
#hiBGFunc.GetYaxis().SetNoExponent()
if not drawMbb: hiBGFunc.GetYaxis().SetTitleOffset(1.2)
hiBGFunc.Draw()

# eyeballing from Schubert plot m_l -> 0, with PDG 2013 osc parameters
ihMinMinMbb_meV = 16.2
ihMinMbb_meV = 18.3
ihMaxMbb_meV = 48.3
ihMaxMaxMbb_meV = 49.2
ihText = "Inverted Hierarchy (m_{#it{l}} #rightarrow 0 eV) "
if drawMbb:
    bInvHierOut = TBox(expMin_ty, ihMinMinMbb_meV, 0.98 * expMax_ty,
                       ihMaxMaxMbb_meV)
    bInvHierIn = TBox(expMin_ty, ihMinMbb_meV, 0.98 * expMax_ty, ihMaxMbb_meV)
    lInvHier = TLatex(2. * expMin_ty,
                      math.sqrt(ihMinMinMbb_meV * ihMaxMaxMbb_meV), ihText)
else:
    ihMinMinTHalf_y = SensClass.GetTHalf(ihMaxMaxMbb_meV * CLHEP.meV, isotope,
                                         nmeModel, ga) / CLHEP.year
    ihMinTHalf_y = SensClass.GetTHalf(ihMaxMbb_meV * CLHEP.meV, isotope,
                                      nmeModel, ga) / CLHEP.year
    ihMaxTHalf_y = SensClass.GetTHalf(ihMinMbb_meV * CLHEP.meV, isotope,
                                      nmeModel, ga) / CLHEP.year
    ihMaxMaxTHalf_y = SensClass.GetTHalf(ihMinMinMbb_meV * CLHEP.meV, isotope,
                                         nmeModel, ga) / CLHEP.year
    bInvHierOut = TBox(expMin_ty, ihMinMinTHalf_y, 0.98 * expMax_ty,
                       ihMaxMaxTHalf_y)
    bInvHierIn = TBox(expMin_ty, ihMinTHalf_y, 0.98 * expMax_ty, ihMaxTHalf_y)
Ejemplo n.º 17
0
            else:  # Custom (x,delta) for this histogram
                tmp_x = float(hArgs[iArg + 2])
                tmp_delta = float(hArgs[iArg + 3])
                iArg + 4

            histoMerged[tmp_path] = f.Get("run_%d/%s" % (runNumber, tmp_path))
            histoMerged[tmp_path].SetTitle(
                "%s - Run %d" % (histoMerged[tmp_path].GetTitle(), runNumber))

            c[tmp_path] = TCanvas(tmp_path, tmp_path)
            minH = histoMerged[tmp_path].GetMinimum() * 0.8
            maxH = histoMerged[tmp_path].GetMaximum() * 1.2
            histoMerged[tmp_path].SetMinimum(minH)
            histoMerged[tmp_path].SetMaximum(maxH)
            histoMerged[tmp_path].Draw()
            box[tmp_path] = TBox(tmp_x - tmp_delta, minH, tmp_x + tmp_delta,
                                 maxH)
            box[tmp_path].SetLineColor(kRed + 1)
            box[tmp_path].SetLineWidth(3)
            box[tmp_path].SetFillStyle(0)
            box[tmp_path].Draw()

            # Extract the list of bins where to count.
            # Scans the window to find all bins that fall in the window
            # The regionBins is defined for each histogram allowing different binning
            nSteps = 1000
            subStep = 2 * tmp_delta / nSteps
            for ix in range(nSteps):
                iX = tmp_x - tmp_delta + ix * subStep
                tmp_bin = histoMerged[tmp_path].FindBin(iX)
                if (tmp_bin not in regionBins):
                    regionBins.append(tmp_bin)
Ejemplo n.º 18
0
class Calorimeter:
    '''class for calorimeter plotting'''
    #class members
    name = 'n'  #ClassVar[TString]
    range_min = 0  #ClassVar[float]
    range_max = 0  #ClassVar[float]
    content = []  #ClassVar[list[float]] #of float
    ombox = []  #ClassVar[list[TBox]] #of TBox
    omtext = []  #ClassVar[list[TText]] #of TText
    source_foil = TLine()  #ClassVar[TLine]
    it_label = ''  #ClassVar[TText]
    fr_label = ''  #ClassVar[TText]
    canvas = None  #ClassVar[TCanvas]
    palette_index = 0  #ClassVar[int]
    fiber_map_lines = np.array([TLine])
    ncalo = 712  #ClassVar[int]
    nmwall = 520
    nxwall = 128
    ngveto = 64

    #constructor of calorimeter
    for calo in range(ncalo):
        content.append(0)

    range_min = range_max = -1

    spacerx = 0.0125
    spacery = 0.0250

    mw_sizey = (1 - 4 * spacery) / (13 + 2)
    gv_sizey = mw_sizey
    xw_sizey = mw_sizey * 13. / 16.

    mw_sizex = (0.5 - 4 * spacerx) / (20 + 4)
    gv_sizex = mw_sizex * 20. / 16.
    xw_sizex = mw_sizex

    for mw0 in range(2):
        for mw1 in range(20):
            for mw2 in range(13):
                id = mw0 * 20 * 13 + mw1 * 13 + mw2
                x1 = spacerx + 2 * xw_sizex + spacerx + 0.5 * mw0 + mw_sizex * (
                    mw1)
                if (mw0 == 1):
                    #swap french in case of internal view
                    x1 = spacerx + 2 * xw_sizex + spacerx + 0.5 * mw0 + mw_sizex * (
                        19 - mw1)
                y1 = spacery + gv_sizey + spacery + mw_sizey * mw2
                x2 = x1 + mw_sizex
                y2 = y1 + mw_sizey
                box = TBox(x1, y1, x2, y2)
                box.SetFillColor(0)
                box.SetLineWidth(1)
                ombox.append(box)

                text = TText(
                    x1 + 0.33 * mw_sizex, y1 + 0.33 * mw_sizey,
                    str(id).zfill(3)
                )  # "{:10.4f}".format(xid))#, TString::Form("%03d",id))
                text.SetTextSize(0.02)
                omtext.append(text)

    for xw0 in range(2):
        for xw1 in range(2):
            for xw2 in range(2):
                for xw3 in range(16):
                    id = 520 + xw0 * 2 * 2 * 16 + xw1 * 2 * 16 + xw2 * 16 + xw3
                    # x1 = 0
                    if xw0 == 0:
                        if xw1 == 0:
                            x1 = spacerx + xw_sizex * xw2
                        elif xw1 == 1:
                            x1 = spacerx + 2 * xw_sizex + spacerx + 20 * mw_sizex + spacerx + (
                                1 - xw2) * xw_sizex

                    elif xw0 == 1:  #wall ID
                        if xw1 == 0:  #side ID
                            x1 = 0.5 + spacerx + 2 * xw_sizex + spacerx + 20 * mw_sizex + spacerx + (
                                1 - xw2) * xw_sizex
                        elif xw1 == 1:
                            x1 = 0.5 + spacerx + xw_sizex * xw2

                    x2 = x1 + xw_sizex

                    y1 = spacery + gv_sizey + spacery + xw_sizey * (xw3)
                    y2 = spacery + gv_sizey + spacery + xw_sizey * (xw3 + 1)

                    box = TBox(x1, y1, x2, y2)
                    box.SetFillColor(0)
                    box.SetLineWidth(1)
                    ombox.append(box)

                    text = TText(x1 + 0.33 * mw_sizex, y1 + 0.33 * mw_sizey,
                                 str(id).zfill(3))
                    text.SetTextSize(0.02)
                    omtext.append(text)

    for gv0 in range(2):
        for gv1 in range(2):
            for gv2 in range(16):
                id = 520 + 128 + gv0 * 2 * 16 + gv1 * 16 + gv2
                # x1 = 0
                if gv0 == 0:  #side ID 1
                    x1 = spacerx + 2 * xw_sizex + spacerx + gv_sizex * gv2

                elif gv0 == 1:  #wall ID 0
                    x1 = 0.5 + spacerx + 2 * xw_sizex + spacerx + gv_sizex * (
                        16 - 1 - gv2)

                x2 = x1 + gv_sizex
                y1 = spacery + gv1 * (gv_sizey + spacery + 13 * mw_sizey +
                                      spacery)
                y2 = y1 + gv_sizey
                box = TBox(x1, y1, x2, y2)
                box.SetFillColor(0)
                box.SetLineWidth(1)
                ombox.append(box)

                text = TText(x1 + 0.33 * gv_sizex, y1 + 0.33 * gv_sizey,
                             str(id).zfill(3))
                text.SetTextSize(0.02)
                omtext.append(text)

    source_foil = TLine(0.5, spacery, 0.5, 1 - spacery)
    source_foil.SetLineWidth(2)

    it_label = TText(
        spacerx, spacery + gv_sizey + spacery + 13 * mw_sizey + spacery +
        0.25 * gv_sizey, "ITALY")
    fr_label = TText(
        0.5 + spacerx, spacery + gv_sizey + spacery + 13 * mw_sizey + spacery +
        0.25 * gv_sizey, "FRANCE")

    it_label.SetTextSize(0.036)
    fr_label.SetTextSize(0.036)

    #fiber map
    line_h_IT = TLine(0.25 - 10 * mw_sizex, 2 * spacery + 9 * mw_sizey,
                      0.25 + 10 * mw_sizex, 2 * spacery + 9 * mw_sizey)
    line_v_A1A2_IT = TLine(0.25, 2 * spacery + 9 * mw_sizey, 0.25,
                           2 * spacery + 14 * mw_sizey)
    line_v_A3A4_IT = TLine(0.25 - 4 * mw_sizex, 2 * 0.025 + mw_sizey,
                           0.25 - 4 * mw_sizex, 2 * spacery + 9 * mw_sizey)
    line_v_A4A5_IT = TLine(0.25 + 4 * mw_sizex, 2 * 0.025 + mw_sizey,
                           0.25 + 4 * mw_sizex, 2 * spacery + 9 * mw_sizey)

    line_h_FR = TLine(0.75 - 10 * mw_sizex, 2 * spacery + 9 * mw_sizey,
                      0.75 + 10 * mw_sizex, 2 * spacery + 9 * mw_sizey)
    line_v_A1A2_FR = TLine(0.75, 2 * 0.025 + 9 * mw_sizey, 0.75,
                           2 * spacery + 14 * mw_sizey)
    line_v_A3A4_FR = TLine(0.75 - 4 * mw_sizex, 2 * spacery + mw_sizey,
                           0.75 - 4 * mw_sizex, 2 * spacery + 9 * mw_sizey)
    line_v_A4A5_FR = TLine(0.75 + 4 * mw_sizex, 2 * spacery + mw_sizey,
                           0.75 + 4 * mw_sizex, 2 * spacery + 9 * mw_sizey)

    line_veto_top_IT = TLine(0.25, 3 * spacery + 14 * mw_sizey, 0.25,
                             3 * spacery + 15 * mw_sizey)
    line_veto_bottom_left_IT = TLine(0.25 - 4 * gv_sizex, spacery,
                                     0.25 - 4 * gv_sizex, spacery + mw_sizey)
    line_veto_bottom_right_IT = TLine(0.25 + 4 * gv_sizex, spacery,
                                      0.25 + 4 * gv_sizex, spacery + mw_sizey)
    line_veto_top_FR = TLine(0.75, 3 * spacery + 14 * mw_sizey, 0.75,
                             3 * spacery + 15 * mw_sizey)
    line_veto_bottom_left_FR = TLine(0.75 - 4 * gv_sizex, spacery,
                                     0.75 - 4 * gv_sizex, spacery + mw_sizey)
    line_veto_bottom_right_FR = TLine(0.75 + 4 * gv_sizex, spacery,
                                      0.75 + 4 * gv_sizex, spacery + mw_sizey)

    line_xw_left_IT = TLine(spacerx, 0.5 + 2 * xw_sizey,
                            spacerx + 2 * xw_sizex, 0.5 + 2 * xw_sizey)
    line_xw_right_IT = TLine(0.5 - spacerx - 2 * xw_sizex, 0.5 + 2 * xw_sizey,
                             0.5 - spacerx, 0.5 + 2 * xw_sizey)
    line_xw_left_FR = TLine(0.5 + spacerx, 0.5 + 2 * xw_sizey,
                            0.5 + spacerx + 2 * xw_sizex, 0.5 + 2 * xw_sizey)
    line_xw_right_FR = TLine(1 - spacerx - 2 * xw_sizex, 0.5 + 2 * xw_sizey,
                             1 - spacerx, 0.5 + 2 * xw_sizey)

    fiber_map_lines = np.array([line_h_IT, line_v_A1A2_IT, line_v_A3A4_IT, line_v_A4A5_IT, \
                                     line_h_FR, line_v_A1A2_FR, line_v_A3A4_FR, line_v_A4A5_FR, \
                                     line_veto_top_IT, line_veto_bottom_left_IT, line_veto_bottom_right_IT, \
                                     line_veto_top_FR, line_veto_bottom_left_FR, line_veto_bottom_right_FR, \
                                     line_xw_right_IT, line_xw_left_IT, \
                                     line_xw_right_FR, line_xw_left_FR])

    nRGBs = 6
    stops = np.array([0.00, 0.20, 0.40, 0.60, 0.80, 1.00])
    red = np.array([0.25, 0.00, 0.20, 1.00, 1.00, 0.90])
    green = np.array([0.25, 0.80, 1.00, 1.00, 0.80, 0.00])
    blue = np.array([1.00, 1.00, 0.20, 0.00, 0.00, 0.00])

    palette_index = TColor.CreateGradientColorTable(nRGBs, stops, red, green,
                                                    blue, 100)

    def setrange(self, xmin, xmax):
        self.range_min = xmin
        self.range_max = xmax
        return 0

    def draw(self, fiber_map=False):
        if (self.canvas == None):
            self.canvas = TCanvas(self.name, "SuperNEMO calorimeter", 1750,
                                  500)
            self.canvas.SetEditable(True)
            self.canvas.cd()

        for mw0 in range(2):
            for mw1 in range(20):
                for mw2 in range(13):
                    id = mw0 * 20 * 13 + mw1 * 13 + mw2

                    self.ombox[id].Draw("l")
                    self.omtext[id].Draw()

        for xw0 in range(2):
            for xw1 in range(2):
                for xw2 in range(2):
                    for xw3 in range(16):
                        id = 520 + xw0 * 2 * 2 * 16 + xw1 * 2 * 16 + xw2 * 16 + xw3
                        self.ombox[id].Draw("l")
                        self.omtext[id].Draw()

        for gv0 in range(2):
            for gv1 in range(2):
                for gv2 in range(16):
                    id = 520 + 128 + gv0 * 2 * 16 + gv1 * 16 + gv2
                    self.ombox[id].Draw("l")
                    self.omtext[id].Draw()

        self.source_foil.Draw()
        self.it_label.Draw()
        self.fr_label.Draw()

        if fiber_map == True:
            for line in self.fiber_map_lines:
                line.SetLineColor(kBlack)
                line.SetLineStyle(9)
                line.SetLineWidth(3)
                line.Draw()

        self.canvas.SetEditable(False)
        gSystem.ProcessEvents()
        return 0

    def reset(self):
        for calo in range(self.ncalo):
            self.content[calo] = 0
            # for calo=0; calo<self.ncalo; ++calo)
            self.ombox[calo].SetFillColor(0)

        self.canvas.Modified()
        self.canvas.Update()
        gSystem.ProcessEvents()

        return 0

    def setcontent(self, pmt, value):
        self.content[pmt] = value
        return 0

    def update(self):
        content_min = self.content[0]
        content_max = self.content[0]

        if (self.range_min == -1):
            for calo in range(1, self.ncalo):
                if (self.content[calo] < content_min):
                    content_min = self.content[calo]
                if (self.content[calo] > content_max):
                    content_max = self.content[calo]
        else:
            self.range_min = 0
            content_max = self.range_max

        for calo in range(self.ncalo):
            if (self.content[calo] != 0):
                self.ombox[calo].SetFillColor(self.palette_index + (
                    int)(99 * (self.content[calo] - content_min) /
                         (content_max - content_min)))
            else:
                self.ombox[calo].SetFillColor(0)

        self.canvas.Modified()
        self.canvas.Update()
        gSystem.ProcessEvents()
        return 0

    def save_canvas(self):
        self.canvas.SaveAs('sncalorimeter.png')
        return 0
Ejemplo n.º 19
0
def main():

    cc.cd()
    cc.SetBorderMode(0)
    cc.SetFixedAspectRatio(1)
    cc.FeedbackMode(1)

    gStyle.SetOptStat(0)
    gStyle.SetGridStyle(1)
    gStyle.SetGridColor(11)

    hh=TH2D('hh',';X;Y',22,-10.5,11.5,22,-10.5,11.5)
    hi=TH2I('hi',';X;Y',22,-10.5,11.5,22,-10.5,11.5)
    setupHists([hh,hi])
    xax,yax=hh.GetXaxis(),hh.GetYaxis()
    hh.Draw('COLZ')
    hi.Draw('TEXTSAME')

    gPad.SetLogz()
    gPad.SetGrid(1,1)
    gPad.SetLeftMargin(0.09)
    gPad.SetRightMargin(0.11)

    #tt2=TPaveText(0.7,0.96,0.9,0.99,'NDC')
    ttM=TPaveText(-3+0.05, 7-4.45, 4.0, 8-4.51)
    tt2=TPaveText(-3+0.05, 7-5.45, 4.0, 8-5.51)

    ttX=TPaveText(-2, 7-8.00, 3, 8-8.00)
    ttY=TPaveText(-2, 7-9.00, 3, 8-9.00)
    ttZ=TPaveText(-2, 6-8.80, 3, 8-9.30)
    ttZ.AddText("positive = beam top/right")

    ttime=TPaveText(-10,-12.5,10,-11.8)
    tchan=TPaveText(0,0,0.9,1)
    setupPaveTexts([tt2,ttM,ttime,tchan,ttX,ttY,ttZ])
    ttM.SetTextColor(2)
    ttM.SetFillStyle(0)
    ttZ.SetFillStyle(0)
    tt2.SetFillStyle(0)

    tarrow=TText(-0.9,0.7,'Beam Right')
    tarrow.SetTextSizePixels(15)
    arrow=TArrow(-1.4,0.5,2.4,0.5,0.02,'|>')
    arrow.SetAngle(40)
    arrow.SetFillColor(1)
    arrow.SetLineWidth(2)

    tt=TText()
    tt.SetTextColor(1)
    tt.SetTextAngle(90)
    tt.SetTextSize(0.04)
    tt.DrawText(12.4,0,'kHz')
    tt.SetTextAngle(0)
    tt.SetTextColor(1)
    tt.DrawTextNDC(0.3,0.92,'FTC FADC SCALERS')

    bb=TBox()
    bb.SetFillStyle(1001)
    bb.SetFillColor(0)
    bb.SetLineWidth(1)
    bb.SetLineColor(1)
    bb.DrawBox(-3.47,-1.47,4.47,2.46)
    bb.DrawBox(-1.47,-3.47,2.49,4.47)
    bb.DrawBox(-2.47,-2.47,3.49,3.47)

    cc.cd()
    for xx in [ttM,tt2,ttime,arrow,tarrow,ttX,ttY,ttZ]: xx.Draw()
    cc2.cd()
    tchan.Draw('NDC')
    cc.cd()

    gPad.SetEditable(0)

    while True:

            for ch in ECAL.chans:
              loadPV(ch)
              ch=ch.vals
              xx,yy=ch['X'],ch['Y']
              #if (ch['PVVAL']>10):
               # print xx,yy,ch['PVVAL']

              # swap x to make it downstream view:
              xx=-xx

              #after, fix the fact x=0 / y=0 don't exists
              if xx<0: xx+=1
              if yy<0: yy+=1
              hh.SetBinContent(xax.FindBin(xx),yax.FindBin(yy),ch['PVVAL'])
              hi.SetBinContent(xax.FindBin(xx),yax.FindBin(yy),ch['PVVAL'])

            for xx in [ttime,tt2,ttM,ttX,ttY]: xx.Clear()
            [total,maximum,top,bottom,left,right]=calcRates(ECAL.chans)

            tt2.AddText('Total:  %.1f MHz'%(total/1000))
            ttM.AddText('Max:  %.0f kHz'%(maximum))

            if total>1e2:
              xasy = (right-left)/total
              yasy = (top-bottom)/total
              ttX.AddText('X-Asy:  %+.1f%%'%(100*xasy))
              ttY.AddText('Y-Asy:  %+.1f%%'%(100*yasy))
            else:
              ttX.AddText('X-Asy:  N/A')
              ttY.AddText('Y-Asy:  N/A')

            ttime.AddText(makeTime())

            if not gPad: sys.exit()

            if gPad.GetEvent()==11:
                xy=pix2xy(gPad)
                ee=ECAL.findChannelXY(xy[0],xy[1])
                if ee:
                    tchan.Clear()
                    tchan.AddText(printChannel(ee))
                    cc2.Modified()
                    cc2.Update()
            elif gPad.GetEvent()==12:
                tchan.Clear()
                cc2.Modified()
                cc2.Update()


            cc.Modified()
            cc.Update()

            time.sleep(2)
Ejemplo n.º 20
0
def plot_rocs(plotObjects, kwargs):

    from ROOT import kCyan, kRed, kGreen, kBlue, kBlack, kMagenta, kGray, kWhite, kYellow
    Colors = [kBlue, kRed, kMagenta, kBlack, kCyan, kGreen]
    from RingerCore import StdPair as std_pair
    from util import line, minmax

    dset = kwargs['set']
    ref = kwargs['reference']
    refVal = kwargs['refVal']
    eps = kwargs['eps']
    savename = kwargs['cname'] + '.pdf'

    #Some protection
    if not ('operation' in dset or 'tst' in dset):
        raise ValueError('Option set must be: tst (test) or val (validation)')
    if not ('SP' in ref or 'Pd' in ref or 'Pf' in ref):
        raise ValueError('Option reference must be: SP, Pd or Pf')

    #Create dict to hold all list plots
    curves = dict()
    #list of dicts to dict of lists
    for name in plotObjects.keys():
        curves[name] = plotObjects.tolist(name)

    paintIdx = kwargs['paintListIdx']  # [best, worst]
    paintCurves = [
        std_pair(plotObjects.index_correction(paintIdx[0]), kBlack),
        std_pair(plotObjects.index_correction(paintIdx[1]), kRed)
    ]
    curves['roc'] = curves['roc_' + dset]

    #Start to build all ROOT objects
    from ROOT import TCanvas, gROOT, kTRUE
    gROOT.SetBatch(kTRUE)
    canvas = TCanvas('canvas', 'canvas', 1600, 1300)

    x_limits = [0.00, 0.40]
    y_limits = [0.6, 1.03]

    #create dummy graph
    dummy = curves['roc'][0]
    dummy.SetTitle('Receive Operation Curve')
    dummy.GetXaxis().SetTitle('False Alarm')
    dummy.GetYaxis().SetTitle('Detection')
    dummy.GetHistogram().SetAxisRange(y_limits[0], y_limits[1], 'Y')
    dummy.GetHistogram().SetAxisRange(x_limits[0], x_limits[1], 'X')
    dummy.Draw('AL')

    corredor = None
    target = None
    from ROOT import TBox
    if ref == 'Pf':
        corredor = TBox(refVal - eps, y_limits[0], refVal + eps, y_limits[1])
        target = line(refVal, y_limits[0], refVal, y_limits[1], kBlack, 2, 1,
                      '')
    elif ref == 'Pd':
        corredor = TBox(x_limits[0], refVal - eps, x_limits[1], refVal + eps)
        target = line(x_limits[0], refVal, x_limits[1], refVal, kBlack, 2, 1,
                      '')

    if ref != 'SP':
        corredor.SetFillColor(kYellow - 9)
        corredor.Draw('same')
        target.Draw('same')
        canvas.Modified()
        canvas.Update()

    #Plot curves
    for c in curves['roc']:
        c.SetLineColor(kGray + 1)
        #c.SetMarkerStyle(7)
        #c.SetMarkerColor(kBlue)
        c.SetLineWidth(1)
        c.SetLineStyle(3)
        #c.Draw('PLsame')
        c.Draw('same')

    marker = list()
    #Paint a specifical curve
    for pair in paintCurves:
        curves['roc'][pair.first].SetLineWidth(1)
        curves['roc'][pair.first].SetLineStyle(1)
        #curves['roc'][pair.first].SetMarkerStyle(7)
        #curves['roc'][pair.first].SetMarkerColor(kBlue)
        curves['roc'][pair.first].SetLineColor(pair.second)
        #curves['roc'][pair.first].Draw('PLsame')
        curves['roc'][pair.first].Draw('same')

        if ref == 'SP':
            faVec = curves['roc'][pair.first].GetX()
            detVec = curves['roc'][pair.first].GetY()
            from RingerCore import calcSP
            spVec = [
                calcSP(detVec[i], 1 - faVec[i])
                for i in range(curves['roc'][pair.first].GetN())
            ]
            imax = spVec.index(max(spVec))
            from ROOT import TMarker
            marker.append(TMarker(faVec[imax], detVec[imax], 4))
            marker[-1].SetMarkerColor(pair.second)
            marker[-1].Draw('same')

    #Update Canvas
    canvas.Modified()
    canvas.Update()
    canvas.SaveAs(savename)
    del canvas

    return savename
                var.setVal(nll_profscan.GetBinCenter(binIdx))
                var.setConstant(True)
                model.fitTo(dataset)
                nll_profscan.SetBinContent(binIdx,(nll.getVal()-fitres.minNll())*2.)

                mesg='nll: {0}, minNLL= {1}'.format(nll.getVal(),fitres.minNll())
                recTime(mesg)
                var.setConstant(False)

            nll_scan.SetStats(False)
            nll_scan.SetLineWidth(2)
            nll_scan.GetXaxis().SetTitle(varInfo['var'])
            nll_profscan.Draw('axis')
            canv.Update()

            box=TBox()
            box.SetFillColor(7)
            bestVal=fitres.floatParsFinal().find(varInfo['var'])
            box.DrawBox(
                    bestVal.getVal()+bestVal.getErrorLo(),canv.GetUymin(),
                    bestVal.getVal()+bestVal.getErrorHi(),canv.GetUymax()
                    )
            nll_scan.Draw('csame')

            nll_profscan.SetLineWidth(2)
            nll_profscan.SetLineColor(2)
            nll_profscan.Draw('csame')
            outFile.cd()
            nll_scan.Write()
            nll_profscan.Write()
Ejemplo n.º 22
0
def main():

    if True:
        mf=TGMainFrame(gClient.GetRoot(),1500,475)
        gvf=TGVerticalFrame(mf,1500,475)
        rec=TRootEmbeddedCanvas("ccc",gvf,1500,450)
        rec2=TRootEmbeddedCanvas("ccc2",gvf,1500,25)
        gvf.AddFrame(rec,TGLayoutHints(ROOT.kLHintsExpandX|ROOT.kLHintsTop))
        gvf.AddFrame(rec2,TGLayoutHints(ROOT.kLHintsExpandX|ROOT.kLHintsBottom))
        mf.AddFrame(gvf,TGLayoutHints(ROOT.kLHintsExpandX))
        cc=rec.GetCanvas()
        cc2=rec2.GetCanvas()
        mf.SetEditable(0)
        mf.SetWindowName('HPS ECAL FADC SCALERS')
        mf.MapSubwindows()
        mf.Resize(1501,476)# resize to get proper frame placement
        mf.MapWindow()
    else:
        cc=TCanvas('cc','',1500,450)
   
    cc.cd()
    cc.SetBorderMode(0)
    cc.SetFixedAspectRatio(1)
    cc.FeedbackMode(1)
    
    gStyle.SetOptStat(0)
    gStyle.SetGridStyle(1)
    gStyle.SetGridColor(11)

    hh=TH2D('hh',';X;Y',46,-22,24,11,-5,6)
    hi=TH2I('hi',';X;Y',46,-22,24,11,-5,6)
    setupHists([hh,hi])
    xax,yax=hh.GetXaxis(),hh.GetYaxis()
    hh.Draw('COLZ')
    hi.Draw('TEXTSAME')
    
    gPad.SetLogz()
    gPad.SetGrid(1,1)
    gPad.SetLeftMargin(0.05)
    
    tt1=TPaveText(0.1,0.9,0.3,1.0,'NDC')
    tt2=TPaveText(0.7,0.91,0.9,0.99,'NDC')
    ttT=TPaveText(-22+13+0.05,6-5,-22+22,7-5-0.05)
    ttB=TPaveText(-22+13+0.05,4-5+0.05,-22+22,5-5)
    ttM=TPaveText(-22+0+0.05,5-5+0.05,-22+13,6-5.01)
    ttime=TPaveText(-10,-6.5,10,-5.8)
    tchan=TPaveText(0,0,0.9,1)
    setupPaveTexts([tt1,tt2,ttT,ttB,ttM,ttime,tchan])
    ttM.SetTextColor(2)
    
    bb=TBox()
    bb.SetFillStyle(1001)
    bb.SetFillColor(0)
    bb.SetLineWidth(1)
    bb.SetLineColor(1)
    bb.DrawBox(-9+0.05,-1,0,1.97)
    bb.DrawBox(-24,0,24.05,0.97)
    
    tarrow=TText(14.5,0.3,'Beam Left')
    arrow=TArrow(19,0.5,23,0.5,0.02,'|>')
    arrow.SetAngle(40)
    arrow.SetFillColor(1)
    arrow.SetLineWidth(2)
    
    tt=TText()
    tt.SetTextColor(1)
    tt.SetTextAngle(90)
    tt.SetTextSize(0.08)
    tt.DrawText(25.4,0,'kHz')
    tt.SetTextAngle(0)
    tt.SetTextColor(2)
    tt.DrawTextNDC(0.3,0.92,'ECAL FADC SCALERS')
   
    cc.cd()
    for xx in [tt2,ttT,ttB,ttM,arrow,tarrow,ttime]: xx.Draw()
    cc2.cd()
    tchan.Draw('NDC')
    cc.cd()
    
    ll=TLine()
    ll.DrawLine(xax.GetXmin(),yax.GetXmin(),xax.GetXmax(),yax.GetXmin())
    ll.DrawLine(xax.GetXmin(),yax.GetXmax(),xax.GetXmax(),yax.GetXmax())
    ll.DrawLine(xax.GetXmin(),yax.GetXmin(),xax.GetXmin(),0)
    ll.DrawLine(xax.GetXmax(),yax.GetXmin(),xax.GetXmax(),0)
    ll.DrawLine(xax.GetXmin(),yax.GetXmax(),xax.GetXmin(),1)
    ll.DrawLine(xax.GetXmax(),yax.GetXmax(),xax.GetXmax(),1)
    ll.DrawLine(xax.GetXmax(),0,0,0)
    ll.DrawLine(xax.GetXmax(),1,0,1)
    ll.DrawLine(xax.GetXmin(),0,-9,0)
    ll.DrawLine(xax.GetXmin(),1,-9,1)
    ll.DrawLine(-9,-1,0,-1)
    ll.DrawLine(-9,2,0,2)
    ll.DrawLine(-9,1,-9,2)
    ll.DrawLine(-9,-1,-9,0)
    ll.DrawLine(0,-1,0,0)
    ll.DrawLine(0,1,0,2)
   
    gPad.SetEditable(0)

    while True:

#        try:

            zvals=getPVS()
            for ii in range(len(zvals)):
                hh.SetBinContent(xax.FindBin(XVALS[ii]),yax.FindBin(YVALS[ii]),zvals[ii])
                hi.SetBinContent(xax.FindBin(XVALS[ii]),yax.FindBin(YVALS[ii]),zvals[ii])
            
            for xx in [ttime,tt2,ttT,ttB,ttM]: xx.Clear()
            [top,bottom,maximum]=calcRates(zvals)
            tt2.AddText('Total:  %.1f MHz'%((top+bottom)/1000))
            ttT.AddText('%.1f MHz'%(top/1000))
            ttB.AddText('%.1f MHz'%(bottom/1000))
            ttM.AddText('MAX SINGLE CRYSTAL = %.0f kHz'%(maximum))
            ttime.AddText(makeTime())
          
            if gPad.GetEvent()==11:
                xy=pix2xy(gPad)
                ee=ECAL.findChannelXY(xy[0],xy[1])
                if ee:
                    tchan.Clear()
                    tchan.AddText(printChannel(ee))
                    cc2.Modified()
                    cc2.Update()
            elif gPad.GetEvent()==12:
                tchan.Clear()
                cc2.Modified()
                cc2.Update()
    
    
            cc.Modified()
            cc.Update()
        
            time.sleep(1)
Ejemplo n.º 23
0
    def draw(plot,
             do_ratio=True,
             channel='#mu#tau_{h}',
             plot_dir='plots',
             plot_name=None,
             SetLogy=0,
             blindxmin=None,
             blindxmax=None,
             unit=None):
        print plot
        Stack.STAT_ERRORS = True

        can = pad = padr = None

        if do_ratio:
            can, pad, padr = HistDrawer.buildCanvas()
        else:
            can = HistDrawer.buildCanvasSingle()

        pad.cd()
        pad.SetLogy(SetLogy)
        # print "about to DrawStack"
        # plot.DrawNormalized()
        # plot.DrawNormalizedRatioStack('HIST', ymin=0.1)
        # , dataAsPoisson=True
        plot.DrawStack(
            'HIST',
            print_norm=plot.name == '_norm_',
            ymin=0.1,
            scale_signal='')  # magic word to print integrals in legend

        h = plot.supportHist
        h.GetXaxis().SetLabelColor(1)
        # h.GetXaxis().SetLabelSize(1)

        unitsperbin = h.GetXaxis().GetBinWidth(1)
        ytitle = 'Events'
        if unit:
            round_to_n = lambda x, n: round(
                x, -int(floor(log10(abs(x)))) + (n - 1))
            ytitle += round_to_n(unitsperbin, 3)

        h.GetYaxis().SetTitle('Events')
        # if axis labels and title overlap, change offset here
        h.GetYaxis().SetTitleOffset(1.3)
        h.GetXaxis().SetTitleOffset(2.0)

        if do_ratio:
            padr.cd()
            ratio = copy.deepcopy(plot)
            ratio.legendOn = False

        if blindxmin or blindxmax:
            if not blindxmin:
                blindxmin = 0
            if not blindxmax:
                blindxmax = plot.GetXaxis().GetXmax()
            if do_ratio:
                ratio.Blind(blindxmin, blindxmax, True)
            plot.Blind(blindxmin, blindxmax, False)

        if do_ratio:
            ratio.DrawDataOverMCMinus1(-0.5, 0.5)
            hr = ratio.dataOverMCHist

            # Gymnastics to get same label sizes etc in ratio and main plot
            ytp_ratio = 2.
            xtp_ratio = 2.

            # hr.GetYaxis().SetNdivisions(4)

            hr.GetYaxis().SetTitleSize(h.GetYaxis().GetTitleSize() * xtp_ratio)
            hr.GetXaxis().SetTitleSize(h.GetXaxis().GetTitleSize() * ytp_ratio)

            hr.GetYaxis().SetTitleOffset(h.GetYaxis().GetTitleOffset() /
                                         xtp_ratio)
            hr.GetXaxis().SetTitleOffset(h.GetXaxis().GetTitleOffset() /
                                         ytp_ratio)

            hr.GetYaxis().SetLabelSize(h.GetYaxis().GetLabelSize() * xtp_ratio)
            hr.GetXaxis().SetLabelSize(h.GetXaxis().GetLabelSize() * ytp_ratio)

            h.GetXaxis().SetLabelColor(0)
            h.GetXaxis().SetLabelSize(0)
            padr.Update()

        # blinding
        if blindxmin or blindxmax:
            pad.cd()
            max = plot.stack.totalHist.GetMaximum()
            box = TBox(blindxmin, 0, blindxmax, max)
            box.SetFillColor(1)
            box.SetFillStyle(3004)
            box.Draw()
            HistDrawer.keeper.append(box)

        HistDrawer.CMSPrelim(plot, pad, channel, legend=plot.legendPos)
        can.cd()

        plotname = plot_dir + '/'
        ensureDir(plot_dir)
        plotname += plot_name if plot_name else plot.name
        can.SaveAs(plotname + '.png')
        can.SaveAs(plotname + '.pdf')

        # Also save with log y
        if plot.legendPos == 'right':
            h.GetYaxis().SetRangeUser(0.1001, pad.GetUymax() * 5.)
        else:
            # minimum is set to 2 orders of magnitude lower than maximum
            minRange = pow(10, floor(log10(pad.GetUymax() / 100.)))
            h.GetYaxis().SetRangeUser(minRange + minRange * 1e-4,
                                      pad.GetUymax() * 5.e3)
        pad.SetLogy(True)
        can.SaveAs(plotname + '_log.png')
        can.SaveAs(plotname + '_log.pdf')
        pad.SetLogy(0)
        return ratio
Ejemplo n.º 24
0
def pullsVertical(fileName):

    content = filterPullFile(fileName)
    nbins, off = len(content), 0.10

    b_pulls = TH1F("b_pulls", ";;Pulls", nbins, 0. - off, nbins - off)
    s_pulls = TH1F("s_pulls", ";;Pulls", nbins, 0. + off, nbins + off)  #

    for i, s in enumerate(content):
        l = s.split()
        b_pulls.GetXaxis().SetBinLabel(i + 1, l[0])
        s_pulls.GetXaxis().SetBinLabel(i + 1, l[0])
        b_pulls.SetBinContent(i + 1, float(l[1]))
        b_pulls.SetBinError(i + 1, float(l[2]))
        s_pulls.SetBinContent(i + 1, float(l[3]))
        s_pulls.SetBinError(i + 1, float(l[4]))

    b_pulls.SetFillStyle(3005)
    b_pulls.SetFillColor(923)
    b_pulls.SetLineColor(923)
    b_pulls.SetLineWidth(1)
    b_pulls.SetMarkerStyle(20)
    b_pulls.SetMarkerSize(1.25)

    s_pulls.SetLineColor(602)
    s_pulls.SetMarkerColor(602)
    s_pulls.SetMarkerStyle(24)  #24
    s_pulls.SetLineWidth(1)

    b_pulls.GetYaxis().SetRangeUser(-2.5, 2.5)

    # Graphs
    h_pulls = TH2F("pulls", "", 6, -3., 3., nbins, 0, nbins)
    B_pulls = TGraphAsymmErrors(nbins)
    S_pulls = TGraphAsymmErrors(nbins)

    boxes = []

    canvas = TCanvas("canvas", "Pulls", 600, 150 + nbins * 10)  #nbins*20)
    canvas.cd()
    canvas.SetGrid(0, 1)
    canvas.GetPad(0).SetTopMargin(0.01)
    canvas.GetPad(0).SetRightMargin(0.01)
    canvas.GetPad(0).SetBottomMargin(0.05)
    canvas.GetPad(0).SetLeftMargin(0.25)  #(0.25)#(0.065)
    canvas.GetPad(0).SetTicks(1, 1)

    for i, s in enumerate(content):
        l = s.split()
        if "1034h" in l[0]: l[0] = "CMS_PDF_13TeV"
        h_pulls.GetYaxis().SetBinLabel(i + 1, l[0].replace('CMS2016_', ''))  #C
        #y1 = gStyle.GetPadBottomMargin()
        #y2 = 1. - gStyle.GetPadTopMargin()
        #h = (y2 - y1) / float(nbins)
        #y1 = y1 + float(i) * h
        #y2 = y1 + h
        #box = TPaveText(0, y1, 1, y2, 'NDC')
        #box.SetFillColor(0)
        #box.SetTextSize(0.02)
        #box.SetBorderSize(0)
        #box.SetTextAlign(12)
        #box.SetMargin(0.005)
        #if i % 2 == 0:
        #    box.SetFillColor(18)
        #box.Draw()
        #boxes.append(box)
        B_pulls.SetPoint(i + 1, float(l[1]), float(i + 1) - 0.3)  #C
        B_pulls.SetPointError(i + 1, float(l[2]), float(l[2]), 0., 0.)  #C

    for i, s in enumerate(content):
        l = s.split()
        S_pulls.SetPoint(i + 1, float(l[3]), float(i + 1) - 0.7)  #C
        S_pulls.SetPointError(i + 1, float(l[4]), float(l[4]), 0., 0.)  #C

    h_pulls.GetXaxis().SetTitle("(#hat{#theta} - #theta_{0}) / #Delta#theta")
    h_pulls.GetXaxis().SetLabelOffset(-0.01)
    h_pulls.GetXaxis().SetTitleOffset(.6)
    h_pulls.GetYaxis().SetNdivisions(nbins, 0, 0)

    B_pulls.SetFillColor(1)
    B_pulls.SetLineColor(1)
    B_pulls.SetLineStyle(1)
    B_pulls.SetLineWidth(2)
    B_pulls.SetMarkerColor(1)
    B_pulls.SetMarkerStyle(20)
    B_pulls.SetMarkerSize(1)  #(0.75)

    S_pulls.SetFillColor(629)
    S_pulls.SetLineColor(629)
    S_pulls.SetMarkerColor(629)
    S_pulls.SetLineWidth(2)
    S_pulls.SetMarkerStyle(20)
    S_pulls.SetMarkerSize(1)

    box1 = TBox(-1., 0., 1., nbins)
    box1.SetFillStyle(3001)
    #box1.SetFillStyle(0)
    box1.SetFillColor(417)
    box1.SetLineWidth(2)
    box1.SetLineStyle(2)
    box1.SetLineColor(417)

    box2 = TBox(-2., 0., 2., nbins)
    box2.SetFillStyle(3001)
    #box2.SetFillStyle(0)
    box2.SetFillColor(800)
    box2.SetLineWidth(2)
    box2.SetLineStyle(2)
    box2.SetLineColor(800)

    leg = TLegend(0.1, -0.05, 0.7, 0.08)
    leg.SetBorderSize(0)
    leg.SetFillStyle(0)
    leg.SetFillColor(0)
    leg.SetNColumns(2)
    leg.AddEntry(B_pulls, "B-only fit", "lp")
    leg.AddEntry(S_pulls, "S+B fit", "lp")
    if text: leg.AddEntry(0, text, "")

    h_pulls.Draw("")
    box2.Draw()
    box1.Draw()
    B_pulls.Draw("P6SAME")
    S_pulls.Draw("P6SAME")
    leg.Draw()

    #    drawCMS(35867, "Preliminary")
    #    drawAnalysis("VH")
    #    drawRegion(outName)

    canvas.Print(outName + ".png")
    canvas.Print(outName + ".pdf")

    if not gROOT.IsBatch(): raw_input("Press Enter to continue...")
Ejemplo n.º 25
0
    def draw(plot,
             do_ratio=True,
             channel='e#mu#mu',
             plot_dir='/plots/',
             plot_name=None,
             SetLogy=0,
             blindxmin=None,
             blindxmax=None,
             unit=None):
        print plot
        Stack.STAT_ERRORS = True

        can = pad = padr = None

        if do_ratio:
            can, pad, padr = HistDrawer.buildCanvas()
        else:
            can = HistDrawer.buildCanvasSingle()

        pad.cd()
        pad.SetLogy(SetLogy)

        plot.DrawStack('HIST', print_norm=plot.name == '_norm_',
                       ymin=0.1)  # magic word to print integrals in legend

        h = plot.supportHist
        h.GetXaxis().SetLabelColor(1)
        # h.GetXaxis().SetLabelSize(1)

        unitsperbin = h.GetXaxis().GetBinWidth(1)
        ytitle = 'Events'
        if unit:
            round_to_n = lambda x, n: round(
                x, -int(floor(log10(abs(x)))) + (n - 1))
            ytitle += round_to_n(unitsperbin, 3)

        h.GetYaxis().SetTitle('Events')
        h.GetYaxis().SetTitleOffset(1.0)
        h.GetXaxis().SetTitleOffset(2.0)

        if do_ratio:
            padr.cd()
            ratio = copy.deepcopy(plot)
            ratio.legendOn = False

        if blindxmin or blindxmax:
            if not blindxmin:
                blindxmin = 0
            if not blindxmax:
                blindxmax = plot.stack.totalHist.GetXaxis().GetXmax()
            if do_ratio:
                ratio.Blind(blindxmin, blindxmax, True)
            plot.Blind(blindxmin, blindxmax, False)

        if do_ratio:
            ratio.DrawDataOverMCMinus1(-0.5, 0.5)
            hr = ratio.dataOverMCHist

            # Gymnastics to get same label sizes etc in ratio and main plot
            ytp_ratio = 2.
            xtp_ratio = 2.

            # hr.GetYaxis().SetNdivisions(4)

            hr.GetYaxis().SetTitleSize(h.GetYaxis().GetTitleSize() * xtp_ratio)
            hr.GetXaxis().SetTitleSize(h.GetXaxis().GetTitleSize() * ytp_ratio)

            hr.GetYaxis().SetTitleOffset(h.GetYaxis().GetTitleOffset() /
                                         xtp_ratio)
            hr.GetXaxis().SetTitleOffset(h.GetXaxis().GetTitleOffset() /
                                         ytp_ratio)

            hr.GetYaxis().SetLabelSize(h.GetYaxis().GetLabelSize() * xtp_ratio)
            hr.GetXaxis().SetLabelSize(h.GetXaxis().GetLabelSize() * ytp_ratio)

            h.GetXaxis().SetLabelColor(0)
            h.GetXaxis().SetLabelSize(0)
            padr.Update()

        # blinding
        if blindxmin or blindxmax:
            pad.cd()
            max = plot.stack.totalHist.GetMaximum()
            box = TBox(blindxmin, 0, blindxmax, max)
            box.SetFillColor(1)
            box.SetFillStyle(3004)
            box.Draw()
            HistDrawer.keeper.append(box)

        HistDrawer.CMSPrelim(plot, pad, channel, legend=plot.legendPos)
        can.cd()

        plotname = plot_dir + '/'
        ensureDir(plot_dir)
        plotname += plot_name if plot_name else plot.name
        can.SaveAs(plotname + '.png')
        can.SaveAs(plotname + '.pdf')
        can.SaveAs(plotname + '.root')

        # Also save with log y
        h.GetYaxis().SetRangeUser(pad.GetUymax() * 5. / 1000000.,
                                  pad.GetUymax() * 5.)
        pad.SetLogy(True)
        can.SaveAs(plotname + '_log.png')
        can.SaveAs(plotname + '_log.pdf')
        pad.SetLogy(0)
Ejemplo n.º 26
0
c = {}
box = {}
line = {}
line2 = {}
arrow = {}
for iHisto in histoKeys:
    c[iHisto] = TCanvas(histoLegend[iHisto])
    if "logy" in canvasOption:
        c[iHisto].SetLogy(1)
    # draw line, arrows, box to highlight the suspicious region considered
    if (histoType == "2d_etaPhiHotSpot"):
        gStyle.SetPalette(1)
        gStyle.SetOptStat("")
        histo[iHisto].Draw("COLZ")
        if not b_wholeHisto:
            box[iHisto] = TBox(etaSpot - deltaSpot, phiSpot - deltaSpot,
                               etaSpot + deltaSpot, phiSpot + deltaSpot)
            box[iHisto].SetLineColor(kRed + 1)
            box[iHisto].SetLineWidth(3)
            box[iHisto].SetFillStyle(0)
            box[iHisto].Draw()
    elif (histoType == "2d_xyHotSpot"):
        gStyle.SetPalette(1)
        gStyle.SetOptStat("")
        histo[iHisto].Draw("COLZ")
        if not b_wholeHisto:
            box[iHisto] = TBox(xSpot - deltaSpot, ySpot - deltaSpot,
                               xSpot + deltaSpot, ySpot + deltaSpot)
            box[iHisto].SetLineColor(kRed + 1)
            box[iHisto].SetLineWidth(3)
            box[iHisto].SetFillStyle(0)
            box[iHisto].Draw()
Ejemplo n.º 27
0
def drawColorTable(clist=range(0, 50),
                   nrow=None,
                   ncol=None,
                   cmax=10,
                   tag="",
                   label=False,
                   RBG=False,
                   newRBG=True,
                   div=2):
    # https://root.cern.ch/doc/master/src_2TPad_8cxx_source.html#l01611

    if not ncol:
        ncol = min(cmax, len(clist))
    if not nrow:
        nrow = 1 if len(clist) <= cmax else int(ceil(len(clist) / float(cmax)))
    x1 = y1 = 0.
    x2 = y2 = 20.
    hs = (y2 - y1) / nrow
    ws = (x2 - x1) / ncol
    if label or RBG:
        width = 170 * ncol
        height = 80 * nrow
    else:
        width = 110 * ncol
        height = 80 * nrow
    scale = 400. / height
    if 400. < height: scale = sqrt(scale)
    canvas = TCanvas("c", "Fill Area colors", 0, 0, width, height)
    canvas.SetFillColor(0)
    canvas.Clear()
    canvas.Range(x1, y1, x2, y2)

    text = TText(0, 0, "")
    text.SetTextFont(61)
    text.SetTextSize(0.07 * scale)
    text.SetTextAlign(22)
    box = TBox()

    for r in range(0, nrow):
        ylow = y2 - hs * (r + 0.1)
        yup = y2 - hs * (r + 0.9)
        for c in range(0, ncol):
            i = ncol * r + c
            if i >= len(clist): break
            xlow = x1 + ws * (c + 0.1)
            xup = x1 + ws * (c + 0.9)
            color = clist[ncol * r + c]
            box.SetFillStyle(1001)
            box.SetFillColor(color)
            box.DrawBox(xlow, ylow, xup, yup)
            box.SetFillStyle(0)
            box.SetLineColor(1)
            box.DrawBox(xlow, ylow, xup, yup)
            if color == 1: text.SetTextColor(0)
            else: text.SetTextColor(1)
            name = "%d" % color
            if (isinstance(label, int) and i % div == label) or label:
                name = getColorString(color)
            if (not isinstance(RBG, bool) and isinstance(RBG, int)
                    and i % div == RBG) or (RBG
                                            and not isinstance(label, int)):
                name = getRGBString(color)
            elif newRBG and color >= 924:
                name = getRGBString(color)
            text.DrawText(0.5 * (xlow + xup), 0.5 * (ylow + yup), name)
        if i >= len(clist): break

    canvas.SaveAs("TColorTable%s.png" % tag)
    canvas.SaveAs("TColorTable%s.pdf" % tag)
cp1 = TCanvas("cp1", vName1 + ' pull')
pull1.Draw('ap')
pull1.SetName(vName1 + "_pull")
cp1.SetGridy()
cp1.Update()
pull1.GetXaxis().SetLimits(pars.varRanges[pars.var[0]][1],
                           pars.varRanges[pars.var[0]][2])
pull1.GetXaxis().SetTitle(fitter.ws.var(vName1).getTitle(True).Data())
pull1.GetYaxis().SetTitle("pull (#sigma)")

blinder = plot1.findObject('TBox')
blinder2 = None
if blinder:
    blinder2 = TBox(pars.exclude[pars.var[0]][0],
                    pull1.GetYaxis().GetXmin(), pars.exclude[pars.var[0]][1],
                    pull1.GetYaxis().GetXmax())
    blinder2.SetFillColor(kBlack)
    blinder2.SetFillStyle(1001)

if blinder2:
    #blinder2.Print()
    blinder2.Draw()

cp1.Update()

if opts.toyOut:
    outFile = open(opts.toyOut, 'a', 1)
    fitter.ws.loadSnapshot("genPars")

    line = '%s %.6g %.6g %.6g '
Ejemplo n.º 29
0
def pullsVertical_noBonly(fileName):

    content = filterPullFile(fileName)
    nbins, off = len(content), 0.10

    # Graphs
    h_pulls = TH2F("pulls", "", 6, -3., 3., nbins, 0, nbins)
    S_pulls = TGraphAsymmErrors(nbins)

    boxes = []

    canvas = TCanvas("canvas", "Pulls", 720, 300 + nbins * 18)  #nbins*20)
    canvas.cd()
    canvas.SetGrid(0, 1)
    canvas.SetTopMargin(0.01)
    canvas.SetRightMargin(0.01)
    canvas.SetBottomMargin(0.10)
    canvas.SetLeftMargin(0.40)
    canvas.SetTicks(1, 1)

    for i, s in enumerate(content):
        l = s.split()
        h_pulls.GetYaxis().SetBinLabel(i + 1, l[0])
        S_pulls.SetPoint(i, float(l[3]), float(i + 1) - 0.5)
        S_pulls.SetPointError(i, float(l[4]), float(l[4]), 0., 0.)

    h_pulls.GetXaxis().SetTitle("(#hat{#theta} - #theta_{0}) / #Delta#theta")
    h_pulls.GetXaxis().SetLabelOffset(0.0)
    h_pulls.GetXaxis().SetTitleOffset(0.8)
    h_pulls.GetXaxis().SetLabelSize(0.045)
    h_pulls.GetXaxis().SetTitleSize(0.050)
    h_pulls.GetYaxis().SetLabelSize(0.046)
    h_pulls.GetYaxis().SetNdivisions(nbins, 0, 0)

    S_pulls.SetFillColor(kBlack)
    S_pulls.SetLineColor(kBlack)
    S_pulls.SetMarkerColor(kBlack)
    S_pulls.SetLineWidth(2)
    S_pulls.SetMarkerStyle(20)
    S_pulls.SetMarkerSize(1)

    box1 = TBox(-1., 0., 1., nbins)
    #box1.SetFillStyle(3001) # 3001 checkered
    #box1.SetFillStyle(0)
    box1.SetFillColor(kGreen + 1)  # 417
    box1.SetLineWidth(2)
    box1.SetLineStyle(2)
    box1.SetLineColor(kGreen + 1)  # 417

    box2 = TBox(-2., 0., 2., nbins)
    #box2.SetFillStyle(3001) # 3001 checkered
    #box2.SetFillStyle(0)
    box2.SetFillColor(kOrange)  # 800
    box2.SetLineWidth(2)
    box2.SetLineStyle(2)
    box2.SetLineColor(kOrange)  # 800

    leg = TLegend(0.01, 0.01, 0.3, 0.15)
    leg.SetTextSize(0.05)
    leg.SetBorderSize(0)
    leg.SetFillStyle(0)
    leg.SetFillColor(0)
    #leg.SetNColumns(2)
    leg.AddEntry(S_pulls, "S+B fit", "lp")
    if text: leg.AddEntry(0, text, "")

    h_pulls.Draw("")
    box2.Draw()
    box1.Draw()
    S_pulls.Draw("P6SAME")
    leg.Draw()
    canvas.RedrawAxis()

    canvas.Print(outName + ".png")
    canvas.Print(outName + ".pdf")

    if not gROOT.IsBatch(): raw_input("Press Enter to continue...")
Ejemplo n.º 30
0
c_res_l.SaveAs(output + "/l_" + algo + "_res.pdf")

c_xy = TCanvas("c_xy")

h_xy.Draw()

h_xy_mc.Draw("same")
h_xy_corr.Draw("same")
h_xy_corr.SetMarkerColor(kBlue + 1)
h_xy_mc.SetMarkerColor(kRed + 1)
h_xy.GetYaxis().SetTitleOffset(1.37)
c_xy.Update()

c_spacecharge.cd()

tpc_xy = TBox(x_start, y_start, x_end, y_end)
tpc_xy.SetLineWidth(3)
tpc_xy.SetLineStyle(2)
tpc_xy.SetFillStyle(0)
tpc_xy.SetFillStyle(0)
tpc_xy.SetLineWidth(3)
h_xy.Draw("col")
h_xy.GetYaxis().SetTitleOffset(1.3)

#h_xy_corr.Draw("col")
h_xy_corr.GetYaxis().SetTitleOffset(1.3)
preliminary = TPaveText(0.48, 0.74, 0.81, 0.84, "NDC")
preliminary.SetShadowColor(0)
preliminary.SetBorderSize(0)
preliminary.SetFillStyle(0)
preliminary.AddText("MicroBooNE Preliminary")