3 #include "FWCore/Framework/interface/Event.h"
4 #include "FWCore/Framework/interface/EventSetup.h"
5 #include "FWCore/Framework/interface/MakerMacros.h"
6 #include "FWCore/ParameterSet/interface/ParameterSet.h"
7 #include "FWCore/Utilities/interface/InputTag.h"
8 #include "DataFormats/Common/interface/Handle.h"
9 #include "DataFormats/Common/interface/ValueMap.h"
10 #include "SimDataFormats/JetMatching/interface/JetFlavourInfoMatching.h"
11 #include "SimDataFormats/JetMatching/interface/JetFlavourMatching.h"
15 const edm::ParameterSet& config)
16 : input_(config.getParameter<
edm::InputTag>(
"input")),
17 input_jet_flavour_(config.getParameter<
edm::InputTag>(
"flavourMap")) {
18 consumes<edm::View<reco::Jet>>(input_);
19 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION==7 && CMSSW_MINOR_VERSION >=4)
20 consumes<reco::JetFlavourInfoMatchingCollection>(input_jet_flavour_);
22 consumes<reco::JetFlavourMatchingCollection>(input_jet_flavour_);
24 produces<edm::ValueMap<std::vector<int>> >();
29 void ICJetFlavourCalculator::produce(edm::Event& event,
30 const edm::EventSetup& setup) {
31 std::auto_ptr<edm::ValueMap<std::vector<int>> > product(
new edm::ValueMap<std::vector<int>>());
32 edm::Handle <edm::View <reco::Jet> > jets_handle;
33 event.getByLabel(input_, jets_handle);
35 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION==7 && CMSSW_MINOR_VERSION >=4 )
36 edm::Handle<reco::JetFlavourInfoMatchingCollection> flavour_handle;
38 edm::Handle<reco::JetFlavourMatchingCollection> flavour_handle;
40 event.getByLabel(input_jet_flavour_, flavour_handle);
42 std::vector<int> dummy_vec(2,0);
43 std::vector<std::vector<int>> values(jets_handle->size(), dummy_vec);
44 for (
unsigned i = 0; i < jets_handle->size(); ++i) {
45 #if CMSSW_MAJOR_VERSION > 7 || (CMSSW_MAJOR_VERSION==7 && CMSSW_MINOR_VERSION>=4)
46 values[i].at(0) = (*flavour_handle)[jets_handle->refAt(i)].getPartonFlavour();
47 values[i].at(1) = (*flavour_handle)[jets_handle->refAt(i)].getHadronFlavour();
49 values[i].at(0) = (*flavour_handle)[jets_handle->refAt(i)].getFlavour();
53 edm::ValueMap<std::vector<int>>::Filler filler(*product);
54 filler.insert(jets_handle, values.begin(), values.end());
60 void ICJetFlavourCalculator::beginJob() {}
62 void ICJetFlavourCalculator::endJob() {}
ICJetFlavourCalculator(const edm::ParameterSet &)
DEFINE_FWK_MODULE(ICJetFlavourCalculator)
~ICJetFlavourCalculator()