File indexing completed on 2024-04-06 12:23:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDProducer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/Utilities/interface/StreamID.h"
0031
0032 #include "DataFormats/JetReco/interface/GenJet.h"
0033 #include "DataFormats/Common/interface/ValueMap.h"
0034
0035
0036
0037
0038
0039 class GenJetTauTaggerProducer : public edm::stream::EDProducer<> {
0040 public:
0041 explicit GenJetTauTaggerProducer(const edm::ParameterSet& iConfig)
0042 : src_(consumes<std::vector<reco::GenJet>>(iConfig.getParameter<edm::InputTag>("src"))) {
0043 produces<edm::ValueMap<bool>>();
0044 }
0045 ~GenJetTauTaggerProducer() override;
0046
0047 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0048
0049 private:
0050 void produce(edm::Event&, const edm::EventSetup&) override;
0051 edm::EDGetTokenT<std::vector<reco::GenJet>> src_;
0052 };
0053
0054 GenJetTauTaggerProducer::~GenJetTauTaggerProducer() {}
0055
0056
0057
0058
0059
0060
0061 void GenJetTauTaggerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0062 using namespace edm;
0063
0064 auto jets = iEvent.getHandle(src_);
0065
0066 std::vector<bool> tags;
0067
0068 for (auto jet = jets->begin(); jet != jets->end(); ++jet) {
0069 bool found = false;
0070 for (auto cand : jet->getJetConstituentsQuick()) {
0071 if (abs(cand->pdgId()) == 15)
0072 found = true;
0073 }
0074 tags.push_back(found);
0075 }
0076
0077 auto tagsV = std::make_unique<edm::ValueMap<bool>>();
0078 edm::ValueMap<bool>::Filler fillerCorr(*tagsV);
0079 fillerCorr.insert(jets, tags.begin(), tags.end());
0080 fillerCorr.fill();
0081 iEvent.put(std::move(tagsV));
0082 }
0083
0084 void GenJetTauTaggerProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0085
0086
0087 edm::ParameterSetDescription desc;
0088 desc.add<edm::InputTag>("src")->setComment("input physics object collection");
0089 descriptions.addDefault(desc);
0090 }
0091
0092
0093 DEFINE_FWK_MODULE(GenJetTauTaggerProducer);