CMS 3D CMS Logo

CandViewRefMerger.cc
Go to the documentation of this file.
1 /* \class CandViewRefMerger
2  *
3  * Producer of merged references to Candidates
4  *
5  * \author: Luca Lista, INFN
6  *
7  */
8 
16 
18 public:
20  srcTokens_(edm::vector_transform(cfg.getParameter<std::vector<edm::InputTag> >("src"), [this](edm::InputTag const & tag){return consumes<reco::CandidateView>(tag);})) {
21  produces<std::vector<reco::CandidateBaseRef> >();
22  }
23 private:
24  void produce(edm::Event & evt, const edm::EventSetup &) override {
25  std::unique_ptr<std::vector<reco::CandidateBaseRef> > out(new std::vector<reco::CandidateBaseRef>);
26  for(std::vector<edm::EDGetTokenT<reco::CandidateView> >::const_iterator i = srcTokens_.begin(); i != srcTokens_.end(); ++i) {
28  evt.getByToken(*i, src);
29  for(size_t j = 0; j < src->size(); ++j)
30  out->push_back(src->refAt(j));
31  }
32  evt.put(std::move(out));
33  }
34  std::vector<edm::EDGetTokenT<reco::CandidateView> > srcTokens_;
35 };
36 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
CandViewRefMerger(const edm::ParameterSet &cfg)
size_type size() const
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
RefToBase< value_type > refAt(size_type i) const
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcTokens_
HLT enums.
void produce(edm::Event &evt, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:510