Skip to content

Commit cff5ae5

Browse files
committed
Merge pull request BristolTopGroup#286 from kreczko/comments_thorsten
Comments thorsten
2 parents 9ff301b + dcd5230 commit cff5ae5

File tree

3 files changed

+56
-26
lines changed

3 files changed

+56
-26
lines changed

config/CMS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'pad': 12
4444
}
4545

46-
legend_properties = {'size':35}
46+
legend_properties = {'size':40}
4747

4848
figsize = (16,16)
4949
dpi = 400

config/latex_labels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@
173173

174174
'electronQCDNonIso' : r"Non-iso e + jets",
175175
'electronQCDConversions' : r"Conversion e + jets",
176-
'muonQCDNonIso' : r"Non-iso $\mu$ + jets",
176+
'muonQCDNonIso' : r"Non-iso $\mu$ + jets (iso $>$ 0.3)",
177+
'muonQCDNonIso2' : r"Non-iso $\mu$ + jets (0.12 $<$ iso $<$ 0.3)",
177178
}
178179

179180
fit_variables_units_latex = {

src/cross_section_measurement/04_make_plots_matplotlib.py

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ def make_template_plots( histograms, category, channel ):
218218

219219
plt.figure( figsize = ( 16, 16 ), dpi = 200, facecolor = 'white' )
220220
axes = plt.axes()
221-
axes.minorticks_on()
221+
if not variable in ['NJets']:
222+
axes.minorticks_on()
222223

223224
plt.xlabel( fit_variables_latex[fit_variable], CMS.x_axis_title )
224225
plt.ylabel( 'normalised to unit area/(%s)' % get_unit_string(fit_variable), CMS.y_axis_title )
225226
plt.tick_params( **CMS.axis_label_major )
226-
plt.tick_params( **CMS.axis_label_minor )
227+
if not variable in ['NJets']:
228+
plt.tick_params( **CMS.axis_label_minor )
227229

228230
rplt.hist( h_ttjet, axes = axes, label = 'signal' )
229231
rplt.hist( h_single_top, axes = axes, label = 'Single Top' )
@@ -349,13 +351,19 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
349351
axes = plt.subplot( gs[0] )
350352
else:
351353
axes = plt.axes()
352-
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
353-
354-
axes.minorticks_on()
355-
356-
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
354+
if variable in ['NJets', 'abs_lepton_eta', 'lepton_eta']:
355+
plt.xlabel( '$%s$' % variables_latex[variable], CMS.x_axis_title )
356+
else:
357+
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
358+
if not variable in ['NJets']:
359+
axes.minorticks_on()
360+
if variable in ['NJets', 'abs_lepton_eta', 'lepton_eta']:
361+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title )
362+
else:
363+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
357364
plt.tick_params( **CMS.axis_label_major )
358-
plt.tick_params( **CMS.axis_label_minor )
365+
if not variable in ['NJets']:
366+
plt.tick_params( **CMS.axis_label_minor )
359367

360368
hist_data.visible = True
361369
if category == 'central':
@@ -407,43 +415,57 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
407415
new_handles.append( handle )
408416
new_labels.append( label )
409417

410-
legend_location = (0.98, 0.88)
418+
legend_location = (0.97, 0.88)
411419
if variable == 'MT':
412420
legend_location = (0.05, 0.88)
413421
elif variable == 'ST':
414-
legend_location = (0.95, 0.88)
422+
legend_location = (0.90, 0.88)
415423
plt.legend( new_handles, new_labels, numpoints = 1, prop = CMS.legend_properties, frameon = False, bbox_to_anchor=legend_location,
416424
bbox_transform=plt.gcf().transFigure )
417425
label, channel_label = get_cms_labels( channel )
418426
# title
419427
plt.title( label,loc='right', **CMS.title )
420428
# CMS text
421429
# note: fontweight/weight does not change anything as we use Latex text!!!
422-
plt.text(0.05, 0.98, r"\textbf{CMS}", transform=axes.transAxes, fontsize=42,
430+
logo_location = (0.05, 0.98)
431+
prelim_location = (0.05, 0.92)
432+
plt.text(logo_location[0], logo_location[1], r"\textbf{CMS}", transform=axes.transAxes, fontsize=42,
423433
verticalalignment='top',horizontalalignment='left')
434+
# preliminary
435+
plt.text(prelim_location[0], prelim_location[1], r"\emph{Preliminary}",
436+
transform=axes.transAxes, fontsize=42,
437+
verticalalignment='top',horizontalalignment='left')
424438
# channel text
425439
axes.text(0.95, 0.98, r"\emph{%s}" %channel_label, transform=axes.transAxes, fontsize=40,
426440
verticalalignment='top',horizontalalignment='right')
427441
ylim = axes.get_ylim()
428442
if ylim[0] < 0:
429443
axes.set_ylim( ymin = 0.)
444+
axes.set_ylim(ymax = ylim[1]*1.2)
430445

431446

432447
if show_ratio:
433448
plt.setp( axes.get_xticklabels(), visible = False )
434449
ax1 = plt.subplot( gs[1] )
435-
ax1.minorticks_on()
450+
if not variable in ['NJets']:
451+
ax1.minorticks_on()
436452
#ax1.grid( True, 'major', linewidth = 1 )
437453
# setting the x_limits identical to the main plot
438454
x_limits = axes.get_xlim()
439455
ax1.set_xlim(x_limits)
440456
ax1.yaxis.set_major_locator( MultipleLocator( 0.5 ) )
441-
ax1.yaxis.set_minor_locator( MultipleLocator( 0.1 ) )
457+
if not variable in ['NJets']:
458+
ax1.yaxis.set_minor_locator( MultipleLocator( 0.1 ) )
459+
460+
if variable in ['NJets', 'abs_lepton_eta', 'lepton_eta']:
461+
plt.xlabel('$%s$' % variables_latex[variable], CMS.x_axis_title )
462+
else:
463+
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
442464

443-
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
444465
plt.tick_params( **CMS.axis_label_major )
445-
plt.tick_params( **CMS.axis_label_minor )
446-
plt.ylabel( '$\\frac{\\textrm{pred.}}{\\textrm{data}}$', CMS.y_axis_title_small )
466+
if not variable in ['NJets']:
467+
plt.tick_params( **CMS.axis_label_minor )
468+
plt.ylabel( '$\\frac{\\textrm{pred.}}{\\textrm{data}}$', CMS.y_axis_title )
447469
ax1.yaxis.set_label_coords(-0.115, 0.8)
448470
#draw a horizontal line at y=1 for data
449471
plt.axhline(y = 1, color = 'black', linewidth = 2)
@@ -482,11 +504,11 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
482504
frameon = False, prop = {'size':26})
483505

484506
ax1.legend(handles = [p_stat_and_syst], loc = 'lower left',
485-
frameon = False, prop = {'size':26})
507+
frameon = False, prop = {'size':30})
486508
ax1.add_artist(l1)
487509

488510
if variable == 'MET':
489-
ax1.set_ylim( ymin = 0.0, ymax = 2 )
511+
ax1.set_ylim( ymin = 0.0, ymax = 2.5 )
490512
ax1.yaxis.set_major_locator( MultipleLocator( 0.5 ) )
491513
# ax1.yaxis.set_minor_locator( MultipleLocator( 0.1 ) )
492514
if variable == 'MT':
@@ -501,6 +523,8 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
501523
ax1.set_ylim( ymin = 0., ymax = 2 )
502524
ax1.yaxis.set_major_locator( MultipleLocator( 0.5 ) )
503525
ax1.yaxis.set_minor_locator( MultipleLocator( 0.1 ) )
526+
elif variable == 'NJets':
527+
ax1.set_ylim( ymin = 0.0, ymax = 2.5 )
504528

505529

506530
if CMS.tight_layout:
@@ -521,17 +545,22 @@ def plot_central_and_systematics( channel, systematics, exclude = [], suffix = '
521545

522546
plt.figure( figsize = ( 16, 16 ), dpi = 200, facecolor = 'white' )
523547
axes = plt.axes()
524-
axes.minorticks_on()
548+
if not variable in ['NJets']:
549+
axes.minorticks_on()
525550

526551
hist_data_central = read_xsection_measurement_results( 'central', channel )[0]['unfolded_with_systematics']
527552
hist_data_central.markersize = 2 # points. Imagine, tangible units!
528553
hist_data_central.marker = 'o'
529-
530-
531-
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
532-
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
554+
555+
if variable in ['NJets', 'abs_lepton_eta', 'lepton_eta']:
556+
plt.xlabel( '$%s$' % variables_latex[variable], CMS.x_axis_title )
557+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title )
558+
else:
559+
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
560+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
533561
plt.tick_params( **CMS.axis_label_major )
534-
plt.tick_params( **CMS.axis_label_minor )
562+
if not variable in ['NJets']:
563+
plt.tick_params( **CMS.axis_label_minor )
535564

536565
rplt.errorbar( hist_data_central, axes = axes, label = 'data', xerr = True )
537566

0 commit comments

Comments
 (0)