Example #1
0
def bpmass_nonres_below5(args, figname):
    datatype = args[0]
    label = args[1]
    test = option_exists(args, '-t')
    rootname = figname.replace('bpmass_nonres_below5', 'summary')
    rootfile = set_file(atr.figpath, label, rootname, '.root', test=test)
    figfile = set_file(atr.figpath, label, figname, '.pdf', test=test)
    c = TCanvas("aCanvas", "Canvas", 600, 600)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetOptTitle(0)
    c.UseCurrentStyle()

    f = TFile(rootfile)
    h = f.Get('h_bpmass_nonres_below5')
    h.GetYaxis().SetTitle(get_y_title(h, 'GeV'))
    h.GetYaxis().SetTitleOffset(1.6)
    h.Draw()

    pt = TPaveText()
    if label == 'Run2011v10.2':
        pt = TPaveText(4.2, 10, 4.8, 12)

    pt.SetBorderSize(0)
    pt.SetFillColor(0)
    pt.AddText("Entries = %d" % h.GetEntries())
    pt.Draw()

    c.Print(figfile)
    f.Close()
Example #2
0
def makePage( algorithm , pagename , cdash = False, prefix=""):
    from ROOT import TCanvas,kBlue,kRed,gROOT,kGreen,kYellow
    gROOT.SetBatch(True)
    c=TCanvas( algorithm.output.name , algorithm.output.name )
    c.Divide(1,2)
    from Interface import Result
    aColor = None
    if algorithm.output.result == Result.FAILED:
        aColor = kRed
    if algorithm.output.result == Result.NOTPASSED:
        aColor = kYellow
    if algorithm.output.result == Result.SUCCESS:
        aColor = kGreen
    if aColor:
        c.SetFillColor( aColor )
    aPad = c.cd(1)
    from Utils import draw
    lims = ()
    if "TH1" not in algorithm.test.dataset1.__class__.__name__:
        lims = ( 100, 
                min( algorithm.test.dataset1.tolist() + algorithm.test.dataset2.tolist() ),
                max( algorithm.test.dataset1.tolist() + algorithm.test.dataset2.tolist() )
               )
    h1=draw( algorithm.test.dataset1 , kBlue , ""    , lims , algorithm.output.name )
    h1.SetName(h1.GetName()+"_new")
    aPad.Update()
    from ROOT import TPaveStats
    statBox = h1.GetListOfFunctions().FindObject("stats")
    statBox.SetName('new_stat')
    statBox.SetY1NDC(statBox.GetY1NDC()-.18)
    statBox.SetY2NDC(statBox.GetY2NDC()-.18)
    statBox.SetTextColor(kBlue)
    statBox.SetBorderSize(2)
    h2=draw( algorithm.test.dataset2 , kRed  , "sames", lims , algorithm.output.name+"ref")
    h2.SetName(h2.GetName()+"_ref")
    aPad.Update()
    statBox2 = h2.GetListOfFunctions().FindObject("stats")
    statBox2.SetName('ref_stat')
    statBox2.SetTextColor(kRed)
    from ROOT import TPaveText
    pave=TPaveText(0.02,0.85,0.35,0.99,"NDC")
    pave.SetTextColor(aColor)
    pave.SetFillColor(1)
    pave.AddText(" %s "%algorithm.output.result)
    pave.AddText("(p-val: %s Test: %s)"%(algorithm.output.value,
                                         algorithm.test.__class__.__name__))
    pave.Draw()
    c.cd(2)
    if 'residuals' in algorithm.test.__dict__:
        algorithm.test.residuals.Draw()
    else:
        from Utils import makeResiduals
        algorithm.test.residuals = makeResiduals( h1 , h2 )
        algorithm.test.residuals.Draw()
    c.Print(pagename+prefix)
    # only print CDASH info if the test has failed (saves space on webserver)
    if cdash == True and not (algorithm.output.result == Result.SUCCESS):
        import os
        c.Print(os.path.dirname(pagename)+"/"+algorithm.output.name.replace('/','_')+".png")
        print " <DartMeasurementFile name=\"" + algorithm.output.name +  "\" type=\"image/png\"> " + os.path.dirname(pagename) + "/" + algorithm.output.name.replace('/','_') + ".png" + " </DartMeasurementFile>"
Example #3
0
def exampleDataPlot(bx, shape, comp):
    kBird()
    f = TFile.Open('DataAnalysisBunch' + bx + shape + '_new_StronRescale.root')
    if f:
        hist = f.Get('dataHist' + comp)
        hist.SetTitle('')
        hist.SetName(bx + shape + '_dataHist' + comp)
        canvas = TCanvas('c_' + hist.GetName(), '', 600, 600)
        canvas.SetFrameFillColor(0)
        hist.Draw("COLZ")
        canvas.Update()
        hist.GetXaxis().SetTitle('x [cm]')
        hist.GetXaxis().SetLabelSize(0.025)
        hist.GetYaxis().SetTitle('y [cm]')
        hist.GetYaxis().SetLabelSize(0.025)
        hist.GetYaxis().SetTitleOffset(1.3)
        hist.GetZaxis().SetTitle('Number of Vertices')
        hist.GetZaxis().SetLabelSize(0.025)
        hist.GetZaxis().SetTitleOffset(0.7)
        hist.GetZaxis().SetRangeUser(0.0, 240.0)
        hist.GetZaxis().CenterTitle()
        hist.GetZaxis().SetNdivisions(1, False)
        palette = hist.GetListOfFunctions().FindObject('palette')
        palette.SetX2NDC(0.929)
        pave = TPaveText(0.65, 0.82, 0.88, 0.88, 'NDC')
        pave.SetTextFont(42)
        pave.SetTextSize(0.025)
        pave.AddText('Scan ' + comp + ', BX ' + bx)
        pave.AddText('Measured data')
        pave.Draw('same')
        drawCMS()
        canvas.Modified()
        canvas.Update()
        canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.pdf')
        canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.C')
Example #4
0
def plotHoAboveThr():
	c5 = TCanvas("c5","c5",1200,1200)
	
	noTrgTdmiAboveThrNotConverted = file.Get("hoMuonAnalyzer/graphs/NoTrgTdmiAboveThr")
	noTrgTdmiAboveThr = PlotStyle.convertToHcalCoords(noTrgTdmiAboveThrNotConverted)
	noTrgTdmiAboveThr.GetXaxis().SetTitle("i#eta / a.u.")
	noTrgTdmiAboveThr.GetYaxis().SetTitle("i#phi / a.u.")
	noTrgTdmiAboveThr.SetMarkerStyle(6)
	noTrgTdmiAboveThr.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	noTrgTdmiAboveThr.SetTitle("#eta #phi plot of HO > 0.2 GeV in no Single #mu Trg. events")
	noTrgTdmiAboveThr.Draw("AP")
	
	pText = TPaveText(0.7,0.85,0.9,0.9,'NDC')
	pText.AddText('No Single #mu in GA: %d' % (noSingleMuEventsInGa))
	pText.AddText('Events in Plot: %d' % (noTrgTdmiAboveThr.GetN()))
	pText.SetBorderSize(1)
	pText.Draw()
	
	chimney1 = PlotStyle.chimney1
	chimney2 = PlotStyle.chimney2
	labelCmsPrivateSimulation = PlotStyle.getLabelCmsPrivateSimulation()
	chimney1Converted.Draw("same,l")
	chimney2Converted.Draw("same,l")
	labelCmsPrivateSimulation.Draw()
	legend = TLegend(0.1,0.87,0.3,0.9)
	legend.AddEntry(chimney2Converted,"chimney","l")
	legend.Draw()
	#c5.SetGridY(0)
	#c5.SetGridX(0)
	c5.Update()
	c5.SaveAs("plots/graphsEtaPhi/gNoTrgTdmiHoAboveThr.png")
Example #5
0
def plotEventsInAcceptance():
	c = TCanvas("c","c",1200,1200)
	
	gTdmiInGaNotConverted = file.Get("hoMuonAnalyzer/graphs/tdmiInGaNotDead")
	gTdmiInGa = PlotStyle.convertToHcalCoords(gTdmiInGaNotConverted)
	gTdmiInGa.GetXaxis().SetTitle("i#eta")
	gTdmiInGa.GetYaxis().SetTitle("i#phi")
	gTdmiInGa.SetMarkerStyle(6)
	gTdmiInGa.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	gTdmiInGa.SetTitle("#eta #phi plot of HO geom. Acceptance and not dead channels")
	gTdmiInGa.Draw("AP")
	
	pText = TPaveText(0.7,0.85,0.9,0.9,'NDC')
	pText.AddText('Total Events: %d' % (totalEvents))
	pText.AddText('Events in Plot: %d' % (gTdmiInGa.GetN()))
	pText.SetBorderSize(1)
	pText.Draw()
	
	chimney1 = PlotStyle.chimney1
	chimney2 = PlotStyle.chimney2
	labelCmsPrivateSimulation = PlotStyle.getLabelCmsPrivateSimulation()
	chimney1Converted.Draw("same,l")
	chimney2Converted.Draw("same,l")
	labelCmsPrivateSimulation.Draw()
	legend = TLegend(0.1,0.87,0.3,0.9)
	legend.AddEntry(chimney2Converted,"chimney","l")
	legend.Draw()
	c.Update()
	c.SaveAs("plots/graphsEtaPhi/gTdmiInGaNotDead.png")
Example #6
0
def plot(obj, plot_name, plot_notes=[]):
    canvas = TCanvas('canvas' + plot_name, "Canvas", 450, 450)
    gPad.SetLeftMargin(.13)
    gPad.SetTopMargin(.05)

    gStyle.SetOptStat(11)
    gStyle.SetOptFit(1111)

    if 'TH2' in obj.ClassName():
        gPad.SetRightMargin(.13)
        draw_options = 'COLZ'

    if 'profile' in obj.GetName():
        gPad.SetRightMargin(.05)
        draw_options = ''

    if 'graph' in obj.GetName():
        gPad.SetRightMargin(.05)
        draw_options = 'APE'
        obj.SetMarkerSize(.7)
        obj.SetMarkerStyle(21)

    note = TPaveText(.2, .7, .5, .9, "brNDC")
    note.SetFillStyle(0)
    note.SetFillColor(0)
    note.SetBorderSize(0)
    note.SetTextColor(1)
    note.SetTextFont(42)
    note.SetTextAlign(11)
    for note_text in plot_notes:
        note.AddText(note_text)

    obj.Draw(draw_options)
    note.Draw()
    canvas.Print('output/' + plot_name + '.pdf')
Example #7
0
def FIT_XS():
    is_fit = True
    gaexs_list_fit, geeff_list_fit, gexs_list_fit, func_list = fit_xs(label_list, iter_old, old_xs_list, tfunc_list, par_list, par_range_list, xmin_list, xmax_list, is_fit)
    for f, label, gaexs, geeff, gexs, xtitle, xs_ytitle, eff_ytitle in zip(func_list, label_list, gaexs_list_fit, geeff_list_fit, gexs_list_fit, xtitle_list, xs_ytitle_list, eff_ytitle_list):
        xs_mbc = TCanvas('xs_mbc_' + label + '_' + iter_old + '_fit', '', 700, 600)
        set_canvas_style(xs_mbc)
        xs_mbc.cd()
        if not label == 'DDPIPI':
            set_graph_style(gaexs, xtitle, xs_ytitle)
            gaexs.Draw('ap')
        else:
            set_graph_style(gaexs, xtitle, xs_ytitle)
            set_graph_style(gexs, xtitle, xs_ytitle)
            mg = TMultiGraph()
            mg.Add(gaexs)
            mg.Add(gexs)
            mg.Draw('ap')
        chi2 =  f.GetChisquare()
        if label == 'DDPIPI': ndf = f.GetNDF() + 1
        else: ndf = f.GetNDF()
        pt = TPaveText(0.15, 0.8, 0.55, 0.9, "BRNDC")
        set_pavetext(pt)
        pt.Draw()
        line = '#chi^{2}/ndf = ' + str(round(chi2, 3)) + '/' + str(round(ndf, 3)) + ' = ' + str(round(chi2/ndf, 3))
        with open('./txts/likelihood_' + label + '.txt', 'w') as f:
            f.write(str(chi2) + '\n' + str(ndf))
        pt.AddText(line)
        xs_mbc.SaveAs('./figs/xs_' + label + '_' + iter_old + '_fit.pdf')
    raw_input('Press <Enter> to end...')
    return func_list
Example #8
0
def kstarpmass(args, figname):
    datatype = args[0]
    label = args[1]
    test = option_exists(args, '-t')
    #rootname = 'SingleBuToKstarMuMu_summary_data_Run2011v10'
    rootname = figname.replace('kstarpmass', 'summary')
    rootfile = set_file(atr.figpath, label, rootname, '.root', test=test)
    figfile = set_file(atr.figpath, label, figname, '.pdf', test=test)
    c = TCanvas("aCanvas", "Canvas", 600, 600)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetOptTitle(0)
    c.UseCurrentStyle()

    f = TFile(rootfile)
    h = f.Get('h_kstarpmass')
    h.GetYaxis().SetTitle(get_y_title(h, 'GeV'))
    h.GetYaxis().SetTitleOffset(1.5)
    h.Draw()

    pt = TPaveText()
    if label == 'Run2011v10.1':
        pt = TPaveText(1, 70, 1.1, 80)
    if label == 'Run2011v10.2':
        pt = TPaveText(1, 70, 1.1, 80)

    pt.SetBorderSize(0)
    pt.SetFillColor(0)
    pt.AddText("Entries = %d" % h.GetEntries())
    pt.Draw()

    c.Print(figfile)
    f.Close()
Example #9
0
def bctau(args, figname):
    datatype = args[0]
    label = args[1]
    test = option_exists(args, '-t')
    rootname = figname.replace('bctau', 'summary')
    rootfile = set_file(atr.figpath, label, rootname, '.root', test=test)
    figfile = set_file(atr.figpath, label, figname, '.pdf', test=test)
    c = TCanvas("aCanvas", "Canvas", 600, 600)
    gStyle.SetPadLeftMargin(0.15)
    gStyle.SetOptTitle(0)
    c.UseCurrentStyle()

    f = TFile(rootfile)
    h = f.Get('h_bctau')
    h.GetYaxis().SetTitle(get_y_title(h, 'cm'))
    h.GetYaxis().SetTitleOffset(1.6)
    h.Draw()

    pt = TPaveText(0.2, 1.6e5, 0.6, 1.8e5)
    pt.SetBorderSize(0)
    pt.SetFillColor(0)
    pt.AddText("Entries = %d" % h.GetEntries())
    pt.Draw()

    c.Print(figfile)
    f.Close()
Example #10
0
def radialResidualPlots(crossings, shapes, chiSq, dof):
    kBird()
    gStyle.SetOptStat(0)
    components = ('X1', 'Y1', 'X2', 'Y2')
    for shape in shapes:
        for bx in crossings:
            f = TFile.Open('DataAnalysisBunch' + bx + shape +
                           '_new_StronRescale.root')
            if not f:
                continue
            for comp in components:
                dataHist = f.Get('dataHist' + comp)
                modelHist = f.Get('modelHist' + comp)
                nbinsx = dataHist.GetXaxis().GetNbins()
                nbinsy = dataHist.GetYaxis().GetNbins()
                radialDat = TH1D('radialDat_'+shape+bx+comp, '', nbinsx/2, 0.0, \
                                 dataHist.GetXaxis().GetXmax())
                radialMod = TH1D('radialMod_'+shape+bx+comp, '', nbinsx/2, 0.0, \
                                 dataHist.GetXaxis().GetXmax())
                hist = TH1D('radialRes_'+shape+bx+comp, '', nbinsx/2, 0.0, \
                            dataHist.GetXaxis().GetXmax())
                radialDat.Sumw2()
                for xbin in range(nbinsx + 1):
                    for ybin in range(nbinsy + 1):
                        r = (dataHist.GetXaxis().GetBinCenter(xbin)**2 + \
                            dataHist.GetYaxis().GetBinCenter(ybin)**2) ** 0.5
                        radialDat.Fill(r, dataHist.GetBinContent(xbin, ybin))
                        radialMod.Fill(r, modelHist.GetBinContent(xbin, ybin))
                for rbin in range(nbinsx / 2 + 1):
                    err = radialDat.GetBinError(rbin)
                    if err > 0.0:
                        pull = (radialDat.GetBinContent(rbin) - \
                                radialMod.GetBinContent(rbin)) / err
                    else:
                        pull = 0.0
                    hist.SetBinContent(rbin, pull)
                canvas = TCanvas('c_' + hist.GetName(), '', 600, 600)
                hist.Draw('HF')
                canvas.Update()
                hist.SetFillColor(4)
                hist.SetLineColor(1)
                hist.GetXaxis().SetTitle('r [cm]')
                hist.GetXaxis().SetLabelSize(0.025)
                hist.GetYaxis().SetTitle('Pulls')
                hist.GetYaxis().SetLabelSize(0.025)
                hist.GetYaxis().SetTitleOffset(1.1)
                hist.GetYaxis().SetRangeUser(-1.5, 5.0)
                pave = TPaveText(0.15, 0.79, 0.42, 0.88, 'NDC')
                pave.SetTextFont(42)
                pave.SetTextSize(0.025)
                pave.AddText('Scan ' + comp + ', BX ' + bx)
                pave.AddText(shapeNames[shape] + ' fit')
                redChiSq = chiSq[shape][bx] / dof[shape][bx]
                pave.AddText('#chi^{2}/d.o.f. = %6.4f' % (redChiSq))
                pave.Draw('same')
                drawCMS()
                canvas.Modified()
                canvas.Update()
                canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.pdf')
                canvas.SaveAs('summaryPlots/' + canvas.GetName() + '.C')
Example #11
0
	def plot1DEMaxAroundL1(self):	
		'''
			eta[P,M][2,1,0]phi[P,M][2,1,0]_averageEnergyAroundPoint
			Central tile is central
		'''
		histList = []
		fitList = []
		labelList = []
		canvas = TCanvas('canvas1DEMax','1D EMax',1200,1200)
		for p in reversed(range(-2,3)):
			for e in range(-2,3):
				if e == 0 and p == 0:
					histList.append(self.fileHandler.getHistogram('etaPhi/energy1D/central_averageEMaxAroundPoint' + self.key))
				else:
					histName = ('etaPhi/energy1D/eta%s%dPhi%s%d_averageEMaxAroundPoint' + self.key) % ('P' if e >= 0 else 'M',abs(e),'P' if p >= 0 else 'M',abs(p))
					histList.append(self.fileHandler.getHistogram(histName))
		canvas.Divide(5,5)
		for i,hist in enumerate(histList):
			canvas.cd(i+1).SetLogy()
			hist.GetXaxis().SetRangeUser(-0.5,4)
			hist.SetLineWidth(3)
			setupAxes(hist)
			hist.Draw()
			fit = TF1('fit%d' % (i),'landau',0.5,2)
			hist.Fit(fit,'RQ')
			label = TPaveText(0.6,0.7,0.9,0.9,"NDC")
			label.AddText('MPV: %5.2f' % (fit.GetParameter(1)))
			label.Draw()
			labelList.append(label)
			fitList.append(fit)
		canvas.Update()
		self.storeCanvas(canvas, '1DEMaxPlots')
		return histList,canvas,fitList,labelList
Example #12
0
def doPlotEventCount(filename='L1MuonHistogram.root'):
    if (DEBUG):
        print 'Opening file:', filename
    file = TFile.Open(filename)
    if (file == None):
        print 'Error opening file:', filename
    histoNames = [
        'hoMuonAnalyzer/L1_SingleMu3_Trig',
        'hoMuonAnalyzer/etaPhi/NoSingleMu_DeltaEtaDeltaPhi',
        'hoMuonAnalyzer/count/Events_Count'
    ]

    histograms = []

    for s in histoNames:
        histograms.append(file.Get(s))

    yValues = []
    yValues.append(histograms[0].GetBinContent(1))
    yValues.append(histograms[1].GetEntries())

    nEvents = histograms[2].GetEntries()

    xLabels = ['No Single #mu trigger', 'HO > 0.2 GeV matched to Gen']

    c = TCanvas('eventCountCanvas', 'PostLS1 Single #mu gun', 1200, 1200)

    hist = TH1D("eventCount", "PostLS1 Single #mu gun", len(xLabels), 0,
                len(xLabels))
    for i, v in enumerate(xLabels):
        hist.SetBinContent(i + 1, yValues[i])
        hist.GetXaxis().SetBinLabel(i + 1, str(v))

    hist.SetStats(0)
    hist.SetLineColor(PlotStyle.colorRwthDarkBlue)
    hist.GetYaxis().SetTitle('#')
    #	hist.GetYaxis().SetRangeUser(0.5,1.1)
    hist.SetLabelFont(62)
    hist.SetTitleFont(62)
    hist.Draw("")

    paveText = TPaveText(0.51, 0.75, 0.9, 0.9, 'NDC')
    paveText.AddText('%s: %d => %.2f%% #pm %.2f%%' %
                     (xLabels[0], yValues[0], yValues[0] / nEvents * 100,
                      calcSigma(yValues[0], nEvents) * 100))
    paveText.AddText('%s: %d => %.2f%% #pm %.2f%%' %
                     (xLabels[1], yValues[1], yValues[1] / yValues[0] * 100,
                      calcSigma(yValues[1], yValues[0]) * 100))
    paveText.SetBorderSize(1)
    paveText.Draw()

    PlotStyle.labelCmsPrivateSimulation.Draw()

    c.Update()

    c.SaveAs("eventCount.png")
    c.SaveAs("eventCount.pdf")
    c.SaveAs("eventCount.root")

    return c, hist
Example #13
0
def checklatex(texts, tag=""):
    """Check legend entries: colors, titles, ..."""
    # https://root.cern.ch/doc/master/classTPaveText.html
    LOG.header("checklegend" + tag.replace('_', ' '))
    output = ensuredir('plots')
    fname = "%s/testLatex%s" % (output, tag)
    xdim = 500
    ydim = 50 * (len(texts) + 2.5)
    print ">>> Canvas: %sx%s (nlines=%d)" % (xdim, ydim, len(texts))
    canvas = TCanvas('canvas', 'canvas', xdim, int(ydim))
    #pave1  = TPaveText(0.0,0,0.5,1,'ARC') #,'BR')
    pave2 = TPaveText(0.04, 0.04, 0.96, 0.96)  #'ARC') #,'BR')
    #pave1.SetBorderSize(0)
    pave2.SetBorderSize(0)
    #pave1.SetTextAlign(12)
    pave2.SetTextAlign(12)
    #pave1.SetTextFont(42)
    pave2.SetTextFont(42)
    #pave1.SetFillColor(0)
    pave2.SetFillColor(0)
    #pave1.SetCornerRadius(0.05)
    #pave2.SetCornerRadius(0.05)
    #pave1.SetMargin(0.12)
    #pave1.SetTextSize(tsize)
    #pave2.Copy(pave1)
    for line in texts:
        latex = makelatex(line)
        print ">>> %r -> %r" % (line, latex)
        #pave1.AddText(line)
        pave2.AddText(latex)
    #pave1.Draw()
    pave2.Draw()
    canvas.SaveAs(fname + ".png")
    #canvas.SaveAs(fname+".pdf")
    canvas.Close()
def drawcounts(h):
    txt = TPaveText(0.75, 0.55, 0.88, 0.7, "NDC")
    for i in h:
        txt.AddText("{}={}".format(i.GetTitle(), i.GetEntries()))
    txt.Draw()
    latexdrawn.append(txt)
    gPad.Update()
Example #15
0
def plot(data_path, pt_title, ecms, xmin, xmax, xbins):
    try:
        f_data = TFile(data_path)
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error('File paths are invalid!')
        sys.exit()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    set_canvas_style(mbc)
    content = (xmax - xmin) / xbins * 1000
    ytitle = 'Events/%.1f MeV' % content
    xtitle = 'M(K^{-}#pi^{+}#pi^{+})(GeV)'
    h_data = TH1F('data', 'data', xbins, xmin, float(xmax))

    set_histo_style(h_data, xtitle, ytitle)
    rawm_D_fill(t_data, h_data)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    h_data.Draw('E1')

    pt = TPaveText(0.6, 0.7, 0.75, 0.75, "BRNDC")
    set_pavetext(pt)
    pt.Draw()
    pt.AddText(pt_title)

    mbc.SaveAs('./figs/m_Kpipi_' + str(ecms) + '.pdf')

    raw_input('Enter anything to end...')
def printLHCb(optLR='L', isPrelim=False, optText=''):
    global lhcbStyle
    global lhcbNames

    lhcbName = None

    if (optLR is 'R'):
        lhcbName = TPaveText(0.70 - lhcbStyle.GetPadRightMargin(),
                             0.85 - lhcbStyle.GetPadTopMargin(),
                             0.95 - lhcbStyle.GetPadRightMargin(),
                             0.95 - lhcbStyle.GetPadTopMargin(), "BRNDC")
    elif (optLR is 'L'):
        lhcbName = TPaveText(lhcbStyle.GetPadLeftMargin() + 0.05,
                             0.85 - lhcbStyle.GetPadTopMargin(),
                             lhcbStyle.GetPadLeftMargin() + 0.30,
                             0.95 - lhcbStyle.GetPadTopMargin(), "BRNDC")
    elif (optLR is 'BR'):
        lhcbName = TPaveText(0.70 - lhcbStyle.GetPadRightMargin(),
                             0.05 + lhcbStyle.GetPadBottomMargin(),
                             0.95 - lhcbStyle.GetPadRightMargin(),
                             0.15 + lhcbStyle.GetPadBottomMargin(), "BRNDC")

    if (isPrelim):
        lhcbName.AddText('#splitline{LHCb}{#scale[1.0]{Preliminary}}')
    else:
        lhcbName.AddText('LHCb')

    lhcbName.SetFillColor(0)
    lhcbName.SetTextAlign(12)
    lhcbName.SetBorderSize(0)
    lhcbName.Draw()

    lhcbNames += [lhcbName]
    return
Example #17
0
def get_ccdb_obj(ccdb_path, timestamp, out_path, host, show, verbose):
    """
    Gets the ccdb object from 'ccdb_path' and 'timestamp' and downloads it into 'out_path'
    """
    if verbose:
        print("Getting obj", ccdb_path, "with timestamp", timestamp,
              convert_timestamp(timestamp))
    cmd = f"o2-ccdb-downloadccdbfile --host {host} --path {ccdb_path} --dest {out_path} --timestamp {timestamp}"
    subprocess.run(cmd.split())
    if verbose:
        f = TFile(os.path.join(out_path, ccdb_path, "snapshot.root"), "READ")
        meta = f.Get("ccdb_meta")
        if False:
            print("Metadata")
            for i in meta:
                print(i)

        def print_info(entry):
            print("Object", entry, meta[entry])

        print_info("Last-Modified")
        if show:
            obj = f.Get("ccdb_object")
            obj.Draw()
            time_box = TPaveText(.01, .9, 0.3, 0.99, "NDC")
            time_box.AddText(ccdb_path)
            time_box.AddText(f"timestamp {timestamp}")
            time_box.AddText(f"{convert_timestamp(timestamp)}")
            time_box.Draw()
            gPad.Update()
            input("Press enter to continue")
Example #18
0
class CanvasIter(TCanvas):
    """A root canvas with title and active pads.  The active pads may be iterated.
    """

    def __init__(self,name,title,wx=850*2/3,wy=1100*2/3,nx=0,ny=1):
        
        TCanvas.__init__(self,name,title,wx,wy)

        self.name     = name
        self.title    = title
        self.wx       = wx
        self.wy       = wy
        self.nx       = nx
        self.ny       = ny

        # Divide this canvase into a 'title' and 'active' area
        self.Divide(1,2)
        self.title_pad = self.cd(1)
        self.active_pad = self.cd(2)
        self.title_pad.SetPad(0.00,0.93,1.00,1.00)
        self.active_pad.SetPad(0.00,0.00,1.00,0.93)

        # In the title pad, draw a TPaveText with the title
        self.title_pad.cd()
        self.pave_title = TPaveText( 0.015, 0.075, 0.985, 0.925, "r" )
        self.pave_title.AddText(0.5,0.85, title)
        self.pave_title.Draw()

        # Divide the active pad, if nx>0
        self.active_pad.cd()
        if ( nx ):
            self.active_pad.Divide(nx,ny)

        self.current = 0         # currently active pad


    def divide(self,nx,ny):
        
        self.active_pad.Clear()
        self.active_pad.Divide(nx,ny)
        self.nx = nx
        self.ny = ny
        self.current = 0

    def __iter__(self):
        return self

    def next(self):
        
        pad = self.active_pad
        if ( self.nx ):
            self.current += 1
            if ( self.current > self.nx*self.ny ):
                raise StopIteration
                return 0
            pad = pad.cd( self.current )

        return pad
Example #19
0
	def plotHoTime(self):
		c3 = TCanvas("c3","HO Time",1200,1200)
		skipNoisePlot = False
		if not skipNoisePlot:
			c3.Divide(1,2)
			c3.cd(1).SetLogy()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			hHoTime = self.fileHandler.getHistogram('hoRecHits_Time')
			
			hHoTime.SetStats(0)
			hHoTime.SetTitle("Time distribution for all HO Rec Hits")
			hHoTime.SetLineColor(colorRwthDarkBlue)
			hHoTime.SetLineWidth(3)
			hHoTime.Draw()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			
		hHoTimeAboveThr = self.fileHandler.getHistogram('hoRecHitsAboveThr_Time')
		c3.cd(2).SetLogy()
		hHoTimeAboveThr.SetStats(0)
		hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV")
		hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue)
		hHoTimeAboveThr.SetLineWidth(3)
		setupAxes(hHoTimeAboveThr)
		hHoTimeAboveThr.Draw()
		
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		
		self.debug(80*'#')
		self.debug( 'Integral of HO > 0.2 GeV time histogram:')
		self.debug( hHoTimeAboveThr.Integral())
		self.debug('')
		
		xLow = -5
		xHigh = 5
		histogramBetween = hHoTimeAboveThr.Integral(hHoTimeAboveThr.FindBin(xLow),hHoTimeAboveThr.FindBin(xHigh))
		histogramTotal = float(hHoTimeAboveThr.Integral())
		self.debug( 'Histogram integral between %.f ns and %.f ns' % (xLow,xHigh) )
		self.debug( '%d/%d => %.2f +/- %f' % (histogramBetween,histogramTotal
											,histogramBetween/histogramTotal,calcSigma(histogramBetween, histogramTotal))) 
		self.debug( 80*'#')
		
		fit = TF1("fit","gaus",-10,10)
		hHoTimeAboveThr.Fit(fit)
		
		pText = TPaveText(0.7,0.8,0.9,0.9,'NDC')
		pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1)))
		pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2)))
		pText.SetBorderSize(1)
		pText.SetFillColor(0)
		pText.Draw()
		
		c3.Update()
		self.storeCanvas(c3,"hoTime")
		
		return c3,label,hHoTimeAboveThr,pText
Example #20
0
    def plotTriggerEfficiency(self, passesHist, totalHist, label=""):
        if self._fout and self._canvas:
            passesHist = passesHist.Rebin(self._rebinFactor, "passesHist")
            totalHist = totalHist.Rebin(self._rebinFactor, "totalHist")

            self.makePassesConsistentWithTotal(passesHist, totalHist)
            metGraph = TGraphAsymmErrors(passesHist, totalHist)
            metGraph.SetEditable(0)

            pt = TPaveText(0.409774, 0.843023, 0.809524, 0.890827, "brNDC")
            pt.SetBorderSize(0)
            pt.SetFillStyle(0)
            pt.SetTextFont(42)
            pt.SetTextSize(0.0387597)
            pt.AddText(str(self._plotLabel))

            cmsLabel = TPaveText(0.134085, 0.937984, 0.418546, 0.984496,
                                 "brNDC")
            cmsLabel.SetBorderSize(0)
            cmsLabel.SetFillStyle(0)
            cmsLabel.SetTextFont(62)
            cmsLabel.SetTextSize(0.0387597)
            cmsLabel.AddText("CMS Preliminary")

            lumiLabel = TPaveText(0.575188, 0.937339, 0.874687, 0.992894,
                                  "brNDC")
            lumiLabel.SetBorderSize(0)
            lumiLabel.SetFillStyle(0)
            lumiLabel.SetTextFont(42)
            lumiLabel.SetTextSize(0.0387597)
            lumiLabel.AddText(str(self._luminosityLabel))

            setStyle(metGraph)
            self._canvas.cd()
            metGraph.Draw("ap")
            setAxisStyle(metGraph, "E_{T}^{miss, no #mu} [GeV]",
                         label + " trigger efficiency", (0.0, 500.0),
                         (0.0, 1.4))
            pt.Draw("same")
            cmsLabel.Draw("same")
            lumiLabel.Draw("same")
            self._fout.cd()
            self._canvas.Write("triggerEfficiency_" + label)
        else:
            print "A TFile and TCanvas must be added. Not making plots..."
Example #21
0
def draw_text(lines, coordinates=[0.1, 0.8, 0.5, 0.9], colour=36):
    text = TPaveText(coordinates[0], coordinates[1], coordinates[2],
                     coordinates[3], "brNDC")
    text.SetFillColorAlpha(0, 1)
    for line in lines:
        text.AddText("#color[" + str(colour) + "]{" + line + "}")
        print(line)
        text.Draw()
        ROOT.SetOwnership(text, False)
Example #22
0
def plot(path, pt_title, ecms, arrow_left, arrow_bottom, arrow_right,
         arrow_top):
    try:
        f_incMC1 = TFile(path[0])
        f_incMC2 = TFile(path[1])
        f_sigMC1 = TFile(path[2])
        f_sigMC2 = TFile(path[3])
        t_incMC1 = f_incMC1.Get('save')
        t_incMC2 = f_incMC2.Get('save')
        t_sigMC1 = f_sigMC1.Get('save')
        t_sigMC2 = f_sigMC2.Get('save')
        entries_incMC1 = t_incMC1.GetEntries()
        entries_incMC2 = t_incMC2.GetEntries()
        entries_sigMC1 = t_sigMC1.GetEntries()
        entries_sigMC2 = t_sigMC2.GetEntries()
        logging.info('inclusive MC (qqbar) entries :' + str(entries_incMC1))
        logging.info('inclusive MC (open charm) entries :' +
                     str(entries_incMC2))
        logging.info('D1(2420) signal MC entries :' + str(entries_sigMC1))
        logging.info('psi(3770) signal MC entries :' + str(entries_sigMC2))
    except:
        logging.error('Files are invalid!')
        sys.exit()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    set_canvas_style(mbc)
    xbins = 150
    M_Dplus = 1.86965
    step = (1.91965 - M_Dplus) / xbins

    h_FOM, ientry, arrow_top = cal_significance(t_incMC1, t_incMC2, t_sigMC1,
                                                t_sigMC2, xbins, step, ecms)
    h_FOM.Draw()

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    arrow_left = ientry * step + step
    arrow_right = ientry * step + step
    arrow_bottom = 0.
    arrow = TArrow(arrow_left, arrow_bottom, arrow_right, arrow_top, 0.01, '>')
    set_arrow(arrow)
    arrow.Draw()

    pt = TPaveText(0.6, 0.8, 0.85, 0.85, "BRNDC")
    set_pavetext(pt)
    pt.Draw()
    pt.AddText(pt_title)

    mass_low = str(M_Dplus - (step + step * ientry))
    mass_up = str(M_Dplus + (step + step * ientry))
    window_width = str(2 * (step + step * ientry))
    range = 'Recoiling mass window of D^{+}#pi^{+}#pi^{-}: : [' + mass_low + ', ' + mass_up + '] GeV/c2' + ' with mass window width: ' + window_width + ' GeV/c2'
    print range

    mbc.Update()
    mbc.SaveAs('./figs/opt_rm_Dpipi_' + str(ecms) + '.pdf')
Example #23
0
def plotGenEtaPhi():
    c = TCanvas("canvasGenEtaPhi", "canvas Gen Eta Phi", 1200, 1200)
    graph = file.Get('hoMuonAnalyzer/graphs/gen')

    graph.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
    graph.SetMarkerStyle(2)
    graph.GetXaxis().SetTitleFont(62)
    graph.GetYaxis().SetTitleFont(62)
    graph.GetYaxis().SetLabelFont(62)
    graph.GetYaxis().SetTitle('#phi')
    graph.GetXaxis().SetTitle('#eta')
    graph.SetTitle('#eta #phi distribution for GEN')
    graph.Draw('AP')

    #CMS label
    label = PlotStyle.getLabelCmsPrivateSimulation()
    label.Draw()

    pText = TPaveText(0.7, 0.85, 0.9, 0.9, 'NDC')
    pText.SetBorderSize(1)
    pText.AddText('Total Events: %d' % (totalEvents))
    pText.Draw()

    c.SaveAs('plots/genControlPlots/genEtaPhi.pdf')
    c.SaveAs('plots/genControlPlots/genEtaPhi.png')

    #Prepare histograms for eta and phi alone
    histPhi = TH1D('histGenPhi', "#phi GEN;#phi;#", 80, -3.48, 3.48)
    histEta = TH1D('histGenEta', "#eta GEN;#eta;#", 40, -1.74, 1.74)

    #Get the data from the graph
    x = Double(0)
    y = Double(0)
    for i in range(0, graph.GetN()):
        graph.GetPoint(i, x, y)
        histPhi.Fill(y)
        histEta.Fill(x)

    #Draw phi histogram
    cPhi = TCanvas("canvasGenPhi", "canvas Gen Phi", 1200, 1200)
    histPhi.SetStats(0)
    histPhi.Draw()
    label.Draw()
    cPhi.SaveAs('plots/genControlPlots/genPhi.pdf')
    cPhi.SaveAs('plots/genControlPlots/genPhi.pdf')

    #Draw eta histogram
    cEta = TCanvas("canvasGenEta", "canvas Gen Eta", 1200, 1200)
    histEta.SetStats(0)
    histEta.Draw()
    label.Draw()
    cEta.SaveAs('plots/genControlPlots/genEta.pdf')
    cEta.SaveAs('plots/genControlPlots/genEta.pdf')

    return c, graph, label, histEta, histPhi, cEta, cPhi, pText
Example #24
0
def plot(data_path, phsp_path, pt_title, ecms, xmin, xmax, xbins):
    try:
        f_data = TFile(data_path)
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error(data_path + ' is invalid!')
        sys.exit()
    try:
        f_phsp = TFile(phsp_path)
        t_phsp = f_phsp.Get('save')
        entries_phsp = t_phsp.GetEntries()
        logging.info('PHSP MC entries :' + str(entries_phsp))
    except:
        logging.error(phsp_path + ' is invalid!')
        sys.exit()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    set_canvas_style(mbc)
    content = int((xmax - xmin) / xbins * 1000)
    ytitle = 'Events/%.1f MeV' % content
    xtitle = 'M(#pi_{0}^{+}#pi_{0}^{-})(GeV)'

    h_data = TH1F('data', 'data', xbins, xmin, xmax)
    set_histo_style(h_data, xtitle, ytitle, 1, -1)
    m_pipi_fill(t_data, h_data)

    h_phsp = TH1F('PHSP', 'PHSP', xbins, xmin, xmax)
    set_histo_style(h_phsp, xtitle, ytitle, 2, 3004)
    m_pipi_fill(t_phsp, h_phsp)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    scale = h_data.Integral() / h_phsp.Integral() * 0.2
    h_phsp.Scale(scale)
    h_data.Draw('E1')
    h_phsp.Draw('same')
    h_data.Draw('sameE1')

    pt = TPaveText(0.6, 0.7, 0.75, 0.75, "BRNDC")
    set_pavetext(pt)
    pt.Draw()
    pt.AddText(pt_title)

    legend = TLegend(0.6, 0.55, 0.75, 0.7)
    set_legend(legend, h_data, h_phsp)
    legend.Draw()

    mbc.SaveAs('./figs/m_pipi_' + str(ecms) + '.pdf')

    raw_input('Enter anything to end...')
def draw_text(lines, coordinates=[0.1, 0.8, 0.5, 0.9], colour=36, border=1):
    text = TPaveText(coordinates[0], coordinates[1], coordinates[2],
                     coordinates[3], "brNDC")
    text.SetFillColorAlpha(0, 0)
    text.SetBorderSize(border)
    text.SetTextFont(62)
    for line in lines:
        text.AddText("#color[" + str(colour) + "]{" + line + "}")
        print(line)
        text.Draw()
        ROOT.SetOwnership(text, False)
    return text
Example #26
0
def plot(path, pt_title, ecms):
    try:
        f_incMC1 = TFile(path[0])
        f_incMC2 = TFile(path[1])
        t_incMC1 = f_incMC1.Get('save')
        t_incMC2 = f_incMC2.Get('save')
        entries_incMC1 = t_incMC1.GetEntries()
        entries_incMC2 = t_incMC2.GetEntries()
        logging.info('inclusive MC (qqbar) entries :' + str(entries_incMC1))
        logging.info('inclusive MC (open charm) entries :' +
                     str(entries_incMC2))
        if ecms > 4230:
            f_sigMC1 = TFile(path[2])
            f_sigMC2 = TFile(path[3])
            t_sigMC1 = f_sigMC1.Get('save')
            t_sigMC2 = f_sigMC2.Get('save')
            entries_sigMC1 = t_sigMC1.GetEntries()
            entries_sigMC2 = t_sigMC2.GetEntries()
            logging.info('D1(2420) signal MC entries :' + str(entries_sigMC1))
            logging.info('psi(3770) signal MC entries :' + str(entries_sigMC2))
        else:
            f_sigMC1 = TFile(path[2])
            t_sigMC1 = f_sigMC1.Get('save')
            entries_sigMC1 = t_sigMC1.GetEntries()
            logging.info('psi(3770) signal MC entries :' + str(entries_sigMC1))
    except:
        logging.error('Files are invalid!')
        sys.exit()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    set_canvas_style(mbc)

    if ecms > 4230:
        t = [t_incMC1, t_incMC2, t_sigMC1, t_sigMC2]
    else:
        t = [t_incMC1, t_incMC2, t_sigMC1]
    h_FOM = cal_significance(t, ecms)
    h_FOM.Draw('colz')

    pt = TPaveText(0.6, 0.8, 0.85, 0.85, "BRNDC")
    set_pavetext(pt)
    pt.Draw()
    pt.AddText(pt_title)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    mbc.RedrawAxis()
    mbc.Update()
    mbc.SaveAs('./figs/opt_rm_D_rm_Dmiss_' + str(ecms) + '.pdf')

    raw_input('Enter anything to end...')
Example #27
0
    def do_final_cosmetics(self):
        self.decoratee.do_final_cosmetics()

        titlebox = TPaveText(0.18, 0.94, 0.9, 0.97, "brNDC")
        titlebox.AddText(self.make_title())
        titlebox.SetTextSize(0.045)
        titlebox.SetFillStyle(0)
        titlebox.SetBorderSize(0)
        titlebox.SetTextAlign(13)
        titlebox.SetMargin(0.0)
        titlebox.SetFillColor(0)
        titlebox.Draw("SAME")
        self.titlebox = titlebox
Example #28
0
	def plotHoTimeLog(self):
		c3 = TCanvas("c3Log","HO Time Log",1200,1200)
		skipNoisePlot = True
		if not skipNoisePlot:
			c3.Divide(1,2)
			c3.cd(1).SetLogy()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			hHoTime = self.fileHandler.getHistogram('hoRecHits_Time')
			
			hHoTime.SetStats(0)
			hHoTime.SetTitle("Time distribution for all HO Rec Hits")
			hHoTime.SetLineColor(colorRwthDarkBlue)
			hHoTime.SetLineWidth(3)
			hHoTime.Draw()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			
		hHoTimeAboveThr = self.fileHandler.getHistogram('hoRecHitsAboveThr_Time')
		c3.cd(2).SetLogy()
		hHoTimeAboveThr.SetStats(0)
		hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV")
		hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue)
		hHoTimeAboveThr.SetLineWidth(3)
		setupAxes(hHoTimeAboveThr)
		hHoTimeAboveThr.Draw()
		
		label = getLabelCmsPrivateSimulation()
		label.Draw()
	
		fit = TF1("fit","gaus",-10,10)
		fit.SetParameter(1,0)
		fit.SetParameter(2,1)
		hHoTimeAboveThr.Fit(fit,'','R',-12.5,12.5)
		
		self.debug(80*'#')
		self.debug('Chi^2: %5.2f' % fit.GetChisquare())
		self.debug('NDF: %d' % fit.GetNDF())
		self.debug(80*'#')
		
		pText = TPaveText(0.7,0.8,0.9,0.9,'NDC')
		pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1)))
		pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2)))
		pText.SetBorderSize(1)
		pText.SetFillColor(0)
		pText.Draw()
		
		c3.Update()
		self.storeCanvas(c3,"hoTimeLog")
		
		return c3,pText,hHoTimeAboveThr
def plot(Polarization):
    Rootfiles = []
    for pol in Polarization:
        #print pol
        for plotstring in Plots:
            print plotstring
            Rootfiles.append(
                TFile(Outpath + "TwoPhotonThrust_" + pol + "._" + plotstring +
                      ".root"))

    for plotstring in Plots:
        print plotstring
        canvas1 = TCanvas("c1", "c1")
        firsthist = True
        for i, rootfile in enumerate(Rootfiles):
            #print i

            exec('plot = rootfile.' + ptype + '_' + plotstring)
            if i + 1 >= 5: plot.SetLineColor(i + 2)
            else: plot.SetLineColor(i + 1)
            plot.SetLineWidth(2)
            plot.SetLineStyle(1)
            #if ptype == 'S': plot.SetLineStyle(1)
            #else: plot.SetLineStyle(2)
            plot.SetTitle(Pol[Polarization[i]])
            plot.Draw("same")
            #plot.SetLogy()

            if firsthist:
                plot.SetStats(False)
                plot.SetXTitle("Thrust")
                plot.GetXaxis().CenterTitle()
                plot.SetYTitle("Events")
                plot.GetYaxis().CenterTitle()
                plot.GetXaxis().SetRangeUser(-3, 4)
                plot.GetYaxis().SetRangeUser(0, 10000)

                firsthist = False
        #STOP rootfiles loop
        gStyle.SetOptTitle(0)
        #turn off default title
        title = TPaveText(0.25, 0.9, 0.75, 1.0, "brNDC")
        title.AddText(Plotnames[plotstring] + ' Thrust Value')
        title.Draw("same")

        canvas1.SetGrid(1, 0)
        canvas1.BuildLegend()
        canvas1.SaveAs(Outpath + ptype + '_' + plotstring + '_' + 'aalowpt' +
                       ".png")
        canvas1.SaveAs(Outpath + ptype + '_' + plotstring + '_' + 'aalowpt' +
                       ".ps")
Example #30
0
def plot(path, pt_title, ecms, arrow_left, arrow_bottom, arrow_right,
         arrow_top):
    try:
        f_incMC1 = TFile(path[0])
        f_incMC2 = TFile(path[1])
        f_sigMC1 = TFile(path[2])
        f_sigMC2 = TFile(path[3])
        t_incMC1 = f_incMC1.Get('save')
        t_incMC2 = f_incMC2.Get('save')
        t_sigMC1 = f_sigMC1.Get('save')
        t_sigMC2 = f_sigMC2.Get('save')
        entries_incMC1 = t_incMC1.GetEntries()
        entries_incMC2 = t_incMC2.GetEntries()
        entries_sigMC1 = t_sigMC1.GetEntries()
        entries_sigMC2 = t_sigMC2.GetEntries()
        logging.info('inclusive MC (qqbar) entries :' + str(entries_incMC1))
        logging.info('inclusive MC (open charm) entries :' +
                     str(entries_incMC2))
        logging.info('D1(2420) signal MC entries :' + str(entries_sigMC1))
        logging.info('psi(3770) signal MC entries :' + str(entries_sigMC2))
    except:
        logging.error('Files are invalid!')
        sys.exit()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    set_canvas_style(mbc)
    xbins = 100
    step = 100 / xbins

    h_FOM, ientry = cal_significance(t_incMC1, t_incMC2, t_sigMC1, t_sigMC2,
                                     xbins, step, ecms)
    h_FOM.Draw()

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    arrow = TArrow(arrow_left, arrow_bottom, arrow_right, arrow_top, 0.01, '>')
    set_arrow(arrow)
    arrow.Draw()

    pt = TPaveText(0.6, 0.8, 0.85, 0.85, "BRNDC")
    set_pavetext(pt)
    pt.Draw()
    pt.AddText(pt_title)

    range = 'chi2 of kinematic fit of D^{+}D_{miss}#pi^{+}#pi^{+}: ' + str(
        arrow_right)
    print range

    mbc.Update()
    mbc.SaveAs('./figs/opt_chi2_kf_' + str(ecms) + '.pdf')