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
Pileup jet ID for JPT #1872
Merged
Merged
Pileup jet ID for JPT #1872
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
http://cmsdoc.cern.ch/cms/data/CMSSW/RecoJets/JetProducers/data/TMVAClassificationCategory_JetID_53X_Dec2012.weights.xml.gz | ||
http://cmsdoc.cern.ch/cms/data/CMSSW/RecoJets/JetProducers/data/TMVAClassificationCategory_JetID_MET_53X_Dec2012.weights.xml.gz | ||
http://cmsdoc.cern.ch/cms/data/CMSSW/RecoJets/JetProducers/data/TMVAClassification_5x_BDT_chsFullPlusRMS.weights.xml.gz | ||
http://cmsdoc.cern.ch/cms/data/CMSSW/RecoJets/JetProducers/data/TMVAClassification_PUJetID_JPT_BDTG.weights.xml.gz | ||
http://cmsdoc.cern.ch/cms/data/CMSSW/RecoJets/JetProducers/data/TMVAClassification_PUJetID_JPT_BDTG.weights_F.xml.gz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef JetProducers_PileupJPTJetIdAlgo_h | ||
#define JetProducers_PileupJPTJetIdAlgo_h | ||
|
||
#include "DataFormats/JetReco/interface/JPTJet.h" | ||
|
||
// user include files | ||
#include <string> | ||
#include <memory> | ||
#include <map> | ||
#include<fstream> | ||
#include<iomanip> | ||
#include<iostream> | ||
#include<vector> | ||
|
||
using namespace std; | ||
using namespace reco; | ||
|
||
namespace edm { | ||
class Event; | ||
class EventSetup; | ||
class ParameterSets; | ||
} | ||
// For MVA analysis | ||
|
||
#include "TMVA/Tools.h" | ||
#include "TMVA/Reader.h" | ||
|
||
namespace cms | ||
{ | ||
|
||
class PileupJPTJetIdAlgo | ||
{ | ||
public: | ||
|
||
PileupJPTJetIdAlgo(const edm::ParameterSet& fParameters); | ||
|
||
virtual ~PileupJPTJetIdAlgo(); | ||
|
||
void bookMVAReader(); | ||
|
||
float fillJPTBlock(const reco::JPTJet* jet | ||
); | ||
private: | ||
int verbosity; | ||
// Variables for multivariate analysis | ||
|
||
float Nvtx,PtJ,EtaJ,Beta,MultCalo,dAxis1c,dAxis2c,MultTr,dAxis1t,dAxis2t; | ||
TMVA::Reader * reader_; | ||
TMVA::Reader * readerF_; | ||
std::string tmvaWeights_, tmvaWeightsF_, tmvaMethod_; | ||
}; | ||
} | ||
#endif |
150 changes: 150 additions & 0 deletions
150
RecoJets/JetProducers/plugins/PileupJPTJetIdProducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDProducer.h" | ||
#include "DataFormats/JetReco/interface/Jet.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "DataFormats/Common/interface/ValueMap.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "RecoJets/JetProducers/interface/PileupJPTJetIdAlgo.h" | ||
#include "DataFormats/JetReco/interface/JPTJetCollection.h" | ||
#include "DataFormats/JetReco/interface/JPTJet.h" | ||
|
||
|
||
// ------------------------------------------------------------------------------------------ | ||
class PileupJPTJetIdProducer : public edm::EDProducer { | ||
public: | ||
explicit PileupJPTJetIdProducer(const edm::ParameterSet&); | ||
~PileupJPTJetIdProducer(); | ||
|
||
private: | ||
virtual void produce(edm::Event&, const edm::EventSetup&); | ||
|
||
virtual void beginRun(edm::Run&, edm::EventSetup const&); | ||
virtual void endRun(edm::Run&, edm::EventSetup const&); | ||
virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); | ||
virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&); | ||
|
||
edm::InputTag jets_; | ||
edm::EDGetTokenT<edm::View<reco::JPTJet> > input_token_; | ||
bool allowMissingInputs_; | ||
int verbosity; | ||
cms::PileupJPTJetIdAlgo* pualgo; | ||
|
||
}; | ||
|
||
// ------------------------------------------------------------------------------------------ | ||
PileupJPTJetIdProducer::PileupJPTJetIdProducer(const edm::ParameterSet& iConfig) | ||
{ | ||
jets_ = iConfig.getParameter<edm::InputTag>("jets"); | ||
input_token_ = consumes<edm::View<reco::JPTJet> >(jets_); | ||
verbosity = iConfig.getParameter<int>("Verbosity"); | ||
allowMissingInputs_=iConfig.getUntrackedParameter<bool>("AllowMissingInputs",false); | ||
pualgo = new cms::PileupJPTJetIdAlgo(iConfig); | ||
pualgo->bookMVAReader(); | ||
produces<edm::ValueMap<float> > ("JPTPUDiscriminant"); | ||
produces<edm::ValueMap<int> > ("JPTPUId"); | ||
} | ||
|
||
|
||
|
||
// ------------------------------------------------------------------------------------------ | ||
PileupJPTJetIdProducer::~PileupJPTJetIdProducer() | ||
{ | ||
} | ||
|
||
|
||
// ------------------------------------------------------------------------------------------ | ||
void | ||
PileupJPTJetIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
using namespace std; | ||
using namespace reco; | ||
edm::Handle<View<JPTJet> > jets; | ||
iEvent.getByToken(input_token_, jets); | ||
vector<float> mva; | ||
vector<int> idflag; | ||
for ( unsigned int i=0; i<jets->size(); ++i ) { | ||
int b = -1; | ||
const JPTJet & jet = jets->at(i); | ||
|
||
float mvapu = pualgo->fillJPTBlock(&jet); | ||
|
||
mva.push_back(mvapu); | ||
|
||
// Get PUid type | ||
///|eta|<2.6 | ||
//WP 95% JPT PUID > 0.3 | ||
//WP 90% JPT PUID > 0.7 | ||
//WP 80% JPT PUID > 0.9 | ||
|
||
//|eta|>=2.6 | ||
//WP 90% JPT PUID > -0.55 | ||
//WP 80% JPT PUID > -0.3 | ||
//WP 70% JPT PUID > -0.1 | ||
|
||
if(fabs(jet.eta()) < 2.6 ) { | ||
if( mvapu > 0.3 ) b = 0; | ||
if( mvapu > 0.7 ) b = 1; | ||
if( mvapu > 0.9 ) b = 2; | ||
} else { | ||
if( mvapu > -0.55 ) b = 0; | ||
if( mvapu > -0.3 ) b = 1; | ||
if( mvapu > -0.1 ) b = 2; | ||
} | ||
|
||
idflag.push_back(b); | ||
|
||
if(verbosity > 0) std::cout<<" PUID producer::Corrected JPT Jet is "<<jet.pt()<<" "<<jet.eta()<<" "<<jet.phi()<<" "<<jet.getSpecific().Zch<<std::endl; | ||
|
||
} | ||
|
||
auto_ptr<ValueMap<float> > mvaout(new ValueMap<float>()); | ||
ValueMap<float>::Filler mvafiller(*mvaout); | ||
mvafiller.insert(jets,mva.begin(),mva.end()); | ||
mvafiller.fill(); | ||
iEvent.put(mvaout,"JPTPUDiscriminant"); | ||
|
||
auto_ptr<ValueMap<int> > idflagout(new ValueMap<int>()); | ||
ValueMap<int>::Filler idflagfiller(*idflagout); | ||
idflagfiller.insert(jets,idflag.begin(),idflag.end()); | ||
idflagfiller.fill(); | ||
iEvent.put(idflagout,"JPTPUId"); | ||
|
||
} | ||
|
||
// ------------------------------------------------------------------------------------------ | ||
void | ||
PileupJPTJetIdProducer::beginRun(edm::Run&, edm::EventSetup const&) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove begin/end Run/Job from .h and .cc , since they are empty |
||
{ | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------ | ||
void | ||
PileupJPTJetIdProducer::endRun(edm::Run&, edm::EventSetup const&) | ||
{ | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------ | ||
void | ||
PileupJPTJetIdProducer::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) | ||
{ | ||
} | ||
|
||
// ------------------------------------------------------------------------------------------ | ||
void | ||
PileupJPTJetIdProducer::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&) | ||
{ | ||
} | ||
|
||
//define this as a plug-in | ||
DEFINE_FWK_MODULE(PileupJPTJetIdProducer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
pileupJPTJetIdProducer = cms.EDProducer("PileupJPTJetIdProducer", | ||
jets = cms.InputTag("ak5JPTJetsL1L2L3"), | ||
Verbosity = cms.int32(0), | ||
tmvaWeightsCentral = cms.string('RecoJets/JetProducers/data/TMVAClassification_PUJetID_JPT_BDTG.weights.xml.gz'), | ||
tmvaWeightsForward = cms.string('RecoJets/JetProducers/data/TMVAClassification_PUJetID_JPT_BDTG.weights_F.xml.gz'), | ||
tmvaMethod = cms.string('BDTG method') | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is new, please use the consumes right away!