From 22a94ef35777612fe5f98ae26ca2404a2909b2e5 Mon Sep 17 00:00:00 2001 From: kreczko Date: Wed, 18 Feb 2015 15:35:12 +0000 Subject: [PATCH 01/10] added name_prefix functionality --- bin/plot | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/plot b/bin/plot index 33e98519..9f134f7e 100755 --- a/bin/plot +++ b/bin/plot @@ -90,7 +90,7 @@ labels = [] plot_options = {} global_options = ['files', 'histograms', 'labels', 'plot_type', 'output_folder', 'output_format', 'command', 'data_index', 'normalise', - 'show_ratio', 'show_stat_errors_on_mc', 'colours'] + 'show_ratio', 'show_stat_errors_on_mc', 'colours', 'name_prefix'] def main(): options, input_values_sets, json_input_files = parse_options() @@ -160,8 +160,10 @@ def _exit_( msg ): def prepare_inputs( input_values ): input_values = check_and_fix_inputs( input_values ) global files, histograms, global_options - sets = group_by_command( input_values['command'] ) + if input_values.has_key('name_prefix'): + for s in sets: + s.name = input_values['name_prefix'] + s.name # now we have to group the plot options plot_options = [] From f0a25bec0152716f658325f9805a8d456bed1d5a Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:09:01 +0000 Subject: [PATCH 02/10] updated rootpy --- external/rootpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/rootpy b/external/rootpy index f96b1908..b6331ccb 160000 --- a/external/rootpy +++ b/external/rootpy @@ -1 +1 @@ -Subproject commit f96b1908012d88bd7475dbf639ef8c0432bcc2f3 +Subproject commit b6331ccb0b5140fac9f8fbb11acb6db289ab7a00 From c1c2e9ffc8e76e70528de44eff5e3c966fd82015 Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:09:54 +0000 Subject: [PATCH 03/10] added file-alias option --- bin/plot | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/plot b/bin/plot index 9f134f7e..8d7ee815 100755 --- a/bin/plot +++ b/bin/plot @@ -13,6 +13,9 @@ Configuration keys compare-hists to compare different histograms in the same file files: list of ROOT files for input (>= 1) + + file-aliases: + list of aliases for files. Used for naming in case command=='compare-hists'. histograms: list of full histogram paths inside the files @@ -77,7 +80,7 @@ Example JSON config structure: from optparse import OptionParser import sys from os.path import exists -from tools.ROOT_utililities import set_root_defaults +from tools.ROOT_utils import set_root_defaults from tools.file_utilities import write_data_to_JSON, read_data_from_JSON from tools.HistSet import HistSet from copy import deepcopy @@ -85,10 +88,11 @@ from copy import deepcopy supported_commands = ['compare-files', 'compare-hists'] files = [] +file_aliases = [] histograms = [] labels = [] plot_options = {} -global_options = ['files', 'histograms', 'labels', 'plot_type', 'output_folder', +global_options = ['files', 'file-aliases', 'histograms', 'labels', 'plot_type', 'output_folder', 'output_format', 'command', 'data_index', 'normalise', 'show_ratio', 'show_stat_errors_on_mc', 'colours', 'name_prefix'] @@ -123,7 +127,7 @@ def parse_options(): return options, input_values_sets, json_input_files def check_and_fix_inputs( input_values ): - global files, histograms, labels, plot_options, supported_commands + global files, file_aliases, histograms, labels, plot_options, supported_commands if not input_values['command'] in supported_commands: _exit_( 'Command "%s" is not supported. Exiting ...' % input_values['command'] ) @@ -136,6 +140,14 @@ def check_and_fix_inputs( input_values ): # check if they exist if not exists( f ): return False, 'File "%s" does not exist' % f + if not input_values.has_key('file-aliases') or len(input_values['file-aliases']) == 0: + for f in files: + name = f.split( '/' )[-1] + name = name.replace( '.root', '' ) + file_aliases.append(name) + else: + file_aliases = input_values['file-aliases'] + if not input_values.has_key('histograms') or len(input_values['histograms']) == 0: _exit_( 'No histograms have been defined.' ) else: @@ -220,12 +232,10 @@ def group_by_file(): Creates: [{name:{f:h}, ...] where f = file and h = histogram path. The name is taken from the file name ''' - global files, histograms, labels + global files, file_aliases, histograms, labels hist_sets = [] - for f in files: + for f,name in zip(files, file_aliases): hist_set = [] - name = f.split( '/' )[-1] - name = name.replace( '.root', '' ) for histogram in histograms: hist_set.append( ( f, histogram ) ) hist_sets.append( HistSet( name, hist_inputs = hist_set, output_hist_labels = labels ) ) From c29d86a572b6ba8eceb3f4c52d8b57cf84c9fa9f Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:10:21 +0000 Subject: [PATCH 04/10] added asymmetric bins functionality to HistSet --- tools/HistSet.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/HistSet.py b/tools/HistSet.py index 238e4d58..7bd50156 100644 --- a/tools/HistSet.py +++ b/tools/HistSet.py @@ -7,6 +7,8 @@ from tools.plotting import Histogram_properties, make_shape_comparison_plot,\ make_data_mc_comparison_plot from ROOT_utils import get_histogram_from_file +import types +from tools.hist_utilities import conditional_rebin class HistSet(): ''' @@ -36,8 +38,13 @@ def plot( self, plot_options = {} ): histogram_properties = Histogram_properties(plot_options) histogram_properties.name = file_name if plot_options.has_key('rebin') and plot_options['rebin'] > 1: - for hist in self.histograms: - hist.Rebin(plot_options['rebin']) + rebin = plot_options['rebin'] + is_list = isinstance(rebin, types.ListType) + for i,hist in enumerate(self.histograms): + if is_list: + self.histograms[i] = conditional_rebin(hist, rebin) + else: + hist.rebin(rebin) colours = ['green', 'yellow', 'magenta', 'red', 'black'] if plot_options.has_key('colours'): From 7029b010a1e9211359386030fc633b26e5841eac Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:11:38 +0000 Subject: [PATCH 05/10] fixed legend bug for shape comparison and added PlotConfig skeleton --- tools/plotting.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/tools/plotting.py b/tools/plotting.py index 98180bf9..850643bb 100644 --- a/tools/plotting.py +++ b/tools/plotting.py @@ -43,24 +43,18 @@ def __init__( self, dictionary = {} ): setattr( self, name, value ) # prototype -class Control_plot: - lumi = 5050 - rebin = 1 - histogram_properties = Histogram_properties() - channel = 'combined' - b_tag_bin = '2orMoreBtags' - - def __init__( self, control_region, qcd_control_region, histogram_files, **kwargs ): - self.control_region = control_region - self.qcd_control_region = qcd_control_region - self.histogram_files = histogram_files - - self.b_tag_bin = kwargs.pop( 'b_tag_bin', self.b_tag_bin ) - self.lumi = kwargs.pop( 'lumi', self.lumi ) - self.rebin = kwargs.pop( 'rebin', self.rebin ) - self.histogram_properties = kwargs.pop( 'histogram_properties', self.histogram_properties ) - self.channel = kwargs.pop( 'channel', self.channel ) - +class PlotConfig: + ''' + Class to read a JSON file and extract information from it. + It creates HistSets and plot_options, essentiall replacing the main + functionality of the bin/plot script. + ''' + general_options = ['files', 'histograms', 'labels', 'plot_type', 'output_folder', + 'output_format', 'command', 'data_index', 'normalise', + 'show_ratio', 'show_stat_errors_on_mc', 'colours', 'name_prefix'] + + def __init__( self, config_file, **kwargs ): + self.config_file = config_file def make_data_mc_comparison_plot( histograms = [], histogram_lables = [], @@ -289,7 +283,8 @@ def make_shape_comparison_plot( shapes = [], # make copies in order not to mess with existing histograms shapes_ = deepcopy(shapes) # normalise as we are comparing shapes - for shape, colour in zip(shapes_, colours): + for shape, colour, label in zip(shapes_, colours, names): + shape.SetTitle(label) integral = shape.Integral() if integral > 0: shape.Sumw2() From 2610f0dff653d3fe84d15f3d14aec6823f93dd7f Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:11:58 +0000 Subject: [PATCH 06/10] more plot configs --- .../HT_reco_gen_truth_comparison_8TeV.json | 39 ++++++++++++++++ .../plots/MET_reco_fake_comparison_8TeV.json | 43 +++++++++++++++++ ...y_down_8TeV_asym_bin_electron_channel.json | 46 +++++++++++++++++++ ...mpare_central_to_tau_energy_down_8TeV.json | 41 +++++++++++++++++ ...tral_to_tau_energy_down_8TeV_asym_bin.json | 46 +++++++++++++++++++ ...compare_central_to_tau_energy_up_8TeV.json | 41 +++++++++++++++++ ...entral_to_tau_energy_up_8TeV_asym_bin.json | 46 +++++++++++++++++++ .../ST_reco_gen_truth_comparison_8TeV.json | 40 ++++++++++++++++ 8 files changed, 342 insertions(+) create mode 100644 config/plots/HT_reco_gen_truth_comparison_8TeV.json create mode 100644 config/plots/MET_reco_fake_comparison_8TeV.json create mode 100644 config/plots/MET_uncertainties/compare_central_to_electron_energy_down_8TeV_asym_bin_electron_channel.json create mode 100644 config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV.json create mode 100644 config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV_asym_bin.json create mode 100644 config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV.json create mode 100644 config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV_asym_bin.json create mode 100644 config/plots/ST_reco_gen_truth_comparison_8TeV.json diff --git a/config/plots/HT_reco_gen_truth_comparison_8TeV.json b/config/plots/HT_reco_gen_truth_comparison_8TeV.json new file mode 100644 index 00000000..b851d1b4 --- /dev/null +++ b/config/plots/HT_reco_gen_truth_comparison_8TeV.json @@ -0,0 +1,39 @@ +{ + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/unfolding/unfolding_TTJets_8TeV.root" + ], + "histograms": [ + "unfolding_HT_analyser_electron_channel/measured", + "unfolding_HT_analyser_electron_channel/truth" + ], + "labels": [ + "measured", + "truth" + ], + "output_folder": "plots/TTJet_comparison", + "output_format": ["pdf"], + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0, 3] + ], + "title": [ + "Comparison of TTJets MC (measured, truth) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$H_T$ [GeV]" + ], + "x_limits": [ + [0, 1000] + ], + "y_axis_title": [ + "normalised to unit area /(10 GeV)" + ], + "y_limits": [ + [0, 0.05] + ], + "rebin" : [ + 10 + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_reco_fake_comparison_8TeV.json b/config/plots/MET_reco_fake_comparison_8TeV.json new file mode 100644 index 00000000..c5884865 --- /dev/null +++ b/config/plots/MET_reco_fake_comparison_8TeV.json @@ -0,0 +1,43 @@ +{ + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/unfolding/unfolding_TTJets_8TeV.root" + ], + "file-aliases": [ + "TTJets" + ], + "histograms": [ + "unfolding_MET_analyser_electron_channel_patType1CorrectedPFMet/measured", + "unfolding_MET_analyser_electron_channel_patType1CorrectedPFMet/fake" + ], + "labels": [ + "measured", + "fake" + ], + "output_folder": "plots/TTJet_comparison", + "output_format": ["pdf"], + "name_prefix": "comparison_measured_fake", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0, 2.5] + ], + "title": [ + "Comparison of TTJets MC (measured, truth) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area" + ], + "y_limits": [ + [0, 0.4] + ], + "rebin" : [ + [0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300] + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_uncertainties/compare_central_to_electron_energy_down_8TeV_asym_bin_electron_channel.json b/config/plots/MET_uncertainties/compare_central_to_electron_energy_down_8TeV_asym_bin_electron_channel.json new file mode 100644 index 00000000..f9d54f31 --- /dev/null +++ b/config/plots/MET_uncertainties/compare_central_to_electron_energy_down_8TeV_asym_bin_electron_channel.json @@ -0,0 +1,46 @@ +{ + "class": "PlotConfig", + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root", + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root" + ], + "file-aliases": [ + "TTJet", + "data" + ], + "histograms": [ + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags", + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMetElectronEnDown/MET_2orMoreBtags" + ], + "labels": [ + "central", + "electron energy down" + ], + "output_folder": "plots/MET_uncertainties", + "output_format": ["pdf"], + "name_prefix": "compare_central_MET_to_electron_energy_down_asym_bins_electron_channel_", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0.95, 1.05] + ], + "title": [ + "Comparison of $E_T^{\\text{miss}}$ (central, electron energy down) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area /(5 GeV)" + ], + "y_limits": [ + [0, 0.4] + ], + "rebin" : [ + [0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300] + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV.json b/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV.json new file mode 100644 index 00000000..1ef6818a --- /dev/null +++ b/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV.json @@ -0,0 +1,41 @@ +{ + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root", + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root" + ], + "histograms": [ + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags", + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMetTauEnDown/MET_2orMoreBtags" + ], + "labels": [ + "central", + "$\\tau$ energy down" + ], + "output_folder": "plots/MET_uncertainties", + "output_format": ["pdf"], + "name_prefix": "compare_central_MET_to_tau_energy_down_", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0.5, 1.5] + ], + "title": [ + "Comparison of $E_T^{\\text{miss}}$ (central, $\\tau$ energy up) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area /(5 GeV)" + ], + "y_limits": [ + [0, 0.08] + ], + "rebin" : [ + 1 + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV_asym_bin.json b/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV_asym_bin.json new file mode 100644 index 00000000..9f160b9a --- /dev/null +++ b/config/plots/MET_uncertainties/compare_central_to_tau_energy_down_8TeV_asym_bin.json @@ -0,0 +1,46 @@ +{ + "class": "PlotConfig", + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root", + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root" + ], + "file-aliases": [ + "TTJet", + "data" + ], + "histograms": [ + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags", + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMetTauEnDown/MET_2orMoreBtags" + ], + "labels": [ + "central", + "$\\tau$ energy down" + ], + "output_folder": "plots/MET_uncertainties", + "output_format": ["pdf"], + "name_prefix": "compare_central_MET_to_tau_energy_down_asym_bins_electron_channel_", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0.9, 1.15] + ], + "title": [ + "Comparison of $E_T^{\\text{miss}}$ (central, $\\tau$ energy down) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area /(5 GeV)" + ], + "y_limits": [ + [0, 0.4] + ], + "rebin" : [ + [0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300] + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV.json b/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV.json new file mode 100644 index 00000000..d48c4885 --- /dev/null +++ b/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV.json @@ -0,0 +1,41 @@ +{ + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root", + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root" + ], + "histograms": [ + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags", + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMetTauEnUp/MET_2orMoreBtags" + ], + "labels": [ + "central", + "$\\tau$ energy up" + ], + "output_folder": "plots/MET_uncertainties", + "output_format": ["pdf"], + "name_prefix": "compare_central_MET_to_tau_energy_up_", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0.5, 1.5] + ], + "title": [ + "Comparison of $E_T^{\\text{miss}}$ (central, $\\tau$ energy up) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area /(5 GeV)" + ], + "y_limits": [ + [0, 0.08] + ], + "rebin" : [ + 1 + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV_asym_bin.json b/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV_asym_bin.json new file mode 100644 index 00000000..867e8133 --- /dev/null +++ b/config/plots/MET_uncertainties/compare_central_to_tau_energy_up_8TeV_asym_bin.json @@ -0,0 +1,46 @@ +{ + "class": "PlotConfig", + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root", + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root" + ], + "file-aliases": [ + "TTJet", + "data" + ], + "histograms": [ + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags", + "TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMetTauEnUp/MET_2orMoreBtags" + ], + "labels": [ + "central", + "$\\tau$ energy up" + ], + "output_folder": "plots/MET_uncertainties", + "output_format": ["pdf"], + "name_prefix": "compare_central_MET_to_tau_energy_up_asym_bins_electron_channel_", + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0.9, 1.15] + ], + "title": [ + "Comparison of $E_T^{\\text{miss}}$ (central, $\\tau$ energy up) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$E_T^{\\text{miss}}$ [GeV]" + ], + "x_limits": [ + [0, 300] + ], + "y_axis_title": [ + "normalised to unit area /(5 GeV)" + ], + "y_limits": [ + [0, 0.4] + ], + "rebin" : [ + [0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300] + ], + "colours": ["green", "yellow"] +} diff --git a/config/plots/ST_reco_gen_truth_comparison_8TeV.json b/config/plots/ST_reco_gen_truth_comparison_8TeV.json new file mode 100644 index 00000000..bdea9e1e --- /dev/null +++ b/config/plots/ST_reco_gen_truth_comparison_8TeV.json @@ -0,0 +1,40 @@ +{ + "command": "compare-hists", + "files": [ + "/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/unfolding/unfolding_TTJets_8TeV.root" + ], + "histograms": [ + "unfolding_ST_analyser_electron_channel_patType1CorrectedPFMet/measured", + "unfolding_ST_analyser_electron_channel_patType1CorrectedPFMet/truth" + ], + "labels": [ + "measured", + "truth" + ], + "output_folder": "plots/TTJet_comparison", + "output_format": ["pdf"], + "name_prefix": ["ST"], + "plot_type": "shape_comparison", + "ratio_y_limits": [ + [0, 3] + ], + "title": [ + "Comparison of TTJets MC (measured, truth) $\\sqrt{s}$ = 8 TeV" + ], + "x_axis_title": [ + "$S_T$ [GeV]" + ], + "x_limits": [ + [0, 1000] + ], + "y_axis_title": [ + "normalised to unit area /(10 GeV)" + ], + "y_limits": [ + [0, 0.05] + ], + "rebin" : [ + 10 + ], + "colours": ["green", "yellow"] +} From f5767fd118fc597e643c3ef8dbcad19c83d3a9f3 Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:12:48 +0000 Subject: [PATCH 07/10] added timing information to running the analysis --- bin/run_x_section_measurement | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/run_x_section_measurement b/bin/run_x_section_measurement index a4ed75e6..15b1d49f 100755 --- a/bin/run_x_section_measurement +++ b/bin/run_x_section_measurement @@ -1,14 +1,14 @@ #!/bin/bash echo "Running differential cross-section analysis for 7 and 8 TeV data" -bash x_01_all_vars +time bash x_01_all_vars wait -bash x_02_all_vars +time bash x_02_all_vars wait -bash x_03_all_vars +time bash x_03_all_vars wait -bash x_04_all_vars +time bash x_04_all_vars wait -bash x_05_all_vars +time bash x_05_all_vars wait echo "Everything is done. Time to run make_analysis_note and go home!" From 56a9dcf5b9c2a8178374e0916c6618c8a73662e7 Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:13:23 +0000 Subject: [PATCH 08/10] removed additional plots from default 04 plotting --- bin/x_04_all_vars | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/x_04_all_vars b/bin/x_04_all_vars index b9ae87b5..9aa44446 100755 --- a/bin/x_04_all_vars +++ b/bin/x_04_all_vars @@ -11,7 +11,7 @@ echo "Using the fit variable(s): $fit_var" i=0 for var in MET HT ST MT WPT; do echo "Plotting diff. x-section for distribution: $var" - nohup time python src/cross_section_measurement/04_make_plots_matplotlib.py -v $var -c 7 -p data/$nice_fit_var -a &> logs/04_${var}_plot_7TeV_${nice_fit_var}.log & + nohup time python src/cross_section_measurement/04_make_plots_matplotlib.py -v $var -c 7 -p data/$nice_fit_var &> logs/04_${var}_plot_7TeV_${nice_fit_var}.log & let i+=1 if (( $i % N_JOBS == 0 )) then @@ -19,7 +19,7 @@ for var in MET HT ST MT WPT; do wait; fi - nohup time python src/cross_section_measurement/04_make_plots_matplotlib.py -v $var -c 8 -p data/$nice_fit_var -a &> logs/04_${var}_plot_8TeV_${nice_fit_var}.log & + nohup time python src/cross_section_measurement/04_make_plots_matplotlib.py -v $var -c 8 -p data/$nice_fit_var &> logs/04_${var}_plot_8TeV_${nice_fit_var}.log & let i+=1 if (( $i % N_JOBS == 0 )) then From ff500880a48cfa27dc0e2b58e0eaf6b960d716a2 Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:13:59 +0000 Subject: [PATCH 09/10] scale unfolding tuple to lumi by default --- tools/Unfolding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Unfolding.py b/tools/Unfolding.py index b5a695e6..d6e922cb 100644 --- a/tools/Unfolding.py +++ b/tools/Unfolding.py @@ -279,7 +279,7 @@ def get_unfold_histogram_tuple( ttbar_xsection = 245.8, luminosity = 19712, load_fakes = False, - scale_to_lumi = False, + scale_to_lumi = True, ): folder = None h_truth = None From cfc90ba7dce6ca596067388067807f237cf09947 Mon Sep 17 00:00:00 2001 From: kreczko Date: Fri, 20 Feb 2015 16:15:36 +0000 Subject: [PATCH 10/10] fixed bin-centre example to plot a nice line --- examples/Bin_Centers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/Bin_Centers.py b/examples/Bin_Centers.py index ecded319..482e7db5 100644 --- a/examples/Bin_Centers.py +++ b/examples/Bin_Centers.py @@ -11,12 +11,12 @@ import matplotlib.pyplot as plt from array import array from rootpy import asrootpy - +import numpy as np if __name__ == '__main__': bins = array('d', [0, 25, 45, 70, 100, 1000]) nbins = len(bins) - 1 - inputFile = File('data/unfolding_merged_sub1.root', 'read') + inputFile = File('/storage/TopQuarkGroup/unfolding/unfolding_merged_sub1.root', 'read') h_truth_finebinned = inputFile.unfoldingAnalyserElectronChannel.truth h_truth = asrootpy(inputFile.unfoldingAnalyserElectronChannel.truth.Rebin(nbins, 'truth_new', bins)) print 'old:', get_bin_centers(bins) @@ -39,16 +39,21 @@ h_truth_finebinned.SetFillStyle(0) h_truth_finebinned.Smooth(500) + x,y = list(h_truth_finebinned.x()), list(h_truth_finebinned.y()) + bin_edges = np.array(list(h_truth_finebinned.xedges())) + bincenters = 0.5*(bin_edges[1:]+bin_edges[:-1]) g_truth = Graph(h_truth) # g_truth_new = Graph(len(h_truth), h_truth_new) g_truth_new.SetLineColor('red') g_truth_new.SetMarkerColor('red') h_truth_finebinned.axis().SetRange(0, 1000) + h_truth_finebinned.linecolor = 'orange' plt.figure(figsize=(16, 10), dpi=100) axes = plt.axes() rplt.errorbar(g_truth_new, label=r'corrected', emptybins=False) rplt.errorbar(g_truth, label=r'bin centre', emptybins=False) - rplt.hist(h_truth_finebinned, label=r'MC', stacked=False) + # rplt.hist(h_truth_finebinned, label=r'MC', stacked=False) + plt.plot(bincenters, y, '-') axes.set_xlim([0,300]) plt.xlabel('$E_{\mathrm{T}}^{miss}$') plt.ylabel('Events')