CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1TPFCandMultiMerger.cc
Go to the documentation of this file.
2 
9 #include <vector>
10 
12 public:
13  explicit L1TPFCandMultiMerger(const edm::ParameterSet&);
14  ~L1TPFCandMultiMerger() override;
15 
16 private:
17  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
18 
19  std::vector<std::string> instances_;
20  std::vector<edm::EDGetTokenT<std::vector<l1t::PFCandidate>>> tokens_;
21 };
22 
24  : instances_(iConfig.getParameter<std::vector<std::string>>("labelsToMerge")) {
25  const std::vector<edm::InputTag>& pfProducers = iConfig.getParameter<std::vector<edm::InputTag>>("pfProducers");
26  tokens_.reserve(instances_.size() * pfProducers.size());
27  for (unsigned int ii = 0, ni = instances_.size(); ii < ni; ++ii) {
28  for (const edm::InputTag& tag : pfProducers) {
29  tokens_.push_back(
30  consumes<std::vector<l1t::PFCandidate>>(edm::InputTag(tag.label(), instances_[ii], tag.process())));
31  }
32  produces<std::vector<l1t::PFCandidate>>(instances_[ii]);
33  }
34 }
35 
37 
40  for (unsigned int ii = 0, it = 0, ni = instances_.size(), np = tokens_.size() / ni; ii < ni; ++ii) {
41  auto out = std::make_unique<std::vector<l1t::PFCandidate>>();
42  for (unsigned int ip = 0; ip < np; ++ip, ++it) {
43  iEvent.getByToken(tokens_[it], handle);
44  out->insert(out->end(), handle->begin(), handle->end());
45  }
46  iEvent.put(std::move(out), instances_[ii]);
47  }
48 }
49 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int ii
Definition: cuy.py:589
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
int np
Definition: AMPTWrapper.h:43
def move
Definition: eostools.py:511
tuple handle
Definition: patZpeak.py:23
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > instances_
L1TPFCandMultiMerger(const edm::ParameterSet &)
std::vector< edm::EDGetTokenT< std::vector< l1t::PFCandidate > > > tokens_