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
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
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
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
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
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
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
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
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
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
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
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