CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
pat::PATJetSelector Class Reference

#include <PATJetSelector.h>

Inheritance diagram for pat::PATJetSelector:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual bool filter (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 PATJetSelector (edm::ParameterSet const &params)
 
virtual ~PATJetSelector ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- 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 ()
 

Protected Attributes

std::string cut_
 
bool filter_
 
StringCutObjectSelector< Jetselector_
 
edm::InputTag src_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
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 25 of file PATJetSelector.h.

Constructor & Destructor Documentation

pat::PATJetSelector::PATJetSelector ( edm::ParameterSet const &  params)
inline

Definition at line 29 of file PATJetSelector.h.

References edm::ParameterSet::exists(), filter_, and edm::ParameterSet::getParameter().

29  :
30  edm::EDFilter( ),
31  src_( params.getParameter<edm::InputTag>("src") ),
32  cut_( params.getParameter<std::string>("cut") ),
33  filter_(false),
34  selector_( cut_ )
35  {
36  produces< std::vector<pat::Jet> >();
37  produces<reco::GenJetCollection> ("genJets");
38  produces<std::vector<CaloTower> > ("caloTowers");
39  produces<reco::PFCandidateCollection > ("pfCandidates");
40  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
41 
42  if ( params.exists("filter") ) {
43  filter_ = params.getParameter<bool>("filter");
44  }
45  }
edm::InputTag src_
StringCutObjectSelector< Jet > selector_
virtual pat::PATJetSelector::~PATJetSelector ( )
inlinevirtual

Definition at line 47 of file PATJetSelector.h.

47 {}

Member Function Documentation

virtual void pat::PATJetSelector::beginJob ( void  )
inlinevirtual

Reimplemented from edm::EDFilter.

Definition at line 49 of file PATJetSelector.h.

49 {}
virtual void pat::PATJetSelector::endJob ( void  )
inlinevirtual

Reimplemented from edm::EDFilter.

Definition at line 50 of file PATJetSelector.h.

50 {}
virtual bool pat::PATJetSelector::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverridevirtual

Implements edm::EDFilter.

Definition at line 52 of file PATJetSelector.h.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::end(), filter_, edm::Event::getByLabel(), edm::Event::getRefBeforePut(), jetProducer_cfi::patJets, edm::Event::put(), selector_, and src_.

52  {
53 
54  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() );
55 
56  std::auto_ptr<reco::GenJetCollection > genJetsOut ( new reco::GenJetCollection() );
57  std::auto_ptr<std::vector<CaloTower> > caloTowersOut( new std::vector<CaloTower> () );
58  std::auto_ptr<reco::PFCandidateCollection > pfCandidatesOut( new reco::PFCandidateCollection() );
59  std::auto_ptr<edm::OwnVector<reco::BaseTagInfo> > tagInfosOut ( new edm::OwnVector<reco::BaseTagInfo>() );
60 
61 
63  edm::RefProd<std::vector<CaloTower> > h_caloTowersOut = iEvent.getRefBeforePut<std::vector<CaloTower> > ( "caloTowers" );
64  edm::RefProd<reco::PFCandidateCollection > h_pfCandidatesOut = iEvent.getRefBeforePut<reco::PFCandidateCollection > ( "pfCandidates" );
66 
68  iEvent.getByLabel( src_, h_jets );
69 
70  // First loop over the products and make the secondary output collections
71  for ( edm::View<pat::Jet>::const_iterator ibegin = h_jets->begin(),
72  iend = h_jets->end(), ijet = ibegin;
73  ijet != iend; ++ijet ) {
74 
75  // Check the selection
76  if ( selector_(*ijet) ) {
77  // Copy over the calo towers
78  for ( CaloTowerFwdPtrVector::const_iterator itowerBegin = ijet->caloTowersFwdPtr().begin(),
79  itowerEnd = ijet->caloTowersFwdPtr().end(), itower = itowerBegin;
80  itower != itowerEnd; ++itower ) {
81  // Add to global calo tower list
82  caloTowersOut->push_back( **itower );
83  }
84 
85 
86  // Copy over the pf candidates
87  for ( reco::PFCandidateFwdPtrVector::const_iterator icandBegin = ijet->pfCandidatesFwdPtr().begin(),
88  icandEnd = ijet->pfCandidatesFwdPtr().end(), icand = icandBegin;
89  icand != icandEnd; ++icand ) {
90  // Add to global pf candidate list
91  pfCandidatesOut->push_back( **icand );
92  }
93 
94  // Copy the tag infos
95  for ( TagInfoFwdPtrCollection::const_iterator iinfoBegin = ijet->tagInfosFwdPtr().begin(),
96  iinfoEnd = ijet->tagInfosFwdPtr().end(), iinfo = iinfoBegin;
97  iinfo != iinfoEnd; ++iinfo ) {
98  // Add to global calo tower list
99  tagInfosOut->push_back( **iinfo );
100  }
101 
102  // Copy the gen jet
103  if ( ijet->genJet() != 0 ) {
104  genJetsOut->push_back( *(ijet->genJet()) );
105  }
106 
107  }
108  }
109 
110 
111  // Output the secondary collections.
112  edm::OrphanHandle<reco::GenJetCollection> oh_genJetsOut = iEvent.put( genJetsOut, "genJets" );
113  edm::OrphanHandle<std::vector<CaloTower> > oh_caloTowersOut = iEvent.put( caloTowersOut, "caloTowers" );
114  edm::OrphanHandle<reco::PFCandidateCollection> oh_pfCandidatesOut = iEvent.put( pfCandidatesOut, "pfCandidates" );
115  edm::OrphanHandle<edm::OwnVector<reco::BaseTagInfo> > oh_tagInfosOut = iEvent.put( tagInfosOut, "tagInfos" );
116 
117 
118 
119 
120 
121  unsigned int caloTowerIndex = 0;
122  unsigned int pfCandidateIndex = 0;
123  unsigned int tagInfoIndex = 0;
124  unsigned int genJetIndex = 0;
125  // Now set the Ptrs with the orphan handles.
126  for ( edm::View<pat::Jet>::const_iterator ibegin = h_jets->begin(),
127  iend = h_jets->end(), ijet = ibegin;
128  ijet != iend; ++ijet ) {
129 
130  // Check the selection
131  if ( selector_(*ijet) ) {
132  // Add the jets that pass to the output collection
133  patJets->push_back( *ijet );
134 
135  // Copy over the calo towers
136  for ( CaloTowerFwdPtrVector::const_iterator itowerBegin = ijet->caloTowersFwdPtr().begin(),
137  itowerEnd = ijet->caloTowersFwdPtr().end(), itower = itowerBegin;
138  itower != itowerEnd; ++itower ) {
139  // Update the "forward" bit of the FwdPtr to point at the new tower collection.
140 
141  // ptr to "this" tower in the global list
142  edm::Ptr<CaloTower> outPtr( oh_caloTowersOut, caloTowerIndex);
143  patJets->back().updateFwdCaloTowerFwdPtr( itower - itowerBegin,// index of "this" tower in the jet
144  outPtr
145  );
146  ++caloTowerIndex;
147  }
148 
149 
150  // Copy over the pf candidates
151  for ( reco::PFCandidateFwdPtrVector::const_iterator icandBegin = ijet->pfCandidatesFwdPtr().begin(),
152  icandEnd = ijet->pfCandidatesFwdPtr().end(), icand = icandBegin;
153  icand != icandEnd; ++icand ) {
154  // Update the "forward" bit of the FwdPtr to point at the new tower collection.
155 
156  // ptr to "this" cand in the global list
157  edm::Ptr<reco::PFCandidate> outPtr( oh_pfCandidatesOut, pfCandidateIndex );
158  patJets->back().updateFwdPFCandidateFwdPtr( icand - icandBegin,// index of "this" tower in the jet
159  outPtr
160  );
161  ++pfCandidateIndex;
162  }
163 
164  // Copy the tag infos
165  for ( TagInfoFwdPtrCollection::const_iterator iinfoBegin = ijet->tagInfosFwdPtr().begin(),
166  iinfoEnd = ijet->tagInfosFwdPtr().end(), iinfo = iinfoBegin;
167  iinfo != iinfoEnd; ++iinfo ) {
168  // Update the "forward" bit of the FwdPtr to point at the new tower collection.
169 
170  // ptr to "this" info in the global list
171  edm::Ptr<reco::BaseTagInfo > outPtr( oh_tagInfosOut, tagInfoIndex );
172  patJets->back().updateFwdTagInfoFwdPtr( iinfo - iinfoBegin,// index of "this" tower in the jet
173  outPtr
174  );
175  ++tagInfoIndex;
176  }
177 
178  // Copy the gen jet
179  if ( ijet->genJet() != 0 ) {
180  patJets->back().updateFwdGenJetFwdRef( edm::Ref<reco::GenJetCollection>( oh_genJetsOut, genJetIndex) // ref to "this" genjet in the global list
181  );
182  ++genJetIndex;
183  }
184 
185  }
186  }
187 
188 
189  // put genEvt in Event
190  bool pass = patJets->size() > 0;
191  iEvent.put(patJets);
192 
193  if ( filter_ )
194  return pass;
195  else
196  return true;
197  }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< GenJet > GenJetCollection
collection of GenJet objects
iterator begin()
Definition: OwnVector.h:227
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
edm::InputTag src_
StringCutObjectSelector< Jet > selector_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
RefProd< PROD > getRefBeforePut()
Definition: Event.h:106
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
iterator end()
Definition: OwnVector.h:232

Member Data Documentation

std::string pat::PATJetSelector::cut_
protected

Definition at line 201 of file PATJetSelector.h.

bool pat::PATJetSelector::filter_
protected

Definition at line 202 of file PATJetSelector.h.

Referenced by filter(), and PATJetSelector().

StringCutObjectSelector<Jet> pat::PATJetSelector::selector_
protected

Definition at line 203 of file PATJetSelector.h.

Referenced by filter().

edm::InputTag pat::PATJetSelector::src_
protected

Definition at line 200 of file PATJetSelector.h.

Referenced by filter().