Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:41

0001 // -*- C++ -*-
0002 //
0003 // Package:    PhysicsTools/NanoAOD
0004 // Class:      GenJetTauTaggerProducer
0005 //
0006 /**\class GenJetTauTaggerProducer GenJetTauTaggerProducer.cc PhysicsTools/NanoAOD/plugins/GenJetTauTaggerProducer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Elisabetta Manca
0015 //         Created:  Wed, 08 May 2019 13:09:28 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
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 // class declaration
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 // member functions
0058 //
0059 
0060 // ------------ method called to produce the data  ------------
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   //The following says we do not know what parameters are allowed so do no validation
0086   // Please change this to state exactly what you do use, even if it is no parameters
0087   edm::ParameterSetDescription desc;
0088   desc.add<edm::InputTag>("src")->setComment("input physics object collection");
0089   descriptions.addDefault(desc);
0090 }
0091 
0092 //define this as a plug-in
0093 DEFINE_FWK_MODULE(GenJetTauTaggerProducer);