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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 24 of file PATObjectSelector.cc.

Constructor & Destructor Documentation

◆ PATJetSelector()

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

Definition at line 26 of file PATObjectSelector.cc.

27  : srcToken_(consumes<edm::View<pat::Jet>>(params.getParameter<edm::InputTag>("src"))),
28  cut_(params.getParameter<std::string>("cut")),
29  cutLoose_(params.getParameter<std::string>("cutLoose")),
30  filter_(params.exists("filter") ? params.getParameter<bool>("filter") : false),
31  nLoose_(params.getParameter<unsigned>("nLoose")),
32  selector_(cut_),
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_
const StringCutObjectSelector< Jet > selectorLoose_
const std::string cutLoose_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::string cut_
const edm::EDGetTokenT< edm::View< pat::Jet > > srcToken_

◆ ~PATJetSelector()

pat::PATJetSelector::~PATJetSelector ( )
inlineoverride

Definition at line 41 of file PATObjectSelector.cc.

41 {}

Member Function Documentation

◆ beginJob()

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

Definition at line 43 of file PATObjectSelector.cc.

43 {}

◆ endJob()

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

Definition at line 44 of file PATObjectSelector.cc.

44 {}

◆ fillDescriptions()

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

Definition at line 206 of file PATObjectSelector.cc.

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

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

◆ filter()

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

Implements edm::stream::EDFilterBase.

Definition at line 46 of file PATObjectSelector.cc.

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

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

◆ cut_

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

Definition at line 219 of file PATObjectSelector.cc.

◆ cutLoose_

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

Definition at line 220 of file PATObjectSelector.cc.

◆ filter_

const bool pat::PATJetSelector::filter_
protected

Definition at line 221 of file PATObjectSelector.cc.

Referenced by filter().

◆ nLoose_

const unsigned pat::PATJetSelector::nLoose_
protected

Definition at line 222 of file PATObjectSelector.cc.

Referenced by filter().

◆ selector_

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

Definition at line 223 of file PATObjectSelector.cc.

Referenced by filter().

◆ selectorLoose_

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

Definition at line 224 of file PATObjectSelector.cc.

Referenced by filter().

◆ srcToken_

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

Definition at line 218 of file PATObjectSelector.cc.

Referenced by filter().