CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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 ()
 
bool filter (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 PATJetSelector (edm::ParameterSet const &params)
 
 ~PATJetSelector () override
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- 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 Attributes

const std::string cut_
 
const std::string cutLoose_
 
const bool filter_
 
const unsigned nLoose_
 
const StringCutObjectSelector< Jetselector_
 
const StringCutObjectSelector< JetselectorLoose_
 
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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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.

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

Definition at line 45 of file PATJetSelector.h.

45 {}

Member Function Documentation

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

Definition at line 47 of file PATJetSelector.h.

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

Definition at line 48 of file PATJetSelector.h.

48 {}
static void pat::PATJetSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 211 of file PATJetSelector.h.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

211  {
213  iDesc.setComment("Energy Correlation Functions adder");
214  iDesc.add<edm::InputTag>("src", edm::InputTag("no default"))->setComment("input collection");
215  iDesc.add<std::string> ("cut", "")->setComment("Jet selection.");
216  iDesc.add<std::string> ("cutLoose", "")->setComment("Loose jet selection. Will keep nLoose loose jets.");
217  iDesc.add<bool> ("filter", false)->setComment("Filter selection?");
218  iDesc.add<unsigned>("nLoose", 0)->setComment("Keep nLoose loose jets that satisfy cutLoose");
219  descriptions.add("PATJetSelector", iDesc);
220  }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool pat::PATJetSelector::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverride

Definition at line 50 of file PATJetSelector.h.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::end(), filter_, edm::Event::getByToken(), edm::Event::getRefBeforePut(), eostools::move(), nLoose_, nullptr, hemisphereProducer_cfi::patJets, edm::Event::put(), selector_, selectorLoose_, and srcToken_.

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

Member Data Documentation

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

Definition at line 224 of file PATJetSelector.h.

const std::string pat::PATJetSelector::cutLoose_
protected

Definition at line 225 of file PATJetSelector.h.

const bool pat::PATJetSelector::filter_
protected

Definition at line 226 of file PATJetSelector.h.

Referenced by filter().

const unsigned pat::PATJetSelector::nLoose_
protected

Definition at line 227 of file PATJetSelector.h.

Referenced by filter().

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

Definition at line 228 of file PATJetSelector.h.

Referenced by filter().

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

Definition at line 229 of file PATJetSelector.h.

Referenced by filter().

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

Definition at line 223 of file PATJetSelector.h.

Referenced by filter().