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

Jet ID update to the Run2017 prescription #22323

Merged
merged 4 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
190 changes: 174 additions & 16 deletions PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {

public: // interface

enum Version_t { FIRSTDATA, RUNIISTARTUP, WINTER16, N_VERSIONS };
enum Quality_t { LOOSE, TIGHT, N_QUALITY};
enum Version_t { FIRSTDATA, RUNIISTARTUP, WINTER16, WINTER17, N_VERSIONS };
enum Quality_t { LOOSE, TIGHT, TIGHTLEPVETO, N_QUALITY};

PFJetIDSelectionFunctor() {}

Expand All @@ -48,17 +48,20 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
// WINTER16 implements most recent (as of Feb 2017) JetID criteria
// See: https://twiki.cern.ch/twiki/bin/view/CMS/JetID13TeVRun2016
else if( versionStr == "WINTER16")
version_ = WINTER16;
else version_ = WINTER16;//set WINTER16 as default
version_ = WINTER16;
else if( versionStr == "WINTER17")
version_ = WINTER17;
else version_ = WINTER17;//set WINTER17 as default


if ( qualityStr == "LOOSE") quality_ = LOOSE;
else if ( qualityStr == "TIGHT") quality_ = TIGHT;
else quality_ = LOOSE;
else if ( qualityStr == "TIGHTLEPVETO") quality_ = TIGHTLEPVETO;
else quality_ = TIGHT;

push_back("CHF" );
push_back("NHF" );
push_back("CEF" );
if( version_ != WINTER17 || quality_ != TIGHT ) push_back("CEF" );
push_back("NEF" );
push_back("NCH" );
push_back("nConstituents");
Expand All @@ -73,7 +76,26 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
push_back("NEF_FW");
push_back("nNeutrals_FW");
}
if(version_ == WINTER17 ){
push_back("NEF_EC_L");
push_back("NEF_EC_U");
push_back("nNeutrals_EC");
push_back("NEF_FW");
push_back("NHF_FW");
push_back("nNeutrals_FW");
if (quality_ == TIGHTLEPVETO) push_back("MUF");;
}


if(version_ == WINTER17 && quality_ == LOOSE ){
edm::LogWarning("BadJetIDVersion") << "Winter17 JetID version does not support the LOOSE operating point -- defaulting to TIGHT";
quality_ = TIGHT;
}

if(version_ != WINTER17 && quality_ == TIGHTLEPVETO){
edm::LogWarning("BadJetIDVersion") << "JetID version does not support the TIGHTLEPVETO operating point -- defaulting to TIGHT";
quality_ = TIGHT;
}


// Set some default cuts for LOOSE, TIGHT
Expand All @@ -100,7 +122,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
} else if ( quality_ == TIGHT ) {
set("CHF", 0.0);
set("NHF", 0.9);
set("CEF", 0.99);
if(version_ != WINTER17 ) set("CEF", 0.99);
set("NEF", 0.9);
set("NCH", 0);
set("nConstituents", 1);
Expand All @@ -115,14 +137,39 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
}
if(version_ == WINTER17){
set("NEF_EC_L",0.02);
set("NEF_EC_U",0.99);
set("nNeutrals_EC",2);
set("NHF_FW",0.02);
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
}

}else if ( quality_ == TIGHTLEPVETO ) {
set("CHF", 0.0);
set("NHF", 0.9);
set("CEF", 0.8);
set("NEF", 0.9);
set("NCH", 0);
set("nConstituents", 1);
if(version_ == WINTER17){
set("NEF_EC_L",0.02);
set("NEF_EC_U",0.99);
set("nNeutrals_EC",2);
set("NHF_FW",0.02);
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
set("MUF", 0.8);
}

}


// Now check the configuration to see if the user changed anything
if ( params.exists("CHF") ) set("CHF", params.getParameter<double>("CHF") );
if ( params.exists("NHF") ) set("NHF", params.getParameter<double>("NHF") );
if ( params.exists("CEF") ) set("CEF", params.getParameter<double>("CEF") );
if(version_ != WINTER17 || quality_ != TIGHT ) {if ( params.exists("CEF") ) set("CEF", params.getParameter<double>("CEF") );}
if ( params.exists("NEF") ) set("NEF", params.getParameter<double>("NEF") );
if ( params.exists("NCH") ) set("NCH", params.getParameter<int> ("NCH") );
if ( params.exists("nConstituents") ) set("nConstituents", params.getParameter<int> ("nConstituents") );
Expand All @@ -137,6 +184,15 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
if ( params.exists("NEF_FW") ) set("NEF_FW", params.getParameter<double> ("NEF_FW") );
if ( params.exists("nNeutrals_FW") ) set("nNeutrals_FW", params.getParameter<int> ("nNeutrals_FW") );
}
if(version_ == WINTER17){
if ( params.exists("NEF_EC_L") ) set("NEF_EC_L", params.getParameter<int> ("NEF_EC_L") );
if ( params.exists("NEF_EC_U") ) set("NEF_EC_U", params.getParameter<int> ("NEF_EC_U") );
if ( params.exists("nNeutrals_EC") ) set("nNeutrals_EC", params.getParameter<int> ("nNeutrals_EC") );
if ( params.exists("NHF_FW") ) set("NHF_FW", params.getParameter<double> ("NHF_FW") );
if ( params.exists("NEF_FW") ) set("NEF_FW", params.getParameter<double> ("NEF_FW") );
if ( params.exists("nNeutrals_FW") ) set("nNeutrals_FW", params.getParameter<int> ("nNeutrals_FW") );
if ( quality_ == TIGHTLEPVETO ) {if ( params.exists("MUF") ) set("MUF", params.getParameter<int> ("MUF") );}
}


if ( params.exists("cutsToIgnore") )
Expand All @@ -146,7 +202,8 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
indexNConstituents_ = index_type (&bits_, "nConstituents");
indexNEF_ = index_type (&bits_, "NEF");
indexNHF_ = index_type (&bits_, "NHF");
indexCEF_ = index_type (&bits_, "CEF");
if(version_ != WINTER17 || quality_ != TIGHT ) indexCEF_ = index_type (&bits_, "CEF");

indexCHF_ = index_type (&bits_, "CHF");
indexNCH_ = index_type (&bits_, "NCH");
if(version_ == RUNIISTARTUP){
Expand All @@ -160,6 +217,19 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
indexNEF_FW_ = index_type (&bits_, "NEF_FW");
indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
}
if(version_ == WINTER17){
indexNEF_EC_L_ = index_type (&bits_, "NEF_EC_L");
indexNEF_EC_U_ = index_type (&bits_, "NEF_EC_U");
indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
indexNHF_FW_ = index_type (&bits_, "NHF_FW");
indexNEF_FW_ = index_type (&bits_, "NEF_FW");
indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
if ( quality_ == TIGHTLEPVETO ) {indexMUF_ = index_type (&bits_, "MUF");}


}



retInternal_ = getBitTemplate();

Expand All @@ -173,7 +243,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {

push_back("CHF" );
push_back("NHF" );
push_back("CEF" );
if(version_ != WINTER17 || quality_ != TIGHT ) push_back("CEF" );
push_back("NEF" );
push_back("NCH" );
push_back("nConstituents");
Expand All @@ -188,8 +258,25 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
push_back("NEF_FW");
push_back("nNeutrals_FW");
}
if(version_ == WINTER17){
push_back("NEF_EC_L");
push_back("NEF_EC_U");
push_back("nNeutrals_EC");
push_back("NHF_FW");
push_back("NEF_FW");
push_back("nNeutrals_FW");
if ( quality_ == TIGHTLEPVETO ) { push_back("MUF");}
}


if(version_ == WINTER17 && quality_ == LOOSE ){
edm::LogWarning("BadJetIDVersion") << "Winter17 JetID version does not support the LOOSE operating point -- defaulting to TIGHT";
quality_ = TIGHT;
}
if(version_ != WINTER17 && quality_ == TIGHTLEPVETO){
edm::LogWarning("BadJetIDVersion") << "JetID version does not support the TIGHTLEPVETO operating point -- defaulting to TIGHT";
quality_ = TIGHT;
}
// Set some default cuts for LOOSE, TIGHT
if ( quality_ == LOOSE ) {
set("CHF", 0.0);
Expand All @@ -210,10 +297,14 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
set("nNeutrals_FW",10);
}





} else if ( quality_ == TIGHT ) {
set("CHF", 0.0);
set("NHF", 0.9);
set("CEF", 0.99);
if(version_ != WINTER17) set("CEF", 0.99);
set("NEF", 0.9);
set("NCH", 0);
set("nConstituents", 1);
Expand All @@ -228,13 +319,41 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
}
if(version_ == WINTER17){
set("NEF_EC_L",0.02);
set("NEF_EC_U",0.99);
set("nNeutrals_EC",2);
set("NHF_FW",0.02);
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
}

} else if ( quality_ == TIGHTLEPVETO ) {
set("CHF", 0.0);
set("NHF", 0.9);
set("CEF", 0.8);
set("NEF", 0.9);
set("NCH", 0);
set("nConstituents", 1);
if(version_ == WINTER17){
set("NEF_EC_L",0.02);
set("NEF_EC_U",0.99);
set("nNeutrals_EC",2);
set("NHF_FW",0.02);
set("NEF_FW",0.90);
set("nNeutrals_FW",10);
set("MUF", 0.8);
}

}




indexNConstituents_ = index_type (&bits_, "nConstituents");
indexNEF_ = index_type (&bits_, "NEF");
indexNHF_ = index_type (&bits_, "NHF");
indexCEF_ = index_type (&bits_, "CEF");
if(version_ != WINTER17 || quality_ != TIGHT ) indexCEF_ = index_type (&bits_, "CEF");
indexCHF_ = index_type (&bits_, "CHF");
indexNCH_ = index_type (&bits_, "NCH");
if(version_ == RUNIISTARTUP){
Expand All @@ -248,6 +367,16 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
indexNEF_FW_ = index_type (&bits_, "NEF_FW");
indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
}
if(version_ == WINTER17){

indexNEF_EC_L_ = index_type (&bits_, "NEF_EC_L");
indexNEF_EC_U_ = index_type (&bits_, "NEF_EC_U");
indexNNeutrals_EC_ = index_type (&bits_, "nNeutrals_EC");
indexNHF_FW_ = index_type (&bits_, "NHF_FW");
indexNEF_FW_ = index_type (&bits_, "NEF_FW");
indexNNeutrals_FW_ = index_type (&bits_, "nNeutrals_FW");
if ( quality_ == TIGHTLEPVETO ) { indexMUF_ = index_type (&bits_, "MUF"); }
}


retInternal_ = getBitTemplate();
Expand All @@ -259,7 +388,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
//
bool operator()( const pat::Jet & jet, pat::strbitset & ret ) override
{
if ( version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16) {
if ( version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 || version_ == WINTER17) {
if ( jet.currentJECLevel() == "Uncorrected" || !jet.jecSetsAvailable() )
return firstDataCuts( jet, ret, version_);
else
Expand All @@ -277,7 +406,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
//
bool operator()( const reco::PFJet & jet, pat::strbitset & ret )
{
if ( version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 ){ return firstDataCuts( jet, ret, version_);
if ( version_ == FIRSTDATA || version_ == RUNIISTARTUP || version_ == WINTER16 || version_ == WINTER17 ){ return firstDataCuts( jet, ret, version_);
}
else {
return false;
Expand Down Expand Up @@ -305,6 +434,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
double nhf = 0.0;
double cef = 0.0;
double nef = 0.0;
double muf = 0.0;
int nch = 0;
int nconstituents = 0;
int nneutrals = 0;
Expand Down Expand Up @@ -383,6 +513,7 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
nhf = pfJet->neutralHadronEnergy() / jetEnergyUncorrected;
cef = pfJet->chargedEmEnergy() / jetEnergyUncorrected;
nef = pfJet->neutralEmEnergy() / jetEnergyUncorrected;
muf = pfJet->muonEnergy() / jetEnergyUncorrected;
}
nch = pfJet->chargedMultiplicity();
nconstituents = pfJet->numberOfDaughters();
Expand Down Expand Up @@ -418,8 +549,11 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
}
} // end if basic jet

// Cuts for |eta| < 2.4 for FIRSTDATA, RUNIISTARTUP and WINTER16
if ( ignoreCut(indexCEF_) || ( cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCEF_);


// Cuts for |eta| < 2.4 for FIRSTDATA, RUNIISTARTUP, WINTER16 and WINTER17
if(version_ != WINTER17 || quality_ != TIGHT ) {if ( ignoreCut(indexCEF_) || ( cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCEF_);}

if ( ignoreCut(indexCHF_) || ( chf > cut(indexCHF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCHF_);
if ( ignoreCut(indexNCH_) || ( nch > cut(indexNCH_, int()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexNCH_);

Expand Down Expand Up @@ -451,6 +585,26 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {
if ( ignoreCut(indexNEF_FW_) || ( nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNEF_FW_);
if ( ignoreCut(indexNNeutrals_FW_) || ( nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNNeutrals_FW_);
}
else if(version_ == WINTER17){
// Cuts for |eta| <= 2.7 for WINTER17 scenario
if ( ignoreCut(indexNConstituents_) || ( nconstituents > cut(indexNConstituents_, int()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNConstituents_);
if ( ignoreCut(indexNEF_) || ( nef < cut(indexNEF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNEF_);
if ( ignoreCut(indexNHF_) || ( nhf < cut(indexNHF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexNHF_);
if ( quality_ == TIGHTLEPVETO ) {if ( ignoreCut(indexMUF_) || ( muf < cut(indexMUF_, double()) || std::abs(jet.eta()) > 2.7 ) ) passCut( ret, indexMUF_);}

// Cuts for 2.7 < |eta| <= 3.0 for WINTER17 scenario

if ( ignoreCut(indexNEF_EC_L_) || ( nef > cut(indexNEF_EC_L_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNEF_EC_L_);
if ( ignoreCut(indexNEF_EC_U_) || ( nef < cut(indexNEF_EC_U_, double()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNEF_EC_U_);
if ( ignoreCut(indexNNeutrals_EC_) || ( nneutrals > cut(indexNNeutrals_EC_, int()) || std::abs(jet.eta()) <= 2.7 || std::abs(jet.eta()) > 3.0) ) passCut( ret, indexNNeutrals_EC_);

// Cuts for |eta| > 3.0 for WINTER17 scenario
if ( ignoreCut(indexNHF_FW_) || ( nhf > cut(indexNHF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNHF_FW_);
if ( ignoreCut(indexNEF_FW_) || ( nef < cut(indexNEF_FW_, double()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNEF_FW_);
if ( ignoreCut(indexNNeutrals_FW_) || ( nneutrals > cut(indexNNeutrals_FW_, int()) || std::abs(jet.eta()) <= 3.0 ) ) passCut( ret, indexNNeutrals_FW_);

}


//std::cout << "<PFJetIDSelectionFunctor::firstDataCuts>:" << std::endl;
//std::cout << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi() << std::endl;
Expand All @@ -467,16 +621,20 @@ class PFJetIDSelectionFunctor : public Selector<pat::Jet> {

index_type indexNConstituents_;
index_type indexNEF_;
index_type indexMUF_;
index_type indexNHF_;
index_type indexCEF_;
index_type indexCHF_;
index_type indexNCH_;

index_type indexNHF_FW_;
index_type indexNEF_FW_;
index_type indexNNeutrals_FW_;

index_type indexNHF_EC_;
index_type indexNEF_EC_;
index_type indexNEF_EC_L_;
index_type indexNEF_EC_U_;
index_type indexNNeutrals_EC_;


Expand Down
4 changes: 2 additions & 2 deletions PhysicsTools/SelectorUtils/python/pfJetIDSelector_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@


pfJetIDSelector = cms.PSet(
version = cms.string('WINTER16'),
quality = cms.string('LOOSE')
version = cms.string('WINTER17'),
quality = cms.string('TIGHT')
)