CMS 3D CMS Logo

CandPtrProjector.cc
Go to the documentation of this file.
10 
12 public:
13  explicit CandPtrProjector(edm::ParameterSet const& iConfig);
14  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
15 
16 private:
19 };
20 
22  : candSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("src"))},
23  vetoSrcToken_{consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("veto"))} {
24  produces<edm::PtrVector<reco::Candidate>>();
25 }
26 
28  using namespace edm;
30  iEvent.getByToken(vetoSrcToken_, vetoes);
31 
32  auto result = std::make_unique<PtrVector<reco::Candidate>>();
33  std::set<reco::CandidatePtr> vetoedPtrs;
34  for (auto const& veto : *vetoes) {
35  auto const n = veto.numberOfSourceCandidatePtrs();
36  for (size_t j{}; j < n; ++j) {
37  vetoedPtrs.insert(veto.sourceCandidatePtr(j));
38  }
39  }
40 
42  iEvent.getByToken(candSrcToken_, cands);
43  for (size_t i{}; i < cands->size(); ++i) {
44  auto const c = cands->ptrAt(i);
45  if (vetoedPtrs.find(c) == vetoedPtrs.cend()) {
46  result->push_back(c);
47  }
48  }
49  iEvent.put(std::move(result));
50 }
51 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< edm::View< reco::Candidate > > vetoSrcToken_
CandPtrProjector(edm::ParameterSet const &iConfig)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::View< reco::Candidate > > candSrcToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511