print region try: print "\t", "correction Et versus tJetEt" # make a correlation of corrected Et versus trigger jet Et x = data['tJet.et'][region_cut] y = tJetEt_correction[region_cut] bins_x = bins_y = np.arange(0., 1500., 10.) xlim = (0., 1000.) ylim = (0., 200.) label_x = r'$E_T^{\mathrm{gJet}}$ [GeV]' label_y = r'$\rho*A^\mathrm{gJet}$ [GeV]' fig, ax = helpers.corr2d(x, y, bins_x, bins_y, label_x, label_y, xlim=xlim, ylim=ylim, profile_y=True, align='tr', strings=[helpers.dataSetStr, helpers.seedCutStr, helpers.noiseCutStr, helpers.towerThrStr]) helpers.to_file(fig, ax, 'plots/trigger_jet_Et_correction/{}_trigger_jet_Et_correction_region{}.png'.format(filename_id, i)) pl.close(fig) except: print "\t", "Error for {}: could not make correlation of corrected Et versus trigger jet Et".format(region) pl.close(fig) pass try: print "\t", "oJetPt versus tJetEt" x = data['oJet.pt'][np.where(tJet_exists & cut)] y = data['tJet.et'][np.where(tJet_exists & cut)] bins_x = bins_y = np.arange(0., 1500., 10.) xlim = ylim = (0., 1000.) label_x = r'offline $p_T^{\mathrm{jet}}$ [GeV]' label_y = r'trigger $E_T^{\mathrm{jet}}$ [GeV]'
sigData = np.zeros((4, 4)) bkgData = background['gJetEtCut_{:0.0f}'.format(gJetEt_cut)]['']['gTowerEtCut_{:0.0f}'.format(gTowerEt_cut)]['oJetnsjCut_{:d}'.format(0)]['vals'] for gJetnsj_cut, i in zip([1, 2, 3, 4], range(4)): # add storage by oJetnsj_cut sigData[i] = signal['gJetEtCut_{:0.0f}'.format(gJetEt_cut)][filenameEnd]['gTowerEtCut_{:0.0f}'.format(gTowerEt_cut)]['gJetnsjCut_{:d}'.format(gJetnsj_cut)]['vals'] fig, ax = pl.subplots(figsize=helpers.figsize) for sig, color, oJetnsj_cut in zip(sigData.T, helpers.colors, range(1, 5)): print "\t"*3, "oJetnsj_cut = {}".format(oJetnsj_cut) # make a label for oJet nsj cut oJetnsjCutLabel = r'$N(P_T^\mathrm{{oJet\ subjet}} >\ 20 \ \mathrm{{GeV}}) \geq {:d}$'.format(oJetnsj_cut) ax.plot(sig, bkgData, linestyle='steps-mid', alpha=0.75, color=color, marker='x', ms=20, mew=10, linewidth=0, label=oJetnsjCutLabel) ax.set_xlim((0.0, 1.1)) ax.set_ylim((0.0, 2.0)) ax.set_xticks(np.linspace(0., 1., 6)) ax.set_yticks(np.linspace(0., 1., 6)) helpers.add_legend(fig, ax, numpoints=1) helpers.add_labels(fig, ax, xlabel='signal', ylabel='background') helpers.add_description(fig, ax, align='tl', strings=[helpers.dataSetStr, 'iso., $\Delta R(\mathrm{gJet},\mathrm{oJet})\leq 1$', helpers.seedCutStr, helpers.noiseCutStr, gJetEtCutLabel, gTowerEtThrLabel, offlineLabel]) helpers.add_grid(fig, ax) helpers.to_file(fig, ax, 'rates/{}_gJetEt{:0.0f}_gTowerEt{:0.0f}.png'.format(filename_id, gJetEt_cut, gTowerEt_cut)) pl.close(fig) endTime_wall = time.time() endTime_processor = time.clock() print "Finished job in:\n\t Wall time: {:0.2f} s \n\t Clock Time: {:0.2f} s".format((endTime_wall - startTime_wall), (endTime_processor - startTime_processor))
mew=10, linewidth=0, label=oJetnsjCutLabel) ax.set_xlim((0.0, 1.1)) ax.set_ylim((0.0, 2.0)) ax.set_xticks(np.linspace(0., 1., 6)) ax.set_yticks(np.linspace(0., 1., 6)) helpers.add_legend(fig, ax, numpoints=1) helpers.add_labels(fig, ax, xlabel='signal', ylabel='background') helpers.add_description( fig, ax, align='tl', strings=[ helpers.dataSetStr, 'iso., $\Delta R(\mathrm{gJet},\mathrm{oJet})\leq 1$', helpers.seedCutStr, helpers.noiseCutStr, gJetEtCutLabel, gTowerEtThrLabel, offlineLabel ]) helpers.add_grid(fig, ax) helpers.to_file( fig, ax, 'rates/{}_gJetEt{:0.0f}_gTowerEt{:0.0f}.png'.format( filename_id, gJetEt_cut, gTowerEt_cut)) pl.close(fig) endTime_wall = time.time() endTime_processor = time.clock() print "Finished job in:\n\t Wall time: {:0.2f} s \n\t Clock Time: {:0.2f} s".format( (endTime_wall - startTime_wall), (endTime_processor - startTime_processor))
alpha=0.75, color=helpers.colors[3], label='$200 < p_T^\mathrm{{oJet}} < 250$\n{:d} events'.format( where[0].size), linewidth=helpers.linewidth) helpers.add_legend(fig, ax) helpers.add_labels(fig, ax, xlabel='$E_T^\mathrm{gTower}$ [GeV]', ylabel='gTower multiplicity / event') helpers.add_grid(fig, ax) helpers.add_description(fig, ax, align='bl', strings=[helpers.dataSetStr]) ax.set_yscale('log', nonposy='clip') ax.set_ylim((0.0, 1284.0)) helpers.to_file(fig, ax, 'plots/multiplicity/{}.png'.format(filename_id)) pl.close(fig) except: print "Could not make multiplicity plot" pl.close(fig) pass valid_gJets = np.where(tJet_exists) try: print "running out profiles for gTowers" fig, ax = pl.subplots(figsize=helpers.figsize) labels = ['$E_T^0$', '$E_T^1$', '$E_T^2$', '$E_T^3$'] gTower_Et = np.zeros((3, np.sum(data[valid_gJets].size)))
n, bins, unweightedPatches = axt.hist(data['oJet.pt'], bins=np.arange(0, 500, 2), stacked=True, fill=False, histtype='step', color='r', label=r'unweighted', linewidth=helpers.linewidth, alpha=0.75) # http://matplotlib.org/examples/api/two_scales.html for tl in ax.get_yticklabels(): tl.set_color('b') for tl in axt.get_yticklabels(): tl.set_color('r') # http://stackoverflow.com/questions/5484922/secondary-axis-with-twinx-how-to-add-to-legend patches = [weightedPatches[0], unweightedPatches[0]] # http://matplotlib.org/examples/pylab_examples/legend_auto.html labels = [p.get_label() for p in patches] ax.set_yscale('log', nonposy='clip') axt.set_yscale('log', nonposy='clip') legend = ax.legend(patches, labels, fancybox=True, framealpha=0.75, fontsize=helpers.labelsize) legend.get_frame().set_facecolor(helpers.light_grey) legend.get_frame().set_linewidth(0.0) helpers.add_labels(fig, ax, xlabel=r'$p_T$ [GeV]', ylabel=r'weighted count') helpers.add_labels(fig, axt, ylabel=r'unweighted count') helpers.add_description(fig, ax, align='cr', strings=[helpers.dataSetStr, helpers.towerThrStr]) helpers.to_file(fig, ax, "plots/weighting/{}_pt.png".format(filename_id)) pl.close(fig) endTime_wall = time.time() endTime_processor = time.clock() print "Finished job in:\n\t Wall time: {:0.2f} s \n\t Clock Time: {:0.2f} s".format((endTime_wall - startTime_wall), (endTime_processor - startTime_processor))
patches = [unweightedPatches[0], weightedPatches[0]] # http://matplotlib.org/examples/pylab_examples/legend_auto.html labels = [p.get_label() for p in patches] ax.set_yscale('log', nonposy='clip') axt.set_yscale('log', nonposy='clip') ax.set_ylim((1e-5, ax.get_ylim()[1])) axt.set_ylim((1e-5, axt.get_ylim()[1])) legend = ax.legend(patches, labels, fancybox=True, framealpha=0.75, fontsize=helpers.labelsize) legend.get_frame().set_facecolor(helpers.light_grey) legend.get_frame().set_linewidth(0.0) helpers.add_labels(fig, ax, xlabel=r'$p_T$ [GeV]', ylabel=r'unweighted count') helpers.add_labels(fig, axt, ylabel=r'weighted count') helpers.add_description(fig, ax, align='cr', strings=[helpers.dataSetStr, helpers.seedCutStr, helpers.noiseCutStr, helpers.towerThrStr]) helpers.to_file(fig, ax, "plots/offline_jet_kinematics/{}_oJet_Pt.png".format(filename_id)) pl.close(fig) fig, ax = pl.subplots(figsize=helpers.figsize) n, bins, unweightedPatches = ax.hist(data['oJet.eta'], bins=np.arange(-4.9, 4.9, 0.2), label='unweighted', stacked=True, fill=False, histtype='step', alpha=0.75, color='r') axt = ax.twinx() n, bins, weightedPatches = axt.hist(data['oJet.eta'], weights=data['weight'], bins=np.arange(-4.9, 4.9, 0.2), label='weighted', stacked=True, fill=False, histtype='step', alpha=0.75, color='b') # http://matplotlib.org/examples/api/two_scales.html for tl in ax.get_yticklabels(): tl.set_color('r') for tl in axt.get_yticklabels(): tl.set_color('b') # make bigger ax.xaxis.set_tick_params(width=2, which='both') ax.yaxis.set_tick_params(width=2, which='both')
# http://stackoverflow.com/questions/5484922/secondary-axis-with-twinx-how-to-add-to-legend patches = [weightedPatches[0], unweightedPatches[0]] # http://matplotlib.org/examples/pylab_examples/legend_auto.html labels = [p.get_label() for p in patches] ax.set_yscale('log', nonposy='clip') axt.set_yscale('log', nonposy='clip') legend = ax.legend(patches, labels, fancybox=True, framealpha=0.75, fontsize=helpers.labelsize) legend.get_frame().set_facecolor(helpers.light_grey) legend.get_frame().set_linewidth(0.0) helpers.add_labels(fig, ax, xlabel=r'$p_T$ [GeV]', ylabel=r'weighted count') helpers.add_labels(fig, axt, ylabel=r'unweighted count') helpers.add_description(fig, ax, align='cr', strings=[helpers.dataSetStr, helpers.towerThrStr]) helpers.to_file(fig, ax, "plots/weighting/{}_pt.png".format(filename_id)) pl.close(fig) endTime_wall = time.time() endTime_processor = time.clock() print "Finished job in:\n\t Wall time: {:0.2f} s \n\t Clock Time: {:0.2f} s".format( (endTime_wall - startTime_wall), (endTime_processor - startTime_processor))
alpha=0.75, color=helpers.colors[3], label='$200 < p_T^\mathrm{{oJet}} < 250$\n{:d} events'.format(where[0].size), linewidth=helpers.linewidth) helpers.add_legend(fig, ax) helpers.add_labels(fig, ax, xlabel='$E_T^\mathrm{gTower}$ [GeV]', ylabel='gTower multiplicity / event') helpers.add_grid(fig, ax) helpers.add_description(fig, ax, align='bl', strings=[helpers.dataSetStr]) ax.set_yscale('log', nonposy='clip') ax.set_ylim((0.0, 1284.0)) helpers.to_file(fig, ax, 'plots/multiplicity/{}.png'.format(filename_id)) pl.close(fig) except: print "Could not make multiplicity plot" pl.close(fig) pass valid_gJets = np.where(tJet_exists) try: print "running out profiles for gTowers" fig, ax = pl.subplots(figsize=helpers.figsize) labels = ['$E_T^0$', '$E_T^1$', '$E_T^2$', '$E_T^3$'] gTower_Et = np.zeros((3, np.sum(data[valid_gJets].size)))