CMS 3D CMS Logo

CollectionCombiner.h
Go to the documentation of this file.
1 #ifndef CollectionCombiner_H
2 #define CollectionCombiner_H
3 
14 // system include files
15 #include <memory>
16 
17 // user include files
20 
23 
25 
26 template <typename Collection>
28 public:
29  explicit CollectionCombiner(const edm::ParameterSet&);
30  ~CollectionCombiner() override;
31 
32 private:
33  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
34 
35  // ----------member data ---------------------------
36  std::vector<edm::InputTag> labels;
37  std::vector<edm::EDGetTokenT<Collection> > collectionTokens;
38 };
39 
40 template <typename Collection>
42  labels = iConfig.getParameter<std::vector<edm::InputTag> >("labels");
43  produces<Collection>();
44  for (unsigned int i = 0; i < labels.size(); ++i)
45  collectionTokens.push_back(consumes<Collection>(labels.at(i)));
46 }
47 template <typename Collection>
49 
50 template <typename Collection>
52  unsigned int i = 0, i_max = labels.size();
54  auto merged = std::make_unique<Collection>();
55  for (; i != i_max; ++i) {
56  iEvent.getByToken(collectionTokens[i], handle);
57  merged->insert(merged->end(), handle->begin(), handle->end());
58  }
59  iEvent.put(std::move(merged));
60 }
61 
62 #endif
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::StreamID
Definition: StreamID.h:30
CollectionCombiner::labels
std::vector< edm::InputTag > labels
Definition: CollectionCombiner.h:36
mps_fire.i
i
Definition: mps_fire.py:428
CollectionCombiner::CollectionCombiner
CollectionCombiner(const edm::ParameterSet &)
Definition: CollectionCombiner.h:41
patZpeak.handle
handle
Definition: patZpeak.py:23
CollectionCombiner::~CollectionCombiner
~CollectionCombiner() override
Definition: CollectionCombiner.h:48
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
CollectionCombiner::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: CollectionCombiner.h:51
CollectionCombiner::collectionTokens
std::vector< edm::EDGetTokenT< Collection > > collectionTokens
Definition: CollectionCombiner.h:37
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
CollectionCombiner
Definition: CollectionCombiner.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73