CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
14  class MCMatchSelector {
15  public:
17  checkCharge_(cfg.getParameter<bool>("checkCharge")) {
18  std::vector<int> ids =
19  cfg.getParameter< std::vector<int> >("mcPdgId");
20  for ( std::vector<int>::const_iterator i=ids.begin();
21  i!=ids.end(); ++i ) ids_.insert(*i);
22  std::vector<int> status =
23  cfg.getParameter< std::vector<int> >("mcStatus");
24  for ( std::vector<int>::const_iterator i=status.begin();
25  i!=status.end(); ++i ) status_.insert(*i);
26  }
28  bool operator()( const T1 & c, const T2 & mc ) const {
29  if ( checkCharge_ && c.charge() != mc.charge() ) return false;
30  if ( !ids_.empty() ) {
31  if ( ids_.find(abs(mc.pdgId()))==ids_.end() ) return false;
32  }
33  if ( status_.empty() ) return true;
34  return status_.find(mc.status())!=status_.end();
35  }
36  private:
37  bool checkCharge_;
38  std::set<int> ids_;
39  std::set<int> status_;
40  };
41 }
42 
43 #endif
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool operator()(const T1 &c, const T2 &mc) const
true if match is possible
#define abs(x)
Definition: mlp_lapack.h:159
MCMatchSelector(const edm::ParameterSet &cfg)
std::set< int > ids_
std::set< int > status_
tuple status
Definition: ntuplemaker.py:245