Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions bin/plot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,20 +80,21 @@ 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

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']
'show_ratio', 'show_stat_errors_on_mc', 'colours', 'name_prefix']

def main():
options, input_values_sets, json_input_files = parse_options()
Expand Down Expand Up @@ -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'] )
Expand All @@ -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:
Expand All @@ -160,8 +172,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 = []
Expand Down Expand Up @@ -218,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 ) )
Expand Down
10 changes: 5 additions & 5 deletions bin/run_x_section_measurement
Original file line number Diff line number Diff line change
@@ -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!"
4 changes: 2 additions & 2 deletions bin/x_04_all_vars
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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
echo "Waiting on the above to finish."
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
Expand Down
39 changes: 39 additions & 0 deletions config/plots/HT_reco_gen_truth_comparison_8TeV.json
Original file line number Diff line number Diff line change
@@ -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"]
}
43 changes: 43 additions & 0 deletions config/plots/MET_reco_fake_comparison_8TeV.json
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"]
}
Original file line number Diff line number Diff line change
@@ -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"]
}
Loading