CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
MVAJetIdMaker Class Reference

#include <MVAJetIdMaker.h>

Public Member Functions

 MVAJetIdMaker (const edm::ParameterSet &, edm::ConsumesCollector &&)
 
void SetVars (HWW &, const edm::Event &, const edm::EventSetup &)
 

Private Attributes

PileupJetIdAlgofPUJetIdAlgo
 
edm::EDGetTokenT
< reco::JetCorrector
jetCorrectorToken_
 
edm::EDGetTokenT
< reco::PFJetCollection
PFJetCollection_
 
edm::EDGetTokenT
< reco::VertexCollection
thePVCollection_
 
edm::EDGetTokenT< double > theRhoCollection_
 

Detailed Description

Definition at line 16 of file MVAJetIdMaker.h.

Constructor & Destructor Documentation

MVAJetIdMaker::MVAJetIdMaker ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iCollector 
)

Definition at line 10 of file MVAJetIdMaker.cc.

References fPUJetIdAlgo, edm::ParameterSet::getParameter(), jetCorrectorToken_, PFJetCollection_, thePVCollection_, and theRhoCollection_.

10  {
11 
12  PFJetCollection_ = iCollector.consumes<reco::PFJetCollection> (iConfig.getParameter<edm::InputTag>("pfJetsInputTag"));
13  thePVCollection_ = iCollector.consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertexInputTag"));
14  theRhoCollection_ = iCollector.consumes<double>(iConfig.getParameter<edm::InputTag>("rhoInputTag"));
15  jetCorrectorToken_ = iCollector.consumes<reco::JetCorrector>(iConfig.getParameter<edm::InputTag>("jetCorrector"));
16 
17  fPUJetIdAlgo = new PileupJetIdAlgo(iConfig.getParameter<edm::ParameterSet>("puJetIDParams"),true);
18 
19 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::PFJetCollection > PFJetCollection_
Definition: MVAJetIdMaker.h:25
T getParameter(std::string const &) const
edm::EDGetTokenT< double > theRhoCollection_
Definition: MVAJetIdMaker.h:27
PileupJetIdAlgo * fPUJetIdAlgo
Definition: MVAJetIdMaker.h:29
edm::EDGetTokenT< reco::VertexCollection > thePVCollection_
Definition: MVAJetIdMaker.h:26
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::JetCorrector > jetCorrectorToken_
Definition: MVAJetIdMaker.h:28
std::vector< PFJet > PFJetCollection
collection of PFJet objects

Member Function Documentation

void MVAJetIdMaker::SetVars ( HWW hww,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 32 of file MVAJetIdMaker.cc.

References StoredPileupJetIdentifier::beta(), StoredPileupJetIdentifier::betaStar(), PileupJetIdAlgo::computeIdVariables(), PileupJetIdentifier::d0(), StoredPileupJetIdentifier::dRMean(), StoredPileupJetIdentifier::dZ(), reco::LeafCandidate::eta(), fPUJetIdAlgo, StoredPileupJetIdentifier::frac01(), StoredPileupJetIdentifier::frac02(), StoredPileupJetIdentifier::frac03(), StoredPileupJetIdentifier::frac04(), StoredPileupJetIdentifier::frac05(), edm::Event::getByToken(), edm::EventBase::id(), reco::Vertex::isFake(), metsig::jet, reco::Jet::jetArea(), jetCorrectorToken_, StoredPileupJetIdentifier::jetEta(), PileupJetIdentifier::jetPhi(), HWW::Load_pfjets_corr_p4(), HWW::Load_pfjets_JEC(), HWW::Load_pfjets_mvavalue(), LogDebug, PileupJetIdentifier::mva(), StoredPileupJetIdentifier::nCharged(), reco::Vertex::ndof(), StoredPileupJetIdentifier::nNeutrals(), StoredPileupJetIdentifier::nvtx(), PFJetCollection_, HWW::pfjets_JEC(), HWW::pfjets_mvavalue(), reco::Vertex::position(), reco::LeafCandidate::pt(), dt_dqm_sourceclient_common_cff::reco, reco::Jet::scaleEnergy(), thePVCollection_, and theRhoCollection_.

Referenced by HWWAnalyzer::analyze().

32  {
33 
34  using namespace std;
35  using namespace edm;
36  using namespace reco;
37 
38  hww.Load_pfjets_corr_p4();
40  hww.Load_pfjets_JEC();
41 
42  bool validToken;
43 
44  //Uncorrected Jets
45  Handle<PFJetCollection> lHUCJets;
46  validToken = iEvent.getByToken(PFJetCollection_, lHUCJets);
47  if(!validToken) return;
48  PFJetCollection lUCJets = *lHUCJets;
49 
50  // vertices
52  validToken = iEvent.getByToken(thePVCollection_, lHVertices);
53  if(!validToken) return;
54  VertexCollection lVertices = *lHVertices;
55 
56  Handle<double> lHrho;
57  validToken = iEvent.getByToken(theRhoCollection_, lHrho);
58  if(!validToken) return;
59  double lrho = *lHrho;
60 
62  iEvent.getByToken( jetCorrectorToken_, jetCorrector );
63  std::vector<reco::PFJet> lCJets;
64  for(reco::PFJetCollection::const_iterator jet=lUCJets.begin(); jet!=lUCJets.end(); ++jet){
65 
66  reco::PFJet tempJet = *jet;
67  tempJet.scaleEnergy(jetCorrector->correction(*jet));
68  lCJets.push_back(tempJet);
69 
70  }
71 
72 
73  // select good vertices
74  // make new collection to put into computeIdVariables(...)
75  VertexCollection lGoodVertices;
76  for(int ivtx = 0; ivtx < (int)lVertices.size(); ivtx++) {
77 
78  const Vertex *vtx = &(lVertices.at(ivtx));
79  if( vtx->isFake() ) continue;
80  if( vtx->ndof()<=4 ) continue;
81  if( vtx->position().Rho()>2.0 ) continue;
82  if( fabs(vtx->position().Z())>24.0 ) continue;
83  lGoodVertices.push_back(*vtx);
84  }
85 
86  // loop over jets
87  for(int i0 = 0; i0 < (int) lUCJets.size(); i0++) { // uncorrected jets collection
88  const PFJet *pUCJet = &(lUCJets.at(i0));
89  for(int i1 = 0; i1 < (int) lCJets.size(); i1++) { // corrected jets collection
90  const PFJet *pCJet = &(lCJets.at(i1));
91  if( pUCJet->jetArea() != pCJet->jetArea() ) continue;
92  if( fabs(pUCJet->eta() - pCJet->eta()) > 0.001 ) continue;
93  if( pUCJet->pt() < 0.0 ) continue;
94  double lJec = pCJet ->pt()/pUCJet->pt();
95 
96  // calculate mva value only when there are good vertices
97  // otherwise store -999
98  if( lGoodVertices.size()>0 ) {
99  PileupJetIdentifier lPUJetId = fPUJetIdAlgo->computeIdVariables(pCJet,lJec,&lGoodVertices[0],lGoodVertices,lrho);
100  hww.pfjets_mvavalue() .push_back( lPUJetId.mva() );
101  hww.pfjets_JEC() .push_back( lJec );
102 
103  // print out MVA inputs
104  if(0) {
105 
106  LogDebug("MVAJetIdMaker")
107  << "Debug Jet MVA : "
108  << iEvent.id() << " : "
109  << lPUJetId.nvtx() << " "
110  << pCJet->pt() << " "
111  << lPUJetId.jetEta() << " "
112  << lPUJetId.jetPhi() << " "
113  << lPUJetId.d0() << " "
114  << lPUJetId.dZ() << " "
115  << lPUJetId.beta() << " "
116  << lPUJetId.betaStar() << " "
117  << lPUJetId.nCharged() << " "
118  << lPUJetId.nNeutrals() << " "
119  << lPUJetId.dRMean() << " "
120  << lPUJetId.frac01() << " "
121  << lPUJetId.frac02() << " "
122  << lPUJetId.frac03() << " "
123  << lPUJetId.frac04() << " "
124  << lPUJetId.frac05()
125  << " === : === "
126  << lPUJetId.mva();
127  }
128  }
129  else
130 
131  hww.pfjets_mvavalue() .push_back( -999. );
132 
133  break;
134 
135  } // lCJets
136  } // lUCJets
137 }
#define LogDebug(id)
edm::EDGetTokenT< reco::PFJetCollection > PFJetCollection_
Definition: MVAJetIdMaker.h:25
edm::EDGetTokenT< double > theRhoCollection_
Definition: MVAJetIdMaker.h:27
virtual void scaleEnergy(double fScale)
scale energy of the jet
const float & frac05() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
PileupJetIdAlgo * fPUJetIdAlgo
Definition: MVAJetIdMaker.h:29
const float & mva() const
edm::EDGetTokenT< reco::VertexCollection > thePVCollection_
Definition: MVAJetIdMaker.h:26
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const float & frac03() const
void Load_pfjets_mvavalue()
Definition: HWW.cc:1376
void Load_pfjets_corr_p4()
Definition: HWW.cc:1367
const Point & position() const
position
Definition: Vertex.h:106
Jets made from PFObjects.
Definition: PFJet.h:21
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
void Load_pfjets_JEC()
Definition: HWW.cc:1373
const float & beta() const
double ndof() const
Definition: Vertex.h:102
const float & jetPhi() const
const float & nNeutrals() const
const float & dZ() const
const float & nvtx() const
edm::EDGetTokenT< reco::JetCorrector > jetCorrectorToken_
Definition: MVAJetIdMaker.h:28
const float & frac04() const
const float & frac01() const
bool isFake() const
Definition: Vertex.h:64
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho)
std::vector< float > & pfjets_mvavalue()
Definition: HWW.cc:785
edm::EventID id() const
Definition: EventBase.h:60
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual float jetArea() const
get jet area
Definition: Jet.h:105
std::vector< float > & pfjets_JEC()
Definition: HWW.cc:781
const float & betaStar() const
const float & dRMean() const
const float & d0() const
const float & nCharged() const
const float & frac02() const
const float & jetEta() const

Member Data Documentation

PileupJetIdAlgo* MVAJetIdMaker::fPUJetIdAlgo
private

Definition at line 29 of file MVAJetIdMaker.h.

Referenced by MVAJetIdMaker(), and SetVars().

edm::EDGetTokenT<reco::JetCorrector> MVAJetIdMaker::jetCorrectorToken_
private

Definition at line 28 of file MVAJetIdMaker.h.

Referenced by MVAJetIdMaker(), and SetVars().

edm::EDGetTokenT<reco::PFJetCollection> MVAJetIdMaker::PFJetCollection_
private

Definition at line 25 of file MVAJetIdMaker.h.

Referenced by MVAJetIdMaker(), and SetVars().

edm::EDGetTokenT<reco::VertexCollection> MVAJetIdMaker::thePVCollection_
private

Definition at line 26 of file MVAJetIdMaker.h.

Referenced by MVAJetIdMaker(), and SetVars().

edm::EDGetTokenT<double> MVAJetIdMaker::theRhoCollection_
private

Definition at line 27 of file MVAJetIdMaker.h.

Referenced by MVAJetIdMaker(), and SetVars().