Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-22 02:24:04

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   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0027     edm::ParameterSetDescription desc;
0028     desc.add<std::vector<edm::InputTag>>("inputs", {});
0029     descriptions.addWithDefaultLabel(desc);
0030   }
0031 
0032   void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& es) const override {
0033     auto output = std::make_unique<reco::PFClusterCollection>();
0034     for (const auto& input : _inputs) {
0035       edm::Handle<reco::PFClusterCollection> handle;
0036       e.getByToken(input, handle);
0037       output->insert(output->end(), handle->begin(), handle->end());
0038     }
0039     e.put(std::move(output));
0040   }
0041 
0042 private:
0043   std::vector<edm::EDGetTokenT<reco::PFClusterCollection>> _inputs;
0044 };
0045 
0046 DEFINE_FWK_MODULE(PFClusterCollectionMerger);
0047 
0048 #endif