diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa1f10d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.pyc +CMSSW_9_3_9_patch1/ +cmssw_configs/ +*.md +*.tex diff --git a/DNN_Tools/optimize_cats.C b/DNN_Tools/optimize_cats.C index cfd654c..cfb1697 100644 --- a/DNN_Tools/optimize_cats.C +++ b/DNN_Tools/optimize_cats.C @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,29 +25,29 @@ using namespace std; void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double xcutoff, double bin_width_, TString ext, TString nTupleLocation) { // void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double xcutoff, int Nbins, TString ext, TString nTupleLocation, TString year) { TString year = "2017"; - // Misc + // Misc gROOT->SetBatch("kTrue"); - // Parameters + // Parameters cout << "extension: " << ext << endl; TString scaleOpt; if(scaleBkgSideband) scaleOpt = "withSidebandScale"; - else scaleOpt = "noSidebandScale"; + else scaleOpt = "noSidebandScale"; TString outDir = "/eos/user/a/atishelm/www/HHWWgg/DNN_Tools_again/"; TString what_to_opt = "evalDNN"; double minevents = 5; double xmin = xcutoff; - double xmax = 1.00001; // to include values that == 1 - // double xmax = 1; // + double xmax = 1.00001; // to include values that == 1 + // double xmax = 1; // Double_t bin_width = bin_width_; // int Nbins = Nbins_; TString xmin_str = to_string(xcutoff); - TString binWidth_str = to_string(bin_width_); + TString binWidth_str = to_string(bin_width_); // TString Nbins_str = to_string(Nbins); TString extraSelections = "*(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1 && N_goodJets >= 1 )"; TString Mgg_window = "*((CMS_hgg_mass>115)&&(CMS_hgg_mass<135))"; - TString Mgg_sideband = "*((CMS_hgg_mass<=115)||(CMS_hgg_mass>=135))"; + TString Mgg_sideband = "*((CMS_hgg_mass<=135)||(CMS_hgg_mass>=135))"; //// Important: Semi-Leptonic branching ratio of 0.441 is in here. Need to change for other final states // 41.5 set as 2017 luminosity @@ -56,14 +56,14 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double else if(year=="2017") lumi = "41.5" ; else if(year=="2018") lumi = "59.4"; - // TString selection_sig = "33.49*0.00097*0.441*41.5*weight*(CMS_hgg_mass > 100 && CMS_hgg_mass < 180)" + extraSelections; // normalize signal properly with cross section + // TString selection_sig = "33.49*0.00097*0.441*41.5*weight*(CMS_hgg_mass > 100 && CMS_hgg_mass < 180)" + extraSelections; // normalize signal properly with cross section TString selection_sig = "31.049*0.00097*0.441*" + lumi + "*weight*(CMS_hgg_mass > 100 && CMS_hgg_mass < 180)" + extraSelections; // normalize signal properly with cross section and branching ratio TString selection_bg = "41.5*weight*(CMS_hgg_mass > 100 && CMS_hgg_mass < 180)" + extraSelections; TString selection_data = "(1)" + extraSelections; TString s; TString sel; TString outname = s.Format("%sCategorization_%s_%dcats_%s",year.Data(),what_to_opt.Data(),NCATS,ext.Data()); -// --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/DNN_testnewfiles/ +// --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/DNN_testnewfiles/ // --nTupleDirec /eos/user/b/bmarzocc/HHWWgg/HHWWgg_DataSignalMCnTuples/PromptPromptApplied-TagsMerged/HHWWyyDNN_binary_testnewfiles_allBkgs/ // Combine Signal Trees @@ -83,7 +83,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double else if(year=="2018") signal_Location = signal_Loc_s.Format("/eos/user/a/atishelm/ntuples/HHWWgg_DataSignalMCnTuples/2018/Signal/HHWWgg-SL-SM-NLO-2018.root/GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER"); else{ cout << "Don't know what to do for year: " << year << endl; - cout << "Exiting" << endl; + cout << "Exiting" << endl; } TChain *file_s = new TChain("file_s"); @@ -107,11 +107,11 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double TChain *tree_bg = new TChain("tree_bg"); // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN/Backgrounds_promptpromptselapplied"; // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds_promptpromptselapplied"; - // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds"; ///// no prompt prompt removal applied - // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds"; ///// no prompt prompt removal applied + // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds"; ///// no prompt prompt removal applied + // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds"; ///// no prompt prompt removal applied TString bkg_Loc_s; - // TString bkg_Location = bkg_Loc_s.Format("%s/Bkgs/",nTupleLocation.Data()); + // TString bkg_Location = bkg_Loc_s.Format("%s/Bkgs/",nTupleLocation.Data()); // TString bkg_Location = bkg_Loc_s.Format("/eos/user/b/bmarzocc/HHWWgg/HHWWgg_DataSignalMCnTuples/PromptPromptApplied-TagsMerged/HHWWyyDNN_binary_weights_exp_allBkgs/Bkgs/"); //-- Hardcoded TString bkg_Location = bkg_Loc_s.Format("/eos/user/b/bmarzocc/HHWWgg/HHWWgg_DataSignalMCnTuples/PromptPromptApplied-TagsMerged/HHWWyyDNN_binary_testnewfiles_allBkgs/Bkgs/"); //-- Hardcoded @@ -119,30 +119,30 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double // string backgroundDirec = "/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN_addWjets/Backgrounds_promptpromptselapplied"; // Prompt Prompt removal applied cout << "backgroundDirec " << backgroundDirec << endl; vector v; - v = read_directory(backgroundDirec); // Get vector of background files - cout << " " << endl; + v = read_directory(backgroundDirec); // Get vector of background files + cout << " " << endl; cout << "Number of background files: " << v.size() << endl; - for(int i = 0; i < v.size(); i++){ // for each file + for(int i = 0; i < v.size(); i++){ // for each file string file = v[i]; string treePath = GetMCTreeName(file); - string fullPath = backgroundDirec + "/"; + string fullPath = backgroundDirec + "/"; fullPath.append(file); fullPath.append( "/" + treePath); - + // cout << "full path: " << fullPath << endl; - tree_bg->Add(fullPath.c_str()); + tree_bg->Add(fullPath.c_str()); - // If there are multiple trees per file - // for(int c = 0; c < 3; c++){ // for each category + // If there are multiple trees per file + // for(int c = 0; c < 3; c++){ // for each category // string cat = to_string(c); // string file = v[i]; // string treePath = GetMCTreeName(file); - // string fullPath = backgroundDirec + "/"; + // string fullPath = backgroundDirec + "/"; // fullPath.append(file); // fullPath.append( "/" + treePath + "_13TeV_HHWWggTag_" + cat); - + // // cout << "full path: " << fullPath << endl; // tree_bg->Add(fullPath.c_str()); @@ -150,12 +150,12 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double // } } - // Combine Data Trees + // Combine Data Trees TString Data_Loc_s; // TString Data_Location = Data_Loc_s.Format("%s/Data/Data.root/Data",nTupleLocation.Data()); // TString Data_Location = Data_Loc_s.Format("%s/Data/2017-Data.root/Data",nTupleLocation.Data()); - // TString Data_Location = Data_Loc_s.Format("%s/Data/2017-Data.root/Data",nTupleLocation.Data()); - TString Data_Location = Data_Loc_s.Format("/eos/user/b/bmarzocc/HHWWgg/HHWWgg_DataSignalMCnTuples/HHWWyyDNN_binary_testnewfiles_allBkgs/2017-Data.root/Data"); + // TString Data_Location = Data_Loc_s.Format("%s/Data/2017-Data.root/Data",nTupleLocation.Data()); + TString Data_Location = Data_Loc_s.Format("/eos/user/b/bmarzocc/HHWWgg/HHWWgg_DataSignalMCnTuples/HHWWyyDNN_binary_testnewfiles_allBkgs/2017-Data.root/Data"); TChain *tree_data = new TChain("tree_data"); tree_data->Add(Data_Location); @@ -163,7 +163,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double // tree_data->Add("/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN/Data/Data.root/Data_13TeV_HHWWggTag_1"); // tree_data->Add("/eos/user/a/atishelm/ntuples/HHWWgg_DataMC/DNN/Data/Data.root/Data_13TeV_HHWWggTag_2"); - // Get Data over Background in sidebands scale factor + // Get Data over Background in sidebands scale factor TH1F* hist_background_sideband = new TH1F("hist_background_sideband","hist_background_sideband",100,-1,1); TH1F* hist_data_sideband = new TH1F("hist_data_sideband","hist_data_sideband",100,-1,1); @@ -197,7 +197,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double if(verbose){ cout << " " << endl; cout << "BG integral under Mgg "<< hist_B->Integral() << endl; - } + } TH1F *hist_B_sideband = new TH1F("hist_B_sideband","hist_B_sideband",int((float(xmax)-float(xmin))/float(bin_width)),float(xmin),float(xmax)); // background sideband region // TH1F *hist_B_sideband = new TH1F("hist_B_sideband","hist_B_sideband",Nbins,float(xmin),float(xmax)); // background sideband region @@ -221,9 +221,9 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double if(verbose){ cout << " " << endl; cout << "Data integral sidebands " << hist_D_sideband->Integral() << endl; - } + } - // Get Start and Ends of Optimization Range + // Get Start and Ends of Optimization Range double END = hist_B->GetBinCenter(hist_B->FindLastBinAbove(-1.)) + hist_B->GetBinWidth(1)/2.; // Left end of BDT distibution double START = hist_B->GetBinCenter(hist_B->FindFirstBinAbove(-1.)) - hist_B->GetBinWidth(1)/2.; // Right end of BDT distibution cout << "START: " << START << endl; @@ -242,7 +242,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double hist_B->SetFillColor(kBlue-10); hist_B->SetLineWidth(2); - // Make Copies of Background and Signal Histograms + // Make Copies of Background and Signal Histograms TH1F *hist_B2 = (TH1F*)hist_B->Clone("b_new"); TH1F *hist_S2 = (TH1F*)hist_S->Clone("s_new"); @@ -300,7 +300,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double float TOTAL_S2OB = 0; for(int i = 0; i < (int) hist_S2->GetEntries(); i++){ - s1 = hist_S2->GetBinContent(i+1); // +1 to skip underflow bin + s1 = hist_S2->GetBinContent(i+1); // +1 to skip underflow bin b1 = hist_B2->GetBinContent(i+1); if(b1 != 0) TOTAL_S2OB += pow(s1,2) / (b1); } @@ -338,13 +338,13 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double std::vector categories_scans; std::vector significance_scans; - // Categorization + // Categorization do { max_n[0] = 0; // I think S^2 / B for one or all categories sig_n[0] = hist_S->Integral(1,hist_S->FindBin(start_n[0])-1); // Optimize cats based on integral of Signifiance? bkg_n[0] = hist_B->Integral(1,hist_B->FindBin(start_n[0])-1); - // Sidebands + // Sidebands bkg_sideband_n[0] = hist_B_sideband->Integral(1,hist_B_sideband->FindBin(start_n[0])-1); data_sideband_n[0] = hist_D_sideband->Integral(1,hist_D_sideband->FindBin(start_n[0])-1); @@ -400,8 +400,8 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double bkg_n[3] = 1; bkg_sideband_n[3] = 1; data_sideband_n[3] = 1; - } - + } + else { sig_n[3] = hist_S->Integral(hist_S->FindBin(start_n[2]),hist_S->FindBin(start_n[3])-1); bkg_n[3] = hist_B->Integral(hist_B->FindBin(start_n[2]),hist_B->FindBin(start_n[3])-1); @@ -415,27 +415,27 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double max_n[4]=0; - if (NCATS<=4) + if (NCATS<=4) { sig_n[4] = 0.; bkg_n[4] = 1.; bkg_sideband_n[4] = 1.; data_sideband_n[4] = 1.; - } - - else + } + + else { sig_n[4] = hist_S->Integral(hist_S->FindBin(start_n[3]),hist_S->GetNbinsX()+1); // FindBin returns the bin number corresponding to the x value - bkg_n[4] = hist_B->Integral(hist_B->FindBin(start_n[3]),hist_B->GetNbinsX()+1); // + bkg_n[4] = hist_B->Integral(hist_B->FindBin(start_n[3]),hist_B->GetNbinsX()+1); // - // Sidebands + // Sidebands bkg_sideband_n[4] = hist_B_sideband->Integral(hist_B_sideband->FindBin(start_n[3]),hist_B_sideband->GetNbinsX()+1); data_sideband_n[4] = hist_D_sideband->Integral(hist_D_sideband->FindBin(start_n[3]),hist_D_sideband->GetNbinsX()+1); // cout << "#5 BIN " << start_n[3] << endl; } - + if (bkg_n[4]!=0) max_n[4]=pow(sig_n[4],2)/bkg_n[4]; double max_sum = 0; @@ -444,8 +444,8 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double max_sum+=max_n[index]; // minevt_cond_n[index] = ( (data_sideband_n[index] >= 4)); // minevt_cond_n[index] = (bkg_sideband_n[index]>=minevents ); - // minevt_cond_n[index] = (bkg_sideband_n[index]>=minevents && (data_sideband_n[index] >= 3)); // 3 hardcoded for number of sideband events - minevt_cond_n[index] = (bkg_sideband_n[index]>=minevents && (data_sideband_n[index] >= 10)); // 3 hardcoded for number of sideband events + // minevt_cond_n[index] = (bkg_sideband_n[index]>=minevents && (data_sideband_n[index] >= 3)); // 3 hardcoded for number of sideband events + minevt_cond_n[index] = (bkg_sideband_n[index]>=minevents && (data_sideband_n[index] >= 10)); // 3 hardcoded for number of sideband events } minevt_cond = std::accumulate(minevt_cond_n, minevt_cond_n + NCATS, 0); // minevt_cond_n+1 for tth only when optimizing separately if (((max_sum)>=max) && (minevt_cond==(NCATS))) { //NCATS-1 for tth @@ -461,13 +461,13 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double } } start_n[3]+=bin_width; - } while (start_n[3]<=(END-(NCATS-4)*bin_width)); // probably max at num cats - NCATS because you can't determine the significance integral for the 1st category so high that cats can't be added at bins starting above it + } while (start_n[3]<=(END-(NCATS-4)*bin_width)); // probably max at num cats - NCATS because you can't determine the significance integral for the 1st category so high that cats can't be added at bins starting above it start_n[2]+=bin_width; } while (start_n[2]<=(END-(NCATS-3)*bin_width)); start_n[1]+=bin_width; } while (start_n[1]<=(END-(NCATS-2)*bin_width)); start_n[0]+=bin_width; - } while (start_n[0]<=(END-(NCATS-1)*bin_width)); + } while (start_n[0]<=(END-(NCATS-1)*bin_width)); borders[NCATS] = END; @@ -484,14 +484,14 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double outborder<Print(s.Format("%s/%s_%s_xMin-%s_Nbins-%s.png",outDir.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),Nbins_str.Data())); // c1->Print(s.Format("%s/%s_%s_xMin-%s_Nbins-%s.pdf",outDir.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),Nbins_str.Data())); c1->Print(s.Format("%s/%s%s_%s_xMin-%s_binWidth-%s.png",outDir.Data(),year.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),binWidth_str.Data())); - c1->Print(s.Format("%s/%s%s_%s_xMin-%s_binWidth-%s.pdf",outDir.Data(),year.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),binWidth_str.Data())); - - + c1->Print(s.Format("%s/%s%s_%s_xMin-%s_binWidth-%s.pdf",outDir.Data(),year.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),binWidth_str.Data())); + + gPad->Update(); frame2->SetMaximum(100); c1->SetLogy(0); - + // c1->Print(s.Format("%s/%s_%s_xMin-%s_Nbins-%s_nonLog.png",outDir.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),Nbins_str.Data())); c1->Print(s.Format("%s/%s%s_%s_xMin-%s_binWidth-%s_nonLog.png",outDir.Data(),year.Data(),scaleOpt.Data(),outname.Data(),xmin_str.Data(),binWidth_str.Data())); @@ -606,11 +606,11 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double double* sign_scan = &significance_scans[0]; int counter = significance_scans.size(); - // TGraph *gr = new TGraph(counter,cat_scan,sign_scan); // significance plot + // TGraph *gr = new TGraph(counter,cat_scan,sign_scan); // significance plot // cout << sign_scan << endl; // cout << "ymin: " << *std::max_element(sign_scan,sign_scan+counter) << endl; - // old end of ymin: * 0.01 + // old end of ymin: * 0.01 ymin = *std::max_element(sign_scan,sign_scan+counter) * 0.01; ymax = *std::max_element(sign_scan,sign_scan+counter) * 1.1; // gr->SetMarkerStyle(20); @@ -644,7 +644,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double gStyle->SetOptStat(0000); int bin_i = 0; - double sig, bkg = 0.; + double sig, bkg = 0.; double sigOverSqrtb = 0; double maxsigOverSqrtb = -99; TH1F * Significance_h = new TH1F("Significance_h","S/#sqrt{B} vs. DNN Score " + scaleOpt,int((float(xmax)-float(xmin))/float(bin_width)),float(xmin),float(xmax)); @@ -652,19 +652,19 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double // TH1F * Significance_h = new TH1F("Significance_h","S/#sqrt{B} vs. DNN Score " + scaleOpt,Nbins,float(xmin),float(xmax)); for(int i = 0; i < (int) hist_S2->GetNbinsX(); i++){ bin_i = i + 1; // +1 to skip underflow bin - sig = hist_S2->GetBinContent(bin_i); + sig = hist_S2->GetBinContent(bin_i); bkg = hist_B2->GetBinContent(bin_i); // if(verbose){ // cout << "evalDNN bin x min: " << Significance_h->GetBinLowEdge(bin_i) << endl; // cout << "S : " << sig << endl; - // cout << "B : " << bkg << endl; + // cout << "B : " << bkg << endl; // } - + if(bkg > 0){ - sigOverSqrtb = sig / sqrt(bkg); - Significance_h->SetBinContent(bin_i, sigOverSqrtb); + sigOverSqrtb = sig / sqrt(bkg); + Significance_h->SetBinContent(bin_i, sigOverSqrtb); if(sigOverSqrtb > maxsigOverSqrtb) maxsigOverSqrtb = sigOverSqrtb; cout << "evalDNN bin x min: " << Significance_h->GetBinLowEdge(bin_i) << endl; cout << "S : " << sig << endl; @@ -673,7 +673,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double } else{ cout << "for DNN val: " << Significance_h->GetBinLowEdge(bin_i) << ", Background Yield < 0: " << bkg << endl; - Significance_h->SetBinContent(bin_i, 0); + Significance_h->SetBinContent(bin_i, 0); } } @@ -699,20 +699,20 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double ofstream catSigOut; // catSigOut.open(s.Format("%s%s_%s_xmin-%s_Nbins-%s_CatSignificances.txt",outDir.Data(),outname.Data(),scaleOpt.Data(),xmin_str.Data(),Nbins_str.Data())); catSigOut.open(s.Format("%s%s_%s_xmin-%s_binWidth-%s_CatSignificances.txt",outDir.Data(),outname.Data(),scaleOpt.Data(),xmin_str.Data(),binWidth_str.Data())); - double cat_min, cat_max = 0.; + double cat_min, cat_max = 0.; double Cat_significance = 0.; int min_bin, max_bin = 0; - double S_total, B_total = 0; + double S_total, B_total = 0; // int numBins = int((float(xmax)-float(xmin))/float(bin_width)); // int num for(int i = 0; i < NCATS; i++){ - cout << "---" << endl; + cout << "---" << endl; // cat_min = borders[i]; // cat_max = borders[i+1]; - //assuming xcutoff 0 for now + //assuming xcutoff 0 for now if(i == 0){ cat_min = xcutoff; cat_max = borders[i+1]; @@ -732,27 +732,27 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double // cout << "(cat_min - xmin) / bin_width: " << (cat_min - xmin) / bin_width << endl; // cout << "cat_max - xmin: " << (cat_max - xmin) << endl; - // cout << "(cat_max - xmin) / bin_width: " << (cat_max - xmin) / bin_width << endl; + // cout << "(cat_max - xmin) / bin_width: " << (cat_max - xmin) / bin_width << endl; cout << "bin_width = " << bin_width << endl; min_bin = (float(cat_min) - float(xmin)) / float(bin_width) + 1; - max_bin = (float(cat_max) - float(xmin)) / float(bin_width); + max_bin = (float(cat_max) - float(xmin)) / float(bin_width); cout << "min_bin : " << min_bin << endl; cout << "max_bin : " << max_bin << endl; // cout << "min_bin low edge: " << hist_S2->GetBinLowEdge(int(min_bin)) << endl; - // cout << "max_bin low edge: " << hist_B2->GetBinLowEdge(int(max_bin)) << endl; + // cout << "max_bin low edge: " << hist_B2->GetBinLowEdge(int(max_bin)) << endl; // Cat_significance = Significance_h->Integral(min_bin,max_bin); // significance for all signal region events in this category S_total = hist_S2->Integral(min_bin, max_bin); B_total = hist_B2->Integral(min_bin, max_bin); - cout << "S: " << S_total << endl; - cout << "B: " << B_total << endl; + cout << "S: " << S_total << endl; + cout << "B: " << B_total << endl; - Cat_significance = S_total / sqrt(B_total); + Cat_significance = S_total / sqrt(B_total); cout << "Significance in the signal region events: " << Cat_significance << endl; catSigOut << "Cat: [" << cat_min << ", " << cat_max << "]: " << Cat_significance << "\n"; cout << "---" << endl; @@ -772,7 +772,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double sig_c->Update(); // https://root-forum.cern.ch/t/drawing-tline-over-a-histogram/10279/3 canvas_ymin = sig_c->GetUymin(); canvas_ymax = sig_c->GetUymax(); - // double cat_min, cat_max = 0.; + // double cat_min, cat_max = 0.; for (int i = 0; i < NCATS-1; i++){ CatLines[i] = new TLine(borders[i+1],canvas_ymin,borders[i+1],canvas_ymax); CatLines[i]->SetLineStyle(9); @@ -794,7 +794,7 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double gPad->Update(); TLine* CatLinesLog[10]; canvas_ymin = sig_c->GetUymin(); - canvas_ymax = sig_c->GetUymax(); + canvas_ymax = sig_c->GetUymax(); for (int i = 0; i < NCATS-1; i++){ Double_t lm = gPad->GetLeftMargin(); Double_t rm = 1.-gPad->GetRightMargin(); @@ -806,13 +806,13 @@ void optimize_cats(const int NCATS, bool scaleBkgSideband, bool verbose, double CatLinesLog[i]->SetLineColor(1); CatLinesLog[i]->SetLineWidth(3); CatLinesLog[i]->DrawLineNDC(xndc,bm,xndc,tm); - } + } // Shaded_Area->SetBinContent(1,100); // Shaded_Area->Draw("hist same"); // sig_c_log->SaveAs(outDir + "Significance_" + scaleOpt + "_" + ext.Data() + "_xmin-" + xmin_str + "_Nbins-" + Nbins_str + "_log.png"); // sig_c_log->SaveAs(outDir + "Significance_" + scaleOpt + "_" + ext.Data() + "_xmin-" + xmin_str + "_Nbins-" + Nbins_str + "_log.pdf"); sig_c_log->SaveAs(outDir + year.Data() + "Significance_" + scaleOpt + "_" + ext.Data() + "_xmin-" + xmin_str + "_binWidth-" + binWidth_str + "_log.png"); - sig_c_log->SaveAs(outDir + year.Data() + "Significance_" + scaleOpt + "_" + ext.Data() + "_xmin-" + xmin_str + "_binWidth-" + binWidth_str + "_log.pdf"); - + sig_c_log->SaveAs(outDir + year.Data() + "Significance_" + scaleOpt + "_" + ext.Data() + "_xmin-" + xmin_str + "_binWidth-" + binWidth_str + "_log.pdf"); + } diff --git a/NtupleAnalysis/CMS_lumi.py b/NtupleAnalysis/CMS_lumi.py new file mode 100644 index 0000000..ce935bf --- /dev/null +++ b/NtupleAnalysis/CMS_lumi.py @@ -0,0 +1,164 @@ +import ROOT as rt + +# CMS_lumi +# Initiated by: Gautier Hamel de Monchenault (Saclay) +# Translated in Python by: Joshua Hardenbrook (Princeton) +# Updated by: Dinko Ferencek (Rutgers) +# + +cmsText = "CMS"; +cmsTextFont = 61 + +writeExtraText = True +extraText = "Preliminary" +extraTextFont = 52 + +lumiTextSize = 0.6*0.8 +lumiTextOffset = 0.2 + +cmsTextSize = 0.75*0.8 +cmsTextOffset = 0.1 + +relPosX = 0.045 +relPosY = 0.035 +relExtraDY = 1.2 + +extraOverCmsTextSize = 0.76 + +lumi_13TeV = "138 fb^{-1}" +# lumi_13TeV = "41.5 fb^{-1}" +lumi_8TeV = "19.7 fb^{-1}" +lumi_7TeV = "5.1 fb^{-1}" +lumi_sqrtS = "" + +drawLogo = False + +def CMS_lumi(pad, iPeriod, iPosX ): + outOfFrame = True + if(iPosX/10==0 ): outOfFrame = True + + alignY_=3 + alignX_=2 + if( iPosX/10==0 ): alignX_=1 + if( iPosX==0 ): alignY_=1 + if( iPosX/10==1 ): alignX_=1 + if( iPosX/10==2 ): alignX_=2 + if( iPosX/10==3 ): alignX_=3 + align_ = 10*alignX_ + alignY_ + + H = pad.GetWh() + W = pad.GetWw() + l = pad.GetLeftMargin() + t = pad.GetTopMargin() + r = pad.GetRightMargin() + b = pad.GetBottomMargin() + e = 0.025 + + pad.cd() + + lumiText = "" + if( iPeriod==1 ): + lumiText += lumi_7TeV + lumiText += " (7 TeV)" + elif ( iPeriod==2 ): + lumiText += lumi_8TeV + lumiText += " (8 TeV)" + + elif( iPeriod==3 ): + lumiText = lumi_8TeV + lumiText += " (8 TeV)" + lumiText += " + " + lumiText += lumi_7TeV + lumiText += " (7 TeV)" + elif ( iPeriod==4 ): + lumiText += lumi_13TeV + lumiText += " (13 TeV)" + elif ( iPeriod==7 ): + if( outOfFrame ):lumiText += "#scale[0.85]{" + lumiText += lumi_13TeV + lumiText += " (13 TeV)" + lumiText += " + " + lumiText += lumi_8TeV + lumiText += " (8 TeV)" + lumiText += " + " + lumiText += lumi_7TeV + lumiText += " (7 TeV)" + if( outOfFrame): lumiText += "}" + elif ( iPeriod==12 ): + lumiText += "8 TeV" + elif ( iPeriod==0 ): + lumiText += lumi_sqrtS + + print lumiText + + latex = rt.TLatex() + latex.SetNDC() + latex.SetTextAngle(0) + latex.SetTextColor(rt.kBlack) + + extraTextSize = extraOverCmsTextSize*cmsTextSize + + latex.SetTextFont(42) + latex.SetTextAlign(31) + latex.SetTextSize(lumiTextSize*t) + + latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText) + + if( outOfFrame ): + latex.SetTextFont(cmsTextFont) + latex.SetTextAlign(11) + latex.SetTextSize(cmsTextSize*t) + latex.DrawLatex(l,1-t+lumiTextOffset*t,cmsText) + + pad.cd() + + posX_ = 0 + if( iPosX%10<=1 ): + posX_ = l + relPosX*(1-l-r) + elif( iPosX%10==2 ): + posX_ = l + 0.5*(1-l-r) + elif( iPosX%10==3 ): + posX_ = 1-r - relPosX*(1-l-r) + + posY_ = 1-t - relPosY*(1-t-b) + + if( not outOfFrame ): + if( drawLogo ): + posX_ = l + 0.045*(1-l-r)*W/H + posY_ = 1-t - 0.045*(1-t-b) + xl_0 = posX_ + yl_0 = posY_ - 0.15 + xl_1 = posX_ + 0.15*H/W + yl_1 = posY_ + CMS_logo = rt.TASImage("CMS-BW-label.png") + pad_logo = rt.TPad("logo","logo", xl_0, yl_0, xl_1, yl_1 ) + pad_logo.Draw() + pad_logo.cd() + CMS_logo.Draw("X") + pad_logo.Modified() + pad.cd() + else: + latex.SetTextFont(cmsTextFont) + latex.SetTextSize(cmsTextSize*t) + latex.SetTextAlign(align_) + latex.DrawLatex(posX_, posY_, cmsText) + if( writeExtraText ) : + latex.SetTextFont(extraTextFont) + latex.SetTextAlign(align_) + latex.SetTextSize(extraTextSize*t) + latex.DrawLatex(posX_, posY_- relExtraDY*cmsTextSize*t, extraText) + elif( writeExtraText ): + # if( iPosX==0): + posX_ = l + relPosX*(1-l-r)*3.5 + posY_ = 1-t+lumiTextOffset*t*2.5 + print("chuw:",posX_,posY_) + latex.SetTextFont(extraTextFont) + latex.SetTextSize(extraTextSize*t) + latex.SetTextAlign(align_) + latex.DrawLatex(posX_, posY_, extraText) + # latex.SetTextFont(extraTextFont) + # latex.SetTextAlign(align_) + # latex.SetTextSize(extraTextSize*t) + # latex.DrawLatex(posX_, posY_- relExtraDY*cmsTextSize*t, extraText) + + pad.Update() diff --git a/NtupleAnalysis/NtupleAnalysis.py b/NtupleAnalysis/NtupleAnalysis.py index 29928a4..a5043a0 100644 --- a/NtupleAnalysis/NtupleAnalysis.py +++ b/NtupleAnalysis/NtupleAnalysis.py @@ -4,22 +4,22 @@ # # The purpose of this module is to analyze HHWWgg ntuples. The current options are: # - Cut flow efficiencies -# - Data / MC comparison +# - Data / MC comparison # -# Example Usage: +# Example Usage: # # ##-- Efficiency Analysis # python NtupleAnalysis.py --Efficiency --folder HHWWgg_v2-4_NMSSM_CutFlow_Hadded/ --note NMSSM_Test --NMSSM --SumTags -# python NtupleAnalysis.py --Efficiency --folder HHWWgg_v2-4_CutFLow_Hadded/ --note EFT_Test --EFT --SumTags -# -# ##-- Efficiency Ratio +# python NtupleAnalysis.py --Efficiency --folder HHWWgg_v2-4_CutFLow_Hadded/ --note EFT_Test --EFT --SumTags +# +# ##-- Efficiency Ratio # python NtupleAnalysis.py --Efficiency --folders HHWWgg_v2-3_Trees_Hadded_some/,HHWWgg_v2-6_Trees_Hadded/ --campaigns HHWWgg_v2-3,HHWWgg_v2-6 --massPoints X1000 --Res --ratio -# +# # ##-- Data / MC Analysis -##-- Plot with and without sideband scale to compare +##-- Plot with and without sideband scale to compare -##-- For HIG-21-014 AN_20_165_v7 ---- post pre-approval talk checks +##-- For HIG-21-014 AN_20_165_v7 ---- post pre-approval talk checks # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HIG-21-014/AN_20_165_v7/Data_MC_SL/ --dataFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_SL_MultiClass_WithMETFix_12LOHH_500epochs_BalanceYields/Data_2017_HHWWggTag_0_MoreVars_v2.root --signalFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_SL_MultiClass_WithMETFix_12LOHH_500epochs_BalanceYields/GluGluToHHTo2G2Qlnu_node_cHHH1_2017.root --bkgDirec /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_SL_MultiClass_WithMETFix_12LOHH_500epochs_BalanceYields/ --VarBatch TrainingVariables --CutsType DataModeling --Lumi 0.3029197 --verbose --SigScale 1 --SB --DNNbinWidth 0.01 --ratioMin 0.5 --ratioMax 1.5 --SidebandScale @@ -38,32 +38,36 @@ # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/ --dataFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/ --VarBatch DNN --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.1 --log --ratioMin 0.5 --ratioMax 1.5 --SidebandScale # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/ --dataFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/ --VarBatch TrainingVariables --CutsType testingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --log --ratioMin 0.1 --ratioMax 2 --SidebandScale # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/WithHggTraining_withSidebandScaling_ANv3/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch TrainingVariables --CutsType testingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --log --ratioMin 0.1 --ratioMax 2 --SidebandScale --log -# python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/WithHggTraining_withSidebandScaling_ANv3/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch TrainingVariables --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --log --ratioMin 0.1 --ratioMax 2 --SidebandScale --log +# python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/WithHggTraining_withSidebandScaling_ANv3/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch TrainingVariables --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --log --ratioMin 0.1 --ratioMax 2 --SidebandScale --log # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/WithHggTraining_withSidebandScaling/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch TrainingVariables --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --log --ratioMin 0.1 --ratioMax 5 --SidebandScale -# python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch RestOfTrainingVars --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --SidebandScale --log +# python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch RestOfTrainingVars --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --SidebandScale --log # python NtupleAnalysis.py --DataMC --ol /eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/January2021-Production/ --dataFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/Data_2017_HHWWggTag_0_MoreVars.root --signalFile /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_noHgg_BalanceYields_allBkgs_oddSignal_v3/GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root --bkgDirec /eos/user/b/bmarzocc/HHWWgg/January_2021_Production/HHWWyyDNN_binary_withHgg_BalanceYields_allBkgs_LOSignals_noPtOverM/ --VarBatch Jet --CutsType TrainingSelections --Lumi 41.5 --verbose --SigScale 1 --SB --DNNbinWidth 0.0333 --SidebandScale # -# ##-- Gen / Reco Analysis +# ##-- Gen / Reco Analysis # python NtupleAnalysis.py --GenReco ######################################################################################################################################################################################################### -##-- Import python modules -from python.Options import * -from python.NtupleAnalysisTools import * -from ROOT import gPad, TAxis, TTree, TChain, TLine, TGraph, TMultiGraph, TFile, TCanvas, gROOT, TH2F, TH1F, kPink, kGreen, kCyan, TLegend, kRed, kOrange, kBlack, TLegend, gStyle, TObjArray, kBlue, TGraphErrors +##-- Import python modules +from python.Options import * +from python.NtupleAnalysisTools import * +from ROOT import gPad, TAxis, TTree, TChain, TLine, TGraph, TMultiGraph, TFile, TCanvas, gROOT, TH2F, TH1F, kPink, kGreen, kCyan, kRed, kOrange, kBlack, TLegend, gStyle, TObjArray, kBlue, TGraphErrors from array import array -import os +import os -##-- Define flags and variables based on user input +##-- Define flags and variables based on user input args = GetOptions() +print("Start of program...") + if __name__ == '__main__': - gROOT.SetBatch(1) # Do not output upon draw statement - if(args.Efficiency): ol = '/eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/cutFlow/' - elif(args.DataMC): - if(args.testFeatures): ol = '/eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/DataMC_testFeatures/' - else: - ol = args.ol # '/eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/DNN_addWjets/' + gROOT.SetBatch(1) # Do not output upon draw statement + if(args.Efficiency): ol = '/eos/user/r/rasharma/www/doubleHiggs/NtupleAnalysis_2022March/cutFlow/' + elif(args.DataMC): + print("Data/MC comparison...") + if(args.testFeatures): ol = '/eos/user/r/rasharma/www/doubleHiggs/NtupleAnalysis_2022March/' + # nTupleDirec = '/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN/' + else: + ol = args.ol # '/eos/user/a/atishelm/www/HHWWgg/NtupleAnalysis/DNN_addWjets/' if(not os.path.exists(ol)): print("Path %s does not exist, so creating it now") print('mkdir %s'%(ol)) @@ -76,8 +80,8 @@ nMassPoints = len(args.massPoints.split(',')) ratio_x_vals = [] for i in range(5): - exec("c1_y_vals_%s = array( 'd' )"%(i)) # campaign 1 efficiencies - exec("c2_y_vals_%s = array ( 'd' )"%(i)) # campaign 2 efficiencies + exec("c1_y_vals_%s = array( 'd' )"%(i)) # campaign 1 efficiencies + exec("c2_y_vals_%s = array ( 'd' )"%(i)) # campaign 2 efficiencies folders = args.folders.split(',') campaigns = args.campaigns.split(',') @@ -94,7 +98,7 @@ x_values = array( 'd' ) x_errors = array( 'd' ) y_errors = array( 'd' ) - y_sigeff00 = array( 'd' ) # MicroAOD (efficiency of 1). Need # of events. + y_sigeff00 = array( 'd' ) # MicroAOD (efficiency of 1). Need # of events. for i in range(5): exec("y_sigeff%s = array( 'd' )"%(i)) Npoints = 0 @@ -125,34 +129,34 @@ # print"orderedFiles:",orderedFiles - # badMasses = ['X750','SM'] # masses to not include in the plot + # badMasses = ['X750','SM'] # masses to not include in the plot badMasses = [] plotLabels = [] - + # for fi,file in enumerate(os.listdir(direc)): # for fi,path in enumerate(files): for fi,path in enumerate(orderedFiles): print("path:",path) Npass_0_tot, Npass_1_tot, Npass_2_tot, Npass_3_tot, Npass_4_tot = 0,0,0,0,0 badmass = 0 - if(args.Res): + if(args.Res): mass = path.split('_')[1] print('On mass:',mass) - for bM in badMasses: - if mass == bM: badmass = 1 - if (badmass): continue + for bM in badMasses: + if mass == bM: badmass = 1 + if (badmass): continue # print"massPoints:",massPoints - if(mass not in massPoints): continue + if(mass not in massPoints): continue x_values.append(float(mass[1:])) if(iFolder==0): ratio_x_vals.append(float(mass[1:])) - + nTotEvents = GetEvents(mass,campaign) elif(args.EFT): SM_point = 0 print("thing:",path.split('_')[0]) if path.split('_')[0] == "SM": - SM_point = 1 + SM_point = 1 x_values.append(fi) nTotEvents = GetEvents("SM") plotLabels.append("SM") @@ -175,32 +179,32 @@ my = path.split('_')[3] massPair = "%s_%s"%(mx,my) print("massPair:",massPair) - x_values.append(fi) # file i + x_values.append(fi) # file i nTotEvents = GetEvents(massPair) massPairString = massPair.replace("_",", ") plotLabels.append(massPairString) y_sigeff00.append(1) # Max efficiency - Npoints += 1 + Npoints += 1 x_errors.append(0.5) y_errors.append(0) # if(SM_point): ntags = 1 # else: ntags = 2 ntags = 3 - if(campaign=="HHWWgg_v2-3"): ntags = 3 - elif(campaign=="HHWWgg_v2-6"): ntags = 3 + if(campaign=="HHWWgg_v2-3"): ntags = 3 + elif(campaign=="HHWWgg_v2-6"): ntags = 3 print("ntags:",ntags) - # if(args.SumTags): ntags = 3 - # if(args.SumTags): ntags = 2 - # else: ntags = 1 + # if(args.SumTags): ntags = 3 + # if(args.SumTags): ntags = 2 + # else: ntags = 1 for tag in range(0,ntags): - # if(not args.SumTags and tag == 1): continue + # if(not args.SumTags and tag == 1): continue # print'path:',path # print'fi =',fi # print'len(orderedFiles):',len(orderedFiles) - # if fi == len(orderedFiles) - 2: continue + # if fi == len(orderedFiles) - 2: continue color = colors[fi] print('Num events in MicroAOD:',nTotEvents) @@ -208,15 +212,16 @@ signal_path = direc + '/' + str(path) signal_file = TFile.Open(signal_path) if(args.Res): treeEnd = 'ggF_' + mass + '_WWgg_qqlnugg_13TeV_HHWWggTag_%s'%(tag) - elif(args.EFT): + elif(args.EFT): if(SM_point): treeEnd = 'ggF_SM_WWgg_qqlnugg_13TeV_HHWWggTag_%s'%(tag) else: treeEnd = 'GluGluToHHTo_WWgg_qqlnu_node%s_13TeV_HHWWggTag_%s'%(BM,tag) - - elif(args.NMSSM): treeEnd = 'NMSSM_XYHWWggqqlnu_%s_13TeV_HHWWggTag_%s'%(massPair,tag) - sig_tree = signal_file.Get('tagsDumper/trees/' + treeEnd) + elif(args.NMSSM): treeEnd = 'NMSSM_XYHWWggqqlnu_%s_13TeV_HHWWggTag_%s'%(massPair,tag) - # outputName = mass + '_CutFlow_efficiencies.txt' # output text file path + # sig_tree = signal_file.Get('tagsDumper/trees/' + treeEnd) + sig_tree = signal_file.Get(treeEnd) + + # outputName = mass + '_CutFlow_efficiencies.txt' # output text file path # EfficienciesTxt = "bthresh\tsigeff\tttHeff\n" sig_h_0 = TH1F('sig_h_0','sig_h_0',2,0,2) @@ -251,8 +256,8 @@ y_sigeff4.append(Neff_4) for i in range(5): - if(iFolder == 0): exec("c1_y_vals_%s.append(Neff_%s)"%(i,i)) # campaign 1 efficiencies - if(iFolder == 1): exec("c2_y_vals_%s.append(Neff_%s)"%(i,i)) # campaign 1 efficiencies + if(iFolder == 0): exec("c1_y_vals_%s.append(Neff_%s)"%(i,i)) # campaign 1 efficiencies + if(iFolder == 1): exec("c2_y_vals_%s.append(Neff_%s)"%(i,i)) # campaign 1 efficiencies # sig_tree.Draw(hasHighbjet + ' >> sig_h',hasHighbjet) # NsigPass = float(Nsig) - float(sig_h.GetEntries()) @@ -265,13 +270,13 @@ # EfficienciesTxt += str(bthresh) + "\t" + str(sig_eff) + "\t" + str(ttH_eff) + "\n" # with open(outputName, "w") as output: - # output.write(EfficienciesTxt) # write txt file + # output.write(EfficienciesTxt) # write txt file if(args.NMSSM) or (args.EFT): sig_eff_g_00 = TGraphErrors(Npoints,x_values,y_sigeff00,x_errors,y_errors) # SetBinLabels(sig_eff_g_00,Npoints,plotLabels) for i in range(0,5): - exec("sig_eff_g_%s = TGraphErrors(Npoints,x_values,y_sigeff%s,x_errors,y_errors)"%(i,i)) + exec("sig_eff_g_%s = TGraphErrors(Npoints,x_values,y_sigeff%s,x_errors,y_errors)"%(i,i)) # exec("SetBinLabels(sig_eff_g_%d,Npoints,plotLabels)"%(i)) else: @@ -283,16 +288,16 @@ SetGraphStyle(sig_eff_g_0,10,kBlue, 21) SetGraphStyle(sig_eff_g_1,9,kGreen, 22) SetGraphStyle(sig_eff_g_2,6,kPink, 23) - SetGraphStyle(sig_eff_g_3,2,95,34) # orange - SetGraphStyle(sig_eff_g_4,7,9,33) # purple + SetGraphStyle(sig_eff_g_3,2,95,34) # orange + SetGraphStyle(sig_eff_g_4,7,9,33) # purple if(args.NMSSM) or (args.EFT): SetGraphStyle(sig_eff_g_00,1,kRed,20) SetGraphStyle(sig_eff_g_0,1,kBlue, 21) SetGraphStyle(sig_eff_g_1,1,kGreen, 22) SetGraphStyle(sig_eff_g_2,1,kPink, 23) - SetGraphStyle(sig_eff_g_3,1,95,34) # orange - SetGraphStyle(sig_eff_g_4,1,9,33) # purple + SetGraphStyle(sig_eff_g_3,1,95,34) # orange + SetGraphStyle(sig_eff_g_4,1,9,33) # purple sig_eff_g_00.SetTitle("MicroAOD") sig_eff_g_0.SetTitle("Pass #gamma#gamma cuts") @@ -321,12 +326,13 @@ if args.log: outName += 'Log' if args.note is not "": outName += '_' + str(args.note) outName += '.png' + os.system("mkdir -p "+outName) - if(args.NMSSM) or (args.EFT): + if(args.NMSSM) or (args.EFT): DrawNonResHistogram(mg,"AP",outName,args.log,Npoints,plotLabels) outName = outName.replace("png","pdf") DrawNonResHistogram(mg,"AP",outName,args.log,Npoints,plotLabels) - else: + else: Draw_Histogram(mg,"APL",outName,args.log) outName = outName.replace("png","pdf") Draw_Histogram(mg,"APL",outName,args.log) @@ -339,21 +345,21 @@ print("c1_y_vals_%s"%(i)) exec("print c1_y_vals_%s"%(i)) print("c2_y_vals_%s"%(i)) - exec("print c2_y_vals_%s"%(i)) + exec("print c2_y_vals_%s"%(i)) x_values = array( 'd' ) y_ratioEff00 = array ( 'd' ) for entry in ratio_x_vals: x_values.append(entry) y_ratioEff00.append(1) - + for i in range(5): exec("y_ratioEff%s = array( 'd' )"%(i)) for i in range(len(args.massPoints.split(','))): for j in range(5): ratio = eval("c1_y_vals_%s[%s] / c2_y_vals_%s[%s]"%(j,i,j,i)) eval("y_ratioEff%s.append(%s)"%(j,ratio)) - + Nmasses = len(args.massPoints.split(',')) sig_ratioEff_g_00 = TGraph(Nmasses,x_values,y_ratioEff00) for i in range(0,5): @@ -363,8 +369,8 @@ SetGraphStyle(sig_ratioEff_g_0,10,kBlue, 21) SetGraphStyle(sig_ratioEff_g_1,9,kGreen, 22) SetGraphStyle(sig_ratioEff_g_2,6,kPink, 23) - SetGraphStyle(sig_ratioEff_g_3,2,95,34) # orange - SetGraphStyle(sig_ratioEff_g_4,7,9,33) # purple + SetGraphStyle(sig_ratioEff_g_3,2,95,34) # orange + SetGraphStyle(sig_ratioEff_g_4,7,9,33) # purple sig_ratioEff_g_00.SetTitle("MicroAOD") sig_ratioEff_g_0.SetTitle("Pass #gamma#gamma cuts") @@ -390,39 +396,41 @@ # ratio_mg.SetMinimum(0) # ratio_mg.SetMaximum(1.01) # ratio_mg.SetMinimum(0.5) -# +# # outName = ol + 'CutFlow' + '_' + args.campaign outName = ol + 'CutFlow' + '_' + campaign if args.log: outName += 'Log' if args.note is not "": outName += '_' + str(args.note) outName += '.png' + if(not os.path.exists(outName)): + os.system("mkdir -p "+outName) - if(args.NMSSM) or (args.EFT): + if(args.NMSSM) or (args.EFT): DrawNonResHistogram(ratio_mg,"AP",outName,args.log,Npoints,plotLabels) outName = outName.replace("png","pdf") DrawNonResHistogram(ratio_mg,"AP",outName,args.log,Npoints,plotLabels) - else: + else: Draw_Histogram(ratio_mg,"APL",outName,args.log) outName = outName.replace("png","pdf") Draw_Histogram(ratio_mg,"APL",outName,args.log) - - ##-- Perform Data / MC analysis + + ##-- Perform Data / MC analysis elif(args.DataMC): print("Performing Data / MC Analysis") ##-- Get Data File - dataFile = args.dataFile + dataFile = args.dataFile - ##-- Get Background Files - bkgDirec = args.bkgDirec + ##-- Get Background Files + bkgDirec = args.bkgDirec bkgFiles = GetFiles(bkgDirec) print("bkgFiles:",bkgFiles) - # exit(1) + # exit(1) - ##-- Get Signal File - signalFile = args.signalFile + ##-- Get Signal File + signalFile = args.signalFile - ##-- Run Main Module + ##-- Run Main Module if(not args.SB and not args.SR): print ("No phase space regions selected") print ("To run on the signal region pass the flag --SR") @@ -432,27 +440,28 @@ ##-- Data, MC and Signal Together. Data and MC in sidebands if(args.SB): region = "SB" elif(args.SR): region = "SR" + print("Cut type: "+args.CutsType) cuts, cutNames = GetCuts(args.CutsType) for i in range(0,len(cuts)): cut_ = cuts[i] ## using only first cut. - cutName_ = cutNames[i] ## using only first cut. + cutName_ = cutNames[i] ## using only first cut. print("cut_:",cut_) - print("cutName_:",cutName_) + print("cutName_:",cutName_) chi2 = PlotDataMC(dataFile,bkgFiles,signalFile,ol,args,region,cut_,cutName_,args.DNNbinWidth, args.ratioMin, args.ratioMax) print("chi2:",chi2) - # ##-- MC and Signal in Signal Region - # if(args.SR): + # ##-- MC and Signal in Signal Region + # if(args.SR): # region = "SR" # cuts, cutNames = GetCuts(args.CutsType) # for i in range(0,len(cuts)): # cut_ = cuts[i] ## using only first cut. - # cutName_ = cutNames[i] ## using only first cut. + # cutName_ = cutNames[i] ## using only first cut. # print"cut_:",cut_ - # print"cutName_:",cutName_ + # print"cutName_:",cutName_ # chi2 = PlotDataMC(dataFile,bkgFiles,signalFile,ol,args,region,cut_,cutName_) - # print "chi2:",chi2 - # if(args.SR): + # print "chi2:",chi2 + # if(args.SR): # region = "SR" # PlotDataMC(dataFile,bkgFiles,signalFile,ol,args,region) print("DONE") diff --git a/NtupleAnalysis/Pre-Production-Checks.py b/NtupleAnalysis/Pre-Production-Checks.py index cf93201..50c91c5 100644 --- a/NtupleAnalysis/Pre-Production-Checks.py +++ b/NtupleAnalysis/Pre-Production-Checks.py @@ -1,7 +1,7 @@ from ROOT import * import argparse from array import array -import os +import os parser = argparse.ArgumentParser() parser.add_argument("-p","--plot", action="store_true", default=False, help="Plot", required=False) @@ -14,15 +14,15 @@ def Draw_Histogram(h_,opt_,fn_): c_tmp = TCanvas('c_tmp','c_tmp',1300,800) h_.Draw(opt_) c_tmp.SaveAs(fn_) - return + return def MakeEffPlot(tree_, Note_,ol_, Note2_, SL_channel): print"Computing efficiency for: %s"%(Note_) - if(Note_=="SL"): - print"Semi-Leptonic channel: ",SL_channel + if(Note_=="SL"): + print"Semi-Leptonic channel: ",SL_channel # print"tree:",tree_ n = 100 - x, y = array( 'd' ), array( 'd' ) + x, y = array( 'd' ), array( 'd' ) cuts = [i*0.01 for i in range(1,101)] N_tot_Entries = tree_.GetEntries() @@ -30,18 +30,18 @@ def MakeEffPlot(tree_, Note_,ol_, Note2_, SL_channel): LUMI = "41.5" SIGNAL_SCALE = "1" CHANNEL_SELECTION = "1" - if(Note_=="SL"): - if(SL_channel=="Electron"): - SIGNAL_SCALE = "(31.049*0.00097)*(0.441)" ##-- add lepton flavor selection + if(Note_=="SL"): + if(SL_channel=="Electron"): + SIGNAL_SCALE = "(31.049*0.00097)*(0.441)" ##-- add lepton flavor selection CHANNEL_SELECTION = "(N_goodElectrons==1)" - elif(SL_channel=="Muon"): + elif(SL_channel=="Muon"): SIGNAL_SCALE = "(31.049*0.00097)*(0.441)" CHANNEL_SELECTION = "(N_goodMuons==1)" - + if(Note_=="FH"): SIGNAL_SCALE = "(31.049*0.00097)*(0.454)" if(Note_=="FL"): SIGNAL_SCALE = "(31.049*0.00097)*(0.107)" - ##-- Compute integral with all events once for denominator + ##-- Compute integral with all events once for denominator h_tmp_all = TH1F("h_tmp_all","h_tmp_all",20,115,135) tree_.Draw("CMS_hgg_mass >> h_tmp_all","1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION)) total_weighed_entries = h_tmp_all.Integral() @@ -51,20 +51,20 @@ def MakeEffPlot(tree_, Note_,ol_, Note2_, SL_channel): x.append(cut) condition = "" maxJets = 5 - h_tmp = TH1F("h_tmp","h_tmp",20,115,135) ##-- signal region + h_tmp = TH1F("h_tmp","h_tmp",20,115,135) ##-- signal region for jet_i in range(0,maxJets): scoreFormat = "goodJets_%s_bDiscriminator_mini_pfDeepFlavourJetTags_prob"%(jet_i) variable = "(%s%s + %s%s + %s%s < %s)"%(scoreFormat,"b",scoreFormat,"bb",scoreFormat,"lepb",cut) condition += variable - if jet_i == maxJets-1: break + if jet_i == maxJets-1: break else: condition += " && " - + tree_.Draw("CMS_hgg_mass >> h_tmp","(%s)*weight*(%s)*(%s)*(%s)*(%s)"%(condition,LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION)) tmp_integral = h_tmp.Integral() N_weighted_entries_pass = tmp_integral eff = float(N_weighted_entries_pass) / float(total_weighed_entries) y.append(eff) - del h_tmp + del h_tmp eff_g = TGraph(n,x,y) eff_g.SetMarkerStyle( 21 ) @@ -75,8 +75,8 @@ def MakeEffPlot(tree_, Note_,ol_, Note2_, SL_channel): outputName = ol_ + 'EffVsBthreshold_%s_%s_%s.png'%(Note_,Note2_,SL_channel) else: outputName = ol_ + 'EffVsBthreshold_%s_%s.png'%(Note_,Note2_) - Draw_Histogram(eff_g,'ACP',outputName) - return eff_g + Draw_Histogram(eff_g,'ACP',outputName) + return eff_g def PlotEffVsEffsTogether(g1, g2, g3, ol_): c = TCanvas("c","c",800,600) @@ -84,7 +84,7 @@ def PlotEffVsEffsTogether(g1, g2, g3, ol_): g1.SetLineColor(kBlue) g1.SetLineWidth(2) g1.SetMarkerColor(kBlue) - g1.SetMarkerStyle( 21 ) + g1.SetMarkerStyle( 21 ) g1.SetTitle( 'Sig Eff. vs. ttH Eff' ) g1.GetXaxis().SetTitle( 'ttH efficiency' ) @@ -93,7 +93,7 @@ def PlotEffVsEffsTogether(g1, g2, g3, ol_): g2.SetLineColor(kGreen+2) g2.SetLineWidth(2) g2.SetMarkerColor(kGreen+2) - g2.SetMarkerStyle( 21 ) + g2.SetMarkerStyle( 21 ) g1.Draw("ACP") g2.Draw("CP same") @@ -108,7 +108,7 @@ def PlotEffVsEff(sig_g, ttH_g,ol_,Note_): nEntries = sig_g.GetN() print"sig_g:",sig_g print"sig_g.GetPointX(0):",sig_g.GetPointX(0) - sig_eff_vals_, ttH_eff_vals_ = [], [] + sig_eff_vals_, ttH_eff_vals_ = [], [] for i in range(nEntries): bThresh = sig_g.GetPointX(i) sigPoint = sig_g.GetPointY(i) @@ -136,7 +136,7 @@ def PlotEffVsEff(sig_g, ttH_g,ol_,Note_): effVseff_h.GetXaxis().SetTitle( 'ttH efficiency' ) effVseff_h.GetYaxis().SetTitle( 'signal efficiency' ) outputName = ol_ + 'sigEffvsttHeff_%s.png'%(Note_) - Draw_Histogram(effVseff_h,'ACP',outputName) + Draw_Histogram(effVseff_h,'ACP',outputName) return effVseff_h def PlotAllEffs(signal_SL_g_, signal_FH_g_, signal_FL_g_, ol_, Note_, Note2_, titles_): @@ -151,19 +151,19 @@ def PlotAllEffs(signal_SL_g_, signal_FH_g_, signal_FL_g_, ol_, Note_, Note2_, ti signal_SL_g_.SetLineColor(kBlue) signal_SL_g_.SetLineWidth(2) signal_SL_g_.SetMarkerColor(kBlue) - signal_SL_g_.SetMarkerStyle( 20 ) + signal_SL_g_.SetMarkerStyle( 20 ) signal_FH_g_.SetLineColor(kGreen+2) signal_FH_g_.SetLineWidth(2) signal_FH_g_.SetMarkerColor(kGreen+2) - signal_FH_g_.SetMarkerStyle( 20 ) + signal_FH_g_.SetMarkerStyle( 20 ) signal_FL_g_.SetLineColor(kPink+2) signal_FL_g_.SetLineWidth(2) signal_FL_g_.SetMarkerColor(kPink+2) - signal_FL_g_.SetMarkerStyle( 20 ) + signal_FL_g_.SetMarkerStyle( 20 ) - ##-- Lines at 3 working points + ##-- Lines at 3 working points signal_SL_g_.Draw("ACP") signal_FH_g_.Draw("CP same") signal_FL_g_.Draw("CP same") @@ -188,42 +188,42 @@ def PlotAllEffs(signal_SL_g_, signal_FH_g_, signal_FL_g_, ol_, Note_, Note2_, ti Line_Tight.Draw("same") c.SetTickx(1) c.SetTicky(1) - c.SaveAs("%s%s%sEffsTogether.png"%(ol_,Note_,Note2_)) + c.SaveAs("%s%s%sEffsTogether.png"%(ol_,Note_,Note2_)) def SetGrStyles(gr_, signal_, type_): gr_.SetLineWidth(2) gr_.SetMarkerSize(0.5) - + if(signal_ == "SL"): if(type_ == "prev"): gr_.SetLineColor(kBlue) - gr_.SetMarkerColor(kBlue) + gr_.SetMarkerColor(kBlue) elif(type_ == "upd"): gr_.SetLineColor(kBlue-2) - gr_.SetMarkerColor(kBlue-2) + gr_.SetMarkerColor(kBlue-2) elif(signal_ == "FH"): if(type_ == "prev"): gr_.SetLineColor(kGreen+2) - gr_.SetMarkerColor(kGreen+2) + gr_.SetMarkerColor(kGreen+2) elif(type_ == "upd"): gr_.SetLineColor(kGreen-2) - gr_.SetMarkerColor(kGreen-2) + gr_.SetMarkerColor(kGreen-2) elif(signal_ == "FL"): if(type_ == "prev"): gr_.SetLineColor(kPink+2) - gr_.SetMarkerColor(kPink+2) + gr_.SetMarkerColor(kPink+2) elif(type_ == "upd"): gr_.SetLineColor(kPink-2) - gr_.SetMarkerColor(kPink-2) + gr_.SetMarkerColor(kPink-2) if(type_ == "prev"): - gr_.SetMarkerStyle( 20 ) - gr_.SetLineStyle(2) + gr_.SetMarkerStyle( 20 ) + gr_.SetLineStyle(2) elif(type_ == "upd"): gr_.SetMarkerStyle( 21 ) - gr_.SetLineStyle(1) + gr_.SetLineStyle(1) - return gr_ + return gr_ # def PlotTwoVars(signal_SL_g_, signal_FH_g_, signal_FL_g_, ol_, Note_, Note2_, titles_): def PlotTwoVars(signal_g_one, signal_g_two, signal_tag, ol_, Note_): @@ -240,14 +240,14 @@ def PlotTwoVars(signal_g_one, signal_g_two, signal_tag, ol_, Note_): signal_g_one.GetYaxis().SetRangeUser(0,1) SetGrStyles(signal_g_two, signal_tag, "upd") - + signal_g_one.Draw("ACP") signal_g_two.Draw("CP same") if(signal_tag == "SL"): SL_channel = Note_.split('-')[-1] legendText = "%s %s"%(signal_tag, SL_channel) - else: + else: legendText = "%s"%(signal_tag) l = TLegend(0.35,0.35,0.6,0.6) @@ -269,15 +269,15 @@ def PlotTwoVars(signal_g_one, signal_g_two, signal_tag, ol_, Note_): Line_Tight.Draw("same") c.SetTickx(1) c.SetTicky(1) - c.SaveAs("%s%s%sEffsTogether.png"%(ol_,signal_tag,Note_)) + c.SaveAs("%s%s%sEffsTogether.png"%(ol_,signal_tag,Note_)) def ComputeIntegralRatio(signal_tree, ttH_tree, channel_,ol_,SL_channel, IncludeSFs, FL_channel): print"Computing signal / ttH integral in the signal region for %s"%(channel_) - if(channel_=="SL"): + if(channel_=="SL"): print"Semi-Leptonic channel: ",SL_channel # n = 100 n = 100 ##-- because ratio in 0th bin might be inf. - x, y = array( 'd' ), array( 'd' ) + x, y = array( 'd' ), array( 'd' ) # cuts = [i*0.01 for i in range(0,100)] cuts = [i*0.01 for i in range(1,101)] # N_tot_Entries = tree_.GetEntries() @@ -285,29 +285,29 @@ def ComputeIntegralRatio(signal_tree, ttH_tree, channel_,ol_,SL_channel, Include LUMI = "41.5" SIGNAL_SCALE = "1" CHANNEL_SELECTION = "1" - if(channel_=="SL"): - if(SL_channel=="Electron"): - SIGNAL_SCALE = "(31.049*0.00097)*(0.441)" ##-- add lepton flavor selection + if(channel_=="SL"): + if(SL_channel=="Electron"): + SIGNAL_SCALE = "(31.049*0.00097)*(0.441)" ##-- add lepton flavor selection CHANNEL_SELECTION = "(N_goodElectrons==1)" - elif(SL_channel=="Muon"): - SIGNAL_SCALE = "(31.049*0.00097)*(0.441)*(N_goodMuons==1)" + elif(SL_channel=="Muon"): + SIGNAL_SCALE = "(31.049*0.00097)*(0.441)*(N_goodMuons==1)" CHANNEL_SELECTION = "(N_goodMuons==1)" if(channel_=="FH"): SIGNAL_SCALE = "(31.049*0.00097)*(0.454)" - if(channel_=="FL"): + if(channel_=="FL"): SIGNAL_SCALE = "(31.049*0.00097)*(0.107)" print"****FL_channel = ",FL_channel if(FL_channel == "ee"): CHANNEL_SELECTION = "(FL_Lep_Flavor==0)" elif(FL_channel == "mumu"): CHANNEL_SELECTION = "(FL_Lep_Flavor==1)" elif(FL_channel == "emu"): CHANNEL_SELECTION = "(FL_Lep_Flavor==2)" elif(FL_channel == "mue"): CHANNEL_SELECTION = "(FL_Lep_Flavor==3)" - else: CHANNEL_SELECTION = 1 + else: CHANNEL_SELECTION = 1 SF_SELECTION = "1" - if(not IncludeSFs): + if(not IncludeSFs): print"----------Dividing OUT Scale Factors-----------------" SF_SELECTION = "(1/centralObjectWeight)" - ##-- Compute integral with all events once for denominator + ##-- Compute integral with all events once for denominator h_tmp_Signal_all = TH1F("h_tmp_Signal_all","h_tmp_Signal_all",20,115,135) h_tmp_ttH_all = TH1F("h_tmp_ttH_all","h_tmp_ttH_all",20,115,135) signal_tree.Draw("CMS_hgg_mass >> h_tmp_Signal_all","1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) @@ -319,20 +319,20 @@ def ComputeIntegralRatio(signal_tree, ttH_tree, channel_,ol_,SL_channel, Include print"Ratio in Signal Region no cut:",float(totalSignal) / float(totalttH) for icut,cut in enumerate(cuts): - # print"icut: ",icut + # print"icut: ",icut x.append(cut) - # print"cut value btag < :",cut + # print"cut value btag < :",cut condition = "" maxJets = 5 - h_tmp = TH1F("h_tmp","h_tmp",20,115,135) ##-- signal region - h_tmp_ttH = TH1F("h_tmp_ttH","h_tmp_ttH",20,115,135) ##-- ttH in signal region + h_tmp = TH1F("h_tmp","h_tmp",20,115,135) ##-- signal region + h_tmp_ttH = TH1F("h_tmp_ttH","h_tmp_ttH",20,115,135) ##-- ttH in signal region for jet_i in range(0,maxJets): scoreFormat = "goodJets_%s_bDiscriminator_mini_pfDeepFlavourJetTags_prob"%(jet_i) variable = "(%s%s + %s%s + %s%s < %s)"%(scoreFormat,"b",scoreFormat,"bb",scoreFormat,"lepb",cut) condition += variable - if jet_i == maxJets-1: break + if jet_i == maxJets-1: break else: condition += " && " - # print "condition = ",condition + # print "condition = ",condition signal_tree.Draw("CMS_hgg_mass >> h_tmp","(%s)*weight*(%s)*(%s)*(%s)*(%s)"%(condition,LUMI,SIGNAL_SCALE,CHANNEL_SELECTION,SF_SELECTION)) ttH_tree.Draw("CMS_hgg_mass >> h_tmp_ttH","(%s)*weight*(%s)*(%s)*(%s)"%(condition,LUMI,CHANNEL_SELECTION,SF_SELECTION)) @@ -344,7 +344,7 @@ def ComputeIntegralRatio(signal_tree, ttH_tree, channel_,ol_,SL_channel, Include # N_weighted_entries_pass = tmp_integral # eff = float(N_weighted_entries_pass) / float(total_weighed_entries) # y.append(eff) - del h_tmp + del h_tmp del h_tmp_ttH sigTottHRatio_g = TGraph(n,x,y) @@ -352,15 +352,15 @@ def ComputeIntegralRatio(signal_tree, ttH_tree, channel_,ol_,SL_channel, Include sigTottHRatio_g.SetTitle( '%s Signal integral / ttH integral in signal region'%(channel_) ) sigTottHRatio_g.GetXaxis().SetTitle( 'b Score Threshold' ) sigTottHRatio_g.GetYaxis().SetTitle( '%s / ttH'%(channel_) ) - + if(channel_=="SL"): outputName = ol_ + 'SigOverttHVsBthreshold_%s_%s.png'%(channel_,SL_channel) elif(channel_=="FL"): outputName = ol_ + 'SigOverttHVsBthreshold_%s_%s.png'%(channel_,FL_channel) else: - outputName = ol_ + 'SigOverttHVsBthreshold_%s.png'%(channel_) - Draw_Histogram(sigTottHRatio_g,'ACP',outputName) - return sigTottHRatio_g + outputName = ol_ + 'SigOverttHVsBthreshold_%s.png'%(channel_) + Draw_Histogram(sigTottHRatio_g,'ACP',outputName) + return sigTottHRatio_g def CombineRatioGraphs(SLTottHRatio_g_, FHTottHRatio_g_, FLTottHRatio_g_, ol_): c = TCanvas("c","c",800,600) @@ -376,19 +376,19 @@ def CombineRatioGraphs(SLTottHRatio_g_, FHTottHRatio_g_, FLTottHRatio_g_, ol_): SLTottHRatio_g_.SetLineColor(kBlue) SLTottHRatio_g_.SetLineWidth(2) SLTottHRatio_g_.SetMarkerColor(kBlue) - SLTottHRatio_g_.SetMarkerStyle( 20 ) + SLTottHRatio_g_.SetMarkerStyle( 20 ) FHTottHRatio_g_.SetLineColor(kGreen+2) FHTottHRatio_g_.SetLineWidth(2) FHTottHRatio_g_.SetMarkerColor(kGreen+2) - FHTottHRatio_g_.SetMarkerStyle( 20 ) + FHTottHRatio_g_.SetMarkerStyle( 20 ) FLTottHRatio_g_.SetLineColor(kPink+2) FLTottHRatio_g_.SetLineWidth(2) FLTottHRatio_g_.SetMarkerColor(kPink+2) - FLTottHRatio_g_.SetMarkerStyle( 20 ) + FLTottHRatio_g_.SetMarkerStyle( 20 ) - ##-- Lines at 3 working points + ##-- Lines at 3 working points SLTottHRatio_g_.Draw("ACP") FHTottHRatio_g_.Draw("CP same") FLTottHRatio_g_.Draw("CP same") @@ -414,13 +414,13 @@ def CombineRatioGraphs(SLTottHRatio_g_, FHTottHRatio_g_, FLTottHRatio_g_, ol_): c.SetTicky(1) # c.SetLeftMargin(0.5) - c.SaveAs("%s/SigOverttHRatiosTogether.png"%(ol_)) + c.SaveAs("%s/SigOverttHRatiosTogether.png"%(ol_)) # def GetTrees(prefix): - # #-- LooseElecID_TightMuonIDISO Files - # signal_path_SL = "%sSL_SM2017.root"%(prefix) - # signal_path_FH = "%sFH_SM2017.root"%(prefix) - # signal_path_FL = "%sFL_SM2017.root"%(prefix) + # #-- LooseElecID_TightMuonIDISO Files + # signal_path_SL = "%sSL_SM2017.root"%(prefix) + # signal_path_FH = "%sFH_SM2017.root"%(prefix) + # signal_path_FL = "%sFL_SM2017.root"%(prefix) # ttH_path = "%sttHJetToGG_2017.root"%(prefix) # signal_file_SL = TFile.Open(signal_path_SL) # signal_file_FH = TFile.Open(signal_path_FH) @@ -445,28 +445,28 @@ def CombineRatioGraphs(SLTottHRatio_g_, FHTottHRatio_g_, FLTottHRatio_g_, ol_): # for finalState in ["SL","FH","FL"]: # print"num %s signal entries: "%(finalState) # exec('print eval("%s_tree.GetEntries()")'%(finalState)) - + # print"num %s ttH entries: "%(finalState) # exec('print eval("ttH_%s_tree.GetEntries()")'%(finalState)) - # return SL_tree, FH_tree, FL_tree, ttH_SL_tree, ttH_FH_tree, ttH_FL_tree + # return SL_tree, FH_tree, FL_tree, ttH_SL_tree, ttH_FH_tree, ttH_FL_tree def ComputeEff(Direc_, ttHFile_LETM_, ttHFile_MEMM_): - print"Computing Efficiency" + print"Computing Efficiency" files = [os.path.join(Direc_, file) for file in os.listdir(Direc_)] for file in files: print"file:",file tfile = TFile.Open(file) - if("SL" in file): + if("SL" in file): channel = "SL" treeName = "tagsDumper/trees/GluGluToHHTo2G2Qlnu_node_cHHH1_13TeV_HHWWggTag_CAT" sigCat = treeName[:].replace("CAT","0") - elif("FL" in file): + elif("FL" in file): channel = "FL" treeName = "tagsDumper/trees/GluGluToHHTo2G2l2nu_node_cHHH1_13TeV_HHWWggTag_CAT" sigCat = treeName[:].replace("CAT","2") - untaggedCat = treeName[:].replace("CAT","3") + untaggedCat = treeName[:].replace("CAT","3") sigTree = tfile.Get(sigCat) untaggedTree = tfile.Get(untaggedCat) @@ -478,9 +478,9 @@ def ComputeEff(Direc_, ttHFile_LETM_, ttHFile_MEMM_): SIGNAL_SCALE = sigScaleDict[channel] PHOTON_CUTS = "( ( (Leading_Photon_pt / CMS_hgg_mass) > 0.33 ) && ( (Subleading_Photon_pt / CMS_hgg_mass) > 0.25 ) )" LUMI = "41.5" - SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied - # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors - CHANNEL_SELECTION = "(1)" ##-- for each channel in cat + SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied + # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors + CHANNEL_SELECTION = "(1)" ##-- for each channel in cat channelDict = { "SL" : [["SL_e","(N_goodElectrons==1)"],["SL_mu","(N_goodMuons==1)"]], @@ -492,29 +492,29 @@ def ComputeEff(Direc_, ttHFile_LETM_, ttHFile_MEMM_): ##-- One denominator value for all subchannels, compute first h_tmp_sig = TH1F("h_tmp_sig","h_tmp_sig",20,115,135) h_tmp_untag = TH1F("h_tmp_untag","h_tmp_untag",20,115,135) - sigTree.Draw("CMS_hgg_mass >> h_tmp_sig","1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,SF_SELECTION)) - untaggedTree.Draw("CMS_hgg_mass >> h_tmp_untag","1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,SF_SELECTION)) + sigTree.Draw("CMS_hgg_mass >> h_tmp_sig","1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,SF_SELECTION)) + untaggedTree.Draw("CMS_hgg_mass >> h_tmp_untag","1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,SF_SELECTION)) sigTot = h_tmp_sig.Integral() untagTot = h_tmp_untag.Integral() - totalYield = float(sigTot) + float(untagTot) + totalYield = float(sigTot) + float(untagTot) print"totalYield:",totalYield del h_tmp_sig - del h_tmp_untag + del h_tmp_untag for subchannel in subchannels: sc_name, CHANNEL_SELECTION = subchannel[0], subchannel[1] print"sc_name:",sc_name h_tmp_sig = TH1F("h_tmp_sig","h_tmp_sig",20,115,135) - sigTree.Draw("CMS_hgg_mass >> h_tmp_sig","1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) + sigTree.Draw("CMS_hgg_mass >> h_tmp_sig","1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) totalSig = h_tmp_sig.Integral() # print"totalSig:",totalSig - # print"tag Efficiency:", float(totalSig) / float(totalYield) + # print"tag Efficiency:", float(totalSig) / float(totalYield) - del h_tmp_sig + del h_tmp_sig if(sc_name == "SL_e" or sc_name == "SL_mu"): - ##-- Make ttH comparison + ##-- Make ttH comparison lepVarDict = { "SL_e" : "goodElectrons_0_pt", "SL_mu" : "goodMuons_0_pt" @@ -534,11 +534,11 @@ def ComputeEff(Direc_, ttHFile_LETM_, ttHFile_MEMM_): ttHSigTree = ttHtfile.Get(ttHtreeName) ttH_lep_pt_h = TH1F("ttH_lep_pt_h","ttH_lep_pt_h",100,0,200) SL_lep_pt_h = TH1F("SL_lep_pt_h","SL_lep_pt_h",100,0,200) - ttHSigTree.Draw("%s >> ttH_lep_pt_h"%(leptonVariable),"1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) + ttHSigTree.Draw("%s >> ttH_lep_pt_h"%(leptonVariable),"1*weight*(%s)*(%s)*(%s)*(%s)"%(LUMI,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) ttH_lep_pt_h.Print() ttH_lep_pt_h.Scale(1/ttH_lep_pt_h.Integral()) ttH_lep_pt_h.SetDirectory(0) - sigTree.Draw("%s >> SL_lep_pt_h"%(leptonVariable),"1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) + sigTree.Draw("%s >> SL_lep_pt_h"%(leptonVariable),"1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,SIGNAL_SCALE,PHOTON_CUTS,CHANNEL_SELECTION,SF_SELECTION)) SL_lep_pt_h.Print() SL_lep_pt_h.Scale(1/SL_lep_pt_h.Integral()) SL_lep_pt_h.SetDirectory(0) @@ -557,44 +557,44 @@ def ComputeEff(Direc_, ttHFile_LETM_, ttHFile_MEMM_): l.AddEntry(ttH_lep_pt_h,"ttH","f") l.AddEntry(SL_lep_pt_h,"SL","f") l.SetBorderSize(0) - l.Draw("same") - c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Lep-ID-ISO/%s-SLTagged-%s-pt.png"%(idType,sc_name)) + l.Draw("same") + c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Lep-ID-ISO/%s-SLTagged-%s-pt.png"%(idType,sc_name)) - return + return # def PUJetIDCompare(Data_NoPUJetID_, Data_TightPUJetID_, FH_NoPUJetID_, FH_TightPUJetID_): def PUJetIDCompare(Direc_): - ##-- Plot Datasidebands, Signal with and without PUJetID - ##-- Put yields on plot - ##-- S / sqrt(B) for each case - ##-- Should also plot N_goodJets for all final state tags, but then don't have signal to compare to + ##-- Plot Datasidebands, Signal with and without PUJetID + ##-- Put yields on plot + ##-- S / sqrt(B) for each case + ##-- Should also plot N_goodJets for all final state tags, but then don't have signal to compare to print"PUJetIDCompare" Variable = "CMS_hgg_mass" # Variable = "N_goodJets" Tags = ["0","1","2","3"] # Tags = ["1"] for Tag in Tags: - Data_hists = [] - Signal_hists = [] + Data_hists = [] + Signal_hists = [] files = [os.path.join(Direc_, file) for file in os.listdir(Direc_)] for file in files: print"file:",file tfile = TFile.Open(file) - if("SL" in file): + if("SL" in file): channel = "SL" treeName = "tagsDumper/trees/GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_%s"%(Tag) - elif("FH" in file): + elif("FH" in file): channel = "FH" treeName = "tagsDumper/trees/GluGluToHHTo2G4Q_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_%s"%(Tag) - elif("FL" in file): + elif("FL" in file): channel = "FL" - treeName = "tagsDumper/trees/GluGluToHHTo2G2l2nu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_%s"%(Tag) - elif("Data" in file): + treeName = "tagsDumper/trees/GluGluToHHTo2G2l2nu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_%s"%(Tag) + elif("Data" in file): channel = "Data" treeName = "tagsDumper/trees/Data_13TeV_HHWWggTag_%s"%(Tag) tree = tfile.Get(treeName) SIGNAL_REGION_CUT = "(CMS_hgg_mass >= 115 && CMS_hgg_mass <= 135)" - DATA_SIDEBANDS_CUT = "(CMS_hgg_mass < 115 || CMS_hgg_mass > 135)" + DATA_SIDEBANDS_CUT = "(CMS_hgg_mass < 135 || CMS_hgg_mass > 135)" sigScaleDict = { "FL" : ["(31.049*0.00097)*(0.107)",SIGNAL_REGION_CUT], "SL" : ["(31.049*0.00097)*(0.441)",SIGNAL_REGION_CUT], @@ -607,11 +607,11 @@ def PUJetIDCompare(Direc_): # PHOTON_CUTS = "( ( (Leading_Photon_pt / CMS_hgg_mass) > 0.33 ) && ( (Subleading_Photon_pt / CMS_hgg_mass) > 0.25 ) )*(dipho_pt > 160)" LUMI = "41.5" SF_SELECTION = "(1)" - # SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied - # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors - CHANNEL_SELECTION = "(1)" ##-- for each channel in cat + # SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied + # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors + CHANNEL_SELECTION = "(1)" ##-- for each channel in cat - ##-- Plot distribution + ##-- Plot distribution binDict = { "N_goodJets" : [10,0,10], "CMS_hgg_mass" : [80,100,180] @@ -621,10 +621,10 @@ def PUJetIDCompare(Direc_): nJetsInfo = 10 # for PUJetIDType in ["None","Loose","Medium","Tight"]: for PUJetIDType in ["None","Loose","Medium","Tight"]: - Cut = "(" + Cut = "(" if(PUJetIDType == "None"): PUJETIDCUTS_Info.append(["(1)","None"]) - continue + continue for i in range(0,nJetsInfo): Cut += "(goodJets_%s_Pass%sJetPUID==1) "%(i,PUJetIDType) if(i < nJetsInfo-1): Cut += "+" @@ -636,7 +636,7 @@ def PUJetIDCompare(Direc_): if(channel == "Data"): LUMI = "(1)" tree.Draw("%s >> h"%(Variable),"1*weight*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,PHOTON_CUTS,REGION_SELECTION,SIGNAL_SCALE,PUJETIDCUT)) - else: + else: tree.Draw("%s >> h"%(Variable),"1*weight*(%s)*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,PHOTON_CUTS,REGION_SELECTION,SIGNAL_SCALE,PUJETIDCUT,SF_SELECTION)) # elif(channel == "FH"): # tree.Draw("%s >> h"%(Variable),"1*weight*(%s)*(%s)*(%s)*(%s)*(%s)*(%s)"%(LUMI,PHOTON_CUTS,REGION_SELECTION,SIGNAL_SCALE,PUJETIDCUT,SF_SELECTION)) @@ -648,13 +648,13 @@ def PUJetIDCompare(Direc_): Signal_hists.append([h, "%s"%(PUJetIDType)]) print"Data_hists:",Data_hists - print"Signal_hists:",Signal_hists + print"Signal_hists:",Signal_hists data_c = TCanvas("data_c","data_c",800,600) data_l = TLegend(0.6,0.6,0.85,0.85) gStyle.SetOptStat(0) for i,dHist_info in enumerate(Data_hists): - dHist, plotType = dHist_info[0], dHist_info[1] + dHist, plotType = dHist_info[0], dHist_info[1] colorMap = { "None" : "kRed+2", "Loose" : "kGreen+2", @@ -664,35 +664,35 @@ def PUJetIDCompare(Direc_): color = colorMap[plotType] # dHist.SetFillColorAlpha(eval(color),0.5) dHist.SetFillColor(eval(color)) - if(Variable == "N_goodJets"): ## -- want to look at change in shape + if(Variable == "N_goodJets"): ## -- want to look at change in shape total = dHist.Integral() if(total != 0 and Tag != "0"): dHist.Scale(1 / total) - dHist.GetYaxis().SetRangeUser(0,0.8) + dHist.GetYaxis().SetRangeUser(0,0.8) if(Tag == "0"): - dHist.GetYaxis().SetRangeUser(0,3000) - dHist.GetYaxis().SetTitle("Normalized Entries") + dHist.GetYaxis().SetRangeUser(0,3000) + dHist.GetYaxis().SetTitle("Normalized Entries") dHist.SetFillColorAlpha(eval(color),0) dHist.SetLineColor(eval(color)) dHist.SetLineWidth(3) data_l.AddEntry(dHist, "%s"%(plotType),"f") - if(i==0): + if(i==0): dHist.SetTitle(Variable) dHist.GetXaxis().SetTitle(Variable) dHist.Draw("hist") - else: + else: dHist.Draw("hist same") data_l.SetBorderSize(0) - data_l.Draw("same") + data_l.Draw("same") data_c.SetTickx(1) data_c.SetTicky(1) data_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/PUJetID/Data-%s-HHWWggTag_%s-all.png"%(Variable,Tag)) - + signal_c = TCanvas("signal_c","signal_c",800,600) signal_l = TLegend(0.6,0.6,0.85,0.85) gStyle.SetOptStat(0) for i,sHist_info in enumerate(Signal_hists): - sHist, plotType = sHist_info[0], sHist_info[1] + sHist, plotType = sHist_info[0], sHist_info[1] colorMap = { "None" : "kRed+2", "Loose" : "kGreen+2", @@ -702,28 +702,28 @@ def PUJetIDCompare(Direc_): color = colorMap[plotType] # sHist.SetFillColorAlpha(eval(color),0.5) sHist.SetFillColor(eval(color)) - if(Variable == "N_goodJets"): ## -- want to look at change in shape + if(Variable == "N_goodJets"): ## -- want to look at change in shape total = sHist.Integral() if(total != 0 and Tag != "0"): - sHist.Scale(1 / total) + sHist.Scale(1 / total) sHist.GetYaxis().SetRangeUser(0,0.8) if(Tag == "0"): sHist.GetYaxis().SetRangeUser(0,3000) - sHist.GetYaxis().SetTitle("Normalized Entries") + sHist.GetYaxis().SetTitle("Normalized Entries") sHist.SetFillColorAlpha(eval(color),0) sHist.SetLineColor(eval(color)) sHist.SetLineWidth(3) signal_l.AddEntry(sHist, "%s"%(plotType),"f") - if(i==0): + if(i==0): sHist.SetTitle(Variable) - sHist.GetXaxis().SetTitle(Variable) + sHist.GetXaxis().SetTitle(Variable) sHist.Draw("hist") - else: + else: sHist.Draw("hist same") signal_l.SetBorderSize(0) - signal_l.Draw("same") + signal_l.Draw("same") signal_c.SetTickx(1) - signal_c.SetTicky(1) + signal_c.SetTicky(1) signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/PUJetID/Signal-%s-Channel-%s-HHWWggTag_%s-all.png"%(Variable,channel,Tag)) def PlotBscores(Direc_): @@ -734,28 +734,28 @@ def PlotBscores(Direc_): # Variables = [""] # Tags = ["2"] # for Tag in Tags: - Data_hists = [] - Signal_hists = [] + Data_hists = [] + Signal_hists = [] files = [os.path.join(Direc_, file) for file in os.listdir(Direc_)] for file in files: print"file:",file tfile = TFile.Open(file) - if("SL" in file): + if("SL" in file): channel = "SL" - treeName = "tagsDumper/trees/GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_0" - elif("FH" in file): + treeName = "tagsDumper/trees/GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_0" + elif("FH" in file): channel = "FH" treeName = "tagsDumper/trees/GluGluToHHTo2G4Q_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_1" elif("FL" in file): channel = "FL" # treeName = "tagsDumper/trees/GluGluToHHTo2G2l2nu_node_cHHH1_13TeV_HHWWggTag_2" treeName = "tagsDumper/trees/GluGluToHHTo2G2l2nu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8_13TeV_HHWWggTag_2" - # elif("Data" in file): + # elif("Data" in file): # channel = "Data" # treeName = "tagsDumper/trees/Data_13TeV_HHWWggTag_%s"%(Tag) tree = tfile.Get(treeName) SIGNAL_REGION_CUT = "(CMS_hgg_mass >= 115 && CMS_hgg_mass <= 135)" - DATA_SIDEBANDS_CUT = "(CMS_hgg_mass < 115 || CMS_hgg_mass > 135)" + DATA_SIDEBANDS_CUT = "(CMS_hgg_mass < 135 || CMS_hgg_mass > 135)" sigScaleDict = { "FL" : ["(31.049*0.00097)*(0.107)",SIGNAL_REGION_CUT], "SL" : ["(31.049*0.00097)*(0.441)",SIGNAL_REGION_CUT], @@ -768,11 +768,11 @@ def PlotBscores(Direc_): # PHOTON_CUTS = "( ( (Leading_Photon_pt / CMS_hgg_mass) > 0.33 ) && ( (Subleading_Photon_pt / CMS_hgg_mass) > 0.25 ) )*(dipho_pt > 160)" LUMI = "41.5" SF_SELECTION = "(1)" - # SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied - # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors - # CHANNEL_SELECTION = "(1)" ##-- for each channel in cat + # SF_SELECTION = "(1/JetBTagReshapeWeightCentral)" ##-- Remove btag SF if no bVeto applied + # SF_SELECTION = "(1/centralObjectWeight)" ##-- No scale factors + # CHANNEL_SELECTION = "(1)" ##-- for each channel in cat - ##-- Plot distribution + ##-- Plot distribution binDict = { "N_goodJets" : [10,0,10], "CMS_hgg_mass" : [80,100,180], @@ -795,7 +795,7 @@ def PlotBscores(Direc_): for jet_i in range(0,nGoodJets): if(Variable == "bScores"): jetStr = "goodJets_%s_bDiscriminator_mini_pfDeepFlavourJetTags_prob"%(jet_i) - var = "(%sb + %sbb + %slepb)"%(jetStr, jetStr, jetStr) + var = "(%sb + %sbb + %slepb)"%(jetStr, jetStr, jetStr) elif(Variable == "PassPUJetID"): var = "goodJets_%s_PassLooseJetPUID"%(jet_i) @@ -815,22 +815,22 @@ def PlotBscores(Direc_): h.GetXaxis().SetTitle(plotTitle) signal_c = TCanvas("signal_c","signal_c",800,600) # signal_l = TLegend(0.6,0.6,0.85,0.85) - gStyle.SetOptStat(0) + gStyle.SetOptStat(0) h.Draw("hist") # signal_l.SetBorderSize(0) - # signal_l.Draw("same") + # signal_l.Draw("same") signal_c.SetTickx(1) - signal_c.SetTicky(1) - # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/PUJetID/Signal-%s-HHWWggTag_%s-all.png"%(Variable,Tag)) - # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Bscores/Signal-%s-HHWWggTag_%s-all.png"%(Variable)) - # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Bscores/Signal-bScore-Jet_%s-%s-signal.png"%(jet_i,channel)) - signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Vars/Signal-%s-Jet_%s-%s-signal.png"%(Variable,jet_i,channel)) - del signal_c - # del signal_l - del h + signal_c.SetTicky(1) + # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/PUJetID/Signal-%s-HHWWggTag_%s-all.png"%(Variable,Tag)) + # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Bscores/Signal-%s-HHWWggTag_%s-all.png"%(Variable)) + # signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Bscores/Signal-bScore-Jet_%s-%s-signal.png"%(jet_i,channel)) + signal_c.SaveAs("/eos/user/a/atishelm/www/HHWWgg/Pre-Production-Checks/Jet-Vars/Signal-%s-Jet_%s-%s-signal.png"%(Variable,jet_i,channel)) + del signal_c + # del signal_l + del h if __name__ == '__main__': - gROOT.SetBatch(1) # Do not output upon draw statement + gROOT.SetBatch(1) # Do not output upon draw statement # PlotBscores("/afs/cern.ch/work/a/atishelm/private/HHWWgg_Tools/NtupleAnalysis/15kSL/") PlotBscores("/afs/cern.ch/work/a/atishelm/private/HHWWgg_Tools/NtupleAnalysis/15kFH/") @@ -843,25 +843,25 @@ def PlotBscores(Direc_): # Direc = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Pre-Production-Checks/hadded/" # ttHFile = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Pre-Production-Checks/hadded/" # ttHFile_LETM = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Signal_LooseElecID_TightMuonIDISO/hadded/ttHJetToGG_2017.root" ##-- LooseElecTightMuon - # ttHFile_MEMM = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Signal_MediumMVAElecID_MediumMuonIDISO/hadded/ttHJetToGG_2017.root" ##-- MedElecMedMuon + # ttHFile_MEMM = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Signal_MediumMVAElecID_MediumMuonIDISO/hadded/ttHJetToGG_2017.root" ##-- MedElecMedMuon # ComputeEff(Direc, ttHFile_LETM, ttHFile_MEMM) # PUJetID_Direc = "/eos/user/a/atishelm/ntuples/HHWWgg_flashgg/Pre-Production-Checks/PUJetID/hadded_allIDs/" # Data_NoPUJetID = "%s/file.root" - # Data_TightPUJetID = "%s/file.root" + # Data_TightPUJetID = "%s/file.root" # FH_NoPUJetID = "%s/file.root" - # FH_TightPUJetID = "%s/file.root" + # FH_TightPUJetID = "%s/file.root" # PUJetIDCompare(PUJetID_Direc) # PUJetIDCompare(Data_NoPUJetID, Data_TightPUJetID, FH_NoPUJetID, FH_TightPUJetID) # PlotLepPt(Direc) - exit(1) + exit(1) # prev_SL_tree, prev_FH_tree, prev_FL_tree, prev_ttH_SL_tree, prev_ttH_FH_tree, prev_ttH_FL_tree = GetTrees(prefix_prev) # upd_SL_tree, upd_FH_tree, upd_FL_tree, upd_ttH_SL_tree, upd_ttH_FH_tree, upd_ttH_FL_tree = GetTrees(prefix_updated) - - ##-- Get Trees - signal_path_SL = "%sSL_SM2017.root"%(prefix_prev) - signal_path_FH = "%sFH_SM2017.root"%(prefix_prev) - signal_path_FL = "%sFL_SM2017.root"%(prefix_prev) + + ##-- Get Trees + signal_path_SL = "%sSL_SM2017.root"%(prefix_prev) + signal_path_FH = "%sFH_SM2017.root"%(prefix_prev) + signal_path_FL = "%sFL_SM2017.root"%(prefix_prev) ttH_path = "%sttHJetToGG_2017.root"%(prefix_prev) signal_file_SL = TFile.Open(signal_path_SL) signal_file_FH = TFile.Open(signal_path_FH) @@ -879,7 +879,7 @@ def PlotBscores(Direc_): for finalState in ["SL","FH","FL"]: print"num %s signal entries: "%(finalState) exec('print eval("prev_%s_tree.GetEntries()")'%(finalState)) - + print"num %s ttH entries: "%(finalState) exec('print eval("prev_ttH_%s_tree.GetEntries()")'%(finalState)) @@ -903,7 +903,7 @@ def PlotBscores(Direc_): # prev_FL_tree.Draw("N_goodElectrons >> prev_goodElectrons_h","1*weight*%s*%s"%(LUMI,SIGNAL_SCALE)) prev_FL_tree.Draw("N_goodMuons >> prev_goodMuons_h","1") prev_goodMuons_h.SetDirectory(0) - # upd_FL_tree.Draw("N_goodElectrons >> upd_goodElectrons_h","1*weight*%s*%s"%(LUMI,SIGNAL_SCALE)) + # upd_FL_tree.Draw("N_goodElectrons >> upd_goodElectrons_h","1*weight*%s*%s"%(LUMI,SIGNAL_SCALE)) print"**********Previous IDs******************" # prev_SLTottHRatio_g_elec = ComputeIntegralRatio(prev_SL_tree,prev_ttH_SL_tree,"SL",ol,"Electron",1) ##-- Final argument: IncludeSFs @@ -914,10 +914,10 @@ def PlotBscores(Direc_): # prev_FLTottHRatio_g = ComputeIntegralRatio(prev_FL_tree,prev_ttH_FL_tree,"FL",ol,"",1,"emu") # prev_FLTottHRatio_g = ComputeIntegralRatio(prev_FL_tree,prev_ttH_FL_tree,"FL",ol,"",1,"mue") - ##-- Updated IDs and ISOs - signal_path_SL = "%sSL_SM2017.root"%(prefix_updated) - signal_path_FH = "%sFH_SM2017.root"%(prefix_updated) - signal_path_FL = "%sFL_SM2017.root"%(prefix_updated) + ##-- Updated IDs and ISOs + signal_path_SL = "%sSL_SM2017.root"%(prefix_updated) + signal_path_FH = "%sFH_SM2017.root"%(prefix_updated) + signal_path_FL = "%sFL_SM2017.root"%(prefix_updated) ttH_path = "%sttHJetToGG_2017.root"%(prefix_updated) signal_file_SL = TFile.Open(signal_path_SL) signal_file_FH = TFile.Open(signal_path_FH) @@ -933,7 +933,7 @@ def PlotBscores(Direc_): upd_ttH_FH_tree = ttH_file.Get('tagsDumper/trees/tth_125_13TeV_HHWWggTag_1') upd_ttH_FL_tree = ttH_file.Get('tagsDumper/trees/tth_125_13TeV_HHWWggTag_2') - ##-- Plot N_goodElectrons, N_goodMuons for fully leptonic final state + ##-- Plot N_goodElectrons, N_goodMuons for fully leptonic final state upd_goodElectrons_h = TH1F("upd_goodElectrons_h","upd_goodElectrons_h",10,0,10) LUMI = "41.5" SIGNAL_SCALE = "(31.049*0.00097)*(0.107)" @@ -951,7 +951,7 @@ def PlotBscores(Direc_): # signal_SL_g_upd_elec = MakeEffPlot(upd_SL_tree,"SL",ol,"Updated","Electron") # signal_SL_g_upd_muon = MakeEffPlot(upd_SL_tree,"SL",ol,"Updated","Muon") # signal_FH_g_upd = MakeEffPlot(upd_FH_tree,"FH",ol,"Updated","") - # signal_FL_g_upd = MakeEffPlot(upd_FL_tree,"FL",ol,"Updated","") + # signal_FL_g_upd = MakeEffPlot(upd_FL_tree,"FL",ol,"Updated","") print"**********Updated IDs******************" # upd_SLTottHRatio_g_elec = ComputeIntegralRatio(upd_SL_tree,upd_ttH_SL_tree,"SL",ol,"Electron",1) @@ -962,7 +962,7 @@ def PlotBscores(Direc_): upd_FLTottHRatio_g = ComputeIntegralRatio(upd_FL_tree,upd_ttH_FL_tree,"FL",ol,"",1,"emu") upd_FLTottHRatio_g = ComputeIntegralRatio(upd_FL_tree,upd_ttH_FL_tree,"FL",ol,"",1,"mue") - ##-- Plot Together + ##-- Plot Together # PlotTwoVars(signal_SL_g_prev_elec, signal_SL_g_upd_elec, "SL", ol, "Eff-Electron") # PlotTwoVars(signal_SL_g_prev_muon, signal_SL_g_upd_muon, "SL", ol, "Eff-Muon") # PlotTwoVars(signal_FH_g_prev, signal_FH_g_upd, "FH", ol, "Eff") @@ -973,9 +973,9 @@ def PlotBscores(Direc_): # PlotTwoVars(prev_SLTottHRatio_g_muon, upd_SLTottHRatio_g_muon, "SL", ol, "IntRatio-Muon") # exit(1) # PlotTwoVars(prev_FHTottHRatio_g, upd_FHTottHRatio_g, "FH", ol, "IntRatio") - PlotTwoVars(prev_FLTottHRatio_g, upd_FLTottHRatio_g, "FL", ol, "IntRatio") - exit(1) - ##-- Plot N_goodElectrons, N_goodMuons for fully leptonic final state + PlotTwoVars(prev_FLTottHRatio_g, upd_FLTottHRatio_g, "FL", ol, "IntRatio") + exit(1) + ##-- Plot N_goodElectrons, N_goodMuons for fully leptonic final state # prev_goodElectrons_h = TH1F("prev_goodElectrons_h","prev_goodElectrons_h",10,0,10) # upd_goodElectrons_h = TH1F("upd_goodElectrons_h","upd_goodElectrons_h",10,0,10) # prev_goodMuons_h = TH1F("prev_goodMuons_h","prev_goodMuons_h",10,0,10) @@ -1001,7 +1001,7 @@ def PlotBscores(Direc_): c_comb.SaveAs("%s/N_goodElectrons_FL.png"%(ol)) - ##-- Good Muons + ##-- Good Muons prev_goodMuons_h.SetFillColor(kBlue) prev_goodMuons_h.SetTitle("N good Muons") upd_goodMuons_h.SetFillColor(kRed+2) @@ -1016,15 +1016,15 @@ def PlotBscores(Direc_): l.SetBorderSize(0) l.Draw("same") - c_comb.SaveAs("%s/N_goodMuons_FL.png"%(ol)) + c_comb.SaveAs("%s/N_goodMuons_FL.png"%(ol)) - ##-- Compute integral with all events once for denominator + ##-- Compute integral with all events once for denominator # h_tmp_all = TH1F("h_tmp_all","h_tmp_all",20,115,135) # tree_.Draw("CMS_hgg_mass >> h_tmp_all","1*weight*(%s)*(%s)"%(LUMI,SIGNAL_SCALE)) # total_weighed_entries = h_tmp_all.Integral() # print"total_weighed_entries in signal region:",total_weighed_entries - ##-- Plot Together + ##-- Plot Together # c_comb = TCanvas("c_comb","c_comb",800,600) # signal_SL_g_upd.SetMarkerStyle(kSquare) # signal_SL_g_prev.Draw() @@ -1048,10 +1048,10 @@ def PlotBscores(Direc_): # SL_effvseff_g = PlotEffVsEff(signal_SL_g,ttHeff_SL_g,ol,"SL") # FH_effvseff_g = PlotEffVsEff(signal_FH_g,ttHeff_FH_g,ol,"FH") # FL_effvseff_g = PlotEffVsEff(signal_FL_g,ttHeff_FL_g,ol,"FL") - + # PlotAllEffs(SL_effvseff_g, FH_effvseff_g, FL_effvseff_g, ol, "both", "effvseff") - + # PlotEffVsEff(signal_FL_g,ttHeff_FL_g,ol,"FL") # PlotEffVsEffsTogether(SL_effvseff_g, FH_effvseff_g, FL_effvseff_g, ol) # PlotEffVsEff(SigEff_g,ttHEff_g,ol) - + diff --git a/NtupleAnalysis/README.md b/NtupleAnalysis/README.md index 9490846..65f9983 100644 --- a/NtupleAnalysis/README.md +++ b/NtupleAnalysis/README.md @@ -1,48 +1,75 @@ # NtupleAnalysis -The purpose of the python modules in this directory is to analyze flashgg outputs from the dumpers and tagger in HHWWgg_dev. At the moment there are two features: Signal efficiency and Data / MC comparisons. +The purpose of the python modules in this directory is to analyze flashgg outputs from the dumpers and tagger in HHWWgg_dev. At the moment there are two features: Signal efficiency and Data / MC comparisons. -**Note**: Can probably speed up plotting by implementing uproot +**Note**: Can probably speed up plotting by implementing uproot -## Data / MC: Example Usage and Explanation +# FH Commands -**Note**: Plots are setup to output onto a CERN website. The website path needs to be set by the user in the python module NtupleAnalysis: [here](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/NtupleAnalysis.py#L36-L37), where ol = output location. Note that you can also set a separate output location to test features (the ol definition when args.testFeatures is true). +```bash +python NtupleAnalysis.py --DataMC --ol /eos/user/r/rasharma/www/doubleHiggs/UnblindedPlots/July20_v1/ --dataFile /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/Data_2017.root --signalFile /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/GluGluToHHTo2G4Q_node_cHHH1_2017.root --bkgDirec /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/ --VarBatch ThreeTopVar_FH --CutsType 4Jet_PhotonSel_DNNBB_WW0p1 --Lumi 41.5 --Tags HHWWggTag_1 --verbose --SB --SigScale 10000 --log +``` -An example command to produce Data / MC comparison plots and yields tables is: +## 27 October 2022 - python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch mass --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +```bash +python NtupleAnalysis.py --DataMC --ol /eos/user/r/rasharma/www/doubleHiggs/UnblindedPlots/Oct2022/ --dataFile /afs/cern.ch/user/r/rasharma/work/public/DoubleHiggs/Data_161718.root --signalFile /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/GluGluToHHTo2G4Q_node_cHHH1_2017.root --bkgDirec /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/ --VarBatch ThreeTopVar_FH --CutsType 4Jet_PhotonSel_DNNBB_WW0p1 --Lumi 41.5 --Tags HHWWggTag_1 --verbose --SB --SigScale 10000 --log -An explanation of each flag in the command: +python NtupleAnalysis.py --DataMC --ol /eos/user/r/rasharma/www/doubleHiggs/UnblindedPlots/Oct2022_27_allDNNVar/ --dataFile /afs/cern.ch/user/r/rasharma/work/public/DoubleHiggs/Data_161718.root --signalFile /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/GluGluToHHTo2G4Q_node_cHHH1_2017.root --bkgDirec /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/ --VarBatch FH_DNN_TrainingVars --CutsType 4Jet_PhotonSel_DNNBB_WW0p1 --Lumi 41.5 --Tags HHWWggTag_1 --verbose --SB --SigScale 10000 --log -- DataMC: Produce Data / MC ratios and yields tables -- dataFolder: The folder to search for data nTuples. This folder will be looked for in the location of the public nTuples: /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/, as defined [here](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/NtupleAnalysis.py#L38) -- mcFolder: The folder to search for background nTuples. This folder will also be searched for in /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/ -- signalFolder: The folder to search for signal nTuples. Again searched for in /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/ -- VarBatch: The batch of variables to plot. These are defined in [VariableTools](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/python/VariableTools.py#L20-L158). Note that "mass" is the most basic variable batch, as it only includes the diphoton mass. Current VarBatch options include: +python NtupleAnalysis.py --DataMC --ol /eos/user/r/rasharma/www/doubleHiggs/UnblindedPlots/Oct2022_DNN/ --dataFile /afs/cern.ch/user/r/rasharma/work/public/DoubleHiggs/Data_161718.root --signalFile /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/GluGluToHHTo2G4Q_node_cHHH1_2017.root --bkgDirec /eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/DNN_Nov2021/temp_21March/ --VarBatch ThreeTopVar_FH --CutsType 4Jet_PhotonSel_DNNBB_WW0p1 --Lumi 41.5 --Tags HHWWggTag_1 --verbose --SB --SigScale 10000 --log +``` + +## Data / MC: Example Usage and Explanation + +**Note**: Plots are setup to output onto a CERN website. The website path needs to be set by the user in the python module NtupleAnalysis: [here](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/NtupleAnalysis.py#L36-L37), where ol = output location. Note that you can also set a separate output location to test features (the ol definition when args.testFeatures is true). + +An example command to produce Data / MC comparison plots and yields tables is: + +```bash +python NtupleAnalysis.py --DataMC --dataFolder data --mcFolder background --signalFolder signal --VarBatch mass --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +``` + +#Delete +```bash +python NtupleAnalysis.py --DataMC --dataFolder data --mcFolder background --signalFolder signal --VarBatch Fully-Hadronic --CutsType 4Jet-Sel --Lumi 41.5 --Tags HHWWggTag_2 --verbose + +python NtupleAnalysis.py --DataMC --dataFolder data --mcFolder background --signalFolder signal --VarBatch Fully-Hadronic --CutsType 4Jet-SelPhoPt --Lumi 41.5 --Tags HHWWggTag_2 --verbose +``` + + + +An explanation of each flag in the command: + +- **DataMC**: Produce Data / MC ratios and yields tables +- **dataFolder**: The folder to search for data nTuples. This folder will be looked for in the location of the public nTuples: /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/, as defined [here](NtupleAnalysis/NtupleAnalysis.py#L38) +- **mcFolder**: The folder to search for background nTuples. This folder will also be searched for in /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/ +- **signalFolder**: The folder to search for signal nTuples. Again searched for in /afs/cern.ch/work/a/atishelm/public/ForJosh/2017_DataMC_ntuples_moreVars/ +- **VarBatch**: The batch of variables to plot. These are defined in [VariableTools](NtupleAnalysis/python/VariableTools.py#L20-L158). Note that "mass" is the most basic variable batch, as it only includes the diphoton mass. Current VarBatch options include: - mass: Only diphoton mass - MVA: Variables potentially useful for MVA study - - MVA2: More potentially useful MVA study variables - - MET: MET Variables. MET pT and MET phi - - Photon: pt, eta, E and MVA score of leading and subleading photons - - Loose: pt, eta, E of the leading lepton. Meant to be used in conjunction with Loose cuts - - all: All tree variables. Warning: This is a LOT of variables and may take forever to run! - - special: dR between leading and subleading jets - -- CutsType: The cuts to apply, defined in [CutsTools](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/python/CutsTools.py#L11-L72). In this example Loose is used. The requires exactly one lepton passing loose selections, and at least two jets passing loose selections. Cut options include: + - MVA2: More potentially useful MVA study variables + - MET: MET Variables. MET pT and MET phi + - Photon: pt, eta, E and MVA score of leading and subleading photons + - Loose: pt, eta, E of the leading lepton. Meant to be used in conjunction with Loose cuts + - all: All tree variables. Warning: This is a LOT of variables and may take forever to run! + - special: dR between leading and subleading jets + +- **CutsType**: The cuts to apply, defined in [CutsTools](https://github.com/NEUAnalyses/HHWWgg_Tools/blob/master/NtupleAnalysis/python/CutsTools.py#L11-L72). In this example Loose is used. The requires exactly one lepton passing loose selections, and at least two jets passing loose selections. Cut options include: - Loose: Described above - PreSelections: No additional ntuple cuts because preselection already applied - final: Apply final analysis selections (may be missing one or two like Tight2017 Jet ID) - final-noPhoSels: Apply b Veto, exactly one good lepton, at least two good jets selections (Tight2017 Jet ID may be missing) - final-noPhoMVA: Apply b Veto, exactly one good lepton, at least two good jets selections (Tight2017 Jet ID may be missing), and photon pT/mgg selections - - bVeto-OneLep: Apply b Veto, exactly one good lepton selections -- Lumi: The luminosity value to scale MC and Signal by in fb-1. Currently required because in flashgg output ntuples are scaled to luminosity 1 fb-1. The example here uses 41.5 for 2017 luminosity. -- Tags: The HHWWgg tags to run on: - - HHWWggTag_0: Semileptonic electron channel requiring exactly one good lepton and at least two good jets - - HHWWggTag_1: Semileptonic muon channel requiring exactly one good lepton and at least two good jets - - HHWWggTag_2: Any events that do not fall into categories 0 and 1 + - bVeto-OneLep: Apply b Veto, exactly one good lepton selections +- **Lumi**: The luminosity value to scale MC and Signal by in fb-1. Currently required because in flashgg output ntuples are scaled to luminosity 1 fb-1. The example here uses 41.5 for 2017 luminosity. +- **Tags**: The HHWWgg tags to run on: + - HHWWggTag_0: Semileptonic electron channel requiring exactly one good lepton and at least two good jets + - HHWWggTag_1: Semileptonic muon channel requiring exactly one good lepton and at least two good jets + - HHWWggTag_2: Any events that do not fall into categories 0 and 1 - combined: Combine all events in ntuples --- noQCD: Do not add QCD to plots and yields tables for HHWWggTag_0 and HHWWggTag_1. This was added because with some cut options, there are very few QCD events with high weights that are not meaningful ---verbose: Add various print statements while running to provide extra information +- **noQCD**: Do not add QCD to plots and yields tables for HHWWggTag_0 and HHWWggTag_1. This was added because with some cut options, there are very few QCD events with high weights that are not meaningful +- **verbose**: Add various print statements while running to provide extra information **Note**: The first time you run things may run slowly, but I've found when running a second time things speed up. I'm not sure why. It may have to do with the loading of certain modules only being done the first time. I am not sure if things run faster if the ntuples are stored in your CERN box instead of the public space in /afs/cern.ch/work. Might be worth copying the files to your cern box and trying. @@ -54,16 +81,24 @@ A few example commands that can be attempted if you want to test things and get Final analysis selections, blinded signal region (no events can fall in HHWWggTag_2): - python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch mass --CutsType final --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,combined --noQCD --verbose +```bash +python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch mass --CutsType final --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,combined --noQCD --verbose +``` Plot leading lepton kinematics with loose selections: - python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch Loose --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +```bash +python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch Loose --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +``` Plot MET variables with loose selections: - python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch MET --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +```bash +python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch MET --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +``` Photon variables with loose selections: - python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch Photon --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +```bash +python NtupleAnalysis.py --DataMC --dataFolder Data --mcFolder Backgrounds --signalFolder Signal --VarBatch Photon --CutsType Loose --Lumi 41.5 --Tags HHWWggTag_0,HHWWggTag_1,HHWWggTag_2,combined --noQCD --verbose +``` diff --git a/NtupleAnalysis/python/CutsTools.py b/NtupleAnalysis/python/CutsTools.py index e46be2f..cd4506c 100644 --- a/NtupleAnalysis/python/CutsTools.py +++ b/NtupleAnalysis/python/CutsTools.py @@ -2,23 +2,23 @@ # Abraham Tishelman-Charny # 13 May 2020 # -# The purpose of this module is to provide cut related variables and definitions for NtupleAnalysis.py +# The purpose of this module is to provide cut related variables and definitions for NtupleAnalysis.py # ########################################################################################################################### -from ROOT import TH2F, TCanvas +from ROOT import TH2F, TCanvas def GetCuts(CutsType): cuts, cutNames = [], [] - ##-- Only apply preselections. This means applying no cut because preselection already applied to events in microAODs + ##-- Only apply preselections. This means applying no cut because preselection already applied to events in microAODs # if(CutsType == "PreSelections"): # cuts = ["1"] # cutNames = ["PreSelections"] if(CutsType == "OneGoodLep"): cuts = ["1"] - cutNames = ["OneGoodLep"] + cutNames = ["OneGoodLep"] elif(CutsType == "OneGoodElec"): cuts = ["(N_goodElectrons==1)"] @@ -26,14 +26,14 @@ def GetCuts(CutsType): elif(CutsType == "OneGoodMuon"): cuts = ["(N_goodMuons==1)"] - cutNames = ["OneGoodMuon"] + cutNames = ["OneGoodMuon"] ##-- jets # elif(CutsType == "LeadbScores"): - ##-- Apply Loose selections + ##-- Apply Loose selections elif(CutsType == "Loose"): ##-- Electrons, Muons, Jets: Keep all analysis selections except dR, pT electronCuts = "" @@ -41,31 +41,31 @@ def GetCuts(CutsType): jetCuts = "" maxObjects = 5 - lepton_pt_cut = 10 - jet_pt_cut = 25 + lepton_pt_cut = 10 + jet_pt_cut = 25 photonCuts = "((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)" - - for i in range(0,maxObjects): # info for 5 first electrons, muons, jets saved + + for i in range(0,maxObjects): # info for 5 first electrons, muons, jets saved elec, muon, jet = "allElectrons_%s"%(i), "allMuons_%s"%(i), "allJets_%s"%(i) electronCuts += "( (%s_pt >= %s) && (%s_passLooseId==1 && (fabs(%s_eta)<1.4442 || ((fabs(%s_eta)>1.566 && fabs(%s_eta)<2.5) ) ) ) )"%(elec,lepton_pt_cut,elec,elec,elec,elec) muonCuts += "((%s_pt >= %s && %s_isTightMuon==1 && fabs(%s_eta)<=2.4))"%(muon,lepton_pt_cut,muon,muon) - jetCuts += "( (%s_pt>%s) && (%s_passTight2017==1) && fabs(%s_eta) <= 2.4)"%(jet,jet_pt_cut,jet,jet) + jetCuts += "( (%s_pt>%s) && (%s_passTight2017==1) && fabs(%s_eta) <= 2.4)"%(jet,jet_pt_cut,jet,jet) if(i != maxObjects-1): # if not the last object, multiply by next selection electronCuts += "+" muonCuts += "+" jetCuts += "+" - cuts = ["( (((%s) + (%s)) == 1) && ((%s) >= 2) && (%s))"%(electronCuts,muonCuts,jetCuts,photonCuts)] # exactly one lepton passing looser selections, at least two jets passing looser selections + cuts = ["( (((%s) + (%s)) == 1) && ((%s) >= 2) && (%s))"%(electronCuts,muonCuts,jetCuts,photonCuts)] # exactly one lepton passing looser selections, at least two jets passing looser selections #print"LOOSE cuts:",cuts - cutNames = ["Loose"] + cutNames = ["Loose"] # elif(CutsType == "TrainingSelections"): - # cuts = ["(1)"] # training selections - # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 1/3)*((Subleading_Photon_pt/CMS_hgg_mass) > 1/4))"] # training selections - # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.33)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && (N_goodElectrons + N_goodMuons == 1) "] # training selections - # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.33)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && (N_goodElectrons + N_goodMuons == 1) && (N_goodJets>=1))"] # training selections + # cuts = ["(1)"] # training selections + # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 1/3)*((Subleading_Photon_pt/CMS_hgg_mass) > 1/4))"] # training selections + # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.33)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && (N_goodElectrons + N_goodMuons == 1) "] # training selections + # # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.33)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && (N_goodElectrons + N_goodMuons == 1) && (N_goodJets>=1))"] # training selections # cutNames = ["TrainingSelections"] # elif(CutsType == "TrainingSelections"): @@ -77,89 +77,303 @@ def GetCuts(CutsType): elif(CutsType == "DataModeling"): cuts = ["(evalDNN_HH > 0.1)"] - cutNames = ["DataModeling"] + cutNames = ["DataModeling"] elif(CutsType == "DataModelingNoDNNCut"): cuts = ["(1.)"] - cutNames = ["DataModelingNoDNNCut"] + cutNames = ["DataModelingNoDNNCut"] - ##-- With/without DNN cut + ##-- With/without DNN cut elif(CutsType == "NoSidebandScaleNoDNNCut"): cuts = ["(1.)"] - cutNames = ["NoSidebandScaleNoDNNCut"] + cutNames = ["NoSidebandScaleNoDNNCut"] elif(CutsType == "WithSidebandScaleNoDNNCut"): cuts = ["(1.)"] - cutNames = ["WithSidebandScaleNoDNNCut"] + cutNames = ["WithSidebandScaleNoDNNCut"] elif(CutsType == "NoSidebandScaleDNNCut"): cuts = ["(evalDNN_HH > 0.1)"] - cutNames = ["NoSidebandScaleDNNCut"] + cutNames = ["NoSidebandScaleDNNCut"] elif(CutsType == "WithSidebandScaleDNNCut"): cuts = ["(evalDNN_HH > 0.1)"] - cutNames = ["WithSidebandScaleDNNCut"] + cutNames = ["WithSidebandScaleDNNCut"] - ##-- + ##-- elif(CutsType == "KinWeightsNoGlobalScale"): cuts = ["(1.)"] - cutNames = ["KinWeightsNoGlobalScale"] + cutNames = ["KinWeightsNoGlobalScale"] elif(CutsType == "KinWeightsWithGlobalScale"): cuts = ["(1.)"] - cutNames = ["KinWeightsWithGlobalScale"] + cutNames = ["KinWeightsWithGlobalScale"] elif(CutsType == "TrainingSelectionsNoDNNCut"): cuts = ["(1.)"] # cuts = ["((fabs(weight*kinWeight) < 10.))"] # cuts = ["(evalDNN > 0.1) && (goodJets_0_pt > 50) && ((Leading_Photon_pt / CMS_hgg_mass) > 0.3)"] # cuts = ["(evalDNN > 0.1) && ((Leading_Photon_pt / CMS_hgg_mass) > 0. )"] - cutNames = ["TrainingSelectionsNoDNNCut"] + cutNames = ["TrainingSelectionsNoDNNCut"] elif(CutsType == "TrainingSelectionsNoDNNCutNosidebandscale"): cuts = ["(1.)"] # cuts = ["((fabs(weight*kinWeight) < 10.))"] # cuts = ["(evalDNN > 0.1) && (goodJets_0_pt > 50) && ((Leading_Photon_pt / CMS_hgg_mass) > 0.3)"] # cuts = ["(evalDNN > 0.1) && ((Leading_Photon_pt / CMS_hgg_mass) > 0. )"] - cutNames = ["TrainingSelectionsNoDNNCutNosidebandscale"] + cutNames = ["TrainingSelectionsNoDNNCutNosidebandscale"] # elif(CutsType == "WithWJetsTraining"): - # # cuts = ["(passPhotonSels==1 && passbVeto==1 && ExOneLep==1 && goodJets==1)"] # training selections + # # cuts = ["(passPhotonSels==1 && passbVeto==1 && ExOneLep==1 && goodJets==1)"] # training selections # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1 && goodJets==1 )"] # cutNames = ["WithWJetsTraining"] elif(CutsType == "WithWJetsTrainingLoose"): cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1)"] - cutNames = ["WithWJetsTrainingLoose"] + cutNames = ["WithWJetsTrainingLoose"] elif(CutsType == "DNNLoose"): cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1 && N_goodJets>=1)"] - cutNames = ["DNNLoose"] + cutNames = ["DNNLoose"] elif(CutsType == "DNNLooseCat0"): cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1 && N_goodJets>=1 && evalDNN > 0.9)"] - cutNames = ["DNNLooseCat0"] + cutNames = ["DNNLooseCat0"] elif(CutsType == "DNNScan"): cuts = [] - cutNames = [] + cutNames = [] for nGoodJets in [0,1,2,3,4,5]: cut = "(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1 && N_goodJets==%s)"%(nGoodJets) cutName = "DNNScan-%sGoodJets"%(nGoodJets) cuts.append(cut) cutNames.append(cutName) - + # elif(CutsType == "WithWJetsTrainingLoose"): # # cuts = ["(passPhotonSels==1 && passbVeto==1 && ExOneLep==1 && goodJets==1)"] # cuts = ["(((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25) && passbVeto==1 && ExOneLep==1)"] - # cutNames = ["WithWJetsTrainingLoose"] + # cutNames = ["WithWJetsTrainingLoose"] - ##-- Apply each analysis selection separately + ##-- Apply each analysis selection separately # elif(CutsType == "all"): # cuts = ["1", "passPhotonSels == 1", "passbVeto == 1", "ExOneLep == 1", "goodJets == 1"] # preselections, photon sels, bVeto, exactly 1 lepton, at least 2 good jets # cutNames = ["PreSelections","PhotonSelections","bVeto","OneLep","TwoGoodJets"] + ##-- Apply 4 4-jet + elif(CutsType == "4Jet-Sel"): + cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cutNames = ["4Jet-Sel"] + + elif(CutsType == "4Jet_PhotonSel"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7)"] + cutNames = ["4Jet_PhotonSel"] + + elif(CutsType == "4Jet_PhotonSel_DNN0p1"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_WWvsAll>0.1)"] + cutNames = ["4Jet_PhotonSel_DNN0p1"] + + elif(CutsType == "4Jet_PhotonSel_DNN0p5"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_WWvsAll>0.5)"] + cutNames = ["4Jet_PhotonSel_DNN0p5"] + + elif(CutsType == "4Jet_PhotonSel_DNN0p7"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_WWvsAll>0.7)"] + cutNames = ["4Jet_PhotonSel_DNN0p7"] + + elif(CutsType == "4Jet_PhotonSel_DNN0p9"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_WWvsAll>0.9)"] + cutNames = ["4Jet_PhotonSel_DNN0p9"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6)"] + cutNames = ["4Jet_PhotonSel_DNNBB"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB0p2"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.2)"] + cutNames = ["4Jet_PhotonSel_DNNBB0p2"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p1"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.1)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p1"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p3"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.3)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p3"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p5"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.5)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p5"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p7"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.7)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p7"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p8"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.8)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p8"] + + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p9"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.9)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p9"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WW0p95"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.95)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WW0p95"] + + elif(CutsType == "4Jet_PhotonSel_DNNBB_WWCat0"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.974285714286)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WWCat0"] + elif(CutsType == "4Jet_PhotonSel_DNNBB_WWCat1"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll<0.974285714286 && evalDNN_WWvsAll>0.961428571429)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WWCat1"] + elif(CutsType == "4Jet_PhotonSel_DNNBB_WWCat2"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll<0.961428571429 && evalDNN_WWvsAll>0.807142857143)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WWCat2"] + elif(CutsType == "4Jet_PhotonSel_DNNBB_WWCat3"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll<0.807142857143 && evalDNN_WWvsAll>0.1)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WWCat3"] + elif(CutsType == "4Jet_PhotonSel_DNNBB_WWCat012"): + # cuts = ["1"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cuts = ["( (Leading_Photon_pt/CMS_hgg_mass) > 1/3. && (Subleading_Photon_pt/CMS_hgg_mass) > 1/4. && Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7 && evalDNN_BBvsAll<0.6 && evalDNN_WWvsAll>0.807142857143)"] + cutNames = ["4Jet_PhotonSel_DNNBB_WWCat012"] + + +# 0.974285714286 + + ##-- Apply 4 4-jet + elif(CutsType == "4Jet-SelPhoPt"): + cuts = ["(HGGCandidate_pt>160)"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cutNames = ["4Jet-SelPhoPt"] + + elif(CutsType == "4Jet-SelPhoPtDiPhoMVA"): + cuts = ["(HGGCandidate_pt>160)*(dipho_MVA>0.9)"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cutNames = ["4Jet-SelPhoPtDiPhoMVA"] + + ##-- Apply 4 4-jet + elif(CutsType == "4Jet-Sel0"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] + cutNames = ["4Jet-Sel0"] + + ##-- Apply 4 4-jet + elif(CutsType == "4Jet-Sel1"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)"] + cutNames = ["4Jet-Sel1"] + + elif(CutsType == "4Jet-Sel2"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*((HGGCandidate_pt>160))"] + cutNames = ["4Jet-Sel2"] + + elif(CutsType == "4Jet-Sel3"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*(HGGCandidate_pt>160)*(mW1_65To105==1)"] + cutNames = ["4Jet-Sel3"] + + elif(CutsType == "4Jet-Sel4"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*(HGGCandidate_pt>160)*(mW1_65To105==1)*(mH_105To160==1)"] + cutNames = ["4Jet-Sel4"] + + elif(CutsType == "4Jet-Sel41"): + # cuts = ["(passPhotonSels==1)"] + bDis = "(goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_problepb < 0.7221)*(goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)" + + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*(HGGCandidate_pt>160)*(mW1_65To105==1)*(mH_105To160==1)*"+bDis] + cutNames = ["4Jet-Sel41"] + + elif(CutsType == "4Jet-Sel31"): + # cuts = ["(passPhotonSels==1)"] + bDis = "(goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_problepb < 0.7221)*(goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)" + + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*(HGGCandidate_pt>160)*(mW1_65To105==1)*"+bDis] + cutNames = ["4Jet-Sel31"] + + elif(CutsType == "4Jet-Sel21"): + # cuts = ["(passPhotonSels==1)"] + bDis = "(goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_problepb < 0.7221)*(goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)*(goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_problepb<0.7221)" + + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)*(HGGCandidate_pt>160)*"+bDis] + cutNames = ["4Jet-Sel21"] + + elif(CutsType == "4Jet-Sel5"): + # cuts = ["(passPhotonSels==1)"] + # cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)"] + ##-- Electrons, Muons, Jets: Keep all analysis selections except dR, pT + jetCuts = "" + maxObjects = 5 + + lepton_pt_cut = 10 + jet_pt_cut = 25 + + photonCuts = "((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)" + jetCuts = "(Leading_Jet_pt>25) && (Subleading_Jet_pt>25) && (fabs(Subleading_Jet_eta)<=2.4) && (fabs(Leading_Jet_eta)<=2.4)" + + # cuts = ["( (((%s) + (%s)) == 1) && ((%s) >= 2) && (%s))"%(electronCuts,muonCuts,jetCuts,photonCuts)] # exactly one lepton passing looser selections, at least two jets passing looser selections + cuts = ["((%s))"%(photonCuts)] # exactly one lepton passing looser selections, at least two jets passing looser selections + cuts = ["(%s) && (%s)"%(photonCuts,jetCuts)] + print"4Jet-Sel5 cuts:",cuts + # + cutNames = ["4Jet-Sel5"] + + elif(CutsType == "4Jet-Sel6"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)"] + cutNames = ["4Jet-Sel6"] + + elif(CutsType == "4Jet-Sel7"): + # cuts = ["(passPhotonSels==1)"] + cuts = ["((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(passPhotonSels==1)"] + cutNames = ["4Jet-Sel7"] + + ##-- Apply 4 4-jet + elif(CutsType == "4Jet-Sel99"): + cuts = ["(passbVeto==1)*(passPhotonSels==1)*(AtLeast4GoodJets0Lep==1)*(mW1_65To105==1)*(mH_105To160)"] + cutNames = ["4Jet-Sel99"] + ##-- Apply final analysis selections (may be missing one or two like Tight2017 Jet ID) elif(CutsType == "final"): cuts = ["(passPhotonSels==1)*(passbVeto==1)*(ExOneLep==1)*(goodJets==1)*((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(Leading_Photon_pt + Subleading_Photon_pt > 100)"] @@ -167,7 +381,7 @@ def GetCuts(CutsType): elif(CutsType == "finalNoSumpt"): cuts = ["(passPhotonSels==1)*(passbVeto==1)*(ExOneLep==1)*(goodJets==1)*((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] - cutNames = ["finalNoSumpt"] + cutNames = ["finalNoSumpt"] elif(CutsType == "old_HHWWggTag_0"): cuts = ["(passPhotonSels==1)*(passbVeto==1)*(ExOneLep==1)*(goodJets==1)*(N_goodElectrons==1)"] @@ -175,7 +389,7 @@ def GetCuts(CutsType): elif(CutsType == "old_HHWWggTag_1"): cuts = ["(passPhotonSels==1)*(passbVeto==1)*(ExOneLep==1)*(goodJets==1)*(N_goodMuons==1)"] - cutNames = ["old_HHWWggTag_1"] + cutNames = ["old_HHWWggTag_1"] ##-- Cut based analysis categories elif(CutsType == "HHWWggTag_0"): @@ -185,28 +399,28 @@ def GetCuts(CutsType): elif(CutsType == "HHWWggTag_1"): cuts = ["(passPhotonSels==1)*(passbVeto==1)*(ExOneLep==1)*(N_goodMuons==1)*(goodJets==1)*((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)*(Leading_Photon_pt + Subleading_Photon_pt > 100)"] cutNames = ["HHWWggTag_1"] - + ##-- Apply b Veto, exactly one good lepton, at least two good jets selections (Tight2017 Jet ID may be missing) elif(CutsType == "final-noPhoSels"): cuts = ["(passbVeto==1)*(ExOneLep==1)*(goodJets==1)"] - cutNames = ["final-noPhoSels"] + cutNames = ["final-noPhoSels"] ##-- Apply b Veto, exactly one good lepton, at least two good jets selections (Tight2017 Jet ID may be missing), and photon pT/mgg selections elif(CutsType == "final-noPhoMVA"): cuts = ["(passbVeto==1)*(ExOneLep==1)*(goodJets==1)*((Leading_Photon_pt/CMS_hgg_mass) > 0.35)*((Subleading_Photon_pt/CMS_hgg_mass) > 0.25)"] - cutNames = ["final-noPhoMVA"] + cutNames = ["final-noPhoMVA"] - ##-- Apply b Veto, exactly one good lepton selections + ##-- Apply b Veto, exactly one good lepton selections elif(CutsType == "bVeto-OneLep"): cuts = ["(passbVeto==1)*(ExOneLep==1)"] - cutNames = ["bVeto-OneLep"] + cutNames = ["bVeto-OneLep"] return [cuts,cutNames] -##-- Create table with number of events all backgrounds plus (Blinded) Data for each set cutSet,tag pair +##-- Create table with number of events all backgrounds plus (Blinded) Data for each set cutSet,tag pair # def CreateEventsTable(cutName,HHWWggTag,dataNevents,MC_Nevents,MC_names,ol_): -## need a new table for s/sqrt(b) since it's only the signal region and the current table shows MC yields for entire 100->180 region +## need a new table for s/sqrt(b) since it's only the signal region and the current table shows MC yields for entire 100->180 region # def CreateYieldsTables(cutBatchTag_pairs, dataNevents_list, MC_names, MC_Nevents_lists, MC_Nevents_noweight_lists, # ol_, Signal_Nevents_list_, removeBackgroundYields_, B_lists_, SidebandSF_): @@ -217,9 +431,10 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, print'SidebandSF:',SidebandSF yaxisLabels = [] + if(region == "SB"): yaxisLabels.append("Data / MC") - yaxisLabels.append("Data (Blinded)") + yaxisLabels.append("Data (Blinded)") yaxisLabels.append("S / sqrt(B)") yaxisLabels.append("sqrt(B)") yaxisLabels.append("B") @@ -230,8 +445,8 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, yaxisLabels.append("sqrt(B)") yaxisLabels.append("B") yaxisLabels.append("S") - dataNevents = 0 - else: + dataNevents = 0 + else: print "[ERROR] - In CutsTools.py:CreateYieldsTable" print "Don't know what to do for region:",region print "Exiting" @@ -239,8 +454,8 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, numSpecialCats = len(yaxisLabels) - if(not removeBackgroundYields): - for Bkg_Name in Bkg_Names: + if(not removeBackgroundYields): + for Bkg_Name in Bkg_Names: yaxisLabels.append(Bkg_Name) xaxisLabels = [] @@ -249,14 +464,14 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, nyLabels = len(yaxisLabels) nxLabels = len(xaxisLabels) - ##-- For table - names, Unweighted_vals, Weighted_vals = [], [], [] + ##-- For table + names, Unweighted_vals, Weighted_vals = [], [], [] # for ylabel in yaxisLabels: for MC_name in Bkg_Names: names.append(MC_name) - ##-- Create TeX file for each + ##-- Create TeX file for each for doUnweighted in [0,1]: histTitles = ["Weighted Events", "Unweighted Events"] @@ -271,7 +486,7 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, h_grid = TH2F('h_grid',histTitle,nxLabels,0,nxLabels,nyLabels,0,nyLabels) h_grid.SetStats(0) - h_grid.GetXaxis().SetLabelSize(.03) + h_grid.GetXaxis().SetLabelSize(.03) for yli, yl in enumerate(yaxisLabels): h_grid.GetYaxis().SetBinLabel(yli+1,yl) @@ -281,13 +496,13 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, B = sum(bkgYields) h_grid.GetXaxis().SetBinLabel(ixL+1,xLabel) - B *= SidebandSF # SidebandSF_ should be 1 by default - - if(B <= 0.0): - data_over_MC = -1 - SqrtB = -1 - sOverSqrtB = -1 - else: + B *= SidebandSF # SidebandSF_ should be 1 by default + + if(B <= 0.0): + data_over_MC = -1 + SqrtB = -1 + sOverSqrtB = -1 + else: data_over_MC = dataNevents / B SqrtB = B**0.5 sOverSqrtB = S / SqrtB @@ -308,35 +523,35 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, # for ie,numEvents in enumerate(MC_Nevents): for ie,numEvents in enumerate(bkgYields): - h_grid.Fill(ixL,ie+numSpecialCats,numEvents) ## num specialCats is non MC background yield cats + h_grid.Fill(ixL,ie+numSpecialCats,numEvents) ## num specialCats is non MC background yield cats exec("%s_vals.append(%s)"%(outLabel,numEvents)) sideScaleOpt = "" if(SidebandSF != 1): sideScaleOpt = "WithSidebandScale" else: sideScaleOpt = "WithoutSidebandScale" outNamepng = "%s/%s_%s_YieldsTable_%s_%s.png"%(ol, region, cut, outLabel, sideScaleOpt) - outNamepdf = "%s/%s_%s_YieldsTable_%s_%s.pdf"%(ol, region, cut, outLabel, sideScaleOpt) + outNamepdf = "%s/%s_%s_YieldsTable_%s_%s.pdf"%(ol, region, cut, outLabel, sideScaleOpt) c_tmp = TCanvas('c_tmp','c_tmp',800,600) c_tmp.SetRightMargin(0.15) c_tmp.SetLeftMargin(0.23) c_tmp.SetBottomMargin(0.15) c_tmp.SetTopMargin(0.1) - - if(not removeBackgroundYields): - h_grid.GetXaxis().SetLabelSize(0.1) + + if(not removeBackgroundYields): + h_grid.GetXaxis().SetLabelSize(0.1) h_grid.SetMarkerSize(1.2) - else: + else: if(region == "SB"): h_grid.GetYaxis().SetLabelSize(0.08) else: h_grid.GetYaxis().SetLabelSize(0.1) - h_grid.GetXaxis().SetLabelSize(0.1) + h_grid.GetXaxis().SetLabelSize(0.1) h_grid.SetMarkerSize(5) h_grid.Draw("text COL1") # label.DrawLatex(0.3,0.95,"HHWWgg 95% CL Limits: " + ml) c_tmp.SaveAs(outNamepng) - c_tmp.SaveAs(outNamepdf) + c_tmp.SaveAs(outNamepdf) - ##-- TeX file table + ##-- TeX file table fileName = "Yields-Table.tex" file = open(fileName,"w") file.write("\\begin{table}[H]\n") @@ -353,8 +568,22 @@ def CreateYieldsTable(region,cut,Bkg_Names,removeBackgroundYields,S_vals,B_vals, file.write("\t\t\end{tabular}\n") file.write("\t\caption{Unweighted and weighted training MC yields}\n") file.write("\t\\end{center}\n") - file.write("\end{table}\n") + file.write("\end{table}\n") file.close() + fileName = "Yields-Table.md" + file = open(fileName,"w") + file.write("|MC Sample | Unweighted Events | Weighted Events | \n") + file.write("|--- |--- |--- | \n") + + for i, name in enumerate(names): + name = name.replace("_","\_") + unweighted_val = Unweighted_vals[i] + weighted_val = Weighted_vals[i] + file.write("| %s | %s | %s | \n"%(name,int(unweighted_val),round(weighted_val,5))) + + # file.write("\t\caption{Unweighted and weighted training MC yields}\n") + + file.close() print"Saving yields table: ",fileName diff --git a/NtupleAnalysis/python/MCTools.py b/NtupleAnalysis/python/MCTools.py index 33d83dd..9a866fc 100644 --- a/NtupleAnalysis/python/MCTools.py +++ b/NtupleAnalysis/python/MCTools.py @@ -2,14 +2,16 @@ # Abraham Tishelman-Charny # 15 June 2020 # -# The purpose of this module is to provide MC related variables and definitions to NtupleAnalysisTools.py +# The purpose of this module is to provide MC related variables and definitions to NtupleAnalysisTools.py # ########################################################################################################################### -##-- Note: This module can be shrunk by mapping file name to treename, MCName, and MCCategory. Don't need dictionary for each one +##-- Note: This module can be shrunk by mapping file name to treename, MCName, and MCCategory. Don't need dictionary for each one +import ROOT def GetMCTreeNameOld(fileName_): MCTreesDict = { + # # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhotonJetsBox1BJet_MGG_80toInf_13TeV_Sherpa", # "DiPhotonJetsBox2BJets_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhotonJetsBox2BJets_MGG_80toInf_13TeV_Sherpa", @@ -20,51 +22,52 @@ def GetMCTreeNameOld(fileName_): # "GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets_HT_40To100_TuneCP5_13TeV_madgraphMLM_pythia8", # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets_HT_600ToInf_TuneCP5_13TeV_madgraphMLM_pythia8", "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "GluGluHToGG_M_125_13TeV_powheg_pythia8", - "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8", + "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8", "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", "DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa", - + "GJet_Pt-20to40.root" : "GJet_Pt_20to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", "GJet_Pt-40toInf.root" : "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", "GJet_Pt-20toInf.root" : "GJet_Pt_20toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", - + #"GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", #"GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt_20toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", #"GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", - + "QCD_Pt-30to40.root" : "QCD_Pt_30to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", "QCD_Pt-30toInf.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", "QCD_Pt-40toInf.root" : "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", - + #"QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", #"QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", #"QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", - "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_Hadded.root" : "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8", + "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_Hadded.root" : "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8sethzenz_RunIIFall17_3_1_0_3_1_0_v1_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v2_dfb4aebb0a34a36b04b8bd8eb2ddfe46USER", "DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "DYJetsToLL_M_50_TuneCP5_13TeV_amcatnloFXFX_pythia8", "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "VBFHToGG_M_125_13TeV_powheg_pythia8", + "VBFHToGG_M125_13TeV_amcatnlo_pythia8_Hadded.root" : "VBFHToGG_M125_13TeV_amcatnlo_pythia8", "TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "TTJets_TuneCP5_13TeV_amcatnloFXFX_pythia8", "TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_Hadded.root" : "TTGJets_TuneCP5_13TeV_amcatnloFXFX_madspin_pythia8", "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_2500toInf_TuneCP5_13TeV_madgraphMLM_pythia8", + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_2500toInf_TuneCP5_13TeV_madgraphMLM_pythia8", "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_600to800_TuneCP5_13TeV_madgraphMLM_pythia8", "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_800to1200_TuneCP5_13TeV_madgraphMLM_pythia8", - "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_1200to2500_TuneCP5_13TeV_madgraphMLM_pythia8", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_1200to2500_TuneCP5_13TeV_madgraphMLM_pythia8", "TTToHadronic_TuneCP5_13TeV-powheg-pythia8_Hadded.root" : "TTToHadronic_TuneCP5_13TeV_powheg_pythia8", - # HHWWgg_bkg_v3 + # HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_0_50_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_400_inf_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_250_400_TuneCP5_13TeV_amcnloFXFX_pythia8", - "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", + "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu_LHEWpT_100_150_TuneCP5_13TeV_amcnloFXFX_pythia8", - # HHWWgg_bkg_v4 + # HHWWgg_bkg_v4 "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", "W3JetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root": "W3JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", "W4JetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root": "W4JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", @@ -77,11 +80,12 @@ def GetMCTreeNameOld(fileName_): # HHWWgg_bkg_v5 # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", - "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root":"ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8", "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", ##-- HHWWgg Signal + "GluGluToHHTo2G4Q_node_cHHH1_2017.root": "Signal", "ggF_SM_WWgg_qqlnugg_Hadded.root":"ggF_SM_WWgg_qqlnugg", "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus.root":"GluGluToHHTo_WWgg_qqlnu_nodeSM", "HHWWgg-SL-SM-NLO-2016.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCUETP8M1_PSWeights_13TeV_powheg_pythia8alesauva_2016_1_10_6_4_v0_RunIISummer16MiniAODv3_PUMoriond17_94X_mcRun2_asymptotic_v3_v1_c3d8a5638586a0e8df7c55ce908b2878USER", @@ -89,7 +93,7 @@ def GetMCTreeNameOld(fileName_): "HHWWgg-SL-SM-NLO-2017-HggVtx-Trees_Hadded.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", "HHWWgg-SL-SM-NLO-2018.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER", "output_numEvent500.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8", - + ##-- Single Higgs "VBFHToGG_M125_13TeV_2016.root" : "vbf_125", "GluGluHToGG_M125_13TeV_2016.root" : "ggh_125", @@ -103,26 +107,66 @@ def GetMCTreeNameOld(fileName_): def GetMCTreeName(fileName_): MCTreesDict = { - "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhotonJetsBox_M40_80_Sherpa", - "DiPhotonJets_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhotonJets_MGG_80toInf_13TeV_amcatnloFXFX_pythia8", - "WW_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WW_TuneCP5_13TeV_pythia8", - "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GluGluHToGG_M_125_13TeV_powheg_pythia8", - # "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8", - "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ggh_125", - "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ggh_125", - # "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", - "ttHJetToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tth_125", - "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "tth_125", - "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa", - + ######################### + # FH Trees # + ######################### + "DiPhotonJetsBox_MGG-80toInf_13TeV.root": "DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa", + "GJet_Pt-20to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "GJet_Pt_20to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "GJet_Pt_20toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", + "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + "GluGluHToGG_M125_TuneCP5_13TeV.root": "ggh_125", + "QCD_Pt-30to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "QCD_Pt_30to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + "QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", + "QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + "allData_QCD_2017.root": "Data", # QCD from QCD_Data + "Data_2017.root": "Data", # QCD from QCD_Data + "datadrivenQCD_v2.root": "Data", # QCD from QCD_Data + "TTGG_0Jets_TuneCP5_13TeV.root": "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8", + "TTGJets_TuneCP5_13TeV.root": "TTGJets_TuneCP5_13TeV_amcatnloFXFX_madspin_pythia8", + "TTJets_TuneCP5_13TeV.root": "TTJets_TuneCP5_13TeV_amcatnloFXFX_pythia8", + "VBFHToGG_M125_13TeV.root": "vbf_125", + "VHToGG_M125_13TeV.root": "wzh_125", + "WW_TuneCP5_13TeV-pythia8.root": "WW_TuneCP5_13TeV_pythia8", + "ttHJetToGG_M125_13TeV.root": "tth_125", + "TTToHadronic_TuneCP5_13TeV-powheg-pythia8.root": "TTToHadronic_TuneCP5_13TeV_powheg_pythia8", + + # DY + "DYJetsToLL_M-50_TuneCP5_13TeV.root": "DYJetsToLL_M_50_TuneCP5_13TeV_amcatnloFXFX_pythia8", # FH + + # DiPhoton + Jets + "DiPhotonJetsBox_M40_80.root": "DiPhotonJetsBox_M40_80_Sherpa", # FH + "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars.root" : "DiPhotonJetsBox_M40_80_Sherpa", + "DiPhotonJets_MGG-80toInf_HHWWggTag_0_MoreVars.root" : "DiPhotonJets_MGG_80toInf_13TeV_amcatnloFXFX_pythia8", + "WW_TuneCP5_HHWWggTag_0_MoreVars.root" : "WW_TuneCP5_13TeV_pythia8", + "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded_HHWWggTag_0_MoreVars.root" : "GluGluHToGG_M_125_13TeV_powheg_pythia8", + # "GluGluHToGG_HHWWggTag_0_MoreVars_noSyst.root" : "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8", + "GluGluHToGG_HHWWggTag_0_MoreVars_noSyst.root" : "ggh_125", + "GluGluHToGG_HHWWggTag_0_MoreVars.root" : "ggh_125", + # "ttHJetToGG_HHWWggTag_0_MoreVars_noSyst.root" : "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", + "ttHJetToGG_2017_HHWWggTag_0_MoreVars.root" : "tth_125", + "ttHJetToGG_HHWWggTag_0_MoreVars_noSyst.root" : "tth_125", + "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars.root" : "DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa", + "GJet_Pt-20to40_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_Pt_20to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", "GJet_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", "GJet_Pt-20toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_Pt_20toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", - - "QCD_Pt-30to40_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_Pt_30to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", - "QCD_Pt-30toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", - "QCD_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", - + + # QCD + "QCD_Pt-30to40_HHWWggTag_0_MoreVars.root" : "QCD_Pt_30to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + "QCD_Pt-30toInf_HHWWggTag_0_MoreVars.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", + "QCD_Pt-40toInf_HHWWggTag_0_MoreVars.root" : "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", + + + "QCD_HT50to100_TuneCP5_13TeV_hadd.root": "QCD_HT50to100_TuneCP5_13TeV_madgraphMLM_pythia8", + "QCD_HT100to200_TuneCP5_13TeV_hadd.root": "QCD_HT100to200_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT200to300_TuneCP5_13TeV_hadd.root": "QCD_HT200to300_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT300to500_TuneCP5_13TeV_hadd.root": "QCD_HT300to500_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT500to700_TuneCP5_13TeV_hadd.root": "QCD_HT500to700_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT700to1000_TuneCP5_13TeV_hadd.root": "QCD_HT700to1000_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT1000to1500_TuneCP5_13TeV_hadd.root": "QCD_HT1000to1500_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT1500to2000_TuneCP5_13TeV_hadd.root": "QCD_HT1500to2000_TuneCP5_13TeV_madgraph_pythia8", + "QCD_HT2000toInf_TuneCP5_13TeV_hadd.root": "QCD_HT2000toInf_TuneCP5_13TeV_madgraph_pythia8", + "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "wzh_125", "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "wzh_125", # "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", @@ -136,22 +180,22 @@ def GetMCTreeName(fileName_): # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", "THQ_ctcvcp_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT_2500toInf_TuneCP5_13TeV_madgraphMLM_pythia8", - "TTJets_HT-600to800_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT_600to800_TuneCP5_13TeV_madgraphMLM_pythia8", - "TTJets_HT-800to1200_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT_800to1200_TuneCP5_13TeV_madgraphMLM_pythia8", - "TTJets_HT-1200to2500_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT_1200to2500_TuneCP5_13TeV_madgraphMLM_pythia8", - "TTToHadronic_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTToHadronic_TuneCP5_13TeV_powheg_pythia8", + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_2500toInf_TuneCP5_13TeV_madgraphMLM_pythia8", + "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_600to800_TuneCP5_13TeV_madgraphMLM_pythia8", + "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_800to1200_TuneCP5_13TeV_madgraphMLM_pythia8", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_1200to2500_TuneCP5_13TeV_madgraphMLM_pythia8", + "TTToHadronic_HHWWggTag_0_MoreVars.root" : "TTToHadronic_TuneCP5_13TeV_powheg_pythia8", - # HHWWgg_bkg_v3 + # HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_0_50_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_400_inf_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_250_400_TuneCP5_13TeV_amcnloFXFX_pythia8", - "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", + "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", "W1JetsToLNu_LHEWpT_100-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu_LHEWpT_100_150_TuneCP5_13TeV_amcnloFXFX_pythia8", - # HHWWgg_bkg_v4 + # HHWWgg_bkg_v4 "W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", "W3JetsToLNu_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W3JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", "W4JetsToLNu_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W4JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", @@ -162,20 +206,22 @@ def GetMCTreeName(fileName_): "W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", # HHWWgg_bkg_v5 - # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", - "WGGJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", - "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", - "ttWJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8", - "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", - "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNu_EWK_QCD_TuneCP5_13TeV_madgraph_pythia8", - # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", + # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", #FH + "WGGJets_HHWWggTag_0_MoreVars.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", + "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", + "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8", + "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", + "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars.root" : "WGJJToLNu_EWK_QCD_TuneCP5_13TeV_madgraph_pythia8", + "WGJJToLNu_EWK_QCD_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJToLNu_EWK_QCD_TuneCP5_13TeV_madgraph_pythia8", + # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8_HHWWggTag_0_MoreVars.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", ##-- HHWWgg Signal - # "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", - - - "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars_kinWeight_noHgg_v3.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", - "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars_kinWeight_noHgg_v3.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", + "GluGluToHHTo2G4Q_node_cHHH1_2017.root": "GluGluToHHTo2G4Q_node_cHHH1", + # "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", + "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", + "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", "GluGluToHHTo2G2Qlnu_node_cHHH1_2017.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", @@ -188,7 +234,7 @@ def GetMCTreeName(fileName_): # "HHWWgg-SL-SM-NLO-2017-HggVtx-Trees_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", # "HHWWgg-SL-SM-NLO-2018_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER", # "output_numEvent500_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8", - + ##-- Single Higgs "VBFHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "vbf_125", "VBFHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "vbf_125", @@ -204,112 +250,56 @@ def GetMCTreeName(fileName_): return MCTreesDict[fileName_] -# def GetMCTreeName(fileName_): -# MCTreesDict = { -# "DiPhotonJetsBox_M40_80.root" : "DiPhotonJetsBox_M40_80_Sherpa", -# # "DiPhotonJets_MGG-80toInf.root" : "DiPhotonJets_MGG_80toInf_13TeV_amcatnloFXFX_pythia8", -# "WW_TuneCP5.root" : "WW_TuneCP5_13TeV_pythia8", -# # "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "GluGluHToGG_M_125_13TeV_powheg_pythia8", -# # "GluGluHToGG.root" : "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8", -# "GluGluHToGG.root" : "ggh_125", -# # "ttHJetToGG.root" : "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", -# "ttHJetToGG.root" : "tth_125", -# "DiPhotonJetsBox_MGG-80toInf.root" : "DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa", - -# "GJet_Pt-20to40.root" : "GJet_Pt_20to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", -# "GJet_Pt-40toInf.root" : "GJet_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", -# "GJet_Pt-20toInf.root" : "GJet_Pt_20toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", - -# "QCD_Pt-30to40.root" : "QCD_Pt_30to40_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", -# "QCD_Pt-30toInf.root" : "QCD_Pt_30toInf_DoubleEMEnriched_MGG_40to80_TuneCP5_13TeV_Pythia8", -# "QCD_Pt-40toInf.root" : "QCD_Pt_40toInf_DoubleEMEnriched_MGG_80toInf_TuneCP5_13TeV_Pythia8", - -# "VHToGG.root" : "wzh_125", -# # "VHToGG.root" : "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", -# "TTGG_0Jets.root" : "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8", -# "DYJetsToLL_M-50.root" : "DYJetsToLL_M_50_TuneCP5_13TeV_amcatnloFXFX_pythia8", -# "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "VBFHToGG_M_125_13TeV_powheg_pythia8", -# "TTJets_TuneCP5.root" : "TTJets_TuneCP5_13TeV_amcatnloFXFX_pythia8", -# "TTGJets_TuneCP5.root" : "TTGJets_TuneCP5_13TeV_amcatnloFXFX_madspin_pythia8", - -# # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", -# "THQ_ctcvcp.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", - -# # HHWWgg_bkg_v2 -# "TTJets_HT-2500toInf.root" : "TTJets_HT_2500toInf_TuneCP5_13TeV_madgraphMLM_pythia8", -# "TTJets_HT-600to800.root" : "TTJets_HT_600to800_TuneCP5_13TeV_madgraphMLM_pythia8", -# "TTJets_HT-800to1200.root" : "TTJets_HT_800to1200_TuneCP5_13TeV_madgraphMLM_pythia8", -# "TTJets_HT-1200to2500.root" : "TTJets_HT_1200to2500_TuneCP5_13TeV_madgraphMLM_pythia8", -# "TTToHadronic.root" : "TTToHadronic_TuneCP5_13TeV_powheg_pythia8", - -# # HHWWgg_bkg_v3 -# "W1JetsToLNu_LHEWpT_0-50.root": "W1JetsToLNu_LHEWpT_0_50_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W1JetsToLNu_LHEWpT_50-150.root": "W1JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W1JetsToLNu_LHEWpT_400-inf.root": "W1JetsToLNu_LHEWpT_400_inf_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W1JetsToLNu_LHEWpT_250-400.root": "W1JetsToLNu_LHEWpT_250_400_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W1JetsToLNu_LHEWpT_150-250.root": "W1JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W1JetsToLNu_LHEWpT_100-150.root": "W1JetsToLNu_LHEWpT_100_150_TuneCP5_13TeV_amcnloFXFX_pythia8", - -# # HHWWgg_bkg_v4 -# "W2JetsToLNu_LHEWpT_50-150.root": "W2JetsToLNu_LHEWpT_50_150_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W3JetsToLNu.root": "W3JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", -# "W4JetsToLNu.root": "W4JetsToLNu_TuneCP5_13TeV_madgraphMLM_pythia8", -# "W2JetsToLNu_LHEWpT_0-50.root": "W2JetsToLNu_LHEWpT_0_50_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W2JetsToLNu_LHEWpT_250-400.root": "W2JetsToLNu_LHEWpT_250_400_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W2JetsToLNu_LHEWpT_400-inf.root": "W2JetsToLNu_LHEWpT_400_inf_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W2JetsToLNu_LHEWpT_100-150.root": "W2JetsToLNu_LHEWpT_100_150_TuneCP5_13TeV_amcnloFXFX_pythia8", -# "W2JetsToLNu_LHEWpT_150-250.root": "W2JetsToLNu_LHEWpT_150_250_TuneCP5_13TeV_amcnloFXFX_pythia8", - -# # HHWWgg_bkg_v5 -# # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", -# "WGGJets.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", -# "WWTo1L1Nu2Q.root": "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8", -# "ttWJets.root":"ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8", -# "WGJJToLNuGJJ_EWK.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", -# "WGJJToLNu_EWK_QCD.root" : "WGJJToLNu_EWK_QCD_TuneCP5_13TeV_madgraph_pythia8", -# # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", - -# ##-- HHWWgg Signal -# "GluGluToHHTo2G2Qlnu_node_cHHH1_2017.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1", -# # "GluGluToHHTo2G2Qlnu_node_cHHH1_2017.root" : "tagsDumper/trees/GluGluToHHTo2G2Qlnu_node_cHHH1", -# # "ggF_SM_WWgg_qqlnugg_Hadded.root":"ggF_SM_WWgg_qqlnugg", -# # "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus.root":"GluGluToHHTo_WWgg_qqlnu_nodeSM", -# # "HHWWgg-SL-SM-NLO-2016.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCUETP8M1_PSWeights_13TeV_powheg_pythia8alesauva_2016_1_10_6_4_v0_RunIISummer16MiniAODv3_PUMoriond17_94X_mcRun2_asymptotic_v3_v1_c3d8a5638586a0e8df7c55ce908b2878USER", -# # "HHWWgg-SL-SM-NLO-2017.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", -# # "HHWWgg-SL-SM-NLO-2017-HggVtx-Trees_Hadded.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", -# # "HHWWgg-SL-SM-NLO-2018.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER", -# # "output_numEvent500.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8", - -# ##-- Single Higgs -# "VBFHToGG.root" : "vbf_125", -# "GluGluHToGG_M125_13TeV_2016.root" : "ggh_125", -# "VHToGG_M125_13TeV_2016.root" : "wzh_125", -# "VBFHToGG_M125_13TeV_2018.root" : "vbf_125", -# "GluGluHToGG_M125_13TeV_2018.root" : "ggh_125", -# "VHToGG_M125_13TeV_2018.root" : "wzh_125" -# } - -# return MCTreesDict[fileName_] - def GetMCName(fileName_): MCNameDict = { - "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox_M40_80", - "DiPhotonJets_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJets_MGG-80toInf", - "WW_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WW", - "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "GluGluHToGG", - "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GluGluHToGG", - "ttHJetToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ttHJetToGG", - "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ttHJetToGG", - "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox_MGG-80toInf", - + "DiPhotonJetsBox_MGG-80toInf_13TeV.root": "DiPhoJets_MGG-80toInf", # FH + "GJet_Pt-20to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "GJet_20to40", # FH + "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "GJet_20toInf", # FH + "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "GJet_40toInf", # FH + "QCD_Pt-30to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "QCD_30to40", # FH + "QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "QCD_30toInf", # FH + "QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "QCD_40toInf", # FH + "allData_QCD_2017.root": "QCD_Data", # QCD from Data + "Data_2017.root": "QCD_Data", # QCD from Data + "datadrivenQCD_v2.root": "QCD_Data", # QCD from QCD_Data + "TTGG_0Jets_TuneCP5_13TeV.root": "TTGG_0Jets", # FH + "TTGJets_TuneCP5_13TeV.root": "TTGJets", # FH + "TTJets_TuneCP5_13TeV.root": "TTJets", # FH + "WW_TuneCP5_13TeV-pythia8.root": "WW", # FH + "GluGluHToGG_M125_TuneCP5_13TeV.root": "ggh_125", # FH + "VBFHToGG_M125_13TeV.root": "vbf_125", # FH + "VHToGG_M125_13TeV.root": "wzh_125", # FH + "ttHJetToGG_M125_13TeV.root": "tth_125", # FH + "TTToHadronic_TuneCP5_13TeV-powheg-pythia8.root": "TTToHadronic", + + "DiPhotonJetsBox_M40_80.root": "DiPhoJetsBox_M40_80", # FH + "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox_M40_80", + "DiPhotonJets_MGG-80toInf_HHWWggTag_0_MoreVars.root" : "DiPhoJets_MGG-80toInf", + "WW_TuneCP5_HHWWggTag_0_MoreVars.root" : "WW", + "GluGluHToGG_HHWWggTag_0_MoreVars_noSyst.root" : "GluGluHToGG", + "GluGluHToGG_HHWWggTag_0_MoreVars.root" : "GluGluHToGG", + "ttHJetToGG_2017_HHWWggTag_0_MoreVars.root" : "ttHJetToGG", + "ttHJetToGG_HHWWggTag_0_MoreVars_noSyst.root" : "ttHJetToGG", + "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox_MGG-80toInf", + "GJet_Pt-20to40_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_20to40", "GJet_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_40toInf", "GJet_Pt-20toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet_20toInf", - - "QCD_Pt-30to40_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_30to40", - "QCD_Pt-30toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_30toInf", - "QCD_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD_40toInf", - + + "QCD_Pt-30to40_HHWWggTag_0_MoreVars.root" : "QCD_30to40", + "QCD_Pt-30toInf_HHWWggTag_0_MoreVars.root" : "QCD_30toInf", + "QCD_Pt-40toInf_HHWWggTag_0_MoreVars.root" : "QCD_40toInf", + + "QCD_HT50to100_TuneCP5_13TeV_hadd.root": "QCD_HT50to100", + "QCD_HT100to200_TuneCP5_13TeV_hadd.root": "QCD_HT100to200", + "QCD_HT200to300_TuneCP5_13TeV_hadd.root": "QCD_HT200to300", + "QCD_HT300to500_TuneCP5_13TeV_hadd.root": "QCD_HT300to500", + "QCD_HT500to700_TuneCP5_13TeV_hadd.root": "QCD_HT500to700", + "QCD_HT700to1000_TuneCP5_13TeV_hadd.root": "QCD_HT700to1000", + "QCD_HT1000to1500_TuneCP5_13TeV_hadd.root": "QCD_HT1000to1500", + "QCD_HT1500to2000_TuneCP5_13TeV_hadd.root": "QCD_HT1500to2000", + "QCD_HT2000toInf_TuneCP5_13TeV_hadd.root": "QCD_HT2000toInf", + "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "wzh_125", "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "wzh_125", # "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8", @@ -323,22 +313,22 @@ def GetMCName(fileName_): # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "THQ_ctcvcp_HToGG_M125_13TeV_madgraph_pythia8_TuneCP5", "THQ_ctcvcp_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "THQ", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT-2500toInf", - "TTJets_HT-600to800_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT-600to800", - "TTJets_HT-800to1200_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT-800to1200", - "TTJets_HT-1200to2500_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTJets_HT-1200to2500", - "TTToHadronic_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "TTToHadronic", ##-- bbWW --> bbqqqq + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-2500toInf", + "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-600to800", + "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-800to1200", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-1200to2500", + "TTToHadronic_HHWWggTag_0_MoreVars.root" : "TTToHadronic", ##-- bbWW --> bbqqqq - # HHWWgg_bkg_v3 + # HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_0-50", "W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_50-150", "W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_400-inf", "W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_250-400", - "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_150-250", + "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_150-250", "W1JetsToLNu_LHEWpT_100-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1Jets_pT_100-150", - # HHWWgg_bkg_v4 + # HHWWgg_bkg_v4 "W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2Jets_pT_50-150", "W3JetsToLNu_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W3Jets", "W4JetsToLNu_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W4Jets", @@ -349,23 +339,27 @@ def GetMCName(fileName_): "W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2Jets_pT_150-250", # HHWWgg_bkg_v5 - # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", - "WGGJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets", - "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WWTo1L1Nu2Q", - "ttWJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"ttWJets", - "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNuGJJ_EWK_aQGC", - "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNu_EWK_QCD", - # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", + # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars.root": "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8", + "WGGJets_HHWWggTag_0_MoreVars.root": "WGGJets", + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"WGGJets", #FH + "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars.root": "WWTo1L1Nu2Q", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root": "WWTo1L1Nu2Q", + "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"ttWJets", + "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars.root" : "WGJJToLNuGJJ_EWK_aQGC", + "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars.root" : "WGJJToLNu_EWK_QCD", + "WGJJToLNu_EWK_QCD_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJToLNu_EWK_QCD", + # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8_HHWWggTag_0_MoreVars.root" : "WGJJToLNuGJJ_EWK_aQGC_FS_FM_TuneCP5_13TeV_madgraph_pythia8", ##-- HHWWgg Signal - "ggF_SM_WWgg_qqlnugg_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"ggF_SM_WWgg_qqlnugg", - "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo_WWgg_qqlnu_nodeSM", - "HHWWgg-SL-SM-NLO-2016_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCUETP8M1_PSWeights_13TeV_powheg_pythia8alesauva_2016_1_10_6_4_v0_RunIISummer16MiniAODv3_PUMoriond17_94X_mcRun2_asymptotic_v3_v1_c3d8a5638586a0e8df7c55ce908b2878USER", - "HHWWgg-SL-SM-NLO-2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", - "HHWWgg-SL-SM-NLO-2017-HggVtx-Trees_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", - "HHWWgg-SL-SM-NLO-2018_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER", - "output_numEvent500_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8", - + "GluGluToHHTo2G4Q_node_cHHH1_2017.root": "Signal", + "ggF_SM_WWgg_qqlnugg_Hadded_HHWWggTag_0_MoreVars.root":"ggF_SM_WWgg_qqlnugg", + "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus_HHWWggTag_0_MoreVars.root":"GluGluToHHTo_WWgg_qqlnu_nodeSM", + "HHWWgg-SL-SM-NLO-2016_HHWWggTag_0_MoreVars.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCUETP8M1_PSWeights_13TeV_powheg_pythia8alesauva_2016_1_10_6_4_v0_RunIISummer16MiniAODv3_PUMoriond17_94X_mcRun2_asymptotic_v3_v1_c3d8a5638586a0e8df7c55ce908b2878USER", + "HHWWgg-SL-SM-NLO-2017_HHWWggTag_0_MoreVars.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", + "HHWWgg-SL-SM-NLO-2017-HggVtx-Trees_Hadded_HHWWggTag_0_MoreVars.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2017_1_10_6_4_v0_RunIIFall17MiniAODv2_PU2017_12Apr2018_94X_mc2017_realistic_v14_v1_1c4bfc6d0b8215cc31448570160b99fdUSER", + "HHWWgg-SL-SM-NLO-2018_HHWWggTag_0_MoreVars.root":"GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8alesauva_2018_1_10_6_4_v0_RunIIAutumn18MiniAOD_102X_upgrade2018_realistic_v15_v1_460d9a73477aa42da0177ac2dc7ecf49USER", + "output_numEvent500_HHWWggTag_0_MoreVars.root" : "GluGluToHHTo2G2Qlnu_node_cHHH1_TuneCP5_PSWeights_13TeV_powheg_pythia8", + ##-- Single Higgs "VBFHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "vbf_125", "VBFHToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "vbf_125", @@ -384,7 +378,7 @@ def GetMCName(fileName_): # ##-- SM Hgg # "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "GluGluHToGG", - # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG", + # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG", # "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "VHToGG", # "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "VBFHToGG", # # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded.root" : "THQ_HToGG", @@ -395,13 +389,13 @@ def GetMCName(fileName_): # "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt-20toInf_MGG-40to80", # "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt-40toInf_MGG-80toInf", - # ##-- GJets + # ##-- GJets # # "GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - # # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", + # # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - # ##-- DiPhotonJets + # ##-- DiPhotonJets # "DiPhotonJets_MGG-80toInf_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "DiPhoJets_MGG-80-Inf", - + # ##-- DiPhotonJetsBox # # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox", @@ -409,20 +403,20 @@ def GetMCName(fileName_): # "DiPhotonJetsBox_M40_80-Sherpa_Hadded.root" : "DiPhoJetsBox_MGG-40_80", # "DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox_MGG-80toInf", - # # HHWWgg_bkg_v2 - # "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT-2500toInf", + # # HHWWgg_bkg_v2 + # "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-2500toInf", # "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT-600to800", # "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_1200to2500", # "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_800to1200", # "TTToHadronic_TuneCP5_13TeV-powheg-pythia8_Hadded.root" : "TTToHadronic", - # ##-- HHWWgg_bkg_v3 + # ##-- HHWWgg_bkg_v3 # "W1JetsToLNu_LHEWpT_0-50_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_0-50", # "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_50-150", # "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_400-inf", # "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_250-400", - # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_150-250", - # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_100-150", + # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_150-250", + # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_100-150", # ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) # "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_50-150", @@ -434,7 +428,7 @@ def GetMCName(fileName_): # "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_100-150", # "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_150-250", - # ##-- Other + # ##-- Other # "WW_TuneCP5_13TeV-pythia8_Hadded.root" : "WW", # non exclusive with WWTo... ? # "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "WWTo1L1Nu2Q", @@ -445,8 +439,9 @@ def GetMCName(fileName_): # "DYJetsToLL_M-50.root" : "DY", # # "DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "DY", + "DYJetsToLL_M-50_TuneCP5_13TeV.root": "DY", - # ##-- HHWWgg_bkg_v5 + # ##-- HHWWgg_bkg_v5 # "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJ", # "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "WGGJets", # # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": "WGGJets", @@ -472,7 +467,7 @@ def GetMCNameOld(fileName_): ##-- SM Hgg "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "GluGluHToGG", - "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG", + "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "GluGluHToGG", "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "VHToGG", "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "VBFHToGG", # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded.root" : "THQ_HToGG", @@ -483,33 +478,34 @@ def GetMCNameOld(fileName_): "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt-20toInf_MGG-40to80", "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet_Pt-40toInf_MGG-80toInf", - ##-- GJets + ##-- GJets # "GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", + # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - ##-- DiPhotonJets + ##-- DiPhotonJets "DiPhotonJets_MGG-80toInf_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "DiPhoJets_MGG-80-Inf", - + ##-- DiPhotonJetsBox # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox", # "DiPhotonJetsBox2BJets_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox", + "DiPhotonJetsBox_M40_80.root": "DiPhoJetsBox_M40_80", # FH "DiPhotonJetsBox_M40_80-Sherpa_Hadded.root" : "DiPhoJetsBox_MGG-40_80", "DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox_MGG-80toInf", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT-2500toInf", + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT-2500toInf", "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT-600to800", - "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_1200to2500", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "TTJets_HT_1200to2500", "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "TTJets_HT_800to1200", "TTToHadronic_TuneCP5_13TeV-powheg-pythia8_Hadded.root" : "TTToHadronic", - # ##-- HHWWgg_bkg_v3 + # ##-- HHWWgg_bkg_v3 # "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) # "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", @@ -521,13 +517,13 @@ def GetMCNameOld(fileName_): # "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", # "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", - ##-- HHWWgg_bkg_v3 + ##-- HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_0-50", "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_50-150", "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_400-inf", "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_250-400", - "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_150-250", - "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_100-150", + "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_150-250", + "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1Jets_LHEWpT_100-150", ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_50-150", @@ -539,26 +535,29 @@ def GetMCNameOld(fileName_): "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_100-150", "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu_150-250", - ##-- Other + ##-- Other "WW_TuneCP5_13TeV-pythia8_Hadded.root" : "WW", # non exclusive with WWTo... ? - "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "WWTo1L1Nu2Q", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root" : "WWTo1L1Nu2Q", "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "ttHJetToGG", "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_Hadded.root" : "TTGG_0Jets", "TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "TTJets", "TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_Hadded.root" : "TTGJets", + "DYJetsToLL_M-50_TuneCP5_13TeV.root":"DY", "DYJetsToLL_M-50.root" : "DY", # "DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "DY", - ##-- HHWWgg_bkg_v5 + ##-- HHWWgg_bkg_v5 "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJ", + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"WGGJets", #FH "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "WGGJets", # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": "WGGJets", "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "ttW", ##-- HHWWgg Signal "ggF_SM_WWgg_qqlnugg_Hadded.root":"HHWWgg_SM", + "GluGluToHHTo_WWgg_qqqq_nodeSM.root":"Signal", "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus.root":"HHWWgg_SM", "HHWWgg-SL-SM-NLO-2016.root" : "HHWWgg_SM", "HHWWgg-SL-SM-NLO-2017.root" : "HHWWgg_SM", @@ -570,16 +569,50 @@ def GetMCNameOld(fileName_): def GetMCCategory(fileName_): MCCategoryDict = { + + "DiPhotonJetsBox_MGG-80toInf_13TeV.root": "DiPhoJetsBox", # FH + "GJet_Pt-20to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "GJet", # FH + "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "GJet", # FH + "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "GJet", # FH + "QCD_Pt-30to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root": "QCD", # FH + "QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root": "QCD", # FH + "QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root": "QCD", # FH + "allData_QCD_2017.root": "QCD_Data", # QCD from Data + "Data_2017.root": "QCD_Data", # QCD from Data + "datadrivenQCD_v2.root": "QCD_Data", # QCD from QCD_Data + "TTGG_0Jets_TuneCP5_13TeV.root": "tt\gamma(s)+jets", # FH + "TTGJets_TuneCP5_13TeV.root": "tt\gamma(s)+jets", # FH + "TTJets_TuneCP5_13TeV.root": "tt\gamma(s)+jets", # FH + "WW_TuneCP5_13TeV-pythia8.root": "WW", # FH + "GluGluHToGG_M125_TuneCP5_13TeV.root": "ggH", # FH + "VBFHToGG_M125_13TeV.root": "VBFH", # FH + "VHToGG_M125_13TeV.root": "VH", # FH + "ttHJetToGG_M125_13TeV.root": "ttHJetToGG", # FH + "TTToHadronic_TuneCP5_13TeV-powheg-pythia8.root": "TTToHadronic", + # ##-- QCD "QCD_Pt-30to40_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD", "QCD_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD", "QCD_Pt-30toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "QCD", - + "QCD_HT50to100_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT100to200_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT200to300_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT300to500_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT500to700_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT700to1000_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT1000to1500_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT1500to2000_TuneCP5_13TeV_hadd.root": "QCD", + "QCD_HT2000toInf_TuneCP5_13TeV_hadd.root": "QCD", + + ##DY + "DYJetsToLL_M-50_TuneCP5_13TeV.root": "DY", + + # ##-- SM Hgg # "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", - # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", + # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", # "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", # "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", "THQ_ctcvcp_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "THQ", @@ -588,14 +621,14 @@ def GetMCCategory(fileName_): "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ggH", "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ggH", "GluGluHToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ggH", - # "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ggH", + # "GluGluHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ggH", "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "VH", "VHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "VH", "VHToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "VH", "VBFHToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "VBFH", "VBFHToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "VBFH", "VBFHToGG_2017_HHWWggTag.root" : "VBFH", - "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ttHJetToGG", + "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ttHJetToGG", "ttHJetToGG_HHWWggTag_0_MoreVars_kinWeight_noHgg_noSyst.root" : "ttHJetToGG", "ttHJetToGG_2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "ttHJetToGG", # "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "SMhgg", @@ -605,34 +638,46 @@ def GetMCCategory(fileName_): "GJet_Pt-20toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet", "GJet_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJet", - ##-- GJets + ##-- GJets # "GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJets", - # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJets", + # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "GJets", - ##-- DiPhotonJets + ##-- DiPhotonJets "DiPhotonJets_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJets", - - - ##-- DiPhotonJetsBox - # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox", - # "DiPhotonJetsBox2BJets_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox", - "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox", - "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DiPhoJetsBox", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTJets_HT-800to1200_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTJets_HT-1200to2500_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTJets_HT-600to800_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTToHadronic_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - - # ##-- HHWWgg_bkg_v3 + ##-- DiPhotonJetsBox + # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox", + # "DiPhotonJetsBox2BJets_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox", + "DiPhotonJetsBox_M40_80.root": "DiPhoJetsBox", # FH + "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox", + "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars.root" : "DiPhoJetsBox", + + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTToHadronic_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", + # # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "DiPhoJetsBox", + # # "DiPhotonJetsBox2BJets_MGG-80toInf_13TeV-Sherpa_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "DiPhoJetsBox", + # "DiPhotonJetsBox_M40_80_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "DiPhoJetsBox", + # "DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "DiPhoJetsBox", + + # # HHWWgg_bkg_v2 + # "TTJets_HT-2500toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "tt\gamma(s)+jets", + # "TTJets_HT-800to1200_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "tt\gamma(s)+jets", + # "TTJets_HT-1200to2500_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "tt\gamma(s)+jets", + # "TTJets_HT-600to800_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "tt\gamma(s)+jets", + # "TTToHadronic_HHWWggTag_0_MoreVars_kinWeight_noHgg.root" : "tt\gamma(s)+jets", + + + # ##-- HHWWgg_bkg_v3 # "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W1JetsToLNu", # ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) # "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2JetsToLNu", @@ -644,13 +689,13 @@ def GetMCCategory(fileName_): # "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2JetsToLNu", # "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "W2JetsToLNu", - ##-- HHWWgg_bkg_v3 + ##-- HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", "W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", "W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", "W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", - "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", - "W1JetsToLNu_LHEWpT_100-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", + "W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", + "W1JetsToLNu_LHEWpT_100-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) "W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", @@ -662,38 +707,42 @@ def GetMCCategory(fileName_): "W2JetsToLNu_LHEWpT_100-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", "W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WJets", - ##-- HHWWgg_bkg_v5 - "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJ", - "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WGJJ", + ##-- HHWWgg_bkg_v5 + "WGJJToLNuGJJ_EWK_HHWWggTag_0_MoreVars.root" : "WGJJ", + "WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars.root" : "WGJJ", + "WGJJToLNu_EWK_QCD_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJ", - ##-- Other - "WW_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WW", # non exclusive with WWTo... ? - "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "WW", + ##-- Other + "WW_TuneCP5_HHWWggTag_0_MoreVars.root" : "WW", # non exclusive with WWTo... ? + "WWTo1L1Nu2Q_HHWWggTag_0_MoreVars.root" : "WW", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root": "WW", + # "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", + "TTGG_0Jets_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", + "TTJets_TuneCP5_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", + "TTJets_TuneCP5_extra_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", + "TTGJets_TuneCP5_HHWWggTag_0_MoreVars.root" : "tt\gamma(s)+jets", - # "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTGG_0Jets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTJets_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTJets_TuneCP5_extra_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", - "TTGJets_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "tt", "DYJetsToLL_M-50_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "DY", - ##-- HHWWgg_bkg_v5 - "WGGJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets", - # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "WGGJets", - "ttWJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root": "ttW", + ##-- HHWWgg_bkg_v5 + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"WGGJets", #FH + "WGGJets_HHWWggTag_0_MoreVars.root": "WGGJets", + # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0_HHWWggTag_0_MoreVars.root": "WGGJets", + "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8.root": "ttW", + ##-- HHWWgg Signal "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars_kinWeight_noHgg_v3.root" : "HHWWgg_SM", "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_MoreVars.root" : "HHWWgg_SM", - "ggF_SM_WWgg_qqlnugg_Hadded_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"HHWWgg_SM", - "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root":"HHWWgg_SM", - "HHWWgg-SL-SM-NLO-2016_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "HHWWgg_SM", - "HHWWgg-SL-SM-NLO-2017_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "HHWWgg_SM", - "HHWWgg-SL-SM-NLO-2018_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root" : "HHWWgg_SM", + "GluGluToHHTo2G4Q_node_cHHH1_2017.root": "Signal", + "ggF_SM_WWgg_qqlnugg_Hadded_HHWWggTag_0_MoreVars.root":"HHWWgg_SM", + "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus_HHWWggTag_0_MoreVars.root":"HHWWgg_SM", + "HHWWgg-SL-SM-NLO-2016_HHWWggTag_0_MoreVars.root" : "HHWWgg_SM", + "HHWWgg-SL-SM-NLO-2017_HHWWggTag_0_MoreVars.root" : "HHWWgg_SM", + "HHWWgg-SL-SM-NLO-2018_HHWWggTag_0_MoreVars.root" : "HHWWgg_SM" - "GluGluToHHTo2G2Qlnu_node_cHHH1_2017.root" : "HHWWgg_SM", } @@ -707,18 +756,18 @@ def GetMCCategoryOld(fileName_): "QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "QCD", "QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "QCD", - + # ##-- SM Hgg # "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "SMhgg", - # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "SMhgg", + # "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "SMhgg", # "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "SMhgg", # "VBFHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "SMhgg", "THQ_ctcvcp_HToGG_M125_13TeV-madgraph-pythia8_TuneCP5_Hadded.root" : "THQ", ##-- SM Hgg "GluGluHToGG_M-125_13TeV_powheg_pythia8_Hadded.root" : "ggH", - "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "ggH", + "GluGluHToGG_M125_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "ggH", "VHToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "VH", "VBFHToGG.root" : "VBFH", "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "ttHJetToGG", @@ -729,13 +778,13 @@ def GetMCCategoryOld(fileName_): "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet", "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV_Pythia8_Hadded.root" : "GJet", - ##-- GJets + ##-- GJets # "GJets_HT-40To100_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", + # "GJets_HT-600ToInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "GJets", - ##-- DiPhotonJets + ##-- DiPhotonJets "DiPhotonJets_MGG-80toInf_13TeV_amcatnloFXFX_pythia8_Hadded.root" : "DiPhoJets", - + ##-- DiPhotonJetsBox # "DiPhotonJetsBox1BJet_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox", @@ -743,20 +792,20 @@ def GetMCCategoryOld(fileName_): "DiPhotonJetsBox_M40_80-Sherpa_Hadded.root" : "DiPhoJetsBox", "DiPhotonJetsBox_MGG-80toInf_13TeV-Sherpa_Hadded.root" : "DiPhoJetsBox", - # HHWWgg_bkg_v2 - "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt", - "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt", - "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt", - "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt", - "TTToHadronic_TuneCP5_13TeV-powheg-pythia8_Hadded.root" : "tt", + # HHWWgg_bkg_v2 + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt\gamma(s)+jets", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root" : "tt\gamma(s)+jets", + "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root" : "tt\gamma(s)+jets", + "TTToHadronic_TuneCP5_13TeV-powheg-pythia8_Hadded.root" : "tt\gamma(s)+jets", - # ##-- HHWWgg_bkg_v3 + # ##-- HHWWgg_bkg_v3 # "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", - # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", + # "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W1JetsToLNu", # ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) # "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", @@ -768,13 +817,13 @@ def GetMCCategoryOld(fileName_): # "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", # "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "W2JetsToLNu", - ##-- HHWWgg_bkg_v3 + ##-- HHWWgg_bkg_v3 "W1JetsToLNu_LHEWpT_0-50_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", - "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", - "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", + "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", + "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets) "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", @@ -786,57 +835,59 @@ def GetMCCategoryOld(fileName_): "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": "WJets", - ##-- HHWWgg_bkg_v5 + ##-- HHWWgg_bkg_v5 "WGJJToLNuGJJ_EWK_aQGC-FS-FM_TuneCP5_13TeV-madgraph-pythia8.root" : "WGJJ", - ##-- Other + ##-- Other "WW_TuneCP5_13TeV-pythia8_Hadded.root" : "WW", # non exclusive with WWTo... ? - "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "WW", + "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root" : "WW", - # "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "tt", - "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_Hadded.root" : "tt", - "TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "tt", - "TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_Hadded.root" : "tt", + # "ttHJetToGG_M125_13TeV_amcatnloFXFX_madspin_pythia8_Hadded.root" : "tt\gamma(s)+jets", + "TTGG_0Jets_TuneCP5_13TeV_amcatnlo_madspin_pythia8_Hadded.root" : "tt\gamma(s)+jets", + "TTJets_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "tt\gamma(s)+jets", + "TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8_Hadded.root" : "tt\gamma(s)+jets", "DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8_Hadded.root" : "DY", + "DYJetsToLL_M-50_TuneCP5_13TeV.root": "DY", - ##-- HHWWgg_bkg_v5 + ##-- HHWWgg_bkg_v5 + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root":"WGGJets", #FH "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "WGGJets", # "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": "WGGJets", "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8_Hadded.root": "ttW", ##-- HHWWgg Signal "ggF_SM_WWgg_qqlnugg_Hadded.root":"HHWWgg_SM", + "GluGluToHHTo_WWgg_qqqq_nodeSM.root":"Signal", "ggF_SM_WWgg_qqlnugg_Hadded_WithTaus.root":"HHWWgg_SM", "HHWWgg-SL-SM-NLO-2016.root" : "HHWWgg_SM", "HHWWgg-SL-SM-NLO-2017.root" : "HHWWgg_SM", "HHWWgg-SL-SM-NLO-2018.root" : "HHWWgg_SM" - } return MCCategoryDict[fileName_] def OrderHistos(histos_,categories_): # print"histos_:",histos_ - # MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox","W1JetsToLNu", "W2JetsToLNu", "W3JetsToLNu", "W4JetsToLNu", "WW", "tt", "DY", "WGGJets", "ttW", + # MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox","W1JetsToLNu", "W2JetsToLNu", "W3JetsToLNu", "W4JetsToLNu", "WW", "tt\gamma(s)+jets", "DY", "WGGJets", "ttW", # "HHWWgg_SM" - # ] - # MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox", "WJets", "WW", "tt", "DY", "WGGJets", "ttW", "WGJJ", + # ] + # MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox", "WJets", "WW", "tt\gamma(s)+jets", "DY", "WGGJets", "ttW", "WGJJ", # "HHWWgg_SM" - # ] - MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox", "WJets", "WW", "tt", "DY", "WGGJets", "ttW", "WGJJ", - "HHWWgg_SM", "ggH","VH","VBFH","ttHJetToGG","THQ" - ] + # ] + MC_Cats = ["QCD", "SMhgg", "GJet", "DiPhoJets", "DiPhoJetsBox", "WJets", "WW", "tt\gamma(s)+jets", "DY", "WGGJets", "ttW", "WGJJ", + "Signal", "ggH","VH","VBFH","ttHJetToGG","THQ","TTToHadronic", "QCD_Data" + ] orderedHistos = [] for cat in MC_Cats: for ih_,h_ in enumerate(histos_): - histCat = categories_[ih_] + histCat = categories_[ih_] if histCat == cat: orderedHistos.append(h_) - # print"orderedHistos:",orderedHistos - return orderedHistos + print"orderedHistos:",orderedHistos + return orderedHistos def GetMCColor(MC_Category_): @@ -853,7 +904,7 @@ def GetMCColor(MC_Category_): # # "W4JetsToLNu" : "222", # "WJets" : "70", # "WW":"47", - # "tt":"51", + # "tt\gamma(s)+jets":"51", # "DY":"28", # "WGGJets":"2", # "ttW":"30", @@ -863,64 +914,66 @@ def GetMCColor(MC_Category_): # } MCColorsDict = { + "WGGJets":"2", + "DiPhoJets" : "ROOT.sunflower", + "TTToHadronic": "7", "QCD" : "8", + "QCD_Data": "8", # "SMhgg" : "9", - "GJet" : "46", + "THQ" : "9", + "WGJJ":"11", + "ggH" : "12", + "DY":"28", + "VH" : "28", + "ttW":"30", + "ttHJetToGG" : "41", # "GJets" : "7", - "DiPhoJets" : "6", - "DiPhoJetsBox" : "42", + "DiPhoJetsBox" : "798", + "GJet" : "46", + "WW":"47", + "tt\gamma(s)+jets":"ROOT.carrot", + "Signal": "ROOT.alizarin", # "W1JetsToLNu" : "70", # "W2JetsToLNu" : "38", # "W3JetsToLNu" : "208", # "W4JetsToLNu" : "222", "WJets" : "70", - "WW":"47", - "tt":"51", - "DY":"28", - "WGGJets":"2", - "ttW":"30", - "WGJJ":"11", - "HHWWgg_SM": "56", # "other" : "47", - "ggH" : "12", - "VH" : "28", "VBFH" : "70", - "ttHJetToGG" : "41", - "THQ" : "9" - } + } return MCColorsDict[MC_Category_] def ReWeightMC(MCpath_): - doReWeight, reWeightScale = 0, 1 + doReWeight, reWeightScale = 0, 1 # "" : [nEventsInMicroAOD, nEventsInMiniAOD] reWeightDict = { - ##-- HHWWgg_bkg_v3 (W1JetsToLNu) + ##-- HHWWgg_bkg_v3 (W1JetsToLNu) "W1JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [13599,88882941], "W1JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [7116,4465538], "W1JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [32290,42817232], - "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [47897,108925160], - "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [20929,78556157], + "W1JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [47897,108925160], + "W1JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [20929,78556157], ##-- HHWWgg_bkg_v4 (W2Jets, W3Jets, W4Jets)[ToLNu] "W2JetsToLNu_LHEWpT_0-50_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [1,1], - "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [6905,35696676], # - "W2JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [102984,143562166], # - "W2JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [65864,60722664], # + "W2JetsToLNu_LHEWpT_50-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [6905,35696676], # + "W2JetsToLNu_LHEWpT_250-400_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [102984,143562166], # + "W2JetsToLNu_LHEWpT_400-inf_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [65864,60722664], # "W2JetsToLNu_LHEWpT_100-150_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [1,1], "W2JetsToLNu_LHEWpT_150-250_TuneCP5_13TeV-amcnloFXFX-pythia8_Hadded.root": [1,1], "W3JetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root": [2766,19700377], "W4JetsToLNu_TuneCP5_13TeV-madgraphMLM-pythia8_Hadded.root": [2502,11103685], - ##-- HHWWgg_bkg_v5 + ##-- HHWWgg_bkg_v5 "output_WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8_bmarzocc-HHWWgg_bkg_v5-94X_mc2017-RunIIFall18-v0-RunIIFall17MiniAODv2-PU2017_12Apr2018_94X_mc2017_realistic_v14-v1-db49498e7dc78d32430682b35e9cae55_USER_0.root": [11241,428364], "ttWJets_Hadded.root": [17821,9425384] } if MCpath_ in reWeightDict: - doReWeight = 1 - N_microAOD, N_miniAOD = reWeightDict[MCpath_][0], reWeightDict[MCpath_][1] + doReWeight = 1 + N_microAOD, N_miniAOD = reWeightDict[MCpath_][0], reWeightDict[MCpath_][1] reWeightScale = float(N_microAOD) / float(N_miniAOD) return [doReWeight, reWeightScale] @@ -928,8 +981,8 @@ def ReWeightMC(MCpath_): def GetEvents(mass_,campaign_): evDict = { "X250": 98443, - # "X260": 99932, # no taus or bs - # "X260": 99942, # with taus and bs HHWWgg_v2-5 + # "X260": 99932, # no taus or bs + # "X260": 99942, # with taus and bs HHWWgg_v2-5 "X260": 99942, # All tau decays added. HHWWgg_v2-6 "X270": 99952, "X280": 99936, @@ -940,8 +993,8 @@ def GetEvents(mass_,campaign_): "X500": 99947, "X550": 99940, # "X600": 99961, - # "X600": 99938, # HHWWgg_v2-5 - "X600": 99933, # HHWWgg_v2-6 + # "X600": 99938, # HHWWgg_v2-5 + "X600": 99933, # HHWWgg_v2-6 "X650": 99450, "X700": 99449, "X750": 99953, @@ -953,7 +1006,7 @@ def GetEvents(mass_,campaign_): "X1000": 99936, # HHWWgg_v2-6 "X1250": 97940, "SM": 99931, - # "SM": 99431, # 199/200 files + # "SM": 99431, # 199/200 files "node2": 99944, "node9": 99938, "MX1000_MY800": 100000, @@ -967,19 +1020,23 @@ def GetEvents(mass_,campaign_): evDict["X600"] = 99961 evDict["X1000"] = 99450 - return evDict[mass_] + return evDict[mass_] -# Get signal cross section to scale. In flashgg default is 1fb --> Scale here +# Get signal cross section to scale. In flashgg default is 1fb --> Scale here def GetXScale(sigCampaign_): - XS_Scale = 1 - HH_ProdXS = 1 - if(sigCampaign_ == "HHWWgg_v2-6"): - HH_ProdXS = 33.49 # 33.49 fb - BR_HH_WWgg = 0.001 - BR_WWgg_finalState = 0.002864 # qqlnu, no taus ## - is this right? + XS_Scale = 1 + HH_ProdXS = 1 + if(sigCampaign_ == "HHWWgg_v2-6"): + HH_ProdXS = 33.49 # 33.49 fb + BR_HH_WWgg = 0.001 + BR_WWgg_finalState = 0.002864 # qqlnu, no taus ## - is this right? elif(sigCampaign_ == "HHWWgg_SM"): HH_ProdXS = 33.49 BR_HH_WWgg = 0.00097 - BR_WWgg_finalState = 0.441 # qqlnu, e mu tau included + BR_WWgg_finalState = 0.441 # qqlnu, e mu tau included + elif(sigCampaign_ == "Signal"): + HH_ProdXS = 33.49 + BR_HH_WWgg = 0.00097 + BR_WWgg_finalState = 0.4544 # qqlnu, e mu tau included XS_Scale = float(HH_ProdXS)*float(BR_HH_WWgg)*float(BR_WWgg_finalState) - return XS_Scale + return XS_Scale diff --git a/NtupleAnalysis/python/NtupleAnalysisTools.py b/NtupleAnalysis/python/NtupleAnalysisTools.py index e13ee51..40efa6a 100644 --- a/NtupleAnalysis/python/NtupleAnalysisTools.py +++ b/NtupleAnalysis/python/NtupleAnalysisTools.py @@ -2,43 +2,96 @@ # Abraham Tishelman-Charny # 13 May 2020 # -# The purpose of this module is to provide variables and definitions for NtupleAnalysis.py +# The purpose of this module is to provide variables and definitions for NtupleAnalysis.py # ########################################################################################################################### - -from ROOT import TCanvas, gROOT, gPad, TH1F, TFile, TChain, TPaveStats, gStyle, THStack, kBlue, kCyan, kRed, kGreen, TLegend, kYellow, TRatioPlot, kBlack, TLine, kPink, TLatex, kOrange, gErrorIgnoreLevel, kWarning, TGraphErrors, kGray -import os -from MCTools import * -from VariableTools import * -from PlotTools import * -from CutsTools import * +# import ROOT +import math +from ROOT import TCanvas, gROOT, gPad, TH1F, TFile, TChain, TPaveStats, gStyle, THStack, kBlue, kCyan, kRed, kGreen, TLegend, kYellow, TRatioPlot, kBlack, TLine, kPink, TLatex, kOrange, gErrorIgnoreLevel, kWarning, TGraphErrors, kGray, TGraphAsymmErrors +import os +from MCTools import * +from VariableTools import * +from PlotTools import * +from CutsTools import * from array import array +from CMS_lumi import * + +class Color(int): + """Create a new ROOT.TColor object with an associated index""" + __slots__ = ["object", "name"] + + def __new__(cls, r, g, b, name=""): + self = int.__new__(cls, ROOT.TColor.GetFreeColorIndex()) + self.object = ROOT.TColor(self, r, g, b, name, 1.0) + self.name = name + return self + +colors = [Color(0, 0, 0, "black"), + Color(26/255., 188/255., 156/255., "turqoise"), + Color( 46/255., 204/255., 113/255.,"emerland" ), + Color( 52/255., 152/255., 219/255.,"peterriver" ), + Color(155/255., 89/255., 182/255.,"amethyst" ), + Color( 52/255., 73/255., 94/255.,"wet-asphalt" ), + Color( 22/255., 160/255., 133/255.,"green-sea" ), + Color( 39/255., 174/255., 96/255.,"nephritis" ), + Color( 41/255., 128/255., 185/255.,"belize-hole" ), + Color(142/255., 68/255., 173/255.,"wisteria" ), + Color( 44/255., 62/255., 80/255.,"midnight-blue" ), + Color(241/255., 196/255., 15/255.,"sunflower" ), + Color(230/255., 126/255., 34/255.,"carrot" ), + Color(231/255., 76/255., 60/255.,"alizarin" ), + Color(236/255., 240/255., 241/255.,"clouds" ), + Color(149/255., 165/255., 166/255.,"concrete" ), + Color(243/255., 156/255., 18/255.,"orange" ), + Color(211/255., 84/255., 0/255.,"pumpkin" ), + Color(192/255., 57/255., 43/255.,"pomegranate" ), + Color(189/255., 195/255., 199/255.,"silver" ), + Color(127/255., 140/255., 141/255.,"asbestos" ), + ] +for color in colors: + setattr(ROOT, color.name, color) + def GetFiles(direc): - files = [] - ##-- training + files = [] + ##-- training MCendsTraining = [ - - 'DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'GJet_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'TTGG_0Jets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'TTGJets_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'ttWJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'TTJets_TuneCP5_extra_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W2JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'W2JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'WGGJets_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - 'WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars_kinWeight_noHgg_v3.root', - - # 'GluGluHToGG_HHWWggTag_0_MoreVars.root', ##-- which is used for training? check training .py file - + 'DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars.root', + 'GJet_Pt-40toInf_HHWWggTag_0_MoreVars.root', + 'TTGG_0Jets_HHWWggTag_0_MoreVars.root', + 'TTGJets_TuneCP5_HHWWggTag_0_MoreVars.root', + 'ttWJets_HHWWggTag_0_MoreVars.root', + 'TTJets_TuneCP5_extra_HHWWggTag_0_MoreVars.root', + 'W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars.root', + 'W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars.root', + 'W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars.root', + 'W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars.root', + 'W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars.root', + 'W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars.root', + 'W2JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars.root', + 'W2JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars.root', + 'WGGJets_HHWWggTag_0_MoreVars.root', + 'WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars.root', + # 'GluGluHToGG_HHWWggTag_0_MoreVars.root', ##-- messed up? not sure. which is used for training? check training .py file + # 'DiPhotonJetsBox_MGG-80toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'GJet_Pt-40toInf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'TTGG_0Jets_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'TTGJets_TuneCP5_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'ttWJets_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'TTJets_TuneCP5_extra_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W1JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W1JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W1JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W1JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W2JetsToLNu_LHEWpT_50-150_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W2JetsToLNu_LHEWpT_150-250_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W2JetsToLNu_LHEWpT_250-400_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'W2JetsToLNu_LHEWpT_400-inf_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'WGGJets_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + # 'WGJJToLNu_EWK_QCD_HHWWggTag_0_MoreVars_kinWeight_noHgg.root', + + # 'GluGluHToGG_HHWWggTag_0_MoreVars.root', ##-- messed up? not sure. which is used for training? check training .py file # 'GluGluHToGG_2017_HHWWggTag_0_MoreVars.root', # 'VBFHToGG_2017_HHWWggTag_0_MoreVars.root', # 'VHToGG_2017_HHWWggTag_0_MoreVars.root', @@ -137,44 +190,98 @@ def GetFiles(direc): "ttHJetToGG_HHWWggTag_0_MoreVars_noSyst.root", "ttWJets_HHWWggTag_0_MoreVars.root" + ] + FHMC = [ + # "allData_QCD_2017.root", + # "Data_2017.root", + "datadrivenQCD_v2.root", + "DYJetsToLL_M-50_TuneCP5_13TeV.root", + + "GluGluHToGG_M125_TuneCP5_13TeV.root", + "VHToGG_M125_13TeV.root", + "ttHJetToGG_M125_13TeV.root", + "VBFHToGG_M125_13TeV.root", + + # "QCD_Pt-30to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root", + # "QCD_Pt-30toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root", + # "QCD_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root", + + "QCD_HT50to100_TuneCP5_13TeV_hadd.root", + "QCD_HT100to200_TuneCP5_13TeV_hadd.root", + "QCD_HT200to300_TuneCP5_13TeV_hadd.root", + "QCD_HT300to500_TuneCP5_13TeV_hadd.root", + "QCD_HT500to700_TuneCP5_13TeV_hadd.root", + "QCD_HT700to1000_TuneCP5_13TeV_hadd.root", + "QCD_HT1000to1500_TuneCP5_13TeV_hadd.root", + "QCD_HT1500to2000_TuneCP5_13TeV_hadd.root", + "QCD_HT2000toInf_TuneCP5_13TeV_hadd.root", + + "DiPhotonJetsBox_M40_80.root", + "DiPhotonJetsBox_MGG-80toInf_13TeV.root", + + # "GJet_Pt-20to40_DoubleEMEnriched_MGG-80toInf_TuneCP5_13TeV.root", + # "GJet_Pt-20toInf_DoubleEMEnriched_MGG-40to80_TuneCP5_13TeV.root", + # "GJet_Pt-40toInf_DoubleEMEnriched_MGG-80toInf.root", + + "TTGG_0Jets_TuneCP5_13TeV.root", + "TTGJets_TuneCP5_13TeV.root", + "ttWJets_TuneCP5_13TeV_madgraphMLM_pythia8.root", + + # "TTJets_TuneCP5_13TeV.root", + "TTJets_HT-600to800_TuneCP5_13TeV-madgraphMLM-pythia8.root", + "TTJets_HT-800to1200_TuneCP5_13TeV-madgraphMLM-pythia8.root", + "TTJets_HT-1200to2500_TuneCP5_13TeV-madgraphMLM-pythia8.root", + "TTJets_HT-2500toInf_TuneCP5_13TeV-madgraphMLM-pythia8.root", + # "TTToHadronic_TuneCP5_13TeV-powheg-pythia8.root", + + + "WGGJets_TuneCP5_13TeV_madgraphMLM_pythia8.root", + + # "WWTo1L1Nu2Q_13TeV_amcatnloFXFX_madspin_pythia8.root", + "WGJJToLNu_EWK_QCD_TuneCP5_13TeV-madgraph-pythia8.root", + "WW_TuneCP5_13TeV-pythia8.root", + + # "THQ_ctcvcp_HToGG_M125_13TeV.root", + + ] - for fileEnd in os.listdir(direc): + for fileEnd in os.listdir(direc): # if ((".root" in fileEnd) and ( (fileEnd == "GluGluToHHTo2G2Qlnu_node_cHHH1_2017_HHWWggTag_0_even_MoreVars.root") or (fileEnd in MCends) ) ): # if ( fileEnd in MCends ): - # if ( fileEnd in MCends ): - if ( fileEnd in MCendsTraining ): + # if ( fileEnd in MCendsTraining ): + if ( fileEnd in FHMC ): fullPath = "%s/%s"%(direc,fileEnd) files.append(fullPath) - return files + return files # def GetFiles(nTupleDirec_, Folder_): -# files = [] +# files = [] # Direc = "%s/%s"%(nTupleDirec_,Folder_) # for file in os.listdir(Direc): files.append(file) -# return files +# return files def AppendNtuples(dataFiles_, mcFiles_, signalFiles_): print "In AppendNtuples" # for each input file, make a new output file with an added branch def CalcEff(h_,cut_): - ##-- return percentage of events that pass cut + ##-- return percentage of events that pass cut pctPass_ = 0 - numPass = 0 + numPass = 0 N = h_.GetEntries() nBins = h_.GetNbinsX() for ix,y in enumerate(h_): - if ix == 0: continue # skip underflow bin - elif ix == nBins + 1: break # skip overflow bin + if ix == 0: continue # skip underflow bin + elif ix == nBins + 1: break # skip overflow bin x = h_.GetBinLowEdge(ix) - if x < cut_: numPass += y # if the x value of the bin is less than the cut, all jets pass - elif x >= cut_: break # if the x value of the bin is greater than or equal to the cut, no more jets will pass + if x < cut_: numPass += y # if the x value of the bin is less than the cut, all jets pass + elif x >= cut_: break # if the x value of the bin is greater than or equal to the cut, no more jets will pass pctPass_ = float(numPass) / float(N) - return pctPass_ + return pctPass_ def GetBinVals(h_): - binVals_ = [] + binVals_ = [] nBins = h_.GetNbinsX() for i in range(0,nBins): bin_val = h_.GetBinContent(i+1) @@ -182,7 +289,7 @@ def GetBinVals(h_): return binVals_ def GetDataHist(dPath,prefix,cut,cutName,iv,v,varTitle,VarBatch,verbose,DNNbinWidth_): - print "Getting data histogram" + print "Getting data histogram" dFile = TFile.Open(dPath) # print "Data file path: ",dPath # ch = TChain('%sData_13TeV_HHWWggTag_0'%(prefix)) @@ -190,33 +297,34 @@ def GetDataHist(dPath,prefix,cut,cutName,iv,v,varTitle,VarBatch,verbose,DNNbinWi data_trees = TChain('data_trees') # data_trees.Add("%s/%sData"%(dPath,prefix)) # data_trees.Add("%s/%sData_13TeV_HHWWggTag_0"%(dPath,prefix)) - data_trees.Add("%s/%sData_13TeV_HHWWggTag_0_v1"%(dPath,prefix)) - - ##-- Hardcoding the addition of 2016 and 2018 data for AN-20-165 v5 checks - # data_trees.Add("/eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_WithHggFactor2-200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/Data_2016_HHWWggTag_0_MoreVars.root/%sData_13TeV_HHWWggTag_0_v1"%(prefix)) - # data_trees.Add("/eos/user/a/atishelm/ntuples/HHWWgg_DNN/MultiClassifier/HHWWyyDNN_WithHggFactor2-200Epochs-3ClassMulticlass_EvenSingleH_2Hgg_withKinWeightCut10_BalanceYields/Data_2018_HHWWggTag_0_MoreVars.root/%sData_13TeV_HHWWggTag_0_v1"%(prefix)) - - - + # data_trees.Add("%s/%s/tagsDumper/trees/Data_13TeV_HHWWggTag_1"%(dPath,prefix)) + data_trees.Add("%s/%sData_13TeV_HHWWggTag_1"%(dPath,prefix)) # data_trees.Add("%s/%stagsDumper/trees/Data_13TeV_HHWWggTag_0"%(dPath,prefix)) # data_trees.Add("%s/%sData_13TeV_HHWWggTag_1"%(dPath,prefix)) # data_trees.Add("%s/%sData_13TeV_HHWWggTag_2"%(dPath,prefix)) - SB_CUT = "(CMS_hgg_mass <= 115 || CMS_hgg_mass >= 135)" - ZERO_CUT = "ZERO_CUT" ## to cut empty entries + SB_CUT = "(CMS_hgg_mass <= 135 || CMS_hgg_mass >= 135)" + # SB_CUT = "(CMS_hgg_mass >= 115 && CMS_hgg_mass <= 135)" + ZERO_CUT = "ZERO_CUT" ## to cut empty entries DATA_CUT = "%s*(%s)"%(SB_CUT,ZERO_CUT) - DATA_CUT += "*(%s)"%(cut) + DATA_CUT += "*(%s*((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7))*(1/1.0))"%(cut) - ##-- Replace zero cut with variable name + ##-- Replace zero cut with variable name if(VarBatch == "Loose"): varTitle = varNames[iv] else: varTitle = GetVarTitle(v) # if(verbose): print"Plotting variable:",varTitle - DATA_CUT = DATA_CUT.replace("ZERO_CUT","(%s != 0) && (%s != -999)"%(v,v)) - # if(varTitle == "weight"): MC_CUT = MC_CUT.replace(MC_WEIGHT,"(1)") # if you want to plot the "weight" variable, you should not scale it by weight! + DATA_CUT = DATA_CUT.replace("ZERO_CUT","(%s != 0) && (%s != -999)"%(v,v)) + # if(varTitle == "weight"): MC_CUT = MC_CUT.replace(MC_WEIGHT,"(1)") # if you want to plot the "weight" variable, you should not scale it by weight! xbins, xmin, xmax = GetBins(varTitle,DNNbinWidth_) - ##-- Fill histogram with data - Data_h_tmp = TH1F('Data_h_tmp',varTitle,xbins,xmin,xmax) - Data_h_tmp.SetTitle("%s"%(varTitle)) + ##-- Fill histogram with data + # special binning for evalDNN_WWvsAll + edges = array('d',[0.1000,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.8071,0.85,0.90,0.9614,1.0001]) + N_bins_special = len(edges) -1 + + if(varTitle == "evalDNN_WWvsAll_"): + Data_h_tmp = TH1F('Data_h_tmp',varTitle,N_bins_special,edges) + else: Data_h_tmp = TH1F('Data_h_tmp',varTitle,xbins,xmin,xmax) + Data_h_tmp.SetTitle("%s"%("")) Data_h_tmp.SetMarkerStyle(8) print"v:",v print"DATA_CUT:",DATA_CUT @@ -224,12 +332,12 @@ def GetDataHist(dPath,prefix,cut,cutName,iv,v,varTitle,VarBatch,verbose,DNNbinWi # exec('data_trees.Draw("%s >> Data_h_tmp","%s")'%(v,DATA_CUT)) print"filled histogram" - ##-- Only save number of events for first variable. Should be same for all because same cut is used - # if(iv == 0): + ##-- Only save number of events for first variable. Should be same for all because same cut is used + # if(iv == 0): # dataNevents = Data_h_tmp.GetEntries() # dataNevents_list.append(dataNevents) - # print"Blinded Data numEvents:",Data_h_tmp.GetEntries() - + # print"Blinded Data numEvents:",Data_h_tmp.GetEntries() + DataHist_ = Data_h_tmp.Clone("DataHist") DataHist_.SetDirectory(0) @@ -237,73 +345,71 @@ def GetDataHist(dPath,prefix,cut,cutName,iv,v,varTitle,VarBatch,verbose,DNNbinWi def GetBackgroundHists(bkgFiles_,noQCD,verbose,prefix,varTitle,region,v,Lumi,cut,DNNbinWidth_): print "Getting background stack" + print "background files: ",bkgFiles_ - ##-- Define cut - REGION_CUT = "" - if(region == "SB"): REGION_CUT = "(CMS_hgg_mass <= 115 || CMS_hgg_mass >= 135)" + ##-- Define cut + REGION_CUT = "1" + if(region == "SB"): REGION_CUT = "(CMS_hgg_mass <= 135 || CMS_hgg_mass >= 135)" elif(region == "SR"): REGION_CUT = "(CMS_hgg_mass > 115 && CMS_hgg_mass < 135)" - else: + else: print"Input region ",region,"is not defined" print"Exiting" exit(1) # B_WEIGHT = "1*weight" - B_WEIGHT = "1*weight*kinWeight*(fabs(weight*kinWeight) < 10.)" ##-- Used in training - # B_WEIGHT = "1*weight" ##-- to plot with no kin weight - - print("Background MC weight applied:", B_WEIGHT) - print("PLEASE NOTE if you want this weight. Check if it includes kinematic reweighting or not.") - + # B_WEIGHT = "1*weight*kinWeight*(fabs(weight*kinWeight) < 10.)" + B_WEIGHT = "1*weight" ZERO_CUT = "ZERO_CUT" B_CUT = "%s*(%s)*(%s)"%(B_WEIGHT,REGION_CUT,ZERO_CUT) - B_CUT += "*(%s)"%(cut) + B_CUT += "*(%s)"%(cut) B_CUT = B_CUT.replace("ZERO_CUT","(%s != 0) && (%s != -999)"%(v,v)) B_CUT_NOWEIGHT = "%s"%(B_CUT) B_CUT_NOWEIGHT = B_CUT_NOWEIGHT.replace(B_WEIGHT,"(1)") - ##-- Get Background Histograms + ##-- Get Background Histograms bkgHistos_ = [] - bkgHistCategories_ = [] - Bkg_Names_ = [] - Bkg_Nevents_ = [] - Bkg_Nevents_unweighted_ = [] + bkgHistCategories_ = [] + Bkg_Names_ = [] + Bkg_Nevents_ = [] + Bkg_Nevents_unweighted_ = [] # for i,mcF_ in enumerate(mcFiles): for i,mcPath in enumerate(bkgFiles_): # mcPath = "%s/%s"%(mcDirec,mcF_) mcEnd = mcPath.split('/')[-1] mcFile = TFile.Open(mcPath) treeName = GetMCTreeName(mcEnd) - treeName += "_13TeV_HHWWggTag_0" + treeName += "_13TeV_HHWWggTag_1" # treeName += "_13TeV_HHWWggTag_0_v1" MC_Category = GetMCCategory(mcEnd) print("MC_Category:",MC_Category) - - v1_mcs = ["VBFH","ttHJetToGG","ggH","VH"] - if(MC_Category in v1_mcs): - treeName += "_v1" + + # v1_mcs = ["VBFH","ttHJetToGG","ggH","VH"] + # if(MC_Category in v1_mcs): + # treeName += "_v1" MCname = GetMCName(mcEnd) - Bkg_Names_.append(MCname) # get shorter MC name here - if(verbose): + Bkg_Names_.append(MCname) # get shorter MC name here + if(verbose): # print"Background File:",mcPath print"Background:",MC_Category - print"file:",mcPath + print"file:",mcPath - ##-- If noQCD set to true, skip QCD - if((MC_Category == "QCD") and (noQCD)): + ##-- If noQCD set to true, skip QCD + if((MC_Category == "QCD") and (noQCD)): print"Skipping QCD" Bkg_Nevents_.append(0) Bkg_Nevents_unweighted_.append(0) - # these_MC_Nevents_noweights.append(0) # Set yields to 0 for table + # these_MC_Nevents_noweights.append(0) # Set yields to 0 for table # these_MC_Nevents.append(0) # Set yields to 0 for table - # B_list.append(0) - # if(itag == 0 and ic == 0 and iv == 0): + # B_list.append(0) + # if(itag == 0 and ic == 0 and iv == 0): # MCname = GetMCName(mcF_) - # MC_names.append(MCname) # Skipping QCD, but still save name for yields because tag_2 may not be 0 - continue + # MC_names.append(MCname) # Skipping QCD, but still save name for yields because tag_2 may not be 0 + continue - ##-- Get Background Trees + ##-- Get Background Trees Bkg_Trees = TChain("Bkg_Trees") # mc_ch = TChain('%s%s_13TeV_HHWWggTag_0'%(args_.prefix,treeName)) + # Bkg_Trees.Add("%s/tagsDumper/trees/%s%s"%(mcPath,prefix,treeName)) Bkg_Trees.Add("%s/%s%s"%(mcPath,prefix,treeName)) # Bkg_Trees.Add("%s/%s%s_13TeV_HHWWggTag_1"%(mcPath,prefix,treeName)) # Bkg_Trees.Add("%s/%s%s_13TeV_HHWWggTag_2"%(mcPath,prefix,treeName)) @@ -312,21 +418,30 @@ def GetBackgroundHists(bkgFiles_,noQCD,verbose,prefix,varTitle,region,v,Lumi,cut xbins, xmin, xmax = GetBins(varTitle, DNNbinWidth_) # exec("MC_h_tmp_%s = TH1F('MC_h_tmp_%s',varTitle,xbins,xmin,xmax)"%(i,i)) # exec("MC_h_tmp_noweight_%s = TH1F('MC_h_tmp_noweight_%s',varTitle,xbins,xmin,xmax)"%(i,i)) - exec("B_h_%s = TH1F('B_h_%s',varTitle,xbins,xmin,xmax)"%(i,i)) # histogram specifically for computing B in signal region + edges = array('d',[0.1000,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.8071,0.85,0.90,0.9614,1.0001]) + N_bins_special = len(edges) - 1 + + if(varTitle == "evalDNN_WWvsAll_"): + exec("B_h_%s = TH1F('B_h_%s',varTitle,N_bins_special,edges)"%(i,i)) # histogram specifically for computing B in signal region + else: + exec("B_h_%s = TH1F('B_h_%s',varTitle,xbins,xmin,xmax)"%(i,i)) # histogram specifically for computing B in signal region + # exec("B_h_noweight_%s = TH1F('B_h_noweight_%s',varTitle,xbins,xmin,xmax)"%(i,i)) # histogram specifically for computing B in signal region - ##-- no weights - exec("B_h_%s_noweights = TH1F('B_h_%s_noweights',varTitle,xbins,xmin,xmax)"%(i,i)) # histogram specifically for computing B in signal region - + ##-- no weights + if(varTitle == "evalDNN_WWvsAll_"): + exec("B_h_%s_noweights = TH1F('B_h_%s_noweights',varTitle,N_bins_special,edges)"%(i,i)) # histogram specifically for computing B in signal region + else: exec("B_h_%s_noweights = TH1F('B_h_%s_noweights',varTitle,xbins,xmin,xmax)"%(i,i)) # histogram specifically for computing B in signal region + # thisHist = eval("MC_h_tmp_%s"%(i)) thisHist = eval("B_h_%s"%(i)) thisHist.Sumw2() mcColor = GetMCColor(MC_Category) - ##-- If GJet or QCD sample, need to remove prompt-prompt events + ##-- If GJet or QCD sample, need to remove prompt-prompt events if(MC_Category == "GJet" or MC_Category == "QCD"): if(verbose): print"Removing prompt-prompt" - removePromptPromptCut = "(!((Leading_Photon_genMatchType == 1) && (Subleading_Photon_genMatchType == 1)))" # selection: remove events where both photons are prompt + removePromptPromptCut = "(!((Leading_Photon_genMatchType == 1) && (Subleading_Photon_genMatchType == 1)) && ((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7)))" # selection: remove events where both photons are prompt original_B_CUT = "%s"%(B_CUT) # original_MC_CUT = "%s"%(MC_CUT) # this_MC_CUT = "%s*(%s)"%(original_MC_CUT,removePromptPromptCut) @@ -334,27 +449,58 @@ def GetBackgroundHists(bkgFiles_,noQCD,verbose,prefix,varTitle,region,v,Lumi,cut # this_MC_CUT_NOWEIGHT = this_MC_CUT.replace(MC_WEIGHT,"(1)") this_B_CUT_NOWEIGHT = this_B_CUT.replace(B_WEIGHT,"(1)") + if(MC_Category == "QCD_Data"): + if(verbose): print"cut for QCD from data" + # removePromptPromptCut = "(Leading_Photon_MVA<-0.7 && Subleading_Photon_MVA<-0.7)" # selection: remove events where both photons are prompt + removePromptPromptCut = "(1)" # selection: remove events where both photons are prompt + original_B_CUT = "%s"%(B_CUT) + # original_MC_CUT = "%s"%(MC_CUT) + # this_MC_CUT = "%s*(%s)"%(original_MC_CUT,removePromptPromptCut) + this_B_CUTDataQCD = "%s*(%s)"%(original_B_CUT,removePromptPromptCut) + # this_MC_CUT_NOWEIGHT = this_MC_CUT.replace(MC_WEIGHT,"(1)") + this_B_CUTDataQCD_NOWEIGHT = this_B_CUTDataQCD.replace(B_WEIGHT,"(1)") # eval("MC_h_tmp_%s.SetFillColor(eval(mcColor))"%(i)) # eval("MC_h_tmp_%s.SetLineColor(eval(mcColor))"%(i)) eval("B_h_%s.SetFillColor(eval(mcColor))"%(i)) - eval("B_h_%s.SetLineColor(eval(mcColor))"%(i)) + eval("B_h_%s.SetLineColor(eval(mcColor))"%(i)) - if(MC_Category == "GJet" or MC_Category == "QCD"): + if(MC_Category == "GJet" or MC_Category == "QCD"): # exec('mc_ch.Draw("%s >> MC_h_tmp_%s","%s")'%(v,i,this_MC_CUT)) exec('Bkg_Trees.Draw("%s >> B_h_%s","%s")'%(v,i,this_B_CUT)) exec('Bkg_Trees.Draw("%s >> B_h_%s_noweights","%s")'%(v,i,this_B_CUT_NOWEIGHT)) - - else: - # exec('mc_ch.Draw("%s >> MC_h_tmp_%s","%s")'%(v,i,MC_CUT)) - exec('Bkg_Trees.Draw("%s >> B_h_%s","%s")'%(v,i,B_CUT)) - exec('Bkg_Trees.Draw("%s >> B_h_%s_noweights","%s")'%(v,i,B_CUT_NOWEIGHT)) + elif(MC_Category == "QCD_Data"): + print "this_B_CUTDataQCD: ",this_B_CUTDataQCD + print "this_B_CUTDataQCD_NOWEIGHT: ",this_B_CUTDataQCD_NOWEIGHT + exec('Bkg_Trees.Draw("%s >> B_h_%s","%s")'%(v,i,this_B_CUTDataQCD)) + exec('Bkg_Trees.Draw("%s >> B_h_%s_noweights","%s")'%(v,i,this_B_CUTDataQCD_NOWEIGHT)) + else: + # exec('mc_ch.Draw("%s >> MC_h_tmp_%s","%s")'%(v,i,MC_CUT)) + # print "DEBUG: B_CUT: ",B_CUT + # print "DEBUG: B_CUT_NOWEIGHT: ",B_CUT_NOWEIGHT + exec('Bkg_Trees.Draw("%s >> B_h_%s","%s*((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7))")'%(v,i,B_CUT)) + exec('Bkg_Trees.Draw("%s >> B_h_%s_noweights","%s*((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7))")'%(v,i,B_CUT_NOWEIGHT)) # eval("MC_h_tmp_%s.Scale(float(args_.Lumi))"%(i)) - eval("B_h_%s.Scale(float(Lumi))"%(i)) - ##-- If required, scale by fraction of events to total due to flashgg submission - # need for - # W1JetsToLNu_LHEWpT_150-250 + if (MC_Category == "QCD_Data"): + eval("B_h_%s.Scale(0.9*3.33)"%(i)) # 138/41.5 = 3.321299639 + elif (MC_Category == "DiPhoJetsBox"): + eval("B_h_%s.Scale(float(138)*1.25)"%(i)) + elif (MC_Category == "GJet"): + eval("B_h_%s.Scale(float(138)*2.23)"%(i)) + # elif (MC_Category == "tt\gamma(s)+jets"): + # import sys + # print 'lumi: ', Lumi + # sys.exit() + # eval("B_h_%s.Scale(float(Lumi)*3.321299639)"%(i)) + else: + # print 'lumi: ', Lumi, 'MC_Category: ',MC_Category + # import sys + # sys.exit() + eval("B_h_%s.Scale(float(138))"%(i)) + ##-- If required, scale by fraction of events to total due to flashgg submission + # need for + # W1JetsToLNu_LHEWpT_150-250 # # W1JetsToLNu_LHEWpT_150-250 ext1 258842513 # W1JetsToLNu_LHEWpT_150-250 new_pmx 108925160 @@ -363,38 +509,36 @@ def GetBackgroundHists(bkgFiles_,noQCD,verbose,prefix,varTitle,region,v,Lumi,cut # # W1JetsToLNu_LHEWpT_400-inf v2 4465538 # W1JetsToLNu_LHEWpT_400-inf ext1 9066797 - # + # # W2JetsToLNu_LHEWpT_100-150 # W2JetsToLNu_LHEWpT_150-250 # W2JetsToLNu_LHEWpT_50-150 - - - Bkg_Nevents_.append(eval("B_h_%s.Integral()"%(i))) + Bkg_Nevents_.append(eval("B_h_%s.Integral()"%(i))) - ##-- Check for negative bins + ##-- Check for negative bins for bi in range(eval("B_h_%s.GetNbinsX()"%(i))): - bin_i = bi + 1 # skip underflow bin - Nbkg = eval("B_h_%s.GetBinContent(%s)"%(i,bin_i)) + bin_i = bi + 1 # skip underflow bin + Nbkg = eval("B_h_%s.GetBinContent(%s)"%(i,bin_i)) if(Nbkg < 0): - Nbkg_unweighted = eval("B_h_%s_noweights.GetBinContent(%s)"%(i,bin_i)) + Nbkg_unweighted = eval("B_h_%s_noweights.GetBinContent(%s)"%(i,bin_i)) print"bin ",bin_i," Background Yield is < 0: ",Nbkg print"number of unweighted events: ",Nbkg_unweighted # if(bin_i == 5 and Nbkg > 0): # print"bin_i == 5" - # Nbkg_unweighted = eval("B_h_%s_noweights.GetBinContent(%s)"%(i,bin_i)) + # Nbkg_unweighted = eval("B_h_%s_noweights.GetBinContent(%s)"%(i,bin_i)) # # print"bin ",bin_i," Background Yield is < 0: ",Nbkg # print"Weighted Background Yield: ",Nbkg - # print"number of unweighted events: ",Nbkg_unweighted + # print"number of unweighted events: ",Nbkg_unweighted ##-- without weights - Bkg_Nevents_unweighted_.append(eval("B_h_%s_noweights.Integral()"%(i))) + Bkg_Nevents_unweighted_.append(eval("B_h_%s_noweights.Integral()"%(i))) newHist = thisHist.Clone("newHist") - ##-- Set title based on treeName + ##-- Set title based on treeName newHist.SetTitle(MC_Category) - newHist.GetXaxis().SetTitle(mcEnd) + newHist.GetXaxis().SetTitle("RAM") newHist.SetDirectory(0) newHist.Sumw2() bkgHistos_.append(newHist) @@ -405,28 +549,28 @@ def GetBackgroundHists(bkgFiles_,noQCD,verbose,prefix,varTitle,region,v,Lumi,cut def GetSignalHists(signalFile_,prefix,v,region,varTitle,Lumi,verbose,cut,DNNbinWidth_): print "Getting Signal histogram(s)" sig_histos_ = [] - sig_histCategories_ = [] + sig_histCategories_ = [] ##-- Get cut - REGION_CUT = "" - if(region == "SB"): REGION_CUT = "(CMS_hgg_mass <= 115 || CMS_hgg_mass >= 135)" + REGION_CUT = "1" + if(region == "SB"): REGION_CUT = "(CMS_hgg_mass <= 135 || CMS_hgg_mass >= 135)" elif(region == "SR"): REGION_CUT = "(CMS_hgg_mass > 115 && CMS_hgg_mass < 135)" - else: + else: print"Input region ",region,"is not defined" print"Exiting" exit(1) S_WEIGHT = "1*weight" ZERO_CUT = "ZERO_CUT" - S_CUT = "%s*(%s)*(%s)"%(S_WEIGHT,REGION_CUT,ZERO_CUT) - S_CUT += "*(%s)"%(cut) - # S_CUT = S_CUT.replace("goodJets","AtLeast2GoodJets") ## for the case where the data and background ntuples have a different variable name than signal here for the same thing + S_CUT = "%s*(%s)*(%s)"%(S_WEIGHT,REGION_CUT,ZERO_CUT) + S_CUT += "*(%s)"%(cut) + # S_CUT = S_CUT.replace("goodJets","AtLeast2GoodJets") ## for the case where the data and background ntuples have a different variable name than signal here for the same thing S_CUT = S_CUT.replace("ZERO_CUT","(%s != 0) && (%s != -999)"%(v,v)) S_CUT_NOWEIGHTS = "%s"%(S_CUT) S_CUT_NOWEIGHTS = S_CUT_NOWEIGHTS.replace(S_WEIGHT,"(1)") - ##-- Get Signal Histogram(s) - signalFiles = [] + ##-- Get Signal Histogram(s) + signalFiles = [] signalFiles.append(signalFile_) for i,sigPath in enumerate(signalFiles): # sigPath = "%s/%s"%(signalDirec,sigF_) @@ -434,14 +578,16 @@ def GetSignalHists(signalFile_,prefix,v,region,varTitle,Lumi,verbose,cut,DNNbinW sigFile = TFile.Open(sigPath) treeName = GetMCTreeName(sigEnd) # treeName += "_13TeV_HHWWggTag_0" - treeName += "_13TeV_HHWWggTag_0" + treeName += "_13TeV_HHWWggTag_1" MC_Category = GetMCCategory(sigEnd) if(verbose): - # print"Signal File:",sigPath + # print"Signal File:",sigPath print"Signal:",MC_Category # Signal_Trees = TChain('%s%s_13TeV_HHWWggTag_0'%(args_.prefix,treeName)) Signal_Trees = TChain("Signal_Trees") + if(verbose): print("Tree name: %s/tagsDumper/trees/%s%s"%(sigPath,prefix,treeName)) + # Signal_Trees.Add("%s/tagsDumper/trees/%s%s"%(sigPath,prefix,treeName)) Signal_Trees.Add("%s/%s%s"%(sigPath,prefix,treeName)) # Signal_Trees.Add("%s/%s%s_13TeV_HHWWggTag_1"%(sigPath,prefix,treeName)) # Signal_Trees.Add("%s/%s%s_13TeV_HHWWggTag_2"%(sigPath,prefix,treeName)) @@ -449,33 +595,42 @@ def GetSignalHists(signalFile_,prefix,v,region,varTitle,Lumi,verbose,cut,DNNbinW # Signal_Trees.Add("%s/%s%s_13TeV_HHWWggTag_4"%(sigPath,prefix,treeName)) ## - tags 3 and 4 may be here in signal but not data and background xbins, xmin, xmax = GetBins(varTitle,DNNbinWidth_) - exec("S_h_%s = TH1F('S_h_%s',v,xbins,xmin,xmax)"%(i,i)) - exec("S_h_%s_unweighted = TH1F('S_h_%s_unweighted',v,xbins,xmin,xmax)"%(i,i)) + + edges = array('d',[0.1000,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.8071,0.85,0.90,0.9614,1.0001]) + N_bins_special = len(edges) - 1 + + if(varTitle == "evalDNN_WWvsAll_"): + exec("S_h_%s = TH1F('S_h_%s',v,N_bins_special,edges)"%(i,i)) + exec("S_h_%s_unweighted = TH1F('S_h_%s_unweighted',v,N_bins_special,edges)"%(i,i)) + else: + exec("S_h_%s = TH1F('S_h_%s',v,xbins,xmin,xmax)"%(i,i)) + exec("S_h_%s_unweighted = TH1F('S_h_%s_unweighted',v,xbins,xmin,xmax)"%(i,i)) + thisHist = eval("S_h_%s"%(i)) - mcColor = GetMCColor(MC_Category) - ##-- Style options for signal to distinguish from Data, Background + mcColor = GetMCColor(MC_Category) + ##-- Style options for signal to distinguish from Data, Background # eval("MC_h_tmp_%s.SetFillColor(eval(mcColor))"%(i)) # eval("MC_h_tmp_%s.SetFillStyle(3004)"%(i)) - ##-- + ##-- #S_CUT = "weight*(CMS_hgg_mass >= 115 && CMS_hgg_mass <= 135)" # eval("MC_h_tmp_%s.SetFillColorAlpha(eval(mcColor),0.1)"%(i)) # eval("MC_h_tmp_%s.SetLineColor(eval(mcColor))"%(i)) - eval("S_h_%s.SetFillColorAlpha(eval(mcColor),0.1)"%(i)) - eval("S_h_%s.SetLineColor(eval(mcColor))"%(i)) + # eval("S_h_%s.SetFillColorAlpha(eval(mcColor),0.1)"%(i)) + eval("S_h_%s.SetLineColor(eval(mcColor))"%(i)) # exec('Signal_Trees.Draw("%s >> MC_h_tmp_%s","%s")'%(v,i,SIGNAL_CUT)) - exec('Signal_Trees.Draw("%s >> S_h_%s","%s")'%(v,i,S_CUT)) - exec('Signal_Trees.Draw("%s >> S_h_%s_unweighted","%s")'%(v,i,S_CUT_NOWEIGHTS)) + exec('Signal_Trees.Draw("%s >> S_h_%s","%s*((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7))")'%(v,i,S_CUT)) + exec('Signal_Trees.Draw("%s >> S_h_%s_unweighted","%s*((Leading_Photon_MVA>-0.7 && Subleading_Photon_MVA>-0.7))")'%(v,i,S_CUT_NOWEIGHTS)) SigXS_Scale = GetXScale("HHWWgg_SM") # how to scale the XS which is by default in flashgg 1fb if(verbose): print"SigXS_Scale: ",SigXS_Scale - eval("S_h_%s.Scale(float(Lumi))"%(i)) - eval("S_h_%s.Scale(float(SigXS_Scale))"%(i)) + eval("S_h_%s.Scale(float(138))"%(i)) + eval("S_h_%s.Scale(float(SigXS_Scale))"%(i)) S_ = eval("S_h_%s.Integral()"%(i)) S_unweighted_ = eval("S_h_%s_unweighted.Integral()"%(i)) newHist = thisHist.Clone("newHist") - ##-- Set title based on treeName + ##-- Set title based on treeName newHist.SetTitle(MC_Category) newHist.GetXaxis().SetTitle(sigPath) newHist.SetLineStyle(1) @@ -483,56 +638,211 @@ def GetSignalHists(signalFile_,prefix,v,region,varTitle,Lumi,verbose,cut,DNNbinW newHist.SetDirectory(0) sig_histos_.append(newHist) - sig_histCategories_.append(MC_Category) + sig_histCategories_.append(MC_Category) return sig_histos_, sig_histCategories_, S_, S_unweighted_ -##-- Main Data / MC module +##-- Main Data / MC module # def PlotDataMC(dataFiles_,mcFiles_,signalFiles_,dataDirec_,mcDirec_,signalDirec_,Tags_,ol_,args_,region_,DNNbinWidth_): def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNNbinWidth_, ratioMin, ratioMax): - ##-- Misc + tdrStyle = ROOT.TStyle("tdrStyle","Style for P-TDR") + + #for the canvas: + tdrStyle.SetCanvasBorderMode(0) + tdrStyle.SetCanvasColor(ROOT.kWhite) + tdrStyle.SetCanvasDefH(600) #Height of canvas + tdrStyle.SetCanvasDefW(600) #Width of canvas + tdrStyle.SetCanvasDefX(0) #POsition on screen + tdrStyle.SetCanvasDefY(0) + + + tdrStyle.SetPadBorderMode(0) + #tdrStyle.SetPadBorderSize(Width_t size = 1) + tdrStyle.SetPadColor(ROOT.kWhite) + tdrStyle.SetPadGridX(False) + tdrStyle.SetPadGridY(False) + tdrStyle.SetGridColor(0) + tdrStyle.SetGridStyle(3) + tdrStyle.SetGridWidth(1) + + #For the frame: + tdrStyle.SetFrameBorderMode(0) + tdrStyle.SetFrameBorderSize(1) + tdrStyle.SetFrameFillColor(0) + tdrStyle.SetFrameFillStyle(0) + tdrStyle.SetFrameLineColor(1) + tdrStyle.SetFrameLineStyle(1) + tdrStyle.SetFrameLineWidth(1) + + #For the histo: + #tdrStyle.SetHistFillColor(1) + #tdrStyle.SetHistFillStyle(0) + # tdrStyle.SetHistLineColor(1) # FH: Ram + # tdrStyle.SetHistLineStyle(0) # FH: Ram + # tdrStyle.SetHistLineWidth(1) # FH: Ram + #tdrStyle.SetLegoInnerR(Float_t rad = 0.5) + #tdrStyle.SetNumberContours(Int_t number = 20) + + # tdrStyle.SetEndErrorSize(2) # FH: Ram + #tdrStyle.SetErrorMarker(20) + #tdrStyle.SetErrorX(0.) + + tdrStyle.SetMarkerStyle(20) + + #For the fit/function: + tdrStyle.SetOptFit(1) + tdrStyle.SetFitFormat("5.4g") + tdrStyle.SetFuncColor(2) + tdrStyle.SetFuncStyle(1) + tdrStyle.SetFuncWidth(1) + + #For the date: + tdrStyle.SetOptDate(0) + # tdrStyle.SetDateX(Float_t x = 0.01) + # tdrStyle.SetDateY(Float_t y = 0.01) + + # For the statistics box: + tdrStyle.SetOptFile(0) + tdrStyle.SetOptStat(0) # To display the mean and RMS: SetOptStat("mr") + tdrStyle.SetStatColor(ROOT.kWhite) + tdrStyle.SetStatFont(42) + tdrStyle.SetStatFontSize(0.025) + tdrStyle.SetStatTextColor(1) + tdrStyle.SetStatFormat("6.4g") + tdrStyle.SetStatBorderSize(1) + tdrStyle.SetStatH(0.1) + tdrStyle.SetStatW(0.15) + # tdrStyle.SetStatStyle(Style_t style = 1001) + # tdrStyle.SetStatX(Float_t x = 0) + # tdrStyle.SetStatY(Float_t y = 0) + + # Margins: + tdrStyle.SetPadTopMargin(0.05) + tdrStyle.SetPadBottomMargin(0.13) + tdrStyle.SetPadLeftMargin(0.16) + tdrStyle.SetPadRightMargin(0.02) + + # For the Global title: + + tdrStyle.SetOptTitle(0) + tdrStyle.SetTitleFont(42) + tdrStyle.SetTitleColor(1) + tdrStyle.SetTitleTextColor(1) + tdrStyle.SetTitleFillColor(10) + tdrStyle.SetTitleFontSize(0.05) + # tdrStyle.SetTitleH(0) # Set the height of the title box + # tdrStyle.SetTitleW(0) # Set the width of the title box + # tdrStyle.SetTitleX(0) # Set the position of the title box + # tdrStyle.SetTitleY(0.985) # Set the position of the title box + # tdrStyle.SetTitleStyle(Style_t style = 1001) + # tdrStyle.SetTitleBorderSize(2) + + # For the axis titles: + + tdrStyle.SetTitleColor(1, "XYZ") + tdrStyle.SetTitleFont(42, "XYZ") + tdrStyle.SetTitleSize(0.06, "XYZ") + # tdrStyle.SetTitleXSize(Float_t size = 0.02) # Another way to set the size? + # tdrStyle.SetTitleYSize(Float_t size = 0.02) + tdrStyle.SetTitleXOffset(0.7) # FH: Ram + tdrStyle.SetTitleYOffset(1.0) + # tdrStyle.SetTitleOffset(1.1, "Y") # Another way to set the Offset + + # For the axis labels: + + tdrStyle.SetLabelColor(1, "XYZ") + tdrStyle.SetLabelFont(42, "XYZ") + tdrStyle.SetLabelOffset(0.003, "XYZ") # FH: Ram + tdrStyle.SetLabelSize(0.035, "XYZ") # FH: Ram + + # For the axis: + + tdrStyle.SetAxisColor(1, "XYZ") + tdrStyle.SetStripDecimals(True) + tdrStyle.SetTickLength(0.03, "XYZ") + tdrStyle.SetNdivisions(510, "XYZ") + tdrStyle.SetPadTickX(1) # To get tick marks on the opposite side of the frame + tdrStyle.SetPadTickY(1) + + # Change for log plots: + tdrStyle.SetOptLogx(0) + tdrStyle.SetOptLogy(0) + tdrStyle.SetOptLogz(0) + + # Postscript options: + tdrStyle.SetPaperSize(20.,20.) + # tdrStyle.SetLineScalePS(Float_t scale = 3) + # tdrStyle.SetLineStyleString(Int_t i, const char* text) + # tdrStyle.SetHeaderPS(const char* header) + # tdrStyle.SetTitlePS(const char* pstitle) + + # tdrStyle.SetBarOffset(Float_t baroff = 0.5) + # tdrStyle.SetBarWidth(Float_t barwidth = 0.5) + # tdrStyle.SetPaintTextFormat(const char* format = "g") + # tdrStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0) + # tdrStyle.SetTimeOffset(Double_t toffset) + # tdrStyle.SetHistMinimumZero(kTRUE) + + # tdrStyle.SetHatchesLineWidth(5) # FH: Ram + tdrStyle.SetHatchesSpacing(0.05) + + tdrStyle.cd() + + ##-- Misc print"Plotting Data / MC and Signal" + print"data file: ",dataFile_ + print"Signal file: ",signalFile_ + print"background files: ",bkgFiles_ gROOT.ProcessLine("gErrorIgnoreLevel = kError") # kPrint, kInfo, kWarning, kError, kBreak, kSysError, kFatal - gStyle.SetOptStat(0) - #gStyle.SetErrorX(0.0001) + gStyle.SetOptStat(0) + #gStyle.SetErrorX(0.0001) chi2 = 0 ##-- Output outputFolder = "%s/%s"%(ol_,cutName) + print("outputFolder: ",outputFolder) if(not os.path.exists(outputFolder)): os.system('mkdir %s'%(outputFolder)) - os.system('cp %s/index.php %s'%(ol_,outputFolder)) + os.system('cp %s/../index.php %s'%(ol_,outputFolder)) ##-- Get Variables - # If var batch is loose, need separate titles for variables since it will be sum of vars * bools + # If var batch is loose, need separate titles for variables since it will be sum of vars * bools if(args_.VarBatch == "Loose"): - Variables, varNames = GetVars(args_.VarBatch) # get vars from var batch + Variables, varNames = GetVars(args_.VarBatch) # get vars from var batch if(args_.verbose): - print"Variables = ",Variables + print"Variables = ",Variables print"varNames = ",varNames - else: Variables = GetVars(args_.VarBatch) # get vars from var batch - - if(args_.verbose): - print "cut:",cut - print "cutName:",cutName - print "vars:",Variables - - ##-- For each Variable + else: Variables = GetVars(args_.VarBatch) # get vars from var batch + + if(args_.verbose): + print "cut:",cut + print "cutName:",cutName + print "vars:",Variables + + ##-- For each Variable for iv,v in enumerate(Variables): + print("Variable to plot: (",iv,"): ",v) # legend = TLegend(0.55,0.65,0.89,0.89) - legend = TLegend(0.55,0.55,0.89,0.89) - legend.SetTextSize(0.025) + # legend = TLegend(0.55,0.55,0.89,0.89) + NLegend_Columns = 1 + if(v == "evalDNN_WWvsAll" or v == "New_pTBasedSel_a_costheta2"): + leg_xmin, leg_ymin, leg_xmax, leg_ymax = 0.25, 0.545, 0.55, 0.865 # xmin, ymin, xmax, ymax + else: + leg_xmin, leg_ymin, leg_xmax, leg_ymax = 0.25, 0.55, 0.875, 0.865 # xmin, ymin, xmax, ymax + legend = TLegend(leg_xmin, leg_ymin, leg_xmax, leg_ymax) + legend.SetNColumns(NLegend_Columns) + legend.SetTextSize(0.038) legend.SetBorderSize(0) - legend.SetFillStyle(0) + legend.SetFillStyle(0) if(args_.VarBatch == "Loose"): varTitle = varNames[iv] - else: varTitle = GetVarTitle(v) + else: varTitle = GetVarTitle(v) if(args_.verbose): print"Plotting variable:",varTitle xbins, xmin, xmax = GetBins(varTitle,DNNbinWidth_) # xbins, xmin, xmax = GetBins(varTitle) ##-- In either case, SB or SR, get backgrounds and signal(s) bkgStack = THStack("bkgStack","bkgStack") - bkgHistos, bkgHistCategories, Bkg_Names, Bkg_Nevents, Bkg_Nevents_unweighted = GetBackgroundHists(bkgFiles_,args_.noQCD,args_.verbose,args_.prefix,varTitle,region_,v,args_.Lumi,cut,DNNbinWidth_) + bkgHistos, bkgHistCategories, Bkg_Names, Bkg_Nevents, Bkg_Nevents_unweighted = GetBackgroundHists(bkgFiles_,args_.noQCD,args_.verbose,args_.prefix,varTitle,region_,v,args_.Lumi,cut,DNNbinWidth_) sig_histos, sig_histCategories, S_, S_unweighted_ = GetSignalHists(signalFile_,args_.prefix,v,region_,varTitle,args_.Lumi,args_.verbose,cut,DNNbinWidth_) # MC_AddedtoLegend = { @@ -543,7 +853,7 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN # "DiPhoJetsBox" : 0, # "WJets" : 0, # "WW" : 0, - # "tt" : 0, + # "tt\gamma(s)+jets" : 0, # "DY" : 0, # "WGGJets" : 0, # "WGJJ" : 0, @@ -552,13 +862,14 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN MC_AddedtoLegend = { "QCD" : 0, + "QCD_Data": 0, "SMhgg" : 0, "GJet" : 0, "DiPhoJets" : 0, "DiPhoJetsBox" : 0, "WJets" : 0, "WW" : 0, - "tt" : 0, + "tt\gamma(s)+jets" : 0, "DY" : 0, "WGGJets" : 0, "WGJJ" : 0, @@ -567,30 +878,39 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN "VH" : 0, "VBFH" : 0, "ttHJetToGG" : 0, - "THQ" : 0 + "THQ" : 0, + "TTToHadronic": 0 } - + Signals_AddedtoLegend = { - "HHWWgg_SM" : 0 + "Signal" : 0 } - ##-- Order histograms by MC category + ##-- Order histograms by MC category orderedHistos = OrderHistos(bkgHistos,bkgHistCategories) sig_orderedHistos = OrderHistos(sig_histos,sig_histCategories) - ##-- Add backgrounds to background stack + ##-- Add backgrounds to background stack + print("orderedHistos: ",orderedHistos) for h in orderedHistos: + print("histograms: ",h) h.Sumw2() bkgStack.Add(h,'hist') bkgName = h.GetTitle() added = MC_AddedtoLegend[bkgName] - if(added): continue + if(added): continue else: + bkgName = bkgName.replace("QCD_Data","Data driven (QCD + #gamma jets)") + bkgName = bkgName.replace("DiPhoJetsBox","#gamma #gamma+jets") + # bkgName = bkgName.replace("HHWWgg_SM","") legend.AddEntry(h,bkgName,"F") - MC_AddedtoLegend[bkgName] = 1 + # Reverse the above two replacement + bkgName = bkgName.replace("Data driven (QCD + #gamma jets)","QCD_Data") + bkgName = bkgName.replace("#gamma #gamma+jets","DiPhoJetsBox") + MC_AddedtoLegend[bkgName] = 1 - ##-- Add text box with selection type + ##-- Add text box with selection type region_labels = { "SB" : "Sidebands", "SR" : "Signal Region" @@ -600,18 +920,18 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN offset = 0 selText = TLatex(0.129,0.85,cutName) selText.SetNDC(1) - selText.SetTextSize(0.04) + selText.SetTextSize(0.04) CatText = TLatex(0.129,0.8,region_label) CatText.SetNDC(1) - CatText.SetTextSize(0.04) - stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio - stackSum.Sumw2() + CatText.SetTextSize(0.04) + stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio + stackSum.Sumw2() stackSum.SetLineColor(kBlack) #stackSum.SetLineWidth(3) #stackSum.SetFillStyle(0) - #stackSum.SetLineStyle(7) # to distinguish from data uncertainty + #stackSum.SetLineStyle(7) # to distinguish from data uncertainty - # # the purpose of this clone is to try and plot shaded error bands on the background stack sum + # # the purpose of this clone is to try and plot shaded error bands on the background stack sum # stackSum_clone_forError = stackSum.Clone("stackSum_clone_forError") # #binWidth = stackSum_clone_forError.GetXaxis().GetBinWidth(0) @@ -641,34 +961,34 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN #print("stack type:",type(stackSum_clone_forError)) #stackSum_clone_forError.SetLineColorAlpha(kBlack, 0.5) #stackSum_clone_forError.SetLineStyle(2) - #stackSum_clone_forError.SetLineWidth(10) + #stackSum_clone_forError.SetLineWidth(10) stackSum_clone = stackSum.Clone("stackSum_clone") stackSum_clone.SetDirectory(0) # B_vals_ = GetBinVals(stackSum_clone) - S_vals_ = GetBinVals(sig_orderedHistos[0]) ## assuming 1 signal + S_vals_ = GetBinVals(sig_orderedHistos[0]) ## assuming 1 signal # for s_val in S_vals_: # print"s_val:",s_val # for b_val in B_vals_: - # print"b_val:",b_val + # print"b_val:",b_val # B = sum(Bkg_Nevents) # S = sum(S_vals_) # print("B = ",B) - ##-- By default draw background save background contributions. Later delete if not wanted + ##-- By default draw background save background contributions. Later delete if not wanted bkgOutName = "%s/BackgroundsPADS_%s_%s.png"%(outputFolder,varTitle,region_) SimpleDrawHisto(bkgStack,"PADS",bkgOutName,varTitle) bkgOutName = bkgOutName.replace(".png",".pdf") - SimpleDrawHisto(bkgStack,"PADS",bkgOutName,varTitle) + SimpleDrawHisto(bkgStack,"PADS",bkgOutName,varTitle) - ##-- If Plotting in the Sidebands, Get Data and combine plots + ##-- If Plotting in the Sidebands, Get Data and combine plots if(region_ == "SB"): - # define selections - # just use combined tag always. Define a category or look at cut based analysis categories by making selections + # define selections + # just use combined tag always. Define a category or look at cut based analysis categories by making selections DataHist = GetDataHist(dataFile_,args_.prefix,cut,cutName,iv,v,varTitle,args_.VarBatch,args_.verbose,DNNbinWidth_) ## assuming one data file! dataNevents = DataHist.GetEntries() # legend.AddEntry(DataHist,"Data","P") @@ -679,40 +999,40 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN DataHist.SetLineColorAlpha(kBlack, 0) - if(args_.log): + if(args_.log): if(args_.verbose): print "Setting histogram minimums" print"Setting histogram minimums" #bkgStack.SetMinimum(1) DataHist.SetMinimum(1.) stackSum.SetMinimum(1.) bkgStack.SetMinimum(1.) - #bkgStack.SetMinimum(0.0001) + #bkgStack.SetMinimum(0.0001) #stackSum.SetMinimum(0.0001) - #bkgStack.SetMinimum(0.0001) + #bkgStack.SetMinimum(0.0001) - # Convert DataHist into TGraphErrors in order to remove x errors + # Convert DataHist into TGraphErrors in order to remove x errors nBins = DataHist.GetNbinsX() print("nBins:",nBins) x_ = [] - ex_= [] + ex_= [] y_ = [] ey_ = [] - + for i,bin in enumerate(DataHist): - if(i == 0): continue # skip underflow bin - if(i == (nBins + 1)): continue # skip overflow bin + if(i == 0): continue # skip underflow bin + if(i == (nBins + 1)): continue # skip overflow bin #print("i:",i) - #print("bin:",bin) + #print("bin:",bin) #print("center_value:",DataHist.GetBinCenter(i)) - #print("yerr:",DataHist.GetBinError(i)) + #print("yerr:",DataHist.GetBinError(i)) center_value = DataHist.GetBinCenter(i) yerr = DataHist.GetBinError(i) x_.append(center_value) - ex_.append(0.0001) + ex_.append(0.0001) y_.append(bin) ey_.append(yerr) - + x = array( 'f', x_ ) ex = array( 'f', ex_ ) y = array( 'f', y_ ) @@ -725,12 +1045,12 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN ## ##-- Optional: Scale Backgrounds to SF: Data sidebands sum / Background sidebands sum - SidebandSF_ = 1 + SidebandSF_ = 1 if(args_.SidebandScale): - data_sidebands_sum = DataHist.Integral() ##-- data hist is already in sidebands only + data_sidebands_sum = DataHist.Integral() ##-- data hist is already in sidebands only background_sidebands_sum = stackSum.Integral() if(background_sidebands_sum > 0): SidebandSF_ = float(data_sidebands_sum / background_sidebands_sum) - else: + else: print "background sidebands sum <= 0. Setting sideband scale factor to 1" SidebandSF_ = 1 print "data sum in sidebands:",data_sidebands_sum @@ -738,9 +1058,9 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN print "Sideband scale factor:",SidebandSF_ for background in bkgStack.GetStack(): background.Scale(SidebandSF_) - stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio + stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio - # the purpose of this clone is to try and plot shaded error bands on the background stack sum + # the purpose of this clone is to try and plot shaded error bands on the background stack sum stackSum_clone_forError = stackSum.Clone("stackSum_clone_forError") #binWidth = stackSum_clone_forError.GetXaxis().GetBinWidth(0) @@ -762,14 +1082,14 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN #stackSum_clone_forError.SetLineStyle(2) #stackSum_clone_forError.SetLineWidth(10) - # stackSum.Scale(SidebandSF) + # stackSum.Scale(SidebandSF) - ##-- Compute chi squared + ##-- Compute chi squared chi2 = GetChiSquared(DataHist,stackSum) - # print"chi2 = ",chi2 - chi2Text = TLatex(0.129,0.75,"#Chi^{2} = %.5g"%(chi2)) + # print"chi2 = ",chi2 + chi2Text = TLatex(0.129,0.75,"#Chi^{2} = %.5g"%(chi2)) chi2Text.SetNDC(1) - chi2Text.SetTextSize(0.04) + chi2Text.SetTextSize(0.04) #for i,bin in enumerate(stackSum): #binUnc = bin**(1/2) #print("bin %s: yield equals: %s"%(i,bin)) @@ -781,54 +1101,166 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN #for i, bin in enumerate(stackSum) - ##-- Define ratio plot for computing Data / MC ratio + ##-- Define ratio plot for computing Data / MC ratio rp = TRatioPlot(DataHist,stackSum) - #rp.SetH1DrawOpt("") # whether or not to draw data from datahist object + #rp.SetH1DrawOpt("") # whether or not to draw data from datahist object rp.SetH2DrawOpt("hist") # rp.SetH2DrawOpt("PE2") # rp.SetGraphDrawOpt("PE2") + rp.SetGraphDrawOpt("PE0") + removeLowererrors = 0 dMax = DataHist.GetMaximum() bMax = stackSum.GetMaximum() - maxHeight = max(dMax,bMax) + maxHeight = max(dMax,bMax) - ##-- Create the entire picture: Combine Data, MC, Data / MC ratio and signal in one plot + ##-- Create the entire picture: Combine Data, MC, Data / MC ratio and signal in one plot for fileType in ["pdf"]: #gStyle.SetErrorX(0.0001) # varTitle = GetVarTitle(v) outName = "%s/DataMC_%s_%s.%s"%(outputFolder,varTitle,region_,fileType) if(args_.log): outName = "%s/DataMC_%s_%s_log.%s"%(outputFolder,varTitle,region_,fileType) - else: outName = "%s/DataMC_%s_%s_nonLog.%s"%(outputFolder,varTitle,region_,fileType) - DataMCRatio_c = TCanvas("DataMCRatio_c","DataMCRatio_c",600,800) + else: outName = "%s/DataMC_%s_%s_nonLog.%s"%(outputFolder,varTitle,region_,fileType) + DataMCRatio_c = TCanvas("DataMCRatio_c","DataMCRatio_c",900,1200) rp.Draw("nogrid") rp.GetLowYaxis().SetNdivisions(5) DataMCRatio_c.Update() + x_ratio_ = [] + ex_ratio_low_= [] + ex_ratio_high_= [] + y_ratio_ = [] + ey_ratio_low_ = [] + ey_ratio_high_ = [] + + # for i,bin in enumerate(DataHist): + # if(i == 0): continue # skip underflow bin + # if(i == (nBins + 1)): continue # skip overflow bin + # center_value = DataHist.GetBinCenter(i) + # yerr = DataHist.GetBinError(i) + ratioGraph = rp.GetCalculationOutputGraph() - ratioGraph.SetMarkerStyle(8) - ratioGraph.SetMarkerSize(0.5) + Npoints_g = ratioGraph.GetN() - # rp.SetGraphDrawOpt("EP") - # rp.SetGraphDrawOpt("EPZ2") - # rp.GetLowerRefYaxis().SetTitle("Data / MC") + x1 = float(ratioGraph.GetPointX(1)) + x2 = float(ratioGraph.GetPointX(2)) + + xWidth = float(x2 - x1) / 2. + + for p_i in range(0, stackSum.GetNbinsX()): + # print("p_i:",p_i) + x_val = ratioGraph.GetPointX(p_i) + y_val = ratioGraph.GetPointY(p_i) + y_err_low = ratioGraph.GetErrorYlow(p_i) + print("Chuw ratio error:",ratioGraph.GetErrorYlow(p_i)) + + y_err_high = ratioGraph.GetErrorYhigh(p_i) + if(stackSum.GetBinContent(p_i+1)!=0): + y_err_low = stackSum.GetBinErrorLow(p_i+1)/stackSum.GetBinContent(p_i+1)*y_val# MC relatively error + y_err_high = stackSum.GetBinErrorUp(p_i+1)/stackSum.GetBinContent(p_i+1)*y_val + else: + y_err_low = 0 + y_err_high = 0 + # print("Chuw MC error:",y_err_low) + # y_val=DataHist.GetBinContent(p_i+1)/stackSum.GetBinContent(p_i+1) + if(DataHist.GetBinContent(p_i+1)!=0): + data_err_low = DataHist.GetBinErrorLow(p_i+1)/DataHist.GetBinContent(p_i+1)*y_val # relative Data error * ratio + data_err_high = DataHist.GetBinErrorUp(p_i+1)/DataHist.GetBinContent(p_i+1)*y_val + else: + data_err_low = 0 + data_err_high = 0 + UseRatioErr=0 + if(UseRatioErr): + data_err_low=ratioGraph.GetErrorYlow(p_i) + data_err_high=ratioGraph.GetErrorYhigh(p_i) + print("Chuw Data error:",data_err_low) + # print("Chuw ratio:",y_val) + print("chuw Data/MC error:",y_val*math.sqrt(((data_err_low*data_err_low)/(y_val*y_val))+(y_err_low*y_err_low)/(y_val*y_val))) + print("Diff:",(y_val*math.sqrt(((data_err_low*data_err_low)/(y_val*y_val))+((y_err_low*y_err_low)/(y_val*y_val)))-ratioGraph.GetErrorYlow(p_i))/ratioGraph.GetErrorYlow(p_i)) + print("=======") + rp.GetLowerRefGraph().SetPointEXhigh(p_i,0) + rp.GetLowerRefGraph().SetPointEXlow(p_i,0) + + rp.GetLowerRefGraph().SetPointEYhigh(p_i,data_err_high) + rp.GetLowerRefGraph().SetPointEYlow(p_i,data_err_low) + + + # print("x_val:",x_val) + # print("y_val:",y_val) + # print("y_err_low:",y_err_low) + # print("y_err_high:",y_err_high) + + x_ratio_.append(x_val) + + if(varTitle != "evalDNN_WWvsAll_"): + ex_ratio_low_.append(xWidth) + ex_ratio_high_.append(xWidth) + else: + + edges = array('d',[0.1000,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50,0.55,0.60,0.65,0.70,0.75,0.8071,0.85,0.90,0.9614,1.0001]) - rp.GetUpperRefYaxis().SetTitle("Entries") + edgeUpper = edges[p_i+1] + edgeLower = edges[p_i] + + er_up = float(edgeUpper - x_val) + er_down = float(x_val - edgeLower) + + ex_ratio_low_.append(er_up) + ex_ratio_high_.append(er_down) + + y_ratio_.append(1) # set to 1 on purpose to make bars from ratio = 1 to show agreement + ey_ratio_low_.append(y_err_low) + ey_ratio_high_.append(y_err_high) + + x_ratio = array( 'f', x_ratio_ ) + ex_ratio_low = array( 'f', ex_ratio_low_ ) + ex_ratio_high = array( 'f', ex_ratio_high_ ) + y_ratio = array( 'f', y_ratio_ ) + ey_ratio_low = array( 'f', ey_ratio_low_ ) + ey_ratio_high = array( 'f', ey_ratio_high_ ) + + ratio_bars = TGraphAsymmErrors(Npoints_g, x_ratio, y_ratio, ex_ratio_low, ex_ratio_high, ey_ratio_low, ey_ratio_high) + + xTitle = GetXaxisTitle(varTitle) + DataHist.GetXaxis().SetTitle(xTitle) + + print("xTitle:",xTitle) + + # logYMin = 0.005 + logYMin = 0.0001 + rp.GetUpperRefYaxis().SetTitle("Entries") rp.GetLowerRefYaxis().SetTitle("Data / MC") + + rp.GetLowerPad().cd() + # ratio_bars.SetFillColor(1) + ratio_bars.SetFillStyle(1001) + ratio_bars.SetFillColorAlpha(kGray+2, 0.5) + ratio_bars.Draw("sameF2") + LowerLegend=TLegend(0.2, 0.8, .4, .9) + LowerLegend.AddEntry(ratio_bars,"MC stat. unc.","F") + LowerLegend.Draw("same") + # rp.GetLowerRefXaxis().SetNdivisions(1 + rp.GetLowerPad().Update() - if(args_.log): rp.GetUpperRefYaxis().SetRangeUser(0.1,maxHeight*100.) - else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*1.4) # to make room for plot text + # if(args_.log): rp.GetUpperRefYaxis().SetRangeUser(0.1,maxHeight*100.) + if(args_.log): rp.GetUpperRefYaxis().SetRangeUser(logYMin,maxHeight*100000.) + else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*1.4) # to make room for plot text + + rp.GetUpperRefXaxis().SetTitle(xTitle) UpperPad = rp.GetUpperPad() UpperPad.cd() + bkgStack.SetTitle("") bkgStack.Draw("same") - #stackSum.Draw("same") # error option for sum of backgrounds stack + #stackSum.Draw("same") # error option for sum of backgrounds stack stackSum_clone_forError.SetLineWidth(0) - stackSum_clone_forError.Draw("sameE0E2") + # stackSum_clone_forError.Draw("sameE0E2") + stackSum_clone_forError.Draw("sameE2") #stackSum.DrawCopy("hist") #stackSum.SetFillColor(kBlue) #stackSum.SetFillStyle(3018) - #stackSum.Draw("e2same") + #stackSum.Draw("e2same") #gStyle.SetErrorX(0.0001) #beforeSetError = gStyle.GetErrorX() #gStyle.SetErrorX(0.0001) @@ -845,88 +1277,154 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN #DataHist.SetMinimum(1.) #stackSum.SetMinimum(1.) #bkgStack.SetMinimum(1.) - - #DataHist.SetMaximum(6000.) - #stackSum.SetMaximum(6000.) - #bkgStack.SetMaximum(6000.) + + # DataHist.SetMaximum(2500000.) + # stackSum.SetMaximum(1000000.) + # bkgStack.SetMaximum(1000000.) for sig_hist in sig_histos: sigMax = sig_hist.GetMaximum() - if sigMax == 0: sigMax = 1 + if sigMax == 0: sigMax = 1 - ##-- No user input signal scale - if(args_.SigScale == -999): - sigScale = (float(maxHeight)/10.) / float(sigMax) # in order to scale signal to 10th of max of plot - sig_hist.Scale(sigScale) + ##-- No user input signal scale + if(args_.SigScale == -999): + sigScale = (float(maxHeight)/10.) / float(sigMax) # in order to scale signal to 10th of max of plot + sig_hist.Scale(sigScale) - ##-- User input signal scale + ##-- User input signal scale else: if(args_.verbose): print"user sig scale:",args_.SigScale sigScale = args_.SigScale - sig_hist.Scale(sigScale) - + sig_hist.Scale(sigScale) + for sig_h in sig_orderedHistos: # sigName = "%s X %d"%(sig_h.GetTitle(),sigScale) sigName = sig_h.GetTitle() added = Signals_AddedtoLegend[sigName] - if(added): continue + if(added): continue else: legend.AddEntry(sig_h,"%s * %.5g"%(sig_h.GetTitle(),sigScale),"FL") - Signals_AddedtoLegend[sigName] + Signals_AddedtoLegend[sigName] sig_hist.Draw("samehist") legend.AddEntry(DataHist,"Data","P") legend.Draw("same") - selText.Draw("same") - CatText.Draw("same") - chi2Text.Draw("same") + if(v == "evalDNN_WWvsAll"): + l1 = TLine(0.9614,0.0,0.9614,1000000000) + l2 = TLine(0.8071,0.0,0.8071,1000000000) + l3 = TLine(0.9743,0.0,0.9743,1000000000) + l1.SetLineStyle(3) + l2.SetLineStyle(3) + l3.SetLineStyle(3) + l1.Draw() + l2.Draw() + l3.Draw() + + text1 = ROOT.TPaveText(0.86, 1.0, 0.90, 5.0) + text2 = ROOT.TPaveText(0.961428571429, 1.0, 0.974285714286, 5.0) + text3 = ROOT.TPaveText(0.98, 1.0, 0.99, 5.0) + text1.AddText("cat-3") + # text1.Draw() + text2.AddText("cat-2") + # text2.Draw() + text3.AddText("cat-1") + # text3.SetTextAngle(90.0) + # text3.SetTextAlign(22) + # text3.SetAllWith("cat",'align',90.0) + # text3.Draw() + + txt4 = ROOT.TText(0.99, 1.0, "CAT-1") + txt4.SetTextAngle(90) + # txt4.Draw() + txt5 = ROOT.TText(0.972, 1.0, "CAT-2") + txt5.SetTextAngle(90) + # txt5.Draw() + txt6 = ROOT.TText(0.88, 1.0, "CAT-3") + txt6.SetTextAngle(90) + # txt6.Draw() + + + # selText.Draw("same") + # CatText.Draw("same") + # chi2Text.Draw("same") rp.GetLowerRefGraph().SetMinimum(ratioMin) - rp.GetLowerRefGraph().SetMaximum(ratioMax) + rp.GetLowerRefGraph().SetMaximum(ratioMax) Npoints = rp.GetLowerRefGraph().GetN() - for ip in range(0,Npoints): - rp.GetLowerRefGraph().SetPointEXhigh(ip,0) - rp.GetLowerRefGraph().SetPointEXlow(ip,0) - if(args_.log): + + # if(1): + # for ip in range(0,Npoints): + # rp.GetLowerRefGraph().SetPointEXhigh(ip,0) + # rp.GetLowerRefGraph().SetPointEXlow(ip,0) + + # rp.GetLowerRefGraph().SetPointEYhigh(ip,0) + # rp.GetLowerRefGraph().SetPointEYlow(ip,0) + + # for ip in range(0,Npoints): + # rp.GetLowerRefGraph().SetPointEXhigh(ip,0) + # rp.GetLowerRefGraph().SetPointEXlow(ip,0) + if(args_.log): UpperPad.SetLogy() - UpperPad.Update() + UpperPad.Update() rp.GetLowerPad().cd() lowerPad = rp.GetLowerPad() + lowerPad.SetBottomMargin(0.0) + lowerPad.SetTopMargin(0.0) + lowerPad.SetLeftMargin(0.15) # it was a miracle that I figured this part out + rp.GetLowerRefYaxis().SetTitle("Data / MC") lineAtOne = TLine(lowerPad.GetUxmin(),1,lowerPad.GetUxmax(),1) lineAtOne.SetLineStyle(3) lineAtOne.Draw("same") - rp.GetLowerPad().Update() - DataMCRatio_c.Update() - DataMCRatio_c.SaveAs(outName) - outName = outName.replace(".pdf",".png") - DataMCRatio_c.SaveAs(outName) + rp.GetLowerPad().Update() + UpperPad = rp.GetUpperPad() + UpperPad.SetBottomMargin(0.0) + rp.GetUpperPad().Update() + + UpperPad.cd() + CMS_lumi( gPad, 4, 1) + DataMCRatio_c.cd() + DataMCRatio_c.Update() + print("TEST RAM1") + # upperPad.SetBottomMargin(0.075) # it was a miracle that I figured this part out + # upperPad.Draw() + # upperPad.cd() + DataMCRatio_c.SaveAs(outName) + outName = outName.replace(".pdf",".png") + DataMCRatio_c.SaveAs(outName) ##-- If plotting in the signal region, Combine Background and Signal(s) elif(region_ == "SR"): - print "Plotting Signal Region" + print "Plotting Signal Region: Data" - # plotLog = 1 ##-- Plot signal region selected plots in log scale by default since HH->WWgg signal is small - # upperPlotymin = 0.001 + # plotLog = 1 ##-- Plot signal region selected plots in log scale by default since HH->WWgg signal is small + # upperPlotymin = 0.001 plotLog = args_.log if(plotLog): upperPlotymin = 0.001 - else: upperPlotymin = 0 - dataNevents = 0 + else: upperPlotymin = 0 + dataNevents = 0 ##-- Optional: Scale Backgrounds to SF: Data sidebands sum / Background sidebands sum - SidebandSF_ = 1 + SidebandSF_ = 1 + print("SidebandSF_: {}".format(SidebandSF_)) + print("args_.SidebandScale: {}".format(args_.SidebandScale)) + print("cutName: {}".format(cutName)) + args_.SidebandScale = True + # print("data side band: {}".format(data_sidebands_sum)) if(args_.SidebandScale): DataHist = GetDataHist(dataFile_,args_.prefix,cut,cutName,iv,v,varTitle,args_.VarBatch,args_.verbose, DNNbinWidth_) ## assuming one data file! - data_sidebands_sum = DataHist.Integral() ##-- data hist is already in sidebands only + data_sidebands_sum = DataHist.Integral() ##-- data hist is already in sidebands only + + print("data side band: {}".format(data_sidebands_sum)) - ##-- If region is SR, need to draw background in SB in order to obtain proper SF + ##-- If region is SR, need to draw background in SB in order to obtain proper SF bkgStack_sidebands = THStack("bkgStack_sidebands","bkgStack_sidebands") - bkgHistos_sidebands, bkgHistCategories_sidebands, Bkg_Names_sidebands, Bkg_Nevents_sidebands, Bkg_Nevents_unweighted_sidebands = GetBackgroundHists(bkgFiles_,args_.noQCD,args_.verbose,args_.prefix,varTitle,"SB",v,args_.Lumi,cut,DNNbinWidth_) ##-- Sidebands + bkgHistos_sidebands, bkgHistCategories_sidebands, Bkg_Names_sidebands, Bkg_Nevents_sidebands, Bkg_Nevents_unweighted_sidebands = GetBackgroundHists(bkgFiles_,args_.noQCD,args_.verbose,args_.prefix,varTitle,"SB",v,args_.Lumi,cut,DNNbinWidth_) ##-- Sidebands orderedHistos_sidebands = OrderHistos(bkgHistos_sidebands,bkgHistCategories_sidebands) for h in orderedHistos_sidebands: h.Sumw2() bkgStack_sidebands.Add(h,'hist') - stackSum_sidebands = bkgStack_sidebands.GetStack().Last() #->Draw(); # for computing ratio + stackSum_sidebands = bkgStack_sidebands.GetStack().Last() #->Draw(); # for computing ratio background_sidebands_sum = stackSum_sidebands.Integral() if(background_sidebands_sum > 0): SidebandSF_ = float(data_sidebands_sum / background_sidebands_sum) - else: + else: print "background sidebands sum <= 0. Setting sideband scale factor to 1" SidebandSF_ = 1 print "data sum in sidebands:",data_sidebands_sum @@ -934,9 +1432,9 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN print "Sideband scale factor:",SidebandSF_ for background in bkgStack.GetStack(): background.Scale(SidebandSF_) - stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio + stackSum = bkgStack.GetStack().Last() #->Draw(); # for computing ratio - Signal_h_clone = sig_histos[0].Clone("Signal_h_clone") ##-- assuming you want the ratio with the first signal in the list + Signal_h_clone = sig_histos[0].Clone("Signal_h_clone") ##-- assuming you want the ratio with the first signal in the list Signal_h_clone.SetDirectory(0) xTitle = GetXaxisTitle(varTitle) Signal_h_clone.GetXaxis().SetTitle(xTitle) @@ -953,9 +1451,9 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN # S_val = Signal_h_clone.GetBinContent(i+1) # i+1 to avoid underflow bin # S_vals_.append(S_val) # # if(S_val != 0.0): S_vals_.append(S_val) - # print "S_vals_:",S_vals_ ## if any of these are zero or background is zero in a bin, you may have problems with the S / sqrt(B) plot + # print "S_vals_:",S_vals_ ## if any of these are zero or background is zero in a bin, you may have problems with the S / sqrt(B) plot - # B_vals_ = [] + # B_vals_ = [] # for i in range(0,xbins): # B_val = stackSum_clone.GetBinContent(i+1) # B_vals_.append(B_val) @@ -963,7 +1461,7 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN for i,bin in enumerate(stackSum): binUnc = bin**(1/2) - # print"bin %s: yield equals: %s"%(i,bin) + # print"bin %s: yield equals: %s"%(i,bin) # print"uncertainty: ",stackSum.GetBinError(i) stackSum.SetBinError(i,binUnc) @@ -975,17 +1473,19 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN sMax = Signal_h_clone.GetMaximum() bMax = stackSum.GetMaximum() - # maxHeight = max(sMax,bMax) - maxHeight = max(sMax,bMax) + # maxHeight = max(sMax,bMax) + maxHeight = max(sMax,bMax) - ##-- Create the entire picture: Combine Data, MC, Data / MC ratio and signal in one plot + ##-- Create the entire picture: Combine Data, MC, Data / MC ratio and signal in one plot for fileType in ["pdf"]: #gStyle.SetErrorX(0.0001) # varTitle = GetVarTitle(v) outName = "%s/DataMC_%s_%s.%s"%(outputFolder,varTitle,region_,fileType) if(plotLog): outName = "%s/DataMC_%s_%s_log.%s"%(outputFolder,varTitle,region_,fileType) - else: outName = "%s/DataMC_%s_%s_nonLog.%s"%(outputFolder,varTitle,region_,fileType) + else: outName = "%s/DataMC_%s_%s_nonLog.%s"%(outputFolder,varTitle,region_,fileType) DataMCRatio_c = TCanvas("DataMCRatio_c","DataMCRatio_c",600,800) + rp.SetTitle("") + rp.Draw("nogrid") rp.GetLowYaxis().SetNdivisions(5) DataMCRatio_c.Update() @@ -998,12 +1498,16 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN # rp.SetGraphDrawOpt("EPZ2") # rp.GetLowerRefYaxis().SetTitle("Data / MC") - rp.GetUpperRefYaxis().SetTitle("Entries") + rp.GetUpperRefYaxis().SetTitle("Entries") rp.GetLowerPad().Update() - if(plotLog): rp.GetUpperRefYaxis().SetRangeUser(upperPlotymin,maxHeight*100.) - # else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*1.4) # to make room for plot text - else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*2.0) # to make room for plot text - + # if(plotLog): rp.GetUpperRefYaxis().SetRangeUser(upperPlotymin,maxHeight*100.) + if(plotLog): rp.GetUpperRefYaxis().SetRangeUser(upperPlotymin,maxHeight*10000.) + # else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*1.4) # to make room for plot text + else: rp.GetUpperRefYaxis().SetRangeUser(0,maxHeight*2.0) # to make room for plot text + + bkgStack.SetTitle("") + stackSum.SetTitle("") + UpperPad = rp.GetUpperPad() UpperPad.cd() bkgStack.Draw("same") @@ -1011,28 +1515,28 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN # DataHist.Draw("samePE") for sig_hist in sig_histos: sigMax = sig_hist.GetMaximum() - if sigMax == 0: sigMax = 1 + if sigMax == 0: sigMax = 1 - ##-- No user input signal scale - if(args_.SigScale == -999): - sigScale = (float(maxHeight)/10.) / float(sigMax) # in order to scale signal to 10th of max of plot - sig_hist.Scale(sigScale) + ##-- No user input signal scale + if(args_.SigScale == -999): + sigScale = (float(maxHeight)/10.) / float(sigMax) # in order to scale signal to 10th of max of plot + sig_hist.Scale(sigScale) - ##-- User input signal scale - ##-- NOTE this will plot something that doesn't correspond to the ratio of S to B if sig scale != 1 + ##-- User input signal scale + ##-- NOTE this will plot something that doesn't correspond to the ratio of S to B if sig scale != 1 else: if(args_.verbose): print"user sig scale:",args_.SigScale sigScale = args_.SigScale - sig_hist.Scale(sigScale) - + sig_hist.Scale(sigScale) + for sig_h in sig_orderedHistos: # sigName = "%s X %d"%(sig_h.GetTitle(),sigScale) sigName = sig_h.GetTitle() added = Signals_AddedtoLegend[sigName] - if(added): continue + if(added): continue else: legend.AddEntry(sig_h,"%s * %.5g"%(sig_h.GetTitle(),sigScale),"FL") - Signals_AddedtoLegend[sigName] + Signals_AddedtoLegend[sigName] sig_hist.Draw("same hist") # legend.AddEntry(DataHist,"Data","P") legend.Draw("same") @@ -1048,44 +1552,45 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN # binmin = rp.GetLowerRefGraph().GetPointX(ip) # SoverB = rp.GetLowerRefGraph().GetPointY(ip) # S = S_vals_[ip] - # ## calc s / sqrtB) from here and then just plot it on lower graph + # ## calc s / sqrtB) from here and then just plot it on lower graph # # print "binmind: ",binmin # # print "S:",S - # # print "SoverB:",SoverB + # # print "SoverB:",SoverB # # sqrtB = (SoverB**-1)*S # B = S*(1 / SoverB) # if(B<=0): sqrtB = 0 # else: sqrtB = B**1/2 # if(sqrtB <= 0 or S == 0): SoversqrtB = 0 # else: SoversqrtB = S / sqrtB - + # # print "SoversqrtB:",SoversqrtB # SosqB_vals.append(SoversqrtB) - + # SosqB_min, SosqB_max = min(SosqB_vals), max(SosqB_vals) # lowerPlotMin, lowerPlotMax = SosqB_min / 2 , SosqB_max * 2 for ip in range(0,Npoints): - rp.GetLowerRefGraph().SetPointEXhigh(ip,0) - rp.GetLowerRefGraph().SetPointEXlow(ip,0) - # rp.GetLowerRefGraph().SetPointY(ip,SosqB_vals[ip]) + rp.GetLowerRefGraph().SetPointEXhigh(ip,0) + rp.GetLowerRefGraph().SetPointEXlow(ip,0) + # rp.GetLowerRefGraph().SetPointY(ip,SosqB_vals[ip]) # rp.GetLowerRefGraph().SetMinimum(lowerPlotMin) - # rp.GetLowerRefGraph().SetMaximum(lowerPlotMax) - if(plotLog): + # rp.GetLowerRefGraph().SetMaximum(lowerPlotMax) + if(plotLog): UpperPad.SetLogy() - UpperPad.Update() + UpperPad.Update() rp.GetLowerPad().cd() lowerPad = rp.GetLowerPad() - # rp.GetLowerRefYaxis().SetTitle("S / #sqrt{B}") # this is what we want but not there yet - rp.GetLowerRefYaxis().SetTitle("S / B") # this is what we want but not there yet + # rp.GetLowerRefYaxis().SetTitle("S / #sqrt{B}") # this is what we want but not there yet + rp.GetLowerRefYaxis().SetTitle("S / B") # this is what we want but not there yet lineAtOne = TLine(lowerPad.GetUxmin(),1,lowerPad.GetUxmax(),1) lineAtOne.SetLineStyle(3) lineAtOne.Draw("same") - rp.GetLowerPad().Update() - DataMCRatio_c.Update() - DataMCRatio_c.SaveAs(outName) - outName = outName.replace(".pdf",".png") - DataMCRatio_c.SaveAs(outName) + rp.GetLowerPad().Update() + DataMCRatio_c.Update() + print("TEST RAM2") + DataMCRatio_c.SaveAs(outName) + outName = outName.replace(".pdf",".png") + DataMCRatio_c.SaveAs(outName) if(not args_.drawPads): bkgOutName = "%s/BackgroundsPADS_%s_%s.png"%(outputFolder,varTitle,region_) @@ -1094,12 +1599,11 @@ def PlotDataMC(dataFile_,bkgFiles_,signalFile_,ol_,args_,region_,cut,cutName,DNN os.system('rm %s'%(bkgOutName)) ##-- Only create yields table for 0th variable because yields are cut dependent, not variable dependent - if(iv==0): + if(iv==0): print"SidebandSF_:",SidebandSF_ - B_vals_ = [] - CreateYieldsTable(region_,cutName,Bkg_Names,args_.removeBackgroundYields,S_vals_,B_vals_,dataNevents,SidebandSF_,Bkg_Nevents,ol_,Bkg_Nevents_unweighted, S_, S_unweighted_) - - ## For each variable loop ends here + B_vals_ = [] + CreateYieldsTable(region_,cutName,Bkg_Names,args_.removeBackgroundYields,S_vals_,B_vals_,dataNevents,SidebandSF_,Bkg_Nevents,ol_,Bkg_Nevents_unweighted, S_, S_unweighted_) + + ## For each variable loop ends here return chi2 - diff --git a/NtupleAnalysis/python/Options.py b/NtupleAnalysis/python/Options.py index 86763bf..9413a7e 100644 --- a/NtupleAnalysis/python/Options.py +++ b/NtupleAnalysis/python/Options.py @@ -1,6 +1,6 @@ -# The purpose of this module is to define options based on user input for running NtupleAnalysis modules +# The purpose of this module is to define options based on user input for running NtupleAnalysis modules -import argparse +import argparse def GetOptions(): parser = argparse.ArgumentParser() @@ -10,7 +10,7 @@ def GetOptions(): parser.add_argument("--DataMC", action="store_true", default=False, help="Produce Data / MC Comparisons", required=False) parser.add_argument("--GenReco", action="store_true", default=False, help="Perform Gen Reco analysis", required=False) - ##-- Efficiency Plots + ##-- Efficiency Plots parser.add_argument("--ratio", action="store_true", default=False, help="Efficiency Ratio", required=False) parser.add_argument('--folders', type=str, default="", help="Comma separated list of ntuple folders", required=False) parser.add_argument('--campaigns', type=str, default="", help="Comma separated list of campaigns", required=False) @@ -27,7 +27,7 @@ def GetOptions(): parser.add_argument('--note', type=str, default="", help="Note for titles and file path", required=False) parser.add_argument('--folder', type=str, default="", help="Input folder with hadded files", required=False) - ##-- Data / MC comparison + ##-- Data / MC comparison parser.add_argument('--dataFile', type=str, default="", help="Path to data file", required=False) parser.add_argument('--signalFile', type=str, default="", help="Path to signal file", required=False) parser.add_argument('--bkgDirec', type=str, default="", help="Directory containing backgrounds", required=False) @@ -40,7 +40,7 @@ def GetOptions(): parser.add_argument('--Tags', type=str, default="", help="Comma separated list of tags to run. Ex: HHWWggTag_0,HHWWggTag_1,HHWWggTag_2 or HHWWggTag_2 or HHWWggTag_2,combined", required=False) parser.add_argument("--noQCD", action="store_true", default=False, help="Turn on to skip QCD", required=False) parser.add_argument("--SidebandScale", action="store_true", default=False, help="Scale all MC to Data sidebands", required=False) - parser.add_argument('--removeBackgroundYields', action="store_true", default=False, help="In yeilds output, only show last few summary rows", required=False) ##-- ideally you should just output both + parser.add_argument('--removeBackgroundYields', action="store_true", default=False, help="In yeilds output, only show last few summary rows", required=False) ##-- ideally you should just output both parser.add_argument('--prefix', type=str, default="", help="Tree prefix. Example: tagsDumper/trees/", required=False) parser.add_argument("--SB", action="store_true", default=False, help="Plot and analyze signal sidebands", required=False) parser.add_argument("--SR", action="store_true", default=False, help="Plot and analyze signal region", required=False) @@ -54,4 +54,4 @@ def GetOptions(): args = parser.parse_args() - return args + return args diff --git a/NtupleAnalysis/python/VariableTools.py b/NtupleAnalysis/python/VariableTools.py index cc4f9fd..51fd6b5 100644 --- a/NtupleAnalysis/python/VariableTools.py +++ b/NtupleAnalysis/python/VariableTools.py @@ -5,12 +5,12 @@ # The purpose of this module is to define variable related objects ########################################################################################################################### -import numpy as np +import numpy as np -##-- Get variables to plot based on user input variable batch name +##-- Get variables to plot based on user input variable batch name def GetVars(VarBatch): - ##-- Definitions of some special variables, created from existing branch values + ##-- Definitions of some special variables, created from existing branch values mjj = "sqrt(2*goodJets_0_pt*goodJets_1_pt*(cosh(goodJets_0_eta-goodJets_1_eta)-cos(goodJets_0_phi-goodJets_1_phi)))" e_mT = "sqrt(2*goodElectrons_0_pt*MET_pt*(1-cos(goodElectrons_0_phi-MET_phi)))" mu_mT = "sqrt(2*goodMuons_0_pt*MET_pt*(1-cos(goodMuons_0_phi-MET_phi)))" @@ -20,18 +20,30 @@ def GetVars(VarBatch): Scaled_Leading_Photon_pt = "(Leading_Photon_pt / CMS_hgg_mass)" Scaled_Subleading_Photon_pt = "(Subleading_Photon_pt / CMS_hgg_mass)" Scaled_Leading_Photon_E = "(Leading_Photon_E / CMS_hgg_mass)" - Scaled_Subleading_Photon_E = "(Subleading_Photon_E / CMS_hgg_mass)" + Scaled_Subleading_Photon_E = "(Subleading_Photon_E / CMS_hgg_mass)" Leading_Jet_bscore = "(goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" Subleading_Jet_bscore = "(goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading2_Jet_bscore = "(goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading3_Jet_bscore = "(goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading4_Jet_bscore = "(goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" ##-- Variable batch definitions - # Just diphoton mass - # make dictionary + # Just diphoton mass + # make dictionary if(VarBatch == "mass"): return ["CMS_hgg_mass"] elif(VarBatch == "DNN"): - return ["evalDNN_HH"] + return ["evalDNN"] + elif(VarBatch == "FHDNN"): + TrainingVars = [ + "evalDNN_WWvsAll", + "evalDNN_BBvsAll", + "CMS_hgg_mass", + "PhotonID_min", + "PhotonID_max" + ] + return TrainingVars elif(VarBatch == "Jet"): return ["Leading_Jet_pt","Leading_Jet_E","Leading_Jet_eta","N_goodJets"] @@ -48,7 +60,7 @@ def GetVars(VarBatch): elif(VarBatch == "TrainingVariables"): TrainingVars = [ "evalDNN_HH", - "METCor_phi", # just to check + "METCor_phi", # just to check # "evalDNN", Scaled_Leading_Photon_pt, "goodJets_0_pt", @@ -77,9 +89,9 @@ def GetVars(VarBatch): "Subleading_Photon_MVA", "goodJets_0_eta", "Leading_Photon_eta", - "Wmt_L" + "Wmt_L" ] - return TrainingVars + return TrainingVars # elif(VarBatch == "RestOfTrainingVars"): # RestOfTrainingVars = [ @@ -100,25 +112,229 @@ def GetVars(VarBatch): # "Subleading_Photon_MVA", # "goodJets_0_eta", # "Leading_Photon_eta", - # "Wmt_L" + # "Wmt_L" # ] # return RestOfTrainingVars - # Some potentially useful MVA variables + # Some potentially useful MVA variables + elif(VarBatch == "ThreeTopVar_FH"): + TrainingVars = [ + # "New_DR_gg", + # Scaled_Leading_Photon_pt, + # "New_pTBasedSel_WW_pT", + "New_DPhi_gg", + "New_SumTwoMaxBScore", + "New_pTBasedSel_a_costheta2", + "CMS_hgg_mass", + "evalDNN_WWvsAll" + ] + return TrainingVars + elif(VarBatch == "FH_DNN_TrainingVars"): + TrainingVars = [ + "evalDNN_WWvsAll", + "CMS_hgg_mass", + Scaled_Leading_Photon_pt, + Scaled_Subleading_Photon_pt, + Scaled_Leading_Photon_E, + Scaled_Subleading_Photon_E, + "Leading_Photon_eta", + "Leading_Photon_phi", + "Subleading_Photon_eta", + "Subleading_Photon_phi", + + "New_DPhi_gg", + "New_DR_gg", + "PhotonID_min", + "PhotonID_max", + + "N_goodJets", + "New_SumTwoMaxBScore", + + "goodJets_0_pt", + "goodJets_0_eta", + "goodJets_0_phi", + "goodJets_0_E", + "goodJets_1_pt", + "goodJets_1_eta", + "goodJets_1_phi", + "goodJets_1_E", + + "goodJets_2_pt", + "goodJets_2_eta", + "goodJets_2_phi", + "goodJets_2_E", + "goodJets_3_pt", + "goodJets_3_eta", + "goodJets_3_phi", + "goodJets_3_E", + "goodJets_4_pt", + "goodJets_4_eta", + "goodJets_4_phi", + "goodJets_4_E", + + Leading_Jet_bscore, + Subleading_Jet_bscore, + Subleading2_Jet_bscore, + Subleading3_Jet_bscore, + Subleading4_Jet_bscore, + + "New_pTBasedSel_minDeltaR_gg4j", + "New_pTBasedSel_maxDeltaR_gg4j", + "New_pTBasedSel_minDeltaR_4j", + "New_pTBasedSel_maxDeltaR_4j", + + "New_pTBasedSel_DPhi_HH", + "New_pTBasedSel_DR_HH", + + "New_pTBasedSel_a_costheta1", + "New_pTBasedSel_a_costheta2", + "New_pTBasedSel_a_costhetastar", + "New_pTBasedSel_a_Phi", + "New_pTBasedSel_a_Phi1", + "New_pTBasedSel_HelicityCostheta1", + "New_pTBasedSel_HelicityCostheta2", + + "New_pTBasedSel_W1_pT", + "New_pTBasedSel_W1_eta", + "New_pTBasedSel_W1_mass", + + "New_pTBasedSel_W2_pT", + "New_pTBasedSel_W2_eta", + "New_pTBasedSel_W2_mass", + + "New_pTBasedSel_WW_pT", + "New_pTBasedSel_WW_eta", + "New_pTBasedSel_WW_mass" + ] + return TrainingVars + elif(VarBatch == "FH_DNN"): + L2vars = [ + "evalDNN_WWvsAll", + "CMS_hgg_mass", + Scaled_Leading_Photon_E, + Scaled_Subleading_Photon_E, + "Leading_Photon_MVA", + "Subleading_Photon_MVA", + "Leading_Photon_SC_eta", + "Leading_Photon_r9", + "Leading_Photon_passElectronVeto", + "Leading_Photon_hasPixelSeed", + "Subleading_Photon_r9", + "Subleading_Photon_passElectronVeto" + "Subleading_Photon_hasPixelSeed", + "Leading_Photon_E", + "Leading_Photon_pt", + "Leading_Photon_eta", + "Leading_Photon_phi", + "Subleading_Photon_E", + "Subleading_Photon_pt", + "Subleading_Photon_eta", + "Subleading_Photon_phi", + "PhotonID_min", + "PhotonID_max", + "N_goodJets", + "New_Leading_Jet_E", + "New_Leading_Jet_pt", + "New_Leading_Jet_px", + "New_Leading_Jet_py", + "New_Leading_Jet_pz", + "New_Leading_Jet_eta", + "New_Leading_Jet_phi", + "New_Subleading_Jet_E", + "New_Subleading_Jet_pt", + "New_Subleading_Jet_px", + "New_Subleading_Jet_py", + "New_Subleading_Jet_pz", + "New_Subleading_Jet_eta", + "New_Subleading_Jet_phi", + "New_Sub2leading_Jet_E", + "New_Sub2leading_Jet_pt", + "New_Sub2leading_Jet_px", + "New_Sub2leading_Jet_py", + "New_Sub2leading_Jet_pz", + "New_Sub2leading_Jet_eta", + "New_Sub2leading_Jet_phi", + "New_Sub3leading_Jet_E", + "New_Sub3leading_Jet_pt", + "New_Sub3leading_Jet_px", + "New_Sub3leading_Jet_py", + "New_Sub3leading_Jet_pz", + "New_Sub3leading_Jet_eta", + "New_Sub3leading_Jet_phi", + "New_OnShellW_LeadingJet_bDis", + "New_OnShellW_SubLeadingJet_bDis", + "New_OffShellW_LeadingJet_bDis", + "New_OffShellW_SubLeadingJet_bDis", + "New_OnShellW_E", + "New_OnShellW_Mass", + "New_OnShellW_pt", + "New_OnShellW_px", + "New_OnShellW_py", + "New_OnShellW_pz", + "New_OnShellW_eta", + "New_OnShellW_phi", + "New_OffShellW_E", + "New_OffShellW_Mass", + "New_OffShellW_pt", + "New_OffShellW_px", + "New_OffShellW_py", + "New_OffShellW_pz", + "New_OffShellW_eta", + "New_OffShellW_phi", + "New_HWW_E", + "New_HWW_Mass", + "New_HWW_pt", + "New_HWW_px", + "New_HWW_py", + "New_HWW_pz", + "New_HWW_eta", + "New_HWW_phi", + "HGGCandidate_pt", "HGGCandidate_eta", "HGGCandidate_phi", + "New_dR_Hgg_Jet1", + "New_dR_Hgg_Jet2", + "New_dR_Hgg_Jet3", + "New_dR_Hgg_Jet4", + "New_dPhi_Hgg_Jet1", + "New_dPhi_Hgg_Jet2", + "New_dPhi_Hgg_Jet3", + "New_dPhi_Hgg_Jet4", + "New_DPhi_gg", + "New_DR_gg", + "New_DPhi_HH", + "New_DR_HH", + "New_minDeltaR_gg4j", + "New_maxDeltaR_gg4j", + "New_minDeltaR_4j", + "New_maxDeltaR_4j", + "a_costheta1", + "a_costheta2", + "a_costhetastar", + "a_Phi", + "a_Phi1", + "CosThetaStar_CS", + "CosThetaStar_CS_old", + "HelicityCostheta1", + "HelicityCostheta2", + "MET_pt","MET_phi" + ] + return L2vars + + # Some potentially useful MVA variables elif(VarBatch == "MVA"): L2vars = [ - "CMS_hgg_mass","Leading_Photon_pt","Subleading_Photon_pt", - "Leading_Photon_MVA","Subleading_Photon_MVA", + "CMS_hgg_mass", + "Leading_Photon_pt","Leading_Photon_eta","Leading_Photon_E","Leading_Photon_MVA", + "Subleading_Photon_pt","Subleading_Photon_eta","Subleading_Photon_E","Subleading_Photon_MVA", "N_allElectrons","N_allMuons","N_allJets", "N_goodElectrons","N_goodMuons","N_goodJets", "goodElectrons_0_pt","goodMuons_0_pt", "goodJets_0_pt","goodJets_1_pt", "MET_pt" - ] + ] return L2vars - # More possible MVA variables + # More possible MVA variables elif(VarBatch == "MVA2"): L2vars = [ "Leading_Photon_eta", "Leading_Photon_phi", @@ -128,30 +344,30 @@ def GetVars(VarBatch): "goodJets_0_eta", "goodJets_0_phi", "goodJets_0_E", "goodJets_1_eta", "goodJets_1_phi", "goodJets_1_E", "MET_phi" - ] - return L2vars + ] + return L2vars - # MET variables + # MET variables elif(VarBatch == "MET"): METvars = [ "MET_pt","MET_phi" ] return METvars - # Photon variables + # Photon variables elif(VarBatch == "Photon"): PhotonVars = [ "Leading_Photon_pt","Leading_Photon_eta","Leading_Photon_E","Leading_Photon_MVA", "Subleading_Photon_pt","Subleading_Photon_eta","Subleading_Photon_E","Subleading_Photon_MVA" ] - return PhotonVars + return PhotonVars - # Photon variables + # Photon variables elif(VarBatch == "LeadingPhoton"): PhotonVars = [ "Leading_Photon_pt","Leading_Photon_eta","Leading_Photon_E","Leading_Photon_MVA" ] - return PhotonVars + return PhotonVars elif(VarBatch =="bScores"): bScores = [] @@ -160,15 +376,15 @@ def GetVars(VarBatch): # bScores.append(scoresum) for score in scores: bScores.append("goodJets_0_%s"%(score)) - return bScores + return bScores # Variables that should be combined with Loose cuts. Plots kinematics of leading lepton (which changes event by event) elif(VarBatch == "Loose"): - LooseVars = [] + LooseVars = [] LooseVarsNames = [] kinVars = ["pt","eta","E"] maxObjects = 5 - lepton_pt_cut = 10 + lepton_pt_cut = 10 for kinVar in kinVars: LooseGoodLepton_var = "" for i in range(0,maxObjects): @@ -180,24 +396,24 @@ def GetVars(VarBatch): if(i != maxObjects-1): LooseGoodLepton_var += " + " LooseVars.append(LooseGoodLepton_var) LooseVarsNames.append("Loose-Good_Lepton_%s"%(kinVar)) - return LooseVars,LooseVarsNames + return LooseVars,LooseVarsNames - # All known tree variables. This is a LOT + # All known tree variables. This is a LOT elif(VarBatch == "all"): finalStateVars_ = [] - ##-- Add lepton, jet variables + ##-- Add lepton, jet variables # p4_variables = ["E","pt","px","py","pz","eta","phi"] p4_variables = ["E","pt","eta","phi"] checkN = 3 - objectVectors = [] + objectVectors = [] objs = ["Electrons","Muons","Jets"] vecTypes = ["all","good"] for t in vecTypes: for o in objs: objVec = "%s%s"%(t,o) - objectVectors.append(objVec) + objectVectors.append(objVec) for objV in objectVectors: - vtitle = "N_%s"%(objV) + vtitle = "N_%s"%(objV) entry = "%s"%(vtitle) finalStateVars_.append(entry) for v in p4_variables: @@ -221,12 +437,12 @@ def GetVars(VarBatch): for i in range(checkN): vtitle = "%s_%s_%s"%(objV,i,mVarTitle) entry = "%s"%(vtitle) - finalStateVars_.append(entry) + finalStateVars_.append(entry) if("Jets" in objV): bscores = ["bDiscriminator('mini_pfDeepFlavourJetTags:probb')","bDiscriminator('pfDeepCSVJetTags:probb')", "bDiscriminator('mini_pfDeepFlavourJetTags:probbb')","bDiscriminator('pfDeepCSVJetTags:probbb')"] - + btitles = ["bDiscriminator_mini_pfDeepFlavourJetTags_probb","bDiscriminator_pfDeepCSVJetTags_probb", "bDiscriminator_mini_pfDeepFlavourJetTags_probbb","bDiscriminator_pfDeepCSVJetTags_probbb" ] @@ -235,116 +451,134 @@ def GetVars(VarBatch): for i in range(checkN): vtitle = "%s_%s_%s"%(objV,i,btitle) entry = "%s"%(vtitle) - finalStateVars_.append(entry) + finalStateVars_.append(entry) # finalStateVars_.append("Leading_Photon_genMatchType") # finalStateVars_.append("Subleading_Photon_genMatchType") - ##-- Add photon variables + ##-- Add photon variables objects = ["Leading_Photon","Subleading_Photon","MET"] finalStateVars_.append("Leading_Photon_MVA") finalStateVars_.append("Subleading_Photon_MVA") for obj in objects: for var in p4_variables: vtitle = "%s_%s"%(obj,var) - finalStateVars_.append(vtitle) - - return finalStateVars_ + finalStateVars_.append(vtitle) - # Just dR between two leading jets + return finalStateVars_ + + # Just dR between two leading jets elif(VarBatch == "special"): return [dr_jj] -##-- Get bins for a variable +##-- Get bins for a variable def GetBins(variable_,DNNbinWidth_): # def GetBins(variable_,DNNbinWidth_ = 0.1): # evalDNNmin, evalDNNmax = 0, 1.00001 # evalDNNmin, evalDNNmax = 0.9, 1.00001 # evalDNNmin, evalDNNmax = 0, 1.00001 - evalDNNmin, evalDNNmax = 0, 1 + evalDNNmin, evalDNNmax = 0.1, 1 nDNNbins = int(float((evalDNNmax - evalDNNmin)) / float(DNNbinWidth_)) if(DNNbinWidth_ != 0.1): print"nDNNbins: ",nDNNbins - # Specify bins for specific variables - nbins_glob = 20 + # Specify bins for specific variables binDict = { - - "Leading_Photon_MVA": [nbins_glob,-1,1], - "Subleading_Photon_MVA": [nbins_glob,-1,1], - "CMS_hgg_mass": [nbins_glob,100,180], - "weight":[nbins_glob,-10,10], - "puweight":[nbins_glob,-2,2], - "mjj" : [nbins_glob,0,300], - "e_mT" : [nbins_glob,0,300], - "mu_mT" : [nbins_glob,0,300], - "dr_gg" : [nbins_glob,0,3], - "dr_jj" : [nbins_glob,0,3], - "pT_gg" : [nbins_glob,0,400], - - "goodJets_0_pt" : [nbins_glob,0,500], - "METCor_phi" : [nbins_glob, -3.15, 3.15], - "goodLepton_pt" : [nbins_glob,0,360], - "Wmass_goodJets12": [nbins_glob,0,750], + "Leading_Photon_MVA": [20,-1,1], + "Subleading_Photon_MVA": [20,-1,1], + "CMS_hgg_mass": [16,100,180], + "weight":[1000,-10,10], + "puweight":[1000,-2,2], + "mjj" : [100,0,300], + "e_mT" : [100,0,300], + "mu_mT" : [100,0,300], + "dr_gg" : [60,0,3], + "dr_jj" : [60,0,3], + "pT_gg" : [40,0,400], + + "N_goodJets": [10, 4, 14], + "goodJets_0_pt" : [18,0,360], + "goodLepton_pt" : [18,0,360], + "Wmass_goodJets12": [25,0,500], # "Subleading_Photon_pt/CMS_hgg_mass", - "goodJets_1_E": [nbins_glob,0,360], - "goodJets_1_pt": [nbins_glob,0,360], - "goodLepton_E": [nbins_glob,0,360], - "METCor_pt": [nbins_glob,0,400], - "goodJets_0_E": [nbins_glob,0,360], - "Scaled_Leading_Photon_pt" : [nbins_glob,0,3], - "Scaled_Subleading_Photon_pt" : [nbins_glob,0,1.5], - "Scaled_Leading_Photon_E" : [nbins_glob,0,3], - "Scaled_Subleading_Photon_E" : [nbins_glob,0,1.5], - "Leading_Jet_bscore" : [nbins_glob,0,1], - "Subleading_Jet_bscore" : [nbins_glob,0,1], - "Wmt_L" : [nbins_glob,0,300], - - ##-- Custom binnings - # "Leading_Photon_MVA": [20,-1,1], - # "Subleading_Photon_MVA": [20,-1,1], - # "CMS_hgg_mass": [30,100,180], - # "weight":[1000,-10,10], - # "puweight":[1000,-2,2], - # "mjj" : [100,0,300], - # "e_mT" : [100,0,300], - # "mu_mT" : [100,0,300], - # "dr_gg" : [60,0,3], - # "dr_jj" : [60,0,3], - # "pT_gg" : [40,0,400], - - # "goodJets_0_pt" : [18,0,360], - # "goodLepton_pt" : [18,0,360], - # "Wmass_goodJets12": [25,0,500], - # # "Subleading_Photon_pt/CMS_hgg_mass", - # "goodJets_1_E": [18,0,360], - # "goodJets_1_pt": [18,0,360], - # "goodLepton_E": [18,0,360], - # "METCor_pt": [40,0,400], - # "goodJets_0_E": [18,0,360], - # "Scaled_Leading_Photon_pt" : [30,0,3], - # "Scaled_Subleading_Photon_pt" : [15,0,1.5], - # "Scaled_Leading_Photon_E" : [30,0,3], - # "Scaled_Subleading_Photon_E" : [15,0,1.5], - # "Leading_Jet_bscore" : [50,0,1], - # "Subleading_Jet_bscore" : [50,0,1], - # "Wmt_L" : [30,0,300], - - - # "evalDNN" : [20,0,1.00001] # To include value == 1 - # "evalDNN" : [10,0,1.00001] # To include value == 1 - # "evalDNN" : [25,0,1.00001] # To include value == 1 - # "evalDNN" : [100,0,1.00001] # To include value == 1 - "evalDNN" : [nDNNbins,evalDNNmin,evalDNNmax], # To include value == 1 - "evalDNN_HH" : [nDNNbins,evalDNNmin,evalDNNmax], # To include value == 1 - "Subleading_Photon_pt" : [24,0,120] - # "evalDNN" : [10,0,1] # To include value == 1 - } - specialVars = ["Subleading_Photon_pt","Leading_Photon_MVA","Subleading_Photon_MVA","CMS_hgg_mass","weight","puweight","mjj","e_mT","mu_mT","dr_gg","dr_jj","pT_gg","evalDNN", "evalDNN_HH", - "goodJets_0_pt", "goodLepton_pt", "Wmass_goodJets12", "goodJets_1_E", "goodJets_1_pt", "goodLepton_E", "METCor_pt", "goodJets_0_E", "Scaled_Leading_Photon_pt", "Scaled_Subleading_Photon_pt", - "Leading_Jet_bscore", "Subleading_Jet_bscore", "Scaled_Leading_Photon_E", "Scaled_Subleading_Photon_E", "Wmt_L", "METCor_phi" - + "goodJets_1_E": [18,0,360], + "goodJets_1_pt": [18,0,360], + "goodJets_2_pt": [25,0,200], + "goodJets_3_pt": [25,0,200], + "goodJets_4_pt": [25,0,150], + "goodJets_3_E": [21,0,300], + "goodJets_4_E": [21,0,300], + "goodLepton_E": [18,0,360], + "METCor_pt": [40,0,400], + "goodJets_0_E": [18,0,360], + "Scaled_Leading_Photon_pt" : [30,0,3], + "Scaled_Subleading_Photon_pt" : [15,0,1.5], + "Scaled_Leading_Photon_E" : [30,0,3], + "Scaled_Subleading_Photon_E" : [15,0,1.5], + "Leading_Jet_bscore" : [11,0,1], + "Subleading_Jet_bscore" : [11,0,1], + "Subleading2_Jet_bscore" : [11,0,1], + "Subleading3_Jet_bscore" : [11,0,1], + "Subleading4_Jet_bscore" : [11,0,1], + "Wmt_L" : [30,0,300], + # "evalDNN" : [20,0,1.00001] # To include value == 1 + # "evalDNN" : [10,0,1.00001] # To include value == 1 + # "evalDNN" : [25,0,1.00001] # To include value == 1 + # "evalDNN" : [100,0,1.00001] # To include value == 1 + # "evalDNN_WWvsAll" : [nDNNbins,evalDNNmin,evalDNNmax], # To include value == 1 + "evalDNN_WWvsAll" : [20,0.1,1.0], # To include value == 1 + # "evalDNN_WWvsAll" : [10,0.974285714286,1.0], # To include value == 1 # Cat 0 + # "evalDNN_WWvsAll" : [5,0.961428571429,0.974285714286], # To include value == 1 # Cat 1 + # "evalDNN_WWvsAll" : [10,0.807142857143,0.961428571429], # To include value == 1 # Cat 2 + # "evalDNN_WWvsAll" : [10,0.807142857143,1.0], # To include value == 1 # Cat 012 + "evalDNN_BBvsAll" : [nDNNbins,evalDNNmin,evalDNNmax], # To include value == 1 + "Subleading_Photon_pt" : [24,0,120], + # "evalDNN" : [10,0,1] # To include value == 1 + "HWWCandidate_M" : [25,50,1000], + "HGGCandidate_pt": [25,100,500], + "PhotonID_min": [10,-1,1], + "PhotonID_max": [10,-1,1], + "a_costheta1": [10,-1,1], + "a_costheta2": [10,-1,1], + "CosThetaStar_CS": [10, -1, 1], + "CosThetaStar_CS_old": [10, -1, 1], + "HelicityCostheta1": [10, -1, 1], + "HelicityCostheta2": [10, -1, 1], + "a_costhetastar": [10,-1,1], + "a_Phi": [10,-1,1], + "a_Phi1": [10,-1,1], + "W2Candidate_M": [25,0,300], + "W2Candidate_pt": [25,0,400], + "New_DPhi_gg": [20,-3.14,3.11], + "New_DR_gg": [10,0,4], + "New_DPhi_HH": [20,-3.14,3.14], + "New_DR_HH": [20,0,6], + "New_HWW_E": [50, 80, 1000], + "New_HWW_Mass": [50, 80, 1000], + "New_OnShellW_E": [50, 0, 700], + "New_OnShellW_Mass": [50, 0, 200], + } + specialVars = ["Subleading_Photon_pt","Leading_Photon_MVA","Subleading_Photon_MVA","CMS_hgg_mass","weight","puweight","mjj","e_mT","mu_mT","dr_gg","dr_jj","pT_gg","evalDNN", + "N_goodJets", + "goodJets_0_pt", "goodLepton_pt", "Wmass_goodJets12", "goodJets_1_E", "goodJets_1_pt", "goodLepton_E", "METCor_pt", "goodJets_0_E", + "goodJets_2_pt","goodJets_3_pt","goodJets_4_pt","goodJets_3_E","goodJets_4_E", + "Scaled_Leading_Photon_pt", "Scaled_Subleading_Photon_pt", + "Leading_Jet_bscore", "Subleading_Jet_bscore", "Subleading2_Jet_bscore", "Subleading3_Jet_bscore","Subleading4_Jet_bscore", + "Scaled_Leading_Photon_E", "Scaled_Subleading_Photon_E", "Wmt_L","HWWCandidate_M", "HGGCandidate_pt", + "PhotonID_min", "PhotonID_max", + "a_costheta1", "a_costheta2", "a_Phi", "a_Phi1", + "a_costhetastar", "W2Candidate_M", "W2Candidate_pt", + "New_DPhi_gg", "New_DR_gg", + "New_DPhi_HH", "New_DR_HH", + "CosThetaStar_CS", + "CosThetaStar_CS_old", + "HelicityCostheta1", + "HelicityCostheta2", + "New_HWW_E", + "New_HWW_Mass", + "New_OnShellW_E", + "New_OnShellW_Mass", "evalDNN_WWvsAll", "evalDNN_BBvsAll" ] scores = ['bDiscriminator_mini_pfDeepFlavourJetTags_probb','bDiscriminator_mini_pfDeepFlavourJetTags_probbb','bDiscriminator_mini_pfDeepFlavourJetTags_problepb'] @@ -357,20 +591,36 @@ def GetBins(variable_,DNNbinWidth_): elif "N_" in variable_: return [10,0,10] - # Specified binning if variable has phi, eta or pt in name + # Specified binning if variable has phi, eta or pt in name else: # if("phi" in variable_): return [20,-3.14,3.14] - if("phi" in variable_): return [nbins_glob,-3.14,3.15] + if("Costheta" in variable_): return [14,-1.,1.] + if("costheta" in variable_): return [14,-1.,1.] + if("phi" in variable_): return [14,-3.14,3.15] + if("Phi" in variable_): return [14,-3.14,3.15] # elif("eta" in variable_): return [16,-4,4] - elif("eta" in variable_): return [nbins_glob,-2.5,2.5] - elif ("pt" in variable_): return [nbins_glob,0,200] - elif("bDiscriminator" in variable_): return [nbins_glob,0,1] - else: return [nbins_glob,0,300] # if variable name meets none of the above conditions, default to this binning - -##-- Get x axis title for ratio plot depending on the variable + elif("eta" in variable_): return [10,-2.5,2.5] + elif ("pt" in variable_): return [30,0,400] + elif ("_M" in variable_): return [55,0,200] + elif ("WW_mass" in variable_): return [55,50,1200] + elif ("DPhi" in variable_): return [10,-3.14,3.14] + elif ("_dR_" in variable_): return [10,0,10] + elif ("_DR_" in variable_): return [10,0,10] + elif ("DeltaR" in variable_): return [10,0,10] + elif ("_r9" in variable_): return [10,0,1.0] + elif("bDiscriminator" in variable_): return [20,0,1] + elif("BScore" in variable_): return [20,0,1] + elif("bscore" in variable_): return [20,0,1] + elif("bDis" in variable_): return [20,0,1] + elif("dPhi_" in variable_): return [10,0,5] + elif("hasPixelSeed" in variable_): return [2,0,2] + elif("passElectron" in variable_): return [2,0,2] + else: return [30,0,300] # if variable name meets none of the above conditions, default to this binning + +##-- Get x axis title for ratio plot depending on the variable def GetXaxisTitle(variable_): - xAxisTitle = "" - variableName = variable_ + xAxisTitle = "" + variableName = variable_ variableUnit = "" variableUnitDict = { @@ -387,34 +637,62 @@ def GetXaxisTitle(variable_): "mu_mT" : "GeV", "dr_gg" : "rad", "dr_jj" : "rad", + "New_DR_gg": "rad", "pT_gg" : "GeV", "DeepJetScore" : "unitless", "evalDNN" : "unitless", "evalDNN_HH" : "unitless", "Scaled_Leading_Photon_pt" : "unitless", "Scaled_Subleading_Photon_pt" : "unitless", - "Leading_Jet_bscore" : "unitless", + "Leading_Jet_bscore" : "unitless", "Subleading_Jet_bscore" : "unitless", + "Subleading2_Jet_bscore" : "unitless", + "Subleading3_Jet_bscore" : "unitless", + "Subleading4_Jet_bscore" : "unitless", "Scaled_Leading_Photon_E" : "unitless", "Scaled_Subleading_Photon_E" : "unitless", - "Wmt_L" : "GeV" + "Wmt_L" : "GeV", + "New_pTBasedSel_WW_pT": "GeV", + "New_DPhi_gg":"unitless", + "New_SumTwoMaxBScore":"unitless", + "New_pTBasedSel_a_costheta2":"unitless" } + variableName_Rep = { + "New_DR_gg": "#Delta R(#gamma #gamma)", + "Scaled_Leading_Photon_pt": "p_{T}(#gamma #gamma)/M_{#gamma #gamma}", + "New_pTBasedSel_WW_pT": "p_{T}(WW)", + "evalDNN_WWvsAll": "DNN Score", + "CMS_hgg_mass": "M_{#gamma #gamma}", + "New_DPhi_gg":"#Delta #phi(#gamma #gamma)", + "New_SumTwoMaxBScore":"Sum of two highest b-jet score", + "New_pTBasedSel_a_costheta2":"cos(#theta_{2})" + } + + for varRep in variableName_Rep: + print "===> ",varRep, variableName + if varRep in variableName: + XAxisTitle_ = variableName_Rep[varRep] + break + else: + XAxisTitle_ = variableName for varFrag in variableUnitDict: varUnit = variableUnitDict[varFrag] if varFrag in variableName: variableUnit = varUnit - xAxisTitle = "%s [%s]"%(variableName,variableUnit) - return xAxisTitle + xAxisTitle = "%s [%s]"%(XAxisTitle_,variableUnit) + if variableUnit == "unitless": + xAxisTitle = "%s "%(XAxisTitle_) + return xAxisTitle -##-- Get the name of variable. Useful for variables that have long strings in draw statement. This returns a shortened value to be used for plot title and output file name +##-- Get the name of variable. Useful for variables that have long strings in draw statement. This returns a shortened value to be used for plot title and output file name def GetVarTitle(varName): varTitle = "" scores = ['bDiscriminator_mini_pfDeepFlavourJetTags_probb','bDiscriminator_mini_pfDeepFlavourJetTags_probbb','bDiscriminator_mini_pfDeepFlavourJetTags_problepb'] - # scoresum = "(goodJets_0_%s + goodJets_0_%s + goodJets_0_%s)"%(scores[0],scores[1],scores[2]) + # scoresum = "(goodJets_0_%s + goodJets_0_%s + goodJets_0_%s)"%(scores[0],scores[1],scores[2]) mjj = "sqrt(2*goodJets_0_pt*goodJets_1_pt*(cosh(goodJets_0_eta-goodJets_1_eta)-cos(goodJets_0_phi-goodJets_1_phi)))" e_mT = "sqrt(2*goodElectrons_0_pt*MET_pt*(1-cos(goodElectrons_0_phi-MET_phi)))" - mu_mT = "sqrt(2*goodMuons_0_pt*MET_pt*(1-cos(goodMuons_0_phi-MET_phi)))" + mu_mT = "sqrt(2*goodMuons_0_pt*MET_pt*(1-cos(goodMuons_0_phi-MET_phi)))" dr_gg = "sqrt( fabs(Leading_Photon_eta - Subleading_Photon_eta)**2 + fabs( Leading_Photon_phi - Subleading_Photon_phi )**2 )" dr_jj = "sqrt( fabs(allJets_0_eta - allJets_1_eta)**2 + fabs( allJets_0_phi - allJets_1_phi )**2 )" pT_gg = "Leading_Photon_pt + Subleading_Photon_pt" @@ -424,11 +702,16 @@ def GetVarTitle(varName): Scaled_Subleading_Photon_E = "(Subleading_Photon_E / CMS_hgg_mass)" Leading_Jet_bscore = "(goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_0_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" Subleading_Jet_bscore = "(goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_1_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading2_Jet_bscore = "(goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_2_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading3_Jet_bscore = "(goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_3_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" + Subleading4_Jet_bscore = "(goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_probb + goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_probbb + goodJets_4_bDiscriminator_mini_pfDeepFlavourJetTags_problepb)" if(varName == mjj): varTitle = "mjj" elif(varName == e_mT): varTitle = "e_mT" elif(varName == mu_mT): varTitle = "mu_mT" elif(varName == dr_gg): varTitle = "dr_gg" + # elif(varName == "New_DR_gg"): varTitle = "#Delta R(#gamma #gamma)" + elif(varName == "New_DR_gg"): varTitle = "New_DR_gg" elif(varName == dr_jj): varTitle = "dr_jj" elif(varName == pT_gg): varTitle = "pT_gg" # elif(varName == scoresum): varTitle = "DeepJetScore" @@ -438,25 +721,29 @@ def GetVarTitle(varName): elif(varName == Scaled_Subleading_Photon_E): varTitle = "Scaled_Subleading_Photon_E" elif(varName == Leading_Jet_bscore) : varTitle = "Leading_Jet_bscore" elif(varName == Subleading_Jet_bscore): varTitle = "Subleading_Jet_bscore" - else: varTitle = varName - return varTitle - -##-- Compute chi squared for a data / mc plot + elif(varName == Subleading2_Jet_bscore): varTitle = "Subleading2_Jet_bscore" + elif(varName == Subleading3_Jet_bscore): varTitle = "Subleading3_Jet_bscore" + elif(varName == Subleading4_Jet_bscore): varTitle = "Subleading4_Jet_bscore" + elif(varName == "New_pTBasedSel_WW_pT"): varTitle = "New_pTBasedSel_WW_pT" + else: varTitle = varName + return varTitle + +##-- Compute chi squared for a data / mc plot def GetChiSquared(DataHist_,stackSum_): - # the two histos should have the same binning + # the two histos should have the same binning Nbins = DataHist_.GetNbinsX() assert(Nbins == stackSum_.GetNbinsX()) chi2_total = 0 - for bin_i in range(1,Nbins): # skip underflow bin + for bin_i in range(1,Nbins): # skip underflow bin data_y, MC_sum_y = DataHist_.GetBinContent(bin_i), stackSum_.GetBinContent(bin_i) chi2_num = pow(abs(float(data_y)-float(MC_sum_y)),2) - # avoid a denominator of 0 - if(data_y == 0.0 and MC_sum_y == 0.0): continue - elif(data_y == 0.0 and MC_sum_y != 0.0): chi2_den = MC_sum_y - else: chi2_den = data_y + # avoid a denominator of 0 + if(data_y == 0.0 and MC_sum_y == 0.0): continue + elif(data_y == 0.0 and MC_sum_y != 0.0): chi2_den = MC_sum_y + else: chi2_den = data_y # print"data_y:",data_y # print"MC_sum_y:",MC_sum_y - chi2 = chi2_num / chi2_den - chi2_total += chi2 - chi2_total /= Nbins - return chi2_total + chi2 = chi2_num / chi2_den + chi2_total += chi2 + chi2_total /= Nbins + return chi2_total