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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenJetFlavourTableProducer (const edm::ParameterSet &iConfig)
 
 ~GenJetFlavourTableProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (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<>
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::EDProducerBase
typedef EDProducerAdaptorBase 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 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 24 of file GenJetFlavourTableProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 26 of file GenJetFlavourTableProducer.cc.

26  :
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")),
31  jetFlavourInfosToken_(consumes<reco::JetFlavourInfoMatchingCollection>(iConfig.getParameter<edm::InputTag>("jetFlavourInfos")))
32  {
33  produces<nanoaod::FlatTable>();
34  }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
const StringCutObjectSelector< reco::GenJet > cut_
GenJetFlavourTableProducer::~GenJetFlavourTableProducer ( )
inlineoverride

Definition at line 36 of file GenJetFlavourTableProducer.cc.

36 {};

Member Function Documentation

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

Definition at line 38 of file GenJetFlavourTableProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), produce(), 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  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void GenJetFlavourTableProducer::produce ( edm::Event ,
edm::EventSetup const &   
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 61 of file GenJetFlavourTableProducer.cc.

References cut_, DEFINE_FWK_MODULE, deltaR(), deltaR_, edm::Event::getByToken(), jets_cff::hadronFlavour, nanoaod::FlatTable::IntColumn, metsig::jet, GenHFHadronMatcher_cfi::jetFlavourInfos, jetFlavourInfosToken_, fwrapper::jets, electrons_cff::matched, eostools::move(), name_, jets_cff::partonFlavour, edm::Event::put(), src_, and nanoaod::FlatTable::UInt8Column.

Referenced by fillDescriptions().

62 {
64  iEvent.getByToken(src_, jets);
65 
67  iEvent.getByToken(jetFlavourInfosToken_, jetFlavourInfos);
68 
69  unsigned int ncand = 0;
70  std::vector<int> partonFlavour;
71  std::vector<uint8_t> hadronFlavour;
72 
73  for (const reco::GenJet & jet : *jets) {
74  if (!cut_(jet)) continue;
75  ++ncand;
76  bool matched = false;
77  for (const reco::JetFlavourInfoMatching & jetFlavourInfoMatching : *jetFlavourInfos) {
78  if (deltaR(jet.p4(), jetFlavourInfoMatching.first->p4()) < deltaR_) {
79  partonFlavour.push_back(jetFlavourInfoMatching.second.getPartonFlavour());
80  hadronFlavour.push_back(jetFlavourInfoMatching.second.getHadronFlavour());
81  matched = true;
82  break;
83  }
84  }
85  if (!matched) {
86  partonFlavour.push_back(0);
87  hadronFlavour.push_back(0);
88  }
89  }
90 
91  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
92  tab->addColumn<int>("partonFlavour", partonFlavour, "flavour from parton matching", nanoaod::FlatTable::IntColumn);
93  tab->addColumn<uint8_t>("hadronFlavour", hadronFlavour, "flavour from hadron ghost clustering", nanoaod::FlatTable::UInt8Column);
94 
95  iEvent.put(std::move(tab));
96 }
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
vector< PseudoJet > jets
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
Jets made from MC generator particles.
Definition: GenJet.h:24
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
JetFlavourInfoMatchingCollection::value_type JetFlavourInfoMatching
const StringCutObjectSelector< reco::GenJet > cut_
hadronFlavour
Definition: jets_cff.py:303
partonFlavour
Definition: jets_cff.py:302
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 53 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

const double GenJetFlavourTableProducer::deltaR_
private

Definition at line 54 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

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

Definition at line 55 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

std::string GenJetFlavourTableProducer::name_
private

Definition at line 51 of file GenJetFlavourTableProducer.cc.

Referenced by produce().

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

Definition at line 52 of file GenJetFlavourTableProducer.cc.

Referenced by produce().