コード例 #1
0
ファイル: liveDisplay.py プロジェクト: Kuenni/HoMuonTrigger
def plotProduct():
	canvas = TCanvas("canvas2p","canvas2p",1200,1200)
	hist = getTH2D("histEffp","L1 Matched to GEN and HO;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histCorrect = getTH2D("histMatchedTruthp","Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histTotal = getTH2D("histTotalTruthp","Parameter Scan Total events;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histCorrectTime = getTH2D("histCorrectp","Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histTotalTime = getTH2D("histTotalp","Parameter Scan Total events;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	for filename in os.listdir('./results'):
		if filename[-4:] == '.txt':
			file = open('./results/' + filename,'r')
			for line in file.readlines():
				if line.find('deltaR') != -1:
					continue
				lineParts = line.split('\t')
				deltaR 	= float(lineParts[0])
				eThr 	= float(lineParts[1])
				nCorrect = float(lineParts[2])
				nTotal 	= float(lineParts[3])
				nMatched = float(lineParts[4])
				nTruth = float(lineParts[5])
				if(nTruth > 0 and nTotal > 0):
					histCorrect.SetBinContent(histCorrect.FindBin(deltaR,eThr),histCorrect.GetBinContent(histCorrect.FindBin(deltaR,eThr)) + nMatched)
					histTotal.SetBinContent(histTotal.FindBin(deltaR,eThr),histTotal.GetBinContent(histCorrect.FindBin(deltaR,eThr)) + nTruth)
					histCorrectTime.SetBinContent(histCorrectTime.FindBin(deltaR,eThr),histCorrectTime.GetBinContent(histCorrectTime.FindBin(deltaR,eThr)) + nCorrect)
					histTotalTime.SetBinContent(histTotalTime.FindBin(deltaR,eThr),histTotalTime.GetBinContent(histTotalTime.FindBin(deltaR,eThr)) + nTotal)
					
	hist.SetStats(0)
	minimum = 100
	for i in range(0,hist.GetNbinsX()):
		for j in range (0,hist.GetNbinsY()):
			if histTotal.GetBinContent(i,j) > 0:
				fraction = histCorrect.GetBinContent(i,j)/histTotal.GetBinContent(i,j)*histCorrectTime.GetBinContent(i,j)/histTotalTime.GetBinContent(i,j)*100
				hist.SetBinContent(i,j,fraction)
				if fraction < minimum:
					minimum = fraction
					
	hist.SetMinimum(minimum)
	hist.SetContour(100)
	hist.GetYaxis().SetTitleOffset(1.45)
	hist.GetZaxis().SetTitle('Efficiency #times Time fraction / %')
	hist.Draw('colz')
	
	canvas.Update()
	pal = hist.GetListOfFunctions().FindObject("palette")
	pal.SetX2NDC(0.92)
	
	label = getLabelCmsPrivateSimulation()
	label.Draw()
	
	hist.SaveAs('product.root')
	
	canvas.Update()	
	return canvas,hist,label
コード例 #2
0
ファイル: liveDisplay.py プロジェクト: Kuenni/HoMuonTrigger
def plotTimeFraction():	
	canvas = TCanvas("canvas","canvas",1200,1200)
	hist = getTH2D("hist","Parameter Scan;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histCorrect = getTH2D("histCorrect","Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	histTotal = getTH2D("histTotal","Parameter Scan Total events;#DeltaR;E_{Thr}",16,-0.0375,0.3625,16,-0.0375,0.3625)
	
	l1Total = 0
	
	for filename in os.listdir('./results'):
		if filename[-4:] == '.txt':
			file = open('./results/' + filename,'r')
			for line in file.readlines():
				if line.find('deltaR') != -1:
					continue
				lineParts = line.split('\t')
				deltaR 	= float(lineParts[0])
				eThr 	= float(lineParts[1])
				nCorrect = float(lineParts[2])
				nTotal 	= float(lineParts[3])
				l1Total += nTotal
				if(nTotal > 0):
					histCorrect.SetBinContent(histCorrect.FindBin(deltaR,eThr),histCorrect.GetBinContent(histCorrect.FindBin(deltaR,eThr)) + nCorrect)
					histTotal.SetBinContent(histTotal.FindBin(deltaR,eThr),histTotal.GetBinContent(histCorrect.FindBin(deltaR,eThr)) + nTotal)
	
	hist.SetStats(0)
	minimum = 100
	for i in range(0,hist.GetNbinsX()):
		for j in range (0,hist.GetNbinsY()):
			if histTotal.GetBinContent(i,j) > 0:
				fraction = histCorrect.GetBinContent(i,j)/histTotal.GetBinContent(i,j)*100
				hist.SetBinContent(i,j,fraction)
				if fraction < minimum:
					minimum = fraction
					
	hist.SetMinimum(minimum)
	hist.SetContour(100)
	hist.SetTitle('Parameter Scan, Single #mu Gun,XYZ')
	hist.GetYaxis().SetTitleOffset(1.45)
	hist.GetZaxis().SetTitle('Fraction within |12.5| ns / %')
	hist.Draw('colz')
	
	canvas.Update()
	pal = hist.GetListOfFunctions().FindObject("palette")
	pal.SetX2NDC(0.92)
	
	label = getLabelCmsPrivateSimulation()
	label.Draw()
	
	hist.SaveAs('FractionTimeWindow.root')
	
	canvas.Update()
	return canvas,hist,label
コード例 #3
0
ファイル: liveDisplay.py プロジェクト: ashrafkasem/MCHAMMER
def plotTimeFraction():
    canvas = TCanvas("canvas", "canvas", 1200, 1200)
    hist = getTH2D("hist", "Parameter Scan;#DeltaR;E_{Thr}", 16, -0.0375,
                   0.3625, 16, -0.0375, 0.3625)
    histCorrect = getTH2D("histCorrect",
                          "Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}", 16,
                          -0.0375, 0.3625, 16, -0.0375, 0.3625)
    histTotal = getTH2D("histTotal",
                        "Parameter Scan Total events;#DeltaR;E_{Thr}", 16,
                        -0.0375, 0.3625, 16, -0.0375, 0.3625)

    l1Total = 0

    for filename in os.listdir('./results'):
        if filename[-4:] == '.txt':
            file = open('./results/' + filename, 'r')
            for line in file.readlines():
                if line.find('deltaR') != -1:
                    continue
                lineParts = line.split('\t')
                deltaR = float(lineParts[0])
                eThr = float(lineParts[1])
                nCorrect = float(lineParts[2])
                nTotal = float(lineParts[3])
                l1Total += nTotal
                if (nTotal > 0):
                    histCorrect.SetBinContent(
                        histCorrect.FindBin(deltaR, eThr),
                        histCorrect.GetBinContent(
                            histCorrect.FindBin(deltaR, eThr)) + nCorrect)
                    histTotal.SetBinContent(
                        histTotal.FindBin(deltaR, eThr),
                        histTotal.GetBinContent(
                            histCorrect.FindBin(deltaR, eThr)) + nTotal)

    hist.SetStats(0)
    minimum = 100
    for i in range(0, hist.GetNbinsX()):
        for j in range(0, hist.GetNbinsY()):
            if histTotal.GetBinContent(i, j) > 0:
                fraction = histCorrect.GetBinContent(
                    i, j) / histTotal.GetBinContent(i, j) * 100
                hist.SetBinContent(i, j, fraction)
                if fraction < minimum:
                    minimum = fraction

    hist.SetMinimum(minimum)
    hist.SetContour(100)
    hist.SetTitle('Parameter Scan, Single #mu Gun,XYZ')
    hist.GetYaxis().SetTitleOffset(1.45)
    hist.GetZaxis().SetTitle('Fraction within |12.5| ns / %')
    hist.Draw('colz')

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

    label = getLabelCmsPrivateSimulation()
    label.Draw()

    hist.SaveAs('FractionTimeWindow.root')

    canvas.Update()
    return canvas, hist, label
コード例 #4
0
ファイル: liveDisplay.py プロジェクト: ashrafkasem/MCHAMMER
def plotProduct():
    canvas = TCanvas("canvas2p", "canvas2p", 1200, 1200)
    hist = getTH2D("histEffp", "L1 Matched to GEN and HO;#DeltaR;E_{Thr}", 16,
                   -0.0375, 0.3625, 16, -0.0375, 0.3625)
    histCorrect = getTH2D("histMatchedTruthp",
                          "Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}", 16,
                          -0.0375, 0.3625, 16, -0.0375, 0.3625)
    histTotal = getTH2D("histTotalTruthp",
                        "Parameter Scan Total events;#DeltaR;E_{Thr}", 16,
                        -0.0375, 0.3625, 16, -0.0375, 0.3625)
    histCorrectTime = getTH2D("histCorrectp",
                              "Parameter Scan in abs(12.5)ns;#DeltaR;E_{Thr}",
                              16, -0.0375, 0.3625, 16, -0.0375, 0.3625)
    histTotalTime = getTH2D("histTotalp",
                            "Parameter Scan Total events;#DeltaR;E_{Thr}", 16,
                            -0.0375, 0.3625, 16, -0.0375, 0.3625)
    for filename in os.listdir('./results'):
        if filename[-4:] == '.txt':
            file = open('./results/' + filename, 'r')
            for line in file.readlines():
                if line.find('deltaR') != -1:
                    continue
                lineParts = line.split('\t')
                deltaR = float(lineParts[0])
                eThr = float(lineParts[1])
                nCorrect = float(lineParts[2])
                nTotal = float(lineParts[3])
                nMatched = float(lineParts[4])
                nTruth = float(lineParts[5])
                if (nTruth > 0 and nTotal > 0):
                    histCorrect.SetBinContent(
                        histCorrect.FindBin(deltaR, eThr),
                        histCorrect.GetBinContent(
                            histCorrect.FindBin(deltaR, eThr)) + nMatched)
                    histTotal.SetBinContent(
                        histTotal.FindBin(deltaR, eThr),
                        histTotal.GetBinContent(
                            histCorrect.FindBin(deltaR, eThr)) + nTruth)
                    histCorrectTime.SetBinContent(
                        histCorrectTime.FindBin(deltaR, eThr),
                        histCorrectTime.GetBinContent(
                            histCorrectTime.FindBin(deltaR, eThr)) + nCorrect)
                    histTotalTime.SetBinContent(
                        histTotalTime.FindBin(deltaR, eThr),
                        histTotalTime.GetBinContent(
                            histTotalTime.FindBin(deltaR, eThr)) + nTotal)

    hist.SetStats(0)
    minimum = 100
    for i in range(0, hist.GetNbinsX()):
        for j in range(0, hist.GetNbinsY()):
            if histTotal.GetBinContent(i, j) > 0:
                fraction = histCorrect.GetBinContent(
                    i, j) / histTotal.GetBinContent(
                        i, j) * histCorrectTime.GetBinContent(
                            i, j) / histTotalTime.GetBinContent(i, j) * 100
                hist.SetBinContent(i, j, fraction)
                if fraction < minimum:
                    minimum = fraction

    hist.SetMinimum(minimum)
    hist.SetContour(100)
    hist.GetYaxis().SetTitleOffset(1.45)
    hist.GetZaxis().SetTitle('Efficiency #times Time fraction / %')
    hist.Draw('colz')

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

    label = getLabelCmsPrivateSimulation()
    label.Draw()

    hist.SaveAs('product.root')

    canvas.Update()
    return canvas, hist, label