CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
pat::PATJetSelector Class Reference
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
 
 EDFilter (const EDFilter &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 25 of file PATObjectSelector.cc.

Constructor & Destructor Documentation

◆ PATJetSelector()

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

Definition at line 27 of file PATObjectSelector.cc.

28  : srcToken_(consumes<edm::View<pat::Jet>>(params.getParameter<edm::InputTag>("src"))),
29  cut_(params.getParameter<std::string>("cut")),
30  cutLoose_(params.getParameter<std::string>("cutLoose")),
31  filter_(params.exists("filter") ? params.getParameter<bool>("filter") : false),
32  nLoose_(params.getParameter<unsigned>("nLoose")),
33  selector_(cut_),
35  produces<std::vector<pat::Jet>>();
36  produces<reco::GenJetCollection>("genJets");
37  produces<std::vector<CaloTower>>("caloTowers");
38  produces<reco::PFCandidateCollection>("pfCandidates");
39  produces<edm::OwnVector<reco::BaseTagInfo>>("tagInfos");
40  }

◆ ~PATJetSelector()

pat::PATJetSelector::~PATJetSelector ( )
inlineoverride

Definition at line 42 of file PATObjectSelector.cc.

42 {}

Member Function Documentation

◆ beginJob()

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

Definition at line 44 of file PATObjectSelector.cc.

44 {}

◆ endJob()

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

Definition at line 45 of file PATObjectSelector.cc.

45 {}

◆ fillDescriptions()

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

Definition at line 207 of file PATObjectSelector.cc.

207  {
209  iDesc.setComment("Energy Correlation Functions adder");
210  iDesc.add<edm::InputTag>("src", edm::InputTag("no default"))->setComment("input collection");
211  iDesc.add<std::string>("cut", "")->setComment("Jet selection.");
212  iDesc.add<std::string>("cutLoose", "")->setComment("Loose jet selection. Will keep nLoose loose jets.");
213  iDesc.add<bool>("filter", false)->setComment("Filter selection?");
214  iDesc.add<unsigned>("nLoose", 0)->setComment("Keep nLoose loose jets that satisfy cutLoose");
215  descriptions.add("PATJetSelector", iDesc);
216  }

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

◆ filter()

bool pat::PATJetSelector::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverridevirtual

Implements edm::stream::EDFilterBase.

Definition at line 47 of file PATObjectSelector.cc.

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

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

Member Data Documentation

◆ cut_

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

Definition at line 220 of file PATObjectSelector.cc.

◆ cutLoose_

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

Definition at line 221 of file PATObjectSelector.cc.

◆ filter_

const bool pat::PATJetSelector::filter_
protected

Definition at line 222 of file PATObjectSelector.cc.

Referenced by filter().

◆ nLoose_

const unsigned pat::PATJetSelector::nLoose_
protected

Definition at line 223 of file PATObjectSelector.cc.

Referenced by filter().

◆ selector_

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

Definition at line 224 of file PATObjectSelector.cc.

Referenced by filter().

◆ selectorLoose_

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

Definition at line 225 of file PATObjectSelector.cc.

Referenced by filter().

◆ srcToken_

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

Definition at line 219 of file PATObjectSelector.cc.

Referenced by filter().

edm::RefProd
Definition: EDProductfwd.h:25
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
pat::PATJetSelector::selector_
const StringCutObjectSelector< Jet > selector_
Definition: PATObjectSelector.cc:224
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
reco::GenJetCollection
std::vector< GenJet > GenJetCollection
collection of GenJet objects
Definition: GenJetCollection.h:14
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
pat::PATJetSelector::filter_
const bool filter_
Definition: PATObjectSelector.cc:222
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
pat::PATJetSelector::nLoose_
const unsigned nLoose_
Definition: PATObjectSelector.cc:223
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref
Definition: AssociativeIterator.h:58
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSetDescription::setComment
void setComment(std::string const &value)
Definition: ParameterSetDescription.cc:33
pat::PATJetSelector::cutLoose_
const std::string cutLoose_
Definition: PATObjectSelector.cc:221
iEvent
int iEvent
Definition: GenABIO.cc:224
hemisphereProducer_cfi.patJets
patJets
Definition: hemisphereProducer_cfi.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Ptr
Definition: AssociationVector.h:31
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
pat::PATJetSelector::srcToken_
const edm::EDGetTokenT< edm::View< pat::Jet > > srcToken_
Definition: PATObjectSelector.cc:219
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
pat::PATJetSelector::cut_
const std::string cut_
Definition: PATObjectSelector.cc:220
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
pat::PATJetSelector::selectorLoose_
const StringCutObjectSelector< Jet > selectorLoose_
Definition: PATObjectSelector.cc:225
edm::InputTag
Definition: InputTag.h:15
edm::OwnVector< reco::BaseTagInfo >