Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:24

0001 #ifndef __PFClusterCollectionMerger__
0002 #define __PFClusterCollectionMerger__
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/global/EDProducer.h"
0007 
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0014 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0015 
0016 class PFClusterCollectionMerger : public edm::global::EDProducer<> {
0017 public:
0018   PFClusterCollectionMerger(const edm::ParameterSet& conf) {
0019     const std::vector<edm::InputTag>& inputs = conf.getParameter<std::vector<edm::InputTag> >("inputs");
0020     for (const auto& input : inputs) {
0021       _inputs.push_back(consumes<reco::PFClusterCollection>(input));
0022     }
0023     produces<reco::PFClusterCollection>();
0024   }
0025 
0026   void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& es) const override {
0027     auto output = std::make_unique<reco::PFClusterCollection>();
0028     for (const auto& input : _inputs) {
0029       edm::Handle<reco::PFClusterCollection> handle;
0030       e.getByToken(input, handle);
0031       output->insert(output->end(), handle->begin(), handle->end());
0032     }
0033     e.put(std::move(output));
0034   }
0035 
0036 private:
0037   std::vector<edm::EDGetTokenT<reco::PFClusterCollection> > _inputs;
0038 };
0039 
0040 DEFINE_FWK_MODULE(PFClusterCollectionMerger);
0041 
0042 #endif