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::stream::EDFilter<> edm::stream::EDFilterBase 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::stream::EDFilter<>
 EDFilter ()=default
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilterBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

const std::string cut_
 
const bool filter_
 
const StringCutObjectSelector
< Jet
selector_
 
const edm::EDGetTokenT
< edm::View< pat::Jet > > 
srcToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 24 of file PATJetSelector.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file PATJetSelector.h.

28  :
29  srcToken_(consumes<edm::View<pat::Jet> >( params.getParameter<edm::InputTag>("src") )),
30  cut_( params.getParameter<std::string>("cut") ),
31  filter_( params.exists("filter") ? params.getParameter<bool>("filter") : false ),
32  selector_( cut_ )
33  {
34  produces< std::vector<pat::Jet> >();
35  produces<reco::GenJetCollection> ("genJets");
36  produces<std::vector<CaloTower> > ("caloTowers");
37  produces<reco::PFCandidateCollection > ("pfCandidates");
38  produces<edm::OwnVector<reco::BaseTagInfo> > ("tagInfos");
39  }
const StringCutObjectSelector< Jet > selector_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::string cut_
const edm::EDGetTokenT< edm::View< pat::Jet > > srcToken_
virtual pat::PATJetSelector::~PATJetSelector ( )
inlinevirtual

Definition at line 41 of file PATJetSelector.h.

41 {}

Member Function Documentation

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

Definition at line 43 of file PATJetSelector.h.

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

Definition at line 44 of file PATJetSelector.h.

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

Implements edm::stream::EDFilterBase.

Definition at line 46 of file PATJetSelector.h.

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

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

Member Data Documentation

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

Definition at line 195 of file PATJetSelector.h.

const bool pat::PATJetSelector::filter_
protected

Definition at line 196 of file PATJetSelector.h.

Referenced by filter().

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

Definition at line 197 of file PATJetSelector.h.

Referenced by filter().

const edm::EDGetTokenT<edm::View<pat::Jet> > pat::PATJetSelector::srcToken_
protected

Definition at line 194 of file PATJetSelector.h.

Referenced by filter().