Skip to content

Commit

Permalink
Clean up code. Remove jet pt threshold in lepton cleaning. Slight upd…
Browse files Browse the repository at this point in the history
…ate to metsig parameters.
  • Loading branch information
nmirman authored and matthieu committed Mar 19, 2015
1 parent 0eb7e04 commit 3263b5b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 35 deletions.
3 changes: 0 additions & 3 deletions RecoMET/METAlgorithms/interface/METSignificance.h
Expand Up @@ -41,10 +41,7 @@ namespace metsig {
double getSignificance(const reco::METCovMatrix& cov, const reco::MET& met ) const;

private:
std::vector<reco::Jet> cleanJets(const edm::View<reco::Jet>& jets,
const std::vector< edm::Handle<reco::CandidateView> >& leptons);
bool cleanJet(const reco::Jet& jet,
//const std::vector<reco::Candidate::LorentzVector>& leptons);
const std::vector< edm::Handle<reco::CandidateView> >& leptons );

double jetThreshold_;
Expand Down
27 changes: 2 additions & 25 deletions RecoMET/METAlgorithms/src/METSignificance.cc
Expand Up @@ -61,12 +61,10 @@ metsig::METSignificance::getCovariance(const edm::View<reco::Jet>& jets,
// for lepton and jet subtraction
std::vector<reco::CandidatePtr> footprint;

std::cout << "Leptons: ";
// subtract leptons out of sumPt
for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
lep_i != leptons.end(); ++lep_i ) {
for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
std::cout << lep->pt() << " ";
if( lep->pt() > 10 ){
for( unsigned int n=0; n < lep->numberOfSourceCandidatePtrs(); n++ ){
if( lep->sourceCandidatePtr(n).isNonnull() and lep->sourceCandidatePtr(n).isAvailable() ){
Expand All @@ -76,7 +74,6 @@ metsig::METSignificance::getCovariance(const edm::View<reco::Jet>& jets,
}
}
}
std::cout << std::endl;
// subtract jets out of sumPt
for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {

Expand All @@ -97,25 +94,19 @@ metsig::METSignificance::getCovariance(const edm::View<reco::Jet>& jets,
cand != pfCandidates.end(); ++cand){

// check if candidate exists in a lepton or jet
//unsigned int iter = cand - pfCandidates.begin();
//if (std::find(footprint.begin(), footprint.end(),
// reco::CandidatePtr(&pfCandidates,iter)) != footprint.end()) {
// continue;
//}
bool cleancand = true;
for(unsigned int i=0; i < footprint.size(); i++){
if( footprint[i]->p4() == cand->p4() ){
cleancand = false;
}
}

// if not, add to sumPt
if( cleancand ){
sumPt += cand->pt();
}

}

std::cout << "Jets: ";
// add jets to metsig covariance matrix and subtract them from sumPt
for(edm::View<reco::Jet>::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {

Expand All @@ -127,7 +118,6 @@ metsig::METSignificance::getCovariance(const edm::View<reco::Jet>& jets,
double feta = std::abs(jeta);
double c = jet->px()/jet->pt();
double s = jet->py()/jet->pt();
std::cout << jpt << " ";

// jet energy resolutions
double jeta_res = (std::abs(jeta) < 9.9) ? jeta : 9.89; // JetResolutions defined for |eta|<9.9
Expand All @@ -152,26 +142,15 @@ metsig::METSignificance::getCovariance(const edm::View<reco::Jet>& jets,
cov_xy += (dpt*dpt-dph*dph)*c*s;
cov_yy += dph*dph*c*c + dpt*dpt*s*s;

// subtract the pf constituents in each jet out of the sumPt
//for(unsigned int i=0; i < jet->numberOfDaughters(); i++){
// sumPt -= jet->daughter(i)->pt();
//}

} else {

// subtract the pf constituents in each jet out of the sumPt
for(unsigned int i=0; i < jet->numberOfDaughters(); i++){
//sumPt -= jet->daughter(i)->pt();
}
// add the (corrected) jet to the sumPt
sumPt += jpt;

}

}
std::cout << std::endl;

std::cout << "sumPt: " << sumPt << std::endl;

//protection against unphysical events
if(sumPt<0) sumPt=0;
Expand Down Expand Up @@ -209,16 +188,14 @@ metsig::METSignificance::getSignificance(const reco::METCovMatrix& cov, const re
bool
metsig::METSignificance::cleanJet(const reco::Jet& jet,
const std::vector< edm::Handle<reco::CandidateView> >& leptons ){

if ( jet.pt() < jetThreshold_ ) return false;

for ( std::vector< edm::Handle<reco::CandidateView> >::const_iterator lep_i = leptons.begin();
lep_i != leptons.end(); ++lep_i ) {
for( reco::CandidateView::const_iterator lep = (*lep_i)->begin(); lep != (*lep_i)->end(); lep++ ){
if ( reco::deltaR2(*lep, jet) < dR2match_ ) {
return false;
}
}
}
}
return true;
}
4 changes: 2 additions & 2 deletions RecoMET/METProducers/python/METSignificanceParams_cfi.py
Expand Up @@ -14,7 +14,7 @@
jeta = cms.vdouble(0.5, 1.1, 1.7, 2.3),

# tuning parameters
jpar = cms.vdouble(1.42,1.29,1.41,1.40,2.52),
pjpar = cms.vdouble(0.0,0.673)
jpar = cms.vdouble(1.41,1.29,1.41,1.40,2.53),
pjpar = cms.vdouble(0.0,0.674)

)
6 changes: 1 addition & 5 deletions RecoMET/METProducers/src/METSignificanceProducer.cc
Expand Up @@ -53,18 +53,14 @@ namespace cms
//
// leptons
//
//std::vector<reco::Candidate::LorentzVector> leptons;
std::vector< edm::Handle<reco::CandidateView> > leptons;
for ( std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = lepTokens_.begin();
srcLeptons_i != lepTokens_.end(); ++srcLeptons_i ) {

edm::Handle<reco::CandidateView> leptons_i;
event.getByToken(*srcLeptons_i, leptons_i);
leptons.push_back( leptons_i );
for ( reco::CandidateView::const_iterator lepton = leptons_i->begin();
lepton != leptons_i->end(); ++lepton ) {
//leptons.push_back(lepton->p4());
}

}

//
Expand Down

0 comments on commit 3263b5b

Please sign in to comment.