CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SimpleJetConstituentTableProducer< T > Class Template Reference
Inheritance diagram for SimpleJetConstituentTableProducer< T >:
edm::stream::EDProducer<>

Public Member Functions

 SimpleJetConstituentTableProducer (const edm::ParameterSet &)
 
 ~SimpleJetConstituentTableProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=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 EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::CandidateViewcand_token_
 
const std::string candIdxDoc_
 
const std::string candIdxName_
 
edm::Handle< reco::CandidateViewcands_
 
edm::EDGetTokenT< edm::View< T > > jet_token_
 
const StringCutObjectSelector< TjetCut_
 
const std::string name_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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
 

Detailed Description

template<typename T>
class SimpleJetConstituentTableProducer< T >

Definition at line 20 of file SimpleJetConstituentTableProducer.cc.

Constructor & Destructor Documentation

◆ SimpleJetConstituentTableProducer()

template<typename T >
SimpleJetConstituentTableProducer< T >::SimpleJetConstituentTableProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 46 of file SimpleJetConstituentTableProducer.cc.

References SimpleJetConstituentTableProducer< T >::name_.

47  : name_(iConfig.getParameter<std::string>("name")),
48  candIdxName_(iConfig.getParameter<std::string>("candIdxName")),
49  candIdxDoc_(iConfig.getParameter<std::string>("candIdxDoc")),
50  jet_token_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("jets"))),
51  cand_token_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("candidates"))),
52  jetCut_(iConfig.getParameter<std::string>("jetCut")) {
53  produces<nanoaod::FlatTable>(name_);
54  produces<std::vector<reco::CandidatePtr>>();
55 }
edm::EDGetTokenT< edm::View< T > > jet_token_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const StringCutObjectSelector< T > jetCut_
edm::EDGetTokenT< reco::CandidateView > cand_token_

◆ ~SimpleJetConstituentTableProducer()

Definition at line 58 of file SimpleJetConstituentTableProducer.cc.

58 {}

Member Function Documentation

◆ fillDescriptions()

template<typename T >
void SimpleJetConstituentTableProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 121 of file SimpleJetConstituentTableProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

121  {
123  desc.add<std::string>("name", "FatJetPFCand");
124  desc.add<std::string>("candIdxName", "PFCandIdx");
125  desc.add<std::string>("candIdxDoc", "Index in PFCand table");
126  desc.add<edm::InputTag>("jets", edm::InputTag("finalJetsAK8"));
127  desc.add<edm::InputTag>("candidates", edm::InputTag("packedPFCandidates"));
128  desc.add<std::string>("jetCut", "");
129  descriptions.addWithDefaultLabel(desc);
130 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

template<typename T >
void SimpleJetConstituentTableProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 61 of file SimpleJetConstituentTableProducer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), BPhysicsValidation_cfi::daughters, spr::find(), iEvent, metsig::jet, boostedTaus_cff::jetIdx, PDWG_EXODelayedJetMET_cff::jets, eostools::move(), AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

61  {
62  // elements in all these collections must have the same order!
63  auto outCands = std::make_unique<std::vector<reco::CandidatePtr>>();
64 
65  auto jets = iEvent.getHandle(jet_token_);
66 
67  iEvent.getByToken(cand_token_, cands_);
68  auto candPtrs = cands_->ptrs();
69 
70  //
71  // First, select jets
72  //
73  std::vector<T> jetsPassCut;
74  for (unsigned jetIdx = 0; jetIdx < jets->size(); ++jetIdx) {
75  const auto &jet = jets->at(jetIdx);
76  if (!jetCut_(jet))
77  continue;
78  jetsPassCut.push_back(jets->at(jetIdx));
79  }
80 
81  //
82  // Then loop over selected jets
83  //
84  std::vector<int> parentJetIdx;
85  std::vector<int> candIdx;
86  for (unsigned jetIdx = 0; jetIdx < jetsPassCut.size(); ++jetIdx) {
87  const auto &jet = jetsPassCut.at(jetIdx);
88 
89  //
90  // Loop over jet constituents
91  //
92  std::vector<reco::CandidatePtr> const &daughters = jet.daughterPtrVector();
93  for (const auto &cand : daughters) {
94  auto candInNewList = std::find(candPtrs.begin(), candPtrs.end(), cand);
95  if (candInNewList == candPtrs.end()) {
96  continue;
97  }
98  outCands->push_back(cand);
99  parentJetIdx.push_back(jetIdx);
100  candIdx.push_back(candInNewList - candPtrs.begin());
101  }
102  } // end jet loop
103 
104  auto candTable = std::make_unique<nanoaod::FlatTable>(outCands->size(), name_, false);
105  // We fill from here only stuff that cannot be created with the SimpleFlatTableProducer
106  candTable->addColumn<int>(candIdxName_, candIdx, candIdxDoc_);
107 
108  std::string parentJetIdxName("jetIdx");
109  std::string parentJetIdxDoc("Index of the parent jet");
111  parentJetIdxName = "genJetIdx";
112  parentJetIdxDoc = "Index of the parent gen jet";
113  }
114  candTable->addColumn<int>(parentJetIdxName, parentJetIdx, parentJetIdxDoc);
115 
116  iEvent.put(std::move(candTable), name_);
117  iEvent.put(std::move(outCands));
118 }
edm::EDGetTokenT< edm::View< T > > jet_token_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int iEvent
Definition: GenABIO.cc:224
const StringCutObjectSelector< T > jetCut_
edm::EDGetTokenT< reco::CandidateView > cand_token_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ cand_token_

template<typename T >
edm::EDGetTokenT<reco::CandidateView> SimpleJetConstituentTableProducer< T >::cand_token_
private

Definition at line 35 of file SimpleJetConstituentTableProducer.cc.

◆ candIdxDoc_

template<typename T >
const std::string SimpleJetConstituentTableProducer< T >::candIdxDoc_
private

Definition at line 32 of file SimpleJetConstituentTableProducer.cc.

◆ candIdxName_

template<typename T >
const std::string SimpleJetConstituentTableProducer< T >::candIdxName_
private

Definition at line 31 of file SimpleJetConstituentTableProducer.cc.

◆ cands_

template<typename T >
edm::Handle<reco::CandidateView> SimpleJetConstituentTableProducer< T >::cands_
private

Definition at line 39 of file SimpleJetConstituentTableProducer.cc.

◆ jet_token_

template<typename T >
edm::EDGetTokenT<edm::View<T> > SimpleJetConstituentTableProducer< T >::jet_token_
private

Definition at line 34 of file SimpleJetConstituentTableProducer.cc.

◆ jetCut_

template<typename T >
const StringCutObjectSelector<T> SimpleJetConstituentTableProducer< T >::jetCut_
private

Definition at line 37 of file SimpleJetConstituentTableProducer.cc.

◆ name_

template<typename T >
const std::string SimpleJetConstituentTableProducer< T >::name_
private