Beispiel #1
0
	def __init__(self,filename = None,data = False, debug = False):
		setPlotStyle()
		self.commandLine = CommandLineHandler('[' + self.__class__.__name__ + ']')
		self.key = 'L1MuonPresent' if data else 'L1MuonTruth'
		self.data = data
		self.DEBUG = debug
		if filename != None:
			self.fileHandler = self.createFileHandler(filename)
		pass
Beispiel #2
0
	def __init__(self,filename,data = False):
		self.commandLine = CommandLineHandler('[TimeWindow] ')
		self.fileHandler = RootFileHandler(filename)
		self.fileHandler.printStatus()
		if( not os.path.exists('plots')):
			os.mkdir('plots')
		if( not os.path.exists('plots/efficiencyWithTime')):
			os.mkdir('plots/efficiencyWithTime')
		setPlotStyle()
		self.data = data
Beispiel #3
0
	def __init__(self,filename,debug,data = False):
		self.commandLine = CommandLineHandler('[TimeWindow] ')
		self.fileHandler = RootFileHandler(filename)
		self.fileHandler.printStatus()
		if( not os.path.exists('plots')):
			os.mkdir('plots')
		if( not os.path.exists('plots/efficiencyWithTime')):
			os.mkdir('plots/efficiencyWithTime')
		setPlotStyle()
		self.data = data
Beispiel #4
0
	def __init__(self,filename,data =False):
		self.commandLine = CommandLineHandler('[QualityCode] ')
		self.fileHandler = RootFileHandler(filename)
		self.fileHandler.printStatus()
		if( not os.path.exists('plots')):
			os.mkdir('plots')
		if( not os.path.exists('plots/qualityCode')):
			os.mkdir('plots/qualityCode')
		setPlotStyle()
		self.data = data
Beispiel #5
0
 def __init__(self, filename=None, data=False, debug=False):
     setPlotStyle()
     self.commandLine = CommandLineHandler('[' + self.__class__.__name__ +
                                           ']')
     self.key = 'L1MuonPresent' if data else 'L1MuonTruth'
     self.data = data
     self.DEBUG = debug
     self.filename = filename
     if self.DEBUG:
         self.debug("Creating plot module %s" % self.__class__.__name__)
     if filename != None:
         self.fileHandler = self.createFileHandler(filename)
     pass
Beispiel #6
0
	def plotEfficiencyCountCheck(self):
		c = TCanvas()
		genHist = self.fileHandler.getHistogram('count/Gen_Count')
		l1AndGenHist = self.fileHandler.getHistogram('count/GenAndL1Muon_Count')
		plusHoHist = self.fileHandler.getHistogram('count/GenAndL1MuonAndHoAboveThr_Count')
		plusHoHist.SetLineColor(colorRwthMagenta)
		genHist.SetLineColor(colorRwthDarkBlue)
	
		genHist.SetLineWidth(3)
		l1AndGenHist.SetLineWidth(3)
		plusHoHist.SetLineWidth(3)
	
		setPlotStyle()
	
		genHist.Draw()
		l1AndGenHist.Draw('same')
		plusHoHist.Draw('same')
		
		return c,l1AndGenHist,plusHoHist,genHist
Beispiel #7
0
    def plotEfficiencyCountCheck(self):
        c = TCanvas()
        genHist = self.fileHandler.getHistogram('count/Gen_Count')
        l1AndGenHist = self.fileHandler.getHistogram(
            'count/GenAndL1Muon_Count')
        plusHoHist = self.fileHandler.getHistogram(
            'count/GenAndL1MuonAndHoAboveThr_Count')
        plusHoHist.SetLineColor(colorRwthMagenta)
        genHist.SetLineColor(colorRwthDarkBlue)

        genHist.SetLineWidth(3)
        l1AndGenHist.SetLineWidth(3)
        plusHoHist.SetLineWidth(3)

        setPlotStyle()

        genHist.Draw()
        l1AndGenHist.Draw('same')
        plusHoHist.Draw('same')

        return c, l1AndGenHist, plusHoHist, genHist
Beispiel #8
0
DEBUG = 1
prefix = '[plotEfficiency] '

markerpairs = [	[20,24],[21,25],[22,26],[23,32],[34,28] ]

if len(sys.argv) < 2:
	print 'First argument has to be the file name scheme!'
fileHandler = RootFileHandler(sys.argv[1])
fileHandler.printStatus()

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

setPlotStyle()

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")
import sys
from ROOT import TFile, TCanvas

from plotting.PlotStyle import setPlotStyle, getLabelCmsPrivateSimulation
setPlotStyle()


def plotCorrectedL1MatchEfficiency():
    c = TCanvas("cL1EffCorrected", "L1EffCorected", 1800, 900)
    c.Divide(2, 1)

    fileVaried = TFile.Open('condor/L1Eff.root')
    if (fileVaried.IsZombie()):
        print 'Error opening file: condor/L1Eff.root'
        sys.exit(1)

    hVaried = fileVaried.Get('histL1Eff')
    hOriginal = hVaried.Clone('clone')
    hVaried.SetName('histL1EffVariedCorrected')

    min = 0
    max = 100
    label = getLabelCmsPrivateSimulation()

    correctionsFile = open('geometricEfficiencies.txt')
    correctionsList = []
    for line in correctionsFile.readlines():
        if line.startswith('#'):
            continue
        correctionsList.append(float((line.split())[1]))
    print correctionsList
Beispiel #10
0
	def plotFractionsOfBxId(self):
		##BX right plotting pt
		canvasBxRightPt = TCanvas("cBxRightPt","cBxRightPt",1200,1200)
		canvasBxRightPt.cd().SetLeftMargin(0.15)
		hBxRightPt = self.fileHandler.getHistogram('BxRightGen_Pt').Clone()
		setPlotStyle()
		hBxRightPt.Rebin(50)
		hBxRightPt.GetXaxis().SetRangeUser(0,200)
		hBxRightPt.GetYaxis().SetTitle("normalized Entries / 5 GeV")
		hBxRightPt.GetXaxis().SetTitle("p_{T} Gen")
		hBxRightPt.GetYaxis().SetTitleOffset(2)
		hBxRightPt.SetTitle("Events with right BX ID vs. p_{T}")
		hBxRightPt.SetStats(0)
		hBxRightPt.SetLineWidth(2)
		hBxRightPt.Scale(1/hBxRightPt.Integral())
		hBxRightPt.Draw()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		self.storeCanvas(canvasBxRightPt,"bxRightPt")
		
		##BX wrong plotting pt
		canvasBxWrongPt = TCanvas("cBxWrongPt","cBxWrongPt",1200,1200)
		canvasBxWrongPt.cd().SetLeftMargin(0.15)
		hBxWrongPt = self.fileHandler.getHistogram('BxWrongGen_Pt').Clone()
		setPlotStyle()
		hBxWrongPt.Rebin(50)
		hBxWrongPt.GetXaxis().SetRangeUser(0,200)
		hBxWrongPt.GetYaxis().SetTitle("normalized Entries / 5 GeV")
		hBxWrongPt.GetXaxis().SetTitle("p_{T} Gen")
		hBxWrongPt.GetYaxis().SetTitleOffset(2)
		hBxWrongPt.SetTitle("Events with wrong BX ID vs. p_{T}")
		hBxWrongPt.SetStats(0)
		hBxWrongPt.SetLineWidth(2)
		hBxWrongPt.Scale(1/hBxWrongPt.Integral())
		hBxWrongPt.DrawCopy()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		self.storeCanvas(canvasBxWrongPt,"bxWrongPt")

		#Plot the histogram stack
		canvasStack = TCanvas("cStacked","cStacked",1200,1200)
		canvasStack.cd().SetLeftMargin(0.15)
		hWrong = self.fileHandler.getHistogram('BxWrongGen_Pt')
		hRight = self.fileHandler.getHistogram('BxRightGen_Pt')
		hRightFraction = TH1D('hRightFraction','',100,0,500)
		hWrongFraction = TH1D('hWrongFraction','',100,0,500)
		#hWrong.Rebin(50)
		#hRight.Rebin(50)
		#Fill the histograms with the bin wise fractions
		for i in range(0,hRight.GetNbinsX()):
			nRight = hRight.GetBinContent(i+1)
			nWrong = hWrong.GetBinContent(i+1)
			if(nRight + nWrong == 0):
				continue
			hRightFraction.SetBinContent(i+1,nRight/(nRight+nWrong))
			hWrongFraction.SetBinContent(i+1,nWrong/(nRight+nWrong))
		
		#Create the stack
		stack = THStack("hstack","Fractions of events for BX ID correct and wrong")
		nRight = hRight.Integral()
		nWrong = hWrong.Integral()
		hRightFraction.SetLineColor(colorRwthDarkBlue)
		hRightFraction.SetFillColor(colorRwthDarkBlue)
		hRightFraction.SetFillStyle(3002)
		hWrongFraction.SetLineColor(colorRwthMagenta)
		hWrongFraction.SetFillColor(colorRwthMagenta)
		hWrongFraction.SetFillStyle(3002)
		stack.Add(hRightFraction)
		stack.Add(hWrongFraction)
		stack.Draw()
		stack.GetXaxis().SetRangeUser(0.5,201)
		stack.GetYaxis().SetTitle('rel. fraction / 5 GeV')
		stack.GetYaxis().SetTitleOffset(2)
		stack.GetXaxis().SetTitle('p_{T} Gen')
		stack.SetMinimum(0.9)
		stack.SetMaximum(1)
		legend = TLegend(0.6,0.75,0.9,0.9)
		legend.AddEntry(hRightFraction,"BX ID right","f")
		legend.AddEntry(hWrongFraction,"BX ID wrong","f")
		legend.Draw()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		canvasStack.Update()
		self.storeCanvas(canvasStack,"bxStacked")
Beispiel #11
0
	def plotFractionsOfBxId(self):
		##BX right plotting pt
		canvasBxRightPt = TCanvas("cBxRightPt","cBxRightPt",1200,1200)
		canvasBxRightPt.cd().SetLeftMargin(0.15)
		hBxRightPt = self.fileHandler.getHistogram('BxRightGen_Pt').Clone()
		setPlotStyle()
		hBxRightPt.Rebin(50)
		hBxRightPt.GetXaxis().SetRangeUser(0,200)
		hBxRightPt.GetYaxis().SetTitle("normalized Entries / 5 GeV")
		hBxRightPt.GetXaxis().SetTitle("p_{T} Gen")
		hBxRightPt.GetYaxis().SetTitleOffset(2)
		hBxRightPt.SetTitle("Events with right BX ID vs. p_{T}")
		hBxRightPt.SetStats(0)
		hBxRightPt.SetLineWidth(2)
		hBxRightPt.Scale(1/hBxRightPt.Integral())
		hBxRightPt.Draw()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		self.storeCanvas(canvasBxRightPt,"bxRightPt")
		
		##BX wrong plotting pt
		canvasBxWrongPt = TCanvas("cBxWrongPt","cBxWrongPt",1200,1200)
		canvasBxWrongPt.cd().SetLeftMargin(0.15)
		hBxWrongPt = self.fileHandler.getHistogram('BxWrongGen_Pt').Clone()
		setPlotStyle()
		hBxWrongPt.Rebin(50)
		hBxWrongPt.GetXaxis().SetRangeUser(0,200)
		hBxWrongPt.GetYaxis().SetTitle("normalized Entries / 5 GeV")
		hBxWrongPt.GetXaxis().SetTitle("p_{T} Gen")
		hBxWrongPt.GetYaxis().SetTitleOffset(2)
		hBxWrongPt.SetTitle("Events with wrong BX ID vs. p_{T}")
		hBxWrongPt.SetStats(0)
		hBxWrongPt.SetLineWidth(2)
		hBxWrongPt.Scale(1/hBxWrongPt.Integral())
		hBxWrongPt.DrawCopy()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		self.storeCanvas(canvasBxWrongPt,"bxWrongPt")

		#Plot the histogram stack
		canvasStack = TCanvas("cStacked","cStacked",1200,1200)
		canvasStack.cd().SetLeftMargin(0.15)
		hWrong = self.fileHandler.getHistogram('BxWrongGen_Pt')
		hRight = self.fileHandler.getHistogram('BxRightGen_Pt')
		hRightFraction = TH1D('hRightFraction','',100,0,500)
		hWrongFraction = TH1D('hWrongFraction','',100,0,500)
		#hWrong.Rebin(50)
		#hRight.Rebin(50)
		#Fill the histograms with the bin wise fractions
		for i in range(0,hRight.GetNbinsX()):
			nRight = hRight.GetBinContent(i+1)
			nWrong = hWrong.GetBinContent(i+1)
			if(nRight + nWrong == 0):
				continue
			hRightFraction.SetBinContent(i+1,nRight/(nRight+nWrong))
			hWrongFraction.SetBinContent(i+1,nWrong/(nRight+nWrong))
		
		#Create the stack
		stack = THStack("hstack","Fractions of events for BX ID correct and wrong")
		nRight = hRight.Integral()
		nWrong = hWrong.Integral()
		hRightFraction.SetLineColor(colorRwthDarkBlue)
		hRightFraction.SetFillColor(colorRwthDarkBlue)
		hRightFraction.SetFillStyle(3002)
		hWrongFraction.SetLineColor(colorRwthMagenta)
		hWrongFraction.SetFillColor(colorRwthMagenta)
		hWrongFraction.SetFillStyle(3002)
		stack.Add(hRightFraction)
		stack.Add(hWrongFraction)
		stack.Draw()
		stack.GetXaxis().SetRangeUser(0.5,201)
		stack.GetYaxis().SetTitle('rel. fraction / 5 GeV')
		stack.GetYaxis().SetTitleOffset(2)
		stack.GetXaxis().SetTitle('p_{T} Gen')
		stack.SetMinimum(0.9)
		stack.SetMaximum(1)
		legend = TLegend(0.6,0.75,0.9,0.9)
		legend.AddEntry(hRightFraction,"BX ID right","f")
		legend.AddEntry(hWrongFraction,"BX ID wrong","f")
		legend.Draw()
		label = getLabelCmsPrivateSimulation()
		label.Draw()
		canvasStack.Update()
		self.storeCanvas(canvasStack,"bxStacked")