CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
21  explicit MCMatchCandRefSelector(const EDGetTokenT<GenParticleMatch>& srcToken) : srcToken_(srcToken) {}
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 <>
45  }
46  };
47 
48  } // namespace modules
49 } // namespace reco
50 
52 
54 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EventSetup & c
static MCMatchCandRefSelector make(const ParameterSet &cfg, edm::ConsumesCollector &iC)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
tuple cfg
Definition: looper.py:296
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
#define EVENTSETUP_STD_INIT(SELECTOR)
SingleObjectRefSelector< Candidate, reco::modules::MCMatchCandRefSelector > MCMatchCandRefSelector
T const * product() const
Definition: Handle.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EDGetTokenT< GenParticleMatch > srcToken_
MCMatchCandRefSelector(const EDGetTokenT< GenParticleMatch > &srcToken)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)