CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
RecoTauJetRegionProducer Class Reference
Inheritance diagram for RecoTauJetRegionProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Types

typedef edm::Association
< reco::PFJetCollection
PFJetMatchMap
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es)
 
 RecoTauJetRegionProducer (const edm::ParameterSet &pset)
 
 ~RecoTauJetRegionProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

double deltaR_
 
edm::InputTag inputJets_
 
edm::InputTag pfSrc_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 26 of file RecoTauJetRegionProducer.cc.

Member Typedef Documentation

Definition at line 28 of file RecoTauJetRegionProducer.cc.

Constructor & Destructor Documentation

RecoTauJetRegionProducer::RecoTauJetRegionProducer ( const edm::ParameterSet pset)
explicit

Definition at line 38 of file RecoTauJetRegionProducer.cc.

References deltaR_, edm::ParameterSet::getParameter(), inputJets_, and pfSrc_.

39  {
40  deltaR_ = pset.getParameter<double>("deltaR");
41  inputJets_ = pset.getParameter<edm::InputTag>("src");
42  pfSrc_ = pset.getParameter<edm::InputTag>("pfSrc");
43  produces<reco::PFJetCollection>("jets");
44  produces<PFJetMatchMap>();
45 }
T getParameter(std::string const &) const
RecoTauJetRegionProducer::~RecoTauJetRegionProducer ( )
inline

Definition at line 30 of file RecoTauJetRegionProducer.cc.

30 {}

Member Function Documentation

void RecoTauJetRegionProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 47 of file RecoTauJetRegionProducer.cc.

References reco::CompositePtrCandidate::addDaughter(), reco::CompositePtrCandidate::clearDaughters(), deltaR_, edm::helper::Filler< Map >::fill(), align_tpl::filter, edm::Event::get(), edm::Event::getByLabel(), edm::RefVector< C, T, F >::id(), inputJets_, edm::helper::Filler< Map >::insert(), analyzePatCleaning_cfg::jets, edm::Ref< C, T, F >::key(), pfSrc_, edm::Event::put(), and edm::RefVector< C, T, F >::size().

48  {
49 
51  evt.getByLabel(pfSrc_, pfCandsHandle);
52 
53  // Build Ptrs for all the PFCandidates
54  typedef edm::Ptr<reco::PFCandidate> PFCandPtr;
55  std::vector<PFCandPtr> pfCands;
56  pfCands.reserve(pfCandsHandle->size());
57  for (size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
58  pfCands.push_back(PFCandPtr(pfCandsHandle, icand));
59  }
60 
61  // Get the jets
63  evt.getByLabel(inputJets_, jetView);
64  // Convert to a vector of PFJetRefs
66  reco::tau::castView<reco::PFJetRefVector>(jetView);
67  size_t nJets = jets.size();
68 
69  // Get the original product, so we can match against it - otherwise the
70  // indices don't match up.
71  edm::ProductID originalId = jets.id();
73  size_t nOriginalJets = 0;
74  // We have to make sure that we have some selected jets, otherwise we don't
75  // actually have a valid product ID to the original jets.
76  if (nJets) {
77  try {
78  evt.get(originalId, originalJets);
79  } catch(const cms::Exception &e) {
80  edm::LogError("MissingOriginalCollection")
81  << "Can't get the original jets that made: " << inputJets_
82  << " that have product ID: " << originalId
83  << " from the event!!";
84  throw e;
85  }
86  nOriginalJets = originalJets->size();
87  }
88 
89  std::auto_ptr<reco::PFJetCollection> newJets(new reco::PFJetCollection);
90 
91  // Keep track of the indices of the current jet and the old (original) jet
92  // -1 indicats no match.
93  std::vector<int> matchInfo(nOriginalJets, -1);
94 
95  for (size_t ijet = 0; ijet < nJets; ++ijet) {
96  // Get a ref to jet
97  reco::PFJetRef jetRef = jets[ijet];
98  // Make an initial copy.
99  reco::PFJet newJet(*jetRef);
100  // Clear out all the constituents
101  newJet.clearDaughters();
102  // Build a DR cone filter about our jet
104  filter(jetRef->p4(), 0, deltaR_);
105 
106  // Loop over all the PFCands
107  std::for_each(
108  // filtering those that don't pass our filter
109  boost::make_filter_iterator(filter,
110  pfCands.begin(), pfCands.end()),
111  boost::make_filter_iterator(filter,
112  pfCands.end(), pfCands.end()),
113  // For the ones that do, call newJet.addDaughter(..) on them
114  boost::bind(&reco::PFJet::addDaughter, boost::ref(newJet), _1));
115  newJets->push_back(newJet);
116  // Match the index of the jet we just made to the index into the original
117  // collection.
118  matchInfo[jetRef.key()] = ijet;
119  }
120 
121  // Put our new jets into the event
123  evt.put(newJets, "jets");
124 
125  // Create a matching between original jets -> extra collection
126  std::auto_ptr<PFJetMatchMap> matching(new PFJetMatchMap(newJetsInEvent));
127  if (nJets) {
128  PFJetMatchMap::Filler filler(*matching);
129  filler.insert(originalJets, matchInfo.begin(), matchInfo.end());
130  filler.fill();
131  }
132  evt.put(matching);
133 }
edm::Association< reco::PFJetCollection > PFJetMatchMap
Jets made from PFObjects.
Definition: PFJet.h:22
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:99
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:266
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:157
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
key_type key() const
Accessor for product key.
Definition: Ref.h:265
std::vector< PFJet > PFJetCollection
collection of PFJet objects
void addDaughter(const CandidatePtr &)
add a daughter via a reference
size_type size() const
Size of the RefVector.
Definition: RefVector.h:84

Member Data Documentation

double RecoTauJetRegionProducer::deltaR_
private

Definition at line 33 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::InputTag RecoTauJetRegionProducer::inputJets_
private

Definition at line 34 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().

edm::InputTag RecoTauJetRegionProducer::pfSrc_
private

Definition at line 35 of file RecoTauJetRegionProducer.cc.

Referenced by produce(), and RecoTauJetRegionProducer().