Skip to content

Commit

Permalink
Merge pull request #115 from blinkseb/cmvav2
Browse files Browse the repository at this point in the history
Move to cMVAv2 b-tagging discriminant
  • Loading branch information
OlivierBondu authored Dec 14, 2016
2 parents f37d854 + 4a0b656 commit 7739d4c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 50 deletions.
14 changes: 7 additions & 7 deletions interface/HHAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ class HHAnalyzer: public Framework::Analyzer {
std::vector<HH::DileptonMet> llmet;
std::vector<HH::Dijet> jj;
std::vector<HH::DileptonMetDijet> llmetjj;
std::vector<HH::DileptonMetDijet> llmetjj_csv;
std::vector<HH::DileptonMetDijet> llmetjj_cmva;
// some few custom candidates, for convenience
// Januray 2016: preapproval freezing custom candidates
BRANCH(llmetjj_HWWleptons_nobtag_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagL_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagM_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagT_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_nobtag_cmva, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagL_cmva, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagM_cmva, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagT_cmva, std::vector<HH::DileptonMetDijet>);
// October 2016: adding some asymmetric btag candidates, for study
BRANCH(llmetjj_HWWleptons_btagLM_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagMT_csv, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagLM_cmva, std::vector<HH::DileptonMetDijet>);
BRANCH(llmetjj_HWWleptons_btagMT_cmva, std::vector<HH::DileptonMetDijet>);

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;
Expand Down
4 changes: 2 additions & 2 deletions interface/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace HH {
bool btag_M;
bool btag_T;
float CSV;
float JP;
float CMVAv2;
bool gen_matched_bParton;
bool gen_matched_bHadron;
bool gen_matched;
Expand Down Expand Up @@ -149,7 +149,7 @@ namespace HH {
bool btag_TM;
bool btag_TT;
float sumCSV;
float sumJP;
float sumCMVAv2;
float DR_j_j;
float DPhi_j_j;
float ht_j_j;
Expand Down
60 changes: 32 additions & 28 deletions plugins/HHAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
myjet.id_T = alljets.passTightID[ijet];
myjet.id_TLV = alljets.passTightLeptonVetoID[ijet];
myjet.CSV = alljets.getBTagDiscriminant(ijet, "pfCombinedInclusiveSecondaryVertexV2BJetTags");
myjet.JP = alljets.getBTagDiscriminant(ijet, "pfJetProbabilityBJetTags");
myjet.CMVAv2 = alljets.getBTagDiscriminant(ijet, "pfCombinedMVAV2BJetTags");
float mybtag = alljets.getBTagDiscriminant(ijet, m_jet_bDiscrName);
myjet.btag_L = mybtag > m_jet_bDiscrCut_loose;
myjet.btag_M = mybtag > m_jet_bDiscrCut_medium;
Expand Down Expand Up @@ -439,7 +439,7 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
myjj.btag_TM = (jets[ijet1].btag_T && jets[ijet2].btag_M) || (jets[ijet2].btag_T && jets[ijet1].btag_M);
myjj.btag_TT = jets[ijet1].btag_T && jets[ijet2].btag_T;
myjj.sumCSV = jets[ijet1].CSV + jets[ijet2].CSV;
myjj.sumJP = jets[ijet1].JP + jets[ijet2].JP;
myjj.sumCMVAv2 = jets[ijet1].CMVAv2 + jets[ijet2].CMVAv2;
myjj.DR_j_j = ROOT::Math::VectorUtil::DeltaR(jets[ijet1].p4, jets[ijet2].p4);
myjj.DPhi_j_j = fabs(ROOT::Math::VectorUtil::DeltaPhi(jets[ijet1].p4, jets[ijet2].p4));
myjj.ht_j_j = jets[ijet1].p4.Pt() + jets[ijet2].p4.Pt();
Expand Down Expand Up @@ -515,7 +515,7 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
myllmetjj.btag_TM = jj[ijj].btag_TM;
myllmetjj.btag_TT = jj[ijj].btag_TT;
myllmetjj.sumCSV = jj[ijj].sumCSV;
myllmetjj.sumJP = jj[ijj].sumJP;
myllmetjj.sumCMVAv2 = jj[ijj].sumCMVAv2;
myllmetjj.DR_j_j = jj[ijj].DR_j_j;
myllmetjj.DPhi_j_j = jj[ijj].DPhi_j_j;
myllmetjj.ht_j_j = jj[ijj].ht_j_j;
Expand Down Expand Up @@ -645,36 +645,40 @@ void HHAnalyzer::analyze(const edm::Event& event, const edm::EventSetup&, const
}



// Sort the collections
// llmetjj_ht.clear(); llmetjj_ht = llmetjj;
// llmetjj_pt.clear(); llmetjj_pt = llmetjj;
// llmetjj_mh.clear(); llmetjj_mh = llmetjj;
llmetjj_csv.clear(); llmetjj_csv = llmetjj;
// llmetjj_ptOverM.clear(); llmetjj_ptOverM = llmetjj;
// std::sort(llmetjj_ht.begin(), llmetjj_ht.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){return (a.jet1_p4.Pt() + a.jet2_p4.Pt()) > (b.jet1_p4.Pt() + bjet2_p4.Pt());});
// std::sort(llmetjj_pt.begin(), llmetjj_pt.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){return a.jj_p4.Pt() > b.jj_p4.Pt();});
// std::sort(llmetjj_mh.begin(), llmetjj_mh.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){return fabs(a.jj_p4.M() - mh) > fabs(b.jj_p4.M() - mh);});
std::sort(llmetjj_csv.begin(), llmetjj_csv.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){return a.sumCSV > b.sumCSV;});
// std::sort(llmetjj_ptOverM.begin(), llmetjj_ptOverM.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){return (a.jj_p4.Pt() / a.jj_p4.M()) > (b.jj_p4.Pt() / b.jj_p4.M());});
llmetjj_cmva.clear();
llmetjj_cmva = llmetjj;

std::sort(llmetjj_cmva.begin(), llmetjj_cmva.end(), [&](HH::DileptonMetDijet& a, const HH::DileptonMetDijet& b){ return a.sumCMVAv2 > b.sumCMVAv2; });

// Adding some few custom candidates, for convenience
for (auto &myllmetjj_csv: llmetjj_csv) {
if (!myllmetjj_csv.id_HWWHWW) continue;
if (!myllmetjj_csv.iso_HWWHWW) continue;
for (auto &myllmetjj_cmva: llmetjj_cmva) {

if (!myllmetjj_cmva.id_HWWHWW)
continue;

if (!myllmetjj_cmva.iso_HWWHWW)
continue;

// jetID::L is enforced while filling the jet collection
llmetjj_HWWleptons_nobtag_csv.push_back(myllmetjj_csv);
if (myllmetjj_csv.btag_LL)
llmetjj_HWWleptons_btagL_csv.push_back(myllmetjj_csv);
if (myllmetjj_csv.btag_MM)
llmetjj_HWWleptons_btagM_csv.push_back(myllmetjj_csv);
if (myllmetjj_csv.btag_TT)
llmetjj_HWWleptons_btagT_csv.push_back(myllmetjj_csv);

llmetjj_HWWleptons_nobtag_cmva.push_back(myllmetjj_cmva);

if (myllmetjj_cmva.btag_LL)
llmetjj_HWWleptons_btagL_cmva.push_back(myllmetjj_cmva);

if (myllmetjj_cmva.btag_MM)
llmetjj_HWWleptons_btagM_cmva.push_back(myllmetjj_cmva);

if (myllmetjj_cmva.btag_TT)
llmetjj_HWWleptons_btagT_cmva.push_back(myllmetjj_cmva);

// October 2016: asymmetric btag candidates
if (myllmetjj_csv.btag_LM || myllmetjj_csv.btag_ML)
llmetjj_HWWleptons_btagLM_csv.push_back(myllmetjj_csv);
if (myllmetjj_csv.btag_MT || myllmetjj_csv.btag_TM)
llmetjj_HWWleptons_btagMT_csv.push_back(myllmetjj_csv);
if (myllmetjj_cmva.btag_LM || myllmetjj_cmva.btag_ML)
llmetjj_HWWleptons_btagLM_cmva.push_back(myllmetjj_cmva);

if (myllmetjj_cmva.btag_MT || myllmetjj_cmva.btag_TM)
llmetjj_HWWleptons_btagMT_cmva.push_back(myllmetjj_cmva);
}


Expand Down
33 changes: 24 additions & 9 deletions src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
<lcgdict>
<class name="HH::Lepton">
<field name="hlt_already_tried_matching" transient="true"/>
<class name="HH::Lepton" ClassVersion="10">
<version ClassVersion="10" checksum="1833596599"/>
<field name="hlt_already_tried_matching" transient="true"/>
</class>
<class name="std::vector<HH::Lepton>"/>
<class name="HH::Dilepton"/>
<class name="HH::Dilepton" ClassVersion="10">
<version ClassVersion="10" checksum="2433355583"/>
</class>
<class name="std::vector<HH::Dilepton>"/>
<class name="HH::Met"/>
<class name="HH::Met" ClassVersion="10">
<version ClassVersion="10" checksum="1356748875"/>
</class>
<class name="std::vector<HH::Met>"/>
<class name="HH::DileptonMet"/>
<class name="HH::DileptonMet" ClassVersion="10">
<version ClassVersion="10" checksum="2202889764"/>
</class>
<class name="std::vector<HH::DileptonMet>"/>
<class name="std::vector< std::vector<int> >"/>
<class name="HH::Jet"/>
<class name="HH::Jet" ClassVersion="10">
<version ClassVersion="10" checksum="194867656"/>
</class>
<class name="std::vector<HH::Jet>"/>
<class name="HH::Dijet"/>
<class name="HH::Dijet" ClassVersion="10">
<version ClassVersion="10" checksum="2119876344"/>
</class>
<class name="std::vector<HH::Dijet>"/>
<class name="HH::DileptonMetDijet"/>
<class name="HH::DileptonMetDijet" ClassVersion="10">
<version ClassVersion="10" checksum="1966451846"/>
</class>
<class name="std::vector<HH::DileptonMetDijet>"/>
<class name="std::pair<int8_t, int8_t>"/>
<class name="HH::MELAAngles"/>
<class name="HH::MELAAngles" ClassVersion="10">
<version ClassVersion="10" checksum="2939888277"/>
</class>
</lcgdict>
11 changes: 7 additions & 4 deletions test/HHConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@
electrons_hlt_safe_wp_name = cms.untracked.string("cutBasedElectronHLTPreselection-Summer16-V1"),
jetEtaCut = cms.untracked.double(2.4),
jetPtCut = cms.untracked.double(20),

# BTAG INFO
discr_name = cms.untracked.string("pfCombinedInclusiveSecondaryVertexV2BJetTags"),
discr_cut_loose = cms.untracked.double(0.460),
discr_cut_medium = cms.untracked.double(0.800),
discr_cut_tight = cms.untracked.double(0.935),
# Working points from https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagRecommendation80X
discr_name = cms.untracked.string("pfCombinedMVAV2BJetTags"),
discr_cut_loose = cms.untracked.double(-0.715),
discr_cut_medium = cms.untracked.double(0.185),
discr_cut_tight = cms.untracked.double(0.875),

minDR_l_j_Cut = cms.untracked.double(0.3),
hltDRCut = cms.untracked.double(0.1),
hltDPtCut = cms.untracked.double(0.5), # cut will be DPt/Pt < hltDPtCut
Expand Down

0 comments on commit 7739d4c

Please sign in to comment.