print "\t", "making y-projection of resolution plots" try: print "\t"*2, "y-projection slices of resolution" # y projection slices pl_res_proj = {} fig, ax = pl.subplots(figsize=helpers.figsize) for oJetPt_cuts in [(170., 180.), (200., 220.), (300., 350.)]: oJetPt_cut = helpers.btwn(data['oJet.pt'], oJetPt_cuts[0], oJetPt_cuts[1]) hist, bins = np.histogram(resolution[np.where(cut & oJetPt_cut & tJet_exists_subtracted)], bins=100, density=True) fwhm = helpers.FWHM(bins, hist) ax.plot(bins[:-1], hist, linestyle='steps-post', alpha=0.75, color='b', label=r'${:0.0f}\ \mathrm{{GeV}} < p_T^\mathrm{{oJet}} <\ {:0.0f}\ \mathrm{{GeV}}$\nFWHM = {:0.4f}'.format(oJetPt_cuts[0], oJetPt_cuts[1], fwhm), linewidth=helpers.linewidth) pl_res_proj['{:0.0f}to{:0.0f}'.format(oJetPt_cuts[0], oJetPt_cuts[1])] = resolution[np.where(cut & oJetPt_cut & tJet_exists_subtracted)] helpers.add_legend(fig, ax) helpers.add_labels(fig, ax, xlabel=r'resolution $\frac{E_T^\mathrm{gFEX} - p_T^\mathrm{offline}}{p_T^\mathrm{offline}}$', ylabel='normalized counts', title='Y-Axis Projections of Resolution') helpers.add_description(fig, ax, align='br', strings=[helpers.dataSetStr, helpers.seedCutStr, helpers.noiseCutStr, helpers.towerThrStr]) ax.set_xlim((-1.0, 1.0)) helpers.add_grid(fig, ax) pickle.dump(pl_res_proj, file(helpers.write_file('plots/pickle/{}_resolution_PtOffline_projection_region{}.pkl'.format(filename_id, i)), 'w+')) helpers.to_file(fig, ax, 'plots/resolution/{}_resolution_PtOffline_projection_region{}.png'.format(filename_id, i)) pl.close(fig) except: print "\t"*2, "Error for {}: could not make resolution projection".format(region) pl.close(fig) pass try: print "\t"*2, "y-projection slices of corrected resolution" pl_res_proj = {}
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))
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))
where = np.where(helpers.btwn(data['oJet.pt'], 200., 250.)) ax.plot( bins_multiplicity[:-1], np.cumsum( np.sum( data['gTower_distribution'][where]).astype(float)[::-1])[::-1] / where[0].size, linestyle='steps-post', 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
label_x = r'$\eta^\mathrm{oJet}$' label_y = r'$\phi^\mathrm{oJet}$' fig, ax = helpers.corr2d(x, y, bins_x, bins_y, label_x, label_y, profile_x=True, profile_y=True, align='tl', strings=[helpers.dataSetStr, helpers.seedCutStr, helpers.noiseCutStr, helpers.towerThrStr]) helpers.to_file(fig, ax, 'plots/offline_jet_kinematics/%s_angular_positions.png' % (filename_id)) pl.close(fig) # y projection slices fig, ax = pl.subplots(figsize=helpers.figsize) selections = {'left': np.where((-1.9 < data['oJet.eta']) & (data['oJet.eta'] < -1.5)), 'middle': np.where((-0.2 < data['oJet.eta']) & (data['oJet.eta'] < 0.2)), 'right': np.where((1.5 < data['oJet.eta']) & (data['oJet.eta'] < 1.9))} ax.hist(data['oJet.phi'][selections['left']], bins=100, weights=data['weight'][selections['left']], stacked=True, fill=False, histtype='step', linewidth=helpers.linewidth, alpha=0.75, color='b', label='$-1.9\ < \eta^\mathrm{oJet} <\ -1.5$') ax.hist(data['oJet.phi'][selections['middle']], bins=100, weights=data['weight'][selections['middle']], stacked=True, fill=False, histtype='step', linewidth=helpers.linewidth, alpha=0.75, color='c', label='$-0.2\ < \eta^\mathrm{oJet} <\ 0.2$') ax.hist(data['oJet.phi'][selections['right']], bins=100, weights=data['weight'][selections['right']], stacked=True, fill=False, histtype='step', linewidth=helpers.linewidth, alpha=0.75, color='r', label='$1.5\ < \eta^\mathrm{oJet} <\ 1.9$') helpers.add_legend(fig, ax) helpers.add_labels(fig, ax, xlabel=r'$\eta^\mathrm{oJet}$', ylabel='weighted counts', title='Y-Axis Projections of $\phi^\mathrm{oJet}$') helpers.add_description(fig, ax, align='cr', strings=[helpers.dataSetStr, helpers.seedCutStr, helpers.noiseCutStr, helpers.towerThrStr]) ax.set_yscale('log', nonposy='clip') helpers.add_grid(fig, ax) helpers.to_file(fig, ax, 'plots/offline_jet_kinematics/%s_offline_jet_phi_projection_y.png' % (filename_id)) pl.close(fig) # eta-pt correlations x = data['oJet.eta'] y = data['oJet.pt'] bins_x = np.arange(-2.7, 2.7, 0.2) bins_y = np.arange(0., 375., 10.) label_x = r'$\eta^\mathrm{oJet}$' label_y = r'$p_T^\mathrm{oJet}$' fig, ax = helpers.corr2d(x, y, bins_x, bins_y, label_x, label_y, profile_x=True, profile_y=True, align='tl',
ax.plot(bins_multiplicity[:-1], np.cumsum(np.sum(data['gTower_distribution'][where]).astype(float)[::-1])[::-1]/where[0].size, linestyle='steps-post', alpha=0.75, color=helpers.colors[2], label='$150 < p_T^\mathrm{{oJet}} < 200$\n{:d} events'.format(where[0].size), linewidth=helpers.linewidth) where = np.where(helpers.btwn(data['oJet.pt'], 200., 250.)) ax.plot(bins_multiplicity[:-1], np.cumsum(np.sum(data['gTower_distribution'][where]).astype(float)[::-1])[::-1]/where[0].size, linestyle='steps-post', 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