def plotCombinedEfficiency():
    hl = plotEfficiency('.')
    canv = TCanvas("canvasCombinedEfficiency", "Combined efficiency plot",
                   1200, 1200)
    leg = TLegend(0.55, 0.1, 0.9, 0.5)
    for i, val in enumerate(hl):
        if (i == 0):
            val[0].Draw()
            val[0].SetTitle("Efficiency for several p_{T}")
        else:
            val[0].Draw('same')
        val[1].Draw('same')

    hl[0][1].SetFillColor(colorRwthMagenta)
    hl[0][0].SetFillColor(colorRwthDarkBlue)
    leg.AddEntry(hl[0][0], "L1", "f")
    leg.AddEntry(hl[0][1], "L1 + HO", "f")
    markers = []
    for i, pair in enumerate(markerpairs):
        markers.append(TMarker(1, 1, pair[0]))
        markers[i].SetMarkerSize(3)
        leg.AddEntry(markers[i], "p_{T} = " + str((i + 1) * 5) + " GeV", "p")
    leg.Draw()

    label = drawLabelCmsPrivateSimulation()

    if (not os.path.exists('plots')):
        os.mkdir('plots')
    if (not os.path.exists('plots/efficiency')):
        os.mkdir('plots/efficiency')

    canv.SaveAs('plots/efficiency/combinedEfficiency.png')
    canv.SaveAs('plots/efficiency/combinedEfficiency.pdf')
    canv.SaveAs('plots/efficiency/combinedEfficiency.root')
    return canv, leg, hl, label
Exemple #2
0
 def drawLabel(self, x1ndc=0.6, y1ndc=0.90, x2ndc=0.9, y2ndc=0.93):
     label = None
     if self.data:
         label = drawLabelCmsPrivateData(x1ndc, y1ndc, x2ndc, y2ndc)
     else:
         label = drawLabelCmsPrivateSimulation(x1ndc, y1ndc, x2ndc, y2ndc)
     return label
def plotCombinedEfficiency():
	hl = plotEfficiency('.')
	canv = TCanvas("canvasCombinedEfficiency","Combined efficiency plot",1200,1200)
	leg = TLegend(0.55,0.1,0.9,0.5)
	for i,val in enumerate(hl):
		if(i == 0):
			val[0].Draw()
			val[0].SetTitle("Efficiency for several p_{T}")
		else:
			val[0].Draw('same')
		val[1].Draw('same')
		
	
	hl[0][1].SetFillColor(colorRwthMagenta)
	hl[0][0].SetFillColor(colorRwthDarkBlue)
	leg.AddEntry(hl[0][0],"L1","f")
	leg.AddEntry(hl[0][1],"L1 + HO","f")
	markers = []
	for i,pair in enumerate(markerpairs):
		markers.append(TMarker(1,1,pair[0]))
		markers[i].SetMarkerSize(3)
		leg.AddEntry(markers[i],"p_{T} = " + str((i+1)*5) + " GeV","p")
	leg.Draw()
	
	label = drawLabelCmsPrivateSimulation()
	
	if( not os.path.exists('plots')):
		os.mkdir('plots')
	if( not os.path.exists('plots/efficiency')):
		os.mkdir('plots/efficiency')
	
	canv.SaveAs('plots/efficiency/combinedEfficiency.png')	
	canv.SaveAs('plots/efficiency/combinedEfficiency.pdf')
	canv.SaveAs('plots/efficiency/combinedEfficiency.root')			
	return canv,leg,hl,label
Exemple #4
0
	def plotL1PerPt(self):
		ptValues = [0.,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,6.0,7.0,8.0,10.0,12.0,14.0,16.0,18.0,20.0,25.0,30.0,35.0,40.0,45.0,50.0,60.0,70.0,80.0,90.0,100.0,120.0,140.0]
		ptBins = [0]
		for i in range(len(ptValues)-1):
			ptBins.append( (ptValues[i]+ptValues[i+1])/2. )
		ptBins.append(200)
		canvas = TCanvas('cL1PerPt')
		hist = TH1D('hist','# L1 per p_{T}',len(ptBins)-1,array('d',ptBins))
		chain = self.fileHandler.getTChain()
		eventCounter = 0
		liste = []
		nEvents = chain.GetEntries()
		for event in chain:
			eventCounter += 1
			for l1 in event.l1MuonData:
				if not l1.pt in liste:
					liste.append(l1.pt)
				hist.Fill(l1.pt)
			if not eventCounter%10000:
				printProgress(eventCounter,nEvents)
			if eventCounter == 50000:
				break
		print
		setupAxes(hist)
		hist.SetStats(0)
		hist.Scale(1,"width")
		hist.Draw()
		
		label = drawLabelCmsPrivateSimulation()
		
		canvas.Update()
		
	#	print liste
		return hist, canvas, label
Exemple #5
0
	def drawLabel(self):
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
		return label
Exemple #6
0
	def plotHoDigiMatchesPerDetId(self):
		canvas = TCanvas('canvasDigiMatchesMultiplicity')
		digiMatches = self.fileHandler.getHistogram('hoDigiMatchesPerDetId_Multiplicity')
		setupAxes(digiMatches)
		digiMatches.SetTitle('Number of matches between RecHit and Digi for a given DetId')
		digiMatches.GetXaxis().SetRangeUser(0,5)
		digiMatches.GetXaxis().SetTitle('Number of matches per DetId')
		digiMatches.GetYaxis().SetTitle('#')
		canvas.cd().SetLogy()
		digiMatches.SetLineWidth(3)
		digiMatches.SetLineColor(colorRwthDarkBlue)
		digiMatches.Draw()
		
		label = drawLabelCmsPrivateSimulation()
		
		canvas.Update()
		
		stats = digiMatches.GetListOfFunctions().FindObject("stats")
		stats.SetX1NDC(.7)
		stats.SetX2NDC(.9)
		stats.SetY1NDC(.75)
		stats.SetY2NDC(.9)
		
		canvas.Update()
		self.storeCanvas(canvas,"digiMatchesPerDetId")
		return canvas,digiMatches,label
Exemple #7
0
	def plotTruthL1Together(self):
		c = TCanvas('cTimeWindowTruthL1',"Time Window Truth L1")
		effL1Muon3x3 = self.fileHandler.getHistogram('hoMuonAnalyzer/efficiency/L1MuonTruth3x3_Efficiency')
		effL1Muon3x3TW = self.fileHandler.getHistogram('hoMuonAnalyzer/efficiency/L1MuonTruthTimeWindow3x3_Efficiency')

		effL1Muon3x3.SetMarkerStyle(22)
		effL1Muon3x3.SetMarkerColor(colorRwthDarkBlue)
		effL1Muon3x3.SetLineColor(colorRwthDarkBlue)
		effL1Muon3x3.SetTitle('Efficiency Truth in 3x3 grid;p_{T} / GeV;rel. fraction')
		effL1Muon3x3.Draw()
		c.Update()
		effL1Muon3x3.GetPaintedGraph().GetXaxis().SetRangeUser(0,40)
		#effL1Muon3x3.GetPaintedGraph().GetYaxis().SetRangeUser(0.996,1.001)
		effL1Muon3x3TW.SetMarkerStyle(23)
		effL1Muon3x3TW.SetMarkerColor(colorRwthMagenta)
		effL1Muon3x3TW.SetLineColor(colorRwthMagenta)
		effL1Muon3x3TW.Draw('same')
		
		setupAxes(effL1Muon3x3)
		
		legend = TLegend(0.55,0.1,0.9,0.3)
		legend.AddEntry(effL1Muon3x3,'Matches to L1 Truth in 3x3 grid','ep')
		legend.AddEntry(effL1Muon3x3TW,'Matches to L1 Truth in 3x3 grid and time window','ep')
		legend.Draw()
		
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
					
		c.Update()
		return c, label, effL1Muon3x3, effL1Muon3x3TW, legend
def plotQualityCodesStacked(gridSize):
	gridString = gridSizeDict.get(gridSize)
	c = TCanvas('cQualityCodes' + gridString + 'Stacked','Stacked QC ' + gridString,600,0,800,600)
	c.SetLogy()
	c.cd().SetBottomMargin(0.15)
	c.cd().SetRightMargin(0.20)
	qualityCodes = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes' + gridString + '_Multiplicity')
	qualityCodesFail = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes' + gridString + 'Fail_Multiplicity')
	
	countQualityCodes = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonAllQualityCodes_Multiplicity')
	countQualityCodesTruth = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonTruthAllQualityCodes_Multiplicity')
	
	print
	cli.output('Sanity check for quality code counts')
	for i in range(1,8):
		nTotalHistogram = countQualityCodes.GetBinContent(countQualityCodes.FindBin(i))
		nFail = qualityCodesFail.GetBinContent(qualityCodesFail.FindBin(i))
		nPass = qualityCodes.GetBinContent(qualityCodes.FindBin(i))
		nSummed = nFail + nPass
		print
		cli.output('NTotal: %d\t\tNSummed: %d' % (nTotalHistogram,nSummed))
		cli.output('Sanity check: %s'% (CliColors.OKBLUE + 'OK' + CliColors.ENDC if nTotalHistogram == nSummed else CliColors.FAIL + 'FAIL' + CliColors.ENDC) )
		print
		if nTotalHistogram:
			qualityCodes.SetBinContent(qualityCodes.FindBin(i),nPass/float(nTotalHistogram))
			qualityCodesFail.SetBinContent(qualityCodesFail.FindBin(i),nFail/float(nTotalHistogram))
	
	stack = THStack("hstack","Quality Codes in matching to HO (" + gridString + ");;rel. fraction")
	
	qualityCodes.SetLineColor(colorRwthDarkBlue)
	qualityCodes.SetFillColor(colorRwthDarkBlue)
	qualityCodes.SetFillStyle(3002)

	qualityCodesFail.SetFillColor(colorRwthMagenta)
	qualityCodesFail.SetLineColor(colorRwthMagenta)
	qualityCodesFail.SetFillStyle(3002)

	stack.Add(qualityCodes)
	stack.Add(qualityCodesFail)
	
	stack.Draw()
	stack.GetXaxis().SetRangeUser(0,8)
		#Label the bins with the meaning of the quality code
	for i in range(1,8):
		stack.GetXaxis().SetBinLabel(stack.GetXaxis().FindBin(i),qualityCodeDict.get(i))
		
	legend = TLegend(0.82,0.75,0.99,0.9)
	legend.AddEntry(qualityCodes,"Passed","f")
	legend.AddEntry(qualityCodesFail,"Failed","f")
	legend.Draw()
	
	label = drawLabelCmsPrivateSimulation(x1ndc=0.5,y1ndc=0.9,x2ndc=0.8,y2ndc=0.93)
	
	setupAxes(stack)
		
	c.Update()
	
	c.SaveAs('plots/efficiency/qualityCodesStacked' + gridString + '.pdf')
	
	return stack,c,qualityCodes,qualityCodesFail,legend,label
Exemple #9
0
	def plotTruthL1Together(self):
		c = TCanvas('cTimeWindowTruthL1',"Time Window Truth L1")
		effL1Muon3x3 = self.fileHandler.getHistogram('efficiency/L1MuonTruth3x3_Efficiency')
		effL1Muon3x3TW = self.fileHandler.getHistogram('efficiency/L1MuonTruthTimeWindow3x3_Efficiency')

		effL1Muon3x3.SetMarkerStyle(22)
		effL1Muon3x3.SetMarkerColor(colorRwthDarkBlue)
		effL1Muon3x3.SetLineColor(colorRwthDarkBlue)
		effL1Muon3x3.SetTitle('Efficiency Truth in 3x3 grid;p_{T} / GeV;rel. fraction')
		effL1Muon3x3.Draw()
		c.Update()
		effL1Muon3x3.GetPaintedGraph().GetXaxis().SetRangeUser(0,40)
		#effL1Muon3x3.GetPaintedGraph().GetYaxis().SetRangeUser(0.996,1.001)
		effL1Muon3x3TW.SetMarkerStyle(23)
		effL1Muon3x3TW.SetMarkerColor(colorRwthMagenta)
		effL1Muon3x3TW.SetLineColor(colorRwthMagenta)
		effL1Muon3x3TW.Draw('same')
		
		setupAxes(effL1Muon3x3)
		
		legend = TLegend(0.55,0.1,0.9,0.3)
		legend.AddEntry(effL1Muon3x3,'Matches to L1 Truth in 3x3 grid','ep')
		legend.AddEntry(effL1Muon3x3TW,'Matches to L1 Truth in 3x3 grid and time window','ep')
		legend.Draw()
		
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
					
		c.Update()
		return c, label, effL1Muon3x3, effL1Muon3x3TW, legend
Exemple #10
0
    def plotHoDigiMatchesPerDetId(self):
        canvas = TCanvas('canvasDigiMatchesMultiplicity')
        digiMatches = self.fileHandler.getHistogram(
            'hoDigiMatchesPerDetId_Multiplicity')
        setupAxes(digiMatches)
        digiMatches.SetTitle(
            'Number of matches between RecHit and Digi for a given DetId')
        digiMatches.GetXaxis().SetRangeUser(0, 5)
        digiMatches.GetXaxis().SetTitle('Number of matches per DetId')
        digiMatches.GetYaxis().SetTitle('#')
        canvas.cd().SetLogy()
        digiMatches.SetLineWidth(3)
        digiMatches.SetLineColor(colorRwthDarkBlue)
        digiMatches.Draw()

        label = drawLabelCmsPrivateSimulation()

        canvas.Update()

        stats = digiMatches.GetListOfFunctions().FindObject("stats")
        stats.SetX1NDC(.7)
        stats.SetX2NDC(.9)
        stats.SetY1NDC(.75)
        stats.SetY2NDC(.9)

        canvas.Update()
        self.storeCanvas(canvas, "digiMatchesPerDetId")
        return canvas, digiMatches, label
Exemple #11
0
	def plot3x3MatchQualityCodes(self):
		c = TCanvas('cMatchQC3x3','Match QC 3x3',0,0,900,700)
		c.SetLogz()
		hist = self.fileHandler.getHistogram('hoMuonAnalyzer/qualityCode/L1Muon3x3Match_QcVsPt')
		hist.SetStats(0)
		hist.Scale(1,'width')
		hist.Draw('colz')
		c.Update()
		setupPalette(hist)
		c.Update()
				
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
		
		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
Exemple #12
0
	def plotBxidVsPtMatch(self):
		c = TCanvas('cBxidVsPtMatch','BxidVsPtMatch',800,1200)
		c.Divide(1,2)
		c.cd(1).SetLogz()
		hist = self.fileHandler.getHistogram('hoMuonAnalyzer/time/L1Muon3x3Match_BxIdVsPt')
		hist.SetStats(0)
		setupAxes(hist)
		hist.SetTitle('Successful matching in 3x3;p_{T} / GeV;BX ID;# entries')
		hist.GetYaxis().SetRangeUser(-3,3)
		
		histCopy = hist.DrawCopy('colz')
		c.Update()
		setupPalette(histCopy)
		c.Update()
		
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
			
		c.cd(2).SetLogz()
		hist.Scale(1,'width')
		hist.SetTitle(hist.GetTitle() + ', by bin width')
		hist.GetZaxis().SetTitle('# entries / GeV')
		hist.Draw('colz')
		c.Update()
		setupPalette(hist)
		c.Update()
		
		labelBottom = None
		if self.data:
			labelBottom = drawLabelCmsPrivateData()
		else:
			labelBottom = drawLabelCmsPrivateSimulation()
		
		c.Update()
		c.SaveAs('plots/efficiencyWithTime/bxIdVsPt3x3Match.gif')
		
		return c, hist,label,labelBottom
Exemple #13
0
	def plotBxidVsPtMatch(self):
		c = TCanvas('cBxidVsPtMatch','BxidVsPtMatch',800,1200)
		c.Divide(1,2)
		c.cd(1).SetLogz()
		hist = self.fileHandler.getHistogram('time/L1Muon3x3Match_BxIdVsPt')
		hist.SetStats(0)
		setupAxes(hist)
		hist.SetTitle('Successful matching in 3x3;p_{T} / GeV;BX ID;# entries')
		hist.GetYaxis().SetRangeUser(-3,3)
		
		histCopy = hist.DrawCopy('colz')
		c.Update()
		setupPalette(histCopy)
		c.Update()
		
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
			
		c.cd(2).SetLogz()
		hist.Scale(1,'width')
		hist.SetTitle(hist.GetTitle() + ', by bin width')
		hist.GetZaxis().SetTitle('# entries / GeV')
		hist.Draw('colz')
		c.Update()
		setupPalette(hist)
		c.Update()
		
		labelBottom = None
		if self.data:
			labelBottom = drawLabelCmsPrivateData()
		else:
			labelBottom = drawLabelCmsPrivateSimulation()
		
		c.Update()
		c.SaveAs('plots/efficiencyWithTime/bxIdVsPt3x3Match.gif')
		
		return c, hist,label,labelBottom
Exemple #14
0
	def plotGenEtaPhi(self):
		c = TCanvas('cGenEta','Gen eta phi',1200,1600)
		c.Divide(2,1)
		gen = self.fileHandler.getGraph('graphs/gen')
		
		histEta = TH1D('hEtaGen',"#eta GEN;#eta;#",288, -math.pi,math.pi)
		histPhi = TH1D('hPhiGen',"#phi GEN;#phi;#",288, -math.pi,math.pi)
		
		x = Double(0)
		y = Double(0)
		
		for i in range(0,gen.GetN()):
			gen.GetPoint(i,x,y)
			histPhi.Fill(y)
			histEta.Fill(x)
		
		setupAxes(histEta)
		setupAxes(histPhi)
	
		histEta.GetXaxis().SetRangeUser(-1,1)
	
		c.cd(1)
		histEta.Draw()
		label1 = drawLabelCmsPrivateSimulation()
		c.cd(2)
	
		histPhi.Draw()
		label2 = drawLabelCmsPrivateSimulation()
		
		c.Update()
		
		setStatBoxOptions(histEta,10)
		setStatBoxPosition(histEta,y1=0.85)
		setStatBoxOptions(histPhi,10)
		setStatBoxPosition(histPhi,y1=0.85)
		
		c.Update()
		self.storeCanvas(c,"genEtaPhi")
		return c,gen,histEta,histPhi,label1,label2
Exemple #15
0
    def plotGenEtaPhi(self):
        c = TCanvas('cGenEta', 'Gen eta phi', 1200, 1600)
        c.Divide(2, 1)
        gen = self.fileHandler.getGraph('graphs/gen')

        histEta = TH1D('hEtaGen', "#eta GEN;#eta;#", 288, -math.pi, math.pi)
        histPhi = TH1D('hPhiGen', "#phi GEN;#phi;#", 288, -math.pi, math.pi)

        x = Double(0)
        y = Double(0)

        for i in range(0, gen.GetN()):
            gen.GetPoint(i, x, y)
            histPhi.Fill(y)
            histEta.Fill(x)

        setupAxes(histEta)
        setupAxes(histPhi)

        histEta.GetXaxis().SetRangeUser(-1, 1)

        c.cd(1)
        histEta.Draw()
        label1 = drawLabelCmsPrivateSimulation()
        c.cd(2)

        histPhi.Draw()
        label2 = drawLabelCmsPrivateSimulation()

        c.Update()

        setStatBoxOptions(histEta, 10)
        setStatBoxPosition(histEta, y1=0.85)
        setStatBoxOptions(histPhi, 10)
        setStatBoxPosition(histPhi, y1=0.85)

        c.Update()
        self.storeCanvas(c, "genEtaPhi")
        return c, gen, histEta, histPhi, label1, label2
Exemple #16
0
def plotQualityCodesVsPt():
    allPlots = []

    allPlots.append(createPlotPtVsQualityCode(1))
    allPlots.append(createPlotPtVsQualityCode(2))
    allPlots.append(createPlotPtVsQualityCode(3))

    canvas = TCanvas('allQCCodes', "All QC")
    canvas.SetLogy()
    canvas.cd().SetBottomMargin(0.15)

    histAllCodes = fileHandler.getHistogram(
        'multiplicity/L1MuonAllQualityCodes_Multiplicity')
    histAllCodesTruth = fileHandler.getHistogram(
        'multiplicity/L1MuonTruthAllQualityCodes_Multiplicity')

    setupAxes(histAllCodes)

    histAllCodes.SetLineWidth(3)
    histAllCodesTruth.SetLineWidth(3)
    histAllCodes.SetLineColor(colorRwthDarkBlue)
    histAllCodes.Scale(1 / histAllCodes.Integral())
    histAllCodes.GetXaxis().SetRangeUser(0, 8)
    histAllCodes.SetStats(0)
    histAllCodes.SetTitle('L1 muon quality codes;;rel. fraction')
    #Label the bins with the meaning of the quality code
    for i in range(1, 8):
        histAllCodes.GetXaxis().SetBinLabel(histAllCodes.GetXaxis().FindBin(i),
                                            qualityCodeDict.get(i))

    histAllCodes.Draw()

    histAllCodesTruth.Scale(1 / histAllCodesTruth.Integral())
    histAllCodesTruth.SetLineColor(colorRwthMagenta)
    histAllCodesTruth.Draw('Same')

    label = drawLabelCmsPrivateSimulation()

    legend = TLegend(0.1, 0.75, 0.3, 0.9)
    legend.AddEntry(histAllCodes, "All L1", "l")
    legend.AddEntry(histAllCodesTruth, "L1 Truth", "l")
    legend.Draw()

    canvas.Update()
    canvas.SaveAs('plots/efficiency/allQualityCodes.pdf')

    allPlots.append([histAllCodes, histAllCodesTruth, canvas, legend, label])

    return allPlots
def plotQualityCodesVsPt():
	allPlots = []

	allPlots.append(createPlotPtVsQualityCode(1))
	allPlots.append(createPlotPtVsQualityCode(2))
	allPlots.append(createPlotPtVsQualityCode(3))
	
	canvas = TCanvas('allQCCodes',"All QC")
	canvas.SetLogy()
	canvas.cd().SetBottomMargin(0.15)

	histAllCodes = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonAllQualityCodes_Multiplicity')
	histAllCodesTruth = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonTruthAllQualityCodes_Multiplicity')

	setupAxes(histAllCodes)

	histAllCodes.SetLineWidth(3)
	histAllCodesTruth.SetLineWidth(3)
	histAllCodes.SetLineColor(colorRwthDarkBlue)
	histAllCodes.Scale(1/histAllCodes.Integral())
	histAllCodes.GetXaxis().SetRangeUser(0,8)	
	histAllCodes.SetStats(0)
	histAllCodes.SetTitle('L1 muon quality codes;;rel. fraction')
	#Label the bins with the meaning of the quality code
	for i in range(1,8):
		histAllCodes.GetXaxis().SetBinLabel(histAllCodes.GetXaxis().FindBin(i),qualityCodeDict.get(i))
	
	histAllCodes.Draw()
	
	histAllCodesTruth.Scale(1/histAllCodesTruth.Integral())
	histAllCodesTruth.SetLineColor(colorRwthMagenta)
	histAllCodesTruth.Draw('Same')
	
	label = drawLabelCmsPrivateSimulation()
	
	legend = TLegend(0.1,0.75,0.3,0.9)
	legend.AddEntry(histAllCodes,"All L1","l")
	legend.AddEntry(histAllCodesTruth,"L1 Truth","l")
	legend.Draw()
	
	canvas.Update()
	canvas.SaveAs('plots/efficiency/allQualityCodes.pdf')
	
	allPlots.append([histAllCodes,histAllCodesTruth,canvas,legend,label])
	
	return allPlots
def createPlotPtVsQualityCode(gridSize):
	sourceHistogramsForGrid = {
		1:'hoMuonAnalyzer/correlation/L1MuonpTvsQCCentralFail',
		2:'hoMuonAnalyzer/correlation/L1MuonpTvsQC3x3Fail',
		3:'hoMuonAnalyzer/correlation/L1MuonpTvsQC5x5Fail'
	}
	histogramTitleDict = {
		1:'Central',
		2:'3x3',
		3:'5x5'
	}
	histogram = fileHandler.getHistogram(sourceHistogramsForGrid.get(gridSize))
	title = 'p_{T} vs. rejected QC (' + histogramTitleDict.get(gridSize) + ')'
	canvasTitle = 'cPtVsQualityCodes' + histogramTitleDict.get(gridSize)
	
	canvas = TCanvas(canvasTitle,'cPtVsQualityCodes' + histogramTitleDict.get(gridSize),800,0,800,600)
	canvas.SetLogz()
		
	histogram.GetXaxis().SetRangeUser(0,8)
	histogram.GetYaxis().SetRangeUser(-1,160)
	histogram.SetStats(0)
	histogram.SetTitle(title)
	
	histogram.Scale(1,'width')
	
	histogram.Draw('colz')
	
	label = drawLabelCmsPrivateSimulation()
	canvas.Update()
	
	setupPalette(histogram)
	canvas.Update()
	
	fileNameTrunk = 'plots/efficiency/ptVsQualityCode' + histogramTitleDict.get(gridSize) + 'Fail'
	
	canvas.SaveAs(fileNameTrunk + '.png')
	canvas.SaveAs(fileNameTrunk + '.pdf')
	
	histogram.Draw('lego2')
	canvas.Update()		
		
	canvas.SaveAs(fileNameTrunk + '3D.png')
	canvas.SaveAs(fileNameTrunk + '3D.pdf')
	
	return canvas,label,histogram
Exemple #19
0
def createPlotPtVsQualityCode(gridSize):
    sourceHistogramsForGrid = {
        1: 'correlation/L1MuonpTvsQCCentralFail',
        2: 'correlation/L1MuonpTvsQC3x3Fail',
        3: 'correlation/L1MuonpTvsQC5x5Fail'
    }
    histogramTitleDict = {1: 'Central', 2: '3x3', 3: '5x5'}
    histogram = fileHandler.getHistogram(sourceHistogramsForGrid.get(gridSize))
    title = 'p_{T} vs. rejected QC (' + histogramTitleDict.get(gridSize) + ')'
    canvasTitle = 'cPtVsQualityCodes' + histogramTitleDict.get(gridSize)

    canvas = TCanvas(canvasTitle,
                     'cPtVsQualityCodes' + histogramTitleDict.get(gridSize),
                     800, 0, 800, 600)
    canvas.SetLogz()

    histogram.GetXaxis().SetRangeUser(0, 8)
    histogram.GetYaxis().SetRangeUser(-1, 160)
    histogram.SetStats(0)
    histogram.SetTitle(title)

    histogram.Scale(1, 'width')

    histogram.Draw('colz')

    label = drawLabelCmsPrivateSimulation()
    canvas.Update()

    setupPalette(histogram)
    canvas.Update()

    fileNameTrunk = 'plots/efficiency/ptVsQualityCode' + histogramTitleDict.get(
        gridSize) + 'Fail'

    canvas.SaveAs(fileNameTrunk + '.png')
    canvas.SaveAs(fileNameTrunk + '.pdf')

    histogram.Draw('lego2')
    canvas.Update()

    canvas.SaveAs(fileNameTrunk + '3D.png')
    canvas.SaveAs(fileNameTrunk + '3D.pdf')

    return canvas, label, histogram
Exemple #20
0
	def plot3x3FailQualityCodes(self):
		c = TCanvas('cFailQC3x3','Fail QC 3x3',910,0,900,700)
		c.SetLogz()
		hist = self.fileHandler.getHistogram('hoMuonAnalyzer/qualityCode/L1Muon3x3Fail_QcVsPt')
		hist.SetStats(0)
		hist.Scale(1,'width')
		hist.Draw('colz')
		c.Update()
		setupPalette(hist)
		c.Update()

		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()		

		c.Update()

		return hist,c,label
		
Exemple #21
0
    def plotL1PerPt(self):
        ptValues = [
            0., 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10.0,
            12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0,
            60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0
        ]
        ptBins = [0]
        for i in range(len(ptValues) - 1):
            ptBins.append((ptValues[i] + ptValues[i + 1]) / 2.)
        ptBins.append(200)
        canvas = TCanvas('cL1PerPt')
        hist = TH1D('hist', '# L1 per p_{T}',
                    len(ptBins) - 1, array('d', ptBins))
        chain = self.fileHandler.getTChain()
        eventCounter = 0
        liste = []
        nEvents = chain.GetEntries()
        for event in chain:
            eventCounter += 1
            for l1 in event.l1MuonData:
                if not l1.pt in liste:
                    liste.append(l1.pt)
                hist.Fill(l1.pt)
            if not eventCounter % 10000:
                printProgress(eventCounter, nEvents)
            if eventCounter == 50000:
                break
        print
        setupAxes(hist)
        hist.SetStats(0)
        hist.Scale(1, "width")
        hist.Draw()

        label = drawLabelCmsPrivateSimulation()

        canvas.Update()

        #	print liste
        return hist, canvas, label
Exemple #22
0
	def plotTimeWindowAlone(self):
		c = TCanvas('cTimeWindowAlone',"Time Window Alone")
		effL1Muon3x3Truth = self.fileHandler.getHistogram('efficiency/L1MuonTruthTimeWindow3x3_Efficiency')
		effL1Muon3x3 = self.fileHandler.getHistogram('efficiency/L1MuonTimeWindow3x3_Efficiency')
		
		effL1Muon3x3.SetMarkerStyle(22)
		effL1Muon3x3.SetMarkerColor(colorRwthDarkBlue)
		effL1Muon3x3.SetLineColor(colorRwthDarkBlue)
		effL1Muon3x3.SetTitle('Efficiency in 3x3 grid with time window;p_{T} / GeV;rel. fraction')
		effL1Muon3x3.Draw()
		c.Update()
		effL1Muon3x3.GetPaintedGraph().GetXaxis().SetRangeUser(0,40)
		#effL1Muon3x3.GetPaintedGraph().GetYaxis().SetRangeUser(0.996,1.001)
		effL1Muon3x3Truth.SetMarkerStyle(23)
		effL1Muon3x3Truth.SetMarkerColor(colorRwthMagenta)
		effL1Muon3x3Truth.SetLineColor(colorRwthMagenta)
		effL1Muon3x3Truth.Draw('same')
		
		setupAxes(effL1Muon3x3)
		
		legend = TLegend(0.55,0.1,0.9,0.3)
		legend.AddEntry(effL1Muon3x3,'Matches in 3x3 grid','ep')
		legend.AddEntry(effL1Muon3x3Truth,'Matches  to truth in 3x3 grid','ep')
		legend.Draw()
		
		label = None
		if self.data:
			label = drawLabelCmsPrivateData()
		else:
			label = drawLabelCmsPrivateSimulation()
		
		c.Update()

		c.SaveAs('plots/efficiencyWithTime/allL1AndL1Truth3x3.gif')

		return c, effL1Muon3x3,effL1Muon3x3Truth,label,legend
Exemple #23
0
	def drawLabel(self,labelPosition = {'x1ndc' : 0.6, 'y1ndc' : 0.95, 'x2ndc' : 0.9, 'y2ndc' : 0.98}):
		if self.data:
			label = drawLabelCmsPrivateData(labelPosition['x1ndc'],labelPosition['y1ndc'],labelPosition['x2ndc'],labelPosition['y2ndc'])
		else:
			label = drawLabelCmsPrivateSimulation(labelPosition['x1ndc'],labelPosition['y1ndc'],labelPosition['x2ndc'],labelPosition['y2ndc'])
		return label
Exemple #24
0
def plotQualityCodes():
    c = TCanvas('cQualityCodes')
    c.SetLogy()
    qualityCodes = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodesCentral_Multiplicity')
    qualityCodesFail = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodesCentralFail_Multiplicity')

    qualityCodes3x3 = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodes3x3_Multiplicity')
    qualityCodes3x3Fail = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodes3x3Fail_Multiplicity')

    qualityCodes5x5 = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodes5x5_Multiplicity')
    qualityCodes5x5Fail = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodes5x5Fail_Multiplicity')

    setupAxes(qualityCodes)
    qualityCodes.SetTitle('Quality codes for grid matching;;#')
    qualityCodes.SetLineColor(colorRwthDarkBlue)
    qualityCodes.GetXaxis().SetRangeUser(0, 8)
    qualityCodes.SetStats(0)
    qualityCodes.SetLineWidth(3)

    c.cd().SetBottomMargin(0.15)
    #Label the bins with the meaning of the quality code
    for i in range(1, 8):
        qualityCodes.GetXaxis().SetBinLabel(qualityCodes.FindBin(i),
                                            qualityCodeDict.get(i))

    setupAxes(qualityCodesFail)
    qualityCodesFail.SetLineWidth(3)
    qualityCodesFail.SetLineStyle(7)
    qualityCodesFail.SetLineColor(colorRwthLightBlue)

    setupAxes(qualityCodes3x3)
    qualityCodes3x3.SetLineWidth(3)
    qualityCodes3x3.SetLineStyle(10)
    qualityCodes3x3.SetLineColor(colorRwthGruen)

    setupAxes(qualityCodes3x3Fail)
    qualityCodes3x3Fail.SetLineWidth(3)
    qualityCodes3x3Fail.SetLineStyle(8)
    qualityCodes3x3Fail.SetLineColor(colorRwthTuerkis)

    setupAxes(qualityCodes5x5)
    qualityCodes5x5.SetLineWidth(3)
    qualityCodes5x5.SetLineColor(colorRwthRot)

    setupAxes(qualityCodes5x5Fail)
    qualityCodes5x5Fail.SetLineWidth(3)
    qualityCodes5x5Fail.SetLineColor(colorRwthMagenta)

    qualityCodes.Scale(1 / qualityCodes.Integral())
    qualityCodes3x3.Scale(1 / qualityCodes3x3.Integral())
    qualityCodes3x3Fail.Scale(1 / qualityCodes3x3Fail.Integral())
    qualityCodes5x5.Scale(1 / qualityCodes5x5.Integral())
    qualityCodes5x5Fail.Scale(1 / qualityCodes5x5Fail.Integral())
    qualityCodesFail.Scale(1 / qualityCodesFail.Integral())

    qualityCodes.Draw()
    qualityCodesFail.Draw('same')
    qualityCodes3x3.Draw('same')
    qualityCodes3x3Fail.Draw('same')
    #	qualityCodes5x5.Draw('same')
    #	qualityCodes5x5Fail.Draw('same')

    legend = TLegend(0.1, 0.6, 0.3, 0.9)
    legend.AddEntry(qualityCodes, "Central", "l")
    legend.AddEntry(qualityCodesFail, "Central Fail", "l")
    legend.AddEntry(qualityCodes3x3, "3x3", "l")
    legend.AddEntry(qualityCodes3x3Fail, "3x3 Fail", "l")
    legend.SetFillColor(0)
    #	legend.AddEntry(qualityCodes5x5,"5x5","l")
    #	legend.AddEntry(qualityCodes5x5Fail,"5x5 Fail","l")
    legend.Draw()

    label = drawLabelCmsPrivateSimulation()
    c.Update()

    c.SaveAs('plots/efficiency/qualityCodes.pdf')

    return c, qualityCodes, label, qualityCodesFail, qualityCodes3x3, qualityCodes3x3Fail, qualityCodes5x5, qualityCodes5x5Fail, legend
Exemple #25
0
def plotQualityCodesStacked(gridSize):
    gridString = gridSizeDict.get(gridSize)
    c = TCanvas('cQualityCodes' + gridString + 'Stacked',
                'Stacked QC ' + gridString, 600, 0, 800, 600)
    c.SetLogy()
    c.cd().SetBottomMargin(0.15)
    c.cd().SetRightMargin(0.20)
    qualityCodes = fileHandler.getHistogram('multiplicity/L1MuonQualityCodes' +
                                            gridString + '_Multiplicity')
    qualityCodesFail = fileHandler.getHistogram(
        'multiplicity/L1MuonQualityCodes' + gridString + 'Fail_Multiplicity')

    countQualityCodes = fileHandler.getHistogram(
        'multiplicity/L1MuonAllQualityCodes_Multiplicity')
    countQualityCodesTruth = fileHandler.getHistogram(
        'multiplicity/L1MuonTruthAllQualityCodes_Multiplicity')

    print
    cli.output('Sanity check for quality code counts')
    for i in range(1, 8):
        nTotalHistogram = countQualityCodes.GetBinContent(
            countQualityCodes.FindBin(i))
        nFail = qualityCodesFail.GetBinContent(qualityCodesFail.FindBin(i))
        nPass = qualityCodes.GetBinContent(qualityCodes.FindBin(i))
        nSummed = nFail + nPass
        print
        cli.output('NTotal: %d\t\tNSummed: %d' % (nTotalHistogram, nSummed))
        cli.output('Sanity check: %s' %
                   (CliColors.OKBLUE + 'OK' + CliColors.ENDC if nTotalHistogram
                    == nSummed else CliColors.FAIL + 'FAIL' + CliColors.ENDC))
        print
        if nTotalHistogram:
            qualityCodes.SetBinContent(qualityCodes.FindBin(i),
                                       nPass / float(nTotalHistogram))
            qualityCodesFail.SetBinContent(qualityCodesFail.FindBin(i),
                                           nFail / float(nTotalHistogram))

    stack = THStack(
        "hstack",
        "Quality Codes in matching to HO (" + gridString + ");;rel. fraction")

    qualityCodes.SetLineColor(colorRwthDarkBlue)
    qualityCodes.SetFillColor(colorRwthDarkBlue)
    qualityCodes.SetFillStyle(3002)

    qualityCodesFail.SetFillColor(colorRwthMagenta)
    qualityCodesFail.SetLineColor(colorRwthMagenta)
    qualityCodesFail.SetFillStyle(3002)

    stack.Add(qualityCodes)
    stack.Add(qualityCodesFail)

    stack.Draw()
    stack.GetXaxis().SetRangeUser(0, 8)
    #Label the bins with the meaning of the quality code
    for i in range(1, 8):
        stack.GetXaxis().SetBinLabel(stack.GetXaxis().FindBin(i),
                                     qualityCodeDict.get(i))

    legend = TLegend(0.82, 0.75, 0.99, 0.9)
    legend.AddEntry(qualityCodes, "Passed", "f")
    legend.AddEntry(qualityCodesFail, "Failed", "f")
    legend.Draw()

    label = drawLabelCmsPrivateSimulation(x1ndc=0.5,
                                          y1ndc=0.9,
                                          x2ndc=0.8,
                                          y2ndc=0.93)

    setupAxes(stack)

    c.Update()

    c.SaveAs('plots/efficiency/qualityCodesStacked' + gridString + '.pdf')

    return stack, c, qualityCodes, qualityCodesFail, legend, label
def plotQualityCodes():
	c = TCanvas('cQualityCodes')
	c.SetLogy()
	qualityCodes = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodesCentral_Multiplicity')
	qualityCodesFail = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodesCentralFail_Multiplicity')
	
	qualityCodes3x3 = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes3x3_Multiplicity')
	qualityCodes3x3Fail = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes3x3Fail_Multiplicity')
	
	qualityCodes5x5 = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes5x5_Multiplicity')
	qualityCodes5x5Fail = fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/L1MuonQualityCodes5x5Fail_Multiplicity')
	
	setupAxes(qualityCodes)
	qualityCodes.SetTitle('Quality codes for grid matching;;#')
	qualityCodes.SetLineColor(colorRwthDarkBlue)
	qualityCodes.GetXaxis().SetRangeUser(0,8)
	qualityCodes.SetStats(0)
	qualityCodes.SetLineWidth(3)
	
	c.cd().SetBottomMargin(0.15)
	#Label the bins with the meaning of the quality code
	for i in range(1,8):
		qualityCodes.GetXaxis().SetBinLabel(qualityCodes.FindBin(i),qualityCodeDict.get(i))
	
	setupAxes(qualityCodesFail)
	qualityCodesFail.SetLineWidth(3)
	qualityCodesFail.SetLineStyle(7)
	qualityCodesFail.SetLineColor(colorRwthLightBlue)
	
	setupAxes(qualityCodes3x3)
	qualityCodes3x3.SetLineWidth(3)
	qualityCodes3x3.SetLineStyle(10)
	qualityCodes3x3.SetLineColor(colorRwthGruen)
	
	setupAxes(qualityCodes3x3Fail)
	qualityCodes3x3Fail.SetLineWidth(3)
	qualityCodes3x3Fail.SetLineStyle(8)
	qualityCodes3x3Fail.SetLineColor(colorRwthTuerkis)
	
	setupAxes(qualityCodes5x5)
	qualityCodes5x5.SetLineWidth(3)
	qualityCodes5x5.SetLineColor(colorRwthRot)
	
	setupAxes(qualityCodes5x5Fail)
	qualityCodes5x5Fail.SetLineWidth(3)
	qualityCodes5x5Fail.SetLineColor(colorRwthMagenta)
	
	qualityCodes.Scale(1/qualityCodes.Integral())
	qualityCodes3x3.Scale(1/qualityCodes3x3.Integral())
	qualityCodes3x3Fail.Scale(1/qualityCodes3x3Fail.Integral())
	qualityCodes5x5.Scale(1/qualityCodes5x5.Integral())
	qualityCodes5x5Fail.Scale(1/qualityCodes5x5Fail.Integral())
	qualityCodesFail.Scale(1/qualityCodesFail.Integral())
	
	qualityCodes.Draw()
	qualityCodesFail.Draw('same')
	qualityCodes3x3.Draw('same')
	qualityCodes3x3Fail.Draw('same')
#	qualityCodes5x5.Draw('same')
#	qualityCodes5x5Fail.Draw('same')
	
	legend = TLegend(0.1,0.6,0.3,0.9)
	legend.AddEntry(qualityCodes,"Central","l")
	legend.AddEntry(qualityCodesFail,"Central Fail","l")
	legend.AddEntry(qualityCodes3x3,"3x3","l")
	legend.AddEntry(qualityCodes3x3Fail,"3x3 Fail","l")
	legend.SetFillColor(0)
#	legend.AddEntry(qualityCodes5x5,"5x5","l")
#	legend.AddEntry(qualityCodes5x5Fail,"5x5 Fail","l")
	legend.Draw()
	
	label = drawLabelCmsPrivateSimulation()
	c.Update()
	
	c.SaveAs('plots/efficiency/qualityCodes.pdf')
	
	return c,qualityCodes,label,qualityCodesFail,qualityCodes3x3,qualityCodes3x3Fail,qualityCodes5x5,qualityCodes5x5Fail,legend
def plotEfficiencyForPt(folder,pt):
	if(DEBUG):
		print prefix + 'was called'
	
	#Set plot style
	
	if(DEBUG):
		print prefix + "Getting histogram: %s" % ("hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) + "_Efficiency")
	
	l1Muon = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) + "_Efficiency")
	l1MuonAndHo = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/L1MuonHoRecoPt" + str(pt) + "_Efficiency")
	if(DEBUG):
		print prefix + "Getting histogram: %s" % ("hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) + "_Efficiency")
	l1MuonAndHoAboveThr = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) + "_Efficiency")
	
	canv = TCanvas("efficiencyCanvas" + str(pt),'efficiencyCanvas' + str(pt),1200,1200)
	
	l1Muon.SetMarkerStyle(markerpairs[pt/5 -1][0])
	l1MuonAndHo.SetMarkerStyle(21)
	l1MuonAndHoAboveThr.SetMarkerStyle(markerpairs[pt/5 -1][1])
	
	l1Muon.SetMarkerColor(colorRwthDarkBlue)
	l1MuonAndHo.SetMarkerColor(ROOT.kBlue)
	l1MuonAndHoAboveThr.SetMarkerColor(colorRwthMagenta)   
	
	l1Muon.SetLineColor(colorRwthDarkBlue)
	l1MuonAndHo.SetLineColor(ROOT.kBlue)
	l1MuonAndHoAboveThr.SetLineColor(colorRwthMagenta)
	
	upperPad = TPad("upperPad", "upperPad", .005, .25, .995, .995);
	lowerPad = TPad("lowerPad", "lowerPad", .005, .005, .995, .25);
	upperPad.SetBottomMargin(0)
	lowerPad.SetTopMargin(0)
	upperPad.Draw()
	lowerPad.Draw()
	upperPad.cd()
	l1Muon.Draw()
#	l1MuonAndHo.Draw('same')
	l1MuonAndHoAboveThr.Draw('same')
	
	canv.Update()
	l1Muon.GetPaintedGraph().GetYaxis().SetTitleFont(62)
	l1Muon.GetPaintedGraph().GetYaxis().SetLabelFont(62)
	l1Muon.GetPaintedGraph().GetXaxis().SetRangeUser(0,50)
	#.GetPaintedGraph()
	l1Muon.SetTitle("Efficiency, p_{T} = " + str(pt) + " GeV;p_{T};Eff.")
	canv.Update()

	line = TLine(pt,0,pt,1)
	line.SetLineColor(ROOT.kRed)
	line.SetLineWidth(2)
	line.Draw()

	legend = TLegend(0.5,0.1,0.9,0.35)
	legend.AddEntry(l1Muon,'L1 Efficiency','ep')
	legend.AddEntry(l1MuonAndHoAboveThr,'L1 + HO hits > 0.2 GeV','ep')
	legend.AddEntry(line,'Trg. threshold','e')
	legend.Draw()
	
	integralL1 = 0
	integralL1AndHo = 0
	for i in range(0,pt+1):
		integralL1 += l1Muon.GetPassedHistogram().GetBinContent(pt+1)
		integralL1AndHo += l1MuonAndHoAboveThr.GetPassedHistogram().GetBinContent(pt+1)

	paveText = TPaveText(0.5,0.35,0.9,0.4,'NDC')
	if(not integralL1 == 0):
		paveText.AddText('%s: %.2f%% #pm %.2f%%' % ('Reduction below threshold',100 - integralL1AndHo/integralL1*100,calcSigma(integralL1AndHo, integralL1)*100))
		paveText.SetBorderSize(1)
		paveText.Draw()

	label = drawLabelCmsPrivateSimulation()
	##### Try creating residuals
	lowerPad.cd()
	l1MuonGraph = l1Muon.GetPaintedGraph()
	l1MuonAndHoAboveThrGraph = l1MuonAndHoAboveThr.GetPaintedGraph()

	newGraph = TGraph()

	x1 = Double(0)
	y1 = Double(0)
	x2 = Double(0)
	y2 = Double(0)
	
	for i in range(0,50):
		l1MuonGraph.GetPoint(i,x1,y1)
		l1MuonAndHoAboveThrGraph.GetPoint(i,x2,y2)
		newGraph.SetPoint(i,x1,(y1-y2)*100)
	
	
	newGraph.SetMarkerStyle(20)
	newGraph.GetYaxis().SetTitle("%")
	newGraph.Draw("a,p")
	newGraph.GetXaxis().SetLimits(0,50)
	line2 = TLine(0,0,50,0)
	line2.SetLineColor(ROOT.kRed)
	line2.SetLineWidth(2)
	line2.Draw()
	
	##### Finally save the stuff
	
	canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".png")
	canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".pdf")
	
	f = TFile.Open("plots/efficiency/efficiency" + str(pt) + ".root","RECREATE")
	canv.Write()
	f.Close()
	return [l1Muon,l1MuonAndHoAboveThr,canv,legend,line,paveText,label,newGraph]
def plotEfficiencyForPt(folder, pt):
    if (DEBUG):
        print prefix + 'was called'

    #Set plot style

    if (DEBUG):
        print prefix + "Getting histogram: %s" % (
            "hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) +
            "_Efficiency")

    l1Muon = fileHandler.getHistogram(
        "hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) + "_Efficiency")
    l1MuonAndHo = fileHandler.getHistogram(
        "hoMuonAnalyzer/efficiency/L1MuonHoRecoPt" + str(pt) + "_Efficiency")
    if (DEBUG):
        print prefix + "Getting histogram: %s" % (
            "hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) +
            "_Efficiency")
    l1MuonAndHoAboveThr = fileHandler.getHistogram(
        "hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) +
        "_Efficiency")

    canv = TCanvas("efficiencyCanvas" + str(pt), 'efficiencyCanvas' + str(pt),
                   1200, 1200)

    l1Muon.SetMarkerStyle(markerpairs[pt / 5 - 1][0])
    l1MuonAndHo.SetMarkerStyle(21)
    l1MuonAndHoAboveThr.SetMarkerStyle(markerpairs[pt / 5 - 1][1])

    l1Muon.SetMarkerColor(colorRwthDarkBlue)
    l1MuonAndHo.SetMarkerColor(ROOT.kBlue)
    l1MuonAndHoAboveThr.SetMarkerColor(colorRwthMagenta)

    l1Muon.SetLineColor(colorRwthDarkBlue)
    l1MuonAndHo.SetLineColor(ROOT.kBlue)
    l1MuonAndHoAboveThr.SetLineColor(colorRwthMagenta)

    upperPad = TPad("upperPad", "upperPad", .005, .25, .995, .995)
    lowerPad = TPad("lowerPad", "lowerPad", .005, .005, .995, .25)
    upperPad.SetBottomMargin(0)
    lowerPad.SetTopMargin(0)
    upperPad.Draw()
    lowerPad.Draw()
    upperPad.cd()
    l1Muon.Draw()
    #	l1MuonAndHo.Draw('same')
    l1MuonAndHoAboveThr.Draw('same')

    canv.Update()
    l1Muon.GetPaintedGraph().GetYaxis().SetTitleFont(62)
    l1Muon.GetPaintedGraph().GetYaxis().SetLabelFont(62)
    l1Muon.GetPaintedGraph().GetXaxis().SetRangeUser(0, 50)
    #.GetPaintedGraph()
    l1Muon.SetTitle("Efficiency, p_{T} = " + str(pt) + " GeV;p_{T};Eff.")
    canv.Update()

    line = TLine(pt, 0, pt, 1)
    line.SetLineColor(ROOT.kRed)
    line.SetLineWidth(2)
    line.Draw()

    legend = TLegend(0.5, 0.1, 0.9, 0.35)
    legend.AddEntry(l1Muon, 'L1 Efficiency', 'ep')
    legend.AddEntry(l1MuonAndHoAboveThr, 'L1 + HO hits > 0.2 GeV', 'ep')
    legend.AddEntry(line, 'Trg. threshold', 'e')
    legend.Draw()

    integralL1 = 0
    integralL1AndHo = 0
    for i in range(0, pt + 1):
        integralL1 += l1Muon.GetPassedHistogram().GetBinContent(pt + 1)
        integralL1AndHo += l1MuonAndHoAboveThr.GetPassedHistogram(
        ).GetBinContent(pt + 1)

    paveText = TPaveText(0.5, 0.35, 0.9, 0.4, 'NDC')
    if (not integralL1 == 0):
        paveText.AddText('%s: %.2f%% #pm %.2f%%' %
                         ('Reduction below threshold',
                          100 - integralL1AndHo / integralL1 * 100,
                          calcSigma(integralL1AndHo, integralL1) * 100))
        paveText.SetBorderSize(1)
        paveText.Draw()

    label = drawLabelCmsPrivateSimulation()
    ##### Try creating residuals
    lowerPad.cd()
    l1MuonGraph = l1Muon.GetPaintedGraph()
    l1MuonAndHoAboveThrGraph = l1MuonAndHoAboveThr.GetPaintedGraph()

    newGraph = TGraph()

    x1 = Double(0)
    y1 = Double(0)
    x2 = Double(0)
    y2 = Double(0)

    for i in range(0, 50):
        l1MuonGraph.GetPoint(i, x1, y1)
        l1MuonAndHoAboveThrGraph.GetPoint(i, x2, y2)
        newGraph.SetPoint(i, x1, (y1 - y2) * 100)

    newGraph.SetMarkerStyle(20)
    newGraph.GetYaxis().SetTitle("%")
    newGraph.Draw("a,p")
    newGraph.GetXaxis().SetLimits(0, 50)
    line2 = TLine(0, 0, 50, 0)
    line2.SetLineColor(ROOT.kRed)
    line2.SetLineWidth(2)
    line2.Draw()

    ##### Finally save the stuff

    canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".png")
    canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".pdf")

    f = TFile.Open("plots/efficiency/efficiency" + str(pt) + ".root",
                   "RECREATE")
    canv.Write()
    f.Close()
    return [
        l1Muon, l1MuonAndHoAboveThr, canv, legend, line, paveText, label,
        newGraph
    ]