diff --git a/interface/Categories.h b/interface/Categories.h index 2480b44..cb95be1 100644 --- a/interface/Categories.h +++ b/interface/Categories.h @@ -8,6 +8,12 @@ class DileptonCategory: public Category { public: const std::vector& getLeptons(const AnalyzersManager& analyzers) const ; const std::vector& getDileptons(const AnalyzersManager& analyzers) const ; + const std::vector& getDileptonMetDijets(const AnalyzersManager& analyzers) const ; + virtual void configure(const edm::ParameterSet& conf) override { + m_analyzer_name = conf.getUntrackedParameter("m_analyzer_name", "hh_analyzer"); + } + private: + std::string m_analyzer_name; }; class MuMuCategory: public DileptonCategory { diff --git a/interface/HHAnalyzer.h b/interface/HHAnalyzer.h index e2f5bc1..0b9df35 100644 --- a/interface/HHAnalyzer.h +++ b/interface/HHAnalyzer.h @@ -61,25 +61,19 @@ class HHAnalyzer: public Framework::Analyzer { } } } + virtual void endJob(MetadataManager&) override; // leptons and dileptons stuff BRANCH(electrons, std::vector); BRANCH(muons, std::vector); BRANCH(leptons, std::vector); - BRANCH(ll, std::vector); BRANCH(met, std::vector); - BRANCH(llmet, std::vector); BRANCH(jets, std::vector); - BRANCH(jj, std::vector); - BRANCH(llmetjj, std::vector); + std::vector ll; + std::vector llmet; + std::vector jj; + std::vector llmetjj; // some few custom candidates, for convenience - // allTight= tight lepton ID, tight lepton Iso, Tight jet ID - BRANCH(llmetjj_allTight_btagL_ht, std::vector); - BRANCH(llmetjj_allTight_btagL_pt, std::vector); - BRANCH(llmetjj_allTight_btagL_csv, std::vector); - BRANCH(llmetjj_allTight_nobtag_ht, std::vector); - BRANCH(llmetjj_allTight_nobtag_pt, std::vector); - BRANCH(llmetjj_allTight_nobtag_csv, std::vector); // Januray 2016: preapproval freezing custom candidates BRANCH(llmetjj_HWWleptons_nobtag_csv, std::vector); BRANCH(llmetjj_HWWleptons_btagL_csv, std::vector); @@ -87,13 +81,13 @@ class HHAnalyzer: public Framework::Analyzer { BRANCH(llmetjj_HWWleptons_btagT_csv, std::vector); // maps - std::vector>& map_l = tree["map_l"].write_with_init>>(lepID::Count * lepIso::Count, std::vector(0)); - std::vector>& map_ll = tree["map_ll"].write_with_init>>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count, std::vector(0)); + std::vector> map_l = std::vector>(lepID::Count * lepIso::Count, std::vector(0)); + std::vector> map_ll = std::vector>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count, std::vector(0)); // FIXME: add enum over met? - std::vector>& map_llmet = tree["map_llmet"].write_with_init>>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count, std::vector(0)); - std::vector>& map_j = tree["map_j"].write_with_init>>(jetID::Count * btagWP::Count, std::vector(0)); - std::vector>& map_jj = tree["map_jj"].write_with_init>>(jetID::Count * jetID::Count * btagWP::Count * btagWP::Count * jetPair::Count, std::vector(0)); - std::vector>& map_llmetjj = tree["map_llmetjj"].write_with_init>>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count * jetID::Count * jetID::Count * btagWP::Count * btagWP::Count * jetPair::Count, std::vector(0)); + std::vector> map_llmet = std::vector>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count, std::vector(0)); + std::vector> map_j = std::vector>(jetID::Count * btagWP::Count, std::vector(0)); + std::vector> map_jj = std::vector>(jetID::Count * jetID::Count * btagWP::Count * btagWP::Count * jetPair::Count, std::vector(0)); + std::vector> map_llmetjj = std::vector>(lepID::Count * lepIso::Count * lepID::Count * lepIso::Count * jetID::Count * jetID::Count * btagWP::Count * btagWP::Count * jetPair::Count, std::vector(0)); virtual void analyze(const edm::Event&, const edm::EventSetup&, const ProducersManager&, const AnalyzersManager&, const CategoryManager&) override; virtual void registerCategories(CategoryManager& manager, const edm::ParameterSet& config) override; @@ -118,6 +112,22 @@ class HHAnalyzer: public Framework::Analyzer { BRANCH(nLeptonsL, unsigned int); BRANCH(nLeptonsT, unsigned int); + float count_has2leptons = 0.; + float count_has2leptons_elel = 0.; + float count_has2leptons_elmu = 0.; + float count_has2leptons_muel = 0.; + float count_has2leptons_mumu = 0.; + float count_has2leptons_1llmetjj = 0.; + float count_has2leptons_elel_1llmetjj = 0.; + float count_has2leptons_elmu_1llmetjj = 0.; + float count_has2leptons_muel_1llmetjj = 0.; + float count_has2leptons_mumu_1llmetjj = 0.; + float count_has2leptons_1llmetjj_2btagM = 0.; + float count_has2leptons_elel_1llmetjj_2btagM = 0.; + float count_has2leptons_elmu_1llmetjj_2btagM = 0.; + float count_has2leptons_muel_1llmetjj_2btagM = 0.; + float count_has2leptons_mumu_1llmetjj_2btagM = 0.; + private: // Producers name std::string m_electrons_producer; diff --git a/plugins/Categories.cc b/plugins/Categories.cc index 0d049e6..48017c4 100644 --- a/plugins/Categories.cc +++ b/plugins/Categories.cc @@ -9,15 +9,20 @@ // ***** ***** ***** const std::vector& DileptonCategory::getLeptons(const AnalyzersManager& analyzers) const { - const HHAnalyzer& hh_analyzer = analyzers.get("hh_analyzer"); + const HHAnalyzer& hh_analyzer = analyzers.get(m_analyzer_name); return hh_analyzer.leptons; } const std::vector& DileptonCategory::getDileptons(const AnalyzersManager& analyzers) const { - const HHAnalyzer& hh_analyzer = analyzers.get("hh_analyzer"); + const HHAnalyzer& hh_analyzer = analyzers.get(m_analyzer_name); return hh_analyzer.ll; } +const std::vector& DileptonCategory::getDileptonMetDijets(const AnalyzersManager& analyzers) const { + const HHAnalyzer& hh_analyzer = analyzers.get(m_analyzer_name); + return hh_analyzer.llmetjj; +} + // ***** ***** ***** // Dilepton Mu-Mu category // ***** ***** ***** @@ -28,12 +33,13 @@ bool MuMuCategory::event_in_category_pre_analyzers(const ProducersManager& produ bool MuMuCategory::event_in_category_post_analyzers(const ProducersManager& producers, const AnalyzersManager& analyzers) const { const std::vector& ll = getDileptons(analyzers); + const std::vector& llmetjj = getDileptonMetDijets(analyzers); bool isMuMu = false; for (unsigned int idilep = 0; idilep < ll.size(); idilep++) { if (ll[idilep].isMuMu) isMuMu = true; } - return (isMuMu); + return (isMuMu && llmetjj.size() > 0); }; void MuMuCategory::register_cuts(CutManager& manager) { @@ -62,12 +68,13 @@ bool ElElCategory::event_in_category_pre_analyzers(const ProducersManager& produ bool ElElCategory::event_in_category_post_analyzers(const ProducersManager& producers, const AnalyzersManager& analyzers) const { const std::vector& ll = getDileptons(analyzers); + const std::vector& llmetjj = getDileptonMetDijets(analyzers); bool isElEl = false; for (unsigned int idilep = 0; idilep < ll.size(); idilep++) { if (ll[idilep].isElEl) isElEl = true; } - return (isElEl); + return (isElEl && llmetjj.size() > 0); }; void ElElCategory::register_cuts(CutManager& manager) { @@ -95,12 +102,13 @@ bool ElMuCategory::event_in_category_pre_analyzers(const ProducersManager& produ bool ElMuCategory::event_in_category_post_analyzers(const ProducersManager& producers, const AnalyzersManager& analyzers) const { const std::vector& ll = getDileptons(analyzers); + const std::vector& llmetjj = getDileptonMetDijets(analyzers); bool isElMu = false; for (unsigned int idilep = 0; idilep < ll.size(); idilep++) { if (ll[idilep].isElMu) isElMu = true; } - return (isElMu); + return (isElMu && llmetjj.size() > 0); }; void ElMuCategory::register_cuts(CutManager& manager) { @@ -126,12 +134,13 @@ bool MuElCategory::event_in_category_pre_analyzers(const ProducersManager& produ bool MuElCategory::event_in_category_post_analyzers(const ProducersManager& producers, const AnalyzersManager& analyzers) const { const std::vector& ll = getDileptons(analyzers); + const std::vector& llmetjj = getDileptonMetDijets(analyzers); bool isMuEl = false; for (unsigned int idilep = 0; idilep < ll.size(); idilep++) { if (ll[idilep].isMuEl) isMuEl = true; } - return (isMuEl); + return (isMuEl && llmetjj.size() > 0); }; void MuElCategory::register_cuts(CutManager& manager) { diff --git a/plugins/HHAnalyzer.cc b/plugins/HHAnalyzer.cc index e7c19d3..26ff720 100644 --- a/plugins/HHAnalyzer.cc +++ b/plugins/HHAnalyzer.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -15,10 +16,12 @@ #define HHANADEBUG 0 void HHAnalyzer::registerCategories(CategoryManager& manager, const edm::ParameterSet& config) { - manager.new_category("mumu", "Category with leading leptons as two muons", config); - manager.new_category("elel", "Category with leading leptons as two electrons", config); - manager.new_category("elmu", "Category with leading leptons as electron, subleading as muon", config); - manager.new_category("muel", "Category with leading leptons as muon, subleading as electron", config); + edm::ParameterSet newconfig = edm::ParameterSet(config); + newconfig.addUntrackedParameter("m_analyzer_name", this->m_name); + manager.new_category("mumu", "Category with leading leptons as two muons", newconfig); + manager.new_category("elel", "Category with leading leptons as two electrons", newconfig); + manager.new_category("elmu", "Category with leading leptons as electron, subleading as muon", newconfig); + manager.new_category("muel", "Category with leading leptons as muon, subleading as electron", newconfig); } @@ -26,6 +29,23 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const float mh = event.isRealData() ? 125.02 : 125.0; LorentzVector null_p4(0., 0., 0., 0.); + const EventProducer& fwevent = producers.get("event"); + float event_weight = fwevent.weight; + float tmp_count_has2leptons = 0.; + float tmp_count_has2leptons_elel = 0.; + float tmp_count_has2leptons_elmu = 0.; + float tmp_count_has2leptons_muel = 0.; + float tmp_count_has2leptons_mumu = 0.; + float tmp_count_has2leptons_1llmetjj = 0.; + float tmp_count_has2leptons_elel_1llmetjj = 0.; + float tmp_count_has2leptons_elmu_1llmetjj = 0.; + float tmp_count_has2leptons_muel_1llmetjj = 0.; + float tmp_count_has2leptons_mumu_1llmetjj = 0.; + float tmp_count_has2leptons_1llmetjj_2btagM = 0.; + float tmp_count_has2leptons_elel_1llmetjj_2btagM = 0.; + float tmp_count_has2leptons_elmu_1llmetjj_2btagM = 0.; + float tmp_count_has2leptons_muel_1llmetjj_2btagM = 0.; + float tmp_count_has2leptons_mumu_1llmetjj_2btagM = 0.; // ***** ***** ***** // Trigger Matching @@ -242,11 +262,24 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const else { fillTriggerEfficiencies(leptons[ilep1], leptons[ilep2], dilep); } - + // Some selection if (!dilep.isOS) continue; if (event.isRealData() && !(leptons[ilep1].hlt_DR_matchedObject < m_hltDRCut && leptons[ilep1].hlt_DR_matchedObject < m_hltDRCut)) continue; + if (!(dilep.id_HWWHWW && dilep.iso_HWWHWW)) + continue; + // Counters + tmp_count_has2leptons = event_weight; + if (dilep.isElEl) + tmp_count_has2leptons_elel = event_weight; + if (dilep.isElMu) + tmp_count_has2leptons_elmu = event_weight; + if (dilep.isElEl) + tmp_count_has2leptons_muel = event_weight; + if (dilep.isElEl) + tmp_count_has2leptons_mumu = event_weight; + // Fill ll.push_back(dilep); } } @@ -304,6 +337,8 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const // ***** // Adding MET(s) // ***** + met.clear(); + llmet.clear(); const METProducer& pf_met = producers.get(m_met_producer); HH::Met mymet; mymet.p4 = pf_met.p4; @@ -458,6 +493,8 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const myjet.gen_b = (alljets.hadronFlavor[ijet]) == 5; // redundant with gen_matched_bHadron defined above myjet.gen_c = (alljets.hadronFlavor[ijet]) == 4; myjet.gen_l = (alljets.hadronFlavor[ijet]) < 4; + if (!myjet.id_L) + continue; jets.push_back(myjet); // filling maps // no jet ID @@ -726,6 +763,11 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const myllmetjj.iso_HWWHWW = ll[ill].iso_HWWHWW; myllmetjj.DR_l_l = ll[ill].DR_l_l; myllmetjj.DPhi_l_l = ll[ill].DPhi_l_l; + myllmetjj.trigger_efficiency = ll[ill].trigger_efficiency; + myllmetjj.trigger_efficiency_downVariated = ll[ill].trigger_efficiency_downVariated; + myllmetjj.trigger_efficiency_downVariated_Arun = ll[ill].trigger_efficiency_downVariated_Arun; + myllmetjj.trigger_efficiency_upVariated = ll[ill].trigger_efficiency_upVariated; + myllmetjj.trigger_efficiency_upVariated_Arun = ll[ill].trigger_efficiency_upVariated_Arun; myllmetjj.ill = ill; myllmetjj.imet = imet; myllmetjj.isNoHF = met[imet].isNoHF; @@ -756,8 +798,32 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const myllmetjj.DPhi_llmet_jj = fabs(ROOT::Math::VectorUtil::DeltaPhi(llmet[illmet].p4, jj[ijj].p4)); myllmetjj.cosThetaStar_CS = fabs(getCosThetaStar_CS(llmet[illmet].p4, jj[ijj].p4)); myllmetjj.MT_fullsystem = myllmetjj.p4.Mt(); + // Some selection if (myllmetjj.minDR_l_j < m_minDR_l_j_Cut) continue; + // Counters + tmp_count_has2leptons_1llmetjj = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_elel_1llmetjj = event_weight; + if (myllmetjj.isElMu) + tmp_count_has2leptons_elmu_1llmetjj = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_muel_1llmetjj = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_mumu_1llmetjj = event_weight; + if (myllmetjj.btag_MM) + { + tmp_count_has2leptons_1llmetjj_2btagM = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_elel_1llmetjj_2btagM = event_weight; + if (myllmetjj.isElMu) + tmp_count_has2leptons_elmu_1llmetjj_2btagM = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_muel_1llmetjj_2btagM = event_weight; + if (myllmetjj.isElEl) + tmp_count_has2leptons_mumu_1llmetjj_2btagM = event_weight; + } + // Fill llmetjj.push_back(myllmetjj); } } @@ -823,40 +889,7 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const } } // Adding some few custom candidates, for convenience - // llmetjj_allTight_btagL - int icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::L, jetID::T, btagWP::L, jetPair::ht); - llmetjj_allTight_btagL_ht.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_btagL_ht.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::L, jetID::T, btagWP::L, jetPair::pt); - llmetjj_allTight_btagL_pt.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_btagL_pt.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::L, jetID::T, btagWP::L, jetPair::csv); - llmetjj_allTight_btagL_csv.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_btagL_csv.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - // llmetjj_allTight_nobtag - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::no, jetID::T, btagWP::no, jetPair::ht); - llmetjj_allTight_nobtag_ht.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_nobtag_ht.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::no, jetID::T, btagWP::no, jetPair::pt); - llmetjj_allTight_nobtag_pt.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_nobtag_pt.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::T, lepIso::T, lepID::T, lepIso::T, jetID::T, btagWP::no, jetID::T, btagWP::no, jetPair::csv); - llmetjj_allTight_nobtag_csv.clear(); - for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) - llmetjj_allTight_nobtag_csv.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); - - - icustom = leplepIDIsojetjetIDbtagWPPair(lepID::HWW, lepIso::HWW, lepID::HWW, lepIso::HWW, jetID::L, btagWP::no, jetID::L, btagWP::no, jetPair::csv); + int icustom = leplepIDIsojetjetIDbtagWPPair(lepID::HWW, lepIso::HWW, lepID::HWW, lepIso::HWW, jetID::L, btagWP::no, jetID::L, btagWP::no, jetPair::csv); llmetjj_HWWleptons_nobtag_csv.clear(); for (unsigned int icandidate = 0; icandidate < map_llmetjj[icustom].size(); icandidate++) llmetjj_HWWleptons_nobtag_csv.push_back(llmetjj[map_llmetjj[icustom][icandidate]]); @@ -927,6 +960,21 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const } } + count_has2leptons += tmp_count_has2leptons; + count_has2leptons_elel += tmp_count_has2leptons_elel; + count_has2leptons_elmu += tmp_count_has2leptons_elmu; + count_has2leptons_muel += tmp_count_has2leptons_muel; + count_has2leptons_mumu += tmp_count_has2leptons_mumu; + count_has2leptons_1llmetjj += tmp_count_has2leptons_1llmetjj; + count_has2leptons_elel_1llmetjj += tmp_count_has2leptons_elel_1llmetjj; + count_has2leptons_elmu_1llmetjj += tmp_count_has2leptons_elmu_1llmetjj; + count_has2leptons_muel_1llmetjj += tmp_count_has2leptons_muel_1llmetjj; + count_has2leptons_mumu_1llmetjj += tmp_count_has2leptons_mumu_1llmetjj; + count_has2leptons_1llmetjj_2btagM += tmp_count_has2leptons_1llmetjj_2btagM; + count_has2leptons_elel_1llmetjj_2btagM += tmp_count_has2leptons_elel_1llmetjj_2btagM; + count_has2leptons_elmu_1llmetjj_2btagM += tmp_count_has2leptons_elmu_1llmetjj_2btagM; + count_has2leptons_muel_1llmetjj_2btagM += tmp_count_has2leptons_muel_1llmetjj_2btagM; + count_has2leptons_mumu_1llmetjj_2btagM += tmp_count_has2leptons_mumu_1llmetjj_2btagM; if (!event.isRealData()) @@ -1450,3 +1498,22 @@ void HHAnalyzer::fillTriggerEfficiencies(const Lepton & lep1, const Lepton & lep dilep.trigger_efficiency_downVariated_Arun = ((nominal - std::sqrt(error_squared_down_Arun)) < 0.)? 0. : nominal - std::sqrt(error_squared_down_Arun); } + +void HHAnalyzer::endJob(MetadataManager& metadata) +{ + metadata.add(this->m_name + "count_has2leptons", count_has2leptons); + metadata.add(this->m_name + "count_has2leptons_elel", count_has2leptons_elel); + metadata.add(this->m_name + "count_has2leptons_elmu", count_has2leptons_elmu); + metadata.add(this->m_name + "count_has2leptons_muel", count_has2leptons_muel); + metadata.add(this->m_name + "count_has2leptons_mumu", count_has2leptons_mumu); + metadata.add(this->m_name + "count_has2leptons_1llmetjj", count_has2leptons_1llmetjj); + metadata.add(this->m_name + "count_has2leptons_elel_1llmetjj", count_has2leptons_elel_1llmetjj); + metadata.add(this->m_name + "count_has2leptons_elmu_1llmetjj", count_has2leptons_elmu_1llmetjj); + metadata.add(this->m_name + "count_has2leptons_muel_1llmetjj", count_has2leptons_muel_1llmetjj); + metadata.add(this->m_name + "count_has2leptons_mumu_1llmetjj", count_has2leptons_mumu_1llmetjj); + metadata.add(this->m_name + "count_has2leptons_1llmetjj_2btagM", count_has2leptons_1llmetjj_2btagM); + metadata.add(this->m_name + "count_has2leptons_elel_1llmetjj_2btagM", count_has2leptons_elel_1llmetjj_2btagM); + metadata.add(this->m_name + "count_has2leptons_elmu_1llmetjj_2btagM", count_has2leptons_elmu_1llmetjj_2btagM); + metadata.add(this->m_name + "count_has2leptons_muel_1llmetjj_2btagM", count_has2leptons_muel_1llmetjj_2btagM); + metadata.add(this->m_name + "count_has2leptons_mumu_1llmetjj_2btagM", count_has2leptons_mumu_1llmetjj_2btagM); +}