Skip to content

Commit 71dddff

Browse files
committed
After paper submission, before holiday.
1 parent b0ec57f commit 71dddff

File tree

12 files changed

+1019
-231
lines changed

12 files changed

+1019
-231
lines changed

bin/plots2tdr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ plot_map_common = {}
1717
plot_map_paper = {
1818
# # <src relative to DPS plots folder> : <dst relative to TDR plots folder>,
1919
# # results 8 TeV
20-
'background_subtraction/7TeV/MET/central/normalised_xsection_combined_*.pdf': '7TeV/MET/',
21-
'background_subtraction/7TeV/HT/central/normalised_xsection_combined_*.pdf': '7TeV/HT/',
22-
'background_subtraction/7TeV/ST/central/normalised_xsection_combined_*.pdf': '7TeV/ST/',
23-
'background_subtraction/7TeV/WPT/central/normalised_xsection_combined_*.pdf': '7TeV/WPT/',
24-
# # results 8 TeV
25-
'background_subtraction/8TeV/MET/central/normalised_xsection_combined_*.pdf': '8TeV/MET/',
26-
'background_subtraction/8TeV/HT/central/normalised_xsection_combined_*.pdf': '8TeV/HT/',
27-
'background_subtraction/8TeV/ST/central/normalised_xsection_combined_*.pdf': '8TeV/ST/',
28-
'background_subtraction/8TeV/WPT/central/normalised_xsection_combined_*.pdf': '8TeV/WPT/',
20+
# 'background_subtraction/7TeV/MET/central/normalised_xsection_combined_*.pdf': '7TeV/MET/',
21+
# 'background_subtraction/7TeV/HT/central/normalised_xsection_combined_*.pdf': '7TeV/HT/',
22+
# 'background_subtraction/7TeV/ST/central/normalised_xsection_combined_*.pdf': '7TeV/ST/',
23+
# 'background_subtraction/7TeV/WPT/central/normalised_xsection_combined_*.pdf': '7TeV/WPT/',
24+
# # # results 8 TeV
25+
# 'background_subtraction/8TeV/MET/central/normalised_xsection_combined_*.pdf': '8TeV/MET/',
26+
# 'background_subtraction/8TeV/HT/central/normalised_xsection_combined_*.pdf': '8TeV/HT/',
27+
# 'background_subtraction/8TeV/ST/central/normalised_xsection_combined_*.pdf': '8TeV/ST/',
28+
# 'background_subtraction/8TeV/WPT/central/normalised_xsection_combined_*.pdf': '8TeV/WPT/',
2929
# # control plots 8 TeV
30-
'control_plots/before_fit/8TeV/*_patType1CorrectedPFMet_2orMoreBtags_with_ratio.pdf': 'control/',
31-
'control_plots/before_fit/8TeV/*_*T_2orMoreBtags_with_ratio.pdf': 'control/',
30+
# 'control_plots/before_fit/8TeV/*_patType1CorrectedPFMet_2orMoreBtags_with_ratio.pdf': 'control/',
31+
# 'control_plots/before_fit/8TeV/*_*T_2orMoreBtags_with_ratio.pdf': 'control/',
3232

33-
# '../tables/background_subtraction/*/*/*_normalised_xsection_*combined.tex': '../tables/'
33+
'../tables/background_subtraction/*/*/*_normalised_xsection_*combined.tex': '../tables/'
3434
}
3535

3636
plot_map_AN = {}

bin/x_02b_all_vars

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ i=0
77

88
for var in MET HT ST WPT; do
99
echo "Unfolding distribution: $var"
10-
nohup time python src/cross_section_measurement/02_unfold_and_measure.py -v $var -c 7 -p data/normalisation/background_subtraction/ &> logs/02b_${var}_unfold_7TeV.log &
10+
nohup time python src/cross_section_measurement/02_unfold_and_measure.py -v $var -c 7 -p data/normalisation/background_subtraction/ --test &> logs/02b_${var}_unfold_7TeV.log &
1111
let i+=1
1212
if (( $i % N_JOBS == 0 ))
1313
then
@@ -16,13 +16,13 @@ for var in MET HT ST WPT; do
1616
fi
1717

1818

19-
# nohup time python src/cross_section_measurement/02_unfold_and_measure.py -v $var -c 8 -p data/normalisation/background_subtraction/ &> logs/02b_${var}_unfold_8TeV.log &
20-
# let i+=1
21-
# if (( $i % N_JOBS == 0 ))
22-
# then
23-
# echo "Waiting on the above to finish."
24-
# wait;
25-
# fi
19+
nohup time python src/cross_section_measurement/02_unfold_and_measure.py -v $var -c 8 -p data/normalisation/background_subtraction/ --test &> logs/02b_${var}_unfold_8TeV.log &
20+
let i+=1
21+
if (( $i % N_JOBS == 0 ))
22+
then
23+
echo "Waiting on the above to finish."
24+
wait;
25+
fi
2626
done
2727

2828
wait;

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':33}
4747

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

config/latex_labels.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828

2929
measurements_latex = {'unfolded': 'unfolded',
3030
'measured': 'measured',
31-
'MADGRAPH': 'Madgraph + Pythia',
32-
'MADGRAPH_ptreweight': 'Madgraph + $p_\mathrm{T}$ reweighting',
33-
'MCATNLO': 'MC@NLO + Herwig',
34-
'powheg_v1_pythia': 'Powheg v1 + Pythia',
35-
'powheg_v2_pythia': 'Powheg v2 + Pythia',
36-
'powheg_v1_herwig': 'Powheg v1 + Herwig',
37-
'powheg_v2_herwig': 'Powheg v2 + Herwig',
31+
'MADGRAPH': r'\textsc{MadGraph \raisebox{.2ex}{+} pythia}',
32+
'MADGRAPH_ptreweight': r'\textsc{MadGraph} \raisebox{.2ex}{+} $p_\mathrm{T}$ reweighting',
33+
'MCATNLO': r'\textsc{mc@nlo \raisebox{.2ex}{+} herwig}',
34+
'powheg_v1_pythia': r'\textsc{powheg v1 \raisebox{.2ex}{+} pythia}',
35+
'powheg_v2_pythia': r'\textsc{powheg v2 \raisebox{.2ex}{+} pythia}',
36+
'powheg_v1_herwig': r'\textsc{powheg v1 \raisebox{.2ex}{+} herwig}',
37+
'powheg_v2_herwig': r'\textsc{powheg v2 \raisebox{.2ex}{+} herwig}',
3838
'matchingdown': 'Matching down',
3939
'matchingup': 'Matching up',
4040
# 'scaledown': '$Q^{2}$ down',
@@ -107,7 +107,7 @@
107107
'ZJets':'Z/$\gamma^*$ + jets',
108108
'TTJet':ttBarLatex,
109109
'SingleTop':'Single Top' ,
110-
'V+Jets' : 'W/Z + jets'
110+
'V+Jets' : r'W/Z \raisebox{.2ex}{+} jets'
111111
}
112112

113113
fit_variables_latex = {
@@ -135,6 +135,7 @@
135135

136136
channel_latex = {
137137
'electron' : r"e + jets",
138-
'muon' : r"$\mu$ + jets",
139-
'combined' : r"e, $\mu$ + jets combined",
138+
'muon' : r"\boldmath$\mu$ + jets",
139+
'combined' : r"e, \boldmath$\mu$ + jets combined",
140+
140141
}

src/cross_section_measurement/02_unfold_and_measure.py

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,30 @@ def unfold_results( results, category, channel, k_value, h_truth, h_measured, h_
3535
unfoldCfg.Hreco = 0
3636
else:
3737
unfoldCfg.Hreco = options.Hreco
38-
38+
3939
h_unfolded_data = unfolding.unfold( h_data )
4040

4141
# unfolding.unfoldObject.GetCov()
4242

4343
covariance_matrix = None
4444
if category == 'central':
45-
covariance_matrix = asrootpy( unfolding.unfoldObject.Ereco(options.Hreco) ).to_numpy()
45+
covariance_matrix = asrootpy( unfolding.unfoldObject.Ereco(3) ).to_numpy()
46+
print covariance_matrix
47+
48+
corr = np.array(np.zeros((covariance_matrix.shape[0], covariance_matrix.shape[1]) ))
49+
50+
for i in range(0,covariance_matrix.shape[0]):
51+
for j in range(0,covariance_matrix.shape[1]):
52+
corr[i,j] = covariance_matrix[i,j] / np.sqrt( covariance_matrix[i,i] * covariance_matrix[j,j] )
53+
print 'Correlation'
54+
print corr
55+
# for i_row in range(0,covariance_matrix.shape[0]):
56+
# for i_col in range(0,covariance_matrix.shape[0]):
57+
# print i_row,i_col
58+
# print covariance_matrix[i_row,i_col]
59+
# # print h_unfolded_data.GetBinContent(i_row+1),h_unfolded_data.GetBinContent(i_col+1)
60+
# print h_unfolded_data.GetBinError(i_row+1)*h_unfolded_data.GetBinError(i_col+1)
61+
4662
# print list( h_unfolded_data.y() )
4763
# unfolding.unfoldObject.ErecoV(options.Hreco).Draw()
4864
# raw_input()
@@ -308,6 +324,7 @@ def get_unfolded_normalisation( TTJet_fit_results, category, channel, k_value ):
308324
'scaledown': scaledown_results,
309325
'scaleup': scaleup_results
310326
}
327+
311328
if centre_of_mass == 8:
312329
normalisation_unfolded['MCATNLO'] = MCATNLO_results
313330
normalisation_unfolded['powheg_v1_herwig'] = powheg_v1_herwig_results
@@ -368,10 +385,10 @@ def calculate_xsections( normalisation, category, channel, k_value = None ):
368385

369386
write_data_to_JSON( xsection_unfolded, filename )
370387

371-
def calculate_normalised_xsections( normalisation, category, channel, k_value = None, normalise_to_one = False ):
388+
def calculate_normalised_xsections( normalisation, category, channel, k_value = None, normalise_to_one = False, debug=False ):
372389
global variable, met_type, path_to_JSON
373390
TTJet_normalised_xsection = calculate_normalised_xsection( normalisation['TTJet_measured'], bin_widths[variable], normalise_to_one )
374-
TTJet_normalised_xsection_unfolded = calculate_normalised_xsection( normalisation['TTJet_unfolded'], bin_widths[variable], normalise_to_one )
391+
TTJet_normalised_xsection_unfolded = calculate_normalised_xsection( normalisation['TTJet_unfolded'], bin_widths[variable], normalise_to_one, debug )
375392
MADGRAPH_normalised_xsection = calculate_normalised_xsection( normalisation['MADGRAPH'], bin_widths[variable], normalise_to_one )
376393
MADGRAPH_ptreweight_normalised_xsection = calculate_normalised_xsection( normalisation['MADGRAPH_ptreweight'], bin_widths[variable], normalise_to_one )
377394
powheg_v2_pythia_normalised_xsection = calculate_normalised_xsection( normalisation['powheg_v2_pythia'], bin_widths[variable], normalise_to_one )
@@ -410,7 +427,6 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
410427
filename = path_to_JSON + '/xsection_measurement_results/%s/kv%d/%s/normalised_xsection_%s.txt' % ( channel, k_value, category, met_type )
411428
else:
412429
filename = path_to_JSON + '/xsection_measurement_results/%s/%s/normalised_xsection_%s.txt' % ( channel, category, met_type )
413-
414430
if normalise_to_one:
415431
filename = filename.replace( 'normalised_xsection', 'normalised_to_one_xsection' )
416432
write_data_to_JSON( normalised_xsection, filename )
@@ -605,9 +621,10 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
605621
if combine_before_unfolding:
606622
unfolded_normalisation_combined, covariance_combined = get_unfolded_normalisation( TTJet_fit_results_combined, category, 'combined', k_value_combined )
607623
else:
608-
covariance_combined = covariance_electron
609-
covariance_combined += covariance_muon
610-
# covariance_combined = asrootpy( covariance_combined )
624+
if category == 'central':
625+
covariance_combined = covariance_electron
626+
covariance_combined += covariance_muon
627+
# covariance_combined = asrootpy( covariance_combined )
611628
unfolded_normalisation_combined = combine_complex_results( unfolded_normalisation_electron, unfolded_normalisation_muon )
612629

613630
filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s.txt' % ( k_value_electron_central, category, met_type )
@@ -632,26 +649,26 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
632649
# else:
633650
# unfolded_normalisation_combined_higgs = combine_complex_results( unfolded_normalisation_electron_higgs, unfolded_normalisation_muon_higgs )
634651
#
635-
# filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_electron_central, category, met_type )
636-
# write_data_to_JSON( unfolded_normalisation_electron_higgs, filename )
637-
# filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_muon_central, category, met_type )
638-
# write_data_to_JSON( unfolded_normalisation_muon_higgs, filename )
639-
# filename = path_to_JSON + '/xsection_measurement_results/combined/%s/normalisation_%s_Higgs.txt' % ( category, met_type )
640-
# write_data_to_JSON( unfolded_normalisation_combined_higgs, filename )
652+
# filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_electron_central, category, met_type )
653+
# write_data_to_JSON( unfolded_normalisation_electron_higgs, filename )
654+
# filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_muon_central, category, met_type )
655+
# write_data_to_JSON( unfolded_normalisation_muon_higgs, filename )
656+
# filename = path_to_JSON + '/xsection_measurement_results/combined/%s/normalisation_%s_Higgs.txt' % ( category, met_type )
657+
# write_data_to_JSON( unfolded_normalisation_combined_higgs, filename )
641658

642659
# measure xsection
643-
# calculate_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
644-
# calculate_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
645-
# calculate_xsections( unfolded_normalisation_combined, category, 'combined' )
646-
647-
# calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
648-
# calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
649-
# calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined' )
660+
calculate_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
661+
calculate_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
662+
calculate_xsections( unfolded_normalisation_combined, category, 'combined' )
663+
664+
calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
665+
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
666+
calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined', debug=True )
650667

651-
# normalise_to_one = True
652-
# calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central, normalise_to_one )
653-
# calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central, normalise_to_one )
654-
# calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined', normalise_to_one )
668+
normalise_to_one = True
669+
calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central, normalise_to_one )
670+
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central, normalise_to_one )
671+
calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined', normalise_to_one )
655672

656673
if category == 'central':
657674
normalised_xsection_covariance_electron = calculate_covariance_for_normalised_xsection( covariance_electron, unfolded_normalisation_electron['TTJet_unfolded'], bin_widths[variable] )
@@ -662,21 +679,24 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
662679
filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/covariance.txt' % ( k_value_electron_central, category )
663680
np.savetxt( filename, normalised_xsection_covariance_electron, delimiter = ',' )
664681

665-
# cov_file = File( filename, 'recreate' )
666-
# covariance_electron.Write()
667-
# normalised_xsection_covariance_electron.(filename,',')
668-
# cov_file.Close()
682+
# # cov_file = File( filename, 'recreate' )
683+
# # covariance_electron.Write()
684+
# # normalised_xsection_covariance_electron.(filename,',')
685+
# # cov_file.Close()
669686

670687
filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/covariance.txt' % ( k_value_muon_central, category )
671688
np.savetxt( filename, normalised_xsection_covariance_muon, delimiter = ',' )
672689

673-
# cov_file = File( filename, 'recreate' )
674-
# covariance_muon.Write()
675-
# normalised_xsection_covariance_muon.Write()
676-
# cov_file.Close()
690+
# # cov_file = File( filename, 'recreate' )
691+
# # covariance_muon.Write()
692+
# # normalised_xsection_covariance_muon.Write()
693+
# # cov_file.Close()
677694

678695
filename = path_to_JSON + '/xsection_measurement_results/combined/%s/covariance.txt' % ( category )
679696
np.savetxt( filename, normalised_xsection_covariance_combined, delimiter = ',' )
697+
for i in range(0,normalised_xsection_covariance_combined.shape[0]):
698+
print np.sqrt( normalised_xsection_covariance_combined[i,i] )
699+
680700
# cov_file = File( filename, 'recreate' )
681701
# covariance_combined.Write()
682702
# normalised_xsection_covariance_combined.Write()

0 commit comments

Comments
 (0)