From 24f5a97c1cb4fba82f9ee2e029b60840d1af57b2 Mon Sep 17 00:00:00 2001 From: "Hesham El Faham (hesham.elfaham@uclouvain.be)" Date: Thu, 7 Feb 2019 15:49:15 +0100 Subject: [PATCH 1/2] sync changes --- interface/ttHAnalyzer.h | 7 ++++++- plugins/ttHAnalyzer.cc | 23 +++++++++++++++++++---- test/ttHConfiguration.py | 13 ++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/interface/ttHAnalyzer.h b/interface/ttHAnalyzer.h index 36357f5..0426ac5 100644 --- a/interface/ttHAnalyzer.h +++ b/interface/ttHAnalyzer.h @@ -77,10 +77,15 @@ class ttHAnalyzer: public Framework::Analyzer { BRANCH(leptons, std::vector); BRANCH(met, std::vector); BRANCH(jets, std::vector); + + + //std::vector selElectrons; + //std::vector selMuons; + //std::vector selleptons; + std::vector ll; std::vector llmet; std::vector jj; - //std::vector llmetjj; //std::vector llmetjj_cmva; // some few custom candidates, for convenience diff --git a/plugins/ttHAnalyzer.cc b/plugins/ttHAnalyzer.cc index e698c1a..1ae8eb0 100644 --- a/plugins/ttHAnalyzer.cc +++ b/plugins/ttHAnalyzer.cc @@ -13,10 +13,11 @@ #include #include - +#include #define ttH_GEN_DEBUG (false) #define TT_GEN_DEBUG (false) + void ttHAnalyzer::registerCategories(CategoryManager& manager, const edm::ParameterSet& config) { edm::ParameterSet newconfig = edm::ParameterSet(config); newconfig.addUntrackedParameter("m_analyzer_name", this->m_name); @@ -37,7 +38,6 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const jj.clear(); //llmetjj.clear(); //llmetjj_cmva.clear(); - const JetsProducer& alljets = producers.get(m_jets_producer); const ElectronsProducer& allelectrons = producers.get(m_electrons_producer); const MuonsProducer& allmuons = producers.get(m_muons_producer); @@ -339,9 +339,15 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const if (allelectrons.p4[ielectron].Pt() > m_subleadingElectronPtCut && fabs(allelectrons.p4[ielectron].Eta()) < m_electronEtaCut) { + // some selection // Ask for medium ID - if (!allelectrons.ids[ielectron][m_electron_medium_wp_name]) + // for(auto& mapelement : allelectrons.ids[ielectron]) + // { + // std::cout << mapelement.first << std::endl; + // } + + if (!allelectrons.ids[ielectron][m_electron_loose_wp_name]) continue; ttH::Lepton ele; @@ -361,10 +367,18 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const ele.sc_eta = allelectrons.products[ielectron]->superCluster()->eta(); + leptons.push_back(ele); + //selElectrons.push_back(ele); } + }//end of loop on electrons + int nElectrons=leptons.size(); + //std::cout<<" # of ele: "<< nElectrons < m_subleadingMuonPtCut @@ -389,8 +403,9 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const leptons.push_back(mu); } + //int nMuons=selMuons.size(); + // if(nMuons!=1) continue; }//end of loop on muons - // sort leptons by pt (ignoring flavour, id and iso) std::sort(leptons.begin(), leptons.end(), [](const ttH::Lepton& lep1, const ttH::Lepton& lep2) { return lep1.p4.Pt() > lep2.p4.Pt(); }); diff --git a/test/ttHConfiguration.py b/test/ttHConfiguration.py index 2018ad1..fc7fc69 100644 --- a/test/ttHConfiguration.py +++ b/test/ttHConfiguration.py @@ -30,7 +30,7 @@ enable = cms.bool(True), categories_parameters = cms.PSet( # Per-category lepton pt cuts - mumu_leadingLeptonPtCut = cms.untracked.double(20), # muon + mumu_leadingLeptonPtCut = cms.untracked.double(0), # muon mumu_subleadingLeptonPtCut = cms.untracked.double(10), # muon elel_leadingLeptonPtCut = cms.untracked.double(25), # electron elel_subleadingLeptonPtCut = cms.untracked.double(15), # electron @@ -57,7 +57,14 @@ muonLooseIsoCut = cms.untracked.double(.25), # https://twiki.cern.ch/twiki/bin/view/CMS/TopMUO muonTightIsoCut = cms.untracked.double(.15), # https://twiki.cern.ch/twiki/bin/view/CMS/TopMUO muonEtaCut = cms.untracked.double(2.4), - electrons_loose_wp_name = cms.untracked.string("cutBasedElectronID-Summer16-80X-V1-loose"), + #electrons_loose_wp_name = cms.untracked.string("cutBasedElectronID-Summer16-80X-V1-loose"), #old working point + + #cutBasedElectronID-Fall17-94X-V2-loose + #cutBasedElectronID-Fall17-94X-V2-medium + #cutBasedElectronID-Fall17-94X-V2-tight + #cutBasedElectronID-Fall17-94X-V2-veto + + electrons_loose_wp_name = cms.untracked.string("cutBasedElectronID-Fall17-94X-V2-loose"), #new working point electrons_medium_wp_name = cms.untracked.string("cutBasedElectronID-Summer16-80X-V1-medium"), electrons_tight_wp_name = cms.untracked.string("cutBasedElectronID-Summer16-80X-V1-tight"), electrons_hlt_safe_wp_name = cms.untracked.string("cutBasedElectronHLTPreselection-Summer16-V1"), @@ -142,4 +149,4 @@ #process.MessageLogger.cerr.FwkReport.reportEvery = 1 #process.source.skipEvents = cms.untracked.uint32(10) -process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1000)) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1)) From 9562cdb097a355433b0e96ec94208e862421e1a6 Mon Sep 17 00:00:00 2001 From: "Hesham El Faham (hesham.elfaham@uclouvain.be)" Date: Tue, 12 Feb 2019 11:08:52 +0100 Subject: [PATCH 2/2] sync modifications (2) --- interface/ttHAnalyzer.h | 16 ++++++++++------ plugins/ttHAnalyzer.cc | 29 ++++++++++++++++------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/interface/ttHAnalyzer.h b/interface/ttHAnalyzer.h index 0426ac5..0903073 100644 --- a/interface/ttHAnalyzer.h +++ b/interface/ttHAnalyzer.h @@ -11,7 +11,7 @@ #include #include - +#include #include using namespace ttH; @@ -22,6 +22,9 @@ class ttHAnalyzer: public Framework::Analyzer { ttHAnalyzer(const std::string& name, const ROOT::TreeGroup& tree_, const edm::ParameterSet& config): Analyzer(name, tree_, config), random_generator(42), br_generator(0, 1) { + + m_f = TFile::Open("htest.root","RECREATE"); //new root file + m_f1 = new TH1F ("f1","object",3,0.,3. ); //new histo // Not untracked as these parameters are mandatory m_electrons_producer = config.getParameter("electronsProducer"); m_muons_producer = config.getParameter("muonsProducer"); @@ -78,26 +81,25 @@ class ttHAnalyzer: public Framework::Analyzer { BRANCH(met, std::vector); BRANCH(jets, std::vector); - - //std::vector selElectrons; - //std::vector selMuons; + std::vector selElectrons; + std::vector selMuons; //std::vector selleptons; - std::vector ll; std::vector llmet; std::vector jj; //std::vector llmetjj; //std::vector llmetjj_cmva; + // some few custom candidates, for convenience // Januray 2016: preapproval freezing custom candidates //BRANCH(llmetjj_HWWleptons_nobtag_cmva, std::vector); //BRANCH(llmetjj_HWWleptons_btagL_cmva, std::vector); //BRANCH(llmetjj_HWWleptons_btagM_cmva, std::vector); //BRANCH(llmetjj_HWWleptons_btagT_cmva, std::vector); + //// October 2016: adding some asymmetric btag candidates, for study //BRANCH(llmetjj_HWWleptons_btagLM_cmva, std::vector); //BRANCH(llmetjj_HWWleptons_btagMT_cmva, std::vector); - BRANCH(llmetjj, std::vector); virtual void analyze(const edm::Event&, const edm::EventSetup&, const ProducersManager&, const AnalyzersManager&, const CategoryManager&) override; @@ -241,6 +243,8 @@ class ttHAnalyzer: public Framework::Analyzer { private: + TFile *m_f; //declaring the file in ttHAnalyzer.cc by adding it as a class member + TH1F *m_f1; //same for histo // Producers name std::string m_electrons_producer; std::string m_muons_producer; diff --git a/plugins/ttHAnalyzer.cc b/plugins/ttHAnalyzer.cc index 1ae8eb0..6a98f6a 100644 --- a/plugins/ttHAnalyzer.cc +++ b/plugins/ttHAnalyzer.cc @@ -14,10 +14,10 @@ #include #include +#include #define ttH_GEN_DEBUG (false) #define TT_GEN_DEBUG (false) - void ttHAnalyzer::registerCategories(CategoryManager& manager, const edm::ParameterSet& config) { edm::ParameterSet newconfig = edm::ParameterSet(config); newconfig.addUntrackedParameter("m_analyzer_name", this->m_name); @@ -27,7 +27,6 @@ void ttHAnalyzer::registerCategories(CategoryManager& manager, const edm::Parame manager.new_category("muel", "Category with leading leptons as muon, subleading as electron", newconfig); } - void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const ProducersManager& producers, const AnalyzersManager&, const CategoryManager&) { // Reset event @@ -45,7 +44,6 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const const HLTProducer& hlt = producers.get("hlt"); const METProducer& pf_met = producers.get(m_met_producer); - if (!event.isRealData()) { // FIXME Moriond 2017 @@ -341,7 +339,7 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const { // some selection - // Ask for medium ID + // Ask for loose ID // for(auto& mapelement : allelectrons.ids[ielectron]) // { // std::cout << mapelement.first << std::endl; @@ -366,18 +364,17 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const ele.hlt_leg2 = false; ele.sc_eta = allelectrons.products[ielectron]->superCluster()->eta(); - - + leptons.push_back(ele); //selElectrons.push_back(ele); } - }//end of loop on electrons - int nElectrons=leptons.size(); - //std::cout<<" # of ele: "<< nElectrons <Fill(0); //filling the histo m_f1 bin 0 + m_f1->Draw(); //drawing the histo for (unsigned int imuon = 0; imuon < allmuons.p4.size(); imuon++) { @@ -402,10 +399,11 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const mu.hlt_leg2 = false; leptons.push_back(mu); + //selMuons.push_back(mu); } - //int nMuons=selMuons.size(); - // if(nMuons!=1) continue; + }//end of loop on muons + // sort leptons by pt (ignoring flavour, id and iso) std::sort(leptons.begin(), leptons.end(), [](const ttH::Lepton& lep1, const ttH::Lepton& lep2) { return lep1.p4.Pt() > lep2.p4.Pt(); }); @@ -511,6 +509,7 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const ll.push_back(dilep); } } + // have the ll collection sorted by ht std::sort(ll.begin(), ll.end(), [&](ttH::Dilepton& a, ttH::Dilepton& b){return a.ht_l_l > b.ht_l_l;}); @@ -1327,7 +1326,6 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const } void ttHAnalyzer::endJob(MetadataManager& metadata) { - if (! doingSystematics()) { metadata.add(this->m_name + "_count_has2leptons", count_has2leptons); metadata.add(this->m_name + "_count_has2leptons_elel", count_has2leptons_elel); @@ -1344,5 +1342,10 @@ void ttHAnalyzer::endJob(MetadataManager& metadata) { 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); + } + m_f1->Write(); //writing the histo to htest.root + m_f->Close(); //closing htest.root which is defined in header and added as a class member + delete m_f; } +