@@ -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