コード例 #1
0
def plotNoL1AndTdmiInAcceptance():
	c4 = TCanvas("c4","c4",1200,1200)
	gNoTrgNoL1TdmiInGa = file.Get("hoMuonAnalyzer/graphs/NoTrgNoL1TdmiInGA")
	gConvertedToiEtaiPhi = PlotStyle.convertToHcalCoords(gNoTrgNoL1TdmiInGa)
	gConvertedToiEtaiPhi.SetTitle('No Single #mu Trg, in HO Acceptance')
	gConvertedToiEtaiPhi.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	gConvertedToiEtaiPhi.Draw("AP")
	chimney1 = PlotStyle.chimney1
	chimney2 = PlotStyle.chimney2
	chimney1Converted = PlotStyle.convertToHcalCoords(chimney1)
	chimney2Converted = PlotStyle.convertToHcalCoords(chimney2)
	chimney1Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney2Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney1Converted.Draw('Same,l')
	chimney2Converted.Draw('Same,l')
	legend = TLegend(0.7,0.85,0.9,0.9)
	legend.AddEntry(chimney2Converted,"chimneys","le")
	legend.Draw()
	
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	c4.Update()
	#boxes = PlotStyle.drawHcalBoxesHcalCoords(c4)
	c4.SaveAs("plots/graphsEtaPhi/gNoTrgNoL1TdmiInGaHocoords.pdf")
	c4.SaveAs("plots/graphsEtaPhi/gNoTrgNoL1TdmiInGaHocoords.png")
	return c4,legend,chimney1Converted,chimney2Converted,gConvertedToiEtaiPhi
コード例 #2
0
def doPlotPhiPtOfFailingMatches():
	file = TFile.Open('L1MuonHistogram.root')
	#Prepare canvas
	canvas = TCanvas("canvasPtPhiHoMatchFail","PtPhiHoMatchFail",1200,1200)
	canvas.cd().Draw()
	#prepare histogram
	hist = file.Get("hoMuonAnalyzer/etaPhi/3D/NoTrgTdmiNotInGA_EtaPhiPt")

	stack = THStack(hist,"zy","2dStack","",-1,-1,-1,-1,"zy","")

	#Create new histogram and add the histograms from the stack
	histNew = TH2D("histPtEtaHoMatchFail","p_{T} vs. #phi distribution for events not in HO acceptance;#phi;p_{T} / 5 GeV;#",80, -3.2, 3.2,40,0,200)
	histNew.GetYaxis().SetTitleOffset(1.2)
	histNew.Sumw2()
	for i in stack.GetHists():
		histNew.Add(i)
	
	gStyle.SetPalette(1)
	histNew.SetStats(0)
	PlotStyle.setupAxes(histNew)
	histNew.Draw('COLZ')
	canvas.Update()

	palette = histNew.FindObject("palette")
	palette.SetX1NDC(0.9)
	palette.SetX2NDC(0.92)
	#add label
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
	canvas.Update()
	canvas.SaveAs('plots/NoL1NotInHoAcceptancePhiPt.pdf')
	canvas.SaveAs('plots/NoL1NotInHoAcceptancePhiPt.png')
	return canvas,hist,stack,histNew,label,palette,file
コード例 #3
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")
コード例 #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")
コード例 #5
0
def doPlotEtaPtOfSuccessfulMatches():
    file = TFile.Open('L1MuonHistogram.root')
    #Prepare canvas
    canvas = TCanvas("canvasPtEtaHoMatch", "PtEtaHoMatch", 1200, 1200)
    canvas.cd().Draw()
    #prepare histogram
    hist = file.Get("hoMuonAnalyzer/etaPhi/3D/NoTrgTdmiAboveThr_EtaPhiPt")

    stack = THStack(hist, "zx", "2dStack", "", -1, -1, -1, -1, "zx", "")

    #Create new histogram and add the histograms from the stack
    histNew = TH2D("histPtEtaHoMatch",
                   "p_{T} vs. #eta distribution;#eta;p_{T} / 5 GeV;#", 40,
                   -1.6, 1.6, 40, 0, 200)
    histNew.GetYaxis().SetTitleOffset(1.2)
    for i in stack.GetHists():
        histNew.Add(i)

    gStyle.SetPalette(1)
    histNew.SetStats(0)
    histNew.Draw('COLZ')
    canvas.Update()

    palette = histNew.FindObject("palette")
    palette.SetX1NDC(0.9)
    palette.SetX2NDC(0.92)
    #add label
    label = PlotStyle.getLabelCmsPrivateSimulation()
    label.Draw()

    canvas.Update()
    canvas.SaveAs('plots/NoL1HoMatchPtEta.pdf')
    canvas.SaveAs('plots/NoL1HoMatchPtEta.png')
    return canvas, hist, stack, histNew, label, palette, file
コード例 #6
0
def doPlotEtaPtOfSuccessfulMatches():
	file = TFile.Open('L1MuonHistogram.root')
	#Prepare canvas
	canvas = TCanvas("canvasPtEtaHoMatch","PtEtaHoMatch",1200,1200)
	canvas.cd().Draw()
	#prepare histogram
	hist = file.Get("hoMuonAnalyzer/etaPhi/3D/NoTrgTdmiAboveThr_EtaPhiPt")

	stack = THStack(hist,"zx","2dStack","",-1,-1,-1,-1,"zx","")

	#Create new histogram and add the histograms from the stack
	histNew = TH2D("histPtEtaHoMatch","p_{T} vs. #eta distribution;#eta;p_{T} / 5 GeV;#",40,-1.6,1.6,40,0,200)
	histNew.GetYaxis().SetTitleOffset(1.2)
	for i in stack.GetHists():
		histNew.Add(i)

	gStyle.SetPalette(1)
	histNew.SetStats(0)
	histNew.Draw('COLZ')
	canvas.Update()

	palette = histNew.FindObject("palette")
	palette.SetX1NDC(0.9)
	palette.SetX2NDC(0.92)
	#add label
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
	canvas.Update()
	canvas.SaveAs('plots/NoL1HoMatchPtEta.pdf')
	canvas.SaveAs('plots/NoL1HoMatchPtEta.png')
	return canvas,hist,stack,histNew,label,palette,file
コード例 #7
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
コード例 #8
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
コード例 #9
0
def doPlotGenPt(filename):
	PlotStyle.setPlotStyle()
	
	if(DEBUG):
		print 'Opening file:',filename
	file = TFile.Open(filename)
	if(file == None):
		print 'Error opening file:',filename

	c = TCanvas('genPtCanvas','Gen Pt no Single #mu trg',1200,1200)
	c.cd().SetLeftMargin(0.15)
	genPtHist = file.Get("hoMuonAnalyzer/NoSingleMu_Pt")
	genPtHist.SetLineColor(PlotStyle.colorRwthDarkBlue)
	genPtHist.SetLineWidth(3)
	genPtHist.Rebin(50)
	genPtHist.Sumw2()
	genPtHist.Scale(1/genPtHist.Integral())
	genPtHist.GetXaxis().SetRangeUser(0,200)
	genPtHist.GetYaxis().SetTitle('normalized entries / 5 GeV')
	genPtHist.GetYaxis().SetTitleOffset(2)
	genPtHist.GetXaxis().SetTitle('p_{T} Gen / GeV')
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
	genPtHist.Draw("ehist")
	
	c.Update()
	
	stats = genPtHist.GetListOfFunctions().FindObject("stats")
	stats.SetOptStat(10)
	stats.SetX1NDC(.7)
	stats.SetX2NDC(.9)
	stats.SetY1NDC(.85)
	stats.SetY2NDC(.9)
	
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
	c.SaveAs('plots/genPtNoSingleMuTrg.png')
	c.SaveAs('plots/genPtNoSingleMuTrg.pdf')
	
	return
コード例 #10
0
def doPlotGenPt(filename):
    PlotStyle.setPlotStyle()

    if (DEBUG):
        print 'Opening file:', filename
    file = TFile.Open(filename)
    if (file == None):
        print 'Error opening file:', filename

    c = TCanvas('genPtCanvas', 'Gen Pt no Single #mu trg', 1200, 1200)
    c.cd().SetLeftMargin(0.15)
    genPtHist = file.Get("hoMuonAnalyzer/NoSingleMu_Pt")
    genPtHist.SetLineColor(PlotStyle.colorRwthDarkBlue)
    genPtHist.SetLineWidth(3)
    genPtHist.Rebin(50)
    genPtHist.Sumw2()
    genPtHist.Scale(1 / genPtHist.Integral())
    genPtHist.GetXaxis().SetRangeUser(0, 200)
    genPtHist.GetYaxis().SetTitle('normalized entries / 5 GeV')
    genPtHist.GetYaxis().SetTitleOffset(2)
    genPtHist.GetXaxis().SetTitle('p_{T} Gen / GeV')
    label = PlotStyle.getLabelCmsPrivateSimulation()
    label.Draw()

    genPtHist.Draw("ehist")

    c.Update()

    stats = genPtHist.GetListOfFunctions().FindObject("stats")
    stats.SetOptStat(10)
    stats.SetX1NDC(.7)
    stats.SetX2NDC(.9)
    stats.SetY1NDC(.85)
    stats.SetY2NDC(.9)

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

    c.SaveAs('plots/genPtNoSingleMuTrg.png')
    c.SaveAs('plots/genPtNoSingleMuTrg.pdf')

    return
コード例 #11
0
def plotAllEventsInAcceptance():
	c = TCanvas("c","c",1200,1200)
	gTdmiInGa = file.Get("hoMuonAnalyzer/graphs/tdmiInGA")
	gTdmiInGa = PlotStyle.convertToHcalCoords(gTdmiInGa)
	gTdmiInGa.GetXaxis().SetTitle("i#eta / a.u.")
	gTdmiInGa.GetYaxis().SetTitle("i#phi / a.u.")
	gTdmiInGa.SetMarkerStyle(6)
	gTdmiInGa.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	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
	
	chimney1Converted = PlotStyle.convertToHcalCoords(chimney1)
	chimney2Converted = PlotStyle.convertToHcalCoords(chimney2)
	chimney1Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney2Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney1Converted.Draw("same,l")
	chimney2Converted.Draw("same,l")
	
	labelCmsPrivateSimulation = PlotStyle.getLabelCmsPrivateSimulation()
	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/gTdmiInGa.pdf")
	c.SaveAs("plots/graphsEtaPhi/gTdmiInGa.png")
	return c,chimney1Converted,chimney2Converted,gTdmiInGa,pText
コード例 #12
0
def doPlotPhiPtOfFailingMatches():
    file = TFile.Open('L1MuonHistogram.root')
    #Prepare canvas
    canvas = TCanvas("canvasPtPhiHoMatchFail", "PtPhiHoMatchFail", 1200, 1200)
    canvas.cd().Draw()
    #prepare histogram
    hist = file.Get("hoMuonAnalyzer/etaPhi/3D/NoTrgTdmiNotInGA_EtaPhiPt")

    stack = THStack(hist, "zy", "2dStack", "", -1, -1, -1, -1, "zy", "")

    #Create new histogram and add the histograms from the stack
    histNew = TH2D(
        "histPtEtaHoMatchFail",
        "p_{T} vs. #phi distribution for events not in HO acceptance;#phi;p_{T} / 5 GeV;#",
        80, -3.2, 3.2, 40, 0, 200)
    histNew.GetYaxis().SetTitleOffset(1.2)
    histNew.Sumw2()
    for i in stack.GetHists():
        histNew.Add(i)

    gStyle.SetPalette(1)
    histNew.SetStats(0)
    PlotStyle.setupAxes(histNew)
    histNew.Draw('COLZ')
    canvas.Update()

    palette = histNew.FindObject("palette")
    palette.SetX1NDC(0.9)
    palette.SetX2NDC(0.92)
    #add label
    label = PlotStyle.getLabelCmsPrivateSimulation()
    label.Draw()

    canvas.Update()
    canvas.SaveAs('plots/NoL1NotInHoAcceptancePhiPt.pdf')
    canvas.SaveAs('plots/NoL1NotInHoAcceptancePhiPt.png')
    return canvas, hist, stack, histNew, label, palette, file
コード例 #13
0
def plotDeltaEtaDeltaPhi(folder,sourceHistogram = 'L1MuonWithHoMatch_DeltaEtaDeltaPhi', sourceFile = 'L1MuonHistogram.root',storeSubdir = 'deltaEtaDeltaPhi'):

	if(DEBUG):
		print prefix + 'was called'

	if(folder == None):
		print prefix + 'Error! Filename as first argument needed.'
		return
	if( not os.path.exists('plots')):
	    os.mkdir('plots')
	if( not os.path.exists('plots/' + storeSubdir)):
		os.mkdir('plots/' + storeSubdir)
        
	filename = folder + '/' + sourceFile
	if( not os.path.exists(filename)):
		print 'Error! File ' + filename + ' does not exist!'
		return
	print prefix + 'Opening file:',filename

	file = TFile.Open(filename)
	PlotStyle.setPlotStyle()
	h2dDeltaEtaDeltaPhi = file.Get("hoMuonAnalyzer/etaPhi/" + sourceHistogram)
	hEventCount = file.Get("hoMuonAnalyzer/count/Events_Count")
	hNoTrgCount = file.Get("hoMuonAnalyzer/count/NoSingleMu_Count")
	if(h2dDeltaEtaDeltaPhi == None):
		print 'Could not get histogram %s from file %s'%("hoMuonAnalyzer/etaPhi/" + sourceHistogram,filename)
	
	canv = TCanvas("canvasDeltaEtaDeltaPhi" + sourceHistogram,'canvasDeltaEtaDeltaPhi',1200,1200)
	canv.SetLogz()
	h2dDeltaEtaDeltaPhi.GetXaxis().SetRangeUser(-.45,.45)
	h2dDeltaEtaDeltaPhi.GetXaxis().SetTitle("#Delta#eta")
	h2dDeltaEtaDeltaPhi.GetYaxis().SetRangeUser(-.45,.45)
	h2dDeltaEtaDeltaPhi.GetYaxis().SetTitle("#Delta#phi")
	h2dDeltaEtaDeltaPhi.GetZaxis().SetTitle("N")
	h2dDeltaEtaDeltaPhi.Draw("colz")
	boxList = drawHoBoxes(canv)

	canv.Update()
	pal = h2dDeltaEtaDeltaPhi.GetListOfFunctions().FindObject("palette")
	pal.SetX2NDC(0.92)

	stats = h2dDeltaEtaDeltaPhi.GetListOfFunctions().FindObject("stats")
	stats.SetX1NDC(.1)
	stats.SetX2NDC(.2)
	stats.SetY1NDC(.1)
	stats.SetY2NDC(.25)

	paveText = TPaveText(0.2,0.1,0.65,0.2,'NDC')
	paveText.AddText('Total Events: %d' % (hEventCount.GetBinContent(2)))
	paveText.AddText('Events with no Single #mu Trg: %d' % (hNoTrgCount.GetBinContent(2)))
	paveText.SetBorderSize(1)
	paveText.Draw()

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

	legend = TLegend(0.7,0.8,0.9,0.9)
	legend.AddEntry(boxList[0],"HO tile dimensions","le")
	legend.Draw()

	canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".png")
	canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".pdf")
	canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".root")
	SetOwnership(h2dDeltaEtaDeltaPhi,False)
	return [h2dDeltaEtaDeltaPhi,canv,legend,boxList,stats,pal,paveText,label]
コード例 #14
0
def doPlotCutflow(filename='L1MuonHistogram.root'):
	
	PlotStyle.setPlotStyle()
	
	if(DEBUG):
		print 'Opening file:',filename
	file = TFile.Open(filename)
	if(file == None):
		print 'Error opening file:',filename
	
	#Total event count
	tagEvents = 'hoMuonAnalyzer/count/Events_Count'	
	tagL1Muons = 'hoMuonAnalyzer/count/L1MuonPresent_Count'
	
	#Counters without energy threshold
	tagHo1 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatch_Count'
	tagHo2 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAcc_Count'
	tagHo3 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAccNotDead_Count'
	tagHo4 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAccThr_Count'
	
	#Counters with energy threshold
	tagThr1 = 'hoMuonAnalyzer/count/L1MuonAboveThr_Count'
	tagThr2 = 'hoMuonAnalyzer/count/L1MuonAboveThrInAcc_Count'
	tagThr3 = 'hoMuonAnalyzer/count/L1MuonAboveThrInAccNotDead_Count'
	
	histEvents = file.Get(tagEvents)
	histL1Muons = file.Get(tagL1Muons)

	histHo1 = file.Get(tagHo1)
	histHo2 = file.Get(tagHo2)
	histHo3 = file.Get(tagHo3)
	histHo4 = file.Get(tagHo4)
	
	histThr1 = file.Get(tagThr1)
	histThr2 = file.Get(tagThr2)
	histThr3 = file.Get(tagThr3)

	yValues = [
			histEvents.GetBinContent(2),
			histL1Muons.GetBinContent(2),
			histHo1.GetBinContent(2),
#			histHo2.GetBinContent(2),
#			histHo3.GetBinContent(2),
			histThr1.GetBinContent(2),
			histThr2.GetBinContent(2),
			histThr3.GetBinContent(2)
			]
	
	xLabels = [
			'Event count',
			'L1Muon objects',
			'HO match (No Thr.)',
			'HO match > 0.2 GeV',
	#		'+ HO acceptance'
			]
	
	norm = yValues[0]
	for i,v in enumerate(yValues):
		yValues[i] = v/norm
	
	c = TCanvas('cutflowCanvas','PostLS1 Single #mu gun',1200,1200)

	hist = TH1D("cutflow","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.GetYaxis().SetTitle('rel. Fraction')
	hist.GetYaxis().SetRangeUser(0.7,1.1)
	hist.SetLineColor(PlotStyle.colorRwthDarkBlue)
	hist.SetLabelFont(62)
	hist.SetTitleFont(62)	
	hist.Draw("")

	histTrgCount = file.Get('hoMuonAnalyzer/count/L1_SingleMuOpen_Count')

	hist2 = TH1D("l1TrgCount","PostLS1 Single #mu gun",len(xLabels),0,len(xLabels))
	hist2.SetBinContent(1,histTrgCount.GetBinContent(2)/norm)
	hist2.SetFillStyle(3002)
	hist2.SetFillColor(PlotStyle.colorRwthMagenta)
	hist2.SetLineColor(PlotStyle.colorRwthMagenta)
	hist2.Draw("same")
	
	paveText = TPaveText(0.51,0.75,0.9,0.9,'NDC')
	paveText.AddText('%s: %.2f%% #pm %.2f%%' % (xLabels[1],yValues[1]*100,calcSigma(yValues[1]*norm,norm)*100))
	paveText.AddText('%s: %.2f%% #pm %.2f%%' % (xLabels[2],yValues[2]*100,calcSigma(yValues[2]*norm,norm)*100))
	paveText.AddText('%s: %.2f%% #pm %.2f%%' % (xLabels[3],yValues[3]*100,calcSigma(yValues[3]*norm,norm)*100))
	paveText.SetBorderSize(1)
	paveText.Draw()
	
	legend = TLegend(0.1,0.8,0.45,0.9)
	legend.AddEntry(hist2,"Fraction with L1 Single #mu Trg.","f")
	legend.Draw()
	
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
	c.Update()
	c.SaveAs("plots/cutflow/cutflowL1.png")
	c.SaveAs("plots/cutflow/cutflowL1.pdf")
	c.SaveAs("plots/cutflow/cutflowL1.root")
	
	nTotal = histEvents.GetBinContent(2)
	nL1 = histL1Muons.GetBinContent(2)
	
	nL1AndHo 				= histHo1.GetBinContent(2)
	nL1AndHoAcc				= histHo2.GetBinContent(2)
	nL1AndHoAccNotDead		= histHo3.GetBinContent(2)
	nL1AndHoAccThr			= histHo4.GetBinContent(2)
	nL1AndHoThr				= histThr1.GetBinContent(2)
	nL1AndHoThrAcc			= histThr2.GetBinContent(2)
	nL1AndHoThrAccNotDead	= histThr3.GetBinContent(2)
	
	print '%s' % (80*'#')
	print '%s' % (80*'#')
	
	print '%25s%d' % ('nEvents:\t',nTotal)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('nL1:\t',nL1,nL1/nTotal*100,calcSigma(nL1, nTotal)*100)
	
	print '%s' % (80*'#')
	
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHo:\t',nL1AndHo,nL1AndHo/nL1*100,calcSigma(nL1AndHo, nL1)*100)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoAcc:\t',nL1AndHoAcc,nL1AndHoAcc/nL1*100,calcSigma(nL1AndHoAcc, nL1)*100)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoAccNotDead:\t',nL1AndHoAccNotDead,nL1AndHoAccNotDead/nL1*100,calcSigma(nL1AndHoAccNotDead, nL1)*100)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoAccThr:\t',nL1AndHoAccThr,nL1AndHoAccThr/nL1*100,calcSigma(nL1AndHoAccThr, nL1)*100)
	
	print '%s' % (80*'#')
	
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoThr:\t',nL1AndHoThr,nL1AndHoThr/nL1*100,calcSigma(nL1AndHoThr, nL1)*100)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoThrAcc:\t',nL1AndHoThrAcc,nL1AndHoThrAcc/nL1*100,calcSigma(nL1AndHoThrAcc,nL1)*100)
	print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoThrAccNotDead:\t',nL1AndHoThrAccNotDead,nL1AndHoThrAccNotDead/nL1*100,calcSigma(nL1AndHoThrAccNotDead, nL1)*100)
	
	print '%s' % (80*'#')
	print '%s' % (80*'#')
											
	return c
コード例 #15
0
def doPlotCutflowNoL1(filename = 'L1MuonHistogram.root'):
	if(DEBUG):
		print 'Opening file:',filename
	file = TFile.Open(filename)
	if(file == None):
		print 'Error opening file:',filename
	histoNames = [
				'hoMuonAnalyzer/count/NoSingleMu_Count',
				'hoMuonAnalyzer/count/NoSingleMuInGa_Count',
				'hoMuonAnalyzer/count/NoSingleMuInGa5x5_Count',
				'hoMuonAnalyzer/count/NoSingleMuInGa3x3_Count',
				'hoMuonAnalyzer/count/NoSingleMuInGaCentral_Count',
				'hoMuonAnalyzer/count/Events_Count'
				]
	
	histograms = []
	yValues = []
	
	for s in histoNames:
		histograms.append(file.Get(s))
		yValues.append(histograms[-1].GetBinContent(2))
	
	nEvents = histograms[-1].GetEntries()

	xLabels = [
	 		'No Single #mu trigger',
			'TDMI in GA',
			'HO > 0.2 GeV in 5x5',
			'HO > 0.2 GeV in 3x3',
			'HO > 0.2 GeV in Central'
			]
	
	c = TCanvas('eventCountCanvas','PostLS1 Single #mu gun',1200,1200)

	hist = TH1D("eventCount","PostLS1 Single #mu gun",len(xLabels)-1,0,len(xLabels))
	
	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[2],yValues[2],yValues[2]/yValues[1]*100,calcSigma(yValues[2], yValues[1])*100))
	paveText.AddText('%s: %d => %.2f%% #pm %.2f%%' % (xLabels[4],yValues[4],yValues[4]/yValues[1]*100,calcSigma(yValues[4], yValues[1])*100))
	paveText.SetBorderSize(1)
	
	print yValues[1]
	
	norm = yValues[1]
	
	for i,v in enumerate(xLabels):
		if(i == 0):
			continue
		hist.SetBinContent(i,yValues[i]/norm)
		hist.GetXaxis().SetBinLabel(i,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.SetMinimum(0)
	

	print yValues



	hist.Draw("")
	paveText.Draw()
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
		
	c.Update()

	c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.png")
	c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.pdf")
	c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.root")

	return c,hist
コード例 #16
0
def plotDeltaEtaDeltaPhi(folder,
                         sourceHistogram='L1MuonWithHoMatch_DeltaEtaDeltaPhi',
                         sourceFile='L1MuonHistogram.root',
                         storeSubdir='deltaEtaDeltaPhi'):

    if (DEBUG):
        print prefix + 'was called'

    if (folder == None):
        print prefix + 'Error! Filename as first argument needed.'
        return
    if (not os.path.exists('plots')):
        os.mkdir('plots')
    if (not os.path.exists('plots/' + storeSubdir)):
        os.mkdir('plots/' + storeSubdir)

    filename = folder + '/' + sourceFile
    if (not os.path.exists(filename)):
        print 'Error! File ' + filename + ' does not exist!'
        return
    print prefix + 'Opening file:', filename

    file = TFile.Open(filename)
    PlotStyle.setPlotStyle()
    h2dDeltaEtaDeltaPhi = file.Get("hoMuonAnalyzer/etaPhi/" + sourceHistogram)
    hEventCount = file.Get("hoMuonAnalyzer/count/Events_Count")
    hNoTrgCount = file.Get("hoMuonAnalyzer/count/NoSingleMu_Count")
    if (h2dDeltaEtaDeltaPhi == None):
        print 'Could not get histogram %s from file %s' % (
            "hoMuonAnalyzer/etaPhi/" + sourceHistogram, filename)

    canv = TCanvas("canvasDeltaEtaDeltaPhi" + sourceHistogram,
                   'canvasDeltaEtaDeltaPhi', 1200, 1200)
    canv.SetLogz()
    h2dDeltaEtaDeltaPhi.GetXaxis().SetRangeUser(-.45, .45)
    h2dDeltaEtaDeltaPhi.GetXaxis().SetTitle("#Delta#eta")
    h2dDeltaEtaDeltaPhi.GetYaxis().SetRangeUser(-.45, .45)
    h2dDeltaEtaDeltaPhi.GetYaxis().SetTitle("#Delta#phi")
    h2dDeltaEtaDeltaPhi.GetZaxis().SetTitle("N")
    h2dDeltaEtaDeltaPhi.Draw("colz")
    boxList = drawHoBoxes(canv)

    canv.Update()
    pal = h2dDeltaEtaDeltaPhi.GetListOfFunctions().FindObject("palette")
    pal.SetX2NDC(0.92)

    stats = h2dDeltaEtaDeltaPhi.GetListOfFunctions().FindObject("stats")
    stats.SetX1NDC(.1)
    stats.SetX2NDC(.2)
    stats.SetY1NDC(.1)
    stats.SetY2NDC(.25)

    paveText = TPaveText(0.2, 0.1, 0.65, 0.2, 'NDC')
    paveText.AddText('Total Events: %d' % (hEventCount.GetBinContent(2)))
    paveText.AddText('Events with no Single #mu Trg: %d' %
                     (hNoTrgCount.GetBinContent(2)))
    paveText.SetBorderSize(1)
    paveText.Draw()

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

    legend = TLegend(0.7, 0.8, 0.9, 0.9)
    legend.AddEntry(boxList[0], "HO tile dimensions", "le")
    legend.Draw()

    canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".png")
    canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".pdf")
    canv.SaveAs("plots/" + storeSubdir + "/" + sourceHistogram + ".root")
    SetOwnership(h2dDeltaEtaDeltaPhi, False)
    return [
        h2dDeltaEtaDeltaPhi, canv, legend, boxList, stats, pal, paveText, label
    ]
コード例 #17
0
def plotFailedHoMatchesNoTrg():
	c = TCanvas("cFailedHoMatchesNoTrg","cFailedHoMatchesNoTrg",1200,1200)
	c.cd().SetRightMargin(0.25)
	c.cd().SetLeftMargin(0.08)
	
	#Graph for in events not in geometric acceptance
	grNotInGaNC = file.Get("hoMuonAnalyzer/graphs/NoTrgTdmiNotInGA")
	grNotInGa = PlotStyle.convertToHcalCoords(grNotInGaNC)
	grNotInGa.GetYaxis().SetTitle("i#phi / a.u.")
	grNotInGa.GetXaxis().SetTitle("i#eta / a.u.")
	grNotInGa.GetYaxis().SetTitleFont(62)
	grNotInGa.GetYaxis().SetLabelFont(62)
	grNotInGa.SetMarkerStyle(6)
	grNotInGa.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	grNotInGa.SetTitle("#eta #phi plot failed HO matches in no Single #mu Trg. events")
	grNotInGa.Draw("AP")
	
	#Graph of events with HO match below threshold
	grHoBelowThrNC = file.Get("hoMuonAnalyzer/graphs/NoTrgTdmiBelowThr")
	grHoBelowThr = PlotStyle.convertToHcalCoords(grHoBelowThrNC)
	grHoBelowThr.SetMarkerStyle(20)
	grHoBelowThr.SetMarkerSize(1.2)
	grHoBelowThr.SetMarkerColor( PlotStyle.colorRwthGruen )
	grHoBelowThr.Draw("samep")
	
	#Graph for events where HO matching failed
	grHoMatchFailNC = file.Get("hoMuonAnalyzer/graphs/NoTrgHoMatchFail")
	grHoMatchFail = PlotStyle.convertToHcalCoords(grHoMatchFailNC)
	grHoMatchFail.SetMarkerStyle(21)
	grHoMatchFail.SetMarkerSize(1)
	grHoMatchFail.SetMarkerColor( PlotStyle.colorRwthRot )
	grHoMatchFail.Draw("samep")
	
	#Draw chimneys
	chimney1Converted = PlotStyle.convertToHcalCoords(PlotStyle.chimney1)
	chimney2Converted = PlotStyle.convertToHcalCoords(PlotStyle.chimney2)
	chimney1Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney2Converted.SetLineColor(PlotStyle.colorRwthMagenta)
	chimney1Converted.Draw('same')
	chimney2Converted.Draw('same')
	
	#cms private label
	label = TPaveText(PlotStyle.getLabelCmsPrivateSimulation(x1ndc=0.5,x2ndc=0.75))
	label.Draw()
	
	#create extra marker for the legend
	marker = TMarker(1,1,2)
	marker.SetMarkerSize(3)
	marker.SetMarkerColor(PlotStyle.colorRwthDarkBlue)
	
	#legend
	legend = TLegend(0.75,0.8,0.99,0.9)
	legend.AddEntry(chimney2Converted,"chimney","l")
	legend.AddEntry(marker,'Not in GA','p')
	legend.AddEntry(grHoMatchFail,'HO match fail','p')
	legend.AddEntry(grHoBelowThr,'HO match < 0.2 GeV','p')
	legend.Draw()
	
	nNotMatching = grHoMatchFail.GetN()
	nNotInGa = grNotInGa.GetN()
	nBelowThr = grHoBelowThr.GetN()
	nTotal = nNotMatching + nNotInGa + nBelowThr
	
	print 80*'#'
	print 'Not Matching:\t%5d/%d\t=> %5.2f%% +- %f%%' % (nNotMatching,nTotal,nNotMatching/float(nTotal)*100,PlotStyle.calcSigma(nNotMatching,float(nTotal)))
	print 'Not in GA:\t%5d/%d\t=> %5.2f%% +- %f%%' % (nNotInGa,nTotal,nNotInGa/float(nTotal)*100,PlotStyle.calcSigma(nNotInGa,float(nTotal)))
	print 'Below Thr:\t%5d/%d\t=> %5.2f%% +- %f%%' % (nBelowThr,nTotal,nBelowThr/float(nTotal)*100,PlotStyle.calcSigma(nBelowThr,float(nTotal)))
	print 80*'#'
	
	c.Update()
	c.SaveAs('plots/graphsEtaPhi/gNoTrgHoMatchingFailed.png')
	c.SaveAs('plots/graphsEtaPhi/gNoTrgHoMatchingFailed.pdf')
	return c,grNotInGa,label,chimney1Converted,chimney2Converted,legend,grHoMatchFail,grHoBelowThr
コード例 #18
0
def plotDigiTest():
	#Prepare canvas
	PlotStyle.setPlotStyle()
	canvas = TCanvas("canvasBxId","BXID",1200,1200)
	canvas.SetLogy()
	histBx = file.Get("hoMuonAnalyzer/hoDigi_BxId")
	histBx.GetXaxis().SetRangeUser(-3,3)
	histBx.SetLineWidth(3)
	histBx.Scale(1/histBx.Integral())
	histBx.SetStats(0)
	histBx.SetLineColor(PlotStyle.colorRwthDarkBlue)
	
	
	histBx.Draw('')	

	#Add label
	label = PlotStyle.getLabelCmsPrivateSimulation()
	label.Draw()
	
# 	#Add legend
# 	legend = TLegend(0.7,0.65,0.9,0.8)
# 	legend.AddEntry(histBx,"DT Only","l")
# 	legend.AddEntry(histNew,"DT shifted with HO","l")
# 	legend.SetBorderSize(1)
# 	legend.Draw()
	
# 	#Add text object
# 	pText = TPaveText(0.52,0.8,0.9,0.9,'NDC')
# 	pText.AddText('Fraction in BX ID 0: %6.3f%% #pm %6.3f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)))
# 	pText.AddText('Fraction in BX ID 0 (HO corr.): %6.3f%% #pm %6.3f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)))
# 	pText.SetBorderSize(1)
# 	pText.SetFillColor(0)
# 	pText.Draw()
# 	
 	pText2 = TPaveText(0.7,0.85,0.9,0.9,'NDC')
 	pText2.AddText('Entries: %d' % (histBx.GetEntries()))
 	pText2.SetBorderSize(1)
 	pText2.SetFillColor(0)
 	pText2.Draw()
	
	canvas.Update()
	canvas.SaveAs('plots/timing/digiBxId.pdf')
	canvas.SaveAs('plots/timing/digiBxId.png')

	canvasAdcSum = TCanvas("cavasAdcSum","ADC Sum",1200,1200)
	canvasAdcSum.SetLogy()
	histAdcSum = file.Get("hoMuonAnalyzer/hoDigiAdcSum_Multiplicity")
	histAdcSum.GetXaxis().SetRangeUser(-0.5,500)
	histAdcSum.GetXaxis().SetTitle('ADC counts')
	histAdcSum.GetYaxis().SetTitle('#')
	histAdcSum.SetLineWidth(3)
	histAdcSum.SetStats(0)
	histAdcSum.SetLineColor(PlotStyle.colorRwthDarkBlue)
	histAdcSum.Draw()
	canvasAdcSum.Update()
	canvasAdcSum.SaveAs('plots/timing/digiAdcSum.pdf')
	canvasAdcSum.SaveAs('plots/timing/digiAdcSum.png')

	canvasTS4 = TCanvas("cavasTS4","TS4",1200,1200)
	canvasTS4.SetLogy()
	histAdcTS4 = file.Get("hoMuonAnalyzer/hoDigiAdcTS4_Multiplicity")
	histAdcTS4.GetXaxis().SetRangeUser(-0.5,500)
	histAdcTS4.GetXaxis().SetTitle('ADC counts')
	histAdcTS4.GetYaxis().SetTitle('#')
	histAdcTS4.SetLineWidth(3)
	histAdcTS4.SetStats(0)
	histAdcTS4.SetLineColor(PlotStyle.colorRwthDarkBlue)
	histAdcTS4.Draw()
	canvasTS4.Update()
	canvasTS4.SaveAs('plots/timing/digiAdcTs4.pdf')
	canvasTS4.SaveAs('plots/timing/digiAdcTs4.png')

	print histAdcSum.Integral(histAdcSum.FindBin(17),histAdcSum.FindBin(500))

	return canvas, histBx,label,canvasAdcSum,histAdcSum,canvasTS4,histAdcTS4
コード例 #19
0
def plotDigiTest():
    #Prepare canvas
    PlotStyle.setPlotStyle()
    canvas = TCanvas("canvasBxId", "BXID", 1200, 1200)
    canvas.SetLogy()
    histBx = file.Get("hoMuonAnalyzer/hoDigi_BxId")
    histBx.GetXaxis().SetRangeUser(-3, 3)
    histBx.SetLineWidth(3)
    histBx.Scale(1 / histBx.Integral())
    histBx.SetStats(0)
    histBx.SetLineColor(PlotStyle.colorRwthDarkBlue)

    histBx.Draw('')

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

    # 	#Add legend
    # 	legend = TLegend(0.7,0.65,0.9,0.8)
    # 	legend.AddEntry(histBx,"DT Only","l")
    # 	legend.AddEntry(histNew,"DT shifted with HO","l")
    # 	legend.SetBorderSize(1)
    # 	legend.Draw()

    # 	#Add text object
    # 	pText = TPaveText(0.52,0.8,0.9,0.9,'NDC')
    # 	pText.AddText('Fraction in BX ID 0: %6.3f%% #pm %6.3f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)))
    # 	pText.AddText('Fraction in BX ID 0 (HO corr.): %6.3f%% #pm %6.3f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)))
    # 	pText.SetBorderSize(1)
    # 	pText.SetFillColor(0)
    # 	pText.Draw()
    #
    pText2 = TPaveText(0.7, 0.85, 0.9, 0.9, 'NDC')
    pText2.AddText('Entries: %d' % (histBx.GetEntries()))
    pText2.SetBorderSize(1)
    pText2.SetFillColor(0)
    pText2.Draw()

    canvas.Update()
    canvas.SaveAs('plots/timing/digiBxId.pdf')
    canvas.SaveAs('plots/timing/digiBxId.png')

    canvasAdcSum = TCanvas("cavasAdcSum", "ADC Sum", 1200, 1200)
    canvasAdcSum.SetLogy()
    histAdcSum = file.Get("hoMuonAnalyzer/hoDigiAdcSum_Multiplicity")
    histAdcSum.GetXaxis().SetRangeUser(-0.5, 500)
    histAdcSum.GetXaxis().SetTitle('ADC counts')
    histAdcSum.GetYaxis().SetTitle('#')
    histAdcSum.SetLineWidth(3)
    histAdcSum.SetStats(0)
    histAdcSum.SetLineColor(PlotStyle.colorRwthDarkBlue)
    histAdcSum.Draw()
    canvasAdcSum.Update()
    canvasAdcSum.SaveAs('plots/timing/digiAdcSum.pdf')
    canvasAdcSum.SaveAs('plots/timing/digiAdcSum.png')

    canvasTS4 = TCanvas("cavasTS4", "TS4", 1200, 1200)
    canvasTS4.SetLogy()
    histAdcTS4 = file.Get("hoMuonAnalyzer/hoDigiAdcTS4_Multiplicity")
    histAdcTS4.GetXaxis().SetRangeUser(-0.5, 500)
    histAdcTS4.GetXaxis().SetTitle('ADC counts')
    histAdcTS4.GetYaxis().SetTitle('#')
    histAdcTS4.SetLineWidth(3)
    histAdcTS4.SetStats(0)
    histAdcTS4.SetLineColor(PlotStyle.colorRwthDarkBlue)
    histAdcTS4.Draw()
    canvasTS4.Update()
    canvasTS4.SaveAs('plots/timing/digiAdcTs4.pdf')
    canvasTS4.SaveAs('plots/timing/digiAdcTs4.png')

    print histAdcSum.Integral(histAdcSum.FindBin(17), histAdcSum.FindBin(500))

    return canvas, histBx, label, canvasAdcSum, histAdcSum, canvasTS4, histAdcTS4
コード例 #20
0
def doPlotCutflowNoL1(filename='L1MuonHistogram.root'):
    if (DEBUG):
        print 'Opening file:', filename
    file = TFile.Open(filename)
    if (file == None):
        print 'Error opening file:', filename
    histoNames = [
        'hoMuonAnalyzer/count/NoSingleMu_Count',
        'hoMuonAnalyzer/count/NoSingleMuInGa_Count',
        'hoMuonAnalyzer/count/NoSingleMuInGa5x5_Count',
        'hoMuonAnalyzer/count/NoSingleMuInGa3x3_Count',
        'hoMuonAnalyzer/count/NoSingleMuInGaCentral_Count',
        'hoMuonAnalyzer/count/Events_Count'
    ]

    histograms = []
    yValues = []

    for s in histoNames:
        histograms.append(file.Get(s))
        yValues.append(histograms[-1].GetBinContent(2))

    nEvents = histograms[-1].GetEntries()

    xLabels = [
        'No Single #mu trigger', 'TDMI in GA', 'HO > 0.2 GeV in 5x5',
        'HO > 0.2 GeV in 3x3', 'HO > 0.2 GeV in Central'
    ]

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

    hist = TH1D("eventCount", "PostLS1 Single #mu gun",
                len(xLabels) - 1, 0, len(xLabels))

    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[2], yValues[2], yValues[2] / yValues[1] * 100,
                      calcSigma(yValues[2], yValues[1]) * 100))
    paveText.AddText('%s: %d => %.2f%% #pm %.2f%%' %
                     (xLabels[4], yValues[4], yValues[4] / yValues[1] * 100,
                      calcSigma(yValues[4], yValues[1]) * 100))
    paveText.SetBorderSize(1)

    print yValues[1]

    norm = yValues[1]

    for i, v in enumerate(xLabels):
        if (i == 0):
            continue
        hist.SetBinContent(i, yValues[i] / norm)
        hist.GetXaxis().SetBinLabel(i, 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.SetMinimum(0)

    hist.Draw("")
    paveText.Draw()
    label = PlotStyle.getLabelCmsPrivateSimulation()
    label.Draw()

    c.Update()

    c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.png")
    c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.pdf")
    c.SaveAs("plots/cutflow/cutflowTdmiNoTrg.root")

    return c, hist
コード例 #21
0
def doPlotCutflow(filename='L1MuonHistogram.root'):

    PlotStyle.setPlotStyle()

    if (DEBUG):
        print 'Opening file:', filename
    file = TFile.Open(filename)
    if (file == None):
        print 'Error opening file:', filename

    #Total event count
    tagEvents = 'hoMuonAnalyzer/count/Events_Count'
    tagL1Muons = 'hoMuonAnalyzer/count/L1MuonPresent_Count'

    #Counters without energy threshold
    tagHo1 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatch_Count'
    tagHo2 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAcc_Count'
    tagHo3 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAccNotDead_Count'
    tagHo4 = 'hoMuonAnalyzer/count/L1MuonPresentHoMatchInAccThr_Count'

    #Counters with energy threshold
    tagThr1 = 'hoMuonAnalyzer/count/L1MuonAboveThr_Count'
    tagThr2 = 'hoMuonAnalyzer/count/L1MuonAboveThrInAcc_Count'
    tagThr3 = 'hoMuonAnalyzer/count/L1MuonAboveThrInAccNotDead_Count'

    histEvents = file.Get(tagEvents)
    histL1Muons = file.Get(tagL1Muons)

    histHo1 = file.Get(tagHo1)
    histHo2 = file.Get(tagHo2)
    histHo3 = file.Get(tagHo3)
    histHo4 = file.Get(tagHo4)

    histThr1 = file.Get(tagThr1)
    histThr2 = file.Get(tagThr2)
    histThr3 = file.Get(tagThr3)

    yValues = [
        histEvents.GetBinContent(2),
        histL1Muons.GetBinContent(2),
        histHo1.GetBinContent(2),
        #			histHo2.GetBinContent(2),
        #			histHo3.GetBinContent(2),
        histThr1.GetBinContent(2),
        histThr2.GetBinContent(2),
        histThr3.GetBinContent(2)
    ]

    xLabels = [
        'Event count',
        'L1Muon objects',
        'HO match (No Thr.)',
        'HO match > 0.2 GeV',
        #		'+ HO acceptance'
    ]

    norm = yValues[0]
    for i, v in enumerate(yValues):
        yValues[i] = v / norm

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

    hist = TH1D("cutflow", "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.GetYaxis().SetTitle('rel. Fraction')
    hist.GetYaxis().SetRangeUser(0.7, 1.1)
    hist.SetLineColor(PlotStyle.colorRwthDarkBlue)
    hist.SetLabelFont(62)
    hist.SetTitleFont(62)
    hist.Draw("")

    histTrgCount = file.Get('hoMuonAnalyzer/count/L1_SingleMuOpen_Count')

    hist2 = TH1D("l1TrgCount", "PostLS1 Single #mu gun", len(xLabels), 0,
                 len(xLabels))
    hist2.SetBinContent(1, histTrgCount.GetBinContent(2) / norm)
    hist2.SetFillStyle(3002)
    hist2.SetFillColor(PlotStyle.colorRwthMagenta)
    hist2.SetLineColor(PlotStyle.colorRwthMagenta)
    hist2.Draw("same")

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

    legend = TLegend(0.1, 0.8, 0.45, 0.9)
    legend.AddEntry(hist2, "Fraction with L1 Single #mu Trg.", "f")
    legend.Draw()

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

    c.Update()
    c.SaveAs("plots/cutflow/cutflowL1.png")
    c.SaveAs("plots/cutflow/cutflowL1.pdf")
    c.SaveAs("plots/cutflow/cutflowL1.root")

    nTotal = histEvents.GetBinContent(2)
    nL1 = histL1Muons.GetBinContent(2)

    nL1AndHo = histHo1.GetBinContent(2)
    nL1AndHoAcc = histHo2.GetBinContent(2)
    nL1AndHoAccNotDead = histHo3.GetBinContent(2)
    nL1AndHoAccThr = histHo4.GetBinContent(2)
    nL1AndHoThr = histThr1.GetBinContent(2)
    nL1AndHoThrAcc = histThr2.GetBinContent(2)
    nL1AndHoThrAccNotDead = histThr3.GetBinContent(2)

    print '%s' % (80 * '#')
    print '%s' % (80 * '#')

    print '%25s%d' % ('nEvents:\t', nTotal)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('nL1:\t', nL1, nL1 / nTotal * 100,
                                             calcSigma(nL1, nTotal) * 100)

    print '%s' % (80 * '#')

    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHo:\t', nL1AndHo,
                                             nL1AndHo / nL1 * 100,
                                             calcSigma(nL1AndHo, nL1) * 100)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoAcc:\t', nL1AndHoAcc,
                                             nL1AndHoAcc / nL1 * 100,
                                             calcSigma(nL1AndHoAcc, nL1) * 100)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % (
        'L1AndHoAccNotDead:\t', nL1AndHoAccNotDead, nL1AndHoAccNotDead / nL1 *
        100, calcSigma(nL1AndHoAccNotDead, nL1) * 100)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % (
        'L1AndHoAccThr:\t', nL1AndHoAccThr, nL1AndHoAccThr / nL1 * 100,
        calcSigma(nL1AndHoAccThr, nL1) * 100)

    print '%s' % (80 * '#')

    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % ('L1AndHoThr:\t', nL1AndHoThr,
                                             nL1AndHoThr / nL1 * 100,
                                             calcSigma(nL1AndHoThr, nL1) * 100)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % (
        'L1AndHoThrAcc:\t', nL1AndHoThrAcc, nL1AndHoThrAcc / nL1 * 100,
        calcSigma(nL1AndHoThrAcc, nL1) * 100)
    print '%25s%d\t=>\t%.2f%% +/- %.2f%%' % (
        'L1AndHoThrAccNotDead:\t', nL1AndHoThrAccNotDead, nL1AndHoThrAccNotDead
        / nL1 * 100, calcSigma(nL1AndHoThrAccNotDead, nL1) * 100)

    print '%s' % (80 * '#')
    print '%s' % (80 * '#')

    return c