20 void makeBkgdFilesForRatio(
int charge,
int two_or_four,
int etaLow=0,
int etaHigh=100) {
27 string dataDir=
"/star/data01/pwg/stevens4/wAnalysis/xSecPaper/sl11b/data/";
28 string dataName=
"run9setABCD.wana.hist.root";
30 gStyle->SetOptDate(0);
31 TFile *f1 =
new TFile(Form(
"%s%s",dataDir,dataName));
35 TH1F *signal = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_wE_etaBin2"))->ProjectionY(
"signal_py",etaLow,etaHigh);
36 TH1F *signal_wo_eemc = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_noE_etaBin2"))->ProjectionY(
"signal_no_eemc_py",etaLow,etaHigh);
37 }
else if (charge == -1) {
38 TH1F *signal = (TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_wE_etaBin2"))->ProjectionY(
"signal_py",etaLow,etaHigh);
39 TH1F *signal_wo_eemc = (TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_noE_etaBin2"))->ProjectionY(
"signal_no_eemc_py",etaLow,etaHigh);
40 }
else if (charge == 0) {
41 TH1F *signal = (TH1F*)f1->Get(
"muclustPtBal");
42 TH1F *signal_wo_eemc = (TH1F*)f1->Get(
"muclustPtBalnoE");
51 string mcDir=
"/star/u/stevens4/wAnalysis/efficXsec/outEmb/gainUp2/";
55 MC_fs[0] =
new TFile(Form(
"%sWplus%s.wana.hist.root",mcDir,tpcHV));
56 MC_fs[1] =
new TFile(Form(
"%sWminus%s.wana.hist.root",mcDir,tpcHV));
57 MC_fs[2] =
new TFile(Form(
"%sWtau%s.wana.hist.root",mcDir,tpcHV));
58 MC_fs[3] =
new TFile(Form(
"%sZany%s.wana.hist.root",mcDir,tpcHV));
59 MC_fs[4] =
new TFile(Form(
"%sZe+e-Interf%s.wana.hist.root",mcDir,tpcHV));
62 TH1F *MC_dists_raw[5][3];
63 for (
int i=0; i<5; i++) {
65 MC_dists_raw[i][0] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_wE_etaBin2"))->ProjectionY(Form(
"%d_0_py",i),etaLow,etaHigh);
66 MC_dists_raw[i][1] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_noE_etaBin2"))->ProjectionY(Form(
"%d_1_py",i),etaLow,etaHigh);
67 MC_dists_raw[i][2] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_back_etaBin2"))->ProjectionY(Form(
"%d_2_py",i),etaLow,etaHigh);
69 }
else if (charge == -1) {
70 MC_dists_raw[i][0] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_wE_etaBin2"))->ProjectionY(Form(
"%d_0_py",i),etaLow,etaHigh);
71 MC_dists_raw[i][1] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_noE_etaBin2"))->ProjectionY(Form(
"%d_1_py",i),etaLow,etaHigh);
72 MC_dists_raw[i][2] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_back_etaBin2"))->ProjectionY(Form(
"%d_2_py",i),etaLow,etaHigh);
73 }
else if (charge == 0) {
74 MC_dists_raw[i][0] = (TH1F*)MC_fs[i]->Get(
"muclustPtBal");
75 MC_dists_raw[i][1] = (TH1F*)MC_fs[i]->Get(
"muclustPtBalnoE");
76 MC_dists_raw[i][2] = (TH1F*)MC_fs[i]->Get(
"muclustPtBal_bckgrd");
81 float lumi[5] = {128.6,385.0,96.2,53.1,531.9};
85 for (
int i=0; i<5; i++) {lumi_fact[i] = 13.18/lumi[i];}
86 for (
int i=0; i<5; i++) {
87 for (
int j=0; j<3; j++) {
88 MC_dists_raw[i][j]->Scale(lumi_fact[i]);
96 TH1F *MC_dists_repack[5][3];
97 for (
int i=0; i<5; i++) {
98 sprintf(str,
"mcclustPtBal_%d",i);
99 MC_dists_repack[i][0] =
new TH1F(str,str,49,1.,99.);
100 sprintf(str,
"mcclustPtBalnoE_%d",i);
101 MC_dists_repack[i][1] =
new TH1F(str,str,49,1.,99.);
102 sprintf(str,
"mcclustPtBal_bckgrd_%d",i);
103 MC_dists_repack[i][2] =
new TH1F(str,str,49,1.,99.);
106 for (
int i=0; i<5; i++) {
107 for (
int j=0; j<3; j++) {
108 for (
int k=1; k<=49; k++) {
109 MC_dists_repack[i][j]->SetBinContent(k,MC_dists_raw[i][j]->GetBinContent(2*k)+MC_dists_raw[i][j]->GetBinContent(2*k+1));
115 for (
int i=0; i<5; i++) {
116 MC_dists_repack[i][1]->Add(MC_dists_repack[i][0],-1);
117 MC_dists_raw[i][1]->Add(MC_dists_raw[i][0],-1.);
124 TH1F *eemc_bkgd = signal_wo_eemc->Clone();
125 eemc_bkgd->Add(signal,-1.);
126 eemc_bkgd->Add(MC_dists_raw[4][1],-1.);
128 TH1F *signal_final = signal->Clone();
129 signal_final->Add(eemc_bkgd,-1);
132 TH1F *eemc_bkgd2 =
new TH1F(
"eemc_bkgd2",
"eemc_bkgd2",49,1,99);
133 TH1F *zsig_bkgd2 =
new TH1F(
"zsig_bkgd2",
"zsig_bkgd2",49,1,99);
134 TH1F *zeemc_bkgd2 =
new TH1F(
"zeemc_bgkd2",
"zeemc_bkgd2",49,1,99);
135 TH1F *zback_bkgd2 =
new TH1F(
"zback_bkgd2",
"zback_bkgd2",49,1,99);
137 TH1F *zanysig_bkgd2 =
new TH1F(
"zanysig_bkgd2",
"zanysig_bkgd2",49,1,99);
138 TH1F *zanyeemc_bkgd2 =
new TH1F(
"zanyeemc_bgkd2",
"zanyeemc_bkgd2",49,1,99);
139 TH1F *zanyback_bkgd2 =
new TH1F(
"zanyback_bkgd2",
"zanyback_bkgd2",49,1,99);
141 TH1F *zsig = MC_dists_raw[4][0]->Clone();
142 TH1F *zeemc = MC_dists_raw[4][1]->Clone();
143 TH1F *zback = MC_dists_raw[4][2]->Clone();
146 signal_final->Add(zsig,-1.);
149 TH1F *bkgd_shape1 = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_back_etaBin2"))->ProjectionY(
"back1_py",etaLow,etaHigh);
150 bkgd_shape1->Add((TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_back_etaBin2"))->ProjectionY(
"back2_py",etaLow,etaHigh));
153 TH1F *bkgd_shape_nom =
new TH1F(
"bkgd_shape",
"bkgd_shape",49,1,99);
154 for (
int i=1; i<=49; i++) {
155 bkgd_shape_nom->SetBinContent(i,bkgd_shape1->GetBinContent(2*i)+
156 bkgd_shape1->GetBinContent(2*i+1));
158 TH1F *bkgd_shape_nom2 = bkgd_shape_nom->Clone();
160 TH1F *signal_final2 =
new TH1F(
"signal_final2",
"signal_final2",49,1,99);
161 signal_final2->SetLineColor(2);
162 signal_final2->SetLineWidth(2.*signal_final2->GetLineWidth());
163 TH1F *signal2 =
new TH1F(
"signal2",
"signal2",49,1,99);
164 for (
int i=1; i<=49; i++) {
165 signal_final2->SetBinContent(i,signal_final->GetBinContent(2*i)+
166 signal_final->GetBinContent(2*i+1));
167 signal2->SetBinContent(i,signal->GetBinContent(2*i)+
168 signal->GetBinContent(2*i+1));
169 eemc_bkgd2->SetBinContent(i,eemc_bkgd->GetBinContent(2*i)+
170 eemc_bkgd->GetBinContent(2*i+1));
171 zsig_bkgd2->SetBinContent(i,zsig->GetBinContent(2*i)+
172 zsig->GetBinContent(2*i+1));
173 zeemc_bkgd2->SetBinContent(i,zeemc->GetBinContent(2*i)+
174 zeemc->GetBinContent(2*i+1));
175 zback_bkgd2->SetBinContent(i,zback->GetBinContent(2*i)+
176 zback->GetBinContent(2*i+1));
177 zanysig_bkgd2->SetBinContent(i,MC_dists_raw[3][0]->GetBinContent(2*i)+
178 MC_dists_raw[3][0]->GetBinContent(2*i+1));
179 zanyeemc_bkgd2->SetBinContent(i,MC_dists_raw[3][1]->GetBinContent(2*i)+
180 MC_dists_raw[3][1]->GetBinContent(2*i+1));
181 zanyback_bkgd2->SetBinContent(i,MC_dists_raw[3][2]->GetBinContent(2*i)+
182 MC_dists_raw[3][2]->GetBinContent(2*i+1));
185 TCanvas *can2 =
new TCanvas(
"can2",
"can2",0,0,600,400);
187 signal_final2->Draw(
"same");
195 eemc_bkgd->SetLineColor(8);
196 eemc_bkgd->SetLineWidth(2.*eemc_bkgd->GetLineWidth());
197 bkgd_shape_nom2->SetLineColor(4);
198 bkgd_shape_nom2->SetLineWidth(2.*bkgd_shape_nom2->GetLineWidth());
200 TCanvas *can8 =
new TCanvas(
"can8",
"can8",0,0,3000,1800);
202 for (
int i=0; i<5; i++) {
203 for (
int j=0; j<3; j++) {
209 signal_final2->Draw();
215 bkgd_shape_nom2->Draw();
217 MC_dists_repack[i][j]->Draw(
"same");
223 for (
int i=0; i<5; i++) {
224 float signal_sum = 0.;
227 for (
int j=13; j<=49; j++) {
228 signal_sum += MC_dists_repack[i][0]->GetBinContent(j);
229 eemc_sum += MC_dists_repack[i][1]->GetBinContent(j);
230 back_sum += MC_dists_repack[i][2]->GetBinContent(j);
235 float signal_in_normMC[3];
237 signal_in_normMC[0]=MC_dists_repack[0][0]->Integral(8,8);
238 signal_in_normMC[1]=MC_dists_repack[0][0]->Integral(9,9);
239 signal_in_normMC[2]=MC_dists_repack[0][0]->Integral(10,10);
242 signal_in_normMC[0]=MC_dists_repack[1][0]->Integral(8,8);
243 signal_in_normMC[1]=MC_dists_repack[1][0]->Integral(9,9);
244 signal_in_normMC[2]=MC_dists_repack[1][0]->Integral(10,10);
251 signal_final2->Add(MC_dists_repack[2][0],-1.*taufrac);
260 TF1 *func1 =
new TF1(
"func1",
"[0]+[1]*x",23,39);
261 func1->SetParameter(0,0.);
262 func1->SetParameter(1,0.);
264 TCanvas *can4 =
new TCanvas(
"can4",
"can4",0,0,600,400);
265 signal_final2->Draw();
269 float signal_in_norm[50];
270 TH1F *bkgd_shape_unnorm[20];
271 TH1F *signal_for_new[20];
272 for (
int i=0; i<20; i++) {
273 bkgd_shape_unnorm[i] = (TH1F*)bkgd_shape_nom->Clone();
274 signal_for_new[i] = (TH1F*)signal_final2->Clone();
277 bkgd_shape_unnorm[i]->Add(zback_bkgd2,-1.);
280 signal_in_norm[8] = func1->Integral(15,17);
281 signal_in_norm[9] = func1->Integral(17,19);
282 signal_in_norm[10] = func1->Integral(19,21);
284 for (
int j=8; j<=10; j++) {
285 if (signal_in_norm[j] < 0) {signal_in_norm[j] = 0.;}
289 signal_in_norm[8]=signal_in_normMC[0];
290 signal_in_norm[9]=signal_in_normMC[1];
291 signal_in_norm[10]=signal_in_normMC[2];
295 float normt = 0, normb = 0.;
296 for (
int k=8; k<10; k++) {
297 if (bkgd_shape_unnorm[i]->GetBinContent(k) > 0) {
298 normt += signal_final2->GetBinContent(k)-signal_in_norm[k];
299 normb += bkgd_shape_unnorm[i]->GetBinContent(k);
302 if (normb > 0 && normt > 0) {
303 float norm = normt/normb;
304 bkgd_shape_unnorm[i]->Scale(norm);
305 bkgd_shape_unnorm[i]->Draw(
"same");
308 else if(normb > 0 && normt < 0){
310 bkgd_shape_unnorm[i]->Scale(norm);
311 bkgd_shape_unnorm[i]->Draw(
"same");
316 for (
int j=1; j<=49; j++) {
317 if (bkgd_shape_unnorm[i]->GetBinContent(j) < 0) {bkgd_shape_unnorm[i]->SetBinContent(j,0.);}
319 signal_for_new[i]->Add(bkgd_shape_unnorm[i],-1.);
320 signal_for_new[i]->Fit(func1,
"RQ");
325 TH1F *signal_in_norm_region =
new TH1F(
"signal_in_norm_region",
"signal_in_norm_region",49,1.,99.);
327 signal_in_norm_region->SetBinContent(8,signal_in_norm[8]);
328 signal_in_norm_region->SetBinContent(9,signal_in_norm[9]);
330 TH1F *new_bkgd =
new TH1F(
"new_bkgd",
"new_bkgd",49,1.,99.);
331 new_bkgd = (TH1F*)bkgd_shape_unnorm[19]->Clone();
332 new_bkgd->SetName(
"new_bkgd");
334 TCanvas *can5 =
new TCanvas(
"can5",
"can5",0,0,600,400);
335 signal_final2->Draw();
336 new_bkgd->Draw(
"same");
337 signal_in_norm_region->Draw(
"same");
348 TH1F *bkgd_hists_from_file[21];
349 TH1F *bkgd_hists_from_file2[21];
351 for (
int i=0; i<=20; i++) {
354 sprintf(str,
"pos_failsPtBal_sPtBal_bin_%d_py",i);
355 bkgd_hists_from_file[i] = (TH1F*)((TH2F*)f1->Get(Form(
"pos_failsPtBal_sPtBal_bin_%d_etaBin2",i)))->ProjectionY(str,etaLow,etaHigh);
356 sprintf(str,
"neg_failsPtBal_sPtBal_bin_%d_py",i);
357 bkgd_hists_from_file2[i] = (TH1F*)((TH2F*)f1->Get(Form(
"neg_failsPtBal_sPtBal_bin_%d_etaBin2",i)))->ProjectionY(str,etaLow,etaHigh);
358 bkgd_hists_from_file[i]->Add(bkgd_hists_from_file2[i]);
363 TH1F *bkgd_hists1[21];
364 TH1F *bkgd_hists2[21];
365 TH1F *bkgd_hists3[21];
366 for (
int i=0; i<=20; i++) {
367 sprintf(str,
"bkgd_hist1_%d",i);
368 bkgd_hists1[i] =
new TH1F(str,str,49,1,99);
369 sprintf(str,
"bkgd_hist2_%d",i);
370 bkgd_hists2[i] =
new TH1F(str,str,49,1,99);
371 sprintf(str,
"bkgd_hist3_%d",i);
372 bkgd_hists3[i] =
new TH1F(str,str,49,1,99);
373 for (
int k=1; k<=49; k++) {
374 bkgd_hists1[i]->SetBinContent(k,bkgd_hists_from_file[i]->GetBinContent(2*k)+bkgd_hists_from_file[i]->GetBinContent(2*k+1));
375 bkgd_hists2[i]->SetBinContent(k,bkgd_hists_from_file[i]->GetBinContent(2*k)+bkgd_hists_from_file[i]->GetBinContent(2*k+1));
376 bkgd_hists3[i]->SetBinContent(k,bkgd_hists_from_file[i]->GetBinContent(2*k)+bkgd_hists_from_file[i]->GetBinContent(2*k+1));
381 TF1 *func2 =
new TF1(
"func2",
"[0]+[1]*x",23,39);
382 func2->SetParameter(0,0.);
383 func2->SetParameter(1,0.);
384 TF1 *func3 =
new TF1(
"func3",
"[0]+[1]*x",23,39);
385 func3->SetParameter(0,0.);
386 func3->SetParameter(1,0.);
389 float final_sig_in_norm[21][3];
390 float final_chisquare[21];
391 float signal_in_norm1[50];
392 float signal_in_norm2[50];
393 float signal_in_norm3[50];
394 TH1F *new_bkgd_hists1[21];
395 TH1F *new_bkgd_hists2[21];
396 TH1F *new_bkgd_hists3[21];
397 TH1F *bkgd_shape_unnorm1[20];
398 TH1F *bkgd_shape_unnorm2[20];
399 TH1F *bkgd_shape_unnorm3[20];
400 TH1F *signal_for_new1[20];
401 TH1F *signal_for_new2[20];
402 TH1F *signal_for_new3[20];
403 for (
int i=0; i<=20; i++) {
405 func1->SetParameter(0,0.);
406 func1->SetParameter(1,0.);
407 func2->SetParameter(0,0.);
408 func2->SetParameter(1,0.);
409 func3->SetParameter(0,0.);
410 func3->SetParameter(1,0.);
412 for (
int l=0; l<20; l++) {
413 bkgd_shape_unnorm1[l] = (TH1F*)bkgd_hists1[i]->Clone();
414 bkgd_shape_unnorm2[l] = (TH1F*)bkgd_hists2[i]->Clone();
415 bkgd_shape_unnorm3[l] = (TH1F*)bkgd_hists3[i]->Clone();
416 signal_for_new1[l] = (TH1F*)signal_final2->Clone();
417 signal_for_new2[l] = (TH1F*)signal_final2->Clone();
418 signal_for_new3[l] = (TH1F*)signal_final2->Clone();
421 bkgd_shape_unnorm1[l]->Add(zback_bkgd2,-1.);
422 bkgd_shape_unnorm2[l]->Add(zback_bkgd2,-1.);
423 bkgd_shape_unnorm3[l]->Add(zback_bkgd2,-1.);
426 signal_in_norm1[8] = func1->Integral(15,17);
427 signal_in_norm1[9] = func1->Integral(17,19);
428 signal_in_norm1[10] = func1->Integral(19,21);
429 signal_in_norm2[8] = func2->Integral(15,17);
430 signal_in_norm2[9] = func2->Integral(17,19);
431 signal_in_norm2[10] = func2->Integral(19,21);
432 signal_in_norm3[8] = func3->Integral(15,17);
433 signal_in_norm3[9] = func3->Integral(17,19);
434 signal_in_norm3[10] = func3->Integral(19,21);
436 for (
int m=8; m<=10; m++) {
437 if (signal_in_norm1[m] < 0) {signal_in_norm1[m] = 0.;}
438 if (signal_in_norm2[m] < 0) {signal_in_norm2[m] = 0.;}
439 if (signal_in_norm3[m] < 0) {signal_in_norm3[m] = 0.;}
443 signal_in_norm1[8]=signal_in_normMC[0];
444 signal_in_norm1[9]=signal_in_normMC[1];
445 signal_in_norm1[10]=signal_in_normMC[2];
446 signal_in_norm2[8]=signal_in_normMC[0];
447 signal_in_norm2[9]=signal_in_normMC[1];
448 signal_in_norm2[10]=signal_in_normMC[2];
449 signal_in_norm3[8]=signal_in_normMC[0];
450 signal_in_norm3[9]=signal_in_normMC[1];
451 signal_in_norm3[10]=signal_in_normMC[2];
454 float normt = 0, normb = 0.;
455 for (
int k=8; k<=8; k++) {
456 if (bkgd_shape_unnorm1[l]->GetBinContent(k) > 0) {
457 normt += signal_final2->GetBinContent(k)-signal_in_norm1[k];
458 normb += bkgd_shape_unnorm1[l]->GetBinContent(k);
461 if (normb > 0 && normt > 0) {
462 float norm = normt/normb;
463 bkgd_shape_unnorm1[l]->Scale(norm);
465 else if(normb > 0 && normt < 0){
467 bkgd_shape_unnorm1[l]->Scale(norm);
470 for (
int m=1; m<=49; m++) {
471 if (bkgd_shape_unnorm1[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm1[l]->SetBinContent(m,0.);}
473 signal_for_new1[l]->Add(bkgd_shape_unnorm1[l],-1.);
474 signal_for_new1[l]->Fit(func1,
"RQ");
477 normt = 0.; normb = 0.;
478 for (
int k=8; k<=9; k++) {
479 if (bkgd_shape_unnorm2[l]->GetBinContent(k) > 0) {
480 normt += signal_final2->GetBinContent(k)-signal_in_norm2[k];
481 normb += bkgd_shape_unnorm2[l]->GetBinContent(k);
484 if (normb > 0 && normt > 0) {
485 float norm = normt/normb;
486 bkgd_shape_unnorm2[l]->Scale(norm);
489 else if(normb > 0 && normt < 0){
491 bkgd_shape_unnorm2[l]->Scale(norm);
494 for (
int m=1; m<=49; m++) {
495 if (bkgd_shape_unnorm2[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm2[l]->SetBinContent(m,0.);}
497 signal_for_new2[l]->Add(bkgd_shape_unnorm2[l],-1.);
498 signal_for_new2[l]->Fit(func2,
"RQ");
501 normt = 0.; normb = 0.;
502 for (
int k=8; k<=10; k++) {
503 if (bkgd_shape_unnorm3[l]->GetBinContent(k) > 0) {
504 normt += signal_final2->GetBinContent(k)-signal_in_norm3[k];
505 normb += bkgd_shape_unnorm3[l]->GetBinContent(k);
508 if (normb > 0 && normt > 0) {
509 float norm = normt/normb;
510 bkgd_shape_unnorm3[l]->Scale(norm);
512 else if(normb > 0 && normt < 0){
514 bkgd_shape_unnorm3[l]->Scale(norm);
517 for (
int m=1; m<=49; m++) {
518 if (bkgd_shape_unnorm3[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm3[l]->SetBinContent(m,0.);}
520 signal_for_new3[l]->Add(bkgd_shape_unnorm3[l],-1.);
521 signal_for_new3[l]->Fit(func3,
"RQ");
525 new_bkgd_hists1[i] = (TH1F*)bkgd_shape_unnorm1[19]->Clone();
526 new_bkgd_hists2[i] = (TH1F*)bkgd_shape_unnorm2[19]->Clone();
527 new_bkgd_hists3[i] = (TH1F*)bkgd_shape_unnorm3[19]->Clone();
532 gStyle->SetTitleBorderSize(0);
533 TCanvas *can6 =
new TCanvas(
"can6",
"can6",0,0,600,400);
534 signal_final2->SetStats(kFALSE);
536 signal_final2->SetTitle(
"W+ Background Shapes");
537 }
else if (charge == -1) {
538 signal_final2->SetTitle(
"W- Background Shapes");
540 signal_final2->GetXaxis()->SetRangeUser(0.,70.);
541 signal_final2->GetXaxis()->SetTitle(
"2x2 Cluster E_{T} (GeV)");
542 signal_final2->Draw();
543 for (
int i=0; i<=20; i++) {
544 new_bkgd_hists1[i]->Draw(
"same");
545 new_bkgd_hists2[i]->Draw(
"same");
546 new_bkgd_hists3[i]->Draw(
"same");
548 new_bkgd->SetLineColor(4);
550 new_bkgd->Draw(
"same");
554 }
else if (charge == -1) {
559 TH1F *chi2s =
new TH1F(
"chi2s",
"chi2s",50,0.,10.);
560 for (
int i=0; i<=20; i++) {
561 chi2s->Fill(final_chisquare[i]);
564 TCanvas *can7 =
new TCanvas(
"can7",
"can7",0,0,600,400);
575 TH1F *tauhist = MC_dists_repack[2][0]->Clone();
576 tauhist->Scale(taufrac);
577 float tau_norm = lumi_fact[2];
578 float Z_norm = lumi_fact[4];
580 float signal_sum = 0.;
582 float QCD_sum = 0., tau_sum = 0., eemc_sum = 0.;
583 float QCD_raw_sum = 0.;
584 float Zany_bkgd_sum = 0.;
585 float Zany_eemc_sum = 0.;
586 float zsig_sum = 0., zeemc_sum = 0.,zback_sum = 0.;
587 float zanysig_sum = 0., zanyeemc_sum = 0.,zanyback_sum = 0.;
588 for (
int i=13; i<=49; i++) {
589 bkgd_sum += new_bkgd->GetBinContent(i);
590 bkgd_sum += tauhist->GetBinContent(i);
591 bkgd_sum += eemc_bkgd2->GetBinContent(i);
592 QCD_raw_sum += bkgd_shape_nom->GetBinContent(i);
593 QCD_sum += new_bkgd->GetBinContent(i);
594 tau_sum += tauhist->GetBinContent(i);
595 eemc_sum += eemc_bkgd2->GetBinContent(i);
596 signal_sum += signal_final2->GetBinContent(i);
597 raw_sum += signal2->GetBinContent(i);
598 zsig_sum += zsig_bkgd2->GetBinContent(i);
599 zeemc_sum += zeemc_bkgd2->GetBinContent(i);
600 zback_sum += zback_bkgd2->GetBinContent(i);
601 zanysig_sum += zanysig_bkgd2->GetBinContent(i);
602 zanyeemc_sum += zanyeemc_bkgd2->GetBinContent(i);
603 zanyback_sum += zanyback_bkgd2->GetBinContent(i);
605 cout <<
"The total background for ET>25 is " << bkgd_sum+zsig_sum << endl;
606 cout <<
"QCD = " << QCD_sum <<
", tau = " << tau_sum <<
", eemc = " << eemc_sum <<
", and Z = " << zsig_sum << endl;
607 cout <<
"Raw = " << raw_sum << endl;
608 cout <<
"W Signal (w/o tau) = " << signal_sum-QCD_sum << endl;
609 cout <<
"Z in sig = " << zsig_sum << endl;
610 cout <<
"Z in eemc = " << zeemc_sum << endl;
611 cout <<
"Z in back = " << zback_sum << endl;
612 cout <<
"Zany in sig = " << zanysig_sum << endl;
613 cout <<
"Zany in eemc = " << zanyeemc_sum << endl;
614 cout <<
"Zany in back = " << zanyback_sum << endl;
615 cout <<
"QCD raw in back = " << QCD_raw_sum << endl;
616 cout <<
"The QCD stat unc. is " << sqrt(norm*QCD_sum) << endl;
617 float tau_stat = tau_norm*taufrac*sqrt(tau_sum/(tau_norm*taufrac));
618 float tau_syst = 0.13*tau_sum;
619 cout <<
"The tau stat unc. is " << tau_stat <<
" syst is " << tau_syst <<
" and total is " << sqrt(tau_stat*tau_stat + tau_syst*tau_syst) << endl;
620 float eemc_stat = sqrt(eemc_sum);
621 float eemc_syst = 0.13*zeemc_sum;
622 cout <<
"The eemc stat unc. is " << eemc_stat <<
" syst is " << eemc_syst <<
" and total is " << sqrt(eemc_stat*eemc_stat + eemc_syst*eemc_syst) << endl;
623 float Z_stat = Z_norm*sqrt(zsig_sum/Z_norm);
624 float Z_syst = 0.13*zsig_sum;
625 cout <<
"The Z stat unc. is " << Z_stat <<
" syst is " << Z_syst <<
" and total is " << sqrt(Z_stat*Z_stat + Z_syst*Z_syst) << endl;
634 TH1F *raw_stat_err2 =
new TH1F(
"raw_stat_err2",
"raw_stat_err2",49,1.,99.);
635 TH1F *QCD_stat_err2 =
new TH1F(
"QCD_stat_err2",
"QCD_stat_err2",49,1.,99.);
636 TH1F *eemc_stat_err2 =
new TH1F(
"eemc_stat_err2",
"eemc_stat_err2",49,1.,99.);
637 TH1F *tau_stat_err2 =
new TH1F(
"tau_stat_err2",
"tau_stat_err2",49,1.,99.);
638 TH1F *QCD_syst_high_err =
new TH1F(
"QCD_syst_high_err",
"QCD_syst_high_err",49,1.,99.);
639 TH1F *QCD_syst_low_err =
new TH1F(
"QCD_syst_low_err",
"QCD_syst_low_err",49,1.,99.);
640 TH1F *zsig_stat_err2 =
new TH1F(
"zsig_stat_err2",
"zsig_stat_err2",49,1.,99.);
641 TH1F *zback_stat_err2 =
new TH1F(
"zback_stat_err2",
"zback_stat_err2",49,1.,99.);
642 TH1F *zeemc_stat_err2 =
new TH1F(
"zeemc_stat_err2",
"zeemc_stat_err2",49,1.,99.);
645 for (
int i=1; i<=49; i++) {
646 raw_stat_err2->SetBinContent(i,signal2->GetBinContent(i));
647 QCD_stat_err2->SetBinContent(i,fabs(norm*new_bkgd->GetBinContent(i)));
648 eemc_stat_err2->SetBinContent(i,max(eemc_bkgd2->GetBinContent(i),0));
649 tau_stat_err2->SetBinContent(i,tau_norm*taufrac*tauhist->GetBinContent(i));
650 zsig_stat_err2->SetBinContent(i,Z_norm*zsig_bkgd2->GetBinContent(i));
651 zback_stat_err2->SetBinContent(i,norm*norm*Z_norm*zback_bkgd2->GetBinContent(i));
652 zeemc_stat_err2->SetBinContent(i,Z_norm*zeemc_bkgd2->GetBinContent(i));
662 TH1F *low_bkgd = new_bkgd->Clone();
663 low_bkgd->SetName(
"low_bkgd");
664 TH1F *high_bkgd = new_bkgd->Clone();
665 high_bkgd->SetName(
"high_bkgd");
669 for (
int i=7; i<=49; i++) {
672 for (
int j=0; j<=20; j++) {
673 if (new_bkgd_hists1[j]->GetBinContent(i) < low) {
674 if (new_bkgd_hists1[j]->GetBinContent(i) >= 0) {
675 low = new_bkgd_hists1[j]->GetBinContent(i);
678 if (new_bkgd_hists1[j]->GetBinContent(i) > high) {
679 high = new_bkgd_hists1[j]->GetBinContent(i);
682 if (new_bkgd_hists2[j]->GetBinContent(i) < low) {
683 if (new_bkgd_hists2[j]->GetBinContent(i) >= 0) {
684 low = new_bkgd_hists2[j]->GetBinContent(i);
687 if (new_bkgd_hists2[j]->GetBinContent(i) > high) {
688 high = new_bkgd_hists2[j]->GetBinContent(i);
691 if (new_bkgd_hists3[j]->GetBinContent(i) < low) {
692 if (new_bkgd_hists3[j]->GetBinContent(i) >= 0) {
693 low = new_bkgd_hists3[j]->GetBinContent(i);
696 if (new_bkgd_hists3[j]->GetBinContent(i) > high) {
697 high = new_bkgd_hists3[j]->GetBinContent(i);
704 low_bkgd->SetBinContent(i,0.);
705 if ((low != 10000) && (new_bkgd->GetBinContent(i)-low > 0)) {
706 if ((i >= 13)&&(i<=49)) {low_sum += low;}
707 low_bkgd->SetBinContent(i,low);
709 if ((i >= 13)&&(i<=49)) {high_sum += high;}
710 high_bkgd->SetBinContent(i,high);
714 if ((low != 10000) && (new_bkgd->GetBinContent(i)-low > 0)) {
715 QCD_syst_low_err->SetBinContent(i,new_bkgd->GetBinContent(i)-low);
717 QCD_syst_low_err->SetBinContent(i,0.);
719 QCD_syst_high_err->SetBinContent(i,high-new_bkgd->GetBinContent(i));
723 cout <<
"QCD shape sys. unc. calc************" << endl;
724 cout <<
"The QCD low sum = " << low_sum << endl;
725 cout <<
"The QCD high sum = " << high_sum << endl;
727 cout <<
"The QCD low error = " << QCD_sum-low_sum << endl;
728 cout <<
"The QCD high error = " << high_sum-QCD_sum << endl;
731 float tot_stat = sqrt(tau_stat*tau_stat+eemc_stat*eemc_stat+Z_stat*Z_stat+norm*QCD_sum);
732 cout <<
"total stat unc. is " << tot_stat << endl;
733 float tot_syst_low = sqrt(tau_syst*tau_syst+eemc_syst*eemc_syst+Z_syst*Z_syst+(QCD_sum-low_sum)*(QCD_sum-low_sum));
734 float tot_syst_high = sqrt(tau_syst*tau_syst+eemc_syst*eemc_syst+Z_syst*Z_syst+(QCD_sum-high_sum)*(QCD_sum-high_sum));
735 cout <<
"total syst unc. is low: " << tot_syst_low <<
" and high: " << tot_syst_high << endl;
736 cout <<
"total unc is low: " << sqrt(tot_syst_low*tot_syst_low+tot_stat*tot_stat) <<
" high: " << sqrt(tot_syst_high*tot_syst_high+tot_stat*tot_stat) <<endl;
739 TH1F *signal_final3 =
new TH1F(
"signal_final3",
"signal_final3",49,1.,99.);
740 for (
int i=1; i<=49; i++) {
741 signal_final3->SetBinContent(i,signal_final2->GetBinContent(i));
743 signal_final3->Add(new_bkgd,-1.);
748 cout<<
"ET min, ET max, N_obs, N_obs-Nbkgd, QCD stat, EEMC stat, Tau stat, Zee stat, QCD syst+, QCD syst-, total stat, MC bkgd tot"<<endl;
749 for (
int i=7; i<=49; i=i+2) {
750 cout.setf(ios::fixed);
752 float Qcd_stat_err2=QCD_stat_err2->GetBinContent(i)+QCD_stat_err2->GetBinContent(i+1);
753 float Eemc_stat_err2=eemc_stat_err2->GetBinContent(i)+eemc_stat_err2->GetBinContent(i+1);
754 float Tau_stat_err2=tau_stat_err2->GetBinContent(i)+tau_stat_err2->GetBinContent(i+1);
755 float Z_stat_err2=zsig_stat_err2->GetBinContent(i)+zsig_stat_err2->GetBinContent(i+1);
756 cout << signal2->GetBinCenter(i)-1 <<
"," << signal2->GetBinCenter(i)+3 <<
"," << signal2->GetBinContent(i)+signal2->GetBinContent(i+1) <<
"," << signal_final3->GetBinContent(i)+signal_final3->GetBinContent(i+1) <<
"," << sqrt(Qcd_stat_err2) <<
"," << sqrt(Eemc_stat_err2) <<
"," << sqrt(Tau_stat_err2) <<
"," << sqrt(Z_stat_err2) <<
"," << QCD_syst_high_err->GetBinContent(i)+QCD_syst_high_err->GetBinContent(i+1) <<
"," << QCD_syst_low_err->GetBinContent(i)+QCD_syst_low_err->GetBinContent(i+1) ;
758 cout<<
"," <<sqrt(Tau_stat_err2+Z_stat_err2+Qcd_stat_err2+Eemc_stat_err2);
760 cout<<
"," << zsig_bkgd2->GetBinContent(i)+zsig_bkgd2->GetBinContent(i+1) + tauhist->GetBinContent(i)+tauhist->GetBinContent(i+1)<<endl;
771 TFile *f2 =
new TFile(
"bkgd_histos_pos_final.root",
"recreate");
772 }
else if (charge == -1) {
773 TFile *f2 =
new TFile(
"bkgd_histos_neg_final.root",
"recreate");
774 }
else if (charge == 0) {
775 TFile *f2 =
new TFile(
"bkgd_histos_sum.root",
"recreate");
780 if (two_or_four == 2) {
782 TH1F *signal_final3 =
new TH1F(
"signal_final3",
"signal_final3",49,1.,99.);
783 for (
int i=1; i<=49; i++) {
784 signal_final3->SetBinContent(i,signal_final2->GetBinContent(i));
786 signal_final3->Add(new_bkgd,-1.);
791 signal_final2->Write();
792 signal_final3->Write();
797 signal_in_norm_region->Write();
799 raw_stat_err2->Write();
800 QCD_stat_err2->Write();
801 eemc_stat_err2->Write();
802 tau_stat_err2->Write();
803 QCD_syst_high_err->Write();
804 QCD_syst_low_err->Write();
805 zsig_stat_err2->Write();
806 zback_stat_err2->Write();
807 zeemc_stat_err2->Write();
810 for (
int i=1; i<=49; i++) {
811 cout.setf(ios::fixed);
813 cout <<
" " << signal2->GetBinCenter(i) <<
" & " << signal2->GetBinContent(i) <<
" & " << signal_final3->GetBinContent(i) <<
" & " << QCD_stat_err2->GetBinContent(i) <<
" & " << eemc_stat_err2->GetBinContent(i) <<
" & " << tau_stat_err2->GetBinContent(i) <<
" & " << zsig_stat_err2->GetBinContent(i) <<
" & " << zback_stat_err2->GetBinContent(i) <<
" & " << QCD_syst_high_err->GetBinContent(i) <<
" & " << QCD_syst_low_err->GetBinContent(i) <<
" \\\\" << endl;
820 }
else if (two_or_four == 4) {
822 TH1F *tauhist_repack =
new TH1F(
"tauhist_r",
"tauhist_r",24,3.,99.);
823 TH1F *zsig_bkgd2_repack =
new TH1F(
"zsig_bkgd2_r",
"zsig_bkgd2_r",24,3,99.);
824 TH1F *signal2_repack =
new TH1F(
"signal2_r",
"signal2_r",24,3.,99.);
825 TH1F *signal_final2_repack =
new TH1F(
"signal_final2_r",
"signal_final2_r",24,3.,99.);
826 TH1F *signal_final3_repack =
new TH1F(
"signal_final3_r",
"signal_final3_r",24,3.,99.);
827 TH1F *eemc_bkgd2_repack =
new TH1F(
"eemc_bkgd2_r",
"eemc_bkgd2_r",24,3.,99.);
828 TH1F *new_bkgd_repack =
new TH1F(
"new_bkgd_r",
"new_bkgd_r",24,3.,99.);
829 TH1F *low_bkgd_repack =
new TH1F(
"low_bkgd_r",
"low_bkgd_r",24,3.,99.);
830 TH1F *high_bkgd_repack =
new TH1F(
"high_bkgd_r",
"high_bkgd_r",24,3.,99.);
831 TH1F *signal_in_norm_region_repack =
new TH1F(
"signal_in_norm_region_r",
"signal_in_norm_region_r",24,3.,99.);
833 TH1F *raw_stat_err2_repack =
new TH1F(
"raw_stat_err2_r",
"raw_stat_err2_r",24,3.,99.);
834 TH1F *QCD_stat_err2_repack =
new TH1F(
"QCD_stat_err2_r",
"QCD_stat_err2_r",24,3.,99.);
835 TH1F *eemc_stat_err2_repack =
new TH1F(
"eemc_stat_err2_r",
"eemc_stat_err2_r",24,3.,99.);
836 TH1F *tau_stat_err2_repack =
new TH1F(
"tau_stat_err2_r",
"tau_stat_err2_r",24,3.,99.);
837 TH1F *QCD_syst_high_err_repack =
new TH1F(
"QCD_syst_high_err_r",
"QCD_syst_high_err_r",24,3.,99.);
838 TH1F *QCD_syst_low_err_repack =
new TH1F(
"QCD_syst_low_err_r",
"QCD_syst_low_err_r",24,3.,99.);
839 TH1F *zsig_stat_err2_repack =
new TH1F(
"zsig_stat_err2_r",
"zsig_stat_err2_r",24,3.,99.);
840 TH1F *zback_stat_err2_repack =
new TH1F(
"zback_stat_err2_r",
"zback_stat_err2_r",24,3.,99.);
841 TH1F *zeemc_stat_err2_repack =
new TH1F(
"zeemc_stat_err2_r",
"zeemc_stat_err2_r",24,3.,99.);
843 for (
int i=1; i<=24; i++) {
844 tauhist_repack->SetBinContent(i,tauhist->GetBinContent(2*i)+
845 tauhist->GetBinContent(2*i+1));
846 zsig_bkgd2_repack->SetBinContent(i,zsig_bkgd2->GetBinContent(2*i)+
847 zsig_bkgd2->GetBinContent(2*i+1));;
848 signal2_repack->SetBinContent(i,signal2->GetBinContent(2*i)+
849 signal2->GetBinContent(2*i+1));
850 signal_final2_repack->SetBinContent(i,signal_final2->GetBinContent(2*i)+
851 signal_final2->GetBinContent(2*i+1));
852 signal_final3_repack->SetBinContent(i,signal_final3->GetBinContent(2*i)+
853 signal_final3->GetBinContent(2*i+1));
854 eemc_bkgd2_repack->SetBinContent(i,eemc_bkgd2->GetBinContent(2*i)+
855 eemc_bkgd2->GetBinContent(2*i+1));
856 new_bkgd_repack->SetBinContent(i,new_bkgd->GetBinContent(2*i)+
857 new_bkgd->GetBinContent(2*i+1));
858 low_bkgd_repack->SetBinContent(i,low_bkgd->GetBinContent(2*i)+
859 low_bkgd->GetBinContent(2*i+1));
860 high_bkgd_repack->SetBinContent(i,high_bkgd->GetBinContent(2*i)+
861 high_bkgd->GetBinContent(2*i+1));
862 signal_in_norm_region_repack->SetBinContent(i,signal_in_norm_region->GetBinContent(2*i)+signal_in_norm_region->GetBinContent(2*i+1));
864 raw_stat_err2_repack->SetBinContent(i,raw_stat_err2->GetBinContent(2*i)+
865 raw_stat_err2->GetBinContent(2*i+1));
866 QCD_stat_err2_repack->SetBinContent(i,QCD_stat_err2->GetBinContent(2*i)+
867 QCD_stat_err2->GetBinContent(2*i+1));
868 eemc_stat_err2_repack->SetBinContent(i,eemc_stat_err2->GetBinContent(2*i)+
869 eemc_stat_err2->GetBinContent(2*i+1));
870 tau_stat_err2_repack->SetBinContent(i,tau_stat_err2->GetBinContent(2*i)+
871 tau_stat_err2->GetBinContent(2*i+1));
872 QCD_syst_high_err_repack->SetBinContent(i,QCD_syst_high_err->GetBinContent(2*i)+QCD_syst_high_err->GetBinContent(2*i+1));
873 QCD_syst_low_err_repack->SetBinContent(i,QCD_syst_low_err->GetBinContent(2*i)+QCD_syst_low_err->GetBinContent(2*i+1));
874 zsig_stat_err2_repack->SetBinContent(i,zsig_stat_err2->GetBinContent(2*i)+
875 zback_stat_err2->GetBinContent(2*i+1));
876 zback_stat_err2_repack->SetBinContent(i,zback_stat_err2->GetBinContent(2*i)+
877 zback_stat_err2->GetBinContent(2*i+1));
878 zeemc_stat_err2_repack->SetBinContent(i,zeemc_stat_err2->GetBinContent(2*i)+
879 zeemc_stat_err2->GetBinContent(2*i+1));
882 tauhist_repack->Write();
883 zsig_bkgd2_repack->Write();
884 signal2_repack->Write();
885 signal_final2_repack->Write();
886 signal_final3_repack->Write();
887 eemc_bkgd2_repack->Write();
888 new_bkgd_repack->Write();
889 low_bkgd_repack->Write();
890 high_bkgd_repack->Write();
891 signal_in_norm_region_repack->Write();
893 raw_stat_err2_repack->Write();
894 QCD_stat_err2_repack->Write();
895 eemc_stat_err2_repack->Write();
896 tau_stat_err2_repack->Write();
897 QCD_syst_high_err_repack->Write();
898 QCD_syst_low_err_repack->Write();
899 zsig_stat_err2_repack->Write();
900 zback_stat_err2_repack->Write();
901 zeemc_stat_err2_repack->Write();
904 for (
int i=1; i<=24; i++) {
905 cout.setf(ios::fixed);
907 cout <<
" " << signal2_repack->GetBinCenter(i) <<
" & " << signal2_repack->GetBinContent(i) <<
" & " << signal_final3_repack->GetBinContent(i) <<
" & " << QCD_stat_err2_repack->GetBinContent(i) <<
" & " << eemc_stat_err2_repack->GetBinContent(i) <<
" & " << tau_stat_err2_repack->GetBinContent(i) <<
" & " << zsig_stat_err2_repack->GetBinContent(i) <<
" & " << zback_stat_err2_repack->GetBinContent(i) <<
" & " << QCD_syst_high_err_repack->GetBinContent(i) <<
" & " << QCD_syst_low_err_repack->GetBinContent(i) <<
" \\\\" << endl;