Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync changes #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions interface/ttHAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cp3_llbb/Framework/interface/HLTProducer.h>

#include <Math/VectorUtil.h>

#include <TH1.h>
#include <random>

using namespace ttH;
Expand All @@ -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<std::string>("electronsProducer");
m_muons_producer = config.getParameter<std::string>("muonsProducer");
Expand Down Expand Up @@ -77,22 +80,26 @@ class ttHAnalyzer: public Framework::Analyzer {
BRANCH(leptons, std::vector<ttH::Lepton>);
BRANCH(met, std::vector<ttH::Met>);
BRANCH(jets, std::vector<ttH::Jet>);

std::vector<ttH::Lepton> selElectrons;
std::vector<ttH::Lepton> selMuons;
//std::vector<ttH::Lepton> selleptons;
std::vector<ttH::Dilepton> ll;
std::vector<ttH::DileptonMet> llmet;
std::vector<ttH::Dijet> jj;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is usually desirable to not have whiteline removed/added without a specific reason.

I am usually personally quite indifferent to that, but there are very picky persons here and there :)

The general idea is that if you don't really need to remove/add a whiteline there, then there is no reason for having it.


//std::vector<ttH::DileptonMetDijet> llmetjj;
//std::vector<ttH::DileptonMetDijet> llmetjj_cmva;

// some few custom candidates, for convenience
// Januray 2016: preapproval freezing custom candidates
//BRANCH(llmetjj_HWWleptons_nobtag_cmva, std::vector<ttH::DileptonMetDijet>);
//BRANCH(llmetjj_HWWleptons_btagL_cmva, std::vector<ttH::DileptonMetDijet>);
//BRANCH(llmetjj_HWWleptons_btagM_cmva, std::vector<ttH::DileptonMetDijet>);
//BRANCH(llmetjj_HWWleptons_btagT_cmva, std::vector<ttH::DileptonMetDijet>);

//// October 2016: adding some asymmetric btag candidates, for study
//BRANCH(llmetjj_HWWleptons_btagLM_cmva, std::vector<ttH::DileptonMetDijet>);
//BRANCH(llmetjj_HWWleptons_btagMT_cmva, std::vector<ttH::DileptonMetDijet>);

BRANCH(llmetjj, std::vector<ttH::DileptonMetDijet>);

virtual void analyze(const edm::Event&, const edm::EventSetup&, const ProducersManager&, const AnalyzersManager&, const CategoryManager&) override;
Expand Down Expand Up @@ -236,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;
Expand Down
34 changes: 26 additions & 8 deletions plugins/ttHAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include <cp3_llbb/Framework/interface/HLTProducer.h>

#include <cmath>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, whiteline should be added back

#include <vector>
#include <TCanvas.h>
#define ttH_GEN_DEBUG (false)
#define TT_GEN_DEBUG (false)

Expand All @@ -26,7 +27,6 @@ void ttHAnalyzer::registerCategories(CategoryManager& manager, const edm::Parame
manager.new_category<MuElCategory>("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
Expand All @@ -37,15 +37,13 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
jj.clear();
//llmetjj.clear();
//llmetjj_cmva.clear();

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whiteline

const JetsProducer& alljets = producers.get<JetsProducer>(m_jets_producer);
const ElectronsProducer& allelectrons = producers.get<ElectronsProducer>(m_electrons_producer);
const MuonsProducer& allmuons = producers.get<MuonsProducer>(m_muons_producer);
const EventProducer& fwevent = producers.get<EventProducer>("event");
const HLTProducer& hlt = producers.get<HLTProducer>("hlt");
const METProducer& pf_met = producers.get<METProducer>(m_met_producer);


if (!event.isRealData()) {

// FIXME Moriond 2017
Expand Down Expand Up @@ -339,9 +337,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)
{

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whiteline

// some selection
// Ask for medium ID
if (!allelectrons.ids[ielectron][m_electron_medium_wp_name])
// Ask for loose ID
// for(auto& mapelement : allelectrons.ids[ielectron])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation should be maintained

// {
// std::cout << mapelement.first << std::endl;
// }

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whiteline not needed

if (!allelectrons.ids[ielectron][m_electron_loose_wp_name])
continue;

ttH::Lepton ele;
Expand All @@ -360,11 +364,18 @@ 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

//histo is defined in the header file and added as a class member

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two whitelines

int nElectrons=leptons.size(); //leptons is first filled by ele
if (nElectrons==1) m_f1->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++)
{
if (allmuons.p4[imuon].Pt() > m_subleadingMuonPtCut
Expand All @@ -388,7 +399,9 @@ void ttHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
mu.hlt_leg2 = false;

leptons.push_back(mu);
//selMuons.push_back(mu);
}

}//end of loop on muons

// sort leptons by pt (ignoring flavour, id and iso)
Expand Down Expand Up @@ -496,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;});

Expand Down Expand Up @@ -1312,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);
Expand All @@ -1329,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;
}

13 changes: 10 additions & 3 deletions test/ttHConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
enable = cms.bool(True),
categories_parameters = cms.PSet(
# Per-category lepton pt cuts
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't understand this commit. I don't remember I touched that intentionally :)

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
Expand All @@ -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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whiteline

#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"),
Expand Down Expand Up @@ -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))