Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:40

0001 #include <string>
0002 #include <memory>
0003 
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/global/EDProducer.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 
0010 #include "DataFormats/Common/interface/RefToPtr.h"
0011 #include "DataFormats/Candidate/interface/Candidate.h"
0012 #include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
0013 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0014 
0015 namespace pat {
0016   class UnclusteredBlobProducer : public edm::global::EDProducer<> {
0017   public:
0018     explicit UnclusteredBlobProducer(const edm::ParameterSet&);
0019     ~UnclusteredBlobProducer() override;
0020     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0021     void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0022 
0023   private:
0024     edm::EDGetTokenT<edm::View<reco::Candidate>> candsrc_;
0025   };
0026 }  // namespace pat
0027 
0028 pat::UnclusteredBlobProducer::UnclusteredBlobProducer(const edm::ParameterSet& iConfig)
0029     : candsrc_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("candsrc"))) {
0030   produces<std::vector<reco::VertexCompositePtrCandidate>>();
0031 }
0032 
0033 pat::UnclusteredBlobProducer::~UnclusteredBlobProducer() {}
0034 
0035 void pat::UnclusteredBlobProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0036   auto blob = std::make_unique<std::vector<reco::VertexCompositePtrCandidate>>();
0037 
0038   edm::Handle<edm::View<reco::Candidate>> candidates;
0039   iEvent.getByToken(candsrc_, candidates);
0040 
0041   blob->emplace_back();
0042 
0043   auto& c_blob = blob->back();
0044 
0045   // combine all candidates into composite so they can be accessed properly by CandPtrSelector
0046   for (unsigned i = 0; i < candidates->size(); ++i) {
0047     c_blob.addDaughter(candidates->ptrAt(i));
0048   }
0049 
0050   iEvent.put(std::move(blob));
0051 }
0052 
0053 void pat::UnclusteredBlobProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0054   edm::ParameterSetDescription desc;
0055   desc.add<edm::InputTag>("candsrc", edm::InputTag("badUnclustered"));
0056 
0057   descriptions.add("UnclusteredBlobProducer", desc);
0058 }
0059 
0060 using pat::UnclusteredBlobProducer;
0061 
0062 #include "FWCore/Framework/interface/MakerMacros.h"
0063 DEFINE_FWK_MODULE(UnclusteredBlobProducer);