@@ -250,7 +250,7 @@ def make_template_plots( histograms, category, channel ):
250250 plt .text (0.95 , 0.95 , r"\textbf{CMS}" , transform = axes .transAxes , fontsize = 42 ,
251251 verticalalignment = 'top' ,horizontalalignment = 'right' )
252252 # channel text
253- axes .text (0.95 , 0.90 , r"\emph{%s}" % channel_label , transform = axes .transAxes , fontsize = 40 ,
253+ axes .text (0.95 , 0.95 , r"\emph{%s}" % channel_label , transform = axes .transAxes , fontsize = 40 ,
254254 verticalalignment = 'top' ,horizontalalignment = 'right' )
255255
256256 plt .tight_layout ()
@@ -406,20 +406,28 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
406406 data_handle = handles [data_label_index ]
407407 labels .remove ( 'data' )
408408 handles .remove ( data_handle )
409- labels .insert ( 0 , 'unfolded data' )
409+ labels .insert ( 0 , 'data' )
410410 handles .insert ( 0 , data_handle )
411411
412412 new_handles , new_labels = [], []
413- for handle , label in zip ( handles , labels ):
414- if not label == 'do_not_show' :
415- new_handles .append ( handle )
416- new_labels .append ( label )
413+ zipped = dict ( zip ( labels , handles ) )
414+ labelOrder = ['data' , 'Powheg Pythia8' , 'Powheg Herwig++' , 'aMC@NLO' , 'Madgraph' , '$Q^{2}$ up' , '$Q^{2}$ down' , 'Top mass up' , 'Top mass down' ]
415+ for label in labelOrder :
416+ if label in labels :
417+ new_handles .append (zipped [label ])
418+ new_labels .append (label )
417419
418- legend_location = (0.97 , 0.88 )
420+ print (new_labels )
421+ print (new_handles )
422+ legend_location = (0.97 , 0.82 )
419423 if variable == 'MT' :
420- legend_location = (0.05 , 0.88 )
424+ legend_location = (0.05 , 0.82 )
421425 elif variable == 'ST' :
422- legend_location = (0.90 , 0.88 )
426+ legend_location = (0.97 , 0.82 )
427+ elif variable == 'WPT' :
428+ legend_location = (1.0 , 0.84 )
429+ elif variable == 'abs_lepton_eta' :
430+ legend_location = (1.0 , 0.94 )
423431 plt .legend ( new_handles , new_labels , numpoints = 1 , prop = CMS .legend_properties , frameon = False , bbox_to_anchor = legend_location ,
424432 bbox_transform = plt .gcf ().transFigure )
425433 label , channel_label = get_cms_labels ( channel )
@@ -429,19 +437,33 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
429437 # note: fontweight/weight does not change anything as we use Latex text!!!
430438 logo_location = (0.05 , 0.98 )
431439 prelim_location = (0.05 , 0.92 )
440+ channel_location = ( 0.05 , 0.86 )
441+ if variable == 'WPT' :
442+ logo_location = (0.03 , 0.98 )
443+ prelim_location = (0.03 , 0.92 )
444+ channel_location = (0.03 , 0.86 )
445+ elif variable == 'abs_lepton_eta' :
446+ logo_location = (0.03 , 0.98 )
447+ prelim_location = (0.03 , 0.92 )
448+ channel_location = (0.03 , 0.86 )
432449 plt .text (logo_location [0 ], logo_location [1 ], r"\textbf{CMS}" , transform = axes .transAxes , fontsize = 42 ,
433450 verticalalignment = 'top' ,horizontalalignment = 'left' )
434451 # preliminary
435452 plt .text (prelim_location [0 ], prelim_location [1 ], r"\emph{Preliminary}" ,
436453 transform = axes .transAxes , fontsize = 42 ,
437454 verticalalignment = 'top' ,horizontalalignment = 'left' )
438455 # channel text
439- axes .text (0.95 , 0.98 , r"\emph{%s}" % channel_label , transform = axes .transAxes , fontsize = 40 ,
440- verticalalignment = 'top' ,horizontalalignment = 'right ' )
456+ plt .text (channel_location [ 0 ], channel_location [ 1 ] , r"\emph{%s}" % channel_label , transform = axes .transAxes , fontsize = 40 ,
457+ verticalalignment = 'top' ,horizontalalignment = 'left ' )
441458 ylim = axes .get_ylim ()
442459 if ylim [0 ] < 0 :
443460 axes .set_ylim ( ymin = 0. )
444- axes .set_ylim (ymax = ylim [1 ]* 1.2 )
461+ if variable == 'WPT' :
462+ axes .set_ylim (ymax = ylim [1 ]* 1.3 )
463+ elif variable == 'abs_lepton_eta' :
464+ axes .set_ylim (ymax = ylim [1 ]* 1.3 )
465+ else :
466+ axes .set_ylim (ymax = ylim [1 ]* 1.2 )
445467
446468
447469 if show_ratio :
@@ -493,39 +515,50 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
493515
494516 if category == 'central' :
495517 rplt .fill_between ( syst_lower , syst_upper , ax1 ,
496- color = 'yellow' , alpha = 0.5 )
518+ color = 'yellow' )
497519
498520 rplt .fill_between ( stat_upper , stat_lower , ax1 , color = '0.75' ,
499- alpha = 0.5 )
521+ )
500522 # legend for ratio plot
501- p_stat = mpatches .Patch (facecolor = '0.75' , label = 'Stat.' ,alpha = 0.5 , edgecolor = 'black' )
502- p_stat_and_syst = mpatches .Patch (facecolor = 'yellow' , label = r'Stat. $\oplus$ Syst.' , alpha = 0.5 , edgecolor = 'black' )
503- l1 = ax1 .legend (handles = [p_stat ], loc = 'upper left' ,
504- frameon = False , prop = {'size' :26 })
523+ p_stat = mpatches .Patch (facecolor = '0.75' , label = 'Stat.' , edgecolor = 'black' )
524+ p_stat_and_syst = mpatches .Patch (facecolor = 'yellow' , label = r'Stat. $\oplus$ Syst.' , edgecolor = 'black' )
525+ l1 = ax1 .legend (handles = [p_stat , p_stat_and_syst ], loc = 'upper left' ,
526+ frameon = False , prop = {'size' :26 }, ncol = 2 )
505527
506- ax1 .legend (handles = [p_stat_and_syst ], loc = 'lower left' ,
507- frameon = False , prop = {'size' :30 })
528+ # ax1.legend(handles = [p_stat_and_syst], loc = 'lower left',
529+ # frameon = False, prop = {'size':30})
508530 ax1 .add_artist (l1 )
509531
510532 if variable == 'MET' :
511- ax1 .set_ylim ( ymin = 0.0 , ymax = 2.5 )
533+ ax1 .set_ylim ( ymin = 0.5 , ymax = 2.4 )
512534 ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
513535# ax1.yaxis.set_minor_locator( MultipleLocator( 0.1 ) )
514536 if variable == 'MT' :
515537 ax1 .set_ylim ( ymin = 0.8 , ymax = 1.2 )
516538 ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.2 ) )
517539 ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
518- elif variable == 'HT' or variable == 'ST' :
519- ax1 .set_ylim ( ymin = 0. , ymax = 2 )
540+ elif variable == 'HT' :
541+ ax1 .set_ylim ( ymin = 0.5 , ymax = 1.8 )
542+ ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
543+ ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
544+ elif variable == 'ST' :
545+ ax1 .set_ylim ( ymin = 0.5 , ymax = 1.8 )
520546 ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
521547 ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
522548 elif variable == 'WPT' :
523- ax1 .set_ylim ( ymin = 0. , ymax = 2 )
549+ ax1 .set_ylim ( ymin = 0.5 , ymax = 1.85 )
524550 ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
525551 ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
526552 elif variable == 'NJets' :
527- ax1 .set_ylim ( ymin = 0.0 , ymax = 2.5 )
528-
553+ ax1 .set_ylim ( ymin = 0.5 , ymax = 2.5 )
554+ elif variable == 'abs_lepton_eta' :
555+ ax1 .set_ylim ( ymin = 0.5 , ymax = 1.6 )
556+ ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
557+ ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
558+ elif variable == 'lepton_pt' :
559+ ax1 .set_ylim ( ymin = 0.5 , ymax = 1.8 )
560+ ax1 .yaxis .set_major_locator ( MultipleLocator ( 0.5 ) )
561+ ax1 .yaxis .set_minor_locator ( MultipleLocator ( 0.1 ) )
529562
530563 if CMS .tight_layout :
531564 plt .tight_layout ()
@@ -690,6 +723,7 @@ def get_unit_string(fit_variable):
690723 # all_measurements.extend( new_uncertainties )
691724 all_measurements .extend ( rate_changing_systematics )
692725 for channel in ['electron' , 'muon' , 'combined' ]:
726+ # for channel in ['combined']:
693727 for category in all_measurements :
694728 if not category == 'central' and not options .additional_plots :
695729 continue
0 commit comments