diff --git a/bin/plots2tdr b/bin/plots2tdr new file mode 100755 index 00000000..8515758a --- /dev/null +++ b/bin/plots2tdr @@ -0,0 +1,84 @@ +#!/usr/bin/env python +''' +plot2tdr --plots --tdr : , + # results 8 TeV + '7TeV/MET/central/normalised_xsection_combined_*.pdf': '7TeV/MET/', + '7TeV/HT/central/normalised_xsection_combined_*.pdf': '7TeV/HT/', + '7TeV/ST/central/normalised_xsection_combined_*.pdf': '7TeV/ST/', + '7TeV/WPT/central/normalised_xsection_combined_*.pdf': '7TeV/WPT/', + # results 8 TeV + '8TeV/MET/central/normalised_xsection_combined_*.pdf': '8TeV/MET/', + '8TeV/HT/central/normalised_xsection_combined_*.pdf': '8TeV/HT/', + '8TeV/ST/central/normalised_xsection_combined_*.pdf': '8TeV/ST/', + '8TeV/WPT/central/normalised_xsection_combined_*.pdf': '8TeV/WPT/', + # control plots 8 TeV + 'control_plots/after_fit/8TeV/*_HT_2orMoreBtags_with_ratio.pdf': 'control/', + 'control_plots/after_fit/8TeV/*_patType1CorrectedPFMet_2orMoreBtags_with_ratio.pdf': 'control/', + # fit variables 8 TeV + 'control_plots/after_fit/8TeV/*_angle_bl_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/', + 'control_plots/after_fit/8TeV/*_AbsEta_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/', + 'control_plots/after_fit/8TeV/*_M3_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/', + } + +plot_map_AN = {} + +noop = False + +def main(): + global noop + plot_src, tdr_dst, t = parse_options() + if t == 'paper': + plot_map_common.update(plot_map_paper) + if t == 'AN': + plot_map_common.update(plot_map_AN) + + for src, dst in plot_map_common.iteritems(): + full_src = plot_src + src + full_dst = tdr_dst + dst + src_files = glob(full_src) + for f in src_files: + dst_file = full_dst + f.split('/')[-1] + print 'Copying %s -> %s' % (f, dst_file) + if not noop: + shutil.copy2(f, dst_file) + +def parse_options(): + global noop + parser = OptionParser( __doc__ ) + parser.add_option( "--plots", dest = "plot_src", default = "plots/", + help = "path to DPS plot location" ) + parser.add_option( "--tdr", dest = "tdr_dst", default = "tdr/", + help = "path to tdr plot location" ) + parser.add_option( "--type", dest = "type", default = "paper", + help = "paper|AN" ) + parser.add_option( "--noop", dest = "noop", action = "store_true", + help = "Don't copy anything" ) + ( options, _ ) = parser.parse_args() + plot_src, tdr_dst = options.plot_src, options.tdr_dst + t = options.type + if not plot_src.endswith('/'): + plot_src += '/' + if not tdr_dst.endswith('/'): + tdr_dst += '/' + + noop = options.noop + + return plot_src, tdr_dst, t + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/config/__init__.py b/config/__init__.py index c313c13f..f893f7d6 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -8,7 +8,7 @@ class XSectionConfig(): current_analysis_path = '/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_7th_draft/' known_centre_of_mass_energies = [7, 8] # has to be separate as many variables depend on it - luminosities = {7:5050, 8:19584} + luminosities = {7:5050, 8:19712} parameters = ['SingleTop_category_templates', 'SingleTop_file', 'VJets_category_templates', 'analysis_types', 'categories_and_prefixes', 'central_general_template', @@ -281,7 +281,7 @@ def __fill_defaults_7TeV__( self ): middle = self.middle path_to_files = self.path_to_files - self.new_luminosity = self.luminosity # pb^-1 + self.new_luminosity = 5050 # pb^-1 self.ttbar_xsection = 177.31 # pb from https://twiki.cern.ch/twiki/bin/view/LHCPhysics/TtbarNNLO self.data_file_electron = path_to_files + 'central/ElectronHad' + middle + '.root' diff --git a/config/latex_labels.py b/config/latex_labels.py index 0728f0f7..bcea38c6 100644 --- a/config/latex_labels.py +++ b/config/latex_labels.py @@ -96,7 +96,7 @@ 'absolute_eta' : r'lepton $|\eta|$', 'M3' : r'$M3$', 'M_bl' : r'$M(b,l)$', - 'angle_bl' : r'angle$(b,l)$', + 'angle_bl' : r'$\alpha$', } typical_systematics_latex = {"typical_systematics_electron": "Electron trigger efficiency \& electron selection", diff --git a/src/cross_section_measurement/04_make_plots_matplotlib.py b/src/cross_section_measurement/04_make_plots_matplotlib.py index b4532af4..9dbb34a2 100644 --- a/src/cross_section_measurement/04_make_plots_matplotlib.py +++ b/src/cross_section_measurement/04_make_plots_matplotlib.py @@ -326,7 +326,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True axes.minorticks_on() - plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title ) + plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title ) plt.tick_params( **CMS.axis_label_major ) plt.tick_params( **CMS.axis_label_minor ) @@ -342,7 +342,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True for key, hist in sorted( histograms.iteritems() ): if not 'unfolded' in key and not 'measured' in key: - hist.linewidth = 2 + hist.linewidth = 4 # setting colours if 'POWHEG_PYTHIA' in key or 'matchingdown' in key: hist.linestyle = 'longdashdot' @@ -415,7 +415,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True plt.ylabel( '$\\frac{\\textrm{pred.}}{\\textrm{data}}$', CMS.y_axis_title ) ax1.yaxis.set_label_coords(-0.115, 0.8) #draw a horizontal line at y=1 for data - plt.axhline(y = 1, color = 'black', linewidth = 1) + plt.axhline(y = 1, color = 'black', linewidth = 2) for key, hist in sorted( histograms.iteritems() ): if not 'unfolded' in key and not 'measured' in key: @@ -437,14 +437,15 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True syst_errors = graph_to_value_errors_tuplelist(hist_data_with_systematics) syst_lower.SetBinContent( bin_i, 1 - syst_errors[bin_i-1][1]/syst_errors[bin_i-1][0] ) syst_upper.SetBinContent( bin_i, 1 + syst_errors[bin_i-1][2]/syst_errors[bin_i-1][0] ) - if category == 'central': - rplt.fill_between( syst_lower, syst_upper, ax1, facecolor = 'yellow', alpha = 0.5 ) + rplt.fill_between( syst_lower, syst_upper, ax1, + color = 'yellow', alpha = 0.5 ) - rplt.fill_between( stat_upper, stat_lower, ax1, facecolor = '0.75', alpha = 0.5 ) + rplt.fill_between( stat_upper, stat_lower, ax1, color = '0.75', + alpha = 0.5 ) # legend for ratio plot - p_stat = mpatches.Patch(color='0.75', label='Stat.', alpha = 0.5 ) - p_stat_and_syst = mpatches.Patch(color='yellow', label=r'Stat. $\oplus$ Syst.', alpha = 0.5 ) + p_stat = mpatches.Patch(facecolor='0.75', label='Stat.',alpha = 0.5, edgecolor='black' ) + p_stat_and_syst = mpatches.Patch(facecolor='yellow', label=r'Stat. $\oplus$ Syst.', alpha = 0.5, edgecolor='black' ) l1 = ax1.legend(handles = [p_stat], loc = 'upper left', frameon = False, prop = {'size':26}) @@ -498,7 +499,7 @@ def plot_central_and_systematics( channel, systematics, exclude = [], suffix = ' plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title ) - plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title ) + plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title ) plt.tick_params( **CMS.axis_label_major ) plt.tick_params( **CMS.axis_label_minor ) diff --git a/src/cross_section_measurement/make_control_plots.py b/src/cross_section_measurement/make_control_plots.py index 5402b23e..e824615e 100644 --- a/src/cross_section_measurement/make_control_plots.py +++ b/src/cross_section_measurement/make_control_plots.py @@ -1,6 +1,6 @@ from optparse import OptionParser from config.latex_labels import b_tag_bins_latex, samples_latex, channel_latex, \ - variables_latex + variables_latex, fit_variables_latex from config.variable_binning import variable_bins_ROOT from config import XSectionConfig from tools.file_utilities import read_data_from_JSON, make_folder_if_not_exists @@ -637,7 +637,7 @@ def make_plot( channel, x_axis_title, y_axis_title, tmp = 'TTbar_plus_X_analysis/EPlusJets/Ref selection/Binned_MT_Analysis/MT_with_patType1CorrectedPFMet_bin_%s/angle_bl_' + b_tag_bin regions = [tmp % bin_i for bin_i in variable_bins_ROOT['MT']] make_plot( 'electron', - x_axis_title = 'angle(bl)', + x_axis_title = fit_variables_latex['angle_bl'], y_axis_title = 'Events/(0.2)', signal_region = regions, qcd_data_region_btag = '1btag', @@ -651,7 +651,7 @@ def make_plot( channel, x_axis_title, y_axis_title, tmp = 'TTbar_plus_X_analysis/MuPlusJets/Ref selection/Binned_MT_Analysis/MT_with_patType1CorrectedPFMet_bin_%s/angle_bl_' + b_tag_bin regions = [tmp % bin_i for bin_i in variable_bins_ROOT['MT']] make_plot( 'muon', - x_axis_title = 'angle(bl)', + x_axis_title = fit_variables_latex['angle_bl'], y_axis_title = 'Events/(0.2)', signal_region = regions, qcd_data_region_btag = '1btag', diff --git a/test/config_XSectionConfig.py b/test/config_XSectionConfig.py index 3fa23dc5..fb023c89 100644 --- a/test/config_XSectionConfig.py +++ b/test/config_XSectionConfig.py @@ -38,7 +38,7 @@ def test_invalid_centre_of_mass_energy( self ): def test_luminosity( self ): self.assertEqual( self.config_7TeV.luminosity, 5050 ) - self.assertEqual( self.config_8TeV.luminosity, 19584 ) + self.assertEqual( self.config_8TeV.luminosity, 19712 ) def test_parameters( self ): for param in XSectionConfig.parameters: