diff --git a/Tool/EffsHeader_MuCS.h b/Tool/EffsHeader_MuCS.h index beba746..a141895 100644 --- a/Tool/EffsHeader_MuCS.h +++ b/Tool/EffsHeader_MuCS.h @@ -1,3 +1,4 @@ + const double ttbar_mtwcorrfactor[8] = {1.00308,1.03938,1.0767,1.0988,1.12942,1.17955,1.25167,1.7567}; const double ttbar_mus_acc[6] = {0.769261,0.871118,0.900174,0.92814,0.921287,0.945285}; const double ttbar_mus_recoeff[8][8] = {{0.952769,0.906542,0.939655,0.93617,0.93038,0.914894,0.92,0.903766},{0.962189,0.966667,0.930147,0.963989,0.963768,0.915254,0.952381,0.95539},{0.971917,0.966019,0.97619,0.934911,0.964126,0.945652,0.951456,0.976048},{0.979784,0.980769,0.949239,0.944206,0.940367,0.960526,0.971429,0.975},{0.980216,0.943089,0.992958,0.986486,0.982955,0.962963,0.9625,0.953757},{0.981664,0.965517,0.949495,0.972125,0.929204,0.960452,0.971223,0.951557},{0.96882,0.990566,0.958042,0.985294,0.954545,0.954545,0.934579,0.95053},{0.925926,0.928571,0.92,0.896552,0.913043,0.9,0.918367,0.932773}}; const double ttbar_mus_isoeff[8][8] = {{0.926544,0.808081,0.77193,0.73743,0.729167,0.752688,0.71831,0.599099},{0.966805,0.884058,0.887597,0.849432,0.833948,0.825,0.762295,0.73622},{0.980271,0.945545,0.936585,0.898773,0.884259,0.8125,0.913462,0.766082},{0.995851,0.993464,0.958115,0.930435,0.925,0.899281,0.913462,0.869792},{0.987544,0.991379,0.962687,0.965686,0.955801,0.935185,0.878378,0.899441},{0.991058,0.982143,0.984127,1,0.990338,0.977528,0.945736,0.930147},{0.997625,1,0.992701,0.995,0.978947,1,0.989796,0.958801},{1,1,1,1,1,1,1,0.996865}}; diff --git a/Tool/LostLepton_MuCS_TTbar.cc b/Tool/LostLepton_MuCS_TTbar.cc index de66cdf..600b5c3 100644 --- a/Tool/LostLepton_MuCS_TTbar.cc +++ b/Tool/LostLepton_MuCS_TTbar.cc @@ -218,15 +218,15 @@ int main(int argc, char* argv[]) int nevents_baseline= 0; //int nevents_baseline_ref= 0; - double mtwcorrfactor[8]; - mtwcorrfactor[0] = 1.01; - mtwcorrfactor[1] = 1.04; - mtwcorrfactor[2] = 1.07; - mtwcorrfactor[3] = 1.20; - mtwcorrfactor[4] = 1.15; - mtwcorrfactor[5] = 1.20; - mtwcorrfactor[6] = 1.28; - mtwcorrfactor[7] = 1.83; + //double mtwcorrfactor[8]; + //mtwcorrfactor[0] = 1.01; + //mtwcorrfactor[1] = 1.04; + //mtwcorrfactor[2] = 1.07; + //mtwcorrfactor[3] = 1.20; + //mtwcorrfactor[4] = 1.15; + //mtwcorrfactor[5] = 1.20; + //mtwcorrfactor[6] = 1.28; + //mtwcorrfactor[7] = 1.83; //first loop, to generate Acc, reco and Iso effs and also fill expected histgram std::cout<<"First loop begin: "< muonsLVec = tr.getVec("muonsLVec"); + vector muonsMiniIso = tr.getVec("muonsMiniIso"); + + double reco_mus_pt = 0, reco_mus_eta = 0, reco_mus_phi = 0; + + for(unsigned int im = 0 ; im < muonsLVec.size() ; im++) + { + if( fabs(muonsLVec[im].Eta()) < 2.4 && muonsMiniIso[im] < 0.2 ) + { + reco_mus_pt = ( muonsLVec.at(im) ).Pt(); + reco_mus_eta = ( muonsLVec.at(im) ).Eta(); + reco_mus_phi = ( muonsLVec.at(im) ).Phi(); + } + } + + double deltaphi_mus = DeltaPhi( reco_mus_phi , metphi ); + double mtW_mus = std::sqrt( 2.0 * reco_mus_pt * met * ( 1.0 - cos(deltaphi_mus) ) ); + (myBaseHistgram.h_mtw_mus)->Fill(mtW_mus); + + int ptbin_number_allreco = Set_ptbin_number(reco_mus_pt); + + myAccRecoIsoEffs.mtwall[ptbin_number_allreco]++; + if( mtW_mus < 100 ) + { + myAccRecoIsoEffs.mtw100[ptbin_number_allreco]++; + } + } + //book the variable we need to check int ntopjets = tr.getVar("nTopCandSortedCnt"); double MT2 = tr.getVar("MT22"); @@ -933,7 +964,7 @@ int main(int argc, char* argv[]) int acbin_number = Set_acbin_number(activity); //mtwcorrfactor - EventWeight_mus = EventWeight_mus * mtwcorrfactor[ptbin_number]; + EventWeight_mus = EventWeight_mus * myAccRecoIsoEffs.mtwcorrfactor[ptbin_number]; //dimuon correction factor EventWeight_mus = EventWeight_mus * myAccRecoIsoEffs.corrfactor_di_mus; @@ -987,7 +1018,7 @@ int main(int argc, char* argv[]) //begin to predict lost electrons from muon CS double EventWeight_els = 1.0; //mtwcorrfactor - EventWeight_els = EventWeight_els * mtwcorrfactor[ptbin_number]; + EventWeight_els = EventWeight_els * myAccRecoIsoEffs.mtwcorrfactor[ptbin_number]; //dielectron correction factor EventWeight_els = EventWeight_els * myAccRecoIsoEffs.corrfactor_di_els; @@ -1112,6 +1143,12 @@ void AccRecoIsoEffs::NumberstoEffs() } } + for(i_cal = 0 ; i_cal < PT_BINS ; i_cal++) + { + mtwcorrfactor[i_cal] = mtwall[i_cal]/mtw100[i_cal]; + mtwcorrfactor_err[i_cal] = get_stat_Error(mtw100[i_cal],mtwall[i_cal]); + } + return ; } @@ -1318,6 +1355,18 @@ void AccRecoIsoEffs::printAccRecoIsoEffs() int i_cal = 0; int j_cal = 0; std::cout.precision(3); + + std::cout << "mtW correction factor: " << std::endl; + for( i_cal=0 ; i_cal < PT_BINS ; i_cal++ ) + { + std::cout << mtwcorrfactor[i_cal] << "(" << mtwcorrfactor_err[i_cal] << ")"<< " ";; + if( i_cal == PT_BINS-1 ) + { + std::cout << std::endl; + } + } + + std::cout << std::endl << "Muon information: " << std::endl; std::cout << "number of muons from top: " << std::endl; @@ -1675,6 +1724,15 @@ void AccRecoIsoEffs::printEffsHeader() int i_cal = 0; int j_cal = 0; + EffsHeader << " const double ttbar_mtwcorrfactor[" << PT_BINS << "] = "; + for( i_cal = 0 ; i_cal < PT_BINS ; i_cal++ ) + { + if( i_cal == 0 ) { EffsHeader << "{"; } + EffsHeader << mtwcorrfactor[i_cal]; + if( i_cal != PT_BINS-1 ) { EffsHeader << ","; } + if( i_cal == PT_BINS-1 ) { EffsHeader << "};" << std::endl; } + } + EffsHeader << " const double ttbar_mus_acc[" << NJETS_BINS << "] = "; for( i_cal = 0 ; i_cal < NJETS_BINS ; i_cal++ ) { diff --git a/Tool/LostLepton_MuCS_TTbar.h b/Tool/LostLepton_MuCS_TTbar.h index dbc1379..156e674 100644 --- a/Tool/LostLepton_MuCS_TTbar.h +++ b/Tool/LostLepton_MuCS_TTbar.h @@ -52,6 +52,8 @@ class AccRecoIsoEffs double mus_isoeff_err_allreco[PT_BINS][AC_BINS] = {{0}}, els_isoeff_err_allreco[PT_BINS][AC_BINS] = {{0}}; + double mtwcorrfactor[PT_BINS] = {0}, mtwcorrfactor_err[PT_BINS] = {0}; + //here we define the muon/electron number we need to count in the loop double nmus[NJETS_BINS] = {0}, nmus_acc[NJETS_BINS] = {0}, nels[NJETS_BINS] = {0}, nels_acc[NJETS_BINS] = {0}; double nmus_acc_bin[PT_BINS][AC_BINS] = {{0}}, nels_acc_bin[PT_BINS][AC_BINS] = {{0}}; @@ -61,6 +63,8 @@ class AccRecoIsoEffs double nmus_reco_allreco[PT_BINS][AC_BINS] = {{0}}, nels_reco_allreco[PT_BINS][AC_BINS] = {{0}}; double nmus_iso_allreco[PT_BINS][AC_BINS] = {{0}}, nels_iso_allreco[PT_BINS][AC_BINS] = {{0}}; + double mtwall[PT_BINS] = {0}, mtw100[PT_BINS] = {0}; + //here we define the event weight we are going to use in the second loop ( muon/electron CS and prediction plots) double mus_EventWeight_iso[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}, mus_EventWeight_reco[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}, mus_EventWeight_acc[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}; double els_EventWeight_iso[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}, els_EventWeight_reco[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}, els_EventWeight_acc[NJETS_BINS][PT_BINS][AC_BINS] = {{{0}}}; @@ -190,6 +194,8 @@ class BaseHistgram TH1D *h_b_njets30_4_eta_els, *h_b_njets30_5_eta_els, *h_b_njets30_6_eta_els, *h_b_njets30_7_eta_els, *h_b_njets30_8_eta_els, *h_b_njets30_9_eta_els; TH1D *h_b_njets30_4_ht_mus, *h_b_njets30_5_ht_mus, *h_b_njets30_6_ht_mus, *h_b_njets30_7_ht_mus, *h_b_njets30_8_ht_mus, *h_b_njets30_9_ht_mus; + TH1D *h_mtw_mus; + //closure plots definition TH1D *h_pred_mu_iso_met, *h_pred_mu_iso_njets, *h_pred_mu_iso_mt2, *h_pred_mu_iso_topmass, *h_pred_mu_iso_ht, *h_pred_mu_iso_mht, *h_pred_mu_iso_ntopjets; TH1D *h_pred_mu_id_met, *h_pred_mu_id_njets, *h_pred_mu_id_mt2, *h_pred_mu_id_topmass, *h_pred_mu_id_ht, *h_pred_mu_id_mht, *h_pred_mu_id_ntopjets; @@ -304,6 +310,8 @@ void BaseHistgram::BookHistgram(const char *outFileName) h_b_njets30_8_eta_els = new TH1D("h_b_njets30_8_eta_els","",60,-3,3); h_b_njets30_9_eta_els = new TH1D("h_b_njets30_9_eta_els","",60,-3,3); + h_mtw_mus = new TH1D("h_mtw_mus","",200,0,200); + h_b_activity_mus = new TH1D("h_b_activity_mus","",1000,0,200); h_b_activity_els = new TH1D("h_b_activity_els","",1000,0,200); diff --git a/Tool/Plot_eff.C b/Tool/Plot_eff.C deleted file mode 100644 index 6c25be5..0000000 --- a/Tool/Plot_eff.C +++ /dev/null @@ -1,122 +0,0 @@ -{ - TFile f_eff("Effs2dPlots.root"); - - TCanvas *c1 = new TCanvas("c1", "c1",0,51,1920,1004); - c1->SetFillColor(0); - c1->cd(); - - TH2F *h_mu_iso_eff_ori = (TH2F*)f_eff.Get("mus_isoeffs"); - //h_mu_iso_eff_ori->Draw("colztext"); - - TH2F *h_mu_iso_eff; - Float_t xbins[9]={5.0,10.0,20.0,30.0,40.0,50.0,70.0,100.0,120.0}; - Float_t ybins[9]={0.0,5.0,10.0,20.0,40.0,60.0,80.0,100.0,120.0}; - h_mu_iso_eff = new TH2F("h_mu_iso_eff", "h_mu_iso_eff", 8, xbins, 8, ybins); - h_mu_iso_eff->SetTitle(""); - h_mu_iso_eff->SetXTitle("muon pT [GeV]"); - h_mu_iso_eff->SetYTitle("activity [GeV]"); - h_mu_iso_eff->SetStats(0); - - for (Int_t muonptc=1;muonptc<9;++muonptc) { - for (int activityc=1;activityc<9;++activityc) - { - h_mu_iso_eff->SetBinContent(muonptc,activityc,h_mu_iso_eff_ori->GetBinContent(muonptc,activityc)); - h_mu_iso_eff->SetBinError(muonptc,activityc,h_mu_iso_eff_ori->GetBinError(muonptc,activityc)); - } - } - gStyle->SetPaintTextFormat("1.2f"); - h_mu_iso_eff->Draw("colztexte"); - - - /////////////////// - // c2 - /////////////////// - - TCanvas *c2 = new TCanvas("c2", "c2",0,51,1920,1004); - c2->SetFillColor(0); - c2->cd(); - - TH2F *h_els_iso_eff_ori = (TH2F*)f_eff.Get("els_isoeffs"); - //h_els_iso_eff_ori->Draw("colztext"); - - TH2F *h_els_iso_eff; - //Float_t xbins[9]={5.0,10.0,20.0,30.0,40.0,50.0,70.0,100.0,120.0}; - //Float_t ybins[9]={0.0,5.0,10.0,20.0,40.0,60.0,80.0,100.0,120.0}; - h_els_iso_eff = new TH2F("h_els_iso_eff", "h_els_iso_eff", 8, xbins, 8, ybins); - h_els_iso_eff->SetTitle(""); - h_els_iso_eff->SetXTitle("electron pT [GeV]"); - h_els_iso_eff->SetYTitle("activity [GeV]"); - h_els_iso_eff->SetStats(0); - - for (Int_t elsonptc=1;elsonptc<9;++elsonptc) { - for (int activityc=1;activityc<9;++activityc) - { - h_els_iso_eff->SetBinContent(elsonptc,activityc,h_els_iso_eff_ori->GetBinContent(elsonptc,activityc)); - h_els_iso_eff->SetBinError(elsonptc,activityc,h_els_iso_eff_ori->GetBinError(elsonptc,activityc)); - } - } - gStyle->SetPaintTextFormat("1.2f"); - h_els_iso_eff->Draw("colztexte"); - - /////////////////// - // c3 - /////////////////// - - TCanvas *c3 = new TCanvas("c3", "c3",0,51,1920,1004); - c3->SetFillColor(0); - c3->cd(); - - TH2F *h_mus_reco_eff_ori = (TH2F*)f_eff.Get("mus_recoeffs"); - //h_mus_reco_eff_ori->Draw("colztext"); - - TH2F *h_mus_reco_eff; - //Float_t xbins[9]={5.0,10.0,20.0,30.0,40.0,50.0,70.0,100.0,120.0}; - //Float_t ybins[9]={0.0,5.0,10.0,20.0,40.0,60.0,80.0,100.0,120.0}; - h_mus_reco_eff = new TH2F("h_mus_reco_eff", "h_mus_reco_eff", 8, xbins, 8, ybins); - h_mus_reco_eff->SetTitle(""); - h_mus_reco_eff->SetXTitle("muon pT [GeV]"); - h_mus_reco_eff->SetYTitle("activity [GeV]"); - h_mus_reco_eff->SetStats(0); - - for (Int_t musonptc=1;musonptc<9;++musonptc) { - for (int activityc=1;activityc<9;++activityc) - { - h_mus_reco_eff->SetBinContent(musonptc,activityc,h_mus_reco_eff_ori->GetBinContent(musonptc,activityc)); - h_mus_reco_eff->SetBinError(musonptc,activityc,h_mus_reco_eff_ori->GetBinError(musonptc,activityc)); - } - } - gStyle->SetPaintTextFormat("1.2f"); - h_mus_reco_eff->Draw("colztexte"); - - /////////////////// - // c4 - /////////////////// - - TCanvas *c4 = new TCanvas("c4", "c4",0,51,1920,1004); - c4->SetFillColor(0); - c4->cd(); - - TH2F *h_els_reco_eff_ori = (TH2F*)f_eff.Get("els_recoeffs"); - //h_els_reco_eff_ori->Draw("colztext"); - - TH2F *h_els_reco_eff; - //Float_t xbins[9]={5.0,10.0,20.0,30.0,40.0,50.0,70.0,100.0,120.0}; - //Float_t ybins[9]={0.0,5.0,10.0,20.0,40.0,60.0,80.0,100.0,120.0}; - h_els_reco_eff = new TH2F("h_els_reco_eff", "h_els_reco_eff", 8, xbins, 8, ybins); - h_els_reco_eff->SetTitle(""); - h_els_reco_eff->SetXTitle("electron pT [GeV]"); - h_els_reco_eff->SetYTitle("activity [GeV]"); - h_els_reco_eff->SetStats(0); - - for (Int_t elsonptc=1;elsonptc<9;++elsonptc) { - for (int activityc=1;activityc<9;++activityc) - { - h_els_reco_eff->SetBinContent(elsonptc,activityc,h_els_reco_eff_ori->GetBinContent(elsonptc,activityc)); - h_els_reco_eff->SetBinError(elsonptc,activityc,h_els_reco_eff_ori->GetBinError(elsonptc,activityc)); - } - } - gStyle->SetPaintTextFormat("1.2f"); - h_els_reco_eff->Draw("colztexte"); - - -}