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::EDConsumerBase 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 &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

float deltaR2_
 
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)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 deltaR2_, edm::ParameterSet::getParameter(), inputJets_, and pfSrc_.

39  {
40  deltaR2_ = pset.getParameter<double>("deltaR"); deltaR2_*=deltaR2_;
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(), reco::deltaR2(), deltaR2_, alignCSCRings::e, edm::helper::Filler< Map >::fill(), edm::Event::get(), edm::Event::getByLabel(), edm::RefVector< C, T, F >::id(), inputJets_, edm::helper::Filler< Map >::insert(), fwrapper::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  newJets->reserve(nJets);
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  newJets->emplace_back(*jetRef);
100  reco::PFJet & newJet = newJets->back();
101  // Clear out all the constituents
102  newJet.clearDaughters();
103  // Loop over all the PFCands
104  for ( auto cand : pfCands )
105  if ( reco::deltaR2(*jetRef,*cand)<deltaR2_ ) newJet.addDaughter(cand);
106  // Match the index of the jet we just made to the index into the original
107  // collection.
108  matchInfo[jetRef.key()] = ijet;
109  }
110 
111  // Put our new jets into the event
113  evt.put(newJets, "jets");
114 
115  // Create a matching between original jets -> extra collection
116  std::auto_ptr<PFJetMatchMap> matching(new PFJetMatchMap(newJetsInEvent));
117  if (nJets) {
118  PFJetMatchMap::Filler filler(*matching);
119  filler.insert(originalJets, matchInfo.begin(), matchInfo.end());
120  filler.fill();
121  }
122  evt.put(matching);
123 }
edm::Association< reco::PFJetCollection > PFJetMatchMap
Jets made from PFObjects.
Definition: PFJet.h:22
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:104
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:282
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
helper::Filler< ValueMap< int > > Filler
Definition: ValueMap.h:157
key_type key() const
Accessor for product key.
Definition: Ref.h:266
void clearDaughters()
clear daughter references
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
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:89

Member Data Documentation

float RecoTauJetRegionProducer::deltaR2_
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().