@@ -33,7 +33,6 @@ def unfold_results( results, category, channel, tau_value, h_truth, h_measured,
3333 unfoldCfg .Hreco = options .Hreco
3434
3535 h_unfolded_data = unfolding .unfold ( h_data )
36-
3736 del unfolding
3837 return hist_to_value_error_tuplelist ( h_unfolded_data )
3938
@@ -63,13 +62,40 @@ def get_unfolded_normalisation( TTJet_fit_results, category, channel, tau_value,
6362 ttbar_theory_systematic_prefix + 'scaleup' : file_for_scaleup ,
6463 ttbar_theory_systematic_prefix + 'massdown' : file_for_massdown ,
6564 ttbar_theory_systematic_prefix + 'massup' : file_for_massup ,
65+
66+ # 'JES_down' : file_for_jesdown,
67+ # 'JES_up' : file_for_jesup,
68+
69+ # 'JER_down' : file_for_jerdown,
70+ # 'JER_up' : file_for_jerup,
71+
72+ # 'BJet_up' : file_for_bjetdown,
73+ # 'BJet_down' : file_for_bjetup,
74+
6675 ttbar_theory_systematic_prefix + 'hadronisation' : file_for_powheg_herwig ,
6776 ttbar_theory_systematic_prefix + 'NLOgenerator' : file_for_amcatnlo ,
77+
78+ # 'ElectronEnUp' : file_for_ElectronEnUp,
79+ # 'ElectronEnDown' : file_for_ElectronEnDown,
80+ # 'MuonEnUp' : file_for_MuonEnUp,
81+ # 'MuonEnDown' : file_for_MuonEnDown,
82+ # 'TauEnUp' : file_for_TauEnUp,
83+ # 'TauEnDown' : file_for_TauEnDown,
84+ # 'UnclusteredEnUp' : file_for_UnclusteredEnUp,
85+ # 'UnclusteredEnDown' : file_for_UnclusteredEnDown,
86+
87+ # 'Muon_up' : file_for_LeptonUp,
88+ # 'Muon_down' : file_for_LeptonDown,
89+ # 'Electron_up' : file_for_LeptonUp,
90+ # 'Electron_down' : file_for_LeptonDown,
91+
92+ # 'PileUpSystematic' : file_for_PUSystematic,
6893 }
6994
7095 h_truth , h_measured , h_response , h_fakes = None , None , None , None
7196 # Systematics where you change the response matrix
72- if category in ttbar_generator_systematics :
97+ if category in ttbar_generator_systematics or category in files_for_systematics :
98+ print 'Doing category' ,category ,'by changing response matrix'
7399 h_truth , h_measured , h_response , h_fakes = get_unfold_histogram_tuple ( inputfile = files_for_systematics [category ],
74100 variable = variable ,
75101 channel = channel ,
@@ -104,7 +130,7 @@ def get_unfolded_normalisation( TTJet_fit_results, category, channel, tau_value,
104130 visiblePS = visiblePS ,
105131 )
106132
107- central_results = hist_to_value_error_tuplelist ( h_truth )
133+ # central_results = hist_to_value_error_tuplelist( h_truth )
108134 TTJet_fit_results_unfolded = unfold_results ( TTJet_fit_results ,
109135 category ,
110136 channel ,
@@ -403,7 +429,31 @@ def calculate_normalised_xsections( normalisation, category, channel, normalise_
403429 ###
404430 file_for_massdown = File ( measurement_config .unfolding_mass_down , 'read' )
405431 file_for_massup = File ( measurement_config .unfolding_mass_up , 'read' )
432+ file_for_jesdown = File ( measurement_config .unfolding_jes_down , 'read' )
433+ file_for_jesup = File ( measurement_config .unfolding_jes_up , 'read' )
434+ ###
435+ file_for_jerdown = File ( measurement_config .unfolding_jer_down , 'read' )
436+ file_for_jerup = File ( measurement_config .unfolding_jer_up , 'read' )
406437 ###
438+ file_for_bjetdown = File ( measurement_config .unfolding_bjet_down , 'read' )
439+ file_for_bjetup = File ( measurement_config .unfolding_bjet_up , 'read' )
440+ ###
441+ file_for_LeptonDown = File ( measurement_config .unfolding_Lepton_down , 'read' )
442+ file_for_LeptonUp = File ( measurement_config .unfolding_Lepton_up , 'read' )
443+ ###
444+ file_for_ElectronEnDown = File ( measurement_config .unfolding_ElectronEn_down , 'read' )
445+ file_for_ElectronEnUp = File ( measurement_config .unfolding_ElectronEn_up , 'read' )
446+ ###
447+ file_for_MuonEnDown = File ( measurement_config .unfolding_MuonEn_down , 'read' )
448+ file_for_MuonEnUp = File ( measurement_config .unfolding_MuonEn_up , 'read' )
449+ ###
450+ file_for_TauEnDown = File ( measurement_config .unfolding_TauEn_down , 'read' )
451+ file_for_TauEnUp = File ( measurement_config .unfolding_TauEn_up , 'read' )
452+ ###
453+ file_for_UnclusteredEnDown = File ( measurement_config .unfolding_UnclusteredEn_down , 'read' )
454+ file_for_UnclusteredEnUp = File ( measurement_config .unfolding_UnclusteredEn_up , 'read' )
455+ ###
456+ file_for_PUSystematic = File ( measurement_config .unfolding_PUSystematic , 'read' )
407457
408458 file_for_powhegPythia8 = File ( measurement_config .unfolding_powheg_pythia8 , 'read' )
409459 file_for_amcatnlo = File ( measurement_config .unfolding_amcatnlo , 'read' )
@@ -449,14 +499,14 @@ def calculate_normalised_xsections( normalisation, category, channel, normalise_
449499 # all MET uncertainties except JES as this is already included
450500 met_uncertainties = [suffix for suffix in measurement_config .met_systematics_suffixes if not 'JetEn' in suffix and not 'JetRes' in suffix ]
451501 all_measurements = deepcopy ( categories )
452- # all_measurements.extend( pdf_uncertainties )
502+ all_measurements .extend ( pdf_uncertainties )
453503 all_measurements .extend ( ['QCD_shape' ] )
454504 all_measurements .extend ( rate_changing_systematics )
505+ all_measurements .extend ( ['central_TTJet' ] )
455506
456507 print 'Performing unfolding for variable' , variable
457508 for category in all_measurements :
458- print 'Doing category ' ,category
459-
509+ print 'Doing category ' , category
460510 if run_just_central and not category == 'central' :
461511 continue
462512 # Don't need to consider MET uncertainties for HT
@@ -483,20 +533,38 @@ def calculate_normalised_xsections( normalisation, category, channel, normalise_
483533 # combined_file = path_to_JSON + '/fit_results/' + category + '/fit_results_combined_' + met_type + '.txt'
484534
485535 # don't change fit input for ttbar generator/theory systematics and PDF weights
486- if category in ttbar_generator_systematics or category in ttbar_theory_systematics or category in pdf_uncertainties :
536+ if category in ttbar_generator_systematics or category in pdf_uncertainties :
487537 # or category in ttbar_mass_systematics
488538 electron_file = path_to_JSON + '/central/normalisation_electron_' + met_type + '.txt'
489539 muon_file = path_to_JSON + '/central/normalisation_muon_' + met_type + '.txt'
490- # combined_file = path_to_JSON + '/central/normalisation_combined_' + met_type + '.txt'
540+ # combined_file = path_to_JSON + '/central/normalisation_combined_' + met_type + '.txt'
541+ elif category in rate_changing_systematics or category == 'QCD_shape' :
542+ electron_file = path_to_JSON + '/' + category + '/normalisation_electron_' + met_type + '.txt'
543+ muon_file = path_to_JSON + '/' + category + '/normalisation_muon_' + met_type + '.txt'
544+ elif category == 'central_TTJet' :
545+ electron_file = path_to_JSON + '/central/initial_normalisation_electron_' + met_type + '.txt'
546+ muon_file = path_to_JSON + '/central/initial_normalisation_muon_' + met_type + '.txt'
547+ # elif category in met_uncertainties and not 'JES' in category and not 'JER' in category:
548+ # electron_file = path_to_JSON + '/'+category+'/initial_normalisation_electron_' + met_type + '.txt'
549+ # muon_file = path_to_JSON + '/'+category+'/initial_normalisation_muon_' + met_type + '.txt'
550+ elif category != 'central' :
551+ # electron_file = path_to_JSON + '/'+category+'/initial_normalisation_electron_' + met_type + '.txt'
552+ # muon_file = path_to_JSON + '/'+category+'/initial_normalisation_muon_' + met_type + '.txt'
553+ # electron_file = path_to_JSON + '/central/normalisation_electron_' + translate_options[options.metType] + '.txt'
554+ # muon_file = path_to_JSON + '/central/normalisation_muon_' + translate_options[options.metType] + '.txt'
555+ electron_file = path_to_JSON + '/' + category + '/normalisation_electron_' + met_type + '.txt'
556+ muon_file = path_to_JSON + '/' + category + '/normalisation_muon_' + met_type + '.txt'
491557
492558 fit_results_electron = None
493559 fit_results_muon = None
494560
495561 if category == 'Muon_up' or category == 'Muon_down' :
562+ # fit_results_electron = read_data_from_JSON( path_to_JSON + '/central/initial_normalisation_electron_' + met_type + '.txt' )
496563 fit_results_electron = read_data_from_JSON ( path_to_JSON + '/central/normalisation_electron_' + met_type + '.txt' )
497564 fit_results_muon = read_data_from_JSON ( muon_file )
498565 elif category == 'Electron_up' or category == 'Electron_down' :
499566 fit_results_electron = read_data_from_JSON ( electron_file )
567+ # fit_results_muon = read_data_from_JSON( path_to_JSON + '/central/initial_normalisation_muon_' + met_type + '.txt' )
500568 fit_results_muon = read_data_from_JSON ( path_to_JSON + '/central/normalisation_muon_' + met_type + '.txt' )
501569 else :
502570 fit_results_electron = read_data_from_JSON ( electron_file )
0 commit comments