forked from owen234/ra2b2016gh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_model_ratio_hist1.c
138 lines (106 loc) · 6.48 KB
/
create_model_ratio_hist1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef create_model_ratio_hist1_c
#define create_model_ratio_hist1_c
#include "TSystem.h"
#include "TPad.h"
#include "TStyle.h"
#include <fstream>
#include <iostream>
#include "binning.h"
#include "histio.c"
#include "read_pars.h"
#include "get_hist.h"
void create_model_ratio_hist1( const char* model_pars_file = "outputfiles/model-pars-qcdmc3.txt",
const char* qcd_ratio_file = "outputfiles/qcdmc-ratio-v3.root" ) {
setup_bins();
gDirectory -> Delete( "h*" ) ;
loadHist( qcd_ratio_file, "qcdmc" ) ;
read_pars( model_pars_file ) ;
TH1F* h_ratio_all = new TH1F( "h_ratio_all", "QCD model H/L ratio", nb_global_after_exclusion, 0.5, nb_global_after_exclusion + 0.5 ) ;
TH1F* h_max_ldp_weight_search_bins = get_hist( "h_max_ldp_weight_search_bins_qcdmc" ) ;
TH1F* h_ldp_search_bins = get_hist( "h_ldp_search_bins_qcdmc" ) ;
TH1F* h_hdp_search_bins = get_hist( "h_hdp_search_bins_qcdmc" ) ;
TH1F* h_ratio_qcdmc = get_hist( "h_ratio_qcdmc" ) ;
int bi_hist_with_exclusion(0) ;
for ( int bi_nj=1; bi_nj<=nb_nj; bi_nj++ ) {
for ( int bi_nb=1; bi_nb<=nb_nb; bi_nb++ ) {
for ( int bi_htmht=4; bi_htmht<=nb_htmht; bi_htmht++ ) {
if ( is_this_bin_excluded(bi_nj-1, bi_nb-1, bi_htmht-1) ) continue;
bi_hist_with_exclusion++; // these few lines should be changed when we update the code that produces qcdmc-ratio-v3.root
int bi_ht, bi_mht ;
htmht_bin_to_ht_and_mht_bins( bi_htmht, bi_ht, bi_mht ) ;
char label[100] ;
sprintf( label, " %3d Nj%d-Nb%d-MHT%d-HT%d (%d)", bi_hist_with_exclusion, bi_nj, bi_nb-1, bi_mht-1, bi_ht, bi_htmht-3 ) ;
double model_ratio_val = 0;
double model_ratio_err = 0;
model_ratio_val = par_val_ht[bi_ht] * par_val_njet[bi_nj] * par_val_ht_mht[bi_ht][bi_mht] * par_val_nb[bi_nb] ;
model_ratio_err = model_ratio_val * sqrt(
pow( par_err_ht_fit[bi_ht]/par_val_ht[bi_ht], 2. )
+ pow( par_err_ht_syst[bi_ht]/par_val_ht[bi_ht], 2. )
+ pow( par_err_njet_fit[bi_nj]/par_val_njet[bi_nj], 2. )
+ pow( par_err_njet_syst[bi_nj]/par_val_njet[bi_nj], 2. )
+ pow( par_err_ht_mht[bi_ht][bi_mht]/par_val_ht_mht[bi_ht][bi_mht], 2. )
+ pow( par_err_nb[bi_nb]/par_val_nb[bi_nb], 2. )
) ;
printf(" %s : Nj %6.4f Nb %6.4f MHT %6.4f HT %6.4f model ratio = %6.4f +/- %6.4f\n", label,
par_val_njet[bi_nj], par_val_nb[bi_nb], par_val_ht_mht[bi_ht][bi_mht], par_val_ht[bi_ht], model_ratio_val, model_ratio_err ) ;
h_ratio_all -> GetXaxis() -> SetBinLabel( bi_hist_with_exclusion, label ) ;
h_ratio_all -> SetBinContent( bi_hist_with_exclusion, model_ratio_val ) ;
h_ratio_all -> SetBinError( bi_hist_with_exclusion, model_ratio_err ) ;
} // bi_htmht
} // bi_nb
} // bi_nj
gStyle -> SetOptStat(0) ;
gStyle -> SetPadBottomMargin(0.30) ;
h_ratio_all -> SetMarkerStyle( 22 ) ;
h_ratio_all -> SetMarkerColor( 2 ) ;
h_ratio_all -> GetXaxis() -> LabelsOption("v") ;
h_ratio_all -> Draw() ;
gPad -> SetGridy(1) ;
//---------------
TH1F* h_ratio_qcdmc_minus_model = new TH1F( "h_ratio_qcdmc_minus_model", "QCD H/L ratio difference (QCD MC - model)", nb_global_after_exclusion, 0.5, nb_global_after_exclusion + 0.5 ) ;
printf("\n\n") ;
bi_hist_with_exclusion = 0;
for ( int bi_nj=1; bi_nj<=nb_nj; bi_nj++ ) {
for ( int bi_nb=1; bi_nb<=nb_nb; bi_nb++ ) {
for ( int bi_htmht=4; bi_htmht<=nb_htmht; bi_htmht++ ) {
if ( is_this_bin_excluded(bi_nj-1, bi_nb-1, bi_htmht-1) ) continue;
bi_hist_with_exclusion++; // these few lines should be changed when we update the code that produces qcdmc-ratio-v3.root
float model_val = h_ratio_all -> GetBinContent( bi_hist_with_exclusion ) ;
float qcdmc_val = h_ratio_qcdmc -> GetBinContent( bi_hist_with_exclusion ) ;
float ldp_val = h_ldp_search_bins -> GetBinContent( bi_hist_with_exclusion ) ;
float hdp_val = h_hdp_search_bins -> GetBinContent( bi_hist_with_exclusion ) ;
float max_ldp_weight = h_max_ldp_weight_search_bins -> GetBinContent( bi_hist_with_exclusion ) ;
char label[100] ;
sprintf( label, "%s", h_ratio_all -> GetXaxis() -> GetBinLabel( bi_hist_with_exclusion ) ) ;
float diff_val(0.) ;
float diff_err(0.) ;
printf(" debug1 : model bin label = %s , qcdmc bin label = %s\n", h_ratio_all -> GetXaxis() -> GetBinLabel( bi_hist_with_exclusion ), h_ratio_qcdmc -> GetXaxis() -> GetBinLabel( bi_hist_with_exclusion ) ) ;
if ( hdp_val > 0 ) {
diff_val = qcdmc_val - model_val ;
std::cout << qcdmc_val << " " << model_val << " " << diff_val << std::endl;
diff_err = diff_val ;
printf(" %40s : LDP %7.1f HDP %7.1f max LDP weight %5.3f, diff err = %5.3f\n", label, ldp_val, hdp_val, max_ldp_weight, diff_err ) ;
} else {
diff_val = 0. ;
if ( ldp_val > 0 ) {
diff_err = max_ldp_weight / ldp_val ;
printf(" %40s : LDP %7.1f HDP %7.1f max LDP weight %5.3f, zero HDP H/L err = %5.3f\n", label, ldp_val, hdp_val, max_ldp_weight, diff_err ) ;
} else {
//diff_err = 0.5 ;
//diff_err = 0.2;
diff_err = 0.0;
printf(" %40s : LDP %7.1f HDP %7.1f max LDP weight %5.3f, *** both zero\n", label, ldp_val, hdp_val, max_ldp_weight ) ;
}
}
h_ratio_qcdmc_minus_model -> SetBinContent( bi_hist_with_exclusion, diff_val ) ;
h_ratio_qcdmc_minus_model -> SetBinError( bi_hist_with_exclusion, diff_err ) ;
h_ratio_qcdmc_minus_model -> GetXaxis() -> SetBinLabel( bi_hist_with_exclusion, label ) ;
} // bi_htmht
}//bi_nb
}//bi_nj
printf("\n\n") ;
h_ratio_qcdmc_minus_model -> GetXaxis() -> LabelsOption( "v" ) ;
saveHist("outputfiles/model-ratio-hist1.root", "h*" ) ;
} // create_model_ratio_hist1
//===============================================================================
#endif