Exemplo n.º 1
0
	def plotEnergyNormalized(self):

		ho = self.fileHandler.getHistogram("hoMuonAnalyzer/energy/horeco_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('hoMuonAnalyzer/energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('hoMuonAnalyzer/energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('hoMuonAnalyzer/energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		canv = TCanvas("energieNormCanvas",'Energy Norm canvas',1200,1200)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('Normalized energy distribution of HO hits (Integral)')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('rel. fraction')
		#ho.GetXaxis().SetRangeUser(-2,6)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Scale(1/ho.Integral())
		ho.Draw()
		
		label = self.drawLabel()
		
		legend = getLegend(0.5,0.65,0.9,0.9)
		legend.AddEntry(ho,'All HO hits','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Scale(1/L1MuonAndHoMatch.Integral())
			L1MuonAndHoMatch.Draw('same')
			legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Scale(1/L1MuonAndHoMatchAboveThr.Integral())
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Scale(1/L1MuonAndHoMatchAboveThrFilt.Integral())
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		
		self.storeCanvas(canv,'energyNorm')
		canv.SaveAs("plots/energy/energyNorm.pdf")
	
		f = TFile.Open("plots/energy/energyNorm.root","RECREATE")
		canv.Write()
		f.Close()
		return [canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,label,legend]
Exemplo n.º 2
0
    def compareL1Count(self):
        hSim = self.fileHandlerSimulation.getHistogram('L1MuonPresent_Pt')
        hSimPu = self.fileHandlerSimulationPu.getHistogram('L1MuonPresent_Pt')
        hData = self.fileHandler.getHistogram('L1MuonPresent_Pt')

        #	hSimPu.Sumw2()
        #	hSim.Sumw2()

        hSim.Scale(1 / hSim.Integral(), 'width')
        hSimPu.Scale(1 / hSimPu.Integral(), 'width')
        hData.Scale(1 / hData.Integral(), 'width')

        c = TCanvas('cNvsPt', 'Nvs pt')
        c.cd().SetLeftMargin(0.17)

        hSim.SetMarkerStyle(20)
        hSim.SetMarkerColor(colorRwthLila)
        hSim.SetLineColor(colorRwthLila)
        hSim.GetYaxis().SetRangeUser(0, 0.03)

        hSimPu.SetMarkerStyle(21)
        hSimPu.SetMarkerColor(colorRwthOrange)
        hSimPu.SetLineColor(colorRwthOrange)
        hSimPu.SetTitle(
            'Normalized distribution of p_{T};p_{T,L1};normalized fraction / binwidth'
        )
        hSimPu.SetStats(0)
        hSimPu.GetXaxis().SetRangeUser(0, 20)
        hSimPu.GetYaxis().SetTitle("Normalized fraction / #frac{1}{GeV}")
        hSimPu.Draw('lp')
        hSim.Draw('same,lp')
        setupAxes(hSimPu)

        hSimPu.GetYaxis().SetTitleOffset(1.35)

        hData.SetMarkerStyle(22)
        hData.SetMarkerColor(colorRwthTuerkis)
        #		hData.Draw('same,p')

        legend = getLegend(y1=0.65, y2=.9)
        legend.AddEntry(hSim, 'Sim', 'lp')
        legend.AddEntry(hSimPu, 'Sim, PU52', 'lp')
        #		legend.AddEntry(hData,'Data','ep')
        legend.Draw()

        label = self.drawLabel()

        c.Update()
        self.storeCanvas(c,
                         'l1CountComparison/l1CountNormalized',
                         markPosition={
                             'x1ndc': 0.16,
                             'y1ndc': 0.898,
                             'x2ndc': 0.319,
                             'y2ndc': 0.940
                         })
        return hSim, c, hSimPu, hData, legend, label
Exemplo n.º 3
0
	def makeQuantilePlot(self,dataSet):
		c = TCanvas(dataSet + 'quantiles')

		graphMean = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data[dataSet]['mean'],
								ey = self.cached_data[dataSet]['meanError'],
								ex=self.cached_data['x']['errors'])
		setupAxes(graphMean)
		graphMean.SetMarkerStyle(20)
		graphMean.SetMarkerColor(colorRwthDarkBlue)
		graphMean.SetLineColor(colorRwthDarkBlue)
		
		graphMedian = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data[dataSet]['median'])
		graphMedian.SetMarkerStyle(21)
		graphMedian.SetMarkerColor(colorRwthMagenta)
		graphMedian.SetLineColor(colorRwthMagenta)
		graphMedian.SetFillColor(colorRwthMagenta)
		
		graphQ50 = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data[dataSet]['q50'])
		graphQ50.SetMarkerStyle(22)
		graphQ50.SetMarkerColor(colorRwthLila)
		graphQ50.SetLineColor(colorRwthLila)
		
		graphShape68 = TGraph()
		graphShape68.SetName(dataSet)
		graphShape68.SetFillStyle(1001)
		graphShape68.SetFillColorAlpha(colorRwthGruen,.75)
		graphShape68.SetLineColorAlpha(colorRwthGruen,.75)

		for i in zip(self.cached_data['x']['values'],self.cached_data[dataSet]['q16']):
			graphShape68.SetPoint(graphShape68.GetN(),i[0],i[1])
		
		for i in zip(reversed(self.cached_data['x']['values']),reversed(self.cached_data[dataSet]['q84'])):
			graphShape68.SetPoint(graphShape68.GetN(),i[0],i[1])
		
		graphShape68.GetYaxis().SetRangeUser(0,200)
		graphShape68.SetTitle(";p_{T,Reco} / GeV;p_{T,L1} / GeV")#"Mean, Median, and Quantiles of " + dataSet + " p_{T};p_{T,Reco} / GeV;p_{T,L1} / GeV")
		setupAxes(graphShape68)

		graphShape68.Draw('a f')
		graphMean.Draw('same p')
		graphMedian.Draw('same,l')
		graphQ50.Draw('same,l')

		
		legend = getLegend(y1=.75,y2 = .95,x1=.1,x2=.5)
		legend.AddEntry(graphMean,dataSet + ' p_{T} Mean','ep')
		legend.AddEntry(graphMedian,dataSet + ' p_{T} Median','l')
		legend.AddEntry(graphShape68,dataSet + ' p_{T} Q_{25} - Q_{75}','f')
		legend.AddEntry(graphQ50,dataSet + ' p_{T} Q_{50}','l')
		legend.Draw()
				
		c.Update()
		self.storeCanvas(c,'quantiles_' + self.truthTag + '_' + dataSet.replace(' ','_').replace('!','Not'), marginRight = .02)
		return c,graphMean,legend,graphMedian,graphShape68,graphQ50
Exemplo n.º 4
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()
			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('')
		hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue)
		hHoTimeAboveThr.SetLineWidth(3)
		hHoTimeAboveThr.GetXaxis().SetRangeUser(-50,50)
		setupAxes(hHoTimeAboveThr)
		hHoTimeAboveThr.Draw()
	
		fit = TF1("fit","gaus",-10,10)
		fit.SetParameter(1,0)
		fit.SetParameter(2,1)
		fit.SetLineWidth(3)
		hHoTimeAboveThr.Fit(fit,'','R',-12.5,7)
		
		self.debug(80*'#')
		self.debug('Chi^2: %5.2f' % fit.GetChisquare())
		self.debug('NDF: %d' % fit.GetNDF())
		self.debug(80*'#')
		
		legend = getLegend(x1=.1, y1=.85, x2=.415, y2=.95)
		legend.AddEntry(hHoTimeAboveThr,'HO (E_{Rec} > 0.2 GeV)','l')
		legend.AddEntry(fit,'Fit','l')
		legend.Draw()
		
		pText = TPaveText(0.78,0.85,0.97,0.95,'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",marginRight=.03)
		
		return c3,pText,hHoTimeAboveThr,legend
Exemplo n.º 5
0
    def makeIntegralPlot(self, datasetName):
        cControlPlot = TCanvas('cControlPlots', 'control plot integral')
        xData = [
            self.cached_data['x']['values'], self.cached_data['x']['errors']
        ]
        dataAllL1, errorAllL1 = self.getHistogramIntegralsAsList(
            'l1PtResolution/' + datasetName)
        dataMatch, errorMatch = self.getHistogramIntegralsAsList(
            'l1PtResolution/' + datasetName + "HoMatch")
        dataNoMatch, errorNoMatch = self.getHistogramIntegralsAsList(
            'l1PtResolution/' + datasetName + "NotHoMatch")

        graphIntegralsAllL1 = getTGraphErrors(xData[0],
                                              dataAllL1,
                                              ex=xData[1],
                                              ey=errorAllL1)
        graphIntegralsMatch = getTGraphErrors(xData[0],
                                              dataMatch,
                                              ex=xData[1],
                                              ey=errorMatch)
        graphIntegralsNoMatch = getTGraphErrors(xData[0],
                                                dataNoMatch,
                                                ex=xData[1],
                                                ey=errorNoMatch)

        graphIntegralsAllL1.SetMarkerStyle(21)
        graphIntegralsAllL1.SetTitle('Integrals of ' + datasetName +
                                     ';p_{T} / GeV;# entries')
        graphIntegralsAllL1.SetMarkerColor(colorRwthDarkBlue)
        graphIntegralsAllL1.SetLineColor(colorRwthDarkBlue)

        graphIntegralsMatch.SetMarkerStyle(20)
        graphIntegralsMatch.SetMarkerColor(colorRwthMagenta)
        graphIntegralsMatch.SetLineColor(colorRwthMagenta)

        graphIntegralsNoMatch.SetMarkerStyle(34)
        graphIntegralsNoMatch.SetMarkerColor(colorRwthTuerkis)
        graphIntegralsNoMatch.SetLineColor(colorRwthTuerkis)

        graphIntegralsAllL1.Draw('ap')
        graphIntegralsMatch.Draw('samep')
        graphIntegralsNoMatch.Draw('samep')

        label = self.drawLabel()

        setupAxes(graphIntegralsAllL1)
        legend2 = getLegend(y2=.9)
        legend2.AddEntry(graphIntegralsAllL1, datasetName, 'ep')
        legend2.AddEntry(graphIntegralsMatch, datasetName + " And HO", 'ep')
        legend2.AddEntry(graphIntegralsNoMatch, datasetName + " !HO", 'ep')
        legend2.Draw()
        cControlPlot.Update()

        self.storeCanvas(cControlPlot, 'rmsVsPt_integrals' + datasetName)
        return label, legend2, graphIntegralsMatch, graphIntegralsNoMatch, cControlPlot, graphIntegralsAllL1
Exemplo n.º 6
0
	def plotEnergyNormalizedToMip(self):
		ho = self.fileHandler.getHistogram("energy/horeco_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		canv = TCanvas("cEnergyNormToMip",'Energy Norm To MIP',1200,1200)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('Normalized energy distribution of HO hits (to MIP Maximum)')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('rel. fraction')
		#ho.GetXaxis().SetRangeUser(-2,6)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Scale(1/ho.GetBinContent(ho.FindBin(MIP_PEAK_POSITION)))
		ho.Draw()
		
		label = self.drawLabel()
		
		legend = getLegend(0.5,0.65,0.9,0.9)
		legend.AddEntry(ho,'All HO hits','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Scale(1/L1MuonAndHoMatch.GetBinContent(L1MuonAndHoMatch.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatch.Draw('same')
			legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Scale(1/L1MuonAndHoMatchAboveThr.GetBinContent(L1MuonAndHoMatchAboveThr.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Scale(1/L1MuonAndHoMatchAboveThrFilt.GetBinContent(L1MuonAndHoMatchAboveThrFilt.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		
	
		self.storeCanvas(canv,'energyNormToMip')
		canv.SaveAs("plots/energy/energyNormToMip.pdf")
	
		return canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,label, legend
Exemplo n.º 7
0
	def plotEnergyNormalizedToMip(self):
		ho = self.fileHandler.getHistogram("energy/horeco_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		canv = TCanvas("cEnergyNormToMip",'Energy Norm To MIP',1200,1200)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('Normalized energy distribution of HO hits (to MIP Maximum)')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('rel. fraction')
		#ho.GetXaxis().SetRangeUser(-2,6)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Scale(1/ho.GetBinContent(ho.FindBin(MIP_PEAK_POSITION)))
		ho.Draw()
		
		label = self.drawLabel()
		
		legend = getLegend(0.5,0.65,0.9,0.9)
		legend.AddEntry(ho,'All HO hits','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Scale(1/L1MuonAndHoMatch.GetBinContent(L1MuonAndHoMatch.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatch.Draw('same')
			legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Scale(1/L1MuonAndHoMatchAboveThr.GetBinContent(L1MuonAndHoMatchAboveThr.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Scale(1/L1MuonAndHoMatchAboveThrFilt.GetBinContent(L1MuonAndHoMatchAboveThrFilt.FindBin(MIP_PEAK_POSITION)))
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		
	
		self.storeCanvas(canv,'energyNormToMip')
		canv.SaveAs("plots/energy/energyNormToMip.pdf")
	
		return canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,label, legend
Exemplo n.º 8
0
	def plotEnergy(self):

		ho = self.fileHandler.getHistogram("energy/horeco_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		canv = TCanvas("energieCanvas",'Energy canvas',1200,1200)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('Energy distribution of HO hits')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('N')
		ho.GetXaxis().SetRangeUser(-2,6)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Draw()
		
		label = self.drawLabel()
		
		legend = getLegend(0.5,0.65,0.9,0.9)
		legend.AddEntry(ho,'All HO hits','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Draw('same')
	#		legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		
		self.storeCanvas(canv,'energy')
	
		#f = TFile.Open("plots/energy/energy.root","RECREATE")
		#canv.Write()
		#f.Close()
		return [canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,label,legend]
Exemplo n.º 9
0
	def compareL1Count(self):
		hSim = self.fileHandlerSimulation.getHistogram('L1MuonPresent_Pt')
		hSimPu = self.fileHandlerSimulationPu.getHistogram('L1MuonPresent_Pt')
		hData = self.fileHandler.getHistogram('L1MuonPresent_Pt')
		
	#	hSimPu.Sumw2()
	#	hSim.Sumw2()

		hSim.Scale(1/hSim.Integral(),'width')
		hSimPu.Scale(1/hSimPu.Integral(),'width')
		hData.Scale(1/hData.Integral(),'width')
		
		c = TCanvas('cNvsPt','Nvs pt')
		c.cd().SetLeftMargin(0.17)
		c.cd().SetBottomMargin(0.15)
		
		hSim.SetMarkerStyle(20)
		hSim.SetMarkerColor(colorRwthLila)
		hSim.SetLineColor(colorRwthLila)
		hSim.GetYaxis().SetRangeUser(0,0.03)
		
		hSimPu.SetMarkerStyle(21)
		hSimPu.SetMarkerColor(colorRwthOrange)
		hSimPu.SetLineColor(colorRwthOrange)
		hSimPu.SetTitle(';p_{T,L1} / GeV;Normalized fraction / #frac{1}{GeV}')#'Normalized distribution of p_{T};p_{T,L1};normalized fraction / binwidth')
		hSimPu.SetStats(0)
		hSimPu.GetXaxis().SetRangeUser(0,20)
		hSimPu.Draw('lp')
		hSim.Draw('same,lp')		
		setupAxes(hSimPu)

		hSimPu.GetYaxis().SetTitleOffset(1.35)
		hSimPu.GetXaxis().SetTitleOffset(1.)

		hData.SetMarkerStyle(22)
		hData.SetMarkerColor(colorRwthTuerkis)
#		hData.Draw('same,p')
		
		legend = getLegend(x1 = 0.65,y1 = 0.65,y2=.95,x2=.98)
		legend.AddEntry(hSim,'Sim','lp')
		legend.AddEntry(hSimPu,'Sim, PU52','lp')
#		legend.AddEntry(hData,'Data','ep')
		legend.Draw()
				
		c.Update()
		self.storeCanvas(c, 'l1CountComparison/l1CountNormalized',marginRight=.02,marginLeft=.17)
						#markPosition={'x1ndc' : 0.16, 'y1ndc' : 0.898, 'x2ndc' : 0.319, 'y2ndc' : 0.940})
		return hSim,c,hSimPu,hData,legend
Exemplo n.º 10
0
	def plotHoThresholdScan(self):
		canvas = TCanvas('cThresholdScan')
		canvas.SetLogy()
		xVals = []
		yVals = []
		yErr = []
		
		meanValues = []
		rmsValues = []
		
		for i in range(0,199):
			hist = self.fileHandler.getHistogram('hoMuonAnalyzer/multiplicity/recHitThrScan%d_Multiplicity' % i)
			hist.GetXaxis().SetRangeUser(0,50)
			hist.Draw()
			canvas.SaveAs('plots/hoThresholdScan/hist%fGeV.gif' % ((i+1)*0.025))
			yVals.append(hist.GetBinCenter(hist.GetMaximumBin()))
			yErr.append(math.sqrt(yVals[-1]))
			xVals.append((i+1)*0.025)
			meanValues.append(hist.GetMean())
			rmsValues.append(hist.GetRMS())
			#getMedian(hist)
		graph = getTGraphErrors(xVals, yVals, ey=yErr)
		graph.SetMarkerStyle(20)
		graph.SetMarkerColor(colorRwthDarkBlue)
		graph.SetLineColor(colorRwthDarkBlue)
		graph.SetTitle('Number of HORecHits per Event;E_{Thr} / GeV;# per Event')
		setupAxes(graph)
		graph.GetXaxis().SetRangeUser(0,2)
		graph.Draw('ap')
		
		graphMean = getTGraphErrors(xVals, meanValues, ey=rmsValues)
		graphMean.SetMarkerStyle(21)
		graphMean.SetMarkerColor(colorRwthMagenta)
		graphMean.SetLineColor(colorRwthMagenta)
		graphMean.Draw('samep')
		
		legend = getLegend(y2 = 0.9)
		legend.AddEntry(graph,'Most frequent # per Evt.','ep')
		legend.AddEntry(graphMean,'Mean # per Evt.','ep')
		legend.Draw()
		
		label = self.drawLabel()
		
		canvas.Update()
		canvas.SaveAs('plots/hoThresholdScan/hoThresholdScan.gif')
		canvas.SaveAs('plots/hoThresholdScan/hoThresholdScan.pdf')
		return canvas, graph,legend,graphMean,label
Exemplo n.º 11
0
	def plotLoosePtResolution(self):
		c = TCanvas('cLooseResolution','cLooseResolution')

		xData = [self.cached_data['x']['values'],self.cached_data['x']['errors']]
		tight = [self.cached_data['L1']['rms'],
				self.cached_data['L1']['rmsError']]
		tightAndHo = [self.cached_data['L1 And HO']['rms'],
				self.cached_data['L1 And HO']['rmsError']]
		tightAndNotHo = [self.cached_data['L1 !HO']['rms'],
				self.cached_data['L1 !HO']['rmsError']]
		
		graphL1Tight = getTGraphErrors(xData[0], tight[0], ex=xData[1], ey=tight[1])
		graphL1TightHo = getTGraphErrors(xData[0], tightAndHo[0], ex=xData[1], ey=tightAndHo[1])
		graphL1TightNotHo = getTGraphErrors(xData[0], tightAndNotHo[0], ex=xData[1], ey=tightAndNotHo[1])
		
		graphL1TightHo.SetMarkerStyle(20)
		graphL1TightHo.SetTitle('RMS of loose L1 Objects;p_{T,RECO} / GeV;L1 p_{T} RMS / GeV')
		graphL1TightHo.SetMarkerColor(colorRwthDarkBlue)
		graphL1TightHo.SetLineColor(colorRwthDarkBlue)
		
		graphL1TightNotHo.SetMarkerStyle(34)
		graphL1TightNotHo.SetMarkerColor(colorRwthMagenta)
		graphL1TightNotHo.SetLineColor(colorRwthMagenta)
		
		graphL1Tight.SetMarkerStyle(25)
		graphL1Tight.SetMarkerColor(colorRwthGruen)
		graphL1Tight.SetLineColor(colorRwthGruen)
		
		graphL1TightHo.Draw('ap')
		graphL1TightNotHo.Draw('samep')
		graphL1Tight.Draw('samep')
		
		label = self.drawLabel()
		
		setupAxes(graphL1TightHo)
		legend = getLegend(y2 = .9)
		legend.AddEntry(graphL1Tight,'L1','ep')
		legend.AddEntry(graphL1TightHo,'L1 & HO','ep')
		legend.AddEntry(graphL1TightNotHo,'L1 & !HO','ep')
		legend.Draw()
		c.Update()

		self.storeCanvas(c, 'rmsVsPt_loose' + self.truthTag)
	
		c2 = self.makeIntegralPlot('patToL1Muon')
		return c,graphL1TightHo,graphL1TightNotHo,legend,label,graphL1Tight,c2
Exemplo n.º 12
0
	def plotHoThresholdScan(self):
		canvas = TCanvas('cThresholdScan')
		canvas.SetLogy()
		xVals = []
		yVals = []
		yErr = []
		
		meanValues = []
		rmsValues = []
		
		for i in range(0,199):
			hist = self.fileHandler.getHistogram('multiplicity/recHitThrScan%d_Multiplicity' % i)
			hist.GetXaxis().SetRangeUser(0,50)
			hist.Draw()
			self.storeCanvas(canvas,'plots/hoThresholdScan/hist%fGeV.gif' % ((i+1)*0.025))
			yVals.append(hist.GetBinCenter(hist.GetMaximumBin()))
			yErr.append(math.sqrt(yVals[-1]))
			xVals.append((i+1)*0.025)
			meanValues.append(hist.GetMean())
			rmsValues.append(hist.GetRMS())
			#getMedian(hist)
		graph = getTGraphErrors(xVals, yVals, ey=yErr)
		graph.SetMarkerStyle(20)
		graph.SetMarkerColor(colorRwthDarkBlue)
		graph.SetLineColor(colorRwthDarkBlue)
		graph.SetTitle('Number of HORecHits per Event;E_{Thr} / GeV;# per Event')
		setupAxes(graph)
		graph.GetXaxis().SetRangeUser(0,2)
		graph.Draw('ap')
		
		graphMean = getTGraphErrors(xVals, meanValues, ey=rmsValues)
		graphMean.SetMarkerStyle(21)
		graphMean.SetMarkerColor(colorRwthMagenta)
		graphMean.SetLineColor(colorRwthMagenta)
		graphMean.Draw('samep')
		
		legend = getLegend(y2 = 0.9)
		legend.AddEntry(graph,'Most frequent # per Evt.','ep')
		legend.AddEntry(graphMean,'Mean # per Evt.','ep')
		legend.Draw()
		
		label = self.drawLabel()
		
		canvas.Update()
		self.storeCanvas(canvas,'hoThresholdScan')
		return canvas, graph,legend,graphMean,label
Exemplo n.º 13
0
	def makeIntegralPlot(self,datasetName):
		cControlPlot = TCanvas('cControlPlots','control plot integral')
		xData = [self.cached_data['x']['values'],self.cached_data['x']['errors']]
		dataAllL1,errorAllL1 = self.getHistogramIntegralsAsList('l1PtResolution/' + datasetName)
		dataMatch,errorMatch = self.getHistogramIntegralsAsList('l1PtResolution/' + datasetName + "HoMatch")
		dataNoMatch,errorNoMatch = self.getHistogramIntegralsAsList('l1PtResolution/' + datasetName + "NotHoMatch")
		
		graphIntegralsAllL1 = getTGraphErrors(xData[0], dataAllL1, ex=xData[1], ey=errorAllL1)
		graphIntegralsMatch = getTGraphErrors(xData[0], dataMatch, ex=xData[1], ey=errorMatch)
		graphIntegralsNoMatch = getTGraphErrors(xData[0], dataNoMatch, ex=xData[1], ey=errorNoMatch)
		
		graphIntegralsAllL1.SetMarkerStyle(21)
		graphIntegralsAllL1.SetTitle('Integrals of ' + datasetName + ';p_{T} / GeV;# entries')
		graphIntegralsAllL1.SetMarkerColor(colorRwthDarkBlue)
		graphIntegralsAllL1.SetLineColor(colorRwthDarkBlue)
		
		graphIntegralsMatch.SetMarkerStyle(20)
		graphIntegralsMatch.SetMarkerColor(colorRwthMagenta)
		graphIntegralsMatch.SetLineColor(colorRwthMagenta)
		
		graphIntegralsNoMatch.SetMarkerStyle(34)
		graphIntegralsNoMatch.SetMarkerColor(colorRwthTuerkis)
		graphIntegralsNoMatch.SetLineColor(colorRwthTuerkis)
		
		graphIntegralsAllL1.Draw('ap')
		graphIntegralsMatch.Draw('samep')
		graphIntegralsNoMatch.Draw('samep')
		
		label = self.drawLabel()
		
		setupAxes(graphIntegralsAllL1)
		legend2 = getLegend(y2 = .9)
		legend2.AddEntry(graphIntegralsAllL1,datasetName,'ep')
		legend2.AddEntry(graphIntegralsMatch,datasetName + " And HO",'ep')
		legend2.AddEntry(graphIntegralsNoMatch,datasetName + " !HO",'ep')
		legend2.Draw()
		cControlPlot.Update()
		
		self.storeCanvas(cControlPlot, 'rmsVsPt_integrals' + datasetName)
		return label, legend2, graphIntegralsMatch, graphIntegralsNoMatch, cControlPlot,graphIntegralsAllL1
Exemplo n.º 14
0
	def plotEnergyPerWheel(self,sourceName):	
		hoM1 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_M1')
		hoM0 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_M0')
		hoP0 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_P0')
		hoP1 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_P1')
		
		c = TCanvas('cEPerWheel','E Per Wheel')
		c.SetLogy()
		hoM1.SetLineColor(colorRwthDarkBlue)
#		hoM1.GetXaxis().SetRangeUser(-.8,6)
		hoM1.SetStats(0)
		hoM1.SetTitle('Reconstructed Energy per Wheel;E_{Rec} / GeV;# Entries')
		
		hoM0.SetLineColor(colorRwthTuerkis)
		hoP0.SetLineColor(colorRwthGruen)
		hoP1.SetLineColor(colorRwthMagenta)
		
		setupAxes(hoM1)
		
		hoM1.Draw('')
		hoM0.Draw('same')
		hoP0.Draw('same')
		hoP1.Draw('same')
		
		legend = getLegend(x1=.7,y2=0.9,y1=.6)
		legend.AddEntry(hoM1,'Wheel M1','l')
		legend.AddEntry(hoM0,'Wheel M0','l')
		legend.AddEntry(hoP0,'Wheel P0','l')
		legend.AddEntry(hoP1,'Wheel P1','l')
		legend.Draw()
		
		label = self.drawLabel()
		
		c.Update()
				
		return hoM1, hoM0, hoP0, hoP1, legend, c, label
Exemplo n.º 15
0
	def plotEnergyPerWheel(self,sourceName):	
		hoM1 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_M1')
		hoM0 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_M0')
		hoP0 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_P0')
		hoP1 = self.fileHandler.getHistogram('energy/perWheel/' + sourceName + '_Energy_P1')
		
		c = TCanvas('cEPerWheel','E Per Wheel')
		c.SetLogy()
		hoM1.SetLineColor(colorRwthDarkBlue)
#		hoM1.GetXaxis().SetRangeUser(-.8,6)
		hoM1.SetStats(0)
		hoM1.SetTitle('Reconstructed Energy per Wheel;E_{Rec} / GeV;# Entries')
		
		hoM0.SetLineColor(colorRwthTuerkis)
		hoP0.SetLineColor(colorRwthGruen)
		hoP1.SetLineColor(colorRwthMagenta)
		
		setupAxes(hoM1)
		
		hoM1.Draw('')
		hoM0.Draw('same')
		hoP0.Draw('same')
		hoP1.Draw('same')
		
		legend = getLegend(x1=.7,y2=0.9,y1=.6)
		legend.AddEntry(hoM1,'Wheel M1','l')
		legend.AddEntry(hoM0,'Wheel M0','l')
		legend.AddEntry(hoP0,'Wheel P0','l')
		legend.AddEntry(hoP1,'Wheel P1','l')
		legend.Draw()
		
		label = self.drawLabel()
		
		c.Update()
				
		return hoM1, hoM0, hoP0, hoP1, legend, c, label
Exemplo n.º 16
0
	def compareEnergyTightNormalizedToIntegral(self):
		hSimMatched = self.fileHandlerSimulation.getHistogram('energy/patMuonsTight_Energy')
		hDataMatched = self.fileHandler.getHistogram('energy/patMuonsTight_Energy')
		hSimPuMatched = self.fileHandlerSimulationPu.getHistogram('energy/patMuonsTight_Energy')
		hDataMatchedNotTight = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		hSimNoPuMatchedNotTight = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		hSimPuMatchedNotTight = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		
		hSimMatched.Sumw2()
		hDataMatched.Sumw2()
		hSimPuMatched.Sumw2()
		hDataMatchedNotTight.Sumw2()
		hSimNoPuMatchedNotTight.Sumw2()
		hSimPuMatchedNotTight.Sumw2()
		
		hSimMatched.Scale(1/hSimMatched.Integral())
		hDataMatched.Scale(1/hDataMatched.Integral())
		hSimPuMatched.Scale(1/hSimPuMatched.Integral())
		hDataMatchedNotTight.Scale(1/hDataMatchedNotTight.Integral())
		hSimNoPuMatchedNotTight.Scale(1/hSimNoPuMatchedNotTight.Integral())
		hSimPuMatchedNotTight.Scale(1/hSimPuMatchedNotTight.Integral())

				
		res = self.buildTripleCanvasWithResiduals(hSimMatched,hSimPuMatched,hDataMatched,'cL1TightAndHoComparedNorm',legendPostix='L1 + HO',ylabel = 'rel. fraction')
		
		res[0].Update()
		self.storeCanvas(res[0], 'energyComparison/energyAbsoluteL1TightAndHoNorm')
		##
		# Data
		##
		c = TCanvas('cTightAndNotTight','Data tight and not tight',1800,1000)
		hDataMatchedNotTight.SetTitle('L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')
		
		hDataClone = self.createResidualsPlot(c, hDataMatchedNotTight, hDataMatched)
		c.cd(1).cd(1)
		label = self.drawLabel()
		legend = getLegend(x1=0.7,y2=.9)
		legend.AddEntry(hDataMatchedNotTight,'Data, L1 + HO','l')
		legend.AddEntry(hDataMatched,'Data, L1 Tight + HO','l')
		legend.Draw()
		
		c.Update()
		self.storeCanvas(c, 'energyComparison/energyDataL1AndL1TightCompared')
		##
		# No PU
		##
		c2 = TCanvas('cTightAndNotTightNoPu','Sim No PU tight and not tight',1800,1000)
		hSimNoPuMatchedNotTight.SetTitle('L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')
		
		hSimNoPuClone = self.createResidualsPlot(c2, hSimNoPuMatchedNotTight, hSimMatched)
		c2.cd(1).cd(1)
		label2 = self.drawLabel()
		legend2 = getLegend(x1=0.7,y2=.9)
		legend2.AddEntry(hSimNoPuMatchedNotTight,'Sim No PU, L1 + HO','l')
		legend2.AddEntry(hSimMatched,'Sim No PU, L1 Tight + HO','l')
		legend2.Draw()
		
		c2.Update()
		self.storeCanvas(c2, 'energyComparison/energySimNoPuL1AndL1TightCompared')
		##
		# PU 52
		##
		c3 = TCanvas('cTightAndNotTightPu','Sim PU tight and not tight',1800,1000)
		hSimPuMatchedNotTight.SetTitle('L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')
		
		hSimPuClone = self.createResidualsPlot(c3, hSimPuMatchedNotTight, hSimPuMatched)
		c3.cd(1).cd(1)
		label3 = self.drawLabel()
		legend3 = getLegend(x1=0.7,y2=.9)
		legend3.AddEntry(hSimPuMatchedNotTight,'Sim PU 52, L1 + HO','l')
		legend3.AddEntry(hSimPuMatched,'Sim PU 52, L1 Tight + HO','l')
		legend3.Draw()
		
		c3.Update()
		self.storeCanvas(c3, 'energyComparison/energySimPu52L1AndL1TightCompared')
		return res,c,c2,c3,hDataClone,hSimNoPuClone,hSimPuClone,legend,legend2,legend3,label,label2,label3
Exemplo n.º 17
0
	def compareEnergyPerWheel(self):	

		namesHo = [
				'energy/perWheel/horeco_Energy_M1',
				'energy/perWheel/horeco_Energy_M0',
				'energy/perWheel/horeco_Energy_P0',
				'energy/perWheel/horeco_Energy_P1'
				]
		
		namesMatched = [
				'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_M1',
				'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_M0',
				'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_P0',
				'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_P1'
				]
				
		canvas = TCanvas('compareCanvas','comparison',1800,500)
		canvas.Divide(4,1)
		
		objectStorage = []
		
		for i in range (0,4):
			canvas.cd(i+1).SetLogy()
			
			hSimHo = self.fileHandlerSimulation.getHistogram(namesHo[i])
			hSimHo.SetLineColor(colorRwthDarkBlue)
			
			hSimMatch = self.fileHandlerSimulation.getHistogram(namesMatched[i])
			hSimMatch.SetLineColor(colorRwthDarkBlue)
			hSimMatch.SetLineStyle(7)
		
			hDataHo = self.fileHandler.getHistogram(namesHo[i])
			hDataHo.SetLineColor(colorRwthMagenta)
			
			hDataMatch = self.fileHandler.getHistogram(namesMatched[i])
			hDataMatch.SetLineColor(colorRwthMagenta)
			hDataMatch.SetLineStyle(7)
			
			hSimPuHo = self.fileHandlerSimulationPu.getHistogram(namesHo[i])
			hSimPuHo.SetLineColor(colorRwthTuerkis)
			
			hSimPuMatch = self.fileHandlerSimulationPu.getHistogram(namesMatched[i])
			hSimPuMatch.SetLineColor(colorRwthTuerkis)
			hSimPuMatch.SetLineStyle(7)
			
			hSimHo.Draw()
			hSimMatch.Draw('same')
			hDataHo.Draw('same')
			hDataMatch.Draw('same')
			hSimPuHo.Draw('same')
			hSimPuMatch.Draw('same')
			
			legend = getLegend(y1 =.6,y2=.9)
			legend.AddEntry(hSimHo,'Sim, HO Only','l').SetTextFont(62)
			legend.AddEntry(hSimMatch,'Sim, HO matched','l').SetTextFont(62)
			legend.AddEntry(hDataHo,'Data, HO Only','l').SetTextFont(62)
			legend.AddEntry(hDataMatch,'Data HO Matched','l').SetTextFont(62)
			legend.AddEntry(hSimPuHo,'Sim PU52, HO Only','l').SetTextFont(62)
			legend.AddEntry(hSimPuMatch,'Sim PU52 HO Matched','l').SetTextFont(62)
			legend.Draw()
			
			label = drawLabelCmsPrivateData()
			
			objectStorage.append([hSimHo,hSimMatch,hDataHo,hDataMatch,hSimPuHo,hSimPuMatch,legend,label])
		
		canvas.Update()
		self.storeCanvas(canvas,'energyComparison/energyPerWheelDataAndSimNormed')
		return canvas,objectStorage
Exemplo n.º 18
0
	def makeCombinedEtaPlot(self, tight = False):
		hist = self.makeL1TimeVsEtaPlot(('tight_' if tight else '') + 'dtOnly_bxidVsEta')[2]
		countsInL1 = []
		for x in np.arange(-.95,1.05,0.1):
			totalCounter = 0
			zeroCount = 0
			for y in range(-2,3):
				totalCounter += hist.GetBinContent(hist.FindBin(x,y))
				if y == 0:
					zeroCount = hist.GetBinContent(hist.FindBin(x,y))
			countsInL1.append({'total':totalCounter,'zero':zeroCount,'eta':x})
	
		#Graph for results
		graph1 = TEfficiency(hist.GetName(),"",8,-9.195,-.5)
		graph2 = TEfficiency(hist.GetName(),"",8,.5,9.195)
	
		for item in countsInL1:
			if item['total'] == 0:
				continue
			print item['total'],item['zero'],item['eta']
			if item['eta'] < 0:
				graph1.SetTotalEvents(graph1.FindFixBin(-0.5 + item['eta']/0.087),int(item['total']))
				graph1.SetPassedEvents(graph1.FindFixBin(-0.5 + item['eta']/0.087),int(item['zero']))
			else:
				graph2.SetTotalEvents(graph2.FindFixBin(0.5 + item['eta']/0.087),int(item['total']))
				graph2.SetPassedEvents(graph2.FindFixBin(0.5 + item['eta']/0.087),int(item['zero']))
		
		histHo = None
		if tight:
			histHo = self.plotTightHoTimeVsEta()[2][1]
		else:
			histHo = self.plotHoTimeVsEta()[2][1]
			
		histHo.SetTitle('')
		
		canvas = TCanvas('combinedPlot' + ('Tight ' if tight else '') + hist.GetName(),'combinedPlot')
		histHo.Draw('ap')
		canvas.Update()
		canvas.cd().SetTicks(0,0)
		
		histHo.SetMarkerStyle(2)
		histHo.SetLineColor(colorRwthDarkBlue)
		histHo.SetMarkerColor(colorRwthDarkBlue)
		histHo.GetPaintedGraph().GetXaxis().SetRangeUser(-12,12)
		histHo.GetPaintedGraph().GetXaxis().SetLabelColor(colorRwthDarkBlue)
		histHo.GetPaintedGraph().GetXaxis().SetTitleColor(colorRwthDarkBlue)
		histHo.GetPaintedGraph().GetXaxis().SetAxisColor(colorRwthDarkBlue)
		yMax = gPad.GetFrame().GetY2()
		yMin = gPad.GetFrame().GetY1()
		
		#Print average Fraction excluding iEta +/-2
		x = Double(0)
		y = Double(0)
		mean = 0
		var = 0
		for i in range(0,histHo.GetPaintedGraph().GetN()):
			histHo.GetPaintedGraph().GetPoint(i,x,y)
			if abs(x) == 2:
				continue
			mean += y
			var += histHo.GetPaintedGraph().GetErrorY(i)*histHo.GetPaintedGraph().GetErrorY(i)
			
		mean /= histHo.GetPaintedGraph().GetN() - 2
		sigma = sqrt(var / (histHo.GetPaintedGraph().GetN() - 2))

		self.debug("Average fraction excluding iEta +/- 2 %s: %5.2f%% +/- %5.2f%%" % ('[Tight]' if tight else '',mean*100,sigma*100))

		nTotal = 0
		nPassed = 0
		for item in countsInL1:
			if fabs(item['eta']) == 2 or fabs(item['eta'] == 0):
				continue
			nTotal += item['total']
			nPassed += item['zero']

		#Print again with ClopperPearson uncertainty, the counts are for L1!!!
		mean = nPassed/nTotal*100
		sigmaPlus = TEfficiency.ClopperPearson(int(nTotal),int(nPassed),.68,1)*100 - mean
		sigmaMinus = mean - TEfficiency.ClopperPearson(int(nTotal),int(nPassed),.68,0)*100
		#self.debug("Average fraction excluding iEta +/- 2 %s with Clop.Pear.: %5.2f%% +%5.2f%% -%5.2f%%" 
		#		% ('[Tight]' if tight else '',mean,sigmaPlus,sigmaMinus))
	
		
		#Left axis part
		f1 = TF1("f1","x",-0.87,0)
		A1 = TGaxis(-10,yMax,-0.5,yMax,"f1",010,"-")
		A1.SetLineColor(colorRwthRot)
		A1.SetLabelColor(colorRwthRot)
		A1.Draw()
		
		#Right axis part
		f2 = TF1("f2","x",0,0.87)
		A2 = TGaxis(0.5,yMax,10,yMax,"f2",010,"-")
		A2.SetLineColor(colorRwthRot)
		A2.SetLabelColor(colorRwthRot)
		A2.Draw()
		
		#Box for shading out 0
		box = TBox(-.5,yMin,0.5, yMax)
		box.SetLineColor(colorRwthDarkGray)
		box.SetFillColor(colorRwthDarkGray)
		box.SetFillStyle(3013)
		box.Draw('same')
		
		#Left L1 eta
		graph1.SetMarkerColor(colorRwthRot)
		graph1.SetLineColor(colorRwthRot)
		graph1.SetMarkerStyle(20)
		graph1.Draw('same,p')
		
		#Right L1Eta
		graph2.SetMarkerColor(colorRwthRot)
		graph2.SetLineColor(colorRwthRot)
		graph2.SetMarkerStyle(20)
		graph2.Draw('same,p')
		
		#Label for extra axis
		axisLabel = TPaveText( 0.83,0.94,0.9,0.98,"NDC")
		axisLabel.AddText('#eta_{L1}')
		axisLabel.SetBorderSize(0)
		axisLabel.SetFillStyle(0)
		axisLabel.SetTextColor(colorRwthRot)
		axisLabel.SetTextSize(0.06)
		axisLabel.Draw()
		
		#Legend
		legend = getLegend(x1=0.1,y1=0.1,x2=0.4,y2=.35)
		legend.AddEntry(histHo,'HO #in #pm12.5 ns','pe')
		legend.AddEntry(graph1,('Tight ' if tight else '') + 'L1 BXID = 0','pe')
		legend.Draw()
		
		label = self.drawLabel({'x1ndc' : .1, 'y1ndc' : 0.35, 'x2ndc' : .4, 'y2ndc' : 0.4})
		
		canvas.Update()
		self.storeCanvas(canvas, "combinedFractionL1AndHo" + ('Tight' if tight else ''),drawMark=False,drawLabel=False,marginTop=0.08)
			
		return histHo, graph1,canvas,A1,f1,A2,f2,box,graph2,axisLabel,legend
Exemplo n.º 19
0
    def buildTripleCanvasWithResiduals(self,
                                       hSimHo,
                                       hSimPuHo,
                                       hDataHo,
                                       canvasName='cTripleCanvas',
                                       legendPostix='HO Only',
                                       ylabel='# entries'):
        canvas = TCanvas(canvasName, canvasName, 1800, 1000)
        canvas.Divide(3, 1)
        ##
        #	Sim No PU and Data
        ##
        hSimHo.SetLineColor(colorRwthDarkBlue)
        hSimHo.SetStats(0)
        hSimHo.SetTitle('No PU and Data compared;E_{HO} / a.u.;' + ylabel)

        hDataHo.SetLineColor(colorRwthMagenta)
        hSimPuHo.SetLineColor(colorRwthTuerkis)

        pad1 = makeResidualsPad(canvas.cd(1))
        pad1.cd(1).SetLogy()
        pad1.cd(2).SetLogy()
        pad1.cd(1)
        hSimHo.Draw()
        hDataHo.DrawCopy('same')

        label = drawLabelCmsPrivateData()

        legend = getLegend(x1=.5, y1=0.75, y2=.9)
        legend.AddEntry(hSimHo, 'Sim No PU, ' + legendPostix, 'l')
        legend.AddEntry(hDataHo, 'Data, ' + legendPostix, 'l')
        legend.Draw()

        setupAxes(hSimHo)

        ##
        #	Sim PU52 and Data
        ##
        pad2 = makeResidualsPad(canvas.cd(2))
        pad2.cd(1).SetLogy()
        pad2.cd(2).SetLogy()
        pad2.cd(1)
        setupAxes(hSimPuHo)
        hSimPuHo.SetStats(0)
        hSimPuHo.SetTitle('PU52 and Data compared;E_{HO} / a.u.;' + ylabel)
        hSimPuHo.DrawCopy('')
        hDataHo.DrawCopy('same')

        label2 = drawLabelCmsPrivateData()

        legend2 = getLegend(x1=.5, y1=0.75, y2=.9)
        legend2.AddEntry(hSimPuHo, 'Sim PU52, ' + legendPostix, 'l')
        legend2.AddEntry(hDataHo, 'Data, ' + legendPostix, 'l')
        legend2.Draw()

        ##
        #	Sim No PU and Sim PU 52
        ##
        pad3 = makeResidualsPad(canvas.cd(3))
        pad3.cd(1).SetLogy()
        pad3.cd(2).SetLogy()
        pad3.cd(1)
        hSimPuHo.SetStats(0)
        setupAxes(hSimPuHo)
        hSimPuHo.SetTitle('PU52 and No PU Simulation compared;E_{HO} / a.u.;' +
                          ylabel)
        hSimPuHo.Draw('')
        hSimHo.DrawCopy('same')

        label3 = drawLabelCmsPrivateData()

        legend3 = getLegend(x1=.5, y1=0.75, y2=.9)
        legend3.AddEntry(hSimPuHo, 'Sim PU52, ' + legendPostix, 'l')
        legend3.AddEntry(hSimHo, 'Sim No PU, ' + legendPostix, 'l')
        legend3.Draw()

        #Do the ratio
        pad1.cd(2)
        cloneData = hSimHo.Clone('cloneData')
        cloneData.SetTitle(';E_{HO} / a.u.;Sim/Data')
        cloneData.Sumw2()
        setupAxes(cloneData)
        cloneData.GetYaxis().SetTitleSize(0.05)
        cloneData.GetYaxis().SetLabelSize(0.05)
        cloneData.GetXaxis().SetTitleSize(0.05)
        cloneData.GetXaxis().SetLabelSize(0.05)
        cloneData.GetYaxis().CenterTitle()
        cloneData.Divide(hDataHo)
        cloneData.SetLineWidth(1)
        cloneData.SetMarkerStyle(6)
        cloneData.SetMarkerColor(colorRwthMagenta)
        cloneData.SetLineColor(colorRwthMagenta)
        cloneData.Draw('ep')

        pad2.cd(2)
        clonePuAndData = hSimPuHo.Clone('clonePuAndData')
        setupAxes(clonePuAndData)
        clonePuAndData.GetYaxis().SetTitleSize(0.05)
        clonePuAndData.GetYaxis().SetLabelSize(0.05)
        clonePuAndData.GetXaxis().SetTitleSize(0.05)
        clonePuAndData.GetXaxis().SetLabelSize(0.05)
        clonePuAndData.GetYaxis().CenterTitle()
        clonePuAndData.SetTitle(';E_{HO} / a.u.;Sim/Data')
        clonePuAndData.Sumw2()
        clonePuAndData.Divide(hDataHo)
        clonePuAndData.SetLineWidth(1)
        clonePuAndData.SetMarkerStyle(6)
        clonePuAndData.SetMarkerColor(colorRwthTuerkis)
        clonePuAndData.SetLineColor(colorRwthTuerkis)
        clonePuAndData.Draw('ep')

        pad3.cd(2)
        clonePuAndNoPu = hSimHo.Clone('clonePuAndNoPu')
        setupAxes(clonePuAndNoPu)
        clonePuAndNoPu.GetYaxis().SetTitleSize(0.05)
        clonePuAndNoPu.GetYaxis().SetLabelSize(0.05)
        clonePuAndNoPu.GetXaxis().SetTitleSize(0.05)
        clonePuAndNoPu.GetXaxis().SetLabelSize(0.05)
        clonePuAndNoPu.GetYaxis().CenterTitle()
        clonePuAndNoPu.SetTitle(';E_{HO} / a.u.;Sim No PU/Sim PU52')
        clonePuAndNoPu.Sumw2()
        clonePuAndNoPu.Divide(hSimPuHo)
        clonePuAndNoPu.SetLineWidth(1)
        clonePuAndNoPu.SetMarkerStyle(6)
        clonePuAndNoPu.SetMarkerColor(colorRwthDarkBlue)
        clonePuAndNoPu.SetLineColor(colorRwthDarkBlue)
        clonePuAndNoPu.Draw('ep')
        return canvas, hSimHo, hDataHo, hSimPuHo, cloneData, clonePuAndData, clonePuAndNoPu, legend, legend2, legend3, label2, label3, label
Exemplo n.º 20
0
    def compareEnergyPerWheel(self):

        namesHo = [
            'energy/perWheel/horeco_Energy_M1',
            'energy/perWheel/horeco_Energy_M0',
            'energy/perWheel/horeco_Energy_P0',
            'energy/perWheel/horeco_Energy_P1'
        ]

        namesMatched = [
            'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_M1',
            'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_M0',
            'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_P0',
            'energy/perWheel/L1MuonWithHoMatchAboveThr_Energy_P1'
        ]

        canvas = TCanvas('compareCanvas', 'comparison', 1800, 500)
        canvas.Divide(4, 1)

        objectStorage = []

        for i in range(0, 4):
            canvas.cd(i + 1).SetLogy()

            hSimHo = self.fileHandlerSimulation.getHistogram(namesHo[i])
            hSimHo.SetLineColor(colorRwthDarkBlue)

            hSimMatch = self.fileHandlerSimulation.getHistogram(
                namesMatched[i])
            hSimMatch.SetLineColor(colorRwthDarkBlue)
            hSimMatch.SetLineStyle(7)

            hDataHo = self.fileHandler.getHistogram(namesHo[i])
            hDataHo.SetLineColor(colorRwthMagenta)

            hDataMatch = self.fileHandler.getHistogram(namesMatched[i])
            hDataMatch.SetLineColor(colorRwthMagenta)
            hDataMatch.SetLineStyle(7)

            hSimPuHo = self.fileHandlerSimulationPu.getHistogram(namesHo[i])
            hSimPuHo.SetLineColor(colorRwthTuerkis)

            hSimPuMatch = self.fileHandlerSimulationPu.getHistogram(
                namesMatched[i])
            hSimPuMatch.SetLineColor(colorRwthTuerkis)
            hSimPuMatch.SetLineStyle(7)

            hSimHo.Draw()
            hSimMatch.Draw('same')
            hDataHo.Draw('same')
            hDataMatch.Draw('same')
            hSimPuHo.Draw('same')
            hSimPuMatch.Draw('same')

            legend = getLegend(y1=.6, y2=.9)
            legend.AddEntry(hSimHo, 'Sim, HO Only', 'l').SetTextFont(62)
            legend.AddEntry(hSimMatch, 'Sim, HO matched', 'l').SetTextFont(62)
            legend.AddEntry(hDataHo, 'Data, HO Only', 'l').SetTextFont(62)
            legend.AddEntry(hDataMatch, 'Data HO Matched', 'l').SetTextFont(62)
            legend.AddEntry(hSimPuHo, 'Sim PU52, HO Only', 'l').SetTextFont(62)
            legend.AddEntry(hSimPuMatch, 'Sim PU52 HO Matched',
                            'l').SetTextFont(62)
            legend.Draw()

            label = drawLabelCmsPrivateData()

            objectStorage.append([
                hSimHo, hSimMatch, hDataHo, hDataMatch, hSimPuHo, hSimPuMatch,
                legend, label
            ])

        canvas.Update()
        self.storeCanvas(canvas,
                         'energyComparison/energyPerWheelDataAndSimNormed')
        return canvas, objectStorage
Exemplo n.º 21
0
	def plotMatchedHoTime(self):
		c2 = TCanvas("cTimeforMatchedHoHits","Matched Ho time",1200,400)
		c2.Divide(3,1)

		c2.cd(1).SetLeftMargin(.12)
		c2.cd(2).SetLeftMargin(.12)
		c2.cd(3).SetLeftMargin(.12)

		### Plot matched DT/RPC
		c2.cd(1).SetLogy()
		hBxIdBest = self.fileHandler.getHistogram('timingSupport_MatchedDtRpcHo_Time')
		hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport_UnmatchedDtHo_Time')
		hBxIdDtOnlyTight = self.fileHandler.getHistogram('timingSupport_tight_UnmatchedDtHo_Time')
		hBxIdOther = self.fileHandler.getHistogram('timingSupport_OtherCodesHo_Time')
		
		hIntegral = hBxIdDtOnly.Integral()
		hIntegralCentral = hBxIdDtOnly.Integral(
			hBxIdDtOnly.FindBin(-12.5),
			hBxIdDtOnly.FindBin(12.5))
		hIntegralTight = hBxIdDtOnlyTight.Integral()
		hIntegralTighCentral = hBxIdDtOnlyTight.Integral(
			hBxIdDtOnlyTight.FindBin(-12.5),
			hBxIdDtOnlyTight.FindBin(12.5))
		
#		hBxIdBest.Sumw2()
#		hBxIdDtOnly.Sumw2()
#		hBxIdOther.Sumw2()
		hBxIdBest.SetLineColor(colorRwthDarkBlue)
		hBxIdBest.SetLineWidth(3)
		hBxIdBest.SetStats(0)
		hBxIdBest.SetTitle("Matched DT/RPC + HO")
		hBxIdBest.GetXaxis().SetRangeUser(-50,50)
		#hBxIdBest.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdBest.Scale(1/hBxIdBest.Integral())
		hBxIdBest.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdBest)
		setBigAxisTitles(hBxIdBest)
		hBxIdBest.Draw()
		
		### Plot unmatched DT
		c2.cd(2).SetLogy()
		hBxIdDtOnly.SetLineColor(colorRwthDarkBlue)
		hBxIdDtOnly.SetLineWidth(3)
		hBxIdDtOnly.SetStats(0)
		hBxIdDtOnly.SetTitle("Unmatched DT + HO")
		hBxIdDtOnly.GetXaxis().SetRangeUser(-50,50)
		#hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral())
		hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdDtOnly)
		setBigAxisTitles(hBxIdDtOnly)
		hBxIdDtOnly.Draw()
		
		### Plot other codes
		c2.cd(3).SetLogy()
		hBxIdOther.SetLineColor(colorRwthDarkBlue)
		hBxIdOther.SetLineWidth(3)
		hBxIdOther.SetStats(0)
		hBxIdOther.SetTitle("Lower quality muon + HO")
		hBxIdOther.GetXaxis().SetRangeUser(-50,50)
		#hBxIdOther.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdOther.Scale(1/hBxIdOther.Integral())
		hBxIdOther.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdOther)
		setBigAxisTitles(hBxIdOther)
		hBxIdOther.Draw()
		
		hBxIdBest.GetYaxis().SetTitleOffset(1)
		hBxIdDtOnly.GetYaxis().SetTitleOffset(1)
		hBxIdOther.GetYaxis().SetTitleOffset(1)

		self.storeCanvas(c2,"matchedHoTime")
		
		c = TCanvas('cDtOnlyWithTight',"DT only with tight",600,600)
		c.SetLogy()
		hBxIdDtOnlyCopy = hBxIdDtOnly.DrawCopy()
		hBxIdDtOnlyTight.Scale(1/hBxIdDtOnlyTight.Integral())
		hBxIdDtOnlyTight.SetLineColor(colorRwthMagenta)
		hBxIdDtOnlyTight.Draw('same')
		
		legend = getLegend(y1=0.75,y2=.9)
		legend.AddEntry(hBxIdDtOnlyCopy,'DT only','l')
		legend.AddEntry(hBxIdDtOnlyTight,'DT only, tight','l')
		legend.Draw()
		
		self.debug(80*'#')
		self.debug('Not tight: Integral in [-12.5,12.5]:\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegral,
				hIntegralCentral/float(hIntegral)*100,calcSigma(hIntegralCentral, hIntegral)*100))
		self.debug('Tight: Integral in [-12.5,12.5]:\t\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegralTight,
				hIntegralTighCentral/float(hIntegralTight)*100,calcSigma(hIntegralTighCentral, hIntegralTight)*100))
		self.debug(80*'#')
		
		self.storeCanvas(c, 'matchedHoDtOnlyWithTight')
				
		return c2,hBxIdBest,hBxIdDtOnly,hBxIdOther,hBxIdDtOnlyTight,hBxIdDtOnlyCopy,c,legend
Exemplo n.º 22
0
	def plotEnergyNormalized(self):

		ho = self.fileHandler.getHistogram("energy/horeco_Energy")
		hoNoise = self.fileHandler.getHistogram("energy/L1MuonPlusPi_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		L1MuonAndHoMatch = None
		L1MuonAndHoMatchAboveThr = None
		L1MuonAndHoMatchAboveThrFilt = None
		
		canv = TCanvas("energieNormCanvas",'Energy Norm canvas',800,800)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('')#Normalized energy distribution of HO hits')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('rel. fraction')
		ho.GetXaxis().SetRangeUser(-0.2,2)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Scale(1/ho.Integral())
		
		hoNoise.SetLineColor(colorRwthMagenta)
		hoNoise.SetLineWidth(3)
		hoNoise.Scale(1/hoNoise.Integral())
		
		setupAxes(ho)		
		ho.Draw()
		hoNoise.Draw('same')
				
		legend = getLegend(0.4,0.8,0.98,0.95)
		legend.AddEntry(ho,'All HO hits','l')
		legend.AddEntry(hoNoise,'HO hits, no #mu expected','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Scale(1/L1MuonAndHoMatch.Integral())
			L1MuonAndHoMatch.Draw('same')
			legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Scale(1/L1MuonAndHoMatchAboveThr.Integral())
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Scale(1/L1MuonAndHoMatchAboveThrFilt.Integral())
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		setupAxes(ho)
		canv.Update()
		
		ho.GetYaxis().SetTitleOffset(1.)
		canv.Update()
		
		self.storeCanvas(canv,'energyNorm',marginRight=.02,marginLeft=.15)

		return [canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,hoNoise,legend]
Exemplo n.º 23
0
	def plotL1AndTightL1Counters(self):
		hEvent = self.fileHandler.getHistogram('hoMuonAnalyzer/count/Events_Count')
		hAllL1 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/L1Muon_Count')
		hAllL13x3 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/L1Muon3x3_Count')
		hTightL1 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/L1TightMuons_Count')
		hTightL13x3 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/L1TightMuons3x3_Count')
		
		hL1 = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1_Count')
		hL1Reco = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1Reco_Count')
		hL1RecoHo = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoHo_Count')
		hL1RecoHoTight = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoHoTight_Count')
		hL1RecoTight = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoTight_Count')
		hL1RecoTightHo = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoTightHo_Count')
		hL1RecoHoNoThr = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoHoNoThr_Count')
		hL1RecoGaHoNoThr = self.fileHandler.getHistogram('hoMuonAnalyzer/count/energyDeposit_L1RecoGaHoNoThr_Count')
		
		histogramList = [hEvent, hL1, hL1Reco, hL1RecoHo, hL1RecoHoTight,
						hL1RecoTight, hL1RecoTightHo, hL1RecoHoNoThr, hL1RecoGaHoNoThr ]
		
		names = ['hEvent','hL1','hL1Reco','hL1RecoHo','hL1RecoHoTight','hL1RecoTight','hL1RecoTightHo','hL1RecoHoNoThr','hL1RecoGaHoNoThr']
		nL1 = hL1.GetBinContent(2)
		
		self.commandLine.output('###############################################')
		for i,h in enumerate(histogramList):
			self.commandLine.output('%-20s:%8d\t=> %5.2f' % (names[i],h.GetBinContent(2),calcPercent(h.GetBinContent(2),nL1)))
		self.commandLine.output('###############################################')

		
		nL1Reco 		= hL1Reco.GetBinContent(2)
		nL1RecoHo 		= hL1RecoHo.GetBinContent(2)
		nL1RecoHoTight 	= hL1RecoHoTight.GetBinContent(2)
		nL1RecoTight 	= hL1RecoTight.GetBinContent(2)
		nL1RecoTightHo	= hL1RecoTightHo.GetBinContent(2)
		
		N_BINS = 4
		
		binContents = [nL1,nL1Reco,nL1RecoHo,nL1RecoHoTight]
		binLabels = ['L1','L1 -> Reco','L1 + R -> HO','L1 + R + HO -> tight']
		
		binContentsInverted = [nL1,nL1Reco,nL1RecoTight,nL1RecoTightHo]
		binLabelsInverted = ['L1','L1 -> Reco','L1 + R -> tight','L1 + R + tight -> HO']

		c = TCanvas('cL1AndTightL1Count','L1AndTightL1Count')
		
		h = TH1D('hL1AndTightL1Count','L1 Cutflow',4,-0.5,N_BINS - .5)
		hInverted = TH1D('hL1AndTightL1CountInverted','L1 Efficiency',4,-0.5,N_BINS - .5)
		hInverted.SetFillStyle(3002)
		hInverted.SetFillColor(colorRwthOrange)
		hInverted.SetLineColor(colorRwthOrange)
		hInverted.SetLineStyle(3)
		
		hL13x3Alone = TH1D('hL1And3x3Alone','',1,1.5,2.5)
		hL13x3Alone.SetBinContent(1,nL1RecoHo/nL1Reco)
		hL13x3Alone.SetBinError(1,calcSigma(nL1RecoHo,nL1Reco))
		hL13x3Alone.SetLineColor(colorRwthMagenta)
		
		hTightL13x3Alone = TH1D('hTightL1And3x3Alone','',1,2.5,3.5)
		hTightL13x3Alone.SetBinContent(1,nL1RecoHoTight/nL1RecoHo)
		hTightL13x3Alone.SetBinError(1,calcSigma(nL1RecoHoTight,nL1RecoHo))
		hTightL13x3Alone.SetLineColor(colorRwthTuerkis)
		
		for i in range(2,N_BINS + 1):
			h.SetBinContent(i,binContents[i-1]/binContents[1])
			h.GetXaxis().SetBinLabel(i,binLabels[i-1])
			hInverted.SetBinContent(i,binContentsInverted[i-1]/binContentsInverted[1])
			hInverted.GetXaxis().SetBinLabel(i,binLabelsInverted[i-1])
			
		h.GetXaxis().SetBinLabel(1,'L1')
		h.SetBinContent(1,1)
		hInverted.GetXaxis().SetBinLabel(1,'L1')
		hInverted.SetBinContent(1,1)
		
		h.SetLineColor(colorRwthDarkBlue)
		h.SetStats(0)
		h.GetYaxis().SetTitle('rel. fraction')
		h.Draw()
#		hL13x3Alone.Draw('same e')
#		hTightL13x3Alone.Draw('same e')
		hInverted.Draw('same')
		hInverted.GetXaxis().Draw('same')
		
		setupAxes(h)
		
		legend = getLegend(y2=.9,x1=.55)
		legend.AddEntry(h,'First match HO then use tight','l')
#		legend.AddEntry(hL13x3Alone,'3x3 matching normed to # L1 + R','le')
#		legend.AddEntry(hTightL13x3Alone,'Normed to # L1 + R + HO','l')
		legend.AddEntry(hInverted,'Inverted order for HO and tight','f')
		legend.Draw()
		
		label = self.drawLabel()
		
		textObjects = []

		#for (Int_t i=1;i<=30;i++) t.DrawText(h->GetBinCenter(i),yt,Form("%d",i%10));
		for i in range(1,4):
			t = TText()
			t.SetTextSize(0.025)
			t.SetTextAlign(22)
			t.SetTextColor(colorRwthOrange)
			t.DrawTextNDC(getXinNDC(hInverted.GetBinCenter(i+1)),0.05,binLabelsInverted[i])
#			Double_t yt = - h->GetMaximum()/15.;
			textObjects.append(t)
		c.Update()
		self.storeCanvas(c, 'l1AndTightL1Counters')
		
		return h,c,hL13x3Alone,hTightL13x3Alone,label,legend,hInverted,textObjects
Exemplo n.º 24
0
    def plotLoosePtResolution(self):
        c = TCanvas('cLooseResolution', 'cLooseResolution')

        xData = [
            self.cached_data['x']['values'], self.cached_data['x']['errors']
        ]
        tight = [
            self.cached_data['L1']['rms'], self.cached_data['L1']['rmsError']
        ]
        tightAndHo = [
            self.cached_data['L1 And HO']['rms'],
            self.cached_data['L1 And HO']['rmsError']
        ]
        tightAndNotHo = [
            self.cached_data['L1 !HO']['rms'],
            self.cached_data['L1 !HO']['rmsError']
        ]

        graphL1Tight = getTGraphErrors(xData[0],
                                       tight[0],
                                       ex=xData[1],
                                       ey=tight[1])
        graphL1TightHo = getTGraphErrors(xData[0],
                                         tightAndHo[0],
                                         ex=xData[1],
                                         ey=tightAndHo[1])
        graphL1TightNotHo = getTGraphErrors(xData[0],
                                            tightAndNotHo[0],
                                            ex=xData[1],
                                            ey=tightAndNotHo[1])

        graphL1TightHo.SetMarkerStyle(20)
        graphL1TightHo.SetTitle(
            'RMS of loose L1 Objects;p_{T,RECO} / GeV;L1 p_{T} RMS / GeV')
        graphL1TightHo.SetMarkerColor(colorRwthDarkBlue)
        graphL1TightHo.SetLineColor(colorRwthDarkBlue)

        graphL1TightNotHo.SetMarkerStyle(34)
        graphL1TightNotHo.SetMarkerColor(colorRwthMagenta)
        graphL1TightNotHo.SetLineColor(colorRwthMagenta)

        graphL1Tight.SetMarkerStyle(25)
        graphL1Tight.SetMarkerColor(colorRwthGruen)
        graphL1Tight.SetLineColor(colorRwthGruen)

        graphL1TightHo.Draw('ap')
        graphL1TightNotHo.Draw('samep')
        graphL1Tight.Draw('samep')

        label = self.drawLabel()

        setupAxes(graphL1TightHo)
        legend = getLegend(y2=.9)
        legend.AddEntry(graphL1Tight, 'L1', 'ep')
        legend.AddEntry(graphL1TightHo, 'L1 & HO', 'ep')
        legend.AddEntry(graphL1TightNotHo, 'L1 & !HO', 'ep')
        legend.Draw()
        c.Update()

        self.storeCanvas(c, 'rmsVsPt_loose' + self.truthTag)

        c2 = self.makeIntegralPlot('patToL1Muon')
        return c, graphL1TightHo, graphL1TightNotHo, legend, label, graphL1Tight, c2
Exemplo n.º 25
0
	def plotLoosePtResolution(self):
		c = TCanvas('cLooseResolution','cLooseResolution')
		xData = self.getXaxisData()
		tightAndHo = self.getHistoDataAsList('hoMuonAnalyzer/l1PtResolution/L1MuonTruthHoMatch')
		tightAndNotHo = self.getHistoDataAsList('hoMuonAnalyzer/l1PtResolution/L1MuonTruthNotHoMatch')
		
		graphL1TightHo = getTGraphErrors(xData[0], tightAndHo[0], ex=xData[1], ey=tightAndHo[1])
		graphL1TightNotHo = getTGraphErrors(xData[0], tightAndNotHo[0], ex=xData[1], ey=tightAndNotHo[1])
		
		graphL1TightHo.SetMarkerStyle(20)
		graphL1TightHo.SetTitle('RMS of loose L1 Objects;p_{T} / GeV;RMS / GeV')
		graphL1TightHo.SetMarkerColor(colorRwthDarkBlue)
		graphL1TightHo.SetLineColor(colorRwthDarkBlue)
		
		graphL1TightNotHo.SetMarkerStyle(34)
		graphL1TightNotHo.SetMarkerColor(colorRwthMagenta)
		graphL1TightNotHo.SetLineColor(colorRwthMagenta)
		
		graphL1TightHo.Draw('ap')
		graphL1TightNotHo.Draw('samep')
		
		label = self.drawLabel()
		
		setupAxes(graphL1TightHo)
		legend = getLegend(y2 = .9)
		legend.AddEntry(graphL1TightHo,'L1 & HO','ep')
		legend.AddEntry(graphL1TightNotHo,'L1 & !HO','ep')
		legend.Draw()
		c.Update()

		self.storeCanvas(c, 'rmsVsPt_loose')
		##
		# Plot the integral for each histogram as a control plot
		##
		cControlPlot = TCanvas('cControlPlotsLoose','control plot integral')
		dataMatch,errorMatch = self.getHistogramIntegralsAsList('hoMuonAnalyzer/l1PtResolution/L1MuonTruthHoMatch')
		dataNoMatch,errorNoMatch = self.getHistogramIntegralsAsList('hoMuonAnalyzer/l1PtResolution/L1MuonTruthNotHoMatch')
		graphIntegralsMatch = getTGraphErrors(xData[0], dataMatch, ex=xData[1], ey=errorMatch)
		graphIntegralsNoMatch = getTGraphErrors(xData[0], dataNoMatch, ex=xData[1], ey=errorNoMatch)
		
		graphIntegralsMatch.SetMarkerStyle(20)
		graphIntegralsMatch.SetTitle('Integral of loose L1 Object histograms;p_{T} / GeV;# entries')
		graphIntegralsMatch.SetMarkerColor(colorRwthDarkBlue)
		graphIntegralsMatch.SetLineColor(colorRwthDarkBlue)
		
		graphIntegralsNoMatch.SetMarkerStyle(34)
		graphIntegralsNoMatch.SetMarkerColor(colorRwthMagenta)
		graphIntegralsNoMatch.SetLineColor(colorRwthMagenta)
		
		graphIntegralsMatch.Draw('ap')
		graphIntegralsNoMatch.Draw('samep')
		
		label = self.drawLabel()
		
		setupAxes(graphIntegralsMatch)
		legend2 = getLegend(y2 = .9)
		legend2.AddEntry(graphIntegralsMatch,'L1 & HO','ep')
		legend2.AddEntry(graphIntegralsNoMatch,'L1 & !HO','ep')
		legend2.Draw()
		cControlPlot.Update()
		
		self.storeCanvas(cControlPlot, 'rmsVsPt_loose_integrals')
		return c,graphL1TightHo,graphL1TightNotHo,legend,label,graphIntegralsMatch,graphIntegralsNoMatch,legend2,cControlPlot
		
Exemplo n.º 26
0
    def makeQuantilePlot(self, dataSet):
        c = TCanvas(dataSet + 'quantiles')

        graphMean = getTGraphErrors(self.cached_data['x']['values'],
                                    self.cached_data[dataSet]['mean'],
                                    ey=self.cached_data[dataSet]['meanError'],
                                    ex=self.cached_data['x']['errors'])
        setupAxes(graphMean)
        graphMean.SetMarkerStyle(20)
        graphMean.SetMarkerColor(colorRwthDarkBlue)
        graphMean.SetLineColor(colorRwthDarkBlue)

        graphMedian = getTGraphErrors(self.cached_data['x']['values'],
                                      self.cached_data[dataSet]['median'])
        graphMedian.SetMarkerStyle(21)
        graphMedian.SetMarkerColor(colorRwthMagenta)
        graphMedian.SetLineColor(colorRwthMagenta)
        graphMedian.SetFillColor(colorRwthMagenta)

        graphQ50 = getTGraphErrors(self.cached_data['x']['values'],
                                   self.cached_data[dataSet]['q50'])
        graphQ50.SetMarkerStyle(22)
        graphQ50.SetMarkerColor(colorRwthLila)
        graphQ50.SetLineColor(colorRwthLila)

        graphShape68 = TGraph()
        graphShape68.SetName(dataSet)
        graphShape68.SetFillStyle(3001)
        graphShape68.SetFillColor(colorRwthGruen)
        graphShape68.SetLineColor(colorRwthGruen)

        for i in zip(self.cached_data['x']['values'],
                     self.cached_data[dataSet]['q16']):
            graphShape68.SetPoint(graphShape68.GetN(), i[0], i[1])

        for i in zip(reversed(self.cached_data['x']['values']),
                     reversed(self.cached_data[dataSet]['q84'])):
            graphShape68.SetPoint(graphShape68.GetN(), i[0], i[1])

        graphShape68.GetYaxis().SetRangeUser(0, 200)
        graphShape68.SetTitle("Mean, Median, and Quantiles of " + dataSet +
                              " p_{T};p_{T,Reco} / GeV;p_{T,L1} / GeV")
        setupAxes(graphShape68)

        graphShape68.Draw('a f')
        graphMean.Draw('same p')
        graphMedian.Draw('same,l')
        graphQ50.Draw('same,l')

        legend = getLegend(y2=.9)
        legend.AddEntry(graphMean, dataSet + ' p_{T} Mean', 'ep')
        legend.AddEntry(graphMedian, dataSet + ' p_{T} Median', 'l')
        legend.AddEntry(graphShape68, dataSet + ' p_{T} Q_{25} - Q_{75}', 'f')
        legend.AddEntry(graphQ50, dataSet + ' p_{T} Q_{50}', 'l')
        legend.Draw()

        label = self.drawLabel()

        c.Update()
        self.storeCanvas(
            c, 'quantiles_' + self.truthTag + '_' +
            dataSet.replace(' ', '_').replace('!', 'Not'))
        return c, graphMean, legend, label, graphMedian, graphShape68, graphQ50
Exemplo n.º 27
0
	def plotPtResolutionHistograms(self):
		ptVals = []
		ptErr = []
		rmsL1 = []
		rmsL1Err = []
		rmsL1Tight = []
		rmsL1TightErr = []
		rmsL1AndHo = []
		rmsL1AndHoErr = []
		rmsL1TightAndHo = []
		rmsL1TightAndHoErr = []
		rmsL1NotHo = []
		rmsL1NotHoErr = []
		rmsL1TightNotHo = []
		rmsL1TightNotHoErr = []
		
		graphL1Fit = TGraphErrors()
		
		for i in range(0,121):
			#calculate pt range from bin number
			histPt = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTruthBin%d' % i)
			histPtTight = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTightTruthBin%d' % i)
			histPtMatch = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTruthHoMatchBin%d' % i)
			histPtTightMatch = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTightTruthHoMatchBin%d' % i)
			histNoMatch = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTruthNotHoMatchBin%d' % i)
			histTightNoMatch = self.fileHandler.getHistogram('hoMuonAnalyzer/l1PtResolution/L1MuonTightTruthNotHoMatchBin%d' % i)
			c = TCanvas()
			c.SetLogy()
			if i < 40:
				ptVals.append(i + 0.5)
				ptErr.append(0.5)
			else:
				ptVals.append(i*2 - 40 + 1)
				ptErr.append(1)
			if histPt == None:
				rmsL1.append(0)
				rmsL1Err.append(0)
				continue
			rmsL1.append(histPt.GetRMS())
			rmsL1Err.append(histPt.GetRMSError())
			setupAxes(histPt)
			histPt.SetLineWidth(3)
			histPt.SetLineColor(colorRwthDarkBlue)
			histPt.Draw()
			if(i < 20):
				f1 = TF1("f1", "gaus", histPt.GetBinCenter(histPt.GetMaximumBin()) - 5, 2*i + 5);
				histPt.Fit(f1,"R")
				graphL1Fit.SetPoint(graphL1Fit.GetN(),i*2,f1.GetParameter(2))#,0,f1.GetParameter(3))
				#raw_input('-')
				
			if histPtMatch != None:
				rmsL1AndHo.append(histPtMatch.GetRMS())
				rmsL1AndHoErr.append(histPtMatch.GetRMSError())
				histPtMatch.SetLineWidth(3)
				histPtMatch.SetLineColor(colorRwthMagenta)
				histPtMatch.Draw('same')
			else:
				rmsL1AndHo.append(0)
				rmsL1AndHoErr.append(0)
			
			if histPtTight != None:
				rmsL1Tight.append(histPtTight.GetRMS())
				rmsL1TightErr.append(histPtTight.GetRMSError())
				histPtTight.SetLineWidth(3)
				histPtTight.SetLineColor(colorRwthGruen)
				histPtTight.SetFillStyle(3002)
				histPtTight.SetFillColor(colorRwthGruen)
				histPtTight.Draw('same')
			else:
				rmsL1Tight.append(0)
				rmsL1TightErr.append(0)
				
			if histPtTightMatch != None:
				rmsL1TightAndHo.append(histPtTightMatch.GetRMS())
				rmsL1TightAndHoErr.append(histPtTightMatch.GetRMSError())
				histPtTightMatch.SetLineWidth(3)
				histPtTightMatch.SetLineColor(colorRwthTuerkis)
				histPtTightMatch.Draw('same')
			else:
				rmsL1TightAndHo.append(0)
				rmsL1TightAndHoErr.append(0)
			if histNoMatch != None:
				rmsL1NotHo.append(histNoMatch.GetRMS())
				rmsL1NotHoErr.append(histNoMatch.GetRMSError())
			else:
				rmsL1NotHo.append(0)
				rmsL1NotHoErr.append(0)
			if histTightNoMatch != None:
				rmsL1TightNotHo.append(histTightNoMatch.GetRMS())
				rmsL1TightNotHoErr.append(histTightNoMatch.GetRMSError())
			else:
				rmsL1TightNotHo.append(0)
				rmsL1TightNotHoErr.append(0)
			self.storeCanvas(c, 'hists/L1Muon%d' % i)
		
		c = TCanvas()
		graphL1 = getTGraphErrors(ptVals,rmsL1,ey = rmsL1Err,ex=ptErr)
		graphL1.SetMarkerStyle(20)
		graphL1.SetMarkerColor(colorRwthDarkBlue)
		graphL1.SetLineColor(colorRwthDarkBlue)
		graphL1.SetTitle("RMS of L1 Objects;p_{T} / GeV;RMS / GeV")
		graphL1.GetYaxis().SetRangeUser(0,75)
		graphL1.Draw('ap')
		
		graphL1Tight = getTGraphErrors(ptVals,rmsL1Tight,ey = rmsL1TightErr,ex=ptErr)
		graphL1Tight.SetMarkerStyle(21)
		graphL1Tight.SetMarkerColor(colorRwthGruen)
		graphL1Tight.SetLineColor(colorRwthGruen)
		graphL1Tight.Draw('samep')
		
		graphL1AndHo = getTGraphErrors(ptVals,rmsL1AndHo,ey = rmsL1AndHoErr,ex=ptErr)
		graphL1AndHo.SetMarkerStyle(26)
		graphL1AndHo.SetMarkerColor(colorRwthMagenta)
		graphL1AndHo.SetLineColor(colorRwthMagenta)
		graphL1AndHo.Draw('samep')
		
		graphL1TightAndHo = getTGraphErrors(ptVals,rmsL1TightAndHo,ey = rmsL1TightAndHoErr,ex=ptErr)
		graphL1TightAndHo.SetMarkerStyle(27)
		graphL1TightAndHo.SetMarkerColor(colorRwthRot)
		graphL1TightAndHo.SetLineColor(colorRwthRot)
		graphL1TightAndHo.Draw('samep')
		
		graphL1NotHo = getTGraphErrors(ptVals, rmsL1NotHo, ex=ptErr, ey=rmsL1NotHoErr)
		graphL1NotHo.SetMarkerStyle(29)
		graphL1NotHo.SetMarkerColor(colorRwthOrange)
		graphL1NotHo.SetLineColor(colorRwthOrange)
		graphL1NotHo.Draw('samep')
		
		graphL1TightNotHo = getTGraphErrors(ptVals, rmsL1TightNotHo, ex=ptErr, ey=rmsL1TightNotHoErr)
		graphL1TightNotHo.SetMarkerStyle(34)
		graphL1TightNotHo.SetMarkerColor(colorRwthLila)
		graphL1TightNotHo.SetLineColor(colorRwthLila)
		graphL1TightNotHo.Draw('samep')
		
		setupAxes(graphL1)
		
		legend = getLegend(y2 = .9)
		legend.AddEntry(graphL1,'RMS L1','ep')
		legend.AddEntry(graphL1AndHo,'RMS L1 and HO','ep')
		legend.AddEntry(graphL1Tight,'RMS L1 Tight','ep')
		legend.AddEntry(graphL1TightAndHo,'RMS L1 Tight and HO','ep')
		legend.AddEntry(graphL1NotHo,'RMS L1 & !HO','ep')
		legend.AddEntry(graphL1TightNotHo,'RMS L1 Tight & !HO','ep')
		legend.Draw()
		
		label = self.drawLabel()
		
		c.Update()
		
		self.storeCanvas(c, 'rmsVsPt')
		c2 = TCanvas('cfitResults','fitResults',800,0,800,600)
		graphL1Fit.Draw('AP')
		return c,graphL1,graphL1AndHo,legend,c2,graphL1Fit,label,graphL1TightAndHo,graphL1Tight, graphL1NotHo, graphL1TightNotHo
Exemplo n.º 28
0
    def plotL1AndTightL1Counters(self):
        hEvent = self.fileHandler.getHistogram('count/Events_Count')
        hAllL1 = self.fileHandler.getHistogram('count/L1Muon_Count')
        hAllL13x3 = self.fileHandler.getHistogram('count/L1Muon3x3_Count')
        hTightL1 = self.fileHandler.getHistogram('count/L1TightMuons_Count')
        hTightL13x3 = self.fileHandler.getHistogram(
            'count/L1TightMuons3x3_Count')

        hL1 = self.fileHandler.getHistogram('count/energyDeposit_L1_Count')
        hL1Reco = self.fileHandler.getHistogram(
            'count/energyDeposit_L1Reco_Count')
        hL1RecoHo = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoHo_Count')
        hL1RecoHoTight = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoHoTight_Count')
        hL1RecoTight = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoTight_Count')
        hL1RecoTightHo = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoTightHo_Count')
        hL1RecoHoNoThr = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoHoNoThr_Count')
        hL1RecoGaHoNoThr = self.fileHandler.getHistogram(
            'count/energyDeposit_L1RecoGaHoNoThr_Count')

        histogramList = [
            hEvent, hL1, hL1Reco, hL1RecoHo, hL1RecoHoTight, hL1RecoTight,
            hL1RecoTightHo, hL1RecoHoNoThr, hL1RecoGaHoNoThr
        ]

        names = [
            'hEvent', 'hL1', 'hL1Reco', 'hL1RecoHo', 'hL1RecoHoTight',
            'hL1RecoTight', 'hL1RecoTightHo', 'hL1RecoHoNoThr',
            'hL1RecoGaHoNoThr'
        ]
        nL1 = hL1.GetBinContent(2)

        self.commandLine.output(
            '###############################################')
        for i, h in enumerate(histogramList):
            self.commandLine.output('%-20s:%8d\t=> %6.2f%% +/- %5.2f%%' %
                                    (names[i], h.GetBinContent(2),
                                     calcPercent(h.GetBinContent(2), nL1),
                                     calcSigma(h.GetBinContent(2), nL1) * 100))
        self.commandLine.output(
            '###############################################')

        nL1Reco = hL1Reco.GetBinContent(2)
        nL1RecoHo = hL1RecoHo.GetBinContent(2)
        nL1RecoHoTight = hL1RecoHoTight.GetBinContent(2)
        nL1RecoTight = hL1RecoTight.GetBinContent(2)
        nL1RecoTightHo = hL1RecoTightHo.GetBinContent(2)

        N_BINS = 4

        binContents = [nL1, nL1Reco, nL1RecoHo, nL1RecoHoTight]
        binLabels = [
            'L1', 'L1 -> Reco', 'L1 + R -> HO', 'L1 + R + HO -> tight'
        ]

        binContentsInverted = [nL1, nL1Reco, nL1RecoTight, nL1RecoTightHo]
        binLabelsInverted = [
            'L1', 'L1 -> Reco', 'L1 + R -> tight', 'L1 + R + tight -> HO'
        ]

        c = TCanvas('cL1AndTightL1Count', 'L1AndTightL1Count')

        h = TH1D('hL1AndTightL1Count', 'L1 Cutflow', 4, -0.5, N_BINS - .5)
        hInverted = TH1D('hL1AndTightL1CountInverted', 'L1 Efficiency', 4,
                         -0.5, N_BINS - .5)
        hInverted.SetFillStyle(3002)
        hInverted.SetFillColor(colorRwthOrange)
        hInverted.SetLineColor(colorRwthOrange)
        hInverted.SetLineStyle(3)

        hL13x3Alone = TH1D('hL1And3x3Alone', '', 1, 1.5, 2.5)
        hL13x3Alone.SetBinContent(1, nL1RecoHo / nL1Reco)
        hL13x3Alone.SetBinError(1, calcSigma(nL1RecoHo, nL1Reco))
        hL13x3Alone.SetLineColor(colorRwthMagenta)

        hTightL13x3Alone = TH1D('hTightL1And3x3Alone', '', 1, 2.5, 3.5)
        hTightL13x3Alone.SetBinContent(1, nL1RecoHoTight / nL1RecoHo)
        hTightL13x3Alone.SetBinError(1, calcSigma(nL1RecoHoTight, nL1RecoHo))
        hTightL13x3Alone.SetLineColor(colorRwthTuerkis)

        for i in range(2, N_BINS + 1):
            h.SetBinContent(i, binContents[i - 1] / binContents[1])
            h.GetXaxis().SetBinLabel(i, binLabels[i - 1])
            hInverted.SetBinContent(
                i, binContentsInverted[i - 1] / binContentsInverted[1])
            hInverted.GetXaxis().SetBinLabel(i, binLabelsInverted[i - 1])

        h.GetXaxis().SetBinLabel(1, 'L1')
        h.SetBinContent(1, 1)
        hInverted.GetXaxis().SetBinLabel(1, 'L1')
        hInverted.SetBinContent(1, 1)

        h.SetLineColor(colorRwthDarkBlue)
        h.SetStats(0)
        h.GetYaxis().SetTitle('rel. fraction')
        h.Draw()
        #		hL13x3Alone.Draw('same e')
        #		hTightL13x3Alone.Draw('same e')
        hInverted.Draw('same')
        hInverted.GetXaxis().Draw('same')

        setupAxes(h)

        legend = getLegend(y2=.9, x1=.55)
        legend.AddEntry(h, 'First match HO then use tight', 'l')
        #		legend.AddEntry(hL13x3Alone,'3x3 matching normed to # L1 + R','le')
        #		legend.AddEntry(hTightL13x3Alone,'Normed to # L1 + R + HO','l')
        legend.AddEntry(hInverted, 'Inverted order for HO and tight', 'f')
        legend.Draw()

        label = self.drawLabel()

        textObjects = []

        #for (Int_t i=1;i<=30;i++) t.DrawText(h->GetBinCenter(i),yt,Form("%d",i%10));
        for i in range(1, 4):
            t = TText()
            t.SetTextSize(0.025)
            t.SetTextAlign(22)
            t.SetTextColor(colorRwthOrange)
            t.DrawTextNDC(getXinNDC(hInverted.GetBinCenter(i + 1)), 0.05,
                          binLabelsInverted[i])
            #			Double_t yt = - h->GetMaximum()/15.;
            textObjects.append(t)
        c.Update()
        self.storeCanvas(c, 'l1AndTightL1Counters')

        return h, c, hL13x3Alone, hTightL13x3Alone, label, legend, hInverted, textObjects
Exemplo n.º 29
0
    def makeCombinedEtaPlot(self, tight=False):
        hist = self.makeL1TimeVsEtaPlot(('tight_' if tight else '') +
                                        'dtOnly_bxidVsEta')[2]
        countsInL1 = []
        for x in np.arange(-.95, 1.05, 0.1):
            totalCounter = 0
            zeroCount = 0
            for y in range(-2, 3):
                totalCounter += hist.GetBinContent(hist.FindBin(x, y))
                if y == 0:
                    zeroCount = hist.GetBinContent(hist.FindBin(x, y))
            countsInL1.append({
                'total': totalCounter,
                'zero': zeroCount,
                'eta': x
            })

        #Graph for results
        graph1 = TEfficiency(hist.GetName(), "", 8, -9.195, -.5)
        graph2 = TEfficiency(hist.GetName(), "", 8, .5, 9.195)

        for item in countsInL1:
            if item['total'] == 0:
                continue
            print item['total'], item['zero'], item['eta']
            if item['eta'] < 0:
                graph1.SetTotalEvents(
                    graph1.FindFixBin(-0.5 + item['eta'] / 0.087),
                    int(item['total']))
                graph1.SetPassedEvents(
                    graph1.FindFixBin(-0.5 + item['eta'] / 0.087),
                    int(item['zero']))
            else:
                graph2.SetTotalEvents(
                    graph2.FindFixBin(0.5 + item['eta'] / 0.087),
                    int(item['total']))
                graph2.SetPassedEvents(
                    graph2.FindFixBin(0.5 + item['eta'] / 0.087),
                    int(item['zero']))

        histHo = None
        if tight:
            histHo = self.plotTightHoTimeVsEta()[3][1]
        else:
            histHo = self.plotHoTimeVsEta()[3][1]

        histHo.SetTitle(('Tight ' if tight else '') + 'Unmatched DT + HO')

        canvas = TCanvas(
            'combinedPlot' + ('Tight ' if tight else '') + hist.GetName(),
            'combinedPlot')
        canvas.cd().SetTopMargin(.15)
        histHo.Draw('ap')
        canvas.Update()
        canvas.cd().SetTicks(0, 0)

        histHo.SetMarkerStyle(2)
        histHo.SetLineColor(colorRwthDarkBlue)
        histHo.SetMarkerColor(colorRwthDarkBlue)
        histHo.GetPaintedGraph().GetXaxis().SetRangeUser(-12, 12)
        histHo.GetPaintedGraph().GetXaxis().SetLabelColor(colorRwthDarkBlue)
        histHo.GetPaintedGraph().GetXaxis().SetTitleColor(colorRwthDarkBlue)
        histHo.GetPaintedGraph().GetXaxis().SetAxisColor(colorRwthDarkBlue)
        yMax = gPad.GetFrame().GetY2()
        yMin = gPad.GetFrame().GetY1()

        #Print average Fraction excluding iEta +/-2
        x = Double(0)
        y = Double(0)
        mean = 0
        var = 0
        for i in range(0, histHo.GetPaintedGraph().GetN()):
            histHo.GetPaintedGraph().GetPoint(i, x, y)
            if abs(x) == 2:
                continue
            mean += y
            var += histHo.GetPaintedGraph().GetErrorY(
                i) * histHo.GetPaintedGraph().GetErrorY(i)

        mean /= histHo.GetPaintedGraph().GetN() - 2
        sigma = sqrt(var / (histHo.GetPaintedGraph().GetN() - 2))

        self.debug(
            "Average fraction excluding iEta +/- 2 %s: %5.2f%% +/- %5.2f%%" %
            ('[Tight]' if tight else '', mean * 100, sigma * 100))

        nTotal = 0
        nPassed = 0
        for item in countsInL1:
            if fabs(item['eta']) == 2 or fabs(item['eta'] == 0):
                continue
            nTotal += item['total']
            nPassed += item['zero']

        #Print again with ClopperPearson uncertainty, the counts are for L1!!!
        mean = nPassed / nTotal * 100
        sigmaPlus = TEfficiency.ClopperPearson(int(nTotal), int(nPassed), .68,
                                               1) * 100 - mean
        sigmaMinus = mean - TEfficiency.ClopperPearson(
            int(nTotal), int(nPassed), .68, 0) * 100
        #self.debug("Average fraction excluding iEta +/- 2 %s with Clop.Pear.: %5.2f%% +%5.2f%% -%5.2f%%"
        #		% ('[Tight]' if tight else '',mean,sigmaPlus,sigmaMinus))

        #Left axis part
        f1 = TF1("f1", "x", -0.87, 0)
        A1 = TGaxis(-10, yMax, -0.5, yMax, "f1", 010, "-")
        A1.SetLineColor(colorRwthRot)
        A1.SetLabelColor(colorRwthRot)
        A1.Draw()

        #Right axis part
        f2 = TF1("f2", "x", 0, 0.87)
        A2 = TGaxis(0.5, yMax, 10, yMax, "f2", 010, "-")
        A2.SetLineColor(colorRwthRot)
        A2.SetLabelColor(colorRwthRot)
        A2.Draw()

        #Box for shading out 0
        box = TBox(-.5, yMin, 0.5, yMax)
        box.SetLineColor(colorRwthDarkGray)
        box.SetFillColor(colorRwthDarkGray)
        box.SetFillStyle(3013)
        box.Draw('same')

        #Left L1 eta
        graph1.SetMarkerColor(colorRwthRot)
        graph1.SetLineColor(colorRwthRot)
        graph1.SetMarkerStyle(20)
        graph1.Draw('same,p')

        #Right L1Eta
        graph2.SetMarkerColor(colorRwthRot)
        graph2.SetLineColor(colorRwthRot)
        graph2.SetMarkerStyle(20)
        graph2.Draw('same,p')

        #Label for extra axis
        axisLabel = TPaveText(0.83, 0.85, 0.89, 0.9, "NDC")
        axisLabel.AddText('#eta_{L1}')
        axisLabel.SetBorderSize(0)
        axisLabel.SetFillStyle(0)
        axisLabel.SetTextColor(colorRwthRot)
        axisLabel.SetTextSize(0.05)
        axisLabel.Draw()

        #Legend
        legend = getLegend(x1=0.1, y1=0.1, x2=0.4, y2=.35)
        legend.AddEntry(histHo, 'HO #in #pm12.5 ns', 'pe')
        legend.AddEntry(graph1, ('Tight ' if tight else '') + 'L1 BXID = 0',
                        'pe')
        legend.Draw()

        canvas.Update()
        self.storeCanvas(canvas,
                         "combinedFractionL1AndHo" +
                         ('Tight' if tight else ''),
                         drawMark=False)

        return histHo, graph1, canvas, A1, f1, A2, f2, box, graph2, axisLabel, legend
Exemplo n.º 30
0
	def plotPtResolutionHistograms(self):

		c = TCanvas()
		graphL1 = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1']['rms'],
								ey = self.cached_data['L1']['rmsError'],
								ex=self.cached_data['x']['errors'])
		graphL1.SetMarkerStyle(20)
		graphL1.SetMarkerColor(colorRwthDarkBlue)
		graphL1.SetLineColor(colorRwthDarkBlue)
		graphL1.SetTitle("RMS of L1 Objects;p_{T} / GeV;RMS / GeV")
		graphL1.GetYaxis().SetRangeUser(0,75)
		graphL1.Draw('ap')
		
		graphL1Tight = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1 Tight']['rms'],
								ey = self.cached_data['L1 Tight']['rmsError'],
								ex=self.cached_data['x']['errors'])#rmsL1Tight
		graphL1Tight.SetMarkerStyle(21)
		graphL1Tight.SetMarkerColor(colorRwthGruen)
		graphL1Tight.SetLineColor(colorRwthGruen)
		graphL1Tight.Draw('samep')
		
		graphL1AndHo = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1 And HO']['rms'],
								ey = self.cached_data['L1 And HO']['rmsError'],
								ex=self.cached_data['x']['errors'])#rmsL1AndHo
		graphL1AndHo.SetMarkerStyle(26)
		graphL1AndHo.SetMarkerColor(colorRwthMagenta)
		graphL1AndHo.SetLineColor(colorRwthMagenta)
		graphL1AndHo.Draw('samep')
		
		graphL1TightAndHo = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1 Tight And HO']['rms'],
								ey = self.cached_data['L1 Tight And HO']['rmsError'],
								ex=self.cached_data['x']['errors'])#rmsL1TightAndHo
		graphL1TightAndHo.SetMarkerStyle(27)
		graphL1TightAndHo.SetMarkerColor(colorRwthRot)
		graphL1TightAndHo.SetLineColor(colorRwthRot)
		graphL1TightAndHo.Draw('samep')
		
		graphL1NotHo = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1 !HO']['rms'],
								ey = self.cached_data['L1 !HO']['rmsError'],
								ex=self.cached_data['x']['errors'])#rmsL1NotHo
		graphL1NotHo.SetMarkerStyle(29)
		graphL1NotHo.SetMarkerColor(colorRwthOrange)
		graphL1NotHo.SetLineColor(colorRwthOrange)
		graphL1NotHo.Draw('samep')
		
		graphL1TightNotHo = getTGraphErrors(self.cached_data['x']['values'],
								self.cached_data['L1 Tight !HO']['rms'],
								ey = self.cached_data['L1 Tight !HO']['rmsError'],
								ex=self.cached_data['x']['errors'])#rmsL1TightNotHo
		graphL1TightNotHo.SetMarkerStyle(34)
		graphL1TightNotHo.SetMarkerColor(colorRwthLila)
		graphL1TightNotHo.SetLineColor(colorRwthLila)
		graphL1TightNotHo.Draw('samep')
		
		setupAxes(graphL1)
		
		legend = getLegend(y2 = .9)
		legend.AddEntry(graphL1,'RMS L1','ep')
		legend.AddEntry(graphL1AndHo,'RMS L1 and HO','ep')
		legend.AddEntry(graphL1Tight,'RMS L1 Tight','ep')
		legend.AddEntry(graphL1TightAndHo,'RMS L1 Tight and HO','ep')
		legend.AddEntry(graphL1NotHo,'RMS L1 & !HO','ep')
		legend.AddEntry(graphL1TightNotHo,'RMS L1 Tight & !HO','ep')
		legend.Draw()
		
		label = self.drawLabel()
		
		c.Update()
		
		self.storeCanvas(c, 'rmsVsPt' + self.truthTag)
		#c2 = TCanvas('cfitResults','fitResults',800,0,800,600)
		#graphL1Fit.Draw('AP')
				
		return graphL1,graphL1AndHo,legend,label,graphL1TightAndHo,graphL1Tight, graphL1NotHo, graphL1TightNotHo#,c2,c
Exemplo n.º 31
0
	def buildTripleCanvasWithResiduals(self,hSimHo, hSimPuHo, hDataHo,canvasName = 'cTripleCanvas',legendPostix = 'HO Only',ylabel = '# entries'):
		canvas = TCanvas(canvasName,canvasName,1800,1000)
		canvas.Divide(3,1)
		##
		#	Sim No PU and Data
		##
		hSimHo.SetLineColor(colorRwthDarkBlue)
		hSimHo.SetStats(0)
		hSimHo.SetTitle('No PU and Data compared;E_{HO} / a.u.;' + ylabel)
		
		hDataHo.SetLineColor(colorRwthMagenta)
		hSimPuHo.SetLineColor(colorRwthTuerkis)
		
		pad1 = makeResidualsPad(canvas.cd(1))
		pad1.cd(1).SetLogy()
		pad1.cd(2).SetLogy()
		pad1.cd(1)
		hSimHo.Draw()
		hDataHo.DrawCopy('same')
		
		label = drawLabelCmsPrivateData()

		legend = getLegend(x1=.5,y1 = 0.75,y2=.9)
		legend.AddEntry(hSimHo,'Sim No PU, ' + legendPostix,'l')
		legend.AddEntry(hDataHo,'Data, ' + legendPostix,'l')
		legend.Draw()
		
		setupAxes(hSimHo)

		##
		#	Sim PU52 and Data
		##		
		pad2 = makeResidualsPad(canvas.cd(2))
		pad2.cd(1).SetLogy()
		pad2.cd(2).SetLogy()
		pad2.cd(1)
		setupAxes(hSimPuHo)
		hSimPuHo.SetStats(0)
		hSimPuHo.SetTitle('PU52 and Data compared;E_{HO} / a.u.;' + ylabel)
		hSimPuHo.DrawCopy('')
		hDataHo.DrawCopy('same')
		
		label2 = drawLabelCmsPrivateData()

		legend2 = getLegend(x1=.5,y1 = 0.75,y2=.9)
		legend2.AddEntry(hSimPuHo,'Sim PU52, ' + legendPostix,'l')
		legend2.AddEntry(hDataHo,'Data, ' + legendPostix,'l')
		legend2.Draw()
		
		##
		#	Sim No PU and Sim PU 52
		##
		pad3 = makeResidualsPad(canvas.cd(3))
		pad3.cd(1).SetLogy()
		pad3.cd(2).SetLogy()
		pad3.cd(1)
		hSimPuHo.SetStats(0)
		setupAxes(hSimPuHo)
		hSimPuHo.SetTitle('PU52 and No PU Simulation compared;E_{HO} / a.u.;' + ylabel)
		hSimPuHo.Draw('')
		hSimHo.DrawCopy('same')
		
		label3 = drawLabelCmsPrivateData()

		legend3 = getLegend(x1=.5,y1 = 0.75,y2=.9)
		legend3.AddEntry(hSimPuHo,'Sim PU52, ' + legendPostix,'l')
		legend3.AddEntry(hSimHo,'Sim No PU, ' + legendPostix,'l')
		legend3.Draw()
				
		#Do the ratio
		pad1.cd(2)
		cloneData = hSimHo.Clone('cloneData')
		cloneData.SetTitle(';E_{HO} / a.u.;Sim/Data')
		cloneData.Sumw2()
		setupAxes(cloneData)
		cloneData.GetYaxis().SetTitleSize(0.05)
		cloneData.GetYaxis().SetLabelSize(0.05)
		cloneData.GetXaxis().SetTitleSize(0.05)
		cloneData.GetXaxis().SetLabelSize(0.05)
		cloneData.GetYaxis().CenterTitle()
		cloneData.Divide(hDataHo)
		cloneData.SetLineWidth(1)
		cloneData.SetMarkerStyle(6)
		cloneData.SetMarkerColor(colorRwthMagenta)
		cloneData.SetLineColor(colorRwthMagenta)
		cloneData.Draw('ep')
		
		pad2.cd(2)
		clonePuAndData = hSimPuHo.Clone('clonePuAndData')
		setupAxes(clonePuAndData)
		clonePuAndData.GetYaxis().SetTitleSize(0.05)
		clonePuAndData.GetYaxis().SetLabelSize(0.05)
		clonePuAndData.GetXaxis().SetTitleSize(0.05)
		clonePuAndData.GetXaxis().SetLabelSize(0.05)
		clonePuAndData.GetYaxis().CenterTitle()
		clonePuAndData.SetTitle(';E_{HO} / a.u.;Sim/Data')
		clonePuAndData.Sumw2()
		clonePuAndData.Divide(hDataHo)
		clonePuAndData.SetLineWidth(1)
		clonePuAndData.SetMarkerStyle(6)
		clonePuAndData.SetMarkerColor(colorRwthTuerkis)
		clonePuAndData.SetLineColor(colorRwthTuerkis)
		clonePuAndData.Draw('ep')
		
		pad3.cd(2)
		clonePuAndNoPu = hSimHo.Clone('clonePuAndNoPu')
		setupAxes(clonePuAndNoPu)
		clonePuAndNoPu.GetYaxis().SetTitleSize(0.05)
		clonePuAndNoPu.GetYaxis().SetLabelSize(0.05)
		clonePuAndNoPu.GetXaxis().SetTitleSize(0.05)
		clonePuAndNoPu.GetXaxis().SetLabelSize(0.05)
		clonePuAndNoPu.GetYaxis().CenterTitle()
		clonePuAndNoPu.SetTitle(';E_{HO} / a.u.;Sim No PU/Sim PU52')
		clonePuAndNoPu.Sumw2()
		clonePuAndNoPu.Divide(hSimPuHo)
		clonePuAndNoPu.SetLineWidth(1)
		clonePuAndNoPu.SetMarkerStyle(6)
		clonePuAndNoPu.SetMarkerColor(colorRwthDarkBlue)
		clonePuAndNoPu.SetLineColor(colorRwthDarkBlue)
		clonePuAndNoPu.Draw('ep')
		return canvas, hSimHo,hDataHo,hSimPuHo,cloneData,clonePuAndData,clonePuAndNoPu, legend,legend2,legend3, label2, label3 ,label
Exemplo n.º 32
0
    def compareEnergyTightNormalizedToIntegral(self):
        hSimMatched = self.fileHandlerSimulation.getHistogram(
            'energy/patMuonsTight_Energy')
        hDataMatched = self.fileHandler.getHistogram(
            'energy/patMuonsTight_Energy')
        hSimPuMatched = self.fileHandlerSimulationPu.getHistogram(
            'energy/patMuonsTight_Energy')
        hDataMatchedNotTight = self.fileHandler.getHistogram(
            'energy/L1MuonWithHoMatchAboveThr_Energy')
        hSimNoPuMatchedNotTight = self.fileHandler.getHistogram(
            'energy/L1MuonWithHoMatchAboveThr_Energy')
        hSimPuMatchedNotTight = self.fileHandler.getHistogram(
            'energy/L1MuonWithHoMatchAboveThr_Energy')

        hSimMatched.Sumw2()
        hDataMatched.Sumw2()
        hSimPuMatched.Sumw2()
        hDataMatchedNotTight.Sumw2()
        hSimNoPuMatchedNotTight.Sumw2()
        hSimPuMatchedNotTight.Sumw2()

        hSimMatched.Scale(1 / hSimMatched.Integral())
        hDataMatched.Scale(1 / hDataMatched.Integral())
        hSimPuMatched.Scale(1 / hSimPuMatched.Integral())
        hDataMatchedNotTight.Scale(1 / hDataMatchedNotTight.Integral())
        hSimNoPuMatchedNotTight.Scale(1 / hSimNoPuMatchedNotTight.Integral())
        hSimPuMatchedNotTight.Scale(1 / hSimPuMatchedNotTight.Integral())

        res = self.buildTripleCanvasWithResiduals(hSimMatched,
                                                  hSimPuMatched,
                                                  hDataMatched,
                                                  'cL1TightAndHoComparedNorm',
                                                  legendPostix='L1 + HO',
                                                  ylabel='rel. fraction')

        res[0].Update()
        self.storeCanvas(res[0],
                         'energyComparison/energyAbsoluteL1TightAndHoNorm')
        ##
        # Data
        ##
        c = TCanvas('cTightAndNotTight', 'Data tight and not tight', 1800,
                    1000)
        hDataMatchedNotTight.SetTitle(
            'L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')

        hDataClone = self.createResidualsPlot(c, hDataMatchedNotTight,
                                              hDataMatched)
        c.cd(1).cd(1)
        label = self.drawLabel()
        legend = getLegend(x1=0.7, y2=.9)
        legend.AddEntry(hDataMatchedNotTight, 'Data, L1 + HO', 'l')
        legend.AddEntry(hDataMatched, 'Data, L1 Tight + HO', 'l')
        legend.Draw()

        c.Update()
        self.storeCanvas(c, 'energyComparison/energyDataL1AndL1TightCompared')
        ##
        # No PU
        ##
        c2 = TCanvas('cTightAndNotTightNoPu', 'Sim No PU tight and not tight',
                     1800, 1000)
        hSimNoPuMatchedNotTight.SetTitle(
            'L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')

        hSimNoPuClone = self.createResidualsPlot(c2, hSimNoPuMatchedNotTight,
                                                 hSimMatched)
        c2.cd(1).cd(1)
        label2 = self.drawLabel()
        legend2 = getLegend(x1=0.7, y2=.9)
        legend2.AddEntry(hSimNoPuMatchedNotTight, 'Sim No PU, L1 + HO', 'l')
        legend2.AddEntry(hSimMatched, 'Sim No PU, L1 Tight + HO', 'l')
        legend2.Draw()

        c2.Update()
        self.storeCanvas(c2,
                         'energyComparison/energySimNoPuL1AndL1TightCompared')
        ##
        # PU 52
        ##
        c3 = TCanvas('cTightAndNotTightPu', 'Sim PU tight and not tight', 1800,
                     1000)
        hSimPuMatchedNotTight.SetTitle(
            'L1 Tight and L1 compared;E_{HO} / a.u.;rel. fraction')

        hSimPuClone = self.createResidualsPlot(c3, hSimPuMatchedNotTight,
                                               hSimPuMatched)
        c3.cd(1).cd(1)
        label3 = self.drawLabel()
        legend3 = getLegend(x1=0.7, y2=.9)
        legend3.AddEntry(hSimPuMatchedNotTight, 'Sim PU 52, L1 + HO', 'l')
        legend3.AddEntry(hSimPuMatched, 'Sim PU 52, L1 Tight + HO', 'l')
        legend3.Draw()

        c3.Update()
        self.storeCanvas(c3,
                         'energyComparison/energySimPu52L1AndL1TightCompared')
        return res, c, c2, c3, hDataClone, hSimNoPuClone, hSimPuClone, legend, legend2, legend3, label, label2, label3
Exemplo n.º 33
0
    def plotPtResolutionHistograms(self):

        c = TCanvas()
        graphL1 = getTGraphErrors(self.cached_data['x']['values'],
                                  self.cached_data['L1']['rms'],
                                  ey=self.cached_data['L1']['rmsError'],
                                  ex=self.cached_data['x']['errors'])
        graphL1.SetMarkerStyle(20)
        graphL1.SetMarkerColor(colorRwthDarkBlue)
        graphL1.SetLineColor(colorRwthDarkBlue)
        graphL1.SetTitle("RMS of L1 Objects;p_{T} / GeV;RMS / GeV")
        graphL1.GetYaxis().SetRangeUser(0, 75)
        graphL1.Draw('ap')

        graphL1Tight = getTGraphErrors(
            self.cached_data['x']['values'],
            self.cached_data['L1 Tight']['rms'],
            ey=self.cached_data['L1 Tight']['rmsError'],
            ex=self.cached_data['x']['errors'])  #rmsL1Tight
        graphL1Tight.SetMarkerStyle(21)
        graphL1Tight.SetMarkerColor(colorRwthGruen)
        graphL1Tight.SetLineColor(colorRwthGruen)
        graphL1Tight.Draw('samep')

        graphL1AndHo = getTGraphErrors(
            self.cached_data['x']['values'],
            self.cached_data['L1 And HO']['rms'],
            ey=self.cached_data['L1 And HO']['rmsError'],
            ex=self.cached_data['x']['errors'])  #rmsL1AndHo
        graphL1AndHo.SetMarkerStyle(26)
        graphL1AndHo.SetMarkerColor(colorRwthMagenta)
        graphL1AndHo.SetLineColor(colorRwthMagenta)
        graphL1AndHo.Draw('samep')

        graphL1TightAndHo = getTGraphErrors(
            self.cached_data['x']['values'],
            self.cached_data['L1 Tight And HO']['rms'],
            ey=self.cached_data['L1 Tight And HO']['rmsError'],
            ex=self.cached_data['x']['errors'])  #rmsL1TightAndHo
        graphL1TightAndHo.SetMarkerStyle(27)
        graphL1TightAndHo.SetMarkerColor(colorRwthRot)
        graphL1TightAndHo.SetLineColor(colorRwthRot)
        graphL1TightAndHo.Draw('samep')

        graphL1NotHo = getTGraphErrors(
            self.cached_data['x']['values'],
            self.cached_data['L1 !HO']['rms'],
            ey=self.cached_data['L1 !HO']['rmsError'],
            ex=self.cached_data['x']['errors'])  #rmsL1NotHo
        graphL1NotHo.SetMarkerStyle(29)
        graphL1NotHo.SetMarkerColor(colorRwthOrange)
        graphL1NotHo.SetLineColor(colorRwthOrange)
        graphL1NotHo.Draw('samep')

        graphL1TightNotHo = getTGraphErrors(
            self.cached_data['x']['values'],
            self.cached_data['L1 Tight !HO']['rms'],
            ey=self.cached_data['L1 Tight !HO']['rmsError'],
            ex=self.cached_data['x']['errors'])  #rmsL1TightNotHo
        graphL1TightNotHo.SetMarkerStyle(34)
        graphL1TightNotHo.SetMarkerColor(colorRwthLila)
        graphL1TightNotHo.SetLineColor(colorRwthLila)
        graphL1TightNotHo.Draw('samep')

        setupAxes(graphL1)

        legend = getLegend(y2=.9)
        legend.AddEntry(graphL1, 'RMS L1', 'ep')
        legend.AddEntry(graphL1AndHo, 'RMS L1 and HO', 'ep')
        legend.AddEntry(graphL1Tight, 'RMS L1 Tight', 'ep')
        legend.AddEntry(graphL1TightAndHo, 'RMS L1 Tight and HO', 'ep')
        legend.AddEntry(graphL1NotHo, 'RMS L1 & !HO', 'ep')
        legend.AddEntry(graphL1TightNotHo, 'RMS L1 Tight & !HO', 'ep')
        legend.Draw()

        label = self.drawLabel()

        c.Update()

        self.storeCanvas(c, 'rmsVsPt' + self.truthTag)
        #c2 = TCanvas('cfitResults','fitResults',800,0,800,600)
        #graphL1Fit.Draw('AP')

        return graphL1, graphL1AndHo, legend, label, graphL1TightAndHo, graphL1Tight, graphL1NotHo, graphL1TightNotHo  #,c2,c
Exemplo n.º 34
0
	def plotEnergyNormalized(self):

		ho = self.fileHandler.getHistogram("energy/horeco_Energy")
		hoNoise = self.fileHandler.getHistogram("energy/L1MuonPlusPi_Energy")
		L1MuonAndHoMatch = self.fileHandler.getHistogram('energy/L1MuonWithHoMatch_Energy')
		L1MuonAndHoMatchAboveThr = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThr_Energy')
		L1MuonAndHoMatchAboveThrFilt = self.fileHandler.getHistogram('energy/L1MuonWithHoMatchAboveThrFilt_Energy')
	
		L1MuonAndHoMatch = None
		L1MuonAndHoMatchAboveThr = None
		L1MuonAndHoMatchAboveThrFilt = None
		
		canv = TCanvas("energieNormCanvas",'Energy Norm canvas',1200,1200)
		canv.SetLogy()
	
		ho.SetStats(0)
		ho.SetTitle('Normalized energy distribution of HO hits')
		ho.GetXaxis().SetTitle('Reconstructed HO energy / GeV')
		ho.GetYaxis().SetTitle('rel. fraction')
		ho.GetXaxis().SetRangeUser(-0.2,6)
	
		ho.SetLineColor(colorRwthDarkBlue)
		ho.SetLineWidth(3)
		ho.Scale(1/ho.Integral())
		
		hoNoise.SetLineColor(colorRwthMagenta)
		hoNoise.SetLineWidth(3)
		hoNoise.Scale(1/hoNoise.Integral())
		
		setupAxes(ho)		
		ho.Draw()
		hoNoise.Draw('same')
		
		label = self.drawLabel()
		
		legend = getLegend(0.5,0.65,0.9,0.9)
		legend.AddEntry(ho,'All HO hits','l')
		legend.AddEntry(hoNoise,'HO hits, no #mu expected','l')
		legend.Draw()
	
		if(L1MuonAndHoMatch):
			L1MuonAndHoMatch.SetLineColor(colorRwthTuerkis)
			L1MuonAndHoMatch.SetLineWidth(3)
			L1MuonAndHoMatch.Scale(1/L1MuonAndHoMatch.Integral())
			L1MuonAndHoMatch.Draw('same')
			legend.AddEntry(L1MuonAndHoMatch,'L1Muon + HO match','l')
			
		if(L1MuonAndHoMatchAboveThr):
			L1MuonAndHoMatchAboveThr.SetLineColor(colorRwthRot)
			L1MuonAndHoMatchAboveThr.SetLineWidth(3)
			L1MuonAndHoMatchAboveThr.Scale(1/L1MuonAndHoMatchAboveThr.Integral())
			L1MuonAndHoMatchAboveThr.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThr,'L1Muon + HO match > 0.2 GeV','l')
	
	
		if(L1MuonAndHoMatchAboveThrFilt):
			L1MuonAndHoMatchAboveThrFilt.SetLineColor(colorRwthGruen)
			L1MuonAndHoMatchAboveThrFilt.SetLineWidth(3)
			L1MuonAndHoMatchAboveThrFilt.Scale(1/L1MuonAndHoMatchAboveThrFilt.Integral())
			L1MuonAndHoMatchAboveThrFilt.Draw('same')
			legend.AddEntry(L1MuonAndHoMatchAboveThrFilt,'L1Muon + HO match > 0.2 GeV (In Ho Geom.)','l')
	
		setupAxes(ho)
		canv.Update()
		
		self.storeCanvas(canv,'energyNorm')

		return [canv,ho,L1MuonAndHoMatch, L1MuonAndHoMatchAboveThr,L1MuonAndHoMatchAboveThrFilt,hoNoise,label,legend]
Exemplo n.º 35
0
	def plotMatchedHoTime(self):
		c2 = TCanvas("cTimeforMatchedHoHits","Matched Ho time",1200,400)
		c2.Divide(3,1)
		
		### Plot matched DT/RPC
		c2.cd(1).SetLogy()
		hBxIdBest = self.fileHandler.getHistogram('timingSupport_MatchedDtRpcHo_Time')
		hBxIdDtOnly = self.fileHandler.getHistogram('timingSupport_UnmatchedDtHo_Time')
		hBxIdDtOnlyTight = self.fileHandler.getHistogram('timingSupport_tight_UnmatchedDtHo_Time')
		hBxIdOther = self.fileHandler.getHistogram('timingSupport_OtherCodesHo_Time')
		
		hIntegral = hBxIdDtOnly.Integral()
		hIntegralCentral = hBxIdDtOnly.Integral(
			hBxIdDtOnly.FindBin(-12.5),
			hBxIdDtOnly.FindBin(12.5))
		hIntegralTight = hBxIdDtOnlyTight.Integral()
		hIntegralTighCentral = hBxIdDtOnlyTight.Integral(
			hBxIdDtOnlyTight.FindBin(-12.5),
			hBxIdDtOnlyTight.FindBin(12.5))
		
#		hBxIdBest.Sumw2()
#		hBxIdDtOnly.Sumw2()
#		hBxIdOther.Sumw2()
		hBxIdBest.SetLineColor(colorRwthDarkBlue)
		hBxIdBest.SetLineWidth(3)
		hBxIdBest.SetStats(0)
		hBxIdBest.SetTitle("Matched DT/RPC + HO")
		hBxIdBest.GetXaxis().SetRangeUser(-50,50)
		#hBxIdBest.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdBest.Scale(1/hBxIdBest.Integral())
		hBxIdBest.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdBest)
		setBigAxisTitles(hBxIdBest)
		hBxIdBest.Draw()
		label = self.drawLabel()
		
		### Plot unmatched DT
		c2.cd(2).SetLogy()
		hBxIdDtOnly.SetLineColor(colorRwthDarkBlue)
		hBxIdDtOnly.SetLineWidth(3)
		hBxIdDtOnly.SetStats(0)
		hBxIdDtOnly.SetTitle("Unmatched DT + HO")
		hBxIdDtOnly.GetXaxis().SetRangeUser(-50,50)
		#hBxIdDtOnly.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdDtOnly.Scale(1/hBxIdDtOnly.Integral())
		hBxIdDtOnly.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdDtOnly)
		setBigAxisTitles(hBxIdDtOnly)
		hBxIdDtOnly.Draw()
		
		### Plot other codes
		c2.cd(3).SetLogy()
		hBxIdOther.SetLineColor(colorRwthDarkBlue)
		hBxIdOther.SetLineWidth(3)
		hBxIdOther.SetStats(0)
		hBxIdOther.SetTitle("Lower quality muon + HO")
		hBxIdOther.GetXaxis().SetRangeUser(-50,50)
		#hBxIdOther.GetYaxis().SetRangeUser(2e-4,1)
		hBxIdOther.Scale(1/hBxIdOther.Integral())
		hBxIdOther.GetYaxis().SetTitle("rel. fraction")
		setupAxes(hBxIdOther)
		setBigAxisTitles(hBxIdOther)
		hBxIdOther.Draw()
		
		self.storeCanvas(c2,"matchedHoTime")
		
		c = TCanvas('cDtOnlyWithTight',"DT only with tight",600,600)
		c.SetLogy()
		hBxIdDtOnlyCopy = hBxIdDtOnly.DrawCopy()
		hBxIdDtOnlyTight.Scale(1/hBxIdDtOnlyTight.Integral())
		hBxIdDtOnlyTight.SetLineColor(colorRwthMagenta)
		hBxIdDtOnlyTight.Draw('same')
		
		legend = getLegend(y1=0.75,y2=.9)
		legend.AddEntry(hBxIdDtOnlyCopy,'DT only','l')
		legend.AddEntry(hBxIdDtOnlyTight,'DT only, tight','l')
		legend.Draw()
		
		self.debug(80*'#')
		self.debug('Not tight: Integral in [-12.5,12.5]:\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegral,
				hIntegralCentral/float(hIntegral)*100,calcSigma(hIntegralCentral, hIntegral)*100))
		self.debug('Tight: Integral in [-12.5,12.5]:\t\t %8d => %5.2f%% +/- %5.2f%%' % (hIntegralTight,
				hIntegralTighCentral/float(hIntegralTight)*100,calcSigma(hIntegralTighCentral, hIntegralTight)*100))
		self.debug(80*'#')
		
		self.storeCanvas(c, 'matchedHoDtOnlyWithTight')
				
		return label,c2,hBxIdBest,hBxIdDtOnly,hBxIdOther,hBxIdDtOnlyTight,hBxIdDtOnlyCopy,c,legend
Exemplo n.º 36
0
	def plotL1AndTightL1Counters(self):
		hEvent = self.fileHandler.getHistogram('count/Events_Count')
		hAllL1 = self.fileHandler.getHistogram('count/L1Muon_Count')
		hAllL13x3 = self.fileHandler.getHistogram('count/L1Muon3x3_Count')
		hTightL1 = self.fileHandler.getHistogram('count/L1TightMuons_Count')
		hTightL13x3 = self.fileHandler.getHistogram('count/L1TightMuons3x3_Count')
		
		hL1 = self.fileHandler.getHistogram('count/energyDeposit_L1_Count')
		hL1Reco = self.fileHandler.getHistogram('count/energyDeposit_L1Reco_Count')
		hL1RecoHo = self.fileHandler.getHistogram('count/energyDeposit_L1RecoHo_Count')
		hL1RecoHoTight = self.fileHandler.getHistogram('count/energyDeposit_L1RecoHoTight_Count')
		hL1RecoTight = self.fileHandler.getHistogram('count/energyDeposit_L1RecoTight_Count')
		hL1RecoTightHo = self.fileHandler.getHistogram('count/energyDeposit_L1RecoTightHo_Count')
		hL1RecoHoNoThr = self.fileHandler.getHistogram('count/energyDeposit_L1RecoHoNoThr_Count')
		hL1RecoGaHoNoThr = self.fileHandler.getHistogram('count/energyDeposit_L1RecoGaHoNoThr_Count')
		
		histogramList = [hEvent, hL1, hL1Reco, hL1RecoHo, hL1RecoHoTight,
						hL1RecoTight, hL1RecoTightHo, hL1RecoHoNoThr, hL1RecoGaHoNoThr ]
		
		names = ['hEvent','hL1','hL1Reco','hL1RecoHo','hL1RecoHoTight','hL1RecoTight','hL1RecoTightHo','hL1RecoHoNoThr','hL1RecoGaHoNoThr']
		nL1 = hL1.GetBinContent(2)
		
		self.commandLine.output('###############################################')
		for i,h in enumerate(histogramList):
			self.commandLine.output('%-20s:%8d\t=> %6.2f%% +/- %5.2f%%' % (names[i],h.GetBinContent(2)
					,calcPercent(h.GetBinContent(2),nL1),calcSigma(h.GetBinContent(2),nL1)*100))
		self.commandLine.output('###############################################')

		
		nL1Reco 		= hL1Reco.GetBinContent(2)
		nL1RecoHo 		= hL1RecoHo.GetBinContent(2)
		nL1RecoHoTight 	= hL1RecoHoTight.GetBinContent(2)
		nL1RecoTight 	= hL1RecoTight.GetBinContent(2)
		nL1RecoTightHo	= hL1RecoTightHo.GetBinContent(2)
		
		N_BINS = 4
		
		binContents = [nL1,nL1Reco,nL1RecoHo,nL1RecoHoTight]
		binLabels = ['L1','L1 -> Reco','L1 + R -> HO','L1 + R + HO -> tight']
		
		binContentsInverted = [nL1,nL1Reco,nL1RecoTight,nL1RecoTightHo]
		binLabelsInverted = ['L1','L1 -> Reco','L1 + R -> tight','L1 + R + tight -> HO']

		c = TCanvas('cL1AndTightL1Count','L1AndTightL1Count',1200,900)
				
		h = TH1D('hL1AndTightL1Count','',4,-0.5,N_BINS - .5)
		hInverted = TH1D('hL1AndTightL1CountInverted','',4,-0.5,N_BINS - .5)
		hInverted.SetFillStyle(1001)
		hInverted.SetFillColorAlpha(colorRwthOrange,.5)
		hInverted.SetLineColorAlpha(colorRwthOrange,.5)
		
		hL13x3Alone = TH1D('hL1And3x3Alone','',1,1.5,2.5)
		hL13x3Alone.SetBinContent(1,nL1RecoHo/nL1Reco)
		hL13x3Alone.SetBinError(1,calcSigma(nL1RecoHo,nL1Reco))
		hL13x3Alone.SetLineColor(colorRwthMagenta)
		
		hTightL13x3Alone = TH1D('hTightL1And3x3Alone','',1,2.5,3.5)
		hTightL13x3Alone.SetBinContent(1,nL1RecoHoTight/nL1RecoHo)
		hTightL13x3Alone.SetBinError(1,calcSigma(nL1RecoHoTight,nL1RecoHo))
		hTightL13x3Alone.SetLineColor(colorRwthTuerkis)
		
		for i in range(2,N_BINS + 1):
			h.SetBinContent(i,binContents[i-1]/binContents[1])
			h.GetXaxis().SetBinLabel(i,binLabels[i-1])
			hInverted.SetBinContent(i,binContentsInverted[i-1]/binContentsInverted[1])
			#Very dirty hack to change the order of plotting but have the correct labels !!!
			hInverted.GetXaxis().SetBinLabel(i,binLabels[i-1])#binLabelsInverted[i-1])
			
		h.GetXaxis().SetBinLabel(1,'L1')
		h.SetBinContent(1,1)
		hInverted.SetLabelSize(0.05)
		hInverted.GetXaxis().SetBinLabel(1,'L1')
		hInverted.SetBinContent(1,1)
		
		h.SetLineColor(colorRwthDarkBlue)
		hInverted.SetStats(0)
		hInverted.GetYaxis().SetTitle('rel. fraction')
		
#		hL13x3Alone.Draw('same e')
#		hTightL13x3Alone.Draw('same e')
		hInverted.Draw('')
		hInverted.GetXaxis().Draw('same')
		h.Draw('same')
		
		setupAxes(hInverted)
		
		legend = getLegend(y1=.85,y2=.95,x1=.64,x2=.98)
		legend.AddEntry(h,'First match HO then use tight','l')
#		legend.AddEntry(hL13x3Alone,'3x3 matching normed to # L1 + R','le')
#		legend.AddEntry(hTightL13x3Alone,'Normed to # L1 + R + HO','l')
		legend.AddEntry(hInverted,'Inverted order for HO and tight','f')
		legend.Draw()
		
		#label = self.drawLabel(x1ndc=.69,x2ndc=.99)
		
		textObjects = []
		
		#Manually determined
		xNdcCoordinates = [0.42,0.64,0.86]
		#for (Int_t i=1;i<=30;i++) t.DrawText(h->GetBinCenter(i),yt,Form("%d",i%10));
		for i in range(1,4):
			t = TText()
			t.SetTextSize(0.035)
			t.SetTextAlign(22)
			t.SetTextColor(colorRwthOrange)
			t.DrawTextNDC(xNdcCoordinates[i-1],0.035,binLabelsInverted[i])
#			Double_t yt = - h->GetMaximum()/15.;
			textObjects.append(t)
		c.Update()
		self.storeCanvas(c, 'l1AndTightL1Counters',marginRight=.02)
		
		return h,c,hL13x3Alone,hTightL13x3Alone,legend,hInverted,textObjects