Changeset 19 in huonglan
- Timestamp:
- Aug 30, 2011, 10:24:25 AM (13 years ago)
- Location:
- SPLOT/NEWREALEASE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
SPLOT/NEWREALEASE/sPlots_Data.C
r17 r19 81 81 TFile *file[2]; 82 82 TTree *t[2]; 83 TTree *tw[2];84 83 85 84 for (int i = 0; i < 2; i++){ 86 filename = "./MERGEFILES/res_"; filename += type[i]; filename += " v3N.root";85 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 87 86 file[i] = TFile::Open(filename); 88 87 t[i] = (TTree*)file[i]->Get("T"); 89 tw[i] = (TTree*)file[i]->Get("Tw");90 t[i]->AddFriend(tw[i]);91 88 } 92 89 … … 104 101 t[i]->GetEntry(iev); 105 102 106 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 107 double HT = t[i]->GetLeaf("HT")->GetValue(); 108 double x = t[i]->GetLeaf("cos_tlepCMtpair")->GetValue(); 109 double y = t[i]->GetLeaf("cosWqq")->GetValue(); 110 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 111 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 112 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 113 double WeiTot = WeiEvt*Wei1fb; 114 115 //cout << "WeiEvt = " << WeiEvt << endl; 116 //cout << "Wei1fb = " << Wei1fb << endl; 103 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 104 double HT = t[i]->GetLeaf("HT")->GetValue(); 105 double x = t[i]->GetLeaf("cos1")->GetValue(); 106 double y = t[i]->GetLeaf("cos2")->GetValue(); 107 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 108 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 109 117 110 //cout << "WeiTot = " << WeiTot << endl; 118 111 … … 327 320 double x = tD->GetLeaf("cos_tlepCMtpair")->GetValue(); 328 321 double y = tD->GetLeaf("cosWqq")->GetValue(); 329 double dMLep = tD->GetLeaf("MinLep1")->GetValue(); 322 double dMLep = tD->GetLeaf("MinLep1")->GetValue(); 330 323 331 324 int hasBJ = tD->GetLeaf("hasBadJet")->GetValue(); … … 383 376 cout << "sigmaN0 = " << sigmaN0 << " sigmaN1 = " << sigmaN1 << " rho = " << rho << endl; 384 377 378 //TH1F *hMTSig = new TH1F("hMTSig", "", 35, 250, 600); 379 //TH1F *hMTBkg = new TH1F("hMTBkg", "", 35, 250, 600); 385 380 TH1F *hMTSig = new TH1F("hMTSig", "", 25, 0, 1500); 386 381 TH1F *hMTBkg = new TH1F("hMTBkg", "", 25, 0, 1500); 387 TH1F *hHTSig = new TH1F("hHTSig", "", 25, 0, 2000); 388 TH1F *hHTBkg = new TH1F("hHTBkg", "", 25, 0, 2000); 389 TH2F *hHTMTSig = new TH2F("hHTMTSig", "", 25, 0, 2000, 25, 0, 1500); 390 TH2F *hHTMTBkg = new TH2F("hHTMTBkg", "", 25, 0, 2000, 25, 0, 1500); 382 383 TH1F *hHTSig = new TH1F("hHTSig", "", 50, 500, 1500); 384 TH1F *hHTBkg = new TH1F("hHTBkg", "", 50, 500, 1500); 385 386 TH2F *hMTHTSig = new TH2F("hMTHTSig", "", 35, 250, 600, 50, 500, 1500); 387 TH2F *hMTHTBkg = new TH2F("hMTHTBkg", "", 35, 250, 600, 50, 500, 1500); 391 388 392 389 TH1F *hmt[6]; … … 449 446 hHTSig->Fill(HT,sP1); 450 447 hHTBkg->Fill(HT,sP0); 451 h HTMTSig->Fill(HT,mt,sP1);452 h HTMTBkg->Fill(HT,mt,sP0);448 hMTHTSig->Fill(mt,HT,sP1); 449 hMTHTBkg->Fill(mt,HT,sP0); 453 450 sPN[icc] = sP1*sP1; 454 451 mtN[icc] = mt; … … 474 471 cout << "hMTBkg integral " << hMTBkg->Integral(0,1500) << endl; 475 472 476 // for (int i = 0; i < Nsel; i++){ 477 // cout << "mt[" << i << "] = " << mtN[i] << " "; 478 // cout << "sP[" << i << "] = " << sPN[i] << endl; 473 // for (int i = 1; i < 36; i++){ 474 // double vb1 = 250 +(i-1)*10; 475 // double vb2 = 250 + i*10; 476 // double ErrBin = 0.; 477 // for (int j = 0; j < Nsel; j++){ 478 // double mt = mtN[j]; 479 // double sp = sPN[j]; 480 // if (mt >= vb1 && mt < vb2){ 481 // ErrBin += sp; 482 // } 483 // } 484 // hMTSig->SetBinError(i,sqrt(ErrBin)); 479 485 // } 480 486 481 487 for (int i = 1; i < 26; i++){ 482 488 double vb1 = (i-1)*60; … … 493 499 } 494 500 495 for (int i = 1; i < 26; i++){496 double vb1 = (i-1)*80;497 double vb2 = i*80;501 for (int i = 1; i < 51; i++){ 502 double vb1 = 500 + (i-1)*20; 503 double vb2 = 500 + i*20; 498 504 double ErrBin = 0.; 499 505 for (int j = 0; j < Nsel; j++){ … … 510 516 c1->Divide(2); 511 517 c1->cd(1); 518 //hMTSig->Rebin(5); 512 519 hMTSig->SetLineColor(2); 513 520 hMTSig->DrawCopy("E1"); 514 521 hMTSig->SetLineColor(1); 522 hMTSig->SetLineWidth(2); 515 523 hMTSig->Draw("hist,same"); 516 524 c1->cd(2); 525 //hMTBkg->Rebin(5); 526 hMTBkg->SetLineWidth(2); 517 527 hMTBkg->Draw(); 518 528 … … 530 540 c3->Divide(2); 531 541 c3->cd(1); 532 h HTMTSig->Draw("colz");542 hMTHTSig->Draw("colz"); 533 543 c3->cd(2); 534 h HTMTBkg->Draw("colz");544 hMTHTBkg->Draw("colz"); 535 545 536 546 TCanvas *c4 = new TCanvas("c4", "", 1000, 600); … … 547 557 } 548 558 } 559 560 //############################################################## 561 //########### N0 known ######################################### 562 //############################################################## 563 564 void sPlots_Data_N0known(){ 565 //gROOT->SetStyle("Plain"); 566 //Make the table of sP values first 567 568 //Get right N0 and N1 569 //Fit(); 570 CalF0F1(); 571 MakeEventListf0f1(); 572 sig2 = sigmaMin*sigmaMin*N1*N1; 573 574 TString filename = ""; 575 //TString type[2] = {"Top_MCAtNLO_PURewei","Signal"}; 576 TString type[2] = {"AllBkgTopMCAtNLO","Signal"}; 577 TFile *file[2]; 578 TTree *t[2]; 579 580 for (int i = 0; i < 2; i++){ 581 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 582 file[i] = TFile::Open(filename); 583 t[i] = (TTree*)file[i]->Get("T"); 584 } 585 586 for (int i = 0; i < 2; i++){ 587 iTot[i] = 0; 588 } 589 590 TH1F *hBkg1fb = new TH1F("hBkg1fb", "", 35, 250, 600); 591 592 //start reading 2 files 593 for (int i = 0; i < 2; i++){ 594 int nevt = t[i]->GetEntries(); 595 for (int iev = 0; iev < nevt; iev++) { 596 t[i]->GetEntry(iev); 597 598 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 599 double HT = t[i]->GetLeaf("HT")->GetValue(); 600 double x = t[i]->GetLeaf("cos1")->GetValue(); 601 double y = t[i]->GetLeaf("cos2")->GetValue(); 602 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 603 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 604 605 double cos1 = fabs(x); 606 double cos2 = fabs(y); 607 608 int hasBJ = t[i]->GetLeaf("hasBadJet")->GetValue(); 609 double hf = t[i]->GetLeaf("hfor")->GetValue(); 610 611 if (hf!=4 && hasBJ==0){ 612 if (mt > Cut4 && HT > Cut5){ 613 iTot[i] += WeiTot; 614 if (i==0) hBkg1fb->Fill(mt,WeiTot); 615 } 616 } 617 }//Read each file 618 }//End of reading 2 files 619 620 hBkg1fb->Scale(1./hBkg1fb->Integral(0,1000)); 621 622 N1 = iTot[1]; 623 N0 = iTot[0]; 624 625 cout << "Main macro : N0 = " << N0 << " N1 = " << N1 << endl; 626 627 TH1F *hsPTot = new TH1F("hsPTot" , "", 35, 250, 600); 628 TH1F *hsP = new TH1F("hsP" , "", 35, 250, 600); 629 TH1F *hesP = new TH1F("hesP", "", 35, 250, 600); 630 631 int icount = 0; 632 TFile *fD = TFile::Open("/data/atlas/huonglan/FROMLYON/DATA/resData.root"); 633 TTree *tD = (TTree*)fD->Get("T"); 634 int nD = tD->GetEntries(); 635 for (int iev = 0; iev < nD; iev++) { 636 tD->GetEntry(iev); 637 638 double mt = tD->GetLeaf("mtophad")->GetValue(); 639 double HT = tD->GetLeaf("HT")->GetValue(); 640 double x = tD->GetLeaf("cos_tlepCMtpair")->GetValue(); 641 double y = tD->GetLeaf("cosWqq")->GetValue(); 642 double dMLep = tD->GetLeaf("MinLep1")->GetValue(); 643 644 int hasBJ = tD->GetLeaf("hasBadJet")->GetValue(); 645 int RunN = tD->GetLeaf("RunNumber_ana")->GetValue(); 646 647 if (RunN >= 180614 && hasBJ==1) continue; 648 649 double cos1 = fabs(x); 650 double cos2 = fabs(y); 651 652 //sPlots total 653 if (mt > Cut4 && HT > Cut5){ 654 icount++; 655 } 656 } 657 658 cout << "icount = " << icount << endl; 659 double k = (sig2 - N1)/(N0 - (sig2 - N1)); 660 661 double *mtV = new double[icount]; 662 double *err = new double[icount]; 663 double *errN = new double[icount]; 664 int icc = 0; 665 666 //Try standard sPlots 667 for (int iev = 0; iev < nD; iev++) { 668 tD->GetEntry(iev); 669 670 double mt = tD->GetLeaf("mtophad")->GetValue(); 671 double HT = tD->GetLeaf("HT")->GetValue(); 672 double x = tD->GetLeaf("cos_tlepCMtpair")->GetValue(); 673 double y = tD->GetLeaf("cosWqq")->GetValue(); 674 double dMLep = tD->GetLeaf("MinLep1")->GetValue(); 675 676 int hasBJ = tD->GetLeaf("hasBadJet")->GetValue(); 677 int RunN = tD->GetLeaf("RunNumber_ana")->GetValue(); 678 679 if (RunN >= 180614 && hasBJ==1) continue; 680 681 double cos1 = fabs(x); 682 double cos2 = fabs(y); 683 684 //sPlots total 685 if (mt > Cut4 && HT > Cut5){ 686 vector<double> veff = vFe(cos1,cos2,dMLep); 687 double F0e = veff.at(0); 688 double F1e = veff.at(1); 689 690 double sWei = sig2*F1e/(N1*F1e + N0*F0e); 691 double sWeiN = sWei*(k+1) - k; 692 693 //M0 distribution unknown 694 hsPTot->Fill(mt,sWei); 695 hesP->Fill(mt,sWeiN); 696 mtV[icc] = mt; 697 err[icc] = sWei*sWei; 698 errN[icc] = sWeiN*sWeiN; 699 icc++; 700 }//Read each file 701 }//End of reading 2 files 702 703 for (int i = 1; i < 36; i++){ 704 double sPTot = hsPTot->GetBinContent(i); 705 double B = (sig2-N1)*hBkg1fb->GetBinContent(i); 706 double sPSig = sPTot - B; 707 708 double vb1 = 250 + 10*(i-1); 709 double vb2 = 250 + 10*i; 710 double SumErrBin = 0; 711 double SumErrNBin = 0; 712 for (int ic = 0; ic < icount; ic++){ 713 double mt = mtV[ic]; 714 double errV = err[ic]; 715 double errNV = errN[ic]; 716 if (mt>=vb1 && mt<vb2){ 717 SumErrBin += errV; 718 SumErrNBin += errNV; 719 } 720 } 721 hsP->SetBinContent(i,sPSig); 722 hsP->SetBinError(i,sqrt(SumErrBin)); 723 hesP->SetBinError(i,sqrt(SumErrNBin)); 724 } 725 726 //plot for sPlot with M0 UNknown 727 TCanvas *c = new TCanvas("c", "", 800,400); 728 c->Divide(2); 729 c->cd(1); 730 hsP->SetLineColor(2); 731 hsP->SetLineWidth(1); 732 hsP->DrawCopy("E1"); 733 hsP->SetLineColor(1); 734 hsP->SetLineWidth(2); 735 hsP->Draw("hist,same"); 736 c->cd(2); 737 hesP->SetLineColor(2); 738 hesP->SetLineWidth(1); 739 hesP->DrawCopy("E1"); 740 hesP->SetLineColor(1); 741 hesP->SetLineWidth(2); 742 hesP->Draw("hist,same"); 743 } -
SPLOT/NEWREALEASE/sPlots_NewRel.C
r17 r19 19 19 double Cut5 = 620; 20 20 double sigmaMin; 21 int icount = 0; 21 22 double iTot[2]; 22 23 double iCatS[6], iCatB[6]; … … 81 82 TFile *file[2]; 82 83 TTree *t[2]; 83 TTree *tw[2]; 84 85 for (int i = 0; i < 2; i++){ 86 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 84 85 for (int i = 0; i < 2; i++){ 86 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 87 87 file[i] = TFile::Open(filename); 88 88 t[i] = (TTree*)file[i]->Get("T"); 89 tw[i] = (TTree*)file[i]->Get("Tw");90 t[i]->AddFriend(tw[i]);91 89 } 92 90 … … 104 102 t[i]->GetEntry(iev); 105 103 106 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 107 double HT = t[i]->GetLeaf("HT")->GetValue(); 108 double x = t[i]->GetLeaf("cos_tlepCMtpair")->GetValue(); 109 double y = t[i]->GetLeaf("cosWqq")->GetValue(); 110 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 111 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 112 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 113 double WeiTot = WeiEvt*Wei1fb; 114 115 //cout << "WeiEvt = " << WeiEvt << endl; 116 //cout << "Wei1fb = " << Wei1fb << endl; 104 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 105 double HT = t[i]->GetLeaf("HT")->GetValue(); 106 double x = t[i]->GetLeaf("cos1")->GetValue(); 107 double y = t[i]->GetLeaf("cos2")->GetValue(); 108 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 109 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 110 117 111 //cout << "WeiTot = " << WeiTot << endl; 118 112 … … 126 120 127 121 if (mt > Cut4 && HT > Cut5) { 122 icount++; 128 123 iTot[i] += WeiTot; 129 124 int it = -1; … … 218 213 TFile *file[2]; 219 214 TTree *t[2]; 220 TTree *tw[2]; 221 222 for (int i = 0; i < 2; i++){ 223 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 215 216 for (int i = 0; i < 2; i++){ 217 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 224 218 file[i] = TFile::Open(filename); 225 219 t[i] = (TTree*)file[i]->Get("T"); 226 tw[i] = (TTree*)file[i]->Get("Tw");227 t[i]->AddFriend(tw[i]);228 220 } 229 221 … … 235 227 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 236 228 double HT = t[i]->GetLeaf("HT")->GetValue(); 237 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();238 double y = t[i]->GetLeaf("cos Wqq")->GetValue();229 double x = t[i]->GetLeaf("cos1")->GetValue(); 230 double y = t[i]->GetLeaf("cos2")->GetValue(); 239 231 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 240 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 241 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 242 double WeiTot = WeiEvt*Wei1fb; 243 244 //cout << "WeiEvt = " << WeiEvt << endl; 245 //cout << "Wei1fb = " << Wei1fb << endl; 232 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 233 246 234 //cout << "WeiTot = " << WeiTot << endl; 247 235 … … 269 257 Fit(){ 270 258 // Test 271 CalF0F1();272 259 MakeEventListf0f1(); 273 260 … … 318 305 cout << "Cut5 = " << Cut5 << endl; 319 306 320 //Get right N0 and N1 307 CalF0F1(); 308 cout << "icount = " << icount << endl; 309 310 //sPlots N0 known 311 cout << "***********************************************" << endl; 312 cout << "************** sPlot N0 known *****************" << endl; 313 cout << "***********************************************" << endl; 314 sPlots_NewRel_N0known(); 315 316 //Get right N0 and N1 for standard sPlot 317 cout << "***********************************************" << endl; 318 cout << "************* sPlot N0 unknown ****************" << endl; 319 cout << "***********************************************" << endl; 320 321 321 Fit(); 322 322 … … 326 326 TFile *file[2]; 327 327 TTree *t[2]; 328 TTree *tw[2]; 329 330 for (int i = 0; i < 2; i++){ 331 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 328 329 for (int i = 0; i < 2; i++){ 330 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 332 331 file[i] = TFile::Open(filename); 333 332 t[i] = (TTree*)file[i]->Get("T"); 334 tw[i] = (TTree*)file[i]->Get("Tw");335 t[i]->AddFriend(tw[i]);336 333 } 337 334 338 335 double VI00 = 0, VI01 = 0, VI10 = 0, VI11 = 0; 339 336 //start reading 2 files 340 int icount = 0;337 //int icount = 0; 341 338 for (int i = 0; i < 2; i++){ 342 339 int nevt = t[i]->GetEntries(); … … 346 343 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 347 344 double HT = t[i]->GetLeaf("HT")->GetValue(); 348 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();349 double y = t[i]->GetLeaf("cos Wqq")->GetValue();345 double x = t[i]->GetLeaf("cos1")->GetValue(); 346 double y = t[i]->GetLeaf("cos2")->GetValue(); 350 347 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 351 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 352 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 353 double WeiTot = WeiEvt*Wei1fb; 348 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 354 349 355 350 double cos1 = fabs(x); … … 361 356 if (hf!=4 && hasBJ==0){ 362 357 if (mt > Cut4 && HT > Cut5){ 363 icount++;364 358 //Compute the matrix 365 359 vector<double> veff = vFe(cos1,cos2,dMLep); … … 413 407 TH2F *h2DBkg = new TH2F("h2DBkg", "", 35, 250, 600, 50, 500, 1500); 414 408 415 cout << "icount = " << icount << endl; 416 409 //Try standard sPlots 417 410 double SumsP1 = 0.; 418 411 double SumsP0 = 0.; … … 420 413 double *mtN = new double[icount]; 421 414 int icc = 0; 422 //Try standard sPlots423 415 for (int i = 0; i < 2; i++){ 424 416 int nevt = t[i]->GetEntries(); … … 428 420 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 429 421 double HT = t[i]->GetLeaf("HT")->GetValue(); 430 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();431 double y = t[i]->GetLeaf("cos Wqq")->GetValue();422 double x = t[i]->GetLeaf("cos1")->GetValue(); 423 double y = t[i]->GetLeaf("cos2")->GetValue(); 432 424 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 433 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 434 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 435 double WeiTot = WeiEvt*Wei1fb; 425 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 436 426 437 427 int hasBJ = t[i]->GetLeaf("hasBadJet")->GetValue(); … … 476 466 477 467 for (int i = 1; i < 36; i++){ 478 double vb1 = 250 + (i-1)*1 6;479 double vb2 = 250 + i*1 6;468 double vb1 = 250 + (i-1)*10; 469 double vb2 = 250 + i*10; 480 470 double ErrBin = 0.; 481 471 for (int j = 0; j < icount; j++){ … … 489 479 } 490 480 481 TH2F *frame = new TH2F("frame", "", 35, 250, 600, 50, -10, 40); 482 491 483 TCanvas *c = new TCanvas("c", "", 900, 400); 492 484 c->Divide(2); 493 485 c->cd(1); 486 //frame->Draw(); 494 487 hSigN->SetLineColor(2); 495 488 hSigN->SetLineWidth(1); 496 //hSigN->DrawCopy("E1");489 hSigN->DrawCopy("E1"); 497 490 hSigN->SetLineColor(1); 498 491 hSigN->SetLineWidth(2.5); 499 hSigN->DrawCopy("hist ");492 hSigN->DrawCopy("hist,same"); 500 493 c->cd(2); 501 494 hBkgN->SetLineColor(4); … … 510 503 h2DBkg->Draw("colz"); 511 504 } 505 506 507 //################################################################## 508 //########### FUNCTION FOR BACKGROUND YIELD KNOWN ################## 509 //################################################################## 510 511 void sPlots_NewRel_N0known(){ 512 cout << "in function N0 known " << icount << endl; 513 N0 = iTot[0]; 514 N1 = iTot[1]; 515 sig2 = sigmaMin*sigmaMin*N1*N1; 516 cout << "sigmaMin = " << sigmaMin << " sig2 = " << sig2 << endl; 517 cout << "N0 = " << N0 << " N1 = " << N1 << endl; 518 519 double k = (sig2 - N1)/(N0 - (sig2 - N1)); 520 521 TH2F *twoDim_mt_HT_Sig = new TH2F("mt_HT_Sig", "", 75, 250, 1500, 50, 500, 2000); 522 TH2F *twoDim_mt_HT_Sig_esP = new TH2F("mt_HT_Sig_esP", "", 75, 250, 1500, 50, 500, 2000); 523 524 TH1F *h[7]; 525 h[0] = new TH1F("All1fb", "", 150, 0, 1500); 526 h[1] = new TH1F("Sig1fb", "", 150, 0, 1500); 527 h[2] = new TH1F("Bkg1fb", "", 150, 0, 1500); 528 h[3] = new TH1F("sPlotAll", "", 150, 0, 1500); 529 h[4] = new TH1F("sPlotSig", "", 150, 0, 1500); 530 h[5] = new TH1F("sPlotBkg", "", 150, 0, 1500); 531 h[6] = new TH1F("esPlotSig", "", 150, 0, 1500); 532 533 double *mtV = new double[icount]; 534 double *err = new double[icount]; 535 double *errN = new double[icount]; 536 int icc = 0; 537 538 TString filename = ""; 539 TString type[2] = {"AllBkgTopMCAtNLO","Signal"}; 540 TFile *file[2]; 541 TTree *t[2]; 542 for (int i = 0; i < 2; i++){ 543 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 544 file[i] = TFile::Open(filename); 545 t[i] = (TTree*)file[i]->Get("T"); 546 } 547 548 for (int i = 0; i < 2; i++){ 549 int nevt = t[i]->GetEntries(); 550 for (int iev = 0; iev < nevt; iev++) { 551 t[i]->GetEntry(iev); 552 553 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 554 double HT = t[i]->GetLeaf("HT")->GetValue(); 555 double x = t[i]->GetLeaf("cos1")->GetValue(); 556 double y = t[i]->GetLeaf("cos2")->GetValue(); 557 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 558 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 559 560 int hasBJ = t[i]->GetLeaf("hasBadJet")->GetValue(); 561 double hf = t[i]->GetLeaf("hfor")->GetValue(); 562 563 if (hf!=4 && hasBJ==0){ 564 565 double cos1 = fabs(x); 566 double cos2 = fabs(y); 567 568 //sPlots total 569 if (mt > Cut4 && HT > Cut5){ 570 vector<double> veff = vFe(cos1,cos2,dMLep); 571 double F0e = veff.at(0); 572 double F1e = veff.at(1); 573 574 double sWei = sig2*F1e*WeiTot/(N1*F1e + N0*F0e); 575 double sWeiN = sWei*(k+1) - k*WeiTot; 576 577 //For 1 fb-1 578 h[0]->Fill(mt,WeiTot); 579 h[3]->Fill(mt,sWei);//sPlot 580 h[6]->Fill(mt,sWeiN);//esPlot 581 582 if (i==0) { 583 h[2]->Fill(mt,WeiTot); 584 h[5]->Fill(mt,sWei); 585 } 586 if (i==1){ 587 h[1]->Fill(mt,WeiTot); 588 twoDim_mt_HT_Sig->Fill(mt,HT,sWei); 589 twoDim_mt_HT_Sig_esP->Fill(mt,HT,sWeiN); 590 } 591 592 //uncertainty 593 mtV[icc] = mt; 594 if (WeiTot==0){ 595 err[icc] = 0; 596 errN[icc] = 0; 597 } else { 598 err[icc] = sWei*sWei/WeiTot; 599 errN[icc] = sWeiN*sWeiN/WeiTot; 600 } 601 icc++; 602 } 603 } 604 }//Read each file 605 }//End of reading 2 files 606 607 h[2]->Scale(1./h[2]->Integral(0,1500)); 608 609 for (int i = 1; i < 151; i++){ 610 double sP = h[3]->GetBinContent(i); 611 double B = (sig2 - N1)*h[2]->GetBinContent(i); 612 double sB = h[5]->GetBinContent(i); 613 double W = sP - B; 614 double sW = sP - sB; 615 double Tot1fb = h[0]->GetBinContent(i); 616 double BkgPure = Tot1fb - sP; 617 618 double vb1 = 10*(i-1); 619 double vb2 = 10*i; 620 double SumErrBin = 0; 621 double SumErrNBin = 0; 622 for (int ic = 0; ic < icount; ic++){ 623 double mt = mtV[ic]; 624 double errV = err[ic]; 625 double errNV = errN[ic]; 626 if (mt>=vb1 && mt<vb2){ 627 SumErrBin += errV; 628 SumErrNBin += errNV; 629 } 630 } 631 h[4]->SetBinContent(i,sW); 632 h[4]->SetBinError(i,sqrt(SumErrBin)); 633 h[6]->SetBinError(i,sqrt(SumErrNBin)); 634 } 635 636 cout << "h2 integral is " << h[2]->Integral(0,1500) << endl; 637 cout << "h4 integral is " << h[4]->Integral(0,1000) << endl; 638 cout << "h6 integral is " << h[6]->Integral(0,1500) << endl; 639 640 double x1 = 250; 641 double x2 = 600 - 0.01; 642 for (int i = 0; i < 7; i++) { 643 //h[i]->Rebin(2); 644 h[i]->SetLineWidth(3); 645 TAxis *ax = h[i]->GetXaxis(); 646 int b1 = ax->FindBin(x1); 647 int b2 = ax->FindBin(x2); 648 ax->SetRange(b1,b2); 649 } 650 651 //plot for sPlot with M0 known 652 TCanvas *csP = new TCanvas("csP", "", 800, 400); 653 csP->Divide(2); 654 csP->cd(1); 655 h[4]->SetLineColor(2); 656 h[4]->SetLineWidth(1); 657 h[4]->DrawCopy("E1"); 658 h[1]->SetLineColor(kGreen+1); 659 h[1]->Draw("same"); 660 h[4]->SetLineColor(1); 661 h[4]->SetLineWidth(3); 662 h[4]->DrawCopy("hist,same"); 663 csP->cd(2); 664 twoDim_mt_HT_Sig->Draw("colz,0"); 665 666 //plot for sPlot with M0 UNknown 667 TCanvas *cesP = new TCanvas("cesP", "", 800,400); 668 cesP->Divide(2); 669 cesP->cd(1); 670 h[6]->SetLineColor(2); 671 h[6]->SetLineWidth(1); 672 h[6]->DrawCopy("E1"); 673 h[6]->SetLineColor(1); 674 h[6]->SetLineWidth(3); 675 h[6]->Draw("hist,same"); 676 cesP->cd(2); 677 twoDim_mt_HT_Sig_esP->Draw("colz,0"); 678 } -
SPLOT/NEWREALEASE/sPlots_NewRel_N0known.C
r17 r19 81 81 TFile *file[2]; 82 82 TTree *t[2]; 83 TTree *tw[2]; 84 85 for (int i = 0; i < 2; i++){ 86 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 83 84 for (int i = 0; i < 2; i++){ 85 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 87 86 file[i] = TFile::Open(filename); 88 87 t[i] = (TTree*)file[i]->Get("T"); 89 tw[i] = (TTree*)file[i]->Get("Tw");90 t[i]->AddFriend(tw[i]);91 88 } 92 89 … … 106 103 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 107 104 double HT = t[i]->GetLeaf("HT")->GetValue(); 108 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();109 double y = t[i]->GetLeaf("cos Wqq")->GetValue();105 double x = t[i]->GetLeaf("cos1")->GetValue(); 106 double y = t[i]->GetLeaf("cos2")->GetValue(); 110 107 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 111 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 112 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 113 double WeiTot = WeiEvt*Wei1fb; 114 115 //cout << "WeiEvt = " << WeiEvt << endl; 116 //cout << "Wei1fb = " << Wei1fb << endl; 108 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 109 117 110 //cout << "WeiTot = " << WeiTot << endl; 118 111 … … 218 211 TFile *file[2]; 219 212 TTree *t[2]; 220 TTree *tw[2]; 221 222 for (int i = 0; i < 2; i++){ 223 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 213 214 for (int i = 0; i < 2; i++){ 215 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 224 216 file[i] = TFile::Open(filename); 225 217 t[i] = (TTree*)file[i]->Get("T"); 226 tw[i] = (TTree*)file[i]->Get("Tw");227 t[i]->AddFriend(tw[i]);228 218 } 229 219 … … 235 225 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 236 226 double HT = t[i]->GetLeaf("HT")->GetValue(); 237 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();238 double y = t[i]->GetLeaf("cos Wqq")->GetValue();227 double x = t[i]->GetLeaf("cos1")->GetValue(); 228 double y = t[i]->GetLeaf("cos2")->GetValue(); 239 229 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 240 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 241 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 242 double WeiTot = WeiEvt*Wei1fb; 243 244 //cout << "WeiEvt = " << WeiEvt << endl; 245 //cout << "Wei1fb = " << Wei1fb << endl; 230 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 231 246 232 //cout << "WeiTot = " << WeiTot << endl; 247 233 … … 318 304 TFile *file[2]; 319 305 TTree *t[2]; 320 TTree *tw[2]; 321 322 for (int i = 0; i < 2; i++){ 323 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "v3N.root"; 306 307 for (int i = 0; i < 2; i++){ 308 filename = "./MERGEFILES/res_"; filename += type[i]; filename += "NEW.root"; 324 309 file[i] = TFile::Open(filename); 325 310 t[i] = (TTree*)file[i]->Get("T"); 326 tw[i] = (TTree*)file[i]->Get("Tw");327 t[i]->AddFriend(tw[i]);328 311 } 329 312 … … 340 323 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 341 324 double HT = t[i]->GetLeaf("HT")->GetValue(); 342 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();343 double y = t[i]->GetLeaf("cos Wqq")->GetValue();325 double x = t[i]->GetLeaf("cos1")->GetValue(); 326 double y = t[i]->GetLeaf("cos2")->GetValue(); 344 327 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 345 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 346 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 347 double WeiTot = WeiEvt*Wei1fb; 328 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 348 329 349 330 double cos1 = fabs(x); … … 404 385 double mt = t[i]->GetLeaf("mtophad")->GetValue(); 405 386 double HT = t[i]->GetLeaf("HT")->GetValue(); 406 double x = t[i]->GetLeaf("cos _tlepCMtpair")->GetValue();407 double y = t[i]->GetLeaf("cos Wqq")->GetValue();387 double x = t[i]->GetLeaf("cos1")->GetValue(); 388 double y = t[i]->GetLeaf("cos2")->GetValue(); 408 389 double dMLep = t[i]->GetLeaf("MinLep1")->GetValue(); 409 double WeiEvt = t[i]->GetLeaf("WeiEvent")->GetValue(); 410 double Wei1fb = t[i]->GetLeaf("wei")->GetValue(); 411 double WeiTot = WeiEvt*Wei1fb; 390 double WeiTot = t[i]->GetLeaf("wei")->GetValue(); 412 391 413 392 int hasBJ = t[i]->GetLeaf("hasBadJet")->GetValue(); … … 416 395 if (hf!=4 && hasBJ==0){ 417 396 418 //cout << "WeiEvt " << WeiEvt << endl;419 //cout << "Wei1fb " << Wei1fb << endl;420 421 397 double cos1 = fabs(x); 422 398 double cos2 = fabs(y); … … 461 437 } else { 462 438 err[icc] = sWei*sWei/WeiTot; 463 errN[icc] = sWeiN*sWeiN *WeiTot;439 errN[icc] = sWeiN*sWeiN/WeiTot; 464 440 } 465 441 icc++; … … 496 472 double errV = err[ic]; 497 473 double errNV = errN[ic]; 498 if (mt>=vb1 && mt<vb2) 474 if (mt>=vb1 && mt<vb2){ 499 475 SumErrBin += errV; 500 476 SumErrNBin += errNV; 477 } 501 478 } 502 479 … … 588 565 h[9]->SetLineWidth(1); 589 566 h[9]->DrawCopy("E1"); 590 h[1]->SetLineColor(kGreen+ 3);567 h[1]->SetLineColor(kGreen+1); 591 568 h[1]->Draw("same"); 592 569 h[9]->SetLineColor(1);
Note: See TracChangeset
for help on using the changeset viewer.