CMS 3D CMS Logo

MCTruthPairSelector.h
Go to the documentation of this file.
1 #ifndef HepMCCandAlgos_MCTruthPairSelector_h
2 #define HepMCCandAlgos_MCTruthPairSelector_h
3 /* \class MCTruthPairSelector
4  *
5  * \author Luca Lista, INFN
6  *
7  */
8 
9 #include <set>
11 
12 namespace helpers {
13  template <typename T>
16  template <typename I>
17  MCTruthPairSelector(const I& begin, const I& end, bool checkCharge = false) : checkCharge_(checkCharge) {
18  for (I i = begin; i != end; ++i)
19  matchIds_.insert(std::abs(*i));
20  }
21  bool operator()(const T& c, const reco::Candidate& mc) const {
22  if (mc.status() != 1)
23  return false;
24  if (checkCharge_ && c.charge() != mc.charge())
25  return false;
26  if (matchIds_.empty())
27  return true;
28  return matchIds_.find(std::abs(mc.pdgId())) != matchIds_.end();
29  }
30 
31  private:
32  std::set<int> matchIds_;
34  };
35 } // namespace helpers
36 
38 #include <algorithm>
39 #include <string>
40 #include <vector>
41 
42 namespace reco {
43  namespace modules {
44 
45  template <typename T>
46  struct ParameterAdapter<helpers::MCTruthPairSelector<T> > {
48  const std::string matchPDGId("matchPDGId");
49  const std::string checkCharge("checkCharge");
50  bool ck = false;
51  std::vector<std::string> bools = cfg.template getParameterNamesForType<bool>();
52  bool found = find(bools.begin(), bools.end(), checkCharge) != bools.end();
53  if (found)
54  ck = cfg.template getParameter<bool>(checkCharge);
55  typedef std::vector<int> vint;
56  std::vector<std::string> ints = cfg.template getParameterNamesForType<vint>();
57  found = find(ints.begin(), ints.end(), matchPDGId) != ints.end();
58  if (found) {
59  vint ids = cfg.template getParameter<vint>(matchPDGId);
60  return helpers::MCTruthPairSelector<T>(ids.begin(), ids.end(), ck);
61  } else {
63  }
64  }
65  };
66 
67  } // namespace modules
68 } // namespace reco
69 
70 #endif
PA_ZEESkim_cff.checkCharge
checkCharge
Definition: PA_ZEESkim_cff.py:27
mps_fire.i
i
Definition: mps_fire.py:428
vint
double vint[400]
Definition: JetMatchingHook.cc:18
CaloTowersParam_cfi.mc
mc
Definition: CaloTowersParam_cfi.py:8
modules
Definition: ZHLTMatchFilter.cc:17
helpers::MCTruthPairSelector::matchIds_
std::set< int > matchIds_
Definition: MCTruthPairSelector.h:32
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
Exhume::I
const std::complex< double > I
Definition: I.h:8
mps_fire.end
end
Definition: mps_fire.py:242
helpers::MCTruthPairSelector::MCTruthPairSelector
MCTruthPairSelector(const I &begin, const I &end, bool checkCharge=false)
Definition: MCTruthPairSelector.h:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
helpers::MCTruthPairSelector::MCTruthPairSelector
MCTruthPairSelector(bool checkCharge=false)
Definition: MCTruthPairSelector.h:15
helpers
Definition: makeCompositeCandidate.h:8
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
helpers::MCTruthPairSelector
Definition: MCTruthPairSelector.h:14
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
helpers::MCTruthPairSelector::checkCharge_
bool checkCharge_
Definition: MCTruthPairSelector.h:33
dimuonsMCMatch_cfi.matchPDGId
matchPDGId
Definition: dimuonsMCMatch_cfi.py:9
T
long double T
Definition: Basic3DVectorLD.h:48
helpers::MCTruthPairSelector::operator()
bool operator()(const T &c, const reco::Candidate &mc) const
Definition: MCTruthPairSelector.h:21
ParameterAdapter.h
reco::modules::ParameterAdapter< helpers::MCTruthPairSelector< T > >::make
static helpers::MCTruthPairSelector< T > make(const edm::ParameterSet &cfg)
Definition: MCTruthPairSelector.h:47
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::modules::ParameterAdapter
Definition: ParameterAdapter.h:12