CMS 3D CMS Logo

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

Public Member Functions

 GenJetFlavourTableProducer (const edm::ParameterSet &iConfig)
 
 ~GenJetFlavourTableProducer () 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 &, edm::EventSetup const &) override
 

Private Attributes

const StringCutObjectSelector< reco::GenJetcut_
 
const double deltaR_
 
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollectionjetFlavourInfosToken_
 
std::string name_
 
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
 

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

Definition at line 24 of file GenJetFlavourTableProducer.cc.

Constructor & Destructor Documentation

◆ GenJetFlavourTableProducer()

GenJetFlavourTableProducer::GenJetFlavourTableProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 26 of file GenJetFlavourTableProducer.cc.

27  : name_(iConfig.getParameter<std::string>("name")),
28  src_(consumes<std::vector<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src"))),
29  cut_(iConfig.getParameter<std::string>("cut"), true),
30  deltaR_(iConfig.getParameter<double>("deltaR")),
32  consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("jetFlavourInfos"))) {
33  produces<nanoaod::FlatTable>();
34  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
const StringCutObjectSelector< reco::GenJet > cut_

◆ ~GenJetFlavourTableProducer()

GenJetFlavourTableProducer::~GenJetFlavourTableProducer ( )
inlineoverride

Definition at line 36 of file GenJetFlavourTableProducer.cc.

36 {};

Member Function Documentation

◆ fillDescriptions()

static void GenJetFlavourTableProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 38 of file GenJetFlavourTableProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

38  {
40  desc.add<edm::InputTag>("src")->setComment("input genJet collection");
41  desc.add<edm::InputTag>("jetFlavourInfos")->setComment("input flavour info collection");
42  desc.add<std::string>("name")->setComment("name of the genJet FlatTable we are extending with flavour information");
43  desc.add<std::string>("cut")->setComment("cut on input genJet collection");
44  desc.add<double>("deltaR")->setComment("deltaR to match genjets");
45  descriptions.add("genJetFlavourTable", desc);
46  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void GenJetFlavourTableProducer::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 59 of file GenJetFlavourTableProducer.cc.

References cut_, PbPb_ZMuSkimMuonDPG_cff::deltaR, deltaR_, custom_jme_cff::hadronFlavour, iEvent, metsig::jet, jetFlavourInfosToken_, muonTagProbeFilters_cff::matched, eostools::move(), name_, btvMC_cff::nBHadrons, btvMC_cff::nCHadrons, custom_jme_cff::partonFlavour, and src_.

59  {
60  const auto& jetsProd = iEvent.get(src_);
61  const auto& jetFlavourInfosProd = iEvent.get(jetFlavourInfosToken_);
62 
63  unsigned int ncand = 0;
64  std::vector<int16_t> partonFlavour;
65  std::vector<uint8_t> hadronFlavour;
66  std::vector<uint8_t> nBHadrons;
67  std::vector<uint8_t> nCHadrons;
68 
69  for (const reco::GenJet& jet : jetsProd) {
70  if (!cut_(jet))
71  continue;
72  ++ncand;
73  bool matched = false;
74  for (const reco::JetFlavourInfoMatching& jetFlavourInfoMatching : jetFlavourInfosProd) {
75  if (deltaR(jet.p4(), jetFlavourInfoMatching.first->p4()) < deltaR_) {
76  partonFlavour.push_back(jetFlavourInfoMatching.second.getPartonFlavour());
77  hadronFlavour.push_back(jetFlavourInfoMatching.second.getHadronFlavour());
78  nBHadrons.push_back(jetFlavourInfoMatching.second.getbHadrons().size());
79  nCHadrons.push_back(jetFlavourInfoMatching.second.getcHadrons().size());
80  matched = true;
81  break;
82  }
83  }
84  if (!matched) {
85  partonFlavour.push_back(0);
86  hadronFlavour.push_back(0);
87  nBHadrons.push_back(0);
88  nCHadrons.push_back(0);
89  }
90  }
91 
92  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
93  tab->addColumn<int16_t>("partonFlavour", partonFlavour, "flavour from parton matching");
94  tab->addColumn<uint8_t>("hadronFlavour", hadronFlavour, "flavour from hadron ghost clustering");
95  tab->addColumn<uint8_t>("nBHadrons", nBHadrons, "number of b-hadrons");
96  tab->addColumn<uint8_t>("nCHadrons", nCHadrons, "number of c-hadrons");
97 
98  iEvent.put(std::move(tab));
99 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
Jets made from MC generator particles.
Definition: GenJet.h:23
JetFlavourInfoMatchingCollection::value_type JetFlavourInfoMatching
const StringCutObjectSelector< reco::GenJet > cut_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ cut_

const StringCutObjectSelector<reco::GenJet> GenJetFlavourTableProducer::cut_
private

Definition at line 53 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

◆ deltaR_

const double GenJetFlavourTableProducer::deltaR_
private

Definition at line 54 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

◆ jetFlavourInfosToken_

edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> GenJetFlavourTableProducer::jetFlavourInfosToken_
private

Definition at line 55 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

◆ name_

std::string GenJetFlavourTableProducer::name_
private

Definition at line 51 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

◆ src_

edm::EDGetTokenT<std::vector<reco::GenJet> > GenJetFlavourTableProducer::src_
private

Definition at line 52 of file GenJetFlavourTableProducer.cc.

Referenced by produce().