CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GenJetFlavourTableProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
9 
13 
18 
20 
23 
25 public:
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  }
35 
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
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  }
47 
48 private:
49  void produce(edm::Event&, edm::EventSetup const&) override;
50 
54  const double deltaR_;
56 };
57 
58 // ------------ method called to produce the data ------------
61  iEvent.getByToken(src_, jets);
62 
65 
66  unsigned int ncand = 0;
67  std::vector<int> partonFlavour;
68  std::vector<uint8_t> hadronFlavour;
69 
70  for (const reco::GenJet& jet : *jets) {
71  if (!cut_(jet))
72  continue;
73  ++ncand;
74  bool matched = false;
75  for (const reco::JetFlavourInfoMatching& jetFlavourInfoMatching : *jetFlavourInfos) {
76  if (deltaR(jet.p4(), jetFlavourInfoMatching.first->p4()) < deltaR_) {
77  partonFlavour.push_back(jetFlavourInfoMatching.second.getPartonFlavour());
78  hadronFlavour.push_back(jetFlavourInfoMatching.second.getHadronFlavour());
79  matched = true;
80  break;
81  }
82  }
83  if (!matched) {
84  partonFlavour.push_back(0);
85  hadronFlavour.push_back(0);
86  }
87  }
88 
89  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
90  tab->addColumn<int>("partonFlavour", partonFlavour, "flavour from parton matching", nanoaod::FlatTable::IntColumn);
91  tab->addColumn<uint8_t>(
92  "hadronFlavour", hadronFlavour, "flavour from hadron ghost clustering", nanoaod::FlatTable::UInt8Column);
93 
94  iEvent.put(std::move(tab));
95 }
96 
98 //define this as a plug-in
ConfigurationDescriptions.h
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
JetFlavourInfo.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
GenJetFlavourTableProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GenJetFlavourTableProducer.cc:38
jets_cff.hadronFlavour
hadronFlavour
Definition: jets_cff.py:531
edm::EDGetTokenT
Definition: EDGetToken.h:33
JetFlavourInfoMatching.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::GenJetCollection >
deltaR.h
GenJetFlavourTableProducer::name_
std::string name_
Definition: GenJetFlavourTableProducer.cc:51
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GenJetFlavourTableProducer::deltaR_
const double deltaR_
Definition: GenJetFlavourTableProducer.cc:54
ParameterSetDescription.h
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
GenJetFlavourTableProducer::~GenJetFlavourTableProducer
~GenJetFlavourTableProducer() override
Definition: GenJetFlavourTableProducer.cc:36
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
nanoaod::FlatTable::UInt8Column
Definition: FlatTable.h:41
FlatTable.h
GenJetFlavourTableProducer::GenJetFlavourTableProducer
GenJetFlavourTableProducer(const edm::ParameterSet &iConfig)
Definition: GenJetFlavourTableProducer.cc:26
nanoaod::FlatTable::IntColumn
Definition: FlatTable.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
jets_cff.partonFlavour
partonFlavour
Definition: jets_cff.py:530
StringCutObjectSelector.h
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
StringCutObjectSelector< reco::GenJet >
reco::JetFlavourInfoMatching
JetFlavourInfoMatchingCollection::value_type JetFlavourInfoMatching
Definition: JetFlavourInfoMatching.h:26
GenJetFlavourTableProducer::src_
edm::EDGetTokenT< std::vector< reco::GenJet > > src_
Definition: GenJetFlavourTableProducer.cc:52
GenJetFlavourTableProducer
Definition: GenJetFlavourTableProducer.cc:24
GenJet.h
nanoDQM_cfi.GenJet
GenJet
Definition: nanoDQM_cfi.py:226
GenHFHadronMatcher_cfi.jetFlavourInfos
jetFlavourInfos
Definition: GenHFHadronMatcher_cfi.py:5
ParameterSet.h
edm::Event
Definition: Event.h:73
StringObjectFunction.h
GenJetFlavourTableProducer::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: GenJetFlavourTableProducer.cc:59
edm::InputTag
Definition: InputTag.h:15
GenJetFlavourTableProducer::jetFlavourInfosToken_
edm::EDGetTokenT< reco::JetFlavourInfoMatchingCollection > jetFlavourInfosToken_
Definition: GenJetFlavourTableProducer.cc:55
GenJetFlavourTableProducer::cut_
const StringCutObjectSelector< reco::GenJet > cut_
Definition: GenJetFlavourTableProducer.cc:53