21 void makeBkgdFilesEta(
int charge=1,
int two_or_four=4,
int etaLow=0,
int etaHigh=100) {
28 string dataDir=
"/star/data01/pwg/stevens4/wAnalysis/xSecPaper/sl11b/data/";
29 string dataName=
"run9setABCD.wana.hist.root";
31 gStyle->SetOptDate(0);
32 TFile *f1 =
new TFile(Form(
"%s%s",dataDir,dataName));
36 TH1F *signal = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_wE_etaBin"))->ProjectionY(
"signal_py",etaLow,etaHigh);
37 TH1F *signal_wo_eemc = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_noE_etaBin"))->ProjectionY(
"signal_no_eemc_py",etaLow,etaHigh);
38 }
else if (charge == -1) {
39 TH1F *signal = (TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_wE_etaBin"))->ProjectionY(
"signal_py",etaLow,etaHigh);
40 TH1F *signal_wo_eemc = (TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_noE_etaBin"))->ProjectionY(
"signal_no_eemc_py",etaLow,etaHigh);
41 }
else if (charge == 0) {
42 TH1F *signal = (TH1F*)f1->Get(
"muclustPtBal");
43 TH1F *signal_wo_eemc = (TH1F*)f1->Get(
"muclustPtBalnoE");
52 string mcDir=
"/star/u/stevens4/wAnalysis/efficXsec/outEmb/gainUp2/";
56 MC_fs[0] =
new TFile(Form(
"%sWplus%s.wana.hist.root",mcDir,tpcHV));
57 MC_fs[1] =
new TFile(Form(
"%sWminus%s.wana.hist.root",mcDir,tpcHV));
58 MC_fs[2] =
new TFile(Form(
"%sWtau%s.wana.hist.root",mcDir,tpcHV));
59 MC_fs[3] =
new TFile(Form(
"%sZany%s.wana.hist.root",mcDir,tpcHV));
60 MC_fs[4] =
new TFile(Form(
"%sZe+e-Interf%s.wana.hist.root",mcDir,tpcHV));
63 TH1F *MC_dists_raw[5][3];
64 for (
int i=0; i<5; i++) {
66 MC_dists_raw[i][0] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_wE_etaBin"))->ProjectionY(Form(
"%d_0_py",i),etaLow,etaHigh);
67 MC_dists_raw[i][1] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_noE_etaBin"))->ProjectionY(Form(
"%d_1_py",i),etaLow,etaHigh);
68 MC_dists_raw[i][2] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"pos_muclustpTbal_back_etaBin"))->ProjectionY(Form(
"%d_2_py",i),etaLow,etaHigh);
70 }
else if (charge == -1) {
71 MC_dists_raw[i][0] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_wE_etaBin"))->ProjectionY(Form(
"%d_0_py",i),etaLow,etaHigh);
72 MC_dists_raw[i][1] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_noE_etaBin"))->ProjectionY(Form(
"%d_1_py",i),etaLow,etaHigh);
73 MC_dists_raw[i][2] = (TH1F*)((TH2F*)MC_fs[i]->Get(
"neg_muclustpTbal_back_etaBin"))->ProjectionY(Form(
"%d_2_py",i),etaLow,etaHigh);
74 }
else if (charge == 0) {
75 MC_dists_raw[i][0] = (TH1F*)MC_fs[i]->Get(
"muclustPtBal");
76 MC_dists_raw[i][1] = (TH1F*)MC_fs[i]->Get(
"muclustPtBalnoE");
77 MC_dists_raw[i][2] = (TH1F*)MC_fs[i]->Get(
"muclustPtBal_bckgrd");
82 float lumi[5] = {128.6,385.0,96.2,53.1,531.9};
86 for (
int i=0; i<5; i++) {lumi_fact[i] = 13.18/lumi[i];}
87 for (
int i=0; i<5; i++) {
88 for (
int j=0; j<3; j++) {
89 MC_dists_raw[i][j]->Scale(lumi_fact[i]);
97 TH1F *MC_dists_repack[5][3];
98 for (
int i=0; i<5; i++) {
99 sprintf(str,
"mcclustPtBal_%d",i);
100 MC_dists_repack[i][0] =
new TH1F(str,str,49,1.,99.);
101 sprintf(str,
"mcclustPtBalnoE_%d",i);
102 MC_dists_repack[i][1] =
new TH1F(str,str,49,1.,99.);
103 sprintf(str,
"mcclustPtBal_bckgrd_%d",i);
104 MC_dists_repack[i][2] =
new TH1F(str,str,49,1.,99.);
107 for (
int i=0; i<5; i++) {
108 for (
int j=0; j<3; j++) {
109 for (
int k=1; k<=49; k++) {
110 MC_dists_repack[i][j]->SetBinContent(k,MC_dists_raw[i][j]->GetBinContent(2*k)+MC_dists_raw[i][j]->GetBinContent(2*k+1));
116 for (
int i=0; i<5; i++) {
117 MC_dists_repack[i][1]->Add(MC_dists_repack[i][0],-1);
118 MC_dists_raw[i][1]->Add(MC_dists_raw[i][0],-1.);
125 TH1F *eemc_bkgd = signal_wo_eemc->Clone();
126 eemc_bkgd->Add(signal,-1.);
127 eemc_bkgd->Add(MC_dists_raw[4][1],-1.);
129 TH1F *signal_final = signal->Clone();
130 signal_final->Add(eemc_bkgd,-1);
133 TH1F *eemc_bkgd2 =
new TH1F(
"eemc_bkgd2",
"eemc_bkgd2",49,1,99);
134 TH1F *zsig_bkgd2 =
new TH1F(
"zsig_bkgd2",
"zsig_bkgd2",49,1,99);
135 TH1F *zeemc_bkgd2 =
new TH1F(
"zeemc_bgkd2",
"zeemc_bkgd2",49,1,99);
136 TH1F *zback_bkgd2 =
new TH1F(
"zback_bkgd2",
"zback_bkgd2",49,1,99);
138 TH1F *zanysig_bkgd2 =
new TH1F(
"zanysig_bkgd2",
"zanysig_bkgd2",49,1,99);
139 TH1F *zanyeemc_bkgd2 =
new TH1F(
"zanyeemc_bgkd2",
"zanyeemc_bkgd2",49,1,99);
140 TH1F *zanyback_bkgd2 =
new TH1F(
"zanyback_bkgd2",
"zanyback_bkgd2",49,1,99);
142 TH1F *zsig = MC_dists_raw[4][0]->Clone();
143 TH1F *zeemc = MC_dists_raw[4][1]->Clone();
144 TH1F *zback = MC_dists_raw[4][2]->Clone();
147 signal_final->Add(zsig,-1.);
150 TH1F *bkgd_shape1 = (TH1F*)((TH2F*)f1->Get(
"pos_muclustpTbal_back_etaBin"))->ProjectionY(
"back1_py",etaLow,etaHigh);
151 bkgd_shape1->Add((TH1F*)((TH2F*)f1->Get(
"neg_muclustpTbal_back_etaBin"))->ProjectionY(
"back2_py",etaLow,etaHigh));
154 TH1F *bkgd_shape_nom =
new TH1F(
"bkgd_shape",
"bkgd_shape",49,1,99);
155 for (
int i=1; i<=49; i++) {
156 bkgd_shape_nom->SetBinContent(i,bkgd_shape1->GetBinContent(2*i)+
157 bkgd_shape1->GetBinContent(2*i+1));
159 TH1F *bkgd_shape_nom2 = bkgd_shape_nom->Clone();
161 TH1F *signal_final2 =
new TH1F(
"signal_final2",
"signal_final2",49,1,99);
162 signal_final2->SetLineColor(2);
163 signal_final2->SetLineWidth(2.*signal_final2->GetLineWidth());
164 TH1F *signal2 =
new TH1F(
"signal2",
"signal2",49,1,99);
165 for (
int i=1; i<=49; i++) {
166 signal_final2->SetBinContent(i,signal_final->GetBinContent(2*i)+
167 signal_final->GetBinContent(2*i+1));
168 signal2->SetBinContent(i,signal->GetBinContent(2*i)+
169 signal->GetBinContent(2*i+1));
170 eemc_bkgd2->SetBinContent(i,eemc_bkgd->GetBinContent(2*i)+
171 eemc_bkgd->GetBinContent(2*i+1));
172 zsig_bkgd2->SetBinContent(i,zsig->GetBinContent(2*i)+
173 zsig->GetBinContent(2*i+1));
174 zeemc_bkgd2->SetBinContent(i,zeemc->GetBinContent(2*i)+
175 zeemc->GetBinContent(2*i+1));
176 zback_bkgd2->SetBinContent(i,zback->GetBinContent(2*i)+
177 zback->GetBinContent(2*i+1));
178 zanysig_bkgd2->SetBinContent(i,MC_dists_raw[3][0]->GetBinContent(2*i)+
179 MC_dists_raw[3][0]->GetBinContent(2*i+1));
180 zanyeemc_bkgd2->SetBinContent(i,MC_dists_raw[3][1]->GetBinContent(2*i)+
181 MC_dists_raw[3][1]->GetBinContent(2*i+1));
182 zanyback_bkgd2->SetBinContent(i,MC_dists_raw[3][2]->GetBinContent(2*i)+
183 MC_dists_raw[3][2]->GetBinContent(2*i+1));
186 TCanvas *can2 =
new TCanvas(
"can2",
"can2",0,0,600,400);
188 signal_final2->Draw(
"same");
196 eemc_bkgd->SetLineColor(8);
197 eemc_bkgd->SetLineWidth(2.*eemc_bkgd->GetLineWidth());
198 bkgd_shape_nom2->SetLineColor(4);
199 bkgd_shape_nom2->SetLineWidth(2.*bkgd_shape_nom2->GetLineWidth());
201 TCanvas *can8 =
new TCanvas(
"can8",
"can8",0,0,3000,1800);
203 for (
int i=0; i<5; i++) {
204 for (
int j=0; j<3; j++) {
210 signal_final2->Draw();
216 bkgd_shape_nom2->Draw();
218 MC_dists_repack[i][j]->Draw(
"same");
224 for (
int i=0; i<5; i++) {
225 float signal_sum = 0.;
228 for (
int j=13; j<=49; j++) {
229 signal_sum += MC_dists_repack[i][0]->GetBinContent(j);
230 eemc_sum += MC_dists_repack[i][1]->GetBinContent(j);
231 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",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",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);
469 for (
int m=1; m<=49; m++) {
470 if (bkgd_shape_unnorm1[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm1[l]->SetBinContent(m,0.);}
472 signal_for_new1[l]->Add(bkgd_shape_unnorm1[l],-1.);
473 signal_for_new1[l]->Fit(func1,
"RQ");
476 normt = 0.; normb = 0.;
477 for (
int k=8; k<=9; k++) {
478 if (bkgd_shape_unnorm2[l]->GetBinContent(k) > 0) {
479 normt += signal_final2->GetBinContent(k)-signal_in_norm2[k];
480 normb += bkgd_shape_unnorm2[l]->GetBinContent(k);
483 if (normb > 0 && normt > 0) {
484 float norm = normt/normb;
485 bkgd_shape_unnorm2[l]->Scale(norm);
488 else if(normb > 0 && normt < 0){
490 bkgd_shape_unnorm2[l]->Scale(norm);
492 for (
int m=1; m<=49; m++) {
493 if (bkgd_shape_unnorm2[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm2[l]->SetBinContent(m,0.);}
495 signal_for_new2[l]->Add(bkgd_shape_unnorm2[l],-1.);
496 signal_for_new2[l]->Fit(func2,
"RQ");
499 normt = 0.; normb = 0.;
500 for (
int k=8; k<=10; k++) {
501 if (bkgd_shape_unnorm3[l]->GetBinContent(k) > 0) {
502 normt += signal_final2->GetBinContent(k)-signal_in_norm3[k];
503 normb += bkgd_shape_unnorm3[l]->GetBinContent(k);
506 if (normb > 0 && normt > 0) {
507 float norm = normt/normb;
508 bkgd_shape_unnorm3[l]->Scale(norm);
510 else if(normb > 0 && normt < 0){
512 bkgd_shape_unnorm3[l]->Scale(norm);
515 for (
int m=1; m<=49; m++) {
516 if (bkgd_shape_unnorm3[l]->GetBinContent(m) < 0) {bkgd_shape_unnorm3[l]->SetBinContent(m,0.);}
518 signal_for_new3[l]->Add(bkgd_shape_unnorm3[l],-1.);
519 signal_for_new3[l]->Fit(func3,
"RQ");
523 new_bkgd_hists1[i] = (TH1F*)bkgd_shape_unnorm1[19]->Clone();
524 new_bkgd_hists2[i] = (TH1F*)bkgd_shape_unnorm2[19]->Clone();
525 new_bkgd_hists3[i] = (TH1F*)bkgd_shape_unnorm3[19]->Clone();
530 gStyle->SetTitleBorderSize(0);
531 TCanvas *can6 =
new TCanvas(
"can6",
"can6",0,0,600,400);
532 signal_final2->SetStats(kFALSE);
534 signal_final2->SetTitle(
"W+ Background Shapes");
535 }
else if (charge == -1) {
536 signal_final2->SetTitle(
"W- Background Shapes");
538 signal_final2->GetXaxis()->SetRangeUser(0.,70.);
539 signal_final2->GetXaxis()->SetTitle(
"2x2 Cluster E_{T} (GeV)");
540 signal_final2->Draw();
541 for (
int i=0; i<=20; i++) {
542 new_bkgd_hists1[i]->Draw(
"same");
543 new_bkgd_hists2[i]->Draw(
"same");
544 new_bkgd_hists3[i]->Draw(
"same");
546 new_bkgd->SetLineColor(4);
548 new_bkgd->Draw(
"same");
552 }
else if (charge == -1) {
557 TH1F *chi2s =
new TH1F(
"chi2s",
"chi2s",50,0.,10.);
558 for (
int i=0; i<=20; i++) {
559 chi2s->Fill(final_chisquare[i]);
562 TCanvas *can7 =
new TCanvas(
"can7",
"can7",0,0,600,400);
573 TH1F *tauhist = MC_dists_repack[2][0]->Clone();
574 tauhist->Scale(taufrac);
575 float tau_norm = lumi_fact[2];
576 float Z_norm = lumi_fact[4];
578 float signal_sum = 0.;
580 float QCD_sum = 0., tau_sum = 0., eemc_sum = 0.;
581 float QCD_raw_sum = 0.;
582 float Zany_bkgd_sum = 0.;
583 float Zany_eemc_sum = 0.;
584 float zsig_sum = 0., zeemc_sum = 0.,zback_sum = 0.;
585 float zanysig_sum = 0., zanyeemc_sum = 0.,zanyback_sum = 0.;
586 for (
int i=13; i<=49; i++) {
587 bkgd_sum += new_bkgd->GetBinContent(i);
588 bkgd_sum += tauhist->GetBinContent(i);
589 bkgd_sum += eemc_bkgd2->GetBinContent(i);
590 QCD_raw_sum += bkgd_shape_nom->GetBinContent(i);
591 QCD_sum += new_bkgd->GetBinContent(i);
592 tau_sum += tauhist->GetBinContent(i);
593 eemc_sum += eemc_bkgd2->GetBinContent(i);
594 signal_sum += signal_final2->GetBinContent(i);
595 raw_sum += signal2->GetBinContent(i);
596 zsig_sum += zsig_bkgd2->GetBinContent(i);
597 zeemc_sum += zeemc_bkgd2->GetBinContent(i);
598 zback_sum += zback_bkgd2->GetBinContent(i);
599 zanysig_sum += zanysig_bkgd2->GetBinContent(i);
600 zanyeemc_sum += zanyeemc_bkgd2->GetBinContent(i);
601 zanyback_sum += zanyback_bkgd2->GetBinContent(i);
603 cout <<
"The total background for ET>25 is " << bkgd_sum+zsig_sum << endl;
604 cout <<
"QCD = " << QCD_sum <<
", tau = " << tau_sum <<
", eemc = " << eemc_sum <<
", and Z = " << zsig_sum << endl;
605 cout <<
"Raw = " << raw_sum << endl;
606 cout <<
"W Signal (w/o tau) = " << signal_sum-QCD_sum << endl;
607 cout <<
"Z in sig = " << zsig_sum << endl;
608 cout <<
"Z in eemc = " << zeemc_sum << endl;
609 cout <<
"Z in back = " << zback_sum << endl;
610 cout <<
"Zany in sig = " << zanysig_sum << endl;
611 cout <<
"Zany in eemc = " << zanyeemc_sum << endl;
612 cout <<
"Zany in back = " << zanyback_sum << endl;
613 cout <<
"QCD raw in back = " << QCD_raw_sum << endl;
614 cout <<
"The QCD stat unc. is " << sqrt(norm*QCD_sum) << endl;
615 float tau_stat = tau_norm*taufrac*sqrt(tau_sum/(tau_norm*taufrac));
616 float tau_syst = 0.13*tau_sum;
617 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;
618 float eemc_stat = sqrt(eemc_sum);
619 float eemc_syst = 0.13*zeemc_sum;
620 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;
621 float Z_stat = Z_norm*sqrt(zsig_sum/Z_norm);
622 float Z_syst = 0.13*zsig_sum;
623 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;
632 TH1F *raw_stat_err2 =
new TH1F(
"raw_stat_err2",
"raw_stat_err2",49,1.,99.);
633 TH1F *QCD_stat_err2 =
new TH1F(
"QCD_stat_err2",
"QCD_stat_err2",49,1.,99.);
634 TH1F *eemc_stat_err2 =
new TH1F(
"eemc_stat_err2",
"eemc_stat_err2",49,1.,99.);
635 TH1F *tau_stat_err2 =
new TH1F(
"tau_stat_err2",
"tau_stat_err2",49,1.,99.);
636 TH1F *QCD_syst_high_err =
new TH1F(
"QCD_syst_high_err",
"QCD_syst_high_err",49,1.,99.);
637 TH1F *QCD_syst_low_err =
new TH1F(
"QCD_syst_low_err",
"QCD_syst_low_err",49,1.,99.);
638 TH1F *zsig_stat_err2 =
new TH1F(
"zsig_stat_err2",
"zsig_stat_err2",49,1.,99.);
639 TH1F *zback_stat_err2 =
new TH1F(
"zback_stat_err2",
"zback_stat_err2",49,1.,99.);
640 TH1F *zeemc_stat_err2 =
new TH1F(
"zeemc_stat_err2",
"zeemc_stat_err2",49,1.,99.);
643 for (
int i=1; i<=49; i++) {
644 raw_stat_err2->SetBinContent(i,signal2->GetBinContent(i));
645 QCD_stat_err2->SetBinContent(i,fabs(norm*new_bkgd->GetBinContent(i)));
646 eemc_stat_err2->SetBinContent(i,max(eemc_bkgd2->GetBinContent(i),0));
647 tau_stat_err2->SetBinContent(i,tau_norm*taufrac*tauhist->GetBinContent(i));
648 zsig_stat_err2->SetBinContent(i,Z_norm*zsig_bkgd2->GetBinContent(i));
649 zback_stat_err2->SetBinContent(i,norm*norm*Z_norm*zback_bkgd2->GetBinContent(i));
650 zeemc_stat_err2->SetBinContent(i,Z_norm*zeemc_bkgd2->GetBinContent(i));
659 TH1F *low_bkgd = new_bkgd->Clone();
660 low_bkgd->SetName(
"low_bkgd");
661 TH1F *high_bkgd = new_bkgd->Clone();
662 high_bkgd->SetName(
"high_bkgd");
666 for (
int i=7; i<=49; i++) {
669 for (
int j=0; j<=20; j++) {
670 if (new_bkgd_hists1[j]->GetBinContent(i) < low) {
671 if (new_bkgd_hists1[j]->GetBinContent(i) >= 0) {
672 low = new_bkgd_hists1[j]->GetBinContent(i);
675 if (new_bkgd_hists1[j]->GetBinContent(i) > high) {
676 high = new_bkgd_hists1[j]->GetBinContent(i);
679 if (new_bkgd_hists2[j]->GetBinContent(i) < low) {
680 if (new_bkgd_hists2[j]->GetBinContent(i) >= 0) {
681 low = new_bkgd_hists2[j]->GetBinContent(i);
684 if (new_bkgd_hists2[j]->GetBinContent(i) > high) {
685 high = new_bkgd_hists2[j]->GetBinContent(i);
688 if (new_bkgd_hists3[j]->GetBinContent(i) < low) {
689 if (new_bkgd_hists3[j]->GetBinContent(i) >= 0) {
690 low = new_bkgd_hists3[j]->GetBinContent(i);
693 if (new_bkgd_hists3[j]->GetBinContent(i) > high) {
694 high = new_bkgd_hists3[j]->GetBinContent(i);
701 low_bkgd->SetBinContent(i,0.);
702 if ((low != 10000) && (new_bkgd->GetBinContent(i)-low > 0)) {
703 if ((i >= 13)&&(i<=49)) {low_sum += low;}
704 low_bkgd->SetBinContent(i,low);
706 if ((i >= 13)&&(i<=49)) {high_sum += high;}
707 high_bkgd->SetBinContent(i,high);
711 if ((low != 10000) && (new_bkgd->GetBinContent(i)-low > 0)) {
712 QCD_syst_low_err->SetBinContent(i,new_bkgd->GetBinContent(i)-low);
714 QCD_syst_low_err->SetBinContent(i,0.);
716 QCD_syst_high_err->SetBinContent(i,high-new_bkgd->GetBinContent(i));
720 cout <<
"QCD shape sys. unc. calc************" << endl;
721 cout <<
"The QCD low sum = " << low_sum << endl;
722 cout <<
"The QCD high sum = " << high_sum << endl;
724 cout <<
"The QCD low error = " << QCD_sum-low_sum << endl;
725 cout <<
"The QCD high error = " << high_sum-QCD_sum << endl;
728 float tot_stat = sqrt(tau_stat*tau_stat+eemc_stat*eemc_stat+Z_stat*Z_stat+norm*QCD_sum);
729 cout <<
"total stat unc. is " << tot_stat << endl;
730 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));
731 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));
732 cout <<
"total syst unc. is low: " << tot_syst_low <<
" and high: " << tot_syst_high << endl;
733 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;
736 TH1F *signal_final3 =
new TH1F(
"signal_final3",
"signal_final3",49,1.,99.);
737 for (
int i=1; i<=49; i++) {
738 signal_final3->SetBinContent(i,signal_final2->GetBinContent(i));
740 signal_final3->Add(new_bkgd,-1.);
745 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;
746 for (
int i=7; i<=49; i=i+2) {
747 cout.setf(ios::fixed);
749 float Qcd_stat_err2=QCD_stat_err2->GetBinContent(i)+QCD_stat_err2->GetBinContent(i+1);
750 float Eemc_stat_err2=eemc_stat_err2->GetBinContent(i)+eemc_stat_err2->GetBinContent(i+1);
751 float Tau_stat_err2=tau_stat_err2->GetBinContent(i)+tau_stat_err2->GetBinContent(i+1);
752 float Z_stat_err2=zsig_stat_err2->GetBinContent(i)+zsig_stat_err2->GetBinContent(i+1);
753 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) ;
755 cout<<
"," <<sqrt(Tau_stat_err2+Z_stat_err2+Qcd_stat_err2+Eemc_stat_err2);
757 cout<<
"," << zsig_bkgd2->GetBinContent(i)+zsig_bkgd2->GetBinContent(i+1) + tauhist->GetBinContent(i)+tauhist->GetBinContent(i+1)<<endl;
768 TFile *f2 =
new TFile(
"bkgd_histos_pos_final.root",
"recreate");
769 }
else if (charge == -1) {
770 TFile *f2 =
new TFile(
"bkgd_histos_neg_final.root",
"recreate");
771 }
else if (charge == 0) {
772 TFile *f2 =
new TFile(
"bkgd_histos_sum.root",
"recreate");
777 if (two_or_four == 2) {
779 TH1F *signal_final3 =
new TH1F(
"signal_final3",
"signal_final3",49,1.,99.);
780 for (
int i=1; i<=49; i++) {
781 signal_final3->SetBinContent(i,signal_final2->GetBinContent(i));
783 signal_final3->Add(new_bkgd,-1.);
788 signal_final2->Write();
789 signal_final3->Write();
794 signal_in_norm_region->Write();
796 raw_stat_err2->Write();
797 QCD_stat_err2->Write();
798 eemc_stat_err2->Write();
799 tau_stat_err2->Write();
800 QCD_syst_high_err->Write();
801 QCD_syst_low_err->Write();
802 zsig_stat_err2->Write();
803 zback_stat_err2->Write();
804 zeemc_stat_err2->Write();
807 for (
int i=1; i<=49; i++) {
808 cout.setf(ios::fixed);
810 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;
817 }
else if (two_or_four == 4) {
819 TH1F *tauhist_repack =
new TH1F(
"tauhist_r",
"tauhist_r",24,3.,99.);
820 TH1F *zsig_bkgd2_repack =
new TH1F(
"zsig_bkgd2_r",
"zsig_bkgd2_r",24,3,99.);
821 TH1F *signal2_repack =
new TH1F(
"signal2_r",
"signal2_r",24,3.,99.);
822 TH1F *signal_final2_repack =
new TH1F(
"signal_final2_r",
"signal_final2_r",24,3.,99.);
823 TH1F *signal_final3_repack =
new TH1F(
"signal_final3_r",
"signal_final3_r",24,3.,99.);
824 TH1F *eemc_bkgd2_repack =
new TH1F(
"eemc_bkgd2_r",
"eemc_bkgd2_r",24,3.,99.);
825 TH1F *new_bkgd_repack =
new TH1F(
"new_bkgd_r",
"new_bkgd_r",24,3.,99.);
826 TH1F *low_bkgd_repack =
new TH1F(
"low_bkgd_r",
"low_bkgd_r",24,3.,99.);
827 TH1F *high_bkgd_repack =
new TH1F(
"high_bkgd_r",
"high_bkgd_r",24,3.,99.);
828 TH1F *signal_in_norm_region_repack =
new TH1F(
"signal_in_norm_region_r",
"signal_in_norm_region_r",24,3.,99.);
830 TH1F *raw_stat_err2_repack =
new TH1F(
"raw_stat_err2_r",
"raw_stat_err2_r",24,3.,99.);
831 TH1F *QCD_stat_err2_repack =
new TH1F(
"QCD_stat_err2_r",
"QCD_stat_err2_r",24,3.,99.);
832 TH1F *eemc_stat_err2_repack =
new TH1F(
"eemc_stat_err2_r",
"eemc_stat_err2_r",24,3.,99.);
833 TH1F *tau_stat_err2_repack =
new TH1F(
"tau_stat_err2_r",
"tau_stat_err2_r",24,3.,99.);
834 TH1F *QCD_syst_high_err_repack =
new TH1F(
"QCD_syst_high_err_r",
"QCD_syst_high_err_r",24,3.,99.);
835 TH1F *QCD_syst_low_err_repack =
new TH1F(
"QCD_syst_low_err_r",
"QCD_syst_low_err_r",24,3.,99.);
836 TH1F *zsig_stat_err2_repack =
new TH1F(
"zsig_stat_err2_r",
"zsig_stat_err2_r",24,3.,99.);
837 TH1F *zback_stat_err2_repack =
new TH1F(
"zback_stat_err2_r",
"zback_stat_err2_r",24,3.,99.);
838 TH1F *zeemc_stat_err2_repack =
new TH1F(
"zeemc_stat_err2_r",
"zeemc_stat_err2_r",24,3.,99.);
840 for (
int i=1; i<=24; i++) {
841 tauhist_repack->SetBinContent(i,tauhist->GetBinContent(2*i)+
842 tauhist->GetBinContent(2*i+1));
843 zsig_bkgd2_repack->SetBinContent(i,zsig_bkgd2->GetBinContent(2*i)+
844 zsig_bkgd2->GetBinContent(2*i+1));;
845 signal2_repack->SetBinContent(i,signal2->GetBinContent(2*i)+
846 signal2->GetBinContent(2*i+1));
847 signal_final2_repack->SetBinContent(i,signal_final2->GetBinContent(2*i)+
848 signal_final2->GetBinContent(2*i+1));
849 signal_final3_repack->SetBinContent(i,signal_final3->GetBinContent(2*i)+
850 signal_final3->GetBinContent(2*i+1));
851 eemc_bkgd2_repack->SetBinContent(i,eemc_bkgd2->GetBinContent(2*i)+
852 eemc_bkgd2->GetBinContent(2*i+1));
853 new_bkgd_repack->SetBinContent(i,new_bkgd->GetBinContent(2*i)+
854 new_bkgd->GetBinContent(2*i+1));
855 low_bkgd_repack->SetBinContent(i,low_bkgd->GetBinContent(2*i)+
856 low_bkgd->GetBinContent(2*i+1));
857 high_bkgd_repack->SetBinContent(i,high_bkgd->GetBinContent(2*i)+
858 high_bkgd->GetBinContent(2*i+1));
859 signal_in_norm_region_repack->SetBinContent(i,signal_in_norm_region->GetBinContent(2*i)+signal_in_norm_region->GetBinContent(2*i+1));
861 raw_stat_err2_repack->SetBinContent(i,raw_stat_err2->GetBinContent(2*i)+
862 raw_stat_err2->GetBinContent(2*i+1));
863 QCD_stat_err2_repack->SetBinContent(i,QCD_stat_err2->GetBinContent(2*i)+
864 QCD_stat_err2->GetBinContent(2*i+1));
865 eemc_stat_err2_repack->SetBinContent(i,eemc_stat_err2->GetBinContent(2*i)+
866 eemc_stat_err2->GetBinContent(2*i+1));
867 tau_stat_err2_repack->SetBinContent(i,tau_stat_err2->GetBinContent(2*i)+
868 tau_stat_err2->GetBinContent(2*i+1));
869 QCD_syst_high_err_repack->SetBinContent(i,QCD_syst_high_err->GetBinContent(2*i)+QCD_syst_high_err->GetBinContent(2*i+1));
870 QCD_syst_low_err_repack->SetBinContent(i,QCD_syst_low_err->GetBinContent(2*i)+QCD_syst_low_err->GetBinContent(2*i+1));
871 zsig_stat_err2_repack->SetBinContent(i,zsig_stat_err2->GetBinContent(2*i)+
872 zback_stat_err2->GetBinContent(2*i+1));
873 zback_stat_err2_repack->SetBinContent(i,zback_stat_err2->GetBinContent(2*i)+
874 zback_stat_err2->GetBinContent(2*i+1));
875 zeemc_stat_err2_repack->SetBinContent(i,zeemc_stat_err2->GetBinContent(2*i)+
876 zeemc_stat_err2->GetBinContent(2*i+1));
879 tauhist_repack->Write();
880 zsig_bkgd2_repack->Write();
881 signal2_repack->Write();
882 signal_final2_repack->Write();
883 signal_final3_repack->Write();
884 eemc_bkgd2_repack->Write();
885 new_bkgd_repack->Write();
886 low_bkgd_repack->Write();
887 high_bkgd_repack->Write();
888 signal_in_norm_region_repack->Write();
890 raw_stat_err2_repack->Write();
891 QCD_stat_err2_repack->Write();
892 eemc_stat_err2_repack->Write();
893 tau_stat_err2_repack->Write();
894 QCD_syst_high_err_repack->Write();
895 QCD_syst_low_err_repack->Write();
896 zsig_stat_err2_repack->Write();
897 zback_stat_err2_repack->Write();
898 zeemc_stat_err2_repack->Write();
901 for (
int i=1; i<=24; i++) {
902 cout.setf(ios::fixed);
904 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;