CMS 3D CMS Logo

MCMatchCandRefSelector.cc
Go to the documentation of this file.
11 
12 using namespace edm;
13 using namespace reco;
14 using namespace std;
15 
16 namespace reco {
17  namespace modules {
18 
20  public:
22  void newEvent(const Event& evt, const EventSetup&);
23  bool operator()(const CandidateBaseRef&) const;
24 
25  private:
27  const GenParticleMatch* match_ = nullptr;
28  };
29 
30  void MCMatchCandRefSelector::newEvent(const Event& evt, const EventSetup&) {
32  evt.getByToken(srcToken_, match);
33  match_ = match.product();
34  }
35 
36  bool MCMatchCandRefSelector::operator()(const CandidateBaseRef& c) const {
37  GenParticleRef m = (*match_)[c];
38  return m.isNonnull();
39  }
40 
41  template <>
44  return MCMatchCandRefSelector(iC.consumes<GenParticleMatch>(cfg.getParameter<InputTag>("match")));
45  }
46  };
47 
48  } // namespace modules
49 } // namespace reco
50 
52 
54 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
static MCMatchCandRefSelector make(const ParameterSet &cfg, edm::ConsumesCollector &iC)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
#define EVENTSETUP_STD_INIT(SELECTOR)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
SingleObjectRefSelector< Candidate, reco::modules::MCMatchCandRefSelector > MCMatchCandRefSelector
fixed size matrix
HLT enums.
EDGetTokenT< GenParticleMatch > srcToken_
MCMatchCandRefSelector(const EDGetTokenT< GenParticleMatch > &srcToken)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)