Skip to content

Commit

Permalink
Merge pull request #3321 from jstupak/jetToolboxPart2
Browse files Browse the repository at this point in the history
Reco -- Code for grooming value maps and pileup jet ID
  • Loading branch information
ktf committed Apr 16, 2014
2 parents e8f781b + 02ed45a commit 6cffc70
Show file tree
Hide file tree
Showing 9 changed files with 1,029 additions and 3 deletions.
122 changes: 122 additions & 0 deletions CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc
@@ -0,0 +1,122 @@
/* \class PFJetSelector
*
* Selects jets with a configurable string-based cut,
* and also writes out the constituents of the jet
* into a separate collection.
*
* \author: Sal Rappoccio
*
*
* for more details about the cut syntax, see the documentation
* page below:
*
* https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePhysicsCutParser
*
*
*/


#include "FWCore/Framework/interface/EDProducer.h"

#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "DataFormats/JetReco/interface/CaloJet.h"

#include "FWCore/Framework/interface/MakerMacros.h"
#include "CommonTools/Utils/interface/StringObjectFunction.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/Math/interface/deltaR.h"

template < class T >
class JetDeltaRValueMapProducer : public edm::EDProducer {

public:

typedef std::vector<T> JetsInput;
typedef edm::ValueMap<float> JetValueMap;

JetDeltaRValueMapProducer ( edm::ParameterSet const & params ) :
srcToken_( consumes< typename edm::View<T> >( params.getParameter<edm::InputTag>("src") ) ),
matchedToken_( consumes< typename edm::View<T> >( params.getParameter<edm::InputTag>( "matched" ) ) ),
distMin_( params.getParameter<double>( "distMin" ) ),
value_( params.getParameter<std::string>("value") ),
evaluation_( value_ )
{
produces< JetValueMap >();
}

virtual ~JetDeltaRValueMapProducer() {}

virtual void beginJob() override {}
virtual void endJob() override {}

virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {



std::auto_ptr< JetValueMap > jetValueMap ( new JetValueMap() );
edm::ValueMap<float>::Filler filler(*jetValueMap);

edm::Handle< typename edm::View<T> > h_jets1;
iEvent.getByToken( srcToken_, h_jets1 );
edm::Handle< typename edm::View<T> > h_jets2;
iEvent.getByToken( matchedToken_, h_jets2 );

std::vector<float> values; values.reserve( h_jets1->size() );

// Now set the Ptrs with the orphan handles.
std::vector<float> v_jets2_eta, v_jets2_phi;
float jet1_eta, jet1_phi;
for ( typename edm::View<T>::const_iterator ibegin = h_jets1->begin(),
iend = h_jets1->end(), ijet = ibegin;
ijet != iend; ++ijet ) {
float minDR2=9999;
float value=-9999;

jet1_eta=ijet->eta();
jet1_phi=ijet->phi();

for ( typename edm::View<T>::const_iterator jbegin = h_jets2->begin(),
jend = h_jets2->end(), jjet = jbegin;
jjet != jend; ++jjet ) {

if(ijet==ibegin){
v_jets2_eta.push_back(jjet->eta());
v_jets2_phi.push_back(jjet->phi());
}

int index=jjet - jbegin;
float dR2=reco::deltaR2(jet1_eta,jet1_phi,v_jets2_eta.at(index),v_jets2_phi.at(index));
if ( dR2 < distMin_*distMin_ && dR2 < minDR2) {
// Check the selection
value = evaluation_(*jjet);
minDR2 = dR2;
}
}// end loop over matched jets

// Fill to the vector
values.push_back( value );

}// end loop over src jets

filler.insert(h_jets1, values.begin(), values.end());
filler.fill();

// put in Event
iEvent.put(jetValueMap);

}

protected:
edm::EDGetTokenT< typename edm::View<T> > srcToken_;
edm::EDGetTokenT< typename edm::View<T> > matchedToken_;
double distMin_;
std::string value_;
StringObjectFunction<T> evaluation_;

};

typedef JetDeltaRValueMapProducer<reco::Jet> RecoJetDeltaRValueMapProducer;

DEFINE_FWK_MODULE( RecoJetDeltaRValueMapProducer );
10 changes: 7 additions & 3 deletions RecoJets/Configuration/python/RecoJets_EventContent_cff.py
Expand Up @@ -44,7 +44,9 @@
'keep *_kt4TrackJets_*_*',
'keep *_ak7BasicJets_*_*',
'keep *_ak7CastorJetID_*_*',
'keep *_fixedGridRho*_*_*'
'keep *_fixedGridRho*_*_*',
'keep *_ca*Links_*_*',
'keep *_ak*Links_*_*'
)
)
RecoGenJetsFEVT = cms.PSet(
Expand Down Expand Up @@ -100,7 +102,8 @@
'keep double_kt6PFJetsCentralChargedPileUp_*_*',
'keep double_kt6PFJetsCentralNeutral_*_*',
'keep double_kt6PFJetsCentralNeutralTight_*_*',
'keep *_fixedGridRho*_*_*'
'keep *_fixedGridRho*_*_*',
'keep *_ca8PFJetsCHSPrunedLinks_*_*'
)
)
RecoGenJetsRECO = cms.PSet(
Expand Down Expand Up @@ -166,7 +169,8 @@
'keep double_kt6PFJetsCentralNeutralTight_*_*',
'keep *_fixedGridRho*_*_*',
'drop doubles_*Jets_rhos_*',
'drop doubles_*Jets_sigmas_*'
'drop doubles_*Jets_sigmas_*',
'keep *_ca8PFJetsCHSPrunedLinks_*_*'
)
)
RecoGenJetsAOD = cms.PSet(
Expand Down
8 changes: 8 additions & 0 deletions RecoJets/Configuration/python/RecoPFJets_cff.py
Expand Up @@ -14,6 +14,8 @@
from RecoJets.JetProducers.fixedGridRhoProducer_cfi import fixedGridRhoAll
from RecoJets.JetProducers.fixedGridRhoProducerFastjet_cfi import fixedGridRhoFastjetAll
from RecoJets.JetProducers.caTopTaggers_cff import *
from RecoJets.JetProducers.ak8PFJetsCHS_groomingValueMaps_cfi import ak8PFJetsCHSPrunedLinks, ak8PFJetsCHSFilteredLinks, ak8PFJetsCHSTrimmedLinks
from RecoJets.JetProducers.ca8PFJetsCHS_groomingValueMaps_cfi import ca8PFJetsCHSPrunedLinks, ca8PFJetsCHSFilteredLinks, ca8PFJetsCHSTrimmedLinks

sisCone7PFJets = sisCone5PFJets.clone( rParam = 0.7 )
ak7PFJets = ak5PFJets.clone( rParam = 0.7 )
Expand Down Expand Up @@ -151,6 +153,8 @@
cmsTopTagPFJetsCHS.src = cms.InputTag("ak8PFJetsCHSConstituents", "constituents")
hepTopTagPFJetsCHS.src = cms.InputTag("ak8PFJetsCHSConstituents", "constituents")



recoPFJets =cms.Sequence(#kt4PFJets+kt6PFJets+
iterativeCone5PFJets+
#kt6PFJetsCentralChargedPileUp+
Expand All @@ -168,6 +172,7 @@
ca8PFJetsCHS+
ak8PFJetsCHSConstituents+
ca8PFJetsCHSPruned+
ca8PFJetsCHSPrunedLinks+
cmsTopTagPFJetsCHS+
hepTopTagPFJetsCHS+
ca15PFJetsCHSMassDropFiltered+
Expand Down Expand Up @@ -203,6 +208,9 @@
ca8PFJetsCHSPruned+
ca8PFJetsCHSFiltered+
ca8PFJetsCHSTrimmed+
ca8PFJetsCHSPrunedLinks+
ca8PFJetsCHSTrimmedLinks+
ca8PFJetsCHSFilteredLinks+
cmsTopTagPFJetsCHS+
hepTopTagPFJetsCHS+
ca15PFJetsCHSMassDropFiltered+
Expand Down

0 comments on commit 6cffc70

Please sign in to comment.