Esempio n. 1
0
	def plotEMaxCounts(self):
		canvas = TCanvas('canvasEmaxcounts','E max counts',1200,1200)
		canvas.cd().SetLogz()
			
		hCounter = self.fileHandler.getHistogram('hoMuonAnalyzer/deltaEtaDeltaPhiEnergy/averageEMaxAroundPointL1MuonPresent_2dCounter')
		#hSum = setupEAvplot(hSum, hCounter,same=True,limitForAll=0.3)
		hCounter.SetTitle('# of E_{Max} in HO tiles around L1 direction;#Delta#eta;#Delta#phi;# Entries')
		hCounter.SetStats(0)
		hCounter.GetXaxis().SetRangeUser(-.5,.5)
		hCounter.GetYaxis().SetRangeUser(-.5,.5)
		hCounter.Draw('colz')
		label = self.drawLabel()
		canvas.Update()		
		setupPalette(hCounter)
		canvas.Update()
		#boxes = drawHoBoxes(canvas)
		self.storeCanvas(canvas,'eMaxCounts')
		
		#Calculate fraction in 3x3 grid
		integralCentral = hCounter.Integral(hCounter.GetXaxis().FindBin(-.0435),hCounter.GetXaxis().FindBin(.0435),
									hCounter.GetYaxis().FindBin(-.0435),hCounter.GetYaxis().FindBin(.0435))
		integral3x3 = hCounter.Integral(hCounter.GetXaxis().FindBin(-.1305),hCounter.GetXaxis().FindBin(.1305),
									hCounter.GetYaxis().FindBin(-.1305),hCounter.GetYaxis().FindBin(.1305))
		integralTotal = hCounter.Integral()
		
		self.output(80*'#')
		self.output('%20s:%5.2f%% +/- %5.2f%%' % ('Central Fraction',calcPercent(integralCentral,integralTotal),
												calcSigma(integralCentral,integralTotal)*100))
		self.output('%20s:%5.2f%% +/- %5.2f%%' % ('3x3 Fraction',calcPercent(integral3x3,integralTotal),
												calcSigma(integral3x3,integralTotal)*100))
		
		self.output(80*'#')
		return canvas,label,hCounter
def plotRpcVsHo():
	hist =fileHandler.getHistogram('hoMuonAnalyzer/correlation/RpcHoAboveThr_TimeCorrelation')
	canvas = TCanvas('canvasRpcVsHo',"RPC vs. HO",1200,1200)
	canvas.cd().SetLogz()

	histNew = getTH2D("histRpcVsHo","RPC BX ID vs. HO > E_{Thr};HO time / ns;BX ID",5,-37.5,87.5#24,-56.25,93.75
						,5,-2.5,2.5)
		
	xAxis = hist.GetXaxis()
	yAxis = hist.GetYaxis()
	nBinsX = xAxis.GetNbins()
	nBinsY = yAxis.GetNbins()
		
	#Fill new histogram with fewer bins
	for i in range( 1 , nBinsX + 1 ):
		for j in range( 1 , nBinsY + 1 ):
			histNew.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,hist.GetBinContent(i,j))

	histNew.SetStats(0)
	histNew.Draw('colz')
	
	canvas.Update()
	
	pal = histNew.GetListOfFunctions().FindObject("palette")
	pal.SetX2NDC(0.92)
	
	#Calcualte fraction at (0,0)
	nCentral = histNew.GetBinContent(histNew.FindBin(0,0))
	nTotal = histNew.Integral()

	fraction = nCentral/float(nTotal)
	fractionUncert = calcSigma(nCentral,nTotal)
	
	sliceFraction = 0
	for i in range(0,5):
		sliceFraction += histNew.GetBinContent(histNew.FindBin(0,-2.5+i))
	
	sliceFractionUncert = calcSigma(sliceFraction,nTotal)
	sliceFraction /= nTotal
	
	paveTextAboveThr = TPaveText(0.1,0.8,0.5,0.9,'NDC')
	paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100))
	paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100))
	paveTextAboveThr.SetBorderSize(1)
	paveTextAboveThr.Draw()
	
	label = getLabelCmsPrivateSimulation()
	label.Draw()
	
	canvas.SaveAs('plots/timeCorrelation/rpcVsHo.pdf')
	canvas.SaveAs('plots/timeCorrelation/rpcVsHo.png')
	
	return hist,canvas,paveTextAboveThr,label
Esempio n. 3
0
def plotEfficiencyForPt(folder,pt):
	if(DEBUG):
		print prefix + 'was called'
	
	#Set plot style
	
	if(DEBUG):
		print prefix + "Getting histogram: %s" % ("hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) + "_Efficiency")
	
	l1Muon = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/GenAndL1MuonPt" + str(pt) + "_Efficiency")
	l1MuonAndHo = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/L1MuonHoRecoPt" + str(pt) + "_Efficiency")
	if(DEBUG):
		print prefix + "Getting histogram: %s" % ("hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) + "_Efficiency")
	l1MuonAndHoAboveThr = fileHandler.getHistogram("hoMuonAnalyzer/efficiency/GenAndL1MuonAndHoAboveThrPt" + str(pt) + "_Efficiency")
	
	canv = TCanvas("efficiencyCanvas" + str(pt),'efficiencyCanvas' + str(pt),1200,1200)
	
	l1Muon.SetMarkerStyle(markerpairs[pt/5 -1][0])
	l1MuonAndHo.SetMarkerStyle(21)
	l1MuonAndHoAboveThr.SetMarkerStyle(markerpairs[pt/5 -1][1])
	
	l1Muon.SetMarkerColor(colorRwthDarkBlue)
	l1MuonAndHo.SetMarkerColor(ROOT.kBlue)
	l1MuonAndHoAboveThr.SetMarkerColor(colorRwthMagenta)   
	
	l1Muon.SetLineColor(colorRwthDarkBlue)
	l1MuonAndHo.SetLineColor(ROOT.kBlue)
	l1MuonAndHoAboveThr.SetLineColor(colorRwthMagenta)
	
	upperPad = TPad("upperPad", "upperPad", .005, .25, .995, .995);
	lowerPad = TPad("lowerPad", "lowerPad", .005, .005, .995, .25);
	upperPad.SetBottomMargin(0)
	lowerPad.SetTopMargin(0)
	upperPad.Draw()
	lowerPad.Draw()
	upperPad.cd()
	l1Muon.Draw()
#	l1MuonAndHo.Draw('same')
	l1MuonAndHoAboveThr.Draw('same')
	
	canv.Update()
	l1Muon.GetPaintedGraph().GetYaxis().SetTitleFont(62)
	l1Muon.GetPaintedGraph().GetYaxis().SetLabelFont(62)
	l1Muon.GetPaintedGraph().GetXaxis().SetRangeUser(0,50)
	#.GetPaintedGraph()
	l1Muon.SetTitle("Efficiency, p_{T} = " + str(pt) + " GeV;p_{T};Eff.")
	canv.Update()

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

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

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

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

	newGraph = TGraph()

	x1 = Double(0)
	y1 = Double(0)
	x2 = Double(0)
	y2 = Double(0)
	
	for i in range(0,50):
		l1MuonGraph.GetPoint(i,x1,y1)
		l1MuonAndHoAboveThrGraph.GetPoint(i,x2,y2)
		newGraph.SetPoint(i,x1,(y1-y2)*100)
	
	
	newGraph.SetMarkerStyle(20)
	newGraph.GetYaxis().SetTitle("%")
	newGraph.Draw("a,p")
	newGraph.GetXaxis().SetLimits(0,50)
	line2 = TLine(0,0,50,0)
	line2.SetLineColor(ROOT.kRed)
	line2.SetLineWidth(2)
	line2.Draw()
	
	##### Finally save the stuff
	
	canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".png")
	canv.SaveAs("plots/efficiency/efficiency" + str(pt) + ".pdf")
	
	f = TFile.Open("plots/efficiency/efficiency" + str(pt) + ".root","RECREATE")
	canv.Write()
	f.Close()
	return [l1Muon,l1MuonAndHoAboveThr,canv,legend,line,paveText,label,newGraph]
def plotHoL1Correlation():
	#Select whether matching to all HO should also be plotted
	plotBoth = True
	histAll = fileHandler.getHistogram('hoMuonAnalyzer/correlation/L1MuonPresentHoMatch_TimeCorrelation')
	histAboveThr = fileHandler.getHistogram('hoMuonAnalyzer/correlation/L1MuonAboveThr_TimeCorrelation')

	label = getLabelCmsPrivateSimulation()
	
	canvas = TCanvas("canvasHoL1Correlation","canvasHoL1Correlation",1600,1200)
	
	if(plotBoth):
		canvas.Divide(2,1)
		canvas.cd(1).SetLogz()
		
		histNew = getTH2D("histNew","Correlation between L1 BX ID and HO;HO time / ns;L1 / BX ID",5,-37.5,87.5#24,-56.25,93.75
						,5,-2.5,2.5)
		
		xAxis = histAll.GetXaxis()
		yAxis = histAll.GetYaxis()
		nBinsX = xAxis.GetNbins()
		nBinsY = yAxis.GetNbins()
		
		#Fill new histogram with fewer bins
		for i in range( 1 , nBinsX + 1 ):
			for j in range( 1 , nBinsY + 1 ):
				histNew.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,histAll.GetBinContent(i,j))
		histNew.SetStats(0)
		histNew.Draw('colz')
			
		canvas.Update()
		pal = histNew.GetListOfFunctions().FindObject("palette")
		pal.SetX2NDC(0.92)
		
		#Calcualte fraction at (0,0)
		nCentral = histNew.GetBinContent(histNew.FindBin(0,0))
		nTotal = histNew.Integral()

		fraction = nCentral/float(nTotal)
		fractionUncert = calcSigma(nCentral,nTotal)
		
		sliceFraction = 0
		for i in range(0,5):
			sliceFraction += histNew.GetBinContent(histNew.FindBin(0,-2.5+i))
		
		sliceFractionUncert = calcSigma(sliceFraction,nTotal)
		sliceFraction /= nTotal
		
		paveText = TPaveText(0.1,0.8,0.5,0.9,'NDC')
		paveText.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100))
		paveText.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100))
		paveText.SetBorderSize(1)
		paveText.Draw()
			
		label.Draw()
		
	canvas.cd(2).SetLogz()
	histAboveThr.SetStats(0)
	
	xAxis = histAboveThr.GetXaxis()
	yAxis = histAboveThr.GetYaxis()
	nBinsX = xAxis.GetNbins()
	nBinsY = yAxis.GetNbins()
	
	histNewAboveThr = getTH2D("histNewAboveThr","Correlation between L1 BX ID and HO > E_{Thr};HO time / ns;L1 / BX ID",5,-37.5,87.5#,12,-56.25,93.75
							,5,-2.5,2.5)
	for i in range( 1 , nBinsX + 1 ):
		for j in range( 1 , nBinsY + 1 ):
			histNewAboveThr.Fill(xAxis.GetBinCenter(i),yAxis.GetBinCenter(j)/25.,histAboveThr.GetBinContent(i,j))
	histNewAboveThr.SetStats(0)
	histNewAboveThr.Draw('colz')
	
	canvas.Update()
	pal = histNewAboveThr.GetListOfFunctions().FindObject("palette")
	pal.SetX2NDC(0.92)
	
	#Calcualte fraction at (0,0)
	nCentral = histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0,0))
	nTotal = histNewAboveThr.Integral()

	fraction = nCentral/float(nTotal)
	fractionUncert = calcSigma(nCentral,nTotal)

	sliceFraction = 0
	for i in range(0,5):
		sliceFraction += histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0,-2.5+i))
	
	sliceFractionUncert = calcSigma(sliceFraction,nTotal)
	sliceFraction /= nTotal
	
	paveTextAboveThr = TPaveText(0.1,0.8,0.5,0.9,'NDC')
	paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' % (fraction*100, fractionUncert*100))
	paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' % (sliceFraction*100, sliceFractionUncert*100))
	paveTextAboveThr.SetBorderSize(1)
	paveTextAboveThr.Draw()
	
	label.Draw()
	canvas.Update()
	
	canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.pdf')
	canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.png')

	return canvas,histAll,histAboveThr,label,histNewAboveThr, histNew,paveTextAboveThr
Esempio n. 5
0
def plotHoL1Correlation():
    #Select whether matching to all HO should also be plotted
    plotBoth = True
    histAll = fileHandler.getHistogram(
        'hoMuonAnalyzer/correlation/L1MuonPresentHoMatch_TimeCorrelation')
    histAboveThr = fileHandler.getHistogram(
        'hoMuonAnalyzer/correlation/L1MuonAboveThr_TimeCorrelation')

    label = getLabelCmsPrivateSimulation()

    canvas = TCanvas("canvasHoL1Correlation", "canvasHoL1Correlation", 1600,
                     1200)

    if (plotBoth):
        canvas.Divide(2, 1)
        canvas.cd(1).SetLogz()

        histNew = getTH2D(
            "histNew",
            "Correlation between L1 BX ID and HO;HO time / ns;L1 / BX ID",
            5,
            -37.5,
            87.5  #24,-56.25,93.75
            ,
            5,
            -2.5,
            2.5)

        xAxis = histAll.GetXaxis()
        yAxis = histAll.GetYaxis()
        nBinsX = xAxis.GetNbins()
        nBinsY = yAxis.GetNbins()

        #Fill new histogram with fewer bins
        for i in range(1, nBinsX + 1):
            for j in range(1, nBinsY + 1):
                histNew.Fill(xAxis.GetBinCenter(i),
                             yAxis.GetBinCenter(j) / 25.,
                             histAll.GetBinContent(i, j))
        histNew.SetStats(0)
        histNew.Draw('colz')

        canvas.Update()
        pal = histNew.GetListOfFunctions().FindObject("palette")
        pal.SetX2NDC(0.92)

        #Calcualte fraction at (0,0)
        nCentral = histNew.GetBinContent(histNew.FindBin(0, 0))
        nTotal = histNew.Integral()

        fraction = nCentral / float(nTotal)
        fractionUncert = calcSigma(nCentral, nTotal)

        sliceFraction = 0
        for i in range(0, 5):
            sliceFraction += histNew.GetBinContent(histNew.FindBin(
                0, -2.5 + i))

        sliceFractionUncert = calcSigma(sliceFraction, nTotal)
        sliceFraction /= nTotal

        paveText = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC')
        paveText.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' %
                         (fraction * 100, fractionUncert * 100))
        paveText.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' %
                         (sliceFraction * 100, sliceFractionUncert * 100))
        paveText.SetBorderSize(1)
        paveText.Draw()

        label.Draw()

    canvas.cd(2).SetLogz()
    histAboveThr.SetStats(0)

    xAxis = histAboveThr.GetXaxis()
    yAxis = histAboveThr.GetYaxis()
    nBinsX = xAxis.GetNbins()
    nBinsY = yAxis.GetNbins()

    histNewAboveThr = getTH2D(
        "histNewAboveThr",
        "Correlation between L1 BX ID and HO > E_{Thr};HO time / ns;L1 / BX ID",
        5,
        -37.5,
        87.5  #,12,-56.25,93.75
        ,
        5,
        -2.5,
        2.5)
    for i in range(1, nBinsX + 1):
        for j in range(1, nBinsY + 1):
            histNewAboveThr.Fill(xAxis.GetBinCenter(i),
                                 yAxis.GetBinCenter(j) / 25.,
                                 histAboveThr.GetBinContent(i, j))
    histNewAboveThr.SetStats(0)
    histNewAboveThr.Draw('colz')

    canvas.Update()
    pal = histNewAboveThr.GetListOfFunctions().FindObject("palette")
    pal.SetX2NDC(0.92)

    #Calcualte fraction at (0,0)
    nCentral = histNewAboveThr.GetBinContent(histNewAboveThr.FindBin(0, 0))
    nTotal = histNewAboveThr.Integral()

    fraction = nCentral / float(nTotal)
    fractionUncert = calcSigma(nCentral, nTotal)

    sliceFraction = 0
    for i in range(0, 5):
        sliceFraction += histNewAboveThr.GetBinContent(
            histNewAboveThr.FindBin(0, -2.5 + i))

    sliceFractionUncert = calcSigma(sliceFraction, nTotal)
    sliceFraction /= nTotal

    paveTextAboveThr = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC')
    paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' %
                             (fraction * 100, fractionUncert * 100))
    paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' %
                             (sliceFraction * 100, sliceFractionUncert * 100))
    paveTextAboveThr.SetBorderSize(1)
    paveTextAboveThr.Draw()

    label.Draw()
    canvas.Update()

    canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.pdf')
    canvas.SaveAs('plots/timeCorrelation/l1AndHoCorrelation.png')

    return canvas, histAll, histAboveThr, label, histNewAboveThr, histNew, paveTextAboveThr
Esempio n. 6
0
def plotRpcVsHo():
    hist = fileHandler.getHistogram(
        'hoMuonAnalyzer/correlation/RpcHoAboveThr_TimeCorrelation')
    canvas = TCanvas('canvasRpcVsHo', "RPC vs. HO", 1200, 1200)
    canvas.cd().SetLogz()

    histNew = getTH2D(
        "histRpcVsHo",
        "RPC BX ID vs. HO > E_{Thr};HO time / ns;BX ID",
        5,
        -37.5,
        87.5  #24,-56.25,93.75
        ,
        5,
        -2.5,
        2.5)

    xAxis = hist.GetXaxis()
    yAxis = hist.GetYaxis()
    nBinsX = xAxis.GetNbins()
    nBinsY = yAxis.GetNbins()

    #Fill new histogram with fewer bins
    for i in range(1, nBinsX + 1):
        for j in range(1, nBinsY + 1):
            histNew.Fill(xAxis.GetBinCenter(i),
                         yAxis.GetBinCenter(j) / 25., hist.GetBinContent(i, j))

    histNew.SetStats(0)
    histNew.Draw('colz')

    canvas.Update()

    pal = histNew.GetListOfFunctions().FindObject("palette")
    pal.SetX2NDC(0.92)

    #Calcualte fraction at (0,0)
    nCentral = histNew.GetBinContent(histNew.FindBin(0, 0))
    nTotal = histNew.Integral()

    fraction = nCentral / float(nTotal)
    fractionUncert = calcSigma(nCentral, nTotal)

    sliceFraction = 0
    for i in range(0, 5):
        sliceFraction += histNew.GetBinContent(histNew.FindBin(0, -2.5 + i))

    sliceFractionUncert = calcSigma(sliceFraction, nTotal)
    sliceFraction /= nTotal

    paveTextAboveThr = TPaveText(0.1, 0.8, 0.5, 0.9, 'NDC')
    paveTextAboveThr.AddText('Fraction at (0,0): %5.2f%% #pm %5.2f%%' %
                             (fraction * 100, fractionUncert * 100))
    paveTextAboveThr.AddText('Fraction at (0,x): %5.2f%% #pm %5.2f%%' %
                             (sliceFraction * 100, sliceFractionUncert * 100))
    paveTextAboveThr.SetBorderSize(1)
    paveTextAboveThr.Draw()

    label = getLabelCmsPrivateSimulation()
    label.Draw()

    canvas.SaveAs('plots/timeCorrelation/rpcVsHo.pdf')
    canvas.SaveAs('plots/timeCorrelation/rpcVsHo.png')

    return hist, canvas, paveTextAboveThr, label
Esempio n. 7
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
Esempio n. 8
0
def plotEfficiencyForPt(folder, pt):
    if (DEBUG):
        print prefix + 'was called'

    #Set plot style

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

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

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

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

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

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

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

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

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

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

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

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

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

    newGraph = TGraph()

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

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

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

    ##### Finally save the stuff

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

    f = TFile.Open("plots/efficiency/efficiency" + str(pt) + ".root",
                   "RECREATE")
    canv.Write()
    f.Close()
    return [
        l1Muon, l1MuonAndHoAboveThr, canv, legend, line, paveText, label,
        newGraph
    ]
Esempio n. 9
0
	def plotL1BxId(self,tight = False):

		TIGHT_TOKEN = '_tight' if tight else ''

		c2 = TCanvas("cBxId" + TIGHT_TOKEN,"BX ID" + TIGHT_TOKEN,1200,400)
		c2.Divide(3,1)

		hBxIdBest = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport%s_MatchedDtRpcHo_BxId' % TIGHT_TOKEN)
		hBxIdDtOnly = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport%s_UnmatchedDtHo_BxId' % TIGHT_TOKEN)
		hBxIdOther = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport%s_OtherCodesHo_BxId' % TIGHT_TOKEN)

		if not hBxIdBest or not hBxIdDtOnly or not hBxIdOther:
			return

		dtBx0BestCentral = hBxIdBest.GetBinContent(hBxIdBest.FindBin(0))
		dtBx0BestIntegral = hBxIdBest.Integral()
		dtBx0BestOther = dtBx0BestIntegral - dtBx0BestCentral
		
		dtBx0DtOnlyCentral = hBxIdDtOnly.GetBinContent(hBxIdDtOnly.FindBin(0))
		dtBx0DtOnlyIntegral = hBxIdDtOnly.Integral()
		dtBx0DtOnlyOther = dtBx0DtOnlyIntegral - dtBx0DtOnlyCentral
		
		dtBx0OtherCentral = hBxIdOther.GetBinContent(hBxIdOther.FindBin(0))
		dtBx0OtherIntegral = hBxIdOther.Integral()
		dtBx0OtherOther = dtBx0OtherIntegral - dtBx0OtherCentral
		
		self.output('#'*20)
		self.output('!TIGHT!' if tight else '')
		self.output('DT/RPC')
		self.output('-'*10)
		self.output('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestCentral,dtBx0BestCentral/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestCentral, dtBx0BestIntegral)*100))
		self.output('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0BestOther,dtBx0BestOther/float(dtBx0BestIntegral)*100,calcSigma(dtBx0BestOther, dtBx0BestIntegral)*100))
		self.output('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0BestCentral + dtBx0BestOther,dtBx0BestIntegral))
		self.output('')
		self.output('DT')
		self.output('-'*10)
		self.output('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyCentral,dtBx0DtOnlyCentral/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyCentral, dtBx0DtOnlyIntegral)*100))
		self.output('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0DtOnlyOther,dtBx0DtOnlyOther/float(dtBx0DtOnlyIntegral)*100,calcSigma(dtBx0DtOnlyOther, dtBx0DtOnlyIntegral)*100))
		self.output('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0DtOnlyCentral + dtBx0DtOnlyOther,dtBx0DtOnlyIntegral))
		self.output('')
		self.output('Other')
		self.output('-'*10)
		self.output('Events in BXID 0: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherCentral,dtBx0OtherCentral/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherCentral, dtBx0OtherIntegral)*100))
		self.output('Events in other BXID: %d\t%6.3f%% +/- %6.3f%%' % (dtBx0OtherOther,dtBx0OtherOther/float(dtBx0OtherIntegral)*100,calcSigma(dtBx0OtherOther, dtBx0OtherIntegral)*100))
		self.output('Consistency check (Central + Other, Integral): %d, %d' % (dtBx0OtherCentral + dtBx0OtherOther,dtBx0OtherIntegral))
		self.output('')
		self.output('#'*20)

		
		### Plot matched DT/RPC
		c2.cd(1).SetLogy()
		hBxIdBest.SetLineColor(colorRwthDarkBlue)
		hBxIdBest.SetLineWidth(3)
		hBxIdBest.SetStats(0)
		hBxIdBest.SetTitle("Matched DT/RPC + HO")
		hBxIdBest.GetXaxis().SetRangeUser(-5,5)
		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(-5,5)
		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(-5,5)
		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,"bxId" + TIGHT_TOKEN)

		return label,c2,hBxIdBest,hBxIdDtOnly,hBxIdOther
Esempio n. 10
0
	def plotImprovementInDt(self):
		#Prepare canvas
		canvas = TCanvas("canvasDtImprovement","DT improvement",1200,1200)
		canvas.SetLogy()
		histDt = self.fileHandler.getHistogram("hoMuonAnalyzer/timingSupport_UnmatchedDtHo_BxId")
		histDtNoHo = self.fileHandler.getHistogram("hoMuonAnalyzer/timingSupport_UnmatchedDt_BxId")
		#print 'DtBxNoHo Integral: ', histDtNoHo.Integral()
		
		#Define variables for integrals
		histHoTime = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_UnmatchedDtHo_Time')
		integralHoCorrect = histHoTime.Integral(histHoTime.FindBin(-12.5),histHoTime.FindBin(12.5))
		integralHoTotal = histHoTime.Integral()
		integralHoOutside = integralHoTotal - integralHoCorrect
		hoFractionWrong = integralHoOutside/float(integralHoTotal)
		hoFractionRight = integralHoCorrect/float(integralHoTotal)
		
		#Print some information
		heading = 'Integrals of the Ho timing:'
		print 80*'#'
		print heading
		print len(heading)*'-'
		print 'Timing correct:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(integralHoCorrect,hoFractionRight*100,calcSigma(integralHoCorrect, integralHoTotal)*100)
		print 'Timing outside:\t%d\t=>\t%6.3f%% +/- %f%%'%(integralHoOutside,hoFractionWrong*100,calcSigma(integralHoOutside, integralHoTotal)*100)
		print 'Timing total:%d'%(integralHoTotal)
		print
		
		#Define Variables for bx id counts
		dtBx0 = histDt.GetBinContent(6)
		dtBxM1 = histDt.GetBinContent(5)
		dtBxP1 = histDt.GetBinContent(7)
		dtBxTotal = dtBx0 + dtBxM1 + dtBxP1
		dtFractionWrongM1 = dtBxM1/float(dtBxTotal)
		dtFractionWrongP1 = dtBxP1/float(dtBxTotal)
	
		#Print some information
		heading = 'Bin contents for DT timing:'
		print heading
		print len(heading)*'-'
		print 'BX ID  0:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBx0,dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100)
		print 'BX ID -1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBxM1,dtFractionWrongM1*100,calcSigma(dtBxM1, dtBxTotal)*100)
		print 'BX ID +1:\t%d\t=>\t%6.3f%% +/- %6.3f%%'%(dtBxP1,dtFractionWrongP1*100,calcSigma(dtBxP1, dtBxTotal)*100)
		print 'BX ID total:\t%d' % (dtBxTotal)
		print
		
		#Calculate corrected numbers
		correctedBxIdM1 = dtBxM1 + hoFractionWrong*dtBx0/2. - hoFractionRight*dtBxM1
		correctedBxId0 = dtBx0 - hoFractionWrong*dtBx0 + hoFractionRight*dtBxM1 + hoFractionRight*dtBxP1
		correctedBxIdP1 = dtBxP1 + hoFractionWrong*dtBx0/2. - hoFractionRight*dtBxP1
		correctedTotal = correctedBxIdM1 + correctedBxId0 + correctedBxIdP1
		correctedRightFraction = correctedBxId0/float(correctedTotal)
		
		heading = 'DT After correction:'
		print heading
		print len(heading)*'-'
		print 'BX -1:\t',int(correctedBxIdM1)
		print 'BX  0:\t',int(correctedBxId0)
		print 'BX +1:\t',int(correctedBxIdP1)
		print 
		#Fill corrected histogram
		histNew = TH1D("histNew","BX ID in DT only triggers;BX ID;rel. fraction",6,-2.5,3.5)
		histNew.SetBinContent(histNew.FindBin(-1),correctedBxIdM1)
		histNew.SetBinContent(histNew.FindBin(0),correctedBxId0)
		histNew.SetBinContent(histNew.FindBin(1),correctedBxIdP1)
		histNew.SetLineColor(colorRwthMagenta)
		histNew.SetStats(0)
		histNew.Scale(1/histNew.Integral())
		histNew.SetLineStyle(9)
		setupAxes(histNew)
		setBigAxisTitles(histNew)
		histDt.GetXaxis().SetRangeUser(-3,3)
		histDt.SetLineWidth(3)
		histDt.Scale(1/histDt.Integral())
		histDt.SetLineColor(colorRwthDarkBlue)
		
		histNew.Draw()
		histDt.Draw('same')
		histNew.Draw('same')
				
		histDtNoHo.Scale(1/histDtNoHo.Integral())
		histDtNoHo.SetLineWidth(3)
		#histDtNoHo.Draw('same')
	
		#Add label
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		
		#Add legend
		legend = TLegend(0.7,0.65,0.9,0.8)
		legend.AddEntry(histDt,"DT Only + HO","l")
		legend.AddEntry(histNew,"DT shifted with HO","l")
		legend.SetBorderSize(1)
		legend.Draw()
		
		#Add text object
		pText = TPaveText(0.52,0.8,0.9,0.9,'NDC')
		pText.AddText('Fraction in BX ID 0: %5.2f%% #pm %5.2f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100))
		pText.AddText('Fraction in BX ID 0 (HO corr.): %5.2f%% #pm %5.2f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)*100))
		pText.SetBorderSize(1)
		pText.SetFillColor(0)
		pText.Draw()
		
		pText2 = TPaveText(0.7,0.6,0.9,0.65,'NDC')
		pText2.AddText('Entries: %d' % (histDt.GetEntries()))
		pText2.SetBorderSize(1)
		pText2.SetFillColor(0)
		pText2.Draw()
		
		#Print again some information
		heading = 'Fraction of correct BXID:'
		print heading
		print len(heading)*'-'
		print 'Uncorrected:\t%5.2f%% #pm %f%%' % (dtBx0/float(dtBxTotal)*100,calcSigma(dtBx0, dtBxTotal)*100)
		print 'Corrected\t%5.2f%% #pm %f%%' % (correctedRightFraction*100,calcSigma(correctedBxId0, correctedTotal)*100)
		print 80*'#'
		
		canvas.Update()
		self.storeCanvas(canvas, 'correctedDt')
		return canvas, histDt,histNew,label,legend,pText2,pText,histDtNoHo
Esempio n. 11
0
	def plotHoTime(self):
		c3 = TCanvas("c3","HO Time",1200,1200)
		skipNoisePlot = False
		if not skipNoisePlot:
			c3.Divide(1,2)
			c3.cd(1).SetLogy()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			hHoTime = self.fileHandler.getHistogram('hoMuonAnalyzer/hoRecHits_Time')
			
			hHoTime.SetStats(0)
			hHoTime.SetTitle("Time distribution for all HO Rec Hits")
			hHoTime.SetLineColor(colorRwthDarkBlue)
			hHoTime.SetLineWidth(3)
			hHoTime.Draw()
			label = getLabelCmsPrivateSimulation()
			label.Draw()
			
		hHoTimeAboveThr = self.fileHandler.getHistogram('hoMuonAnalyzer/hoRecHitsAboveThr_Time')
		c3.cd(2).SetLogy()
		hHoTimeAboveThr.SetStats(0)
		hHoTimeAboveThr.SetTitle("Time distribution for HO Rec Hits > 0.2 GeV")
		hHoTimeAboveThr.SetLineColor(colorRwthDarkBlue)
		hHoTimeAboveThr.SetLineWidth(3)
		setupAxes(hHoTimeAboveThr)
		hHoTimeAboveThr.Draw()
		
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		
		print 80*'#'
		print 'Integral of HO > 0.2 GeV time histogram:'
		print hHoTimeAboveThr.Integral()
		print
		
		xLow = -5
		xHigh = 5
		histogramBetween = hHoTimeAboveThr.Integral(hHoTimeAboveThr.FindBin(xLow),hHoTimeAboveThr.FindBin(xHigh))
		histogramTotal = float(hHoTimeAboveThr.Integral())
		print 'Histogram integral between %.f ns and %.f ns' % (xLow,xHigh)
		print '%d/%d => %.2f +/- %f' % (histogramBetween,histogramTotal,histogramBetween/histogramTotal,calcSigma(histogramBetween, histogramTotal))  
		print 80*'#'
		
		fit = TF1("fit","gaus",-10,10)
		hHoTimeAboveThr.Fit(fit)
		
		pText = TPaveText(0.7,0.8,0.9,0.9,'NDC')
		pText.AddText('Mean: %.2f ns' % (fit.GetParameter(1)))
		pText.AddText('#sigma: %.2f ns' % (fit.GetParameter(2)))
		pText.SetBorderSize(1)
		pText.SetFillColor(0)
		pText.Draw()
		
		c3.Update()
		self.storeCanvas(c3,"hoTime")
		
		return c3,label,hHoTimeAboveThr,pText
Esempio n. 12
0
	def plotDeltaTime(self):
		hDeltaTAllHo = self.fileHandler.getHistogram('hoMuonAnalyzer/L1MuonPresentHoMatch_DeltaTime')
		hDeltaTCleanHo = self.fileHandler.getHistogram('hoMuonAnalyzer/timingSupport_UnmatchedDtHo_DeltaTime')
		
		c = TCanvas("c","Delta Time",1200,1200)
		c.SetLogy()
		
		hDeltaTAllHo.SetLineColor(colorRwthDarkBlue)
		hDeltaTAllHo.SetLineWidth(3)
		hDeltaTAllHo.SetFillColor(colorRwthDarkBlue)
		hDeltaTAllHo.SetFillStyle(3017)
		hDeltaTAllHo.SetTitle("#Delta time")
		hDeltaTAllHo.SetStats(0)
		
		hDeltaTCleanHo.SetLineColor(8)
		hDeltaTCleanHo.SetFillColor(8)
		hDeltaTCleanHo.SetLineWidth(3)
		hDeltaTCleanHo.SetFillStyle(3002)
		
		#hDeltaTAllHo.Scale(1/hDeltaTAllHo.Integral())
		#hDeltaTCleanHo.Scale(1/hDeltaTCleanHo.Integral())
		
		print hDeltaTCleanHo.Integral(),hDeltaTAllHo.Integral()
		
		fitFirstMin = TF1("fitFirstMin","[0]+x*[1]+[2]*x**2")
		fitSecondMin = TF1("fitsecondMin","[0]+x*[1]+[2]*x**2",10,20)
		
		hDeltaTCleanHo.Fit(fitFirstMin,"+q","",-20,-10)
		hDeltaTCleanHo.Fit(fitSecondMin,"R+q","")
		
		hDeltaTAllHo.Draw()
		legend = TLegend(0.6,0.75,0.9,0.9)
		legend.AddEntry(hDeltaTAllHo,"L1Muon matched to any HO","le")
		legend.Draw()
		
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		c.Update()
		
		self.storeCanvas(c,"deltaTimeAllHo")
		hDeltaTCleanHo.Draw('same')
		
		fitFirstMin.SetRange(-50,50)
		fitSecondMin.SetRange(-50,50)
		
		#fitFirstMin.Draw('lSame')
		#fitSecondMin.Draw('lSame')
		
		lineFirstMin = TLine(fitFirstMin.GetMinimumX(-20,-10),hDeltaTAllHo.GetMinimum(),fitFirstMin.GetMinimumX(-20,-10),hDeltaTAllHo.GetMaximum())
		lineFirstMin.SetLineWidth(3)
		lineFirstMin.SetLineColor(colorRwthRot)
		lineFirstMin.Draw()
		
		lineSecondMin = TLine(fitSecondMin.GetMinimumX(10,20),hDeltaTAllHo.GetMinimum(),fitSecondMin.GetMinimumX(10,20),hDeltaTAllHo.GetMaximum())
		lineSecondMin.SetLineWidth(3)
		lineSecondMin.SetLineColor(colorRwthRot)
		lineSecondMin.Draw()
		
		
		legend.AddEntry(hDeltaTCleanHo,"L1Muon matched to HO > 0.2 GeV","le")
		legend.AddEntry(lineFirstMin,"Integral boundaries","e")
		legend.Draw()
		
		integralCenter = hDeltaTCleanHo.Integral(hDeltaTCleanHo.FindBin(fitFirstMin.GetMinimumX(-20,-10)),hDeltaTCleanHo.FindBin(fitSecondMin.GetMinimumX(10,20)))
		integralCenterAll = hDeltaTAllHo.Integral(hDeltaTAllHo.FindBin(fitFirstMin.GetMinimumX(-20,-10)),hDeltaTAllHo.FindBin(fitSecondMin.GetMinimumX(10,20)))
		print 80*'#'
		print 'Integral of center area in clean histogram :',integralCenter
		print '==> %.2f%% +/- %.2f%%' % (integralCenter/hDeltaTCleanHo.Integral()*100,calcSigma(integralCenter, hDeltaTCleanHo.Integral())*100)
		print 'Integral of center area in all matched HO events:',integralCenterAll
		print '==> %.2f%% +/- %.2f%%' % (integralCenterAll/hDeltaTAllHo.Integral()*100,calcSigma(integralCenterAll, hDeltaTAllHo.Integral())*100)
		print 80*'#'
		
		paveText = TPaveText(0.6,0.7,0.9,0.75,'NDC')
		paveText.AddText('%s' % ('Central peak contains (filtered hist.)'))
		paveText.AddText('%.2f%% +/- %.2f%%' % (integralCenter/hDeltaTCleanHo.Integral()*100,calcSigma(integralCenter, hDeltaTCleanHo.Integral())*100))
		paveText.SetBorderSize(1)
		paveText.Draw()
		
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		c.Update()
		
		self.storeCanvas(c,"deltaTime")
		return c, hDeltaTCleanHo