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
2 changes: 1 addition & 1 deletion bin/x_02_all_vars
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ for var in MET HT ST MT WPT; do
wait;
fi
done

wait;
echo "All done! Time to run x_03_all_vars."
1 change: 1 addition & 0 deletions bin/x_03_all_vars
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ for var in MET HT ST MT WPT; do
fi
done

wait;
echo "All done! Time to run x_04_all_vars and x_05_all_vars."
1 change: 1 addition & 0 deletions bin/x_04_all_vars
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ for var in MET HT ST MT WPT; do
fi
done

wait;
echo "All done!"
1 change: 1 addition & 0 deletions bin/x_05_all_vars
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ for var in MET HT ST MT WPT; do
fi
done

wait;
echo "All done!"
2 changes: 2 additions & 0 deletions config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def __fill_defaults__( self ):
self.central_general_template = path_to_files + 'central/%s' + middle + '.root'
self.generator_systematic_vjets_templates = { systematic: path_to_files + 'central/VJets-%s_%dpb_PFElectron_PFMuon_PF2PATJets_PFMET.root' % ( systematic, self.luminosity ) for systematic in self.generator_systematics}

self.kValueSystematic = [ 'kValue_up', 'kValue_down']

categories_and_prefixes = self.categories_and_prefixes

self.general_category_templates = {category: path_to_files + category + '/%s' + middle + prefix + '.root' for category, prefix in categories_and_prefixes.iteritems()}
Expand Down
2 changes: 2 additions & 0 deletions config/latex_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
'Electron_up' : 'Electron efficiency $+1\sigma$',
'Muon_down' : 'Muon efficiency $-1\sigma$',
'Muon_up' : 'Muon efficiency $+1\sigma$',
'kValue_up' : 'k Value $+1$',
'kValue_down' : 'k Value $-1$',
}

met_systematics_latex = {
Expand Down
50 changes: 35 additions & 15 deletions src/cross_section_measurement/02_unfold_and_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
file_for_massup = File( measurement_config.unfolding_mass_up, 'read' )

variable = options.variable
k_value_electron = measurement_config.k_values_electron[variable]
k_value_muon = measurement_config.k_values_muon[variable]
k_value_combined = measurement_config.k_values_combined[variable]
k_value_electron_central = measurement_config.k_values_electron[variable]
k_value_muon_central = measurement_config.k_values_muon[variable]
k_value_combined_central = measurement_config.k_values_combined[variable]
load_fakes = options.load_fakes
unfoldCfg.Hreco = options.Hreco
method = options.unfolding_method
Expand All @@ -425,6 +425,10 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
ttbar_mass_systematics = measurement_config.topMass_systematics
categories.extend( measurement_config.topMass_systematics )

# Add k Value systematic
kValue_systematics = measurement_config.kValueSystematic
categories.extend( measurement_config.kValueSystematic )

pdf_uncertainties = ['PDFWeights_%d' % index for index in range( 1, 45 )]
rate_changing_systematics = [systematic + '+' for systematic in measurement_config.rate_changing_systematics.keys()]
rate_changing_systematics.extend( [systematic + '-' for systematic in measurement_config.rate_changing_systematics.keys()] )
Expand Down Expand Up @@ -455,14 +459,30 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
met_type += 'JetEnDown'
if met_type == 'PFMETJetEnDown':
met_type = 'patPFMetJetEnDown'


# Choose k Value
k_value_electron = k_value_electron_central
k_value_muon = k_value_muon_central
k_value_combined = k_value_combined_central
if category == 'kValue_up':
k_value_electron = k_value_electron_central+1
k_value_muon = k_value_muon_central+1
k_value_combined = k_value_combined_central+1
elif category == 'kValue_down':
k_value_electron = k_value_electron_central-1
if k_value_electron < 2 : k_value_electron = 2
k_value_muon = k_value_muon_central-1
if k_value_muon < 2 : k_value_muon = 2
k_value_combined = k_value_combined_central-1
if k_value_combined < 2 : k_value_combined = 2

# read fit results from JSON
electron_file = path_to_JSON + '/fit_results/' + category + '/fit_results_electron_' + met_type + '.txt'
muon_file = path_to_JSON + '/fit_results/' + category + '/fit_results_muon_' + met_type + '.txt'
combined_file = path_to_JSON + '/fit_results/' + category + '/fit_results_combined_' + met_type + '.txt'

# don't change fit input for ttbar generator/theory systematics and PDF weights
if category in ttbar_generator_systematics or category in ttbar_theory_systematics or category in pdf_uncertainties or category in ttbar_mass_systematics:
if category in ttbar_generator_systematics or category in ttbar_theory_systematics or category in pdf_uncertainties or category in ttbar_mass_systematics or category in kValue_systematics:
electron_file = path_to_JSON + '/fit_results/central/fit_results_electron_' + met_type + '.txt'
muon_file = path_to_JSON + '/fit_results/central/fit_results_muon_' + met_type + '.txt'
combined_file = path_to_JSON + '/fit_results/central/fit_results_combined_' + met_type + '.txt'
Expand Down Expand Up @@ -490,9 +510,9 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
else:
unfolded_normalisation_combined = combine_complex_results( unfolded_normalisation_electron, unfolded_normalisation_muon )

filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s.txt' % ( k_value_electron, category, met_type )
filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s.txt' % ( k_value_electron_central, category, met_type )
write_data_to_JSON( unfolded_normalisation_electron, filename )
filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s.txt' % ( k_value_muon, category, met_type )
filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s.txt' % ( k_value_muon_central, category, met_type )
write_data_to_JSON( unfolded_normalisation_muon, filename )
filename = path_to_JSON + '/xsection_measurement_results/combined/%s/normalisation_%s.txt' % ( category, met_type )
write_data_to_JSON( unfolded_normalisation_combined, filename )
Expand All @@ -509,23 +529,23 @@ def calculate_normalised_xsections( normalisation, category, channel, k_value =
else:
unfolded_normalisation_combined_higgs = combine_complex_results( unfolded_normalisation_electron_higgs, unfolded_normalisation_muon_higgs )

filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_electron, category, met_type )
filename = path_to_JSON + '/xsection_measurement_results/electron/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_electron_central, category, met_type )
write_data_to_JSON( unfolded_normalisation_electron_higgs, filename )
filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_muon, category, met_type )
filename = path_to_JSON + '/xsection_measurement_results/muon/kv%d/%s/normalisation_%s_Higgs.txt' % ( k_value_muon_central, category, met_type )
write_data_to_JSON( unfolded_normalisation_muon_higgs, filename )
filename = path_to_JSON + '/xsection_measurement_results/combined/%s/normalisation_%s_Higgs.txt' % ( category, met_type )
write_data_to_JSON( unfolded_normalisation_combined_higgs, filename )

# measure xsection
calculate_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron )
calculate_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon )
calculate_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
calculate_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
calculate_xsections( unfolded_normalisation_combined, category, 'combined' )

calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron )
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon )
calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central )
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central )
calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined' )

normalise_to_one = True
calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron, normalise_to_one )
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon, normalise_to_one )
calculate_normalised_xsections( unfolded_normalisation_electron, category, 'electron', k_value_electron_central, normalise_to_one )
calculate_normalised_xsections( unfolded_normalisation_muon, category, 'muon', k_value_muon_central, normalise_to_one )
calculate_normalised_xsections( unfolded_normalisation_combined, category, 'combined', normalise_to_one )
Loading