File indexing completed on 2024-04-06 12:01:16
0001 #ifndef MCMatchSelector_h
0002 #define MCMatchSelector_h
0003
0004
0005
0006
0007
0008
0009 #include <set>
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011
0012 namespace reco {
0013 template <typename T1, typename T2>
0014 class MCMatchSelector {
0015 public:
0016 MCMatchSelector(const edm::ParameterSet& cfg) : checkCharge_(cfg.getParameter<bool>("checkCharge")) {
0017 std::vector<int> ids = cfg.getParameter<std::vector<int> >("mcPdgId");
0018 for (std::vector<int>::const_iterator i = ids.begin(); i != ids.end(); ++i)
0019 ids_.insert(*i);
0020 std::vector<int> status = cfg.getParameter<std::vector<int> >("mcStatus");
0021 for (std::vector<int>::const_iterator i = status.begin(); i != status.end(); ++i)
0022 status_.insert(*i);
0023 }
0024
0025 bool operator()(const T1& c, const T2& mc) const {
0026 if (checkCharge_ && c.charge() != mc.charge())
0027 return false;
0028 if (!ids_.empty()) {
0029 if (ids_.find(abs(mc.pdgId())) == ids_.end())
0030 return false;
0031 }
0032 if (status_.empty())
0033 return true;
0034 return status_.find(mc.status()) != status_.end();
0035 }
0036
0037 private:
0038 bool checkCharge_;
0039 std::set<int> ids_;
0040 std::set<int> status_;
0041 };
0042 }
0043
0044 #endif