From 81f700f9dbf2a440bc9e5344b9d5965c53f72158 Mon Sep 17 00:00:00 2001 From: "tfarooque@ifae.es" <tfarooque@at306.pic.es> Date: Wed, 28 Dec 2016 16:11:08 +0100 Subject: [PATCH 1/7] Region options in selector --- Root/VLQ_Analysis_Data2015.cxx | 2 +- Root/VLQ_Options.cxx | 5 + Root/VLQ_Selector.cxx | 519 +++++++++++++++++++++------------ VLQAnalysis/VLQ_Options.h | 2 + VLQAnalysis/VLQ_Selector.h | 15 + data/samples_info.dat | 49 ++-- python/ProduceSampleDATfile.py | 2 +- 7 files changed, 383 insertions(+), 211 deletions(-) diff --git a/Root/VLQ_Analysis_Data2015.cxx b/Root/VLQ_Analysis_Data2015.cxx index 38e6734..4ab141a 100644 --- a/Root/VLQ_Analysis_Data2015.cxx +++ b/Root/VLQ_Analysis_Data2015.cxx @@ -853,7 +853,7 @@ bool VLQ_Analysis_Data2015::Process(Long64_t entry) // # //########################################################### //ALERTRISHA - add option for low jet multiplicity regions - if( m_outData -> o_jets_n < 5 || (m_outData-> o_channel_type==VLQ_Enums::FULLHAD && m_outData -> o_jets_n < 6) ){ + if( m_outData -> o_jets_n < 4 || (m_outData-> o_channel_type==VLQ_Enums::FULLHAD && m_outData -> o_jets_n < 6) ){ m_outData -> o_rejectEvent |= 1 << VLQ_Enums::JETS_REJECTED; } if(m_opt -> MsgLevel() == Debug::DEBUG) std::cout << "==> After jets selection" << std::endl; diff --git a/Root/VLQ_Options.cxx b/Root/VLQ_Options.cxx index 0edbe05..177601a 100644 --- a/Root/VLQ_Options.cxx +++ b/Root/VLQ_Options.cxx @@ -56,6 +56,7 @@ m_lepPtCut(28.), m_btagOP("77"), m_TRFCDIPath("xAODBTaggingEfficiency/13TeV/2016-20_7-13TeV-MC15-CDI-July12_v1.root"), m_QCDMode("none"), +m_do_regions(""), m_filterType(NOFILTER) {} @@ -105,6 +106,7 @@ OptionsBase(q) m_btagOP = q.m_btagOP; m_TRFCDIPath = q.m_TRFCDIPath; m_QCDMode = q.m_QCDMode; + m_do_regions = q. m_do_regions; m_maxb = q.m_maxb; m_filterType = q.m_filterType; } @@ -217,6 +219,8 @@ bool VLQ_Options::IdentifyOption ( const std::string &argument, const std::strin m_TRFCDIPath = temp_val; } else if( temp_arg.find("--QCDMODE") != std::string::npos ){ m_QCDMode = temp_val.c_str(); + } else if( temp_arg.find("--DOREGIONS") != std::string::npos ){ + m_do_regions = temp_val.c_str(); } // // Int arguments @@ -265,6 +269,7 @@ void VLQ_Options::PrintOptions(){ std::cout << " m_recomputeTRF = " << m_recomputeTRF << std::endl; std::cout << " m_TRFCDIPath = " << m_TRFCDIPath << std::endl; std::cout << " m_qcdMode = " << m_QCDMode << std::endl; + std::cout << " m_do_regions = " << m_do_regions << std::endl; std::cout << " m_maxb = " << m_maxb << std::endl; std::cout << " m_RCNsubjetsCut = " << m_RCNsubjetsCut << std::endl; std::cout << " m_RCJetsPtCut = " << m_RCJetsPtCut << std::endl; diff --git a/Root/VLQ_Selector.cxx b/Root/VLQ_Selector.cxx index b527cbe..7bfb44b 100644 --- a/Root/VLQ_Selector.cxx +++ b/Root/VLQ_Selector.cxx @@ -1,5 +1,8 @@ #include <iostream> #include <algorithm> +#include <ctype.h> +//#include <locale> +#include "IFAETopFramework/AnalysisUtils.h" #include "IFAETopFramework/OptionsBase.h" #include "IFAETopFramework/OutputHistManager.h" #include "IFAETopFramework/OutputTreeManager.h" @@ -23,6 +26,18 @@ VLQ_Selector::VLQ_Selector( VLQ_Options *opt, const VLQ_NtupleData *ntupData m_outData(outData), m_anaTools(anaTools), m_outMngrHist(0), + m_do_presel(false), + m_do_validn_reg(false), + m_do_fit_reg(false), + m_do_lowb(false), + m_do_split_emu(false), + m_do_lowj(false), + m_do_highj(false), + m_do_old_boost(false), + m_do_new_boost(false), + m_do_merge_boost(false), + m_do_split_mtb(false), + m_do_split_mbb(false), m_sel_indices(NULL), m_sel_names(NULL), m_sel_lep_prop(NULL), @@ -32,8 +47,10 @@ VLQ_Selector::VLQ_Selector( VLQ_Options *opt, const VLQ_NtupleData *ntupData m_sel_M_prop(NULL), m_sel_T_prop(NULL), m_sel_H_prop(NULL), + m_sel_TH_prop(NULL), m_sel_Mbb_prop(NULL), - m_sel_Mtb_prop(NULL)//, + m_sel_Mtb_prop(NULL) + //m_nsel(0) { @@ -49,6 +66,16 @@ SelectorBase(q) m_outData = q.m_outData; m_anaTools = q.m_anaTools; m_outMngrHist = q.m_outMngrHist; + m_do_presel = q.m_do_presel; + m_do_validn_reg = q.m_do_validn_reg; + m_do_fit_reg = q.m_do_fit_reg; + m_do_lowb = q.m_do_lowb; + m_do_split_emu = q.m_do_split_emu; + m_do_lowj = q.m_do_lowj; + m_do_highj = q.m_do_highj; + m_do_old_boost = q.m_do_old_boost; + m_do_new_boost = q.m_do_new_boost; + m_do_merge_boost = q.m_do_merge_boost; m_sel_indices = new std::map<std::string, int>(*(q.m_sel_indices)); m_sel_names = new std::map<int, std::string>(*(q.m_sel_names)); m_sel_lep_prop = new std::vector<SelProp>(*(q.m_sel_lep_prop)); @@ -58,6 +85,7 @@ SelectorBase(q) m_sel_M_prop = new std::vector<SelProp>(*(q.m_sel_M_prop)); m_sel_T_prop = new std::vector<SelProp>(*(q.m_sel_T_prop)); m_sel_H_prop = new std::vector<SelProp>(*(q.m_sel_H_prop)); + m_sel_TH_prop = new std::vector<SelProp>(*(q.m_sel_TH_prop)); m_sel_Mbb_prop = new std::vector<SelProp>(*(q.m_sel_Mbb_prop)); m_sel_Mtb_prop = new std::vector<SelProp>(*(q.m_sel_Mtb_prop)); @@ -74,13 +102,46 @@ VLQ_Selector::~VLQ_Selector(){ // bool VLQ_Selector::Init(){ if(m_opt->MsgLevel() == Debug::DEBUG){ - std::cout<<" Inside VLQ_Selector::Init()"<<std::endl; - } - - //only looking at the very final regions - const bool onlyFinal = m_opt -> OnlyDumpFinalRegions(); + std::cout<<" Inside VLQ_Selector::Init()"<<std::endl; + } - //============================ Initialise top selections ================================== + std::string doRegions = m_opt->DoRegions(); + std::string reg; reg.clear(); + int nreg = 0; + std::string::size_type pos = 0; + do{ + pos = AnalysisUtils::ParseString(doRegions, reg, ","); + AnalysisUtils::TrimString(reg); + if (reg == "PRESEL") m_do_presel = true; + else if(reg == "VALIDATION") m_do_validn_reg = true; + else if(reg == "FIT") m_do_fit_reg = true; + else if(reg == "LOWB") m_do_lowb = true; + else if(reg == "SPLITEMU") m_do_split_emu = true; + else if(reg == "LOWJ") m_do_lowj = true; + else if(reg == "HIGHJ") m_do_highj = true; + else if(reg == "OLDBOOST") m_do_old_boost = true; + else if(reg == "NEWBOOST") m_do_new_boost = true; + else if(reg == "MERGEBOOST") m_do_merge_boost = true; + else{ std::cout<<"VLQ_Selector::Init() -->WARNING: Unknown region option "<<reg<< std::endl; } + }while(pos != std::string::npos); + + std::cout<< " doRegions = "<<m_opt->DoRegions()<<std::endl; + std::cout<< " m_do_presel = "<< m_do_presel << std::endl; + std::cout<< " m_do_validn_reg = "<< m_do_validn_reg << std::endl; + std::cout<< " m_do_fit_reg = "<< m_do_fit_reg << std::endl; + std::cout<< " m_do_lowb = "<< m_do_lowb << std::endl; + std::cout<< " m_do_split_emu = "<< m_do_split_emu << std::endl; + std::cout<< " m_do_lowj = "<< m_do_lowj << std::endl; + std::cout<< " m_do_highj = "<< m_do_highj << std::endl; + std::cout<< " m_do_old_boost = "<< m_do_old_boost << std::endl; + std::cout<< " m_do_new_boost = "<< m_do_new_boost << std::endl; + std::cout<< " m_do_merge_boost = "<< m_do_merge_boost << std::endl; + + + //only looking at the very final regions + //const bool onlyFinal = m_opt -> OnlyDumpFinalRegions(); + + //============================ Initialise top selections and add rules for primary ancestors ================================== m_sel_indices = new std::map<std::string, int>(); m_sel_names = new std::map<int, std::string>(); @@ -114,6 +175,9 @@ bool VLQ_Selector::Init(){ m_sel_H_prop = new std::vector<SelProp>({ MakeSelProp("0Hex",c_0Hex), MakeSelProp("1Hex", c_1Hex), MakeSelProp("2Hin", c_2Hin) }); + m_sel_TH_prop = new std::vector<SelProp>({ + MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("3THin", c_3THin) }); + m_sel_Mbb_prop = new std::vector<SelProp>({ MakeSelProp("LowMbb",c_LowMbb), MakeSelProp("HighMbb", c_HighMbb) }); @@ -128,90 +192,158 @@ bool VLQ_Selector::Init(){ for(auto selprop : *m_sel_M_prop){ AddSelectionIndex(selprop.name, selprop.index); } for(auto selprop : *m_sel_T_prop){ AddSelectionIndex(selprop.name, selprop.index); } for(auto selprop : *m_sel_H_prop){ AddSelectionIndex(selprop.name, selprop.index); } + for(auto selprop : *m_sel_TH_prop){ AddSelectionIndex(selprop.name, selprop.index); } for(auto selprop : *m_sel_Mbb_prop){ AddSelectionIndex(selprop.name, selprop.index); } for(auto selprop : *m_sel_Mtb_prop){ AddSelectionIndex(selprop.name, selprop.index); } if(m_opt->MsgLevel() == Debug::DEBUG){ std::cout<<"Added all top selections "<<std::endl; } //========================== Add desired regions ================================================ - std::vector<std::string> bjet_presellist{"2bin", "2bex", "3bex", "4bin"}; - if(m_opt->DoLowBRegions()){ - bjet_presellist.push_back("0bex"); - bjet_presellist.push_back("1bex"); - } + //======== PRESELECTION========= + if(m_do_presel){ + + std::vector<std::string> v_bjet_presel = {"2bin"}; + if(m_do_lowb){ + v_bjet_presel.push_back("0bex"); + v_bjet_presel.push_back("1bex"); + } - std::vector<std::string> bjet_analist{ "2bex", "3bex", "4bin"}; + if(m_opt->DoOneLeptonAna()){ + std::vector<std::string> v_jet_presel = {"5jin"}; + if(m_do_lowj){ + v_jet_presel.push_back("4jex"); + v_jet_presel.push_back("4jin"); + } + for(const std::string& jet : v_jet_presel){ + for(const std::string& bjet : v_bjet_presel){ + AddVLQSelection("c1lep"+jet+bjet, true, false); + if(m_do_split_emu){ + AddVLQSelection("c1lep"+jet+bjet+"_el", true, false); + AddVLQSelection("c1lep"+jet+bjet+"_mu", true, false); + } + }//bjet + }//jet + }//1-lep + + if(m_opt->DoZeroLeptonAna()){ + std::vector<std::string> v_jet_presel = {"6jin"}; + if(m_do_lowj){ + v_jet_presel.push_back("4jex"); + v_jet_presel.push_back("4jin"); + v_jet_presel.push_back("5jex"); + v_jet_presel.push_back("5jin"); + } + for(const std::string& jet : v_jet_presel){ + for(const std::string& bjet : v_bjet_presel){ + AddVLQSelection("c0lep"+jet+bjet, true, false); + }//bjet + }//jet + }//0-lep + + }//Preselection regions + + if(m_do_fit_reg || m_do_validn_reg){ + std::vector<std::string> bjet_analist{ "2bex", "3bex", "4bin"}; + + std::vector<std::string> boostlist_1L{}; + std::vector<std::string> boostlist_0L{}; + + if(m_do_old_boost){ + std::vector<std::string> boostlist_old = {"2Min", "1Mex", "0Mex"}; + boostlist_1L.insert(boostlist_1L.end(), boostlist_old.begin(), boostlist_old.end()); + boostlist_0L.insert(boostlist_0L.end(), boostlist_old.begin(), boostlist_old.end()); + } + if(m_do_new_boost){ + std::vector<std::string> boostlist_new = { + "2Tin2Hin", "2Tin1Hex", "2Tin0Hex", + "1Tex2Hin", "1Tex1Hex", "1Tex0Hex", + "0Tex2Hin", "0Tex1Hex", "0Tex0Hex", + }; + boostlist_0L.insert(boostlist_0L.end(), boostlist_new.begin(), boostlist_new.end()); + } + if(m_do_merge_boost){ + std::vector<std::string> boostlist_super_merge = { + "3THin", "2THex", "1THex", "0THex" + }; + boostlist_0L.insert(boostlist_0L.end(), boostlist_super_merge.begin(), boostlist_super_merge.end()); - std::vector<std::string> boostlist = { + std::vector<std::string> boostlist_1L_merge = { "2Tin1Hex", "2Tin0Hex", "1Tex1Hex", "1Tex0Hex", "0Tex1Hex", "0Tex0Hex", "0Tin2Hin" }; - //"2Tin2Hin", "2Tin1Hex", "2Tin0Hex", - //"1Tex2Hin", "1Tex1Hex", "1Tex0Hex", - //"0Tex2Hin", "0Tex1Hex", "0Tex0Hex"}; - if(!onlyFinal){ - boostlist.push_back("2Min"); - boostlist.push_back("1Mex"); - boostlist.push_back("0Mex"); - } - - if(m_opt->DoOneLeptonAna()){ - std::vector<std::string> subchanlist = {""}; - if(!onlyFinal){ - subchanlist.push_back("_el"); - subchanlist.push_back("_mu"); - } - std::vector < std::string > vec_jets = {"5jex", "6jin"}; - if(!onlyFinal){ - vec_jets.push_back("5jin"); - vec_jets.push_back("6_8jin"); - vec_jets.push_back("9jin"); - } - for( std::string jet : vec_jets ){ - if(!onlyFinal){ - for( std::string bjet : bjet_presellist ){ - for( std::string subchannel : subchanlist ){ - AddVLQSelection("c1lep"+jet+bjet+subchannel, true, false); - } - } //presel bjet channels - } - for( std::string bjet : bjet_analist ){ - for( std::string boost : boostlist ){ - AddVLQSelection("c1lep"+boost+jet+bjet, true, false); - if(!onlyFinal){ - AddVLQSelection("c1lep"+boost+jet+bjet+"LowMbb", true, false); - AddVLQSelection("c1lep"+boost+jet+bjet+"HighMbb", true, false); - } - } - }//ana bjet channels - }//jet - - }//1-lepton - - if(m_opt->DoZeroLeptonAna()){ - - for( std::string jet : {"6jex", "7jin"} ){ - if(!onlyFinal){ - for( std::string bjet : bjet_presellist ){ - AddVLQSelection("c0lep"+jet+bjet, true, false); - }//presel bjet channels - } - for( std::string bjet : bjet_analist ){ - //Split in boost - for( std::string boost : boostlist ){ - AddVLQSelection("c0lep"+boost+jet+bjet, true, false); - if(!onlyFinal){ - AddVLQSelection("c0lep"+boost+jet+bjet+"LowMtbmin", true, false); - AddVLQSelection("c0lep"+boost+jet+bjet+"HighMtbmin", true, false); - } - } - }//ana bjet channels - }//jet - - }//0-lepton + boostlist_1L.insert(boostlist_1L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); + boostlist_0L.insert(boostlist_0L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); + } + //Remove overlaps between different boost options so that any region is only added once + std::set<std::string> boostset_1L(boostlist_1L.begin(), boostlist_1L.end()); + std::set<std::string> boostset_0L(boostlist_0L.begin(), boostlist_0L.end()); + + if(m_opt->DoZeroLeptonAna()){ + std::vector<std::string> jet_analist_0L{}; + if(m_do_fit_reg){ jet_analist_0L.push_back("7jin"); } + if(m_do_lowj) { + jet_analist_0L.push_back("4jex"); + jet_analist_0L.push_back("5jex"); + } + if(m_do_validn_reg){ jet_analist_0L.push_back("6jex"); } + for( const std::string& jet : jet_analist_0L ){ + for( std::string bjet : bjet_analist ){ + for( std::string boost : boostset_0L ){ + AddVLQSelection("c0lep"+boost+jet+bjet, true, false); + if(m_do_split_mtb){ + AddVLQSelection("c0lep"+boost+jet+bjet+"LowMtbmin", true, false); + AddVLQSelection("c0lep"+boost+jet+bjet+"HighMtbmin", true, false); + }//mbb split + }//boost list + }//ana bjet channels + }//jet + }//0-lepton + + if(m_opt->DoOneLeptonAna()){ + std::vector<std::string> jet_analist_1L{}; + if(m_do_fit_reg){ jet_analist_1L.push_back("6jin"); } + if(m_do_highj) { + jet_analist_1L.push_back("6_8jin"); + jet_analist_1L.push_back("9jin"); + } + if(m_do_lowj) { + jet_analist_1L.push_back("4jex"); + } + if(m_do_validn_reg){ jet_analist_1L.push_back("5jex"); } + + for( const std::string& jet : jet_analist_1L ){ + for( std::string bjet : bjet_analist ){ + for( std::string boost : boostset_1L ){ + AddVLQSelection("c1lep"+boost+jet+bjet, true, false); + //Only do mbb splitting for old mass-tagged jet regions + if(m_do_split_mbb && ( (boost.find("Mex") != std::string::npos) || (boost.find("Min") != std::string::npos) ) ){ + AddVLQSelection("c1lep"+boost+jet+bjet+"LowMbb", true, false); + AddVLQSelection("c1lep"+boost+jet+bjet+"HighMbb", true, false); + }//mbb split + }//boost list + }//ana bjet channels + }//jet + }//1-lepton + + }//Fit/validation regions + + /* + AddVLQSelection("c1lep4jex2bin", true, false); + AddVLQSelection("c1lep4jin2bin", true, false); + AddVLQSelection("c1lep5jin2bin", true, false); + + AddVLQSelection("c1lep4jex2bin_el", true, false); + AddVLQSelection("c1lep4jin2bin_el", true, false); + AddVLQSelection("c1lep5jin2bin_el", true, false); + + AddVLQSelection("c1lep4jex2bin_mu", true, false); + AddVLQSelection("c1lep4jin2bin_mu", true, false); + AddVLQSelection("c1lep5jin2bin_mu", true, false); + */ return true; + } //______________________________________________________________________________ @@ -256,128 +388,148 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) SelProp* sprop_M = NULL; SelProp* sprop_T = NULL; SelProp* sprop_H = NULL; + SelProp* sprop_TH = NULL; SelProp* sprop_Mbb = NULL; SelProp* sprop_Mtb = NULL; //=============== Lepton part ===================== - if(sel_name.find("lep") != std::string::npos){ - for(SelProp lepprop : *m_sel_lep_prop){ - if( sel_name.find(lepprop.name) != std::string::npos ){ - sprop_lep = &lepprop; - break; - } - } - if(sprop_lep == NULL){ - std::cerr << " Cannnot identify lepton channel for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; + if(sel_name.find("lep") != std::string::npos){ + for(SelProp lepprop : *m_sel_lep_prop){ + if( sel_name.find(lepprop.name) != std::string::npos ){ + sprop_lep = &lepprop; + break; + } + } + if(sprop_lep == NULL){ + std::cerr << " Cannnot identify lepton channel for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; } //=============== Jet part ======================== - if( (sel_name.find("jin") != std::string::npos) || (sel_name.find("jex") != std::string::npos) ){ + if( (sel_name.find("jin") != std::string::npos) || (sel_name.find("jex") != std::string::npos) ){ - for(SelProp jetprop : *m_sel_jet_prop){ - if( sel_name.find(jetprop.name) != std::string::npos ){ - sprop_jet = &jetprop; - break; - } - } - if(sprop_jet == NULL){ - std::cerr << " Cannnot identify jet multiplicity requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + for(SelProp jetprop : *m_sel_jet_prop){ + if( sel_name.find(jetprop.name) != std::string::npos ){ + sprop_jet = &jetprop; + break; + } + } + if(sprop_jet == NULL){ + std::cerr << " Cannnot identify jet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //=============== B-jet part ======================== //if(sel_name.find("b") != std::string::npos){ - if( (sel_name.find("bin") != std::string::npos) || (sel_name.find("bex") != std::string::npos) ){ - for(SelProp bjetprop : *m_sel_bjet_prop){ - if( sel_name.find(bjetprop.name) != std::string::npos ){ - sprop_bjet = &bjetprop; - break; - } - } - if(sprop_bjet == NULL){ - std::cerr << " Cannnot identify bjet multiplicity requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + if( (sel_name.find("bin") != std::string::npos) || (sel_name.find("bex") != std::string::npos) ){ + for(SelProp bjetprop : *m_sel_bjet_prop){ + if( sel_name.find(bjetprop.name) != std::string::npos ){ + sprop_bjet = &bjetprop; + break; + } + } + if(sprop_bjet == NULL){ + std::cerr << " Cannnot identify bjet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //============== M-tag part ========================= - if( (sel_name.find("Min") != std::string::npos) || (sel_name.find("Mex") != std::string::npos) ){ - for(SelProp Mprop : *m_sel_M_prop){ - if( sel_name.find(Mprop.name) != std::string::npos ){ - sprop_M = &Mprop; - break; - } - } - if(sprop_M == NULL){ - std::cerr << " Cannnot identify M-tagged jet multiplicity requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + if( (sel_name.find("Min") != std::string::npos) || (sel_name.find("Mex") != std::string::npos) ){ + for(SelProp Mprop : *m_sel_M_prop){ + if( sel_name.find(Mprop.name) != std::string::npos ){ + sprop_M = &Mprop; + break; + } + } + if(sprop_M == NULL){ + std::cerr << " Cannnot identify M-tagged jet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } + //============== TH-tag part ========================= + if( (sel_name.find("THin") != std::string::npos) || (sel_name.find("THex") != std::string::npos) ){ + for(SelProp THprop : *m_sel_TH_prop){ + if( sel_name.find(THprop.name) != std::string::npos ){ + sprop_TH = &THprop; + break; + } + } + if(sprop_TH == NULL){ + std::cerr << " Cannnot identify TH-tagged jet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //============== T-tag part ========================= - if( (sel_name.find("Tin") != std::string::npos) || (sel_name.find("Tex") != std::string::npos) ){ - for(SelProp Tprop : *m_sel_T_prop){ - if( sel_name.find(Tprop.name) != std::string::npos ){ - sprop_T = &Tprop; - break; - } - } - if(sprop_T == NULL){ - std::cerr << " Cannnot identify T-tagged jet multiplicity requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + //Check that the character preceding "T" is a digit + if( ( (sel_name.find("Tin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Tin")-1)[0] )) ) + || ( (sel_name.find("Tex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Tex")-1)[0] )) ) ){ + for(SelProp Tprop : *m_sel_T_prop){ + if( sel_name.find(Tprop.name) != std::string::npos ){ + sprop_T = &Tprop; + break; + } + } + if(sprop_T == NULL){ + std::cerr << " Cannnot identify T-tagged jet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //============== H-tag part ========================= - if( (sel_name.find("Hin") != std::string::npos) || (sel_name.find("Hex") != std::string::npos) ){ - for(SelProp Hprop : *m_sel_H_prop){ - if( sel_name.find(Hprop.name) != std::string::npos ){ - sprop_H = &Hprop; - break; - } - } - if(sprop_H == NULL){ - std::cerr << " Cannnot identify H-tagged jet multiplicity requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + //Check that the character preceding "H" is a digit (to distinguish this option from "TH" + if( ( (sel_name.find("Hin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hin")-1)[0] )) ) + || ( (sel_name.find("Hex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hex")-1)[0] )) ) ){ + for(SelProp Hprop : *m_sel_H_prop){ + if( sel_name.find(Hprop.name) != std::string::npos ){ + sprop_H = &Hprop; + break; + } + } + if(sprop_H == NULL){ + std::cerr << " Cannnot identify H-tagged jet multiplicity requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } + //============== Mbb part ========================= - if(sel_name.find("Mbb") != std::string::npos){ - for(SelProp Mbbprop : *m_sel_Mbb_prop){ - if( sel_name.find(Mbbprop.name) != std::string::npos ){ - sprop_Mbb = &Mbbprop; - break; - } - } - if(sprop_Mbb == NULL){ - std::cerr << " Cannnot identify Mbb requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + if(sel_name.find("Mbb") != std::string::npos){ + for(SelProp Mbbprop : *m_sel_Mbb_prop){ + if( sel_name.find(Mbbprop.name) != std::string::npos ){ + sprop_Mbb = &Mbbprop; + break; + } + } + if(sprop_Mbb == NULL){ + std::cerr << " Cannnot identify Mbb requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //============== Mtb part ========================= - if(sel_name.find("Mtb") != std::string::npos){ - for(SelProp Mtbprop : *m_sel_Mtb_prop){ - if( sel_name.find(Mtbprop.name) != std::string::npos ){ - sprop_Mtb = &Mtbprop; - break; - } - } - if(sprop_Mtb == NULL){ - std::cerr << " Cannnot identify Mtb requirements for selection "<<name<<std::endl; - return NULL; - } - n_nodes++; - } + if(sel_name.find("Mtb") != std::string::npos){ + for(SelProp Mtbprop : *m_sel_Mtb_prop){ + if( sel_name.find(Mtbprop.name) != std::string::npos ){ + sprop_Mtb = &Mtbprop; + break; + } + } + if(sprop_Mtb == NULL){ + std::cerr << " Cannnot identify Mtb requirements for selection "<<name<<std::endl; + return NULL; + } + n_nodes++; + } //============================= Only certain selection patterns are currently allowed ========================= if( (n_nodes > 1) && !sprop_lep ){ //If no lepton channel found for a compound selection @@ -389,7 +541,7 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) return NULL; } - if( !( (sprop_M==NULL) || ( (sprop_T==NULL) && (sprop_H==NULL) ) ) ){ + if( !( (sprop_M==NULL) || ( (sprop_T==NULL) && (sprop_H==NULL) && (sprop_TH==NULL) ) ) ){ std::cerr << " It is inadvisable to apply M-tagged jet cut together "; std::cerr << "with a cut on T-tagging or H-tagging. Please check selection pattern "; std::cerr << name << ". Exiting. "<<std::endl; @@ -409,7 +561,7 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) else if(sel_name.find("_mu") != std::string::npos){ SelectorBase::AddAncestor(*sel, c_1mu_chan); } }//el/mu channel splitting is done last else{ - if( !(sprop_bjet || sprop_M || sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ + if( !(sprop_bjet || sprop_M || sprop_TH|| sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ if(sprop_jet->primanc_name.empty()){ SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index}, sprop_lep->index); @@ -420,7 +572,7 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) } }//Lep + jet - else if( !(sprop_M || sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ + else if( !(sprop_M || sprop_TH || sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ if(sprop_bjet->primanc_name.empty()){ AddAncestor(*sel, "c"+sprop_lep->name+sprop_jet->name, true); @@ -443,6 +595,7 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if(sprop_M){s_boost += sprop_M->name; } if(sprop_T){s_boost += sprop_T->name; } if(sprop_H){s_boost += sprop_H->name; } + if(sprop_TH){s_boost += sprop_TH->name; } if(sprop_Mbb){ AddAncestor(*sel, "c" + sprop_lep->name + s_boost + sprop_jet->name + sprop_bjet->name, true); diff --git a/VLQAnalysis/VLQ_Options.h b/VLQAnalysis/VLQ_Options.h index 8d274fe..7586c6d 100644 --- a/VLQAnalysis/VLQ_Options.h +++ b/VLQAnalysis/VLQ_Options.h @@ -67,6 +67,7 @@ public: inline std::string BtagOP() const { return m_btagOP; } inline std::string TRFCDIPath() const { return m_TRFCDIPath; } inline std::string QCDMode() const { return m_QCDMode; } + inline std::string DoRegions() const { return m_do_regions; } // doubles inline double RCJetsPtCut() const { return m_RCJetsPtCut; } inline double JetsPtCut() const { return m_jetsPtCut; } @@ -122,6 +123,7 @@ private: std::string m_btagOP; std::string m_TRFCDIPath; std::string m_QCDMode; + std::string m_do_regions; FilteringType m_filterType; }; diff --git a/VLQAnalysis/VLQ_Selector.h b/VLQAnalysis/VLQ_Selector.h index 2fdb6b9..866f0ad 100644 --- a/VLQAnalysis/VLQ_Selector.h +++ b/VLQAnalysis/VLQ_Selector.h @@ -34,6 +34,7 @@ public: c_0Mex, c_1Mex, c_2Min, c_0Tex, c_0Tin, c_1Tex, c_1Tin, c_2Tin, c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, + c_0THex, c_1THex, c_2THex, c_3THin, c_LowMtbmin, c_HighMtbmin, c_LowMbb, c_HighMbb, TOPSEL_MAX }; @@ -101,6 +102,19 @@ public: OutputHistManager* m_outMngrHist; //OutputTreeManager* m_outMngrTree; + bool m_do_presel; + bool m_do_validn_reg; + bool m_do_fit_reg; + bool m_do_lowb; + bool m_do_split_emu; + bool m_do_lowj; + bool m_do_highj; + bool m_do_old_boost; + bool m_do_new_boost; + bool m_do_merge_boost; + bool m_do_split_mtb; + bool m_do_split_mbb; + std::map<std::string, int>* m_sel_indices; std::map<int, std::string>* m_sel_names; std::vector<SelProp>* m_sel_lep_prop; @@ -110,6 +124,7 @@ public: std::vector<SelProp>* m_sel_M_prop; std::vector<SelProp>* m_sel_T_prop; std::vector<SelProp>* m_sel_H_prop; + std::vector<SelProp>* m_sel_TH_prop; std::vector<SelProp>* m_sel_Mbb_prop; std::vector<SelProp>* m_sel_Mtb_prop; diff --git a/data/samples_info.dat b/data/samples_info.dat index 264529d..6c828b4 100644 --- a/data/samples_info.dat +++ b/data/samples_info.dat @@ -1,7 +1,7 @@ # # -# Path to files: /nfs/atlas-data07/lvalery/VLQFiles/MBJ-2.4.19-3/ -# Date: 2016_10_31_1422 +# Path to files: /nfs/atlas-data07/lvalery/VLQFiles/MBJ-2.4.22-2-0/ +# Date: 2016_12_16_1602 # Histogram used to normalize: cut_flow # # @@ -10,25 +10,24 @@ 407010. 1959000.0 2.66570241 407011. 493000.0 0.541911048 407012. 3953000.0 7.670660550000001 -410001. 19133000.0 451.66407468000006 +410001. 19933000.0 451.66407468000006 410002. 19816000.0 451.66407468000006 410003. 2832822.0 451.63887300000005 -410232. -17629353000.0 0.0 410186. 2748937.177796171 379.190196 410187. 637139.3153684614 182.52669600000002 410188. 662615.6867510127 182.388888 410189. 126825.08000462421 87.66081720000001 407200. 605293.6878291359 403.518505829 407201. 6665.359439293912 28.166851711 -407202. 19335.52554393129 9.314823567 +407202. 19494.585791897145 9.314823567 407203. 14707.95228319196 7.640266009 407204. 1362.085848716204 3.025597303 363331. 13358929.870112043 15821.9692868 -363332. 3530169.2007669536 2683.83259267 -363333. 3704883.187305265 909.565023 -363334. 2059954.6969637647 375.759077047 -363335. 2298436.668747467 144.539591316 -363336. 2573331.8146737185 49.107324606 +363332. 3530169.200766953 2683.83259267 +363333. 3704883.1873052646 909.565023 +363334. 2059954.6969637643 375.759077047 +363335. 2345873.6620247364 144.539591316 +363336. 2573331.814673718 49.107324606 363337. 2158062.3020979045 50.173358226 363338. 2655100.8042401318 22.558816959 363339. 2804712.9959699926 8.611129318 @@ -48,10 +47,10 @@ 363353. 7212.607830047607 8.707e-06 363354. 6762.675058841705 5.143e-06 363436. 13337472.413192276 15795.1948618 -363437. 3523276.858181094 2675.17332482 +363437. 3523276.8581810934 2675.17332482 363438. 3685437.6737969164 907.616822112 363439. 2057601.5299330484 377.749548487 -363440. 2353836.5086779664 145.131941493 +363440. 2353836.508677967 145.131941493 363441. 2567287.068155028 49.820615432 363442. 2157059.3071770603 50.117877494 363443. 2672074.4495697385 22.617359448 @@ -71,10 +70,10 @@ 363457. 4496.180504083633 1.2348e-05 363458. 8494.651215195656 9.812e-06 363459. 6553.594656348228 5.314e-06 -363460. 11232496.544199575 15813.6777927 -363461. 3537884.9495730717 2684.61495225 +363460. 13361584.819936153 15813.6777927 +363461. 3537884.949573071 2684.61495225 363462. 3725310.1216163673 912.150989719 -363463. 2048477.1468568454 376.41531567 +363463. 2048477.1468568456 376.41531567 363464. 2349600.920185622 146.400460335 363465. 2578062.7687725388 49.551285758 363466. 2155108.648944433 50.212399035 @@ -95,7 +94,7 @@ 363481. 4780.497862935066 1.2973e-05 363482. 5484.196552157402 2.364e-06 363483. 5680.835121870041 3.705e-06 -363102. 116020.70272448566 46.751851426 +363102. 569330.9493347334 46.751851426 363103. 248901.7463053711 14.026868379 363104. 553733.6962420273 8.832529157 363105. 276429.14321800973 6.73378408 @@ -142,11 +141,11 @@ 363385. 11097.32879152894 2.451e-06 363386. 8526.27656173706 1.38e-06 363387. 7544.75397837162 6.69e-07 -363388. 1991755.8305751984 1641.4628707 +363388. 1991755.8305751989 1641.4628707 363389. 1171678.7545841862 241.466440999 363390. 1057145.0710850768 140.517436867 363391. 577845.0901656877 46.790575075 -363392. 404629.97116456495 14.049268454 +363392. 404629.971164565 14.049268454 363393. 559457.2096852564 8.861525949 363394. 442495.1637891263 6.789837772 363395. 508522.6639410838 2.42660918 @@ -166,10 +165,10 @@ 363409. 11687.755994215608 2.524e-06 363410. 7347.040529966354 1.218e-06 363411. 7069.116419672966 6.99e-07 -363412. 5267767.595836165 8849.62366464 -363413. 2895544.7531762654 1261.784832 -363414. 2613355.4120988413 777.421359616 -363415. 250568.9016328124 262.063481626 +363412. 5267767.595836166 8849.62366464 +363413. 2895544.753176265 1261.784832 +363414. 2613355.4120988417 777.421359616 +363415. 1376663.7008297076 262.063481626 363416. 1015015.0284848226 78.642619761 363417. 1254964.813221789 49.007402629 363418. 1068596.1209359253 37.875959148 @@ -205,11 +204,8 @@ 410066. 1986400.0 0.2330592 410067. 2355815.1317760646 0.1856184 410068. 1282597.0725458562 0.18057600000000001 -410073. 1959000.0 0.2546187 -410074. 2385552.9338029325 0.2430351 -410075. 1377693.0950496495 0.2561769 410081. 50000.0 0.009904052250000002 -343365. 242615.03977490944 0.05343 +343365. 242615.0397749094 0.05343 343366. 2305336.7569104517 0.22276 343367. 2134378.8306208653 0.23082 361091. 477048.8134109229 22.64535 @@ -219,3 +215,4 @@ 361095. 145633.38444022834 6.167070000000001 361096. 323506.1387570943 14.96495 361097. 327652.0711047682 14.953119999999998 +410080. 198800.0 0.00920068124 diff --git a/python/ProduceSampleDATfile.py b/python/ProduceSampleDATfile.py index 134883a..6b66264 100644 --- a/python/ProduceSampleDATfile.py +++ b/python/ProduceSampleDATfile.py @@ -30,7 +30,7 @@ here = os.getcwd() ##________________________________________________________ ## Defining the paths and the tarball -inputDir="/nfs/atlas-data07/lvalery/VLQFiles/MBJ-2.4.19-3/" +inputDir="/nfs/atlas-data07/lvalery/VLQFiles/MBJ-2.4.22-2-0/" listFolder=here+"/Lists_Analysis_" + now histogramName="cut_flow" ##........................................................ -- GitLab From b44c03bd9ba1762c81e6208fe4dd7a7c7b99f31a Mon Sep 17 00:00:00 2001 From: "tfarooque@ifae.es" <tfarooque@at305.pic.es> Date: Sun, 1 Jan 2017 17:23:29 +0100 Subject: [PATCH 2/7] Adding a revised weight manager with AnalysisTop branch names (TBU) --- Root/VLQ_WeightManager.cxx | 581 ++++++++++++++++++++++++++++++++ VLQAnalysis/VLQ_WeightManager.h | 61 ++++ 2 files changed, 642 insertions(+) create mode 100644 Root/VLQ_WeightManager.cxx create mode 100644 VLQAnalysis/VLQ_WeightManager.h diff --git a/Root/VLQ_WeightManager.cxx b/Root/VLQ_WeightManager.cxx new file mode 100644 index 0000000..e53c0fb --- /dev/null +++ b/Root/VLQ_WeightManager.cxx @@ -0,0 +1,581 @@ +#include "VLQAnalysis/VLQ_WeightManager.h" + +//#include "IFAETopFramework/WeightManager.h" +#include "IFAETopFramework/SampleInfo.h" +#include "IFAETopFramework/AnalysisObject.h" + +#include "VLQAnalysis/VLQ_Options.h" +#include "VLQAnalysis/VLQ_NtupleData.h" +#include "VLQAnalysis/VLQ_OutputData.h" +#include "VLQAnalysis/VLQ_Enums.h" +#include "VLQAnalysis/VLQ_QCDWeight.h" +#include "VLQAnalysis/VLQ_TtbarSystematicsManager.h" +#include "VLQAnalysis/VLQ_VariableComputer.h" + +#include "IFAEReweightingTools/HFSystDataMembers.h" +#include "IFAEReweightingTools/ttbbNLO_syst.h" +#include "IFAEReweightingTools/ttccNLO_syst.h" +#include "IFAEReweightingTools/TtbarFractionReweighter.h" + + +#include <iostream> +#include <stdexcept> // invalid_argument +#include <string> + +using std::string; + +//_____________________________________________________________________________________ +// +VLQ_WeightManager::VLQ_WeightManager( VLQ_Options *opt, const VLQ_NtupleData* ntupleData, VLQ_OutputData* outputData ): + WeightManager(opt, ntupleData, outputData), + m_vlq_opt(opt), + m_vlq_ntupData(ntupleData), + m_vlq_outData(outputData), + //m_weightMngr(weightManager), + m_sampleInfo(0), + m_qcdWeight(0), + m_varComputer(0), + m_tool_HFsyst(0), + m_tool_ttFractionRw(0), + m_ttbar_syst_weight(0) +{ + /////////////////////////////////////// + // Cross-section weight + /////////////////////////////////////// + if ( !(m_vlq_opt -> IsData() || (m_vlq_opt -> SampleName() == SampleName::QCD)) ) { + std::string path = ""; + path += std::getenv("ROOTCOREBIN") + std::string("/data/VLQAnalysis/samples_info.dat"); + string sampleId = opt -> StrSampleID(); + m_sampleInfo = new SampleInfo( sampleId, path ); + if(!m_sampleInfo->Ready()){ + throw std::invalid_argument(string(__FILE__)+"\n"+ + " Could not identify sample '"+sampleId+"'" + " in the provided config file '"+path+"'. \n" + " Please check !" + " Normalisation will be crap !"); + } + } + + ////////////////////////////////////// + // QCD weight tool + ////////////////////////////////////// + m_qcdWeight = new VLQ_QCDWeight(); + m_varComputer = new VLQ_VariableComputer(m_vlq_opt); + + // + // ttbar-related + // + if(m_vlq_opt -> SampleName() == SampleName::TTBARBB || m_vlq_opt -> SampleName() == SampleName::TTBARCC || + m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT || m_vlq_opt -> SampleName() == SampleName::TTBAR ){ + + ////////////////////////////////////// + // tt+bb reweighting tool + ////////////////////////////////////// + + // Declaration of ttbb_syst class + if( m_vlq_opt -> RecomputeTtBbRw () ){ + m_tool_HFsyst = new ttbbNLO_syst( m_vlq_opt -> StrSampleID(),std::getenv("ROOTCOREBIN")+std::string("/data/IFAEReweightingTools/ttbbNormRw.root"), + std::getenv("ROOTCOREBIN")+std::string("/data/IFAEReweightingTools/ttbbShapeRw.root")); + m_tool_HFsyst -> Init(); + } + + // Declaration of Ttbar Fraction Rw tool + if( m_vlq_opt -> ReweightTtbarFractions () ){ + m_tool_ttFractionRw = new TtbarFractionReweighter(m_vlq_opt -> StrSampleID(), std::getenv("ROOTCOREBIN")+std::string("/data/IFAEReweightingTools/TtbarHFFractions_Rw.root")); + m_tool_ttFractionRw -> Init(); + } + + ////////////////////////////////////// + // ttbar systematic uncertainties (generator comparisons) + ////////////////////////////////////// + + m_ttbar_syst_weight = new VLQ_TtbarSystematicsManager( m_vlq_opt, m_vlq_outData, m_vlq_ntupData ); + m_ttbar_syst_weight -> Init(std::getenv("ROOTCOREBIN")+std::string("/data/VLQAnalysis/ttbarSystematics.root")); + + } +} + +//_____________________________________________________________________________________ +// +VLQ_WeightManager::VLQ_WeightManager( const VLQ_WeightManager &q ) : WeightManager(q) { + m_vlq_opt = q.m_vlq_opt; + m_vlq_ntupData = q.m_vlq_ntupData; + m_vlq_outData = q.m_vlq_outData; + //m_weightMngr = q.m_weightMngr; + + m_sampleInfo = q.m_sampleInfo; + m_qcdWeight = q.m_qcdWeight; + m_varComputer = q.m_varComputer; + m_tool_HFsyst = q.m_tool_HFsyst; + m_tool_ttFractionRw = q.m_tool_ttFractionRw; + m_ttbar_syst_weight = q.m_ttbar_syst_weight; +} + +//_____________________________________________________________________________________ +// +VLQ_WeightManager::~VLQ_WeightManager(){ + if(m_sampleInfo) delete m_sampleInfo; + if(m_qcdWeight) delete m_qcdWeight; + if(m_varComputer) delete m_varComputer; + if(m_tool_HFsyst) delete m_tool_HFsyst; + if(m_tool_ttFractionRw) delete m_tool_ttFractionRw; + if(m_ttbar_syst_weight) delete m_ttbar_syst_weight; +} + +/* +// +// Declaration of the WeightManager, and reading in of nominal and systematic weight components +// +if(m_vlq_opt -> MsgLevel() == Debug::DEBUG) std::cout << "Declaring WeightManager" << std::endl; +m_weightMngr = new WeightManager( m_vlq_opt, m_vlq_ntupData, m_vlq_outData ); +m_weightMngr -> SetConfigBlock( "ISQCD", ( m_vlq_opt -> SampleName() == SampleName::QCD ) ); +m_weightMngr -> SetConfigBlock( "USEPUWEIGHT", m_vlq_opt -> UsePileUpWeight() ); +m_weightMngr -> SetConfigBlock( "USELEPTONSF", m_vlq_opt -> UseLeptonsSF() ); +m_weightMngr -> SetConfigBlock( "USELEPTONTRIGGERSF", m_vlq_opt -> UseLeptonTrigger() ); +m_weightMngr -> SetConfigBlock( "RECOMPUTEBTAGGINGWEIGHTS", (m_vlq_opt -> DoTRF() && m_vlq_opt -> RecomputeTRF()) || m_vlq_opt -> RecomputeBtagSF() ); +m_weightMngr -> SetConfigBlock( "RUNLEPTONSYSTEMATICS", m_vlq_opt -> ComputeWeightSys() ); + +bool isTtbar = (m_vlq_opt -> SampleName() == SampleName::TTBAR) || (m_vlq_opt -> SampleName() == SampleName::TTBARBB) + || (m_vlq_opt -> SampleName() == SampleName::TTBARCC) || (m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT); + +bool isVjets22 = ( (m_vlq_opt -> StrSampleName().find("W+JETS22") != std::string::npos) + || (m_vlq_opt -> StrSampleName().find("Z+JETS22") != std::string::npos) ); +m_weightMngr -> SetConfigBlock( "SCALETTBARHTSLICES", isTtbar && m_vlq_opt -> ScaleTtbarHtSlices() ); +m_weightMngr -> SetConfigBlock( "USETTBBCORRECTION", isTtbar && m_vlq_opt -> ApplyTtbbCorrection() ); +m_weightMngr -> SetConfigBlock( "USETTBARFRACTIONSREWEIGHTING", isTtbar && m_vlq_opt -> ReweightTtbarFractions() ); +m_weightMngr -> SetConfigBlock( "ISTTBAR", isTtbar ); +m_weightMngr -> SetConfigBlock( "USETTBARNNLOREWEIGHTING", isTtbar && m_vlq_opt -> ApplyTtbarNNLOCorrection() ); +m_weightMngr -> SetConfigBlock( "COMPUTETTCCNLO", isTtbar && m_vlq_opt -> ComputeTtccNLO() ); +m_weightMngr -> SetConfigBlock( "USEVJETSSHERPA22RW", isVjets22 && m_vlq_opt -> ApplyVjetsSherpa22RW() ); + +*/ + + +//_____________________________________________________________________________________ +// +bool VLQ_WeightManager::AddVLQNominalWeights(){ + + if( m_vlq_opt -> SampleName() == SampleName::QCD ){ + AddAndInitWeight("weight_qcd", "", true, false); + } + else{ + + AddAndInitWeight("weight_mc"); + AddAndInitWeight("weight_jvt"); + + AddAndInitWeight("weight_norm", "", true, false); + + if(m_vlq_opt->UsePileUpWeight()){ AddAndInitWeight("weight_pu"); } + + if(m_vlq_opt->UseLeptonsSF()){ + if(m_vlq_opt->ComputeWeightSys()){ + std::vector<std::string> el_nom_comp = {"Reco", "ID", "Isol"}; + std::vector<std::string> mu_nom_comp = {"ID", "Isol", "TTVA"}; + if(m_vlq_opt->UseLeptonTrigger()){ mu_nom_comp.push_back("Trigger"); } + + for(const std::string& el_nom : el_nom_comp){ + AddAndInitWeight("weight_indiv_SF_EL_"+el_nom, "", true, true, "", "", "F"); + } + + for(const std::string& mu_nom : mu_nom_comp){ + AddAndInitWeight("weight_indiv_SF_MU_"+mu_nom, "", true, true, "", "", "F"); + } + } + else{ + AddAndInitWeight("weigt_leptonSF", "", true, true, "", "", "F"); + } + + } + + if((m_vlq_opt -> DoTRF() && m_vlq_opt -> RecomputeTRF()) || m_vlq_opt -> RecomputeBtagSF()){ + AddAndInitWeight("weight_btag_recomputed", "", true, false); + } + else{ + AddAndInitWeight("weight_bTagSF_77"); + } + + if( (m_vlq_opt -> SampleName() == SampleName::TTBAR) || (m_vlq_opt -> SampleName() == SampleName::TTBARBB) + || (m_vlq_opt -> SampleName() == SampleName::TTBARCC) || (m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT) ){ + + if(m_vlq_opt->ApplyTtbbCorrection()){ + AddAndInitWeight("weight_ttbb", "", true, false); + } + + if(m_vlq_opt->ReweightTtbarFractions()){ + AddAndInitWeight("weight_ttbar_fractions_rw", "", true, false); + } + + if(m_vlq_opt->ApplyTtbarNNLOCorrection()){ + AddAndInitWeight("weight_ttbar_nnlo", "", true, true, "", "", "F"); + } + }//ttbar + + }//!QCD + + + return true; +} + +//_____________________________________________________________________________________ +// +bool VLQ_WeightManager::AddVLQSystematicWeights(){ + + AddAndInitWeight("weight_jvt_UP", "", false, true, "", "weight_jvt", "F"); + AddAndInitWeight("weight_jvt_DOWN", "", false, true, "", "weight_jvt", "F"); + + if(m_vlq_opt->UsePileUpWeight()){ + AddAndInitWeight("weight_pileup_UP", "", false, true, "", "weight_pileup", "F"); + AddAndInitWeight("weight_pileup_DOWN", "", false, true, "", "weight_pileup", "F"); + } + + if(m_vlq_opt->UseLeptonsSF()){ + + std::vector<std::string> el_sys_comp = {"Reco", "ID", "Isol" }; + + std::map<std::string, std::vector<std::string> > mu_sys_comp = { + {"ID", {"STAT", "SYST", "STAT_LOWPT", "SYST_LOWPT"}}, + {"Isol",{"STAT", "SYST"}}, + {"TTVA", {"STAT", "SYST"}} + }; + + if(m_vlq_opt->UseLeptonTrigger()){ + + el_sys_comp.push_back("Trigger"); + mu_sys_comp.insert( std::pair<std::string, std::vector<std::string> >("Trigger", {"STAT", "SYST"}) ); + + } + + for(const std::string& el_sys : el_sys_comp){ + AddAndInitWeight("weight_indiv_SF_EL_"+el_sys+"_UP", "", false, true, "", "weight_indiv_SF_EL_"+el_sys, "F"); + AddAndInitWeight("weight_indiv_SF_EL_"+el_sys+"_DOWN", "", false, true, "", "weight_indiv_SF_EL_"+el_sys, "F"); + } + + for(std::pair<std::string, std::vector<std::string> > mu_sys_pair : mu_sys_comp){ + + for(const std::string& mu_sys : mu_sys_pair.second){ + AddAndInitWeight("weight_indiv_SF_MU_"+mu_sys_pair.first+"_"+mu_sys+"_UP","",false, true, "", "weight_indiv_SF_MU_"+mu_sys_pair.first, "F"); + AddAndInitWeight("weight_indiv_SF_MU_"+mu_sys_pair.first+"_"+mu_sys+"_DOWN","",false, true, "", "weight_indiv_SF_MU_"+mu_sys_pair.first, "F"); + } + + } + + }//lepton SF + + std::string btag_name = ""; + std::string btag_vartype = ""; + bool btag_isinput = true; + if((m_vlq_opt -> DoTRF() && m_vlq_opt -> RecomputeTRF()) || m_vlq_opt -> RecomputeBtagSF()){ + btag_name = "weight_btag_recomputed"; + btag_isinput = false; + btag_vartype = "D"; + } + else{ + btag_name = "weight_bTagSF_77"; + btag_vartype = "PVF"; + } + /* + + WeightObject* AddAndInitWeight( const std::string &name, const std::string& title="", bool isNominal=true, + bool isInput=true, const std::string& branchName="", + const std::string& affected_component="", + const std::string& componentType="D", int vec_ind=-1); + + */ + + for(int i = 0; i <=4; i++ ){ + AddAndInitWeight(Form("%s_B_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_B_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_B_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_B_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + } + + for(int i = 0; i <=3; i++ ){ + AddAndInitWeight(Form("%s_C_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_C_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_C_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_C_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + } + + for(int i = 0; i <=13; i++ ){ + if(i == 6) continue; + AddAndInitWeight(Form("%s_Light_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_Light_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_Light_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_Light_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + } + + AddAndInitWeight(btag_name+"_extrapolation_Up", "", false, btag_isinput, "", btag_name, btag_vartype); + AddAndInitWeight(btag_name+"_extrapolation_Down", "", false, btag_isinput, "", btag_name, btag_vartype); + + AddAndInitWeight(btag_name+"_extrapolation_from_charm_Up", "", false, btag_isinput, "", btag_name, btag_vartype); + AddAndInitWeight(btag_name+"_extrapolation_from_charm_Down", "", false, btag_isinput, "", btag_name, btag_vartype); + + if( (m_vlq_opt -> SampleName() == SampleName::TTBAR) || (m_vlq_opt -> SampleName() == SampleName::TTBARBB) + || (m_vlq_opt -> SampleName() == SampleName::TTBARCC) || (m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT) ){ + + std::vector<std::string> ttbar_sys_comp = {"PS", "GEN", "GENPS", "RADHI", "RADLOW"}; + for(const std::string& ttbar_sys : ttbar_sys_comp){ + AddAndInitWeight("weight_ttbar_"+ttbar_sys,"",false, false, "", "weight_ttbar_NNLO"); + } + + if(m_vlq_opt->ApplyTtbbCorrection()){ + + std::vector<std::string> ttbb_sys_comp = {"CSS_KIN", "MSTW", "NNPDF", "Q_CMMPS", "glosoft", "defaultX05", "defaultX2", "MPIup", "MPIdown", "MPIfactor"}; + + for(const std::string& ttbb_sys : ttbb_sys_comp){ + AddAndInitWeight("weight_ttbb_"+ttbb_sys, "", false, false, "", "weight_ttbb"); + } + }//ttbb correction + + }//ttbar samples + + + return true; + +} + + + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetTtbarHtSliceScale(){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbarHtSliceScale(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + SetNominalComponent("weight_ttbar_htslice", 1.); + + bool is1L = ( m_vlq_outData-> o_channel_type == VLQ_Enums::ELECTRON ) || ( m_vlq_outData-> o_channel_type == VLQ_Enums::MUON ); + bool is0L = ( m_vlq_outData-> o_channel_type == VLQ_Enums::FULLHAD ); + if(is1L){ + if( m_vlq_ntupData -> d_runNumber == 407009 ){ SetNominalComponent("weight_ttbar_htslice", 1.02849); } + else if( m_vlq_ntupData -> d_runNumber == 407010 ){ SetNominalComponent("weight_ttbar_htslice", 1.02637); } + else if( m_vlq_ntupData -> d_runNumber == 407011 ){ SetNominalComponent("weight_ttbar_htslice", 0.872646); } + } + else if(is0L){ + if( m_vlq_ntupData -> d_runNumber == 407009 ){ SetNominalComponent("weight_ttbar_htslice", 1.04571); } + else if( m_vlq_ntupData -> d_runNumber == 407010 ){ SetNominalComponent("weight_ttbar_htslice", 0.983895); } + else if( m_vlq_ntupData -> d_runNumber == 407011 ){ SetNominalComponent("weight_ttbar_htslice", 0.916687); } + } + + return true; +} + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetCrossSectionWeight(){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetCrossSectionWeight(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + if(!m_sampleInfo){ + std::cerr << "<!> Error in VLQ_WeightManager::SetCrossSectionWeight(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + if( m_vlq_opt -> IsData() || m_vlq_opt -> SampleName() == SampleName::QCD ){ + return false; + } + SetNominalComponent( "weight_norm", m_sampleInfo -> NormFactor() ); + return true; +} + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetQCDWeight( const int channel ){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetQCDWeight(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + if( m_vlq_opt -> SampleName() != SampleName::QCD ){ + return false; + } + bool isElectronChannel = ( channel == VLQ_Enums::ELECTRON ); + bool isMuonChannel = ( channel == VLQ_Enums::MUON ); + if( !m_vlq_opt -> RecomputeQCDWeight() || (!isElectronChannel && !isMuonChannel) ){ + SetNominalComponent("weight_qcd", 1. ); + return false; + } + if(!m_varComputer){ + std::cerr << "<!> Error in VLQ_WeightManager::SetQCDWeight(): m_varComputer is null ... Please check !" << std::endl; + abort(); + } + if(!m_qcdWeight){ + std::cerr << "<!> Error in VLQ_WeightManager::SetQCDWeight(): m_qcdWeight is null ... Please check !" << std::endl; + abort(); + } + + double minDR = 0; + AnalysisObject *lepton = nullptr; + if(isElectronChannel){ + minDR = m_varComputer -> GetMindR( *(m_vlq_outData -> o_jets), *(m_vlq_outData -> o_el) ); + lepton = m_vlq_outData -> o_el -> at(0); + } + else if(isMuonChannel){ + minDR = m_varComputer -> GetMindR( *(m_vlq_outData -> o_jets), *(m_vlq_outData -> o_mu) ); + lepton = m_vlq_outData -> o_mu -> at(0); + } + + bool isBoosted = false; + if( m_vlq_opt -> QCDMode() == "FJ" ){ + isBoosted = true; + } else if( m_vlq_opt -> QCDMode() == "DEP" ){ + if(m_vlq_outData -> o_taggedjets_n.at("RCTTMass") > 0){ + isBoosted = true; + } else { + isBoosted = false; + } + } + const double qcdWeight = m_qcdWeight -> RetrieveWeight( isElectronChannel, lepton->Pt(), minDR, ((int)lepton->GetMoment("signal")==1), isMuonChannel, isBoosted ); + SetNominalComponent("weight_qcd", qcdWeight ); + if(m_vlq_opt->MsgLevel()==Debug::DEBUG){ + std::cout << "Electron: " << isElectronChannel << " pT = " << lepton->Pt() << " dR = " << minDR << " Tight: "; + std::cout << ((int)lepton->GetMoment("signal")==1) << " Boosted: " << isBoosted << " Weight: " << qcdWeight << std::endl; + } + return true; +} + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetTtbbWeights(){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbbWeights(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + if(m_vlq_opt -> SampleName() == SampleName::TTBARBB || m_vlq_opt -> SampleName() == SampleName::TTBARCC || + m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT || m_vlq_opt -> SampleName() == SampleName::TTBAR ){ + + // + // NLO tt+bb Sherpa-based reweighting + // + if( m_vlq_opt -> ApplyTtbbCorrection() && m_vlq_opt -> RecomputeTtBbRw () ){ + + if(!m_tool_HFsyst){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbbWeights(): m_tool_HFsyst is null ... Please check !" << std::endl; + abort(); + } + + if(m_vlq_opt -> MsgLevel() == Debug::DEBUG) std::cout << "==> Evaluating TtBb Weigths" << std::endl; + HFSystDataMembers *dm_HFsyst = new HFSystDataMembers(); + std::map<std::string,float> mapsOfHFweights; + mapsOfHFweights.clear(); + + dm_HFsyst -> q1_pt = m_vlq_ntupData->d_q1_pt; + dm_HFsyst -> q1_eta = m_vlq_ntupData->d_q1_eta; + dm_HFsyst -> qq_pt = m_vlq_ntupData->d_qq_pt; + dm_HFsyst -> qq_dr = m_vlq_ntupData->d_qq_dr; + dm_HFsyst -> top_pt = m_vlq_ntupData->d_top_pt / 1000.; + dm_HFsyst -> ttbar_pt = m_vlq_ntupData->d_ttbar_pt / 1000.; + dm_HFsyst -> HF_Classification = m_vlq_ntupData -> d_HF_Classification; + + mapsOfHFweights = m_tool_HFsyst->GetttHFWeights(dm_HFsyst); + + SetNominalComponent("weight_ttbb", mapsOfHFweights["ttbb_Nominal_weight"]); + + if( m_vlq_opt -> ComputeWeightSys() ){ + SetSystematicComponent("weight_ttbb_CSS_KIN", mapsOfHFweights["ttbb_CSS_KIN_weight"]); + SetSystematicComponent("weight_ttbb_MSTW", mapsOfHFweights["ttbb_MSTW_weight"]); + SetSystematicComponent("weight_ttbb_NNPDF", mapsOfHFweights["ttbb_NNPDF_weight"]); + SetSystematicComponent("weight_ttbb_Q_CMMPS", mapsOfHFweights["ttbb_Q_CMMPS_weight"]); + SetSystematicComponent("weight_ttbb_glosoft", mapsOfHFweights["ttbb_glosoft_weight"]); + SetSystematicComponent("weight_ttbb_defaultX05", mapsOfHFweights["ttbb_defaultX05_weight"]); + SetSystematicComponent("weight_ttbb_defaultX2", mapsOfHFweights["ttbb_defaultX2_weight"]); + SetSystematicComponent("weight_ttbb_MPIup", mapsOfHFweights["ttbb_MPIup_weight"]); + SetSystematicComponent("weight_ttbb_MPIdown", mapsOfHFweights["ttbb_MPIdown_weight"]); + SetSystematicComponent("weight_ttbb_MPIfactor", mapsOfHFweights["ttbb_MPIfactor_weight"]); + SetSystematicComponent("weight_ttbb_aMcAtNloHpp",mapsOfHFweights["ttbb_aMcAtNloHpp_weight"]); + SetSystematicComponent("weight_ttbb_aMcAtNloPy8",mapsOfHFweights["ttbb_aMcAtNloPy8_weight"]); + } + + delete dm_HFsyst; + if(m_vlq_opt -> MsgLevel() == Debug::DEBUG) std::cout << "==> After TtBb weights" << std::endl; + } + + // + // tt+bb/cc/light fraction reweithing in the different ttbar generators + // + if( m_vlq_opt -> ReweightTtbarFractions () ){ + if(!m_tool_ttFractionRw){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbbWeights(): m_tool_ttFractionRw is null ... Please check !" << std::endl; + abort(); + } + SetNominalComponent("weight_ttbar_fractions_rw", m_tool_ttFractionRw->GetTtbarFraction_Rw(m_vlq_ntupData -> d_HF_SimpleClassification) ); + } + } else { + return false; + } + return true; +} + + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetTtccWeights(){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbbWeights(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + if(!m_vlq_opt->ComputeWeightSys() || !m_vlq_opt -> ComputeTtccNLO()){ + return true; + } + + + if(m_vlq_opt -> SampleName() == SampleName::TTBARBB || m_vlq_opt -> SampleName() == SampleName::TTBARCC || + m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT || m_vlq_opt -> SampleName() == SampleName::TTBAR ){ + + // + // NLO tt+cc + // + + + float ttccNLO_weight=ttccNLO_syst::CharmRW(m_vlq_ntupData -> d_HF_Classification, m_vlq_ntupData->d_q1_pt, m_vlq_ntupData->d_q1_eta, m_vlq_ntupData->d_qq_pt, m_vlq_ntupData->d_qq_dr); + + + SetSystematicComponent("weight_ttcc_NLO", ttccNLO_weight); + + if(m_vlq_opt -> MsgLevel() == Debug::DEBUG) std::cout << "==> After TtCc weights" << std::endl; + + + } else{ + return false; + } + return true; +} + + + + +//____________________________________________________________________________________ +// +bool VLQ_WeightManager::SetTtbarGeneratorSystematics(){ + /* + if(!m_weightMngr){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbbWeights(): m_weightMngr is null ... Please check !" << std::endl; + abort(); + } + */ + if(!m_vlq_opt->ComputeWeightSys()){ + return true; + } + + if(m_vlq_opt -> SampleName() == SampleName::TTBARBB || m_vlq_opt -> SampleName() == SampleName::TTBARCC || + m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT || m_vlq_opt -> SampleName() == SampleName::TTBAR ){ + + if(!m_ttbar_syst_weight){ + std::cerr << "<!> Error in VLQ_WeightManager::SetTtbarGeneratorSystematics(): m_ttbar_syst_weight is null ... Please check !" << std::endl; + abort(); + } + SetSystematicComponent( "weight_ttbar_PS", m_ttbar_syst_weight -> GetTtbarSystWeight(VLQ_TtbarSystematicsManager::PS) ); + SetSystematicComponent( "weight_ttbar_GEN", m_ttbar_syst_weight -> GetTtbarSystWeight(VLQ_TtbarSystematicsManager::GEN) ); + SetSystematicComponent( "weight_ttbar_GENPS", m_ttbar_syst_weight -> GetTtbarSystWeight(VLQ_TtbarSystematicsManager::GENPS) ); + SetSystematicComponent( "weight_ttbar_RADHI", m_ttbar_syst_weight -> GetTtbarSystWeight(VLQ_TtbarSystematicsManager::RADHI) ); + SetSystematicComponent( "weight_ttbar_RADLOW",m_ttbar_syst_weight -> GetTtbarSystWeight(VLQ_TtbarSystematicsManager::RADLOW) ); + + } else { + return false; + } + return true; +} diff --git a/VLQAnalysis/VLQ_WeightManager.h b/VLQAnalysis/VLQ_WeightManager.h new file mode 100644 index 0000000..77c8cd1 --- /dev/null +++ b/VLQAnalysis/VLQ_WeightManager.h @@ -0,0 +1,61 @@ +#ifndef VLQ_WEIGHTSETTER_H +#define VLQ_WEIGHTSETTER_H + +//in IFAETopFramework +#include "IFAETopFramework/WeightManager.h" +class SampleInfo; + +//in VLQAnalysis +class VLQ_Options; +class VLQ_OutputData; +class VLQ_NtupleData; +class VLQ_QCDWeight; +class VLQ_VariableComputer; +class VLQ_TtbarSystematicsManager; + +//in IFAEReweightingTools +class ttbbNLO_syst; +class TtbarFractionReweighter; +class ttccNLO_syst; + +class VLQ_WeightManager : public WeightManager { + +public: + // + // Standard C++ functions + // + VLQ_WeightManager( VLQ_Options *opt, const VLQ_NtupleData* ntupleData, VLQ_OutputData* outputData ); + VLQ_WeightManager( const VLQ_WeightManager & ); + virtual ~VLQ_WeightManager(); + + // + // Class specific functions + // + bool AddVLQNominalWeights(); + bool AddVLQSystematicWeights(); + + //virtual bool ComputeNominalWeight(); + + bool SetCrossSectionWeight(); + bool SetQCDWeight( const int channel ); + bool SetTtbbWeights(); + bool SetTtccWeights(); + bool SetTtbarGeneratorSystematics(); + bool SetTtbarHtSliceScale(); + +private: + VLQ_Options *m_vlq_opt; + const VLQ_NtupleData *m_vlq_ntupData; + VLQ_OutputData *m_vlq_outData; + //WeightManager *m_weightMngr; + + SampleInfo *m_sampleInfo; + VLQ_QCDWeight *m_qcdWeight; + VLQ_VariableComputer *m_varComputer; + ttbbNLO_syst *m_tool_HFsyst; + TtbarFractionReweighter *m_tool_ttFractionRw; + VLQ_TtbarSystematicsManager *m_ttbar_syst_weight; + +}; + +#endif //VLQ_WEIGHTSETTER_H -- GitLab From 30ff4893dc9638cd34869a6a50523935b02490bd Mon Sep 17 00:00:00 2001 From: "tfarooque@ifae.es" <tfarooque@at301.pic.es> Date: Mon, 2 Jan 2017 14:09:27 +0100 Subject: [PATCH 3/7] Updated weight branch names to SUSYTools --- Root/LinkDef.h | 2 + Root/VLQ_Analysis_Data2015.cxx | 39 +++++--- Root/VLQ_WeightManager.cxx | 146 ++++++++++++++-------------- VLQAnalysis/VLQ_Analysis_Data2015.h | 7 +- 4 files changed, 103 insertions(+), 91 deletions(-) diff --git a/Root/LinkDef.h b/Root/LinkDef.h index 08244fc..40993df 100644 --- a/Root/LinkDef.h +++ b/Root/LinkDef.h @@ -15,6 +15,7 @@ #include "VLQAnalysis/VLQ_TruthManager.h" #include "VLQAnalysis/VLQ_TtbarSystematicsManager.h" #include "VLQAnalysis/VLQ_VariableComputer.h" +#include "VLQAnalysis/VLQ_WeightManager.h" #pragma link off all globals; #pragma link off all classes; @@ -34,5 +35,6 @@ #pragma link C++ class VLQ_TruthManager; #pragma link C++ class VLQ_TtbarSystematicsManager; #pragma link C++ class VLQ_VariableComputer; +#pragma link C++ class VLQ_WeightManager; #endif diff --git a/Root/VLQ_Analysis_Data2015.cxx b/Root/VLQ_Analysis_Data2015.cxx index 4ab141a..edefa29 100644 --- a/Root/VLQ_Analysis_Data2015.cxx +++ b/Root/VLQ_Analysis_Data2015.cxx @@ -12,7 +12,7 @@ #include "IFAETopFramework/OutputTreeManager.h" #include "IFAETopFramework/CommonConstants.h" #include "IFAETopFramework/AnalysisObject.h" -#include "IFAETopFramework/WeightManager.h" +//#include "IFAETopFramework/WeightManager.h" #include "IFAETopFramework/AnalysisUtils.h" #include "IFAETopFramework/TriggerInfo.h" #include "IFAETopFramework/Selection.h" @@ -25,7 +25,7 @@ #include "VLQAnalysis/VLQ_VariableComputer.h" #include "VLQAnalysis/VLQ_Enums.h" #include "VLQAnalysis/VLQ_TruthManager.h" -#include "VLQAnalysis/VLQ_WeightSetter.h" +#include "VLQAnalysis/VLQ_WeightManager.h" #include "VLQAnalysis/VLQ_TRFManager.h" #include "VLQAnalysis/VLQ_Selector.h" #include "VLQAnalysis/string_utils.h" @@ -55,8 +55,8 @@ m_anaTools(0), m_varComputer(0), m_truthMngr(0), m_TRFMngr(0), -m_weightMngr(0), -m_weightSetter(0) +m_weightMngr(0)//, +//m_weightSetter(0) { m_channels.clear(); m_topTaggers.clear(); @@ -134,7 +134,10 @@ bool VLQ_Analysis_Data2015::Begin(){ // Declaration of the WeightManager, and reading in of nominal and systematic weight components // if(m_opt -> MsgLevel() == Debug::DEBUG) std::cout << "Declaring WeightManager" << std::endl; - m_weightMngr = new WeightManager( m_opt, m_ntupData, m_outData ); + m_weightMngr = new VLQ_WeightManager( m_opt, m_ntupData, m_outData ); + + + /* m_weightMngr -> SetConfigBlock( "ISQCD", ( m_opt -> SampleName() == SampleName::QCD ) ); m_weightMngr -> SetConfigBlock( "USEPUWEIGHT", m_opt -> UsePileUpWeight() ); m_weightMngr -> SetConfigBlock( "USELEPTONSF", m_opt -> UseLeptonsSF() ); @@ -142,9 +145,6 @@ bool VLQ_Analysis_Data2015::Begin(){ m_weightMngr -> SetConfigBlock( "RECOMPUTEBTAGGINGWEIGHTS", (m_opt -> DoTRF() && m_opt -> RecomputeTRF()) || m_opt -> RecomputeBtagSF() ); m_weightMngr -> SetConfigBlock( "RUNLEPTONSYSTEMATICS", m_opt -> ComputeWeightSys() ); - bool isTtbar = (m_opt -> SampleName() == SampleName::TTBAR) || (m_opt -> SampleName() == SampleName::TTBARBB) - || (m_opt -> SampleName() == SampleName::TTBARCC) || (m_opt -> SampleName() == SampleName::TTBARLIGHT); - bool isVjets22 = ( (m_opt -> StrSampleName().find("W+JETS22") != std::string::npos) || (m_opt -> StrSampleName().find("Z+JETS22") != std::string::npos) ); m_weightMngr -> SetConfigBlock( "SCALETTBARHTSLICES", isTtbar && m_opt -> ScaleTtbarHtSlices() ); @@ -154,8 +154,11 @@ bool VLQ_Analysis_Data2015::Begin(){ m_weightMngr -> SetConfigBlock( "USETTBARNNLOREWEIGHTING", isTtbar && m_opt -> ApplyTtbarNNLOCorrection() ); m_weightMngr -> SetConfigBlock( "COMPUTETTCCNLO", isTtbar && m_opt -> ComputeTtccNLO() ); m_weightMngr -> SetConfigBlock( "USEVJETSSHERPA22RW", isVjets22 && m_opt -> ApplyVjetsSherpa22RW() ); + */ + m_weightMngr->AddVLQNominalWeights(); + if(m_opt->ComputeWeightSys()) m_weightMngr->AddVLQSystematicWeights(); - m_weightMngr -> AddAllWeights(); + //m_weightMngr -> AddAllWeights(); m_weightMngr -> Print( false ); // @@ -572,6 +575,10 @@ bool VLQ_Analysis_Data2015::Begin(){ // // Declaration of the VLQ_TruthManager object (to recover and treat truth information) // + bool isTtbar = (m_opt -> SampleName() == SampleName::TTBAR) || (m_opt -> SampleName() == SampleName::TTBARBB) + || (m_opt -> SampleName() == SampleName::TTBARCC) || (m_opt -> SampleName() == SampleName::TTBARLIGHT); + + if( ( m_opt -> SampleName() == SampleName::VLQ ) || isTtbar ) { m_truthMngr = new VLQ_TruthManager( m_opt, m_ntupData ); } else { @@ -611,7 +618,7 @@ bool VLQ_Analysis_Data2015::Begin(){ // // Weight affectation class // - m_weightSetter = new VLQ_WeightSetter( m_opt, m_ntupData, m_outData, m_weightMngr ); + //m_weightSetter = new VLQ_WeightSetter( m_opt, m_ntupData, m_outData, m_weightMngr ); return true; } @@ -875,13 +882,13 @@ bool VLQ_Analysis_Data2015::Process(Long64_t entry) //########################################################### if ( !(m_opt -> IsData() || (m_opt -> SampleName() == SampleName::QCD)) ) { - m_weightSetter -> SetCrossSectionWeight(); + m_weightMngr -> SetCrossSectionWeight(); if( (m_opt -> SampleName() == SampleName::TTBARBB) || (m_opt -> SampleName() == SampleName::TTBARCC) || (m_opt -> SampleName() == SampleName::TTBARLIGHT) || (m_opt -> SampleName() == SampleName::TTBAR) ){ - m_weightSetter -> SetTtbbWeights(); - m_weightSetter -> SetTtccWeights(); - m_weightSetter -> SetTtbarGeneratorSystematics(); - if(m_opt->ScaleTtbarHtSlices()){ m_weightSetter -> SetTtbarHtSliceScale(); } + m_weightMngr -> SetTtbbWeights(); + m_weightMngr -> SetTtccWeights(); + m_weightMngr -> SetTtbarGeneratorSystematics(); + if(m_opt->ScaleTtbarHtSlices()){ m_weightMngr -> SetTtbarHtSliceScale(); } } } @@ -1061,7 +1068,7 @@ bool VLQ_Analysis_Data2015::Terminate() delete m_outMngrHist; delete m_outMngrTree; - delete m_weightSetter; + delete m_weightMngr; delete m_TRFMngr; delete m_selector; diff --git a/Root/VLQ_WeightManager.cxx b/Root/VLQ_WeightManager.cxx index e53c0fb..358e914 100644 --- a/Root/VLQ_WeightManager.cxx +++ b/Root/VLQ_WeightManager.cxx @@ -24,6 +24,7 @@ using std::string; + //_____________________________________________________________________________________ // VLQ_WeightManager::VLQ_WeightManager( VLQ_Options *opt, const VLQ_NtupleData* ntupleData, VLQ_OutputData* outputData ): @@ -148,6 +149,19 @@ m_weightMngr -> SetConfigBlock( "USETTBARNNLOREWEIGHTING", isTtbar && m_vlq_ m_weightMngr -> SetConfigBlock( "COMPUTETTCCNLO", isTtbar && m_vlq_opt -> ComputeTtccNLO() ); m_weightMngr -> SetConfigBlock( "USEVJETSSHERPA22RW", isVjets22 && m_vlq_opt -> ApplyVjetsSherpa22RW() ); + + //weight_WZ_2_2 = 0 + //weight_btag = 0 + //weight_elec = 0 + //weight_elec_trigger = 0 + //weight_jvt = 0 + //weight_mc = 0 + //weight_muon = 0 + //weight_muon_trigger = 0 + //weight_pu = 0 + //weight_ttbar_NNLO = 0 + //weight_ttbar_NNLO_1L = 0 + */ @@ -168,37 +182,26 @@ bool VLQ_WeightManager::AddVLQNominalWeights(){ if(m_vlq_opt->UsePileUpWeight()){ AddAndInitWeight("weight_pu"); } if(m_vlq_opt->UseLeptonsSF()){ - if(m_vlq_opt->ComputeWeightSys()){ - std::vector<std::string> el_nom_comp = {"Reco", "ID", "Isol"}; - std::vector<std::string> mu_nom_comp = {"ID", "Isol", "TTVA"}; - if(m_vlq_opt->UseLeptonTrigger()){ mu_nom_comp.push_back("Trigger"); } - - for(const std::string& el_nom : el_nom_comp){ - AddAndInitWeight("weight_indiv_SF_EL_"+el_nom, "", true, true, "", "", "F"); - } - - for(const std::string& mu_nom : mu_nom_comp){ - AddAndInitWeight("weight_indiv_SF_MU_"+mu_nom, "", true, true, "", "", "F"); - } - } - else{ - AddAndInitWeight("weigt_leptonSF", "", true, true, "", "", "F"); + AddAndInitWeight("weight_elec"); + AddAndInitWeight("weight_muon"); + if(m_vlq_opt->UseLeptonTrigger()){ + AddAndInitWeight("weight_elec_trigger"); + AddAndInitWeight("weight_muon_trigger"); } - } if((m_vlq_opt -> DoTRF() && m_vlq_opt -> RecomputeTRF()) || m_vlq_opt -> RecomputeBtagSF()){ AddAndInitWeight("weight_btag_recomputed", "", true, false); } else{ - AddAndInitWeight("weight_bTagSF_77"); + AddAndInitWeight("weight_btag"); } if( (m_vlq_opt -> SampleName() == SampleName::TTBAR) || (m_vlq_opt -> SampleName() == SampleName::TTBARBB) || (m_vlq_opt -> SampleName() == SampleName::TTBARCC) || (m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT) ){ if(m_vlq_opt->ApplyTtbbCorrection()){ - AddAndInitWeight("weight_ttbb", "", true, false); + AddAndInitWeight("weight_ttbb", "weight_ttbb_ttbb_Nominal_weight"); } if(m_vlq_opt->ReweightTtbarFractions()){ @@ -206,9 +209,13 @@ bool VLQ_WeightManager::AddVLQNominalWeights(){ } if(m_vlq_opt->ApplyTtbarNNLOCorrection()){ - AddAndInitWeight("weight_ttbar_nnlo", "", true, true, "", "", "F"); + AddAndInitWeight("weight_ttbar_NNLO"); } }//ttbar + if( (m_vlq_opt -> StrSampleName().find("W+JETS22") != std::string::npos) + || (m_vlq_opt -> StrSampleName().find("Z+JETS22") != std::string::npos) ){ + AddAndInitWeight("weight_WZ_2_2"); + } }//!QCD @@ -216,93 +223,90 @@ bool VLQ_WeightManager::AddVLQNominalWeights(){ return true; } + //_____________________________________________________________________________________ // bool VLQ_WeightManager::AddVLQSystematicWeights(){ - AddAndInitWeight("weight_jvt_UP", "", false, true, "", "weight_jvt", "F"); - AddAndInitWeight("weight_jvt_DOWN", "", false, true, "", "weight_jvt", "F"); + AddAndInitWeight("weight_jvt_UP", "", false, true, "weight_jvt_JET_JvtEfficiency__1up", "weight_jvt"); + AddAndInitWeight("weight_jvt_DOWN", "", false, true, "weight_jvt_JET_JvtEfficiency__1down", "weight_jvt"); if(m_vlq_opt->UsePileUpWeight()){ - AddAndInitWeight("weight_pileup_UP", "", false, true, "", "weight_pileup", "F"); - AddAndInitWeight("weight_pileup_DOWN", "", false, true, "", "weight_pileup", "F"); + AddAndInitWeight("weight_pu_UP", "", false, true, "weight_pu_PRW_DATASF__1up", "weight_pu"); + AddAndInitWeight("weight_pu_DOWN", "", false, true, "weight_pu_PRW_DATASF__1down", "weight_pu"); } if(m_vlq_opt->UseLeptonsSF()){ - std::vector<std::string> el_sys_comp = {"Reco", "ID", "Isol" }; + std::vector<std::string> el_sys_comp = {"Reco", "ID", "Iso" }; + for(const std::string& el_sys : el_sys_comp){ + AddAndInitWeight("weight_elec_"+el_sys+"_UP", "", false, true, "weight_elec_EL_EFF_"+el_sys+"_TOTAL_1NPCOR_PLUS_UNCOR__1up", "weight_elec"); + AddAndInitWeight("weight_elec_"+el_sys+"_DOWN", "", false, true, "weight_elec_EL_EFF_"+el_sys+"_TOTAL_1NPCOR_PLUS_UNCOR__1down", "weight_elec"); + } std::map<std::string, std::vector<std::string> > mu_sys_comp = { - {"ID", {"STAT", "SYST", "STAT_LOWPT", "SYST_LOWPT"}}, - {"Isol",{"STAT", "SYST"}}, - {"TTVA", {"STAT", "SYST"}} + {"EFF", {"STAT", "SYS", "STAT_LOWPT", "SYS_LOWPT"}}, + {"ISO",{"STAT", "SYS"}}, + {"TTVA", {"STAT", "SYS"}} }; + for(std::pair<std::string, std::vector<std::string> > mu_sys_pair : mu_sys_comp){ - if(m_vlq_opt->UseLeptonTrigger()){ - - el_sys_comp.push_back("Trigger"); - mu_sys_comp.insert( std::pair<std::string, std::vector<std::string> >("Trigger", {"STAT", "SYST"}) ); - - } + for(const std::string& mu_sys : mu_sys_pair.second){ + AddAndInitWeight("weight_muon_"+mu_sys_pair.first+"_"+mu_sys+"_UP","",false, true, "weight_muon_MUON_"+mu_sys_pair.first+"_"+mu_sys+"__1up", "weight_muon"); + AddAndInitWeight("weight_muon_"+mu_sys_pair.first+"_"+mu_sys+"_DOWN","",false, true, "weight_muon_MUON_"+mu_sys_pair.first+"_"+mu_sys+"__1down", "weight_muon"); + } - for(const std::string& el_sys : el_sys_comp){ - AddAndInitWeight("weight_indiv_SF_EL_"+el_sys+"_UP", "", false, true, "", "weight_indiv_SF_EL_"+el_sys, "F"); - AddAndInitWeight("weight_indiv_SF_EL_"+el_sys+"_DOWN", "", false, true, "", "weight_indiv_SF_EL_"+el_sys, "F"); } - for(std::pair<std::string, std::vector<std::string> > mu_sys_pair : mu_sys_comp){ + if(m_vlq_opt->UseLeptonTrigger()){ - for(const std::string& mu_sys : mu_sys_pair.second){ - AddAndInitWeight("weight_indiv_SF_MU_"+mu_sys_pair.first+"_"+mu_sys+"_UP","",false, true, "", "weight_indiv_SF_MU_"+mu_sys_pair.first, "F"); - AddAndInitWeight("weight_indiv_SF_MU_"+mu_sys_pair.first+"_"+mu_sys+"_DOWN","",false, true, "", "weight_indiv_SF_MU_"+mu_sys_pair.first, "F"); + std::vector<std::string> el_trig_sys_comp = {"TriggerEff", "Trigger"}; + for(const std::string& el_trig_sys : el_trig_sys_comp){ + AddAndInitWeight("weight_elec_"+el_trig_sys+"_UP", "", false, true, "weight_elec_trigger_EL_EFF_"+el_trig_sys+"_TOTAL_1NPCOR_PLUS_UNCOR__1up", "weight_elec_trigger"); + AddAndInitWeight("weight_elec_"+el_trig_sys+"_DOWN", "", false, true, "weight_elec_trigger_EL_EFF_"+el_trig_sys+"_TOTAL_1NPCOR_PLUS_UNCOR__1down", "weight_elec_trigger"); + } + std::vector<std::string> mu_trig_sys_comp = {"TrigStatUncertainty", "TrigSystUncertainty"}; + for(const std::string& mu_trig_sys : mu_trig_sys_comp){ + AddAndInitWeight("weight_muon_"+mu_trig_sys+"_UP", "", false, true, "weight_muon_trigger_MUON_EFF_"+mu_trig_sys+"__1up", "weight_muon_trigger"); + AddAndInitWeight("weight_muon_"+mu_trig_sys+"_DOWN", "", false, true, "weight_muon_trigger_MUON_EFF_"+mu_trig_sys+"__1down", "weight_muon_trigger"); } - } + }//trigger }//lepton SF + std::string btag_name = ""; std::string btag_vartype = ""; bool btag_isinput = true; if((m_vlq_opt -> DoTRF() && m_vlq_opt -> RecomputeTRF()) || m_vlq_opt -> RecomputeBtagSF()){ btag_name = "weight_btag_recomputed"; btag_isinput = false; - btag_vartype = "D"; } else{ - btag_name = "weight_bTagSF_77"; - btag_vartype = "PVF"; + btag_name = "weight_btag"; } - /* - - WeightObject* AddAndInitWeight( const std::string &name, const std::string& title="", bool isNominal=true, - bool isInput=true, const std::string& branchName="", - const std::string& affected_component="", - const std::string& componentType="D", int vec_ind=-1); - - */ for(int i = 0; i <=4; i++ ){ - AddAndInitWeight(Form("%s_B_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_B_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); - AddAndInitWeight(Form("%s_B_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_B_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_B_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_B_%i__1up",i), btag_name); + AddAndInitWeight(Form("%s_B_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_B_%i__1down",i), btag_name); } for(int i = 0; i <=3; i++ ){ - AddAndInitWeight(Form("%s_C_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_C_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); - AddAndInitWeight(Form("%s_C_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_C_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_C_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_C_%i__1up",i), btag_name); + AddAndInitWeight(Form("%s_C_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_C_%i__1down",i), btag_name); } for(int i = 0; i <=13; i++ ){ - if(i == 6) continue; - AddAndInitWeight(Form("%s_Light_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_Light_eigenvars_Up_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); - AddAndInitWeight(Form("%s_Light_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("%s_Light_eigenvars_Down_%i",btag_name.c_str(),i), btag_name, btag_vartype, i); + AddAndInitWeight(Form("%s_Light_EV_Up_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_Light_%i__1up",i), btag_name); + AddAndInitWeight(Form("%s_Light_EV_Down_%i",btag_name.c_str(),i), "", false, btag_isinput, Form("weight_btag_FT_EFF_Eigen_Light_%i__1down",i), btag_name); } - AddAndInitWeight(btag_name+"_extrapolation_Up", "", false, btag_isinput, "", btag_name, btag_vartype); - AddAndInitWeight(btag_name+"_extrapolation_Down", "", false, btag_isinput, "", btag_name, btag_vartype); + AddAndInitWeight(btag_name+"_extrapolation_Up", "", false, btag_isinput, "weight_btag_FT_EFF_extrapolation__1up", btag_name); + AddAndInitWeight(btag_name+"_extrapolation_Down", "", false, btag_isinput, "weight_btag_FT_EFF_extrapolation__1down", btag_name); - AddAndInitWeight(btag_name+"_extrapolation_from_charm_Up", "", false, btag_isinput, "", btag_name, btag_vartype); - AddAndInitWeight(btag_name+"_extrapolation_from_charm_Down", "", false, btag_isinput, "", btag_name, btag_vartype); + AddAndInitWeight(btag_name+"_extrapolation_from_charm_Up", "", false, btag_isinput, "weight_btag_FT_EFF_extrapolation_from_charm__1up", btag_name); + AddAndInitWeight(btag_name+"_extrapolation_from_charm_Down", "", false, btag_isinput, "weight_btag_FT_EFF_extrapolation_from_charm__1down", btag_name); if( (m_vlq_opt -> SampleName() == SampleName::TTBAR) || (m_vlq_opt -> SampleName() == SampleName::TTBARBB) || (m_vlq_opt -> SampleName() == SampleName::TTBARCC) || (m_vlq_opt -> SampleName() == SampleName::TTBARLIGHT) ){ @@ -312,14 +316,14 @@ bool VLQ_WeightManager::AddVLQSystematicWeights(){ AddAndInitWeight("weight_ttbar_"+ttbar_sys,"",false, false, "", "weight_ttbar_NNLO"); } - if(m_vlq_opt->ApplyTtbbCorrection()){ - - std::vector<std::string> ttbb_sys_comp = {"CSS_KIN", "MSTW", "NNPDF", "Q_CMMPS", "glosoft", "defaultX05", "defaultX2", "MPIup", "MPIdown", "MPIfactor"}; - - for(const std::string& ttbb_sys : ttbb_sys_comp){ - AddAndInitWeight("weight_ttbb_"+ttbb_sys, "", false, false, "", "weight_ttbb"); - } - }//ttbb correction + if(m_vlq_opt->ApplyTtbbCorrection()){ + + std::vector<std::string> ttbb_sys_comp = {"CSS_KIN", "MSTW", "NNPDF", "Q_CMMPS", "glosoft", "defaultX05", "defaultX2", "MPIup", "MPIdown", "MPIfactor", "aMcAtNloHpp", "aMcAtNloPy8"}; + for(const std::string& ttbb_sys : ttbb_sys_comp){ + AddAndInitWeight("weight_ttbb_"+ttbb_sys, "", false, false, "weight_ttbb_ttbb_"+ttbb_sys+"_weight", "weight_ttbb"); + } + + }//ttbb correction }//ttbar samples diff --git a/VLQAnalysis/VLQ_Analysis_Data2015.h b/VLQAnalysis/VLQ_Analysis_Data2015.h index 40b3b19..1bb9875 100644 --- a/VLQAnalysis/VLQ_Analysis_Data2015.h +++ b/VLQAnalysis/VLQ_Analysis_Data2015.h @@ -8,7 +8,7 @@ //IFAEFramework classes class OutputHistManager; class OutputTreeManager; -class WeightManager; +//class WeightManager; //VLQ specific classes class VLQ_Options; @@ -17,7 +17,7 @@ class VLQ_AnalysisTools; class VLQ_VariableComputer; class VLQ_TruthManager; class VLQ_TRFManager; -class VLQ_WeightSetter; +class VLQ_WeightManager; class VLQ_NtupleData; class VLQ_NtupleReader; class VLQ_Selector; @@ -48,8 +48,7 @@ private: VLQ_VariableComputer *m_varComputer; VLQ_TruthManager *m_truthMngr; VLQ_TRFManager *m_TRFMngr; - WeightManager *m_weightMngr; - VLQ_WeightSetter *m_weightSetter; + VLQ_WeightManager *m_weightMngr; VLQ_Selector *m_selector; std::map < std::string, std::vector < std::string > > m_channels; std::vector < std::string > m_topTaggers; -- GitLab From 85817e2bd8c8560608e2128e4cd610d2c50bb727 Mon Sep 17 00:00:00 2001 From: "tfarooque@ifae.es" <tfarooque@at301.pic.es> Date: Wed, 4 Jan 2017 17:59:53 +0100 Subject: [PATCH 4/7] Fixing selection index names --- Root/VLQ_Selector.cxx | 16 +++++++++------- VLQAnalysis/VLQ_Selector.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Root/VLQ_Selector.cxx b/Root/VLQ_Selector.cxx index 7bfb44b..bd4d928 100644 --- a/Root/VLQ_Selector.cxx +++ b/Root/VLQ_Selector.cxx @@ -155,8 +155,8 @@ bool VLQ_Selector::Init(){ MakeSelProp("4jin", c_4jin, "") ,MakeSelProp("4jex", c_4jex, "4jin"), MakeSelProp("5jin", c_5jin, "4jin") ,MakeSelProp("5jex", c_5jex, "5jin"), MakeSelProp("6jin", c_6jin, "5jin") - ,MakeSelProp("6_8jin", c_6_8jin, "6jin"), MakeSelProp("7jin", c_7jin, "6jin") - ,MakeSelProp("6jex", c_6jex, "6_8jin") + ,MakeSelProp("6_8jwin", c_6_8jwin, "6jin"), MakeSelProp("7jin", c_7jin, "6jin") + ,MakeSelProp("6jex", c_6jex, "6_8jwin") ,MakeSelProp("7jex", c_7jex, "7jin"), MakeSelProp("8jin", c_8jin, "7jin") ,MakeSelProp("8jex", c_8jex, "8jin"), MakeSelProp("9jin", c_9jin, "8jin") }); @@ -173,7 +173,7 @@ bool VLQ_Selector::Init(){ MakeSelProp("0Tin",c_0Tin), MakeSelProp("0Tex",c_0Tex), MakeSelProp("1Tex", c_1Tex), MakeSelProp("2Tin", c_2Tin) }); m_sel_H_prop = new std::vector<SelProp>({ - MakeSelProp("0Hex",c_0Hex), MakeSelProp("1Hex", c_1Hex), MakeSelProp("2Hin", c_2Hin) }); + MakeSelProp("0Hex",c_0Hex), MakeSelProp("1Hex", c_1Hex), MakeSelProp("2Hin", c_2Hin), MakeSelProp("0_1Hwin", c_0_1Hwin) }); m_sel_TH_prop = new std::vector<SelProp>({ MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("3THin", c_3THin) }); @@ -268,7 +268,7 @@ bool VLQ_Selector::Init(){ boostlist_0L.insert(boostlist_0L.end(), boostlist_super_merge.begin(), boostlist_super_merge.end()); std::vector<std::string> boostlist_1L_merge = { - "2Tin1Hex", "2Tin0Hex", + "2Tin0_1Hwin", "1Tex1Hex", "1Tex0Hex", "0Tex1Hex", "0Tex0Hex", "0Tin2Hin" }; @@ -305,7 +305,7 @@ bool VLQ_Selector::Init(){ std::vector<std::string> jet_analist_1L{}; if(m_do_fit_reg){ jet_analist_1L.push_back("6jin"); } if(m_do_highj) { - jet_analist_1L.push_back("6_8jin"); + jet_analist_1L.push_back("6_8jwin"); jet_analist_1L.push_back("9jin"); } if(m_do_lowj) { @@ -486,7 +486,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) //============== H-tag part ========================= //Check that the character preceding "H" is a digit (to distinguish this option from "TH" if( ( (sel_name.find("Hin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hin")-1)[0] )) ) - || ( (sel_name.find("Hex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hex")-1)[0] )) ) ){ + || ( (sel_name.find("Hex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hex")-1)[0] )) ) + || ( (sel_name.find("Hwin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hwin")-1)[0] )) ) ){ for(SelProp Hprop : *m_sel_H_prop){ if( sel_name.find(Hprop.name) != std::string::npos ){ sprop_H = &Hprop; @@ -657,7 +658,7 @@ bool VLQ_Selector::PassSelection(const int index){ else if(index == c_7jex){ pass = (m_outData->o_jets_n == 7); } else if(index == c_8jex){ pass = (m_outData->o_jets_n == 8); } - else if(index == c_6_8jin){ pass = (m_outData->o_jets_n >= 6) && (m_outData->o_jets_n <= 8); } + else if(index == c_6_8jwin){ pass = (m_outData->o_jets_n >= 6) && (m_outData->o_jets_n <= 8); } else if(index == c_4jin){ pass = (m_outData->o_jets_n >= 4); } else if(index == c_5jin){ pass = (m_outData->o_jets_n >= 5); } @@ -683,6 +684,7 @@ bool VLQ_Selector::PassSelection(const int index){ else if(index == c_1Hex){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } else if(index == c_1Hin){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") >= 1); } else if(index == c_2Hin){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") >= 2); } + else if(index == c_0_1Hwin){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") == 0 || m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } //=========== B-tag multiplicities ==================== diff --git a/VLQAnalysis/VLQ_Selector.h b/VLQAnalysis/VLQ_Selector.h index 866f0ad..53385b5 100644 --- a/VLQAnalysis/VLQ_Selector.h +++ b/VLQAnalysis/VLQ_Selector.h @@ -27,13 +27,13 @@ public: //=========== Top selections ========================= enum VLQTopSels{ c_1l_chan=1, c_1el_chan, c_1mu_chan, c_0l_chan, - c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8jin, + c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8jwin, c_4jin, c_5jin, c_6jin, c_7jin, c_8jin, c_9jin, c_0bex, c_1bex, c_2bex, c_3bex, c_0bin, c_1bin, c_2bin, c_3bin, c_4bin, c_0Mex, c_1Mex, c_2Min, c_0Tex, c_0Tin, c_1Tex, c_1Tin, c_2Tin, - c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, + c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, c_0_1Hwin, c_0THex, c_1THex, c_2THex, c_3THin, c_LowMtbmin, c_HighMtbmin, c_LowMbb, c_HighMbb, TOPSEL_MAX }; -- GitLab From 3bbdfcb033b33f75676f7d58f26939f8aebe72d8 Mon Sep 17 00:00:00 2001 From: "tfarooque@ifae.es" <tfarooque@at307.pic.es> Date: Thu, 5 Jan 2017 15:04:35 +0100 Subject: [PATCH 5/7] Adding TH selections --- Root/VLQ_Selector.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Root/VLQ_Selector.cxx b/Root/VLQ_Selector.cxx index bd4d928..16280a0 100644 --- a/Root/VLQ_Selector.cxx +++ b/Root/VLQ_Selector.cxx @@ -686,6 +686,10 @@ bool VLQ_Selector::PassSelection(const int index){ else if(index == c_2Hin){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") >= 2); } else if(index == c_0_1Hwin){ pass = (m_outData->o_taggedjets_n.at("RCMHiggs") == 0 || m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } + else if(index == c_0THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 0); } + else if(index == c_1THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } + else if(index == c_2THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 2); } + else if(index == c_3THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 3); } //=========== B-tag multiplicities ==================== else if(index == c_0bex){ pass = m_anaTools->PassBTagRequirement(0, false); } -- GitLab From 6821bbeb3975ccbf2bcb1afca48569e25ecb1f07 Mon Sep 17 00:00:00 2001 From: "lvalery@ifae.es" <lvalery@at305.pic.es> Date: Thu, 5 Jan 2017 17:25:27 +0100 Subject: [PATCH 6/7] Fixing validation regions boosted splitting - Fixing bug for TH regions --- Root/VLQ_Selector.cxx | 223 ++++++++++++++++++------------------- VLQAnalysis/VLQ_Selector.h | 40 +++---- 2 files changed, 130 insertions(+), 133 deletions(-) diff --git a/Root/VLQ_Selector.cxx b/Root/VLQ_Selector.cxx index 16280a0..e9aa7b7 100644 --- a/Root/VLQ_Selector.cxx +++ b/Root/VLQ_Selector.cxx @@ -105,12 +105,11 @@ bool VLQ_Selector::Init(){ std::cout<<" Inside VLQ_Selector::Init()"<<std::endl; } - std::string doRegions = m_opt->DoRegions(); + std::string doRegions = m_opt->DoRegions(); std::string reg; reg.clear(); - int nreg = 0; std::string::size_type pos = 0; - do{ - pos = AnalysisUtils::ParseString(doRegions, reg, ","); + do{ + pos = AnalysisUtils::ParseString(doRegions, reg, ","); AnalysisUtils::TrimString(reg); if (reg == "PRESEL") m_do_presel = true; else if(reg == "VALIDATION") m_do_validn_reg = true; @@ -123,24 +122,24 @@ bool VLQ_Selector::Init(){ else if(reg == "NEWBOOST") m_do_new_boost = true; else if(reg == "MERGEBOOST") m_do_merge_boost = true; else{ std::cout<<"VLQ_Selector::Init() -->WARNING: Unknown region option "<<reg<< std::endl; } - }while(pos != std::string::npos); + }while(pos != std::string::npos); std::cout<< " doRegions = "<<m_opt->DoRegions()<<std::endl; - std::cout<< " m_do_presel = "<< m_do_presel << std::endl; - std::cout<< " m_do_validn_reg = "<< m_do_validn_reg << std::endl; - std::cout<< " m_do_fit_reg = "<< m_do_fit_reg << std::endl; - std::cout<< " m_do_lowb = "<< m_do_lowb << std::endl; - std::cout<< " m_do_split_emu = "<< m_do_split_emu << std::endl; - std::cout<< " m_do_lowj = "<< m_do_lowj << std::endl; - std::cout<< " m_do_highj = "<< m_do_highj << std::endl; - std::cout<< " m_do_old_boost = "<< m_do_old_boost << std::endl; - std::cout<< " m_do_new_boost = "<< m_do_new_boost << std::endl; - std::cout<< " m_do_merge_boost = "<< m_do_merge_boost << std::endl; + std::cout<< " m_do_presel = "<< m_do_presel << std::endl; + std::cout<< " m_do_validn_reg = "<< m_do_validn_reg << std::endl; + std::cout<< " m_do_fit_reg = "<< m_do_fit_reg << std::endl; + std::cout<< " m_do_lowb = "<< m_do_lowb << std::endl; + std::cout<< " m_do_split_emu = "<< m_do_split_emu << std::endl; + std::cout<< " m_do_lowj = "<< m_do_lowj << std::endl; + std::cout<< " m_do_highj = "<< m_do_highj << std::endl; + std::cout<< " m_do_old_boost = "<< m_do_old_boost << std::endl; + std::cout<< " m_do_new_boost = "<< m_do_new_boost << std::endl; + std::cout<< " m_do_merge_boost = "<< m_do_merge_boost << std::endl; //only looking at the very final regions //const bool onlyFinal = m_opt -> OnlyDumpFinalRegions(); - + //============================ Initialise top selections and add rules for primary ancestors ================================== m_sel_indices = new std::map<std::string, int>(); m_sel_names = new std::map<int, std::string>(); @@ -152,19 +151,19 @@ bool VLQ_Selector::Init(){ MakeSelProp("1el", c_1el_chan) , MakeSelProp("1mu", c_1mu_chan) }); m_sel_jet_prop = new std::vector<SelProp>({ - MakeSelProp("4jin", c_4jin, "") - ,MakeSelProp("4jex", c_4jex, "4jin"), MakeSelProp("5jin", c_5jin, "4jin") - ,MakeSelProp("5jex", c_5jex, "5jin"), MakeSelProp("6jin", c_6jin, "5jin") - ,MakeSelProp("6_8jwin", c_6_8jwin, "6jin"), MakeSelProp("7jin", c_7jin, "6jin") - ,MakeSelProp("6jex", c_6jex, "6_8jwin") - ,MakeSelProp("7jex", c_7jex, "7jin"), MakeSelProp("8jin", c_8jin, "7jin") - ,MakeSelProp("8jex", c_8jex, "8jin"), MakeSelProp("9jin", c_9jin, "8jin") }); + MakeSelProp("4jin", c_4jin, "") + ,MakeSelProp("4jex", c_4jex, "4jin"), MakeSelProp("5jin", c_5jin, "4jin") + ,MakeSelProp("5jex", c_5jex, "5jin"), MakeSelProp("6jin", c_6jin, "5jin") + ,MakeSelProp("6_8jwin", c_6_8jwin, "6jin"), MakeSelProp("7jin", c_7jin, "6jin") + ,MakeSelProp("6jex", c_6jex, "6_8jwin") + ,MakeSelProp("7jex", c_7jex, "7jin"), MakeSelProp("8jin", c_8jin, "7jin") + ,MakeSelProp("8jex", c_8jex, "8jin"), MakeSelProp("9jin", c_9jin, "8jin") }); m_sel_bjet_prop = new std::vector<SelProp>({ - MakeSelProp("0bex", c_0bex, ""), MakeSelProp("1bin", c_1bin, "") - ,MakeSelProp("1bex", c_1bex, "1bin"), MakeSelProp("2bin", c_2bin, "1bin") - ,MakeSelProp("2bex", c_2bex, "2bin"), MakeSelProp("3bin", c_3bin, "2bin") - ,MakeSelProp("3bex", c_3bex, "3bin"), MakeSelProp("4bin", c_4bin, "3bin") }); + MakeSelProp("0bex", c_0bex, ""), MakeSelProp("1bin", c_1bin, "") + ,MakeSelProp("1bex", c_1bex, "1bin"), MakeSelProp("2bin", c_2bin, "1bin") + ,MakeSelProp("2bex", c_2bex, "2bin"), MakeSelProp("3bin", c_3bin, "2bin") + ,MakeSelProp("3bex", c_3bex, "3bin"), MakeSelProp("4bin", c_4bin, "3bin") }); m_sel_M_prop = new std::vector<SelProp>({ MakeSelProp("0Mex",c_0Mex), MakeSelProp("1Mex", c_1Mex), MakeSelProp("2Min", c_2Min) }); @@ -176,7 +175,7 @@ bool VLQ_Selector::Init(){ MakeSelProp("0Hex",c_0Hex), MakeSelProp("1Hex", c_1Hex), MakeSelProp("2Hin", c_2Hin), MakeSelProp("0_1Hwin", c_0_1Hwin) }); m_sel_TH_prop = new std::vector<SelProp>({ - MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("3THin", c_3THin) }); + MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("1THin", c_1THin), MakeSelProp("3THin", c_3THin) }); m_sel_Mbb_prop = new std::vector<SelProp>({ MakeSelProp("LowMbb",c_LowMbb), MakeSelProp("HighMbb", c_HighMbb) }); @@ -211,32 +210,32 @@ bool VLQ_Selector::Init(){ if(m_opt->DoOneLeptonAna()){ std::vector<std::string> v_jet_presel = {"5jin"}; if(m_do_lowj){ - v_jet_presel.push_back("4jex"); - v_jet_presel.push_back("4jin"); + v_jet_presel.push_back("4jex"); + v_jet_presel.push_back("4jin"); } for(const std::string& jet : v_jet_presel){ - for(const std::string& bjet : v_bjet_presel){ - AddVLQSelection("c1lep"+jet+bjet, true, false); - if(m_do_split_emu){ - AddVLQSelection("c1lep"+jet+bjet+"_el", true, false); - AddVLQSelection("c1lep"+jet+bjet+"_mu", true, false); - } - }//bjet + for(const std::string& bjet : v_bjet_presel){ + AddVLQSelection("c1lep"+jet+bjet, true, false); + if(m_do_split_emu){ + AddVLQSelection("c1lep"+jet+bjet+"_el", true, false); + AddVLQSelection("c1lep"+jet+bjet+"_mu", true, false); + } + }//bjet }//jet }//1-lep if(m_opt->DoZeroLeptonAna()){ std::vector<std::string> v_jet_presel = {"6jin"}; if(m_do_lowj){ - v_jet_presel.push_back("4jex"); - v_jet_presel.push_back("4jin"); - v_jet_presel.push_back("5jex"); - v_jet_presel.push_back("5jin"); + v_jet_presel.push_back("4jex"); + v_jet_presel.push_back("4jin"); + v_jet_presel.push_back("5jex"); + v_jet_presel.push_back("5jin"); } for(const std::string& jet : v_jet_presel){ - for(const std::string& bjet : v_bjet_presel){ - AddVLQSelection("c0lep"+jet+bjet, true, false); - }//bjet + for(const std::string& bjet : v_bjet_presel){ + AddVLQSelection("c0lep"+jet+bjet, true, false); + }//bjet }//jet }//0-lep @@ -255,23 +254,27 @@ bool VLQ_Selector::Init(){ } if(m_do_new_boost){ std::vector<std::string> boostlist_new = { - "2Tin2Hin", "2Tin1Hex", "2Tin0Hex", - "1Tex2Hin", "1Tex1Hex", "1Tex0Hex", - "0Tex2Hin", "0Tex1Hex", "0Tex0Hex", + "2Tin2Hin", "2Tin1Hex", "2Tin0Hex", + "1Tex2Hin", "1Tex1Hex", "1Tex0Hex", + "0Tex2Hin", "0Tex1Hex", "0Tex0Hex", }; boostlist_0L.insert(boostlist_0L.end(), boostlist_new.begin(), boostlist_new.end()); } if(m_do_merge_boost){ std::vector<std::string> boostlist_super_merge = { - "3THin", "2THex", "1THex", "0THex" + "3THin", "2THex", "1THex", "0THex" }; boostlist_0L.insert(boostlist_0L.end(), boostlist_super_merge.begin(), boostlist_super_merge.end()); std::vector<std::string> boostlist_1L_merge = { - "2Tin0_1Hwin", - "1Tex1Hex", "1Tex0Hex", - "0Tex1Hex", "0Tex0Hex", - "0Tin2Hin" }; + "2Tin0_1Hwin", + "1Tex1Hex", "1Tex0Hex", + "0Tex1Hex", "0Tex0Hex", + "0Tin2Hin" }; + + if(m_do_validn_reg){ + boostlist_1L_merge.push_back("1THin"); + } boostlist_1L.insert(boostlist_1L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); boostlist_0L.insert(boostlist_0L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); } @@ -280,68 +283,60 @@ bool VLQ_Selector::Init(){ std::set<std::string> boostset_1L(boostlist_1L.begin(), boostlist_1L.end()); std::set<std::string> boostset_0L(boostlist_0L.begin(), boostlist_0L.end()); + //0-lepton fit regions if(m_opt->DoZeroLeptonAna()){ std::vector<std::string> jet_analist_0L{}; if(m_do_fit_reg){ jet_analist_0L.push_back("7jin"); } - if(m_do_lowj) { - jet_analist_0L.push_back("4jex"); - jet_analist_0L.push_back("5jex"); + if(m_do_lowj) { + jet_analist_0L.push_back("4jex"); + jet_analist_0L.push_back("5jex"); + } + if(m_do_validn_reg){ + jet_analist_0L.push_back("6jex"); } - if(m_do_validn_reg){ jet_analist_0L.push_back("6jex"); } for( const std::string& jet : jet_analist_0L ){ - for( std::string bjet : bjet_analist ){ - for( std::string boost : boostset_0L ){ - AddVLQSelection("c0lep"+boost+jet+bjet, true, false); - if(m_do_split_mtb){ - AddVLQSelection("c0lep"+boost+jet+bjet+"LowMtbmin", true, false); - AddVLQSelection("c0lep"+boost+jet+bjet+"HighMtbmin", true, false); - }//mbb split - }//boost list - }//ana bjet channels + for( std::string bjet : bjet_analist ){ + for( std::string boost : boostset_0L ){ + AddVLQSelection("c0lep"+boost+jet+bjet, true, false); + if(m_do_split_mtb){ + AddVLQSelection("c0lep"+boost+jet+bjet+"LowMtbmin", true, false); + AddVLQSelection("c0lep"+boost+jet+bjet+"HighMtbmin", true, false); + }//mbb split + }//boost list + }//ana bjet channels }//jet }//0-lepton if(m_opt->DoOneLeptonAna()){ std::vector<std::string> jet_analist_1L{}; - if(m_do_fit_reg){ jet_analist_1L.push_back("6jin"); } - if(m_do_highj) { - jet_analist_1L.push_back("6_8jwin"); - jet_analist_1L.push_back("9jin"); + if(m_do_fit_reg){ + jet_analist_1L.push_back("6jin"); + } + if(m_do_highj) { + jet_analist_1L.push_back("6_8jwin"); + jet_analist_1L.push_back("9jin"); } - if(m_do_lowj) { - jet_analist_1L.push_back("4jex"); + if(m_do_lowj) { + jet_analist_1L.push_back("4jex"); } if(m_do_validn_reg){ jet_analist_1L.push_back("5jex"); } for( const std::string& jet : jet_analist_1L ){ - for( std::string bjet : bjet_analist ){ - for( std::string boost : boostset_1L ){ - AddVLQSelection("c1lep"+boost+jet+bjet, true, false); - //Only do mbb splitting for old mass-tagged jet regions - if(m_do_split_mbb && ( (boost.find("Mex") != std::string::npos) || (boost.find("Min") != std::string::npos) ) ){ - AddVLQSelection("c1lep"+boost+jet+bjet+"LowMbb", true, false); - AddVLQSelection("c1lep"+boost+jet+bjet+"HighMbb", true, false); - }//mbb split - }//boost list - }//ana bjet channels + for( std::string bjet : bjet_analist ){ + for( std::string boost : boostset_1L ){ + AddVLQSelection("c1lep"+boost+jet+bjet, true, false); + //Only do mbb splitting for old mass-tagged jet regions + if(m_do_split_mbb && ( (boost.find("Mex") != std::string::npos) || (boost.find("Min") != std::string::npos) ) ){ + AddVLQSelection("c1lep"+boost+jet+bjet+"LowMbb", true, false); + AddVLQSelection("c1lep"+boost+jet+bjet+"HighMbb", true, false); + }//mbb split + }//boost list + }//ana bjet channels }//jet }//1-lepton }//Fit/validation regions - /* - AddVLQSelection("c1lep4jex2bin", true, false); - AddVLQSelection("c1lep4jin2bin", true, false); - AddVLQSelection("c1lep5jin2bin", true, false); - - AddVLQSelection("c1lep4jex2bin_el", true, false); - AddVLQSelection("c1lep4jin2bin_el", true, false); - AddVLQSelection("c1lep5jin2bin_el", true, false); - - AddVLQSelection("c1lep4jex2bin_mu", true, false); - AddVLQSelection("c1lep4jin2bin_mu", true, false); - AddVLQSelection("c1lep5jin2bin_mu", true, false); - */ return true; } @@ -367,7 +362,6 @@ Selection* VLQ_Selector::AddVLQSelection(const std::string& name, bool do_runop, //______________________________________________________________________________ // Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name){ - if(m_opt->MsgLevel() == Debug::DEBUG){ std::cout<<" VLQ_Selector::MakeSelection with name "<<name<<" and index "<<index<<std::endl; } if( (index < 0) && name.empty() ){ @@ -411,8 +405,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) for(SelProp jetprop : *m_sel_jet_prop){ if( sel_name.find(jetprop.name) != std::string::npos ){ - sprop_jet = &jetprop; - break; + sprop_jet = &jetprop; + break; } } if(sprop_jet == NULL){ @@ -426,8 +420,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if( (sel_name.find("bin") != std::string::npos) || (sel_name.find("bex") != std::string::npos) ){ for(SelProp bjetprop : *m_sel_bjet_prop){ if( sel_name.find(bjetprop.name) != std::string::npos ){ - sprop_bjet = &bjetprop; - break; + sprop_bjet = &bjetprop; + break; } } if(sprop_bjet == NULL){ @@ -441,8 +435,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if( (sel_name.find("Min") != std::string::npos) || (sel_name.find("Mex") != std::string::npos) ){ for(SelProp Mprop : *m_sel_M_prop){ if( sel_name.find(Mprop.name) != std::string::npos ){ - sprop_M = &Mprop; - break; + sprop_M = &Mprop; + break; } } if(sprop_M == NULL){ @@ -456,8 +450,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if( (sel_name.find("THin") != std::string::npos) || (sel_name.find("THex") != std::string::npos) ){ for(SelProp THprop : *m_sel_TH_prop){ if( sel_name.find(THprop.name) != std::string::npos ){ - sprop_TH = &THprop; - break; + sprop_TH = &THprop; + break; } } if(sprop_TH == NULL){ @@ -466,14 +460,15 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) } n_nodes++; } + //============== T-tag part ========================= //Check that the character preceding "T" is a digit - if( ( (sel_name.find("Tin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Tin")-1)[0] )) ) + if( ( (sel_name.find("Tin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Tin")-1)[0] )) ) || ( (sel_name.find("Tex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Tex")-1)[0] )) ) ){ for(SelProp Tprop : *m_sel_T_prop){ if( sel_name.find(Tprop.name) != std::string::npos ){ - sprop_T = &Tprop; - break; + sprop_T = &Tprop; + break; } } if(sprop_T == NULL){ @@ -485,13 +480,13 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) //============== H-tag part ========================= //Check that the character preceding "H" is a digit (to distinguish this option from "TH" - if( ( (sel_name.find("Hin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hin")-1)[0] )) ) + if( ( (sel_name.find("Hin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hin")-1)[0] )) ) || ( (sel_name.find("Hex") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hex")-1)[0] )) ) || ( (sel_name.find("Hwin") != std::string::npos) && (std::isdigit(sel_name.substr(sel_name.find("Hwin")-1)[0] )) ) ){ for(SelProp Hprop : *m_sel_H_prop){ if( sel_name.find(Hprop.name) != std::string::npos ){ - sprop_H = &Hprop; - break; + sprop_H = &Hprop; + break; } } if(sprop_H == NULL){ @@ -506,8 +501,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if(sel_name.find("Mbb") != std::string::npos){ for(SelProp Mbbprop : *m_sel_Mbb_prop){ if( sel_name.find(Mbbprop.name) != std::string::npos ){ - sprop_Mbb = &Mbbprop; - break; + sprop_Mbb = &Mbbprop; + break; } } if(sprop_Mbb == NULL){ @@ -521,8 +516,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if(sel_name.find("Mtb") != std::string::npos){ for(SelProp Mtbprop : *m_sel_Mtb_prop){ if( sel_name.find(Mtbprop.name) != std::string::npos ){ - sprop_Mtb = &Mtbprop; - break; + sprop_Mtb = &Mtbprop; + break; } } if(sprop_Mtb == NULL){ @@ -589,6 +584,7 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) else{ if(sprop_T ){ SelectorBase::AddAncestor(*sel, sprop_T->index); } if(sprop_H ){ SelectorBase::AddAncestor(*sel, sprop_H->index); } + if(sprop_TH ){ SelectorBase::AddAncestor(*sel, sprop_TH->index); } } }//Lep-jet-bjet + boost else{ @@ -689,6 +685,7 @@ bool VLQ_Selector::PassSelection(const int index){ else if(index == c_0THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 0); } else if(index == c_1THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } else if(index == c_2THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 2); } + else if(index == c_1THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 1); } else if(index == c_3THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 3); } //=========== B-tag multiplicities ==================== diff --git a/VLQAnalysis/VLQ_Selector.h b/VLQAnalysis/VLQ_Selector.h index 53385b5..247d721 100644 --- a/VLQAnalysis/VLQ_Selector.h +++ b/VLQAnalysis/VLQ_Selector.h @@ -27,14 +27,14 @@ public: //=========== Top selections ========================= enum VLQTopSels{ c_1l_chan=1, c_1el_chan, c_1mu_chan, c_0l_chan, - c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8jwin, + c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8jwin, c_4jin, c_5jin, c_6jin, c_7jin, c_8jin, c_9jin, c_0bex, c_1bex, c_2bex, c_3bex, c_0bin, c_1bin, c_2bin, c_3bin, c_4bin, - c_0Mex, c_1Mex, c_2Min, + c_0Mex, c_1Mex, c_2Min, c_0Tex, c_0Tin, c_1Tex, c_1Tin, c_2Tin, c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, c_0_1Hwin, - c_0THex, c_1THex, c_2THex, c_3THin, + c_0THex, c_1THex, c_2THex, c_1THin, c_3THin, c_LowMtbmin, c_HighMtbmin, c_LowMbb, c_HighMbb, TOPSEL_MAX }; @@ -45,11 +45,11 @@ public: //=========== Top selections ========================= c_1l_chan, c_1el_chan, c_1mu_chan, c_0l_chan, - c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8j, + c_4jex, c_5jex, c_6jex, c_7jex, c_8jex, c_6_8j, c_4jin, c_5jin, c_6jin, c_7jin, c_8jin, c_9jin, c_0bex, c_1bex, c_2bex, c_3bex, c_0bin, c_1bin, c_2bin, c_3bin, c_4bin, - c_0Mex, c_1Mex, c_2Min, + c_0Mex, c_1Mex, c_2Min, c_0THex, c_0THin, c_1THex, c_1THin, c_2THin, c_0Tex, c_0Tin, c_1Tex, c_1Tin, c_2Tin, c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, @@ -66,7 +66,7 @@ public: inline void SetOutputHistManager(OutputHistManager* outMngrHist){ m_outMngrHist = outMngrHist; } //inline void SetOutputTreeManager(OutputTreeManager* outMngrTree){ m_outMngrTree = outMngrTree; } - + //virtual bool AddFlag(Selection& sel , const std::string& flag, const bool value=true ); //using SelectorBase::AddFlag; //void FillSelIndMap(); @@ -80,9 +80,9 @@ public: int GetSelectionIndex( const std::string& sel_name); std::string GetSelectionName( const int sel_index); - + virtual bool PassSelection( const int index ); - virtual bool RunOperations(const Selection& sel) const; + virtual bool RunOperations(const Selection& sel) const; protected: virtual Selection* MakeSelection( const int index, const std::string& name="" ); @@ -115,18 +115,18 @@ public: bool m_do_split_mtb; bool m_do_split_mbb; - std::map<std::string, int>* m_sel_indices; - std::map<int, std::string>* m_sel_names; - std::vector<SelProp>* m_sel_lep_prop; - std::vector<SelProp>* m_sel_lepflav_prop; - std::vector<SelProp>* m_sel_jet_prop; - std::vector<SelProp>* m_sel_bjet_prop; - std::vector<SelProp>* m_sel_M_prop; - std::vector<SelProp>* m_sel_T_prop; - std::vector<SelProp>* m_sel_H_prop; - std::vector<SelProp>* m_sel_TH_prop; - std::vector<SelProp>* m_sel_Mbb_prop; - std::vector<SelProp>* m_sel_Mtb_prop; + std::map<std::string, int>* m_sel_indices; + std::map<int, std::string>* m_sel_names; + std::vector<SelProp>* m_sel_lep_prop; + std::vector<SelProp>* m_sel_lepflav_prop; + std::vector<SelProp>* m_sel_jet_prop; + std::vector<SelProp>* m_sel_bjet_prop; + std::vector<SelProp>* m_sel_M_prop; + std::vector<SelProp>* m_sel_T_prop; + std::vector<SelProp>* m_sel_H_prop; + std::vector<SelProp>* m_sel_TH_prop; + std::vector<SelProp>* m_sel_Mbb_prop; + std::vector<SelProp>* m_sel_Mtb_prop; //int m_nsel; -- GitLab From 549151094fdaf0757225ef37d11ce0f9f39df720 Mon Sep 17 00:00:00 2001 From: "lvalery@ifae.es" <lvalery@at305.pic.es> Date: Thu, 5 Jan 2017 18:09:54 +0100 Subject: [PATCH 7/7] Fix bug in region definition - Remove useless regions for 1lep --- Root/VLQ_Selector.cxx | 126 +++++++++++++++++++------------------ VLQAnalysis/VLQ_Selector.h | 2 +- 2 files changed, 67 insertions(+), 61 deletions(-) diff --git a/Root/VLQ_Selector.cxx b/Root/VLQ_Selector.cxx index e9aa7b7..27e1081 100644 --- a/Root/VLQ_Selector.cxx +++ b/Root/VLQ_Selector.cxx @@ -175,7 +175,7 @@ bool VLQ_Selector::Init(){ MakeSelProp("0Hex",c_0Hex), MakeSelProp("1Hex", c_1Hex), MakeSelProp("2Hin", c_2Hin), MakeSelProp("0_1Hwin", c_0_1Hwin) }); m_sel_TH_prop = new std::vector<SelProp>({ - MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("1THin", c_1THin), MakeSelProp("3THin", c_3THin) }); + MakeSelProp("0THex",c_0THex), MakeSelProp("1THex", c_1THex), MakeSelProp("2THex", c_2THex), MakeSelProp("2THin", c_2THin), MakeSelProp("3THin", c_3THin) }); m_sel_Mbb_prop = new std::vector<SelProp>({ MakeSelProp("LowMbb",c_LowMbb), MakeSelProp("HighMbb", c_HighMbb) }); @@ -273,7 +273,7 @@ bool VLQ_Selector::Init(){ "0Tin2Hin" }; if(m_do_validn_reg){ - boostlist_1L_merge.push_back("1THin"); + boostlist_1L_merge.push_back("2THin"); } boostlist_1L.insert(boostlist_1L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); boostlist_0L.insert(boostlist_0L.end(), boostlist_1L_merge.begin(), boostlist_1L_merge.end()); @@ -319,11 +319,17 @@ bool VLQ_Selector::Init(){ if(m_do_lowj) { jet_analist_1L.push_back("4jex"); } - if(m_do_validn_reg){ jet_analist_1L.push_back("5jex"); } - + if(m_do_validn_reg){ + jet_analist_1L.push_back("5jex"); + } for( const std::string& jet : jet_analist_1L ){ - for( std::string bjet : bjet_analist ){ - for( std::string boost : boostset_1L ){ + for( const std::string& bjet : bjet_analist ){ + for( const std::string& boost : boostset_1L ){ + //Remove the 2TH merging for the fit regions (only in the validation regions) + if(boost=="2THin" && (jet!="5jex" || bjet!="4bin") ) continue; + //Avoid the too fine splitting in the 4bin VRs + if(jet=="5jex" && bjet=="4bin" && ( boost=="1Tex1Hex" || boost=="2Tin0_1Hwin" || boost=="0Tin2Hin" ) ) continue; + //otherwise, add the region AddVLQSelection("c1lep"+boost+jet+bjet, true, false); //Only do mbb splitting for old mass-tagged jet regions if(m_do_split_mbb && ( (boost.find("Mex") != std::string::npos) || (boost.find("Min") != std::string::npos) ) ){ @@ -539,8 +545,8 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) if( !( (sprop_M==NULL) || ( (sprop_T==NULL) && (sprop_H==NULL) && (sprop_TH==NULL) ) ) ){ std::cerr << " It is inadvisable to apply M-tagged jet cut together "; - std::cerr << "with a cut on T-tagging or H-tagging. Please check selection pattern "; - std::cerr << name << ". Exiting. "<<std::endl; + std::cerr << "with a cut on T-tagging or H-tagging. Please check selection pattern "; + std::cerr << name << ". Exiting. "<<std::endl; return NULL; } @@ -555,57 +561,57 @@ Selection* VLQ_Selector::MakeSelection(const int index, const std::string& name) AddAncestor(*sel, sel_name.substr(0, sel_name.find("_")), true); if(sel_name.find("_el") != std::string::npos){ SelectorBase::AddAncestor(*sel, c_1el_chan); } else if(sel_name.find("_mu") != std::string::npos){ SelectorBase::AddAncestor(*sel, c_1mu_chan); } - }//el/mu channel splitting is done last - else{ - if( !(sprop_bjet || sprop_M || sprop_TH|| sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ - - if(sprop_jet->primanc_name.empty()){ - SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index}, sprop_lep->index); - } - else{ - AddPrimary(*sel, "c"+sprop_lep->name+sprop_jet->primanc_name); - SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index}); - } - - }//Lep + jet - else if( !(sprop_M || sprop_TH || sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ - - if(sprop_bjet->primanc_name.empty()){ - AddAncestor(*sel, "c"+sprop_lep->name+sprop_jet->name, true); - } - else{ - AddPrimary(*sel, "c"+sprop_lep->name+sprop_jet->name+sprop_bjet->primanc_name); - SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index, sprop_bjet->index}); - } - } //Lep + jet + bjet - else if( !(sprop_Mbb || sprop_Mtb) ){ - AddAncestor(*sel, "c"+sprop_lep->name+sprop_jet->name+sprop_bjet->name, true); - if(sprop_M){ SelectorBase::AddAncestor(*sel, sprop_M->index); } - else{ - if(sprop_T ){ SelectorBase::AddAncestor(*sel, sprop_T->index); } - if(sprop_H ){ SelectorBase::AddAncestor(*sel, sprop_H->index); } - if(sprop_TH ){ SelectorBase::AddAncestor(*sel, sprop_TH->index); } - } - }//Lep-jet-bjet + boost - else{ - std::string s_boost = ""; - if(sprop_M){s_boost += sprop_M->name; } - if(sprop_T){s_boost += sprop_T->name; } - if(sprop_H){s_boost += sprop_H->name; } - if(sprop_TH){s_boost += sprop_TH->name; } - - if(sprop_Mbb){ - AddAncestor(*sel, "c" + sprop_lep->name + s_boost + sprop_jet->name + sprop_bjet->name, true); - SelectorBase::AddAncestor(*sel, sprop_Mbb->index); - } - else if(sprop_Mtb){ - AddAncestor(*sel, "c" + sprop_lep->name + s_boost + sprop_jet->name + sprop_bjet->name, true); - SelectorBase::AddAncestor(*sel, sprop_Mtb->index); - } - } - if(m_opt->MsgLevel() == Debug::DEBUG){ std::cout<<" Selection "<<sel_name<<" successfully added"<<std::endl; } - - }//if not el or mu channel + }//el/mu channel splitting is done last + else{ + if( !(sprop_bjet || sprop_M || sprop_TH|| sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ + + if(sprop_jet->primanc_name.empty()){ + SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index}, sprop_lep->index); + } + else{ + AddPrimary(*sel, "c"+sprop_lep->name+sprop_jet->primanc_name); + SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index}); + } + + }//Lep + jet + else if( !(sprop_M || sprop_TH || sprop_T || sprop_H || sprop_Mbb || sprop_Mtb) ){ + + if(sprop_bjet->primanc_name.empty()){ + AddAncestor(*sel, "c"+sprop_lep->name+sprop_jet->name, true); + } + else{ + AddPrimary(*sel, "c"+sprop_lep->name+sprop_jet->name+sprop_bjet->primanc_name); + SelectorBase::AddAncestors(*sel, {sprop_lep->index, sprop_jet->index, sprop_bjet->index}); + } + } //Lep + jet + bjet + else if( !(sprop_Mbb || sprop_Mtb) ){ + AddAncestor(*sel, "c"+sprop_lep->name+sprop_jet->name+sprop_bjet->name, true); + if(sprop_M){ SelectorBase::AddAncestor(*sel, sprop_M->index); } + else{ + if(sprop_T ){ SelectorBase::AddAncestor(*sel, sprop_T->index); } + if(sprop_H ){ SelectorBase::AddAncestor(*sel, sprop_H->index); } + if(sprop_TH ){ SelectorBase::AddAncestor(*sel, sprop_TH->index); } + } + }//Lep-jet-bjet + boost + else{ + std::string s_boost = ""; + if(sprop_M){s_boost += sprop_M->name; } + if(sprop_T){s_boost += sprop_T->name; } + if(sprop_H){s_boost += sprop_H->name; } + if(sprop_TH){s_boost += sprop_TH->name; } + + if(sprop_Mbb){ + AddAncestor(*sel, "c" + sprop_lep->name + s_boost + sprop_jet->name + sprop_bjet->name, true); + SelectorBase::AddAncestor(*sel, sprop_Mbb->index); + } + else if(sprop_Mtb){ + AddAncestor(*sel, "c" + sprop_lep->name + s_boost + sprop_jet->name + sprop_bjet->name, true); + SelectorBase::AddAncestor(*sel, sprop_Mtb->index); + } + } + if(m_opt->MsgLevel() == Debug::DEBUG){ std::cout<<" Selection "<<sel_name<<" successfully added"<<std::endl; } + + }//if not el or mu channel return sel; } @@ -685,7 +691,7 @@ bool VLQ_Selector::PassSelection(const int index){ else if(index == c_0THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 0); } else if(index == c_1THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 1); } else if(index == c_2THex){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") == 2); } - else if(index == c_1THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 1); } + else if(index == c_2THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 2); } else if(index == c_3THin){ pass = (m_outData->o_taggedjets_n.at("RCMTop")+m_outData->o_taggedjets_n.at("RCMHiggs") >= 3); } //=========== B-tag multiplicities ==================== diff --git a/VLQAnalysis/VLQ_Selector.h b/VLQAnalysis/VLQ_Selector.h index 247d721..57c2a0f 100644 --- a/VLQAnalysis/VLQ_Selector.h +++ b/VLQAnalysis/VLQ_Selector.h @@ -34,7 +34,7 @@ public: c_0Mex, c_1Mex, c_2Min, c_0Tex, c_0Tin, c_1Tex, c_1Tin, c_2Tin, c_0Hex, c_0Hin, c_1Hex, c_1Hin, c_2Hin, c_0_1Hwin, - c_0THex, c_1THex, c_2THex, c_1THin, c_3THin, + c_0THex, c_1THex, c_2THex, c_2THin, c_3THin, c_LowMtbmin, c_HighMtbmin, c_LowMbb, c_HighMbb, TOPSEL_MAX }; -- GitLab