CMS 3D CMS Logo

MCMatchSelector.h
Go to the documentation of this file.
1 #ifndef MCMatchSelector_h
2 #define MCMatchSelector_h
3 /* \class MCMatchSelector
4  *
5  * Extended version of MCTruthPairSelector. Preselects matches
6  * based on charge, pdgId and status.
7  */
8 
9 #include <set>
11 
12 namespace reco {
13  template <typename T1, typename T2>
15  public:
16  MCMatchSelector(const edm::ParameterSet& cfg) : checkCharge_(cfg.getParameter<bool>("checkCharge")) {
17  std::vector<int> ids = cfg.getParameter<std::vector<int> >("mcPdgId");
18  for (std::vector<int>::const_iterator i = ids.begin(); i != ids.end(); ++i)
19  ids_.insert(*i);
20  std::vector<int> status = cfg.getParameter<std::vector<int> >("mcStatus");
21  for (std::vector<int>::const_iterator i = status.begin(); i != status.end(); ++i)
22  status_.insert(*i);
23  }
25  bool operator()(const T1& c, const T2& mc) const {
26  if (checkCharge_ && c.charge() != mc.charge())
27  return false;
28  if (!ids_.empty()) {
29  if (ids_.find(abs(mc.pdgId())) == ids_.end())
30  return false;
31  }
32  if (status_.empty())
33  return true;
34  return status_.find(mc.status()) != status_.end();
35  }
36 
37  private:
39  std::set<int> ids_;
40  std::set<int> status_;
41  };
42 } // namespace reco
43 
44 #endif
bool operator()(const T1 &c, const T2 &mc) const
true if match is possible
MCMatchSelector(const edm::ParameterSet &cfg)
std::set< int > ids_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
fixed size matrix
std::set< int > status_