Example #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
Example #2
0
	def outputFractionsInTileGrid(self,hist):
		#Calculate fraction in grids
		integralCentral = hist.Integral(hist.GetXaxis().FindBin(-.0435),hist.GetXaxis().FindBin(.0435),
									hist.GetYaxis().FindBin(-.0435),hist.GetYaxis().FindBin(.0435))
		integral3x3 = hist.Integral(hist.GetXaxis().FindBin(-.1305),hist.GetXaxis().FindBin(.1305),
									hist.GetYaxis().FindBin(-.1305),hist.GetYaxis().FindBin(.1305))
		integral5x5 = hist.Integral(hist.GetXaxis().FindBin(-.2175),hist.GetXaxis().FindBin(.2175),
									hist.GetYaxis().FindBin(-.2175),hist.GetYaxis().FindBin(.2175))
		integralTotal = hist.Integral()
		
		self.debug(80*'#')
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('Central Fraction',calcPercent(integralCentral,integralTotal),
												calcSigma(integralCentral,integralTotal)*100))
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('3x3 Fraction',calcPercent(integral3x3,integralTotal),
												calcSigma(integral3x3,integralTotal)*100))
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('5x5 Fraction',calcPercent(integral5x5,integralTotal),
												calcSigma(integral5x5,integralTotal)*100))
		self.debug(80*'#')
Example #3
0
	def outputFractionsInTileGrid(self,hist):
		#Calculate fraction in grids
		integralCentral = hist.Integral(hist.GetXaxis().FindBin(-.0435),hist.GetXaxis().FindBin(.0435),
									hist.GetYaxis().FindBin(-.0435),hist.GetYaxis().FindBin(.0435))
		integral3x3 = hist.Integral(hist.GetXaxis().FindBin(-.1305),hist.GetXaxis().FindBin(.1305),
									hist.GetYaxis().FindBin(-.1305),hist.GetYaxis().FindBin(.1305))
		integral5x5 = hist.Integral(hist.GetXaxis().FindBin(-.2175),hist.GetXaxis().FindBin(.2175),
									hist.GetYaxis().FindBin(-.2175),hist.GetYaxis().FindBin(.2175))
		integralTotal = hist.Integral()
		
		self.debug(80*'#')
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('Central Fraction',calcPercent(integralCentral,integralTotal),
												calcSigma(integralCentral,integralTotal)*100))
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('3x3 Fraction',calcPercent(integral3x3,integralTotal),
												calcSigma(integral3x3,integralTotal)*100))
		self.debug('%20s:%5.2f%% +/- %5.2f%%' % ('5x5 Fraction',calcPercent(integral5x5,integralTotal),
												calcSigma(integral5x5,integralTotal)*100))
		self.debug(80*'#')
Example #4
0
	def printFractionsPerIEta(self,graph):
		self.output("Fractions of HO time in [-12.5,12.5] ns")
		counterDict = [{'total':0,'inside':0, 'hist':TH1D('hist' + str(i-10),'',201,-100.5,100.5)} for i in range(0,21)]
		x = Double(0)
		y = Double(0)
		nTotal = graph.GetN()
		
		###
		# Fill histograms for later calculation of mean
		###
		for i in range(0,nTotal):
			graph.GetPoint(i,x,y)
			indexHelper = int(x+10)
			counterDict[indexHelper]['total'] += 1
			counterDict[indexHelper]['hist'].Fill(y)
			
		
		###
		# Once all histograms are filled, calculate median
		###
		for index,item in enumerate(counterDict):
			item['median'] = getMedian(item['hist'])
		
		###
		# Fill the number of objects in interval depending on the
		# Histogram median
		###
		nDone = 0
		if self.DEBUG:
			self.debug('Filling interval counters')
		for i in range(0,nTotal):
			graph.GetPoint(i,x,y)
			indexHelper = int(x+10)
			median = counterDict[indexHelper]['median']
			if( fabs(median - y) < 12.5 ):
				counterDict[indexHelper]['inside'] += 1
			nDone += 1
			self.printProgress(nDone, nTotal)
			
		#Graph for results
		graph = TEfficiency(graph.GetName(),"",21,-10.5,10.5)
		
		###
		# Plot the results of calculations on CLI
		###
		for index,item in enumerate(counterDict):
			if(index - 10 == 0):
				continue
			total = item['total']
			inside = item['inside']
			self.output("iEta: %3d\tTotal: %5d\tInside:%5d\tFraction:%6.2f +/- %6.2f" % 
					(index - 10, total, inside, calcPercent(inside,total),calcSigma(inside, total)*100))
			graph.SetTotalEvents(graph.FindFixBin(index -10),total)
			graph.SetPassedEvents(graph.FindFixBin(index -10),inside)
		return graph,counterDict
	def printFractionsForDtOnly(self):
		allL1 = self.fileHandler.getHistogram('count/timingSupport__Count')
		allTightL1 = self.fileHandler.getHistogram('count/timingSupport_tight__Count')
		dtOnly = self.makeDtOnlyPlot(sourceDt='UnmatchedDt', sourceDtHo='UnmatchedDtHo')[1]
		dtOnlyBxWrong = self.makeDtOnlyPlot(sourceDt='UnmatchedDtBxNot0', sourceDtHo='UnmatchedDtHoBxNot0')[1]
		dtOnlyBxWrongHo = self.makeDtOnlyPlot(sourceDt='UnmatchedDtHoBxNot0', sourceDtHo='')[1]
		dtOnlyTight = self.makeDtOnlyPlot(sourceDt='tight_UnmatchedDt', sourceDtHo='tight_UnmatchedDtHo')[1]
		dtOnlyTightBxWrong = self.makeDtOnlyPlot(sourceDt='tight_UnmatchedDtBxNot0', sourceDtHo='tight_UnmatchedDtHoBxNot0')[1]
		dtOnlyTightBxWrongHo = self.makeDtOnlyPlot(sourceDt='tight_UnmatchedDtHoBxNot0', sourceDtHo='')[1]
		
		nAllL1 = allL1.GetEntries()
		nAllL1Tight = allTightL1.GetEntries()
		nDtOnly = dtOnly.GetEntries()
		nDtOnlyBxWrong = dtOnlyBxWrong.GetEntries()
		nDtOnlyBxWrongHo = dtOnlyBxWrongHo.GetEntries()
		nDtOnlyTight = dtOnlyTight.GetEntries()
		nDtOnlyTightBxWrong = dtOnlyTightBxWrong.GetEntries()
		nDtOnlyTightBxWrongHo = dtOnlyTightBxWrongHo.GetEntries()
		
		print
		header = "%30s  %7s    %s" % ('Data source','Entries','Fraction of total L1')
		if (self.ptCut != ""):
			header += '\tpT cut: ' + self.ptCut
		self.debug(header)
		self.debug('-'*len(header))
		self.debug("%30s: %7d" % ('L1',nAllL1))
		self.debug("%30s: %7d => %6.2f +/- %6.2f" % ('DT only',nDtOnly,calcPercent(nDtOnly, nAllL1),calcSigma(nDtOnly,nAllL1)*100))
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('DT only, BX wrong',nDtOnlyBxWrong,calcPercent(nDtOnlyBxWrong, nAllL1),calcSigma(nDtOnlyBxWrong,nAllL1)*100))
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('DT only, BX wrong + HO',nDtOnlyBxWrongHo,calcPercent(nDtOnlyBxWrongHo, nAllL1),calcSigma(nDtOnlyBxWrongHo,nAllL1)*100))
		print
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('Tight L1',nAllL1Tight,calcPercent(nAllL1Tight, nAllL1),calcSigma(nAllL1Tight,nAllL1)*100))
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('Tight DT only',nDtOnlyTight,calcPercent(nDtOnlyTight, nAllL1),calcSigma(nDtOnlyTight,nAllL1)*100))
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('Tight DT only, BX wrong',nDtOnlyTightBxWrong,calcPercent(nDtOnlyTightBxWrong, nAllL1)
				,calcSigma(nDtOnlyTightBxWrong,nAllL1)*100))
		self.debug("%30s: %7d => %6.2f +/- %6.2f"
				 % ('Tight DT only, BX wrong + HO',nDtOnlyTightBxWrongHo,calcPercent(nDtOnlyTightBxWrongHo, nAllL1)
				,calcSigma(nDtOnlyTightBxWrongHo,nAllL1)*100))
		print
		return
Example #6
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
Example #7
0
    def printFractionsForDtOnly(self):
        allL1 = self.fileHandler.getHistogram('count/timingSupport__Count')
        allTightL1 = self.fileHandler.getHistogram(
            'count/timingSupport_tight__Count')
        dtOnly = self.makeDtOnlyPlot(sourceDt='UnmatchedDt',
                                     sourceDtHo='UnmatchedDtHo')[1]
        dtOnlyBxWrong = self.makeDtOnlyPlot(
            sourceDt='UnmatchedDtBxNot0', sourceDtHo='UnmatchedDtHoBxNot0')[1]
        dtOnlyBxWrongHo = self.makeDtOnlyPlot(sourceDt='UnmatchedDtHoBxNot0',
                                              sourceDtHo='')[1]
        dtOnlyTight = self.makeDtOnlyPlot(sourceDt='tight_UnmatchedDt',
                                          sourceDtHo='tight_UnmatchedDtHo')[1]
        dtOnlyTightBxWrong = self.makeDtOnlyPlot(
            sourceDt='tight_UnmatchedDtBxNot0',
            sourceDtHo='tight_UnmatchedDtHoBxNot0')[1]
        dtOnlyTightBxWrongHo = self.makeDtOnlyPlot(
            sourceDt='tight_UnmatchedDtHoBxNot0', sourceDtHo='')[1]

        nAllL1 = allL1.GetEntries()
        nAllL1Tight = allTightL1.GetEntries()
        nDtOnly = dtOnly.GetEntries()
        nDtOnlyBxWrong = dtOnlyBxWrong.GetEntries()
        nDtOnlyBxWrongHo = dtOnlyBxWrongHo.GetEntries()
        nDtOnlyTight = dtOnlyTight.GetEntries()
        nDtOnlyTightBxWrong = dtOnlyTightBxWrong.GetEntries()
        nDtOnlyTightBxWrongHo = dtOnlyTightBxWrongHo.GetEntries()

        print
        header = "%30s  %7s    %s" % ('Data source', 'Entries',
                                      'Fraction of total L1')
        if (self.ptCut != ""):
            header += '\tpT cut: ' + self.ptCut
        self.debug(header)
        self.debug('-' * len(header))
        self.debug("%30s: %7d" % ('L1', nAllL1))
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('DT only', nDtOnly, calcPercent(
                       nDtOnly, nAllL1), calcSigma(nDtOnly, nAllL1) * 100))
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('DT only, BX wrong', nDtOnlyBxWrong,
                    calcPercent(nDtOnlyBxWrong, nAllL1),
                    calcSigma(nDtOnlyBxWrong, nAllL1) * 100))
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('DT only, BX wrong + HO', nDtOnlyBxWrongHo,
                    calcPercent(nDtOnlyBxWrongHo, nAllL1),
                    calcSigma(nDtOnlyBxWrongHo, nAllL1) * 100))
        print
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('Tight L1', nAllL1Tight, calcPercent(nAllL1Tight, nAllL1),
                    calcSigma(nAllL1Tight, nAllL1) * 100))
        self.debug(
            "%30s: %7d => %6.2f +/- %6.2f" %
            ('Tight DT only', nDtOnlyTight, calcPercent(
                nDtOnlyTight, nAllL1), calcSigma(nDtOnlyTight, nAllL1) * 100))
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('Tight DT only, BX wrong', nDtOnlyTightBxWrong,
                    calcPercent(nDtOnlyTightBxWrong, nAllL1),
                    calcSigma(nDtOnlyTightBxWrong, nAllL1) * 100))
        self.debug("%30s: %7d => %6.2f +/- %6.2f" %
                   ('Tight DT only, BX wrong + HO', nDtOnlyTightBxWrongHo,
                    calcPercent(nDtOnlyTightBxWrongHo, nAllL1),
                    calcSigma(nDtOnlyTightBxWrongHo, nAllL1) * 100))
        print
        return
Example #8
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
Example #9
0
    def printFractionsPerIEta(self, graph):
        self.output("Fractions of HO time in [-12.5,12.5] ns")
        counterDict = [{
            'total':
            0,
            'inside':
            0,
            'hist':
            TH1D('hist' + str(i - 10), '', 201, -100.5, 100.5)
        } for i in range(0, 21)]
        x = Double(0)
        y = Double(0)
        nTotal = graph.GetN()

        ###
        # Fill histograms for later calculation of mean
        ###
        for i in range(0, nTotal):
            graph.GetPoint(i, x, y)
            indexHelper = int(x + 10)
            counterDict[indexHelper]['total'] += 1
            counterDict[indexHelper]['hist'].Fill(y)

        ###
        # Once all histograms are filled, calculate median
        ###
        for index, item in enumerate(counterDict):
            item['median'] = getMedian(item['hist'])

        ###
        # Fill the number of objects in interval depending on the
        # Histogram median
        ###
        nDone = 0
        if self.DEBUG:
            self.debug('Filling interval counters')
        for i in range(0, nTotal):
            graph.GetPoint(i, x, y)
            indexHelper = int(x + 10)
            median = counterDict[indexHelper]['median']
            if (fabs(median - y) < 12.5):
                counterDict[indexHelper]['inside'] += 1
            nDone += 1
            self.printProgress(nDone, nTotal)

        #Graph for results
        graph = TEfficiency(graph.GetName(), "", 21, -10.5, 10.5)

        ###
        # Plot the results of calculations on CLI
        ###
        for index, item in enumerate(counterDict):
            if (index - 10 == 0):
                continue
            total = item['total']
            inside = item['inside']
            self.output(
                "iEta: %3d\tTotal: %5d\tInside:%5d\tFraction:%6.2f +/- %6.2f" %
                (index - 10, total, inside, calcPercent(
                    inside, total), calcSigma(inside, total) * 100))
            graph.SetTotalEvents(graph.FindFixBin(index - 10), total)
            graph.SetPassedEvents(graph.FindFixBin(index - 10), inside)
        return graph, counterDict
Example #10
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