CMS 3D CMS Logo

CompositeCandSelector.h
Go to the documentation of this file.
1 #ifndef CommonTools_CandUtils_CompositeCandSelector_h
2 #define CommonTools_CandUtils_CompositeCandSelector_h
5 
6 template <typename Selector, typename T1 = reco::Candidate, typename T2 = T1, unsigned int nDau = 2>
8 public:
10  bool operator()(const reco::Candidate &cmp) const {
11  if (cmp.numberOfDaughters() != nDau)
13  << "candidate has " << cmp.numberOfDaughters() << ", while CompositeCandSelector "
14  << "requires " << nDau << " daughters.\n";
15  const T1 *dau1 = dynamic_cast<const T1 *>(cmp.daughter(0));
16  if (dau1 == nullptr)
17  throw edm::Exception(edm::errors::InvalidReference) << "candidate's first daughter is not of the type required "
18  << "by CompositeCandSelector.\n";
19  const T2 *dau2 = dynamic_cast<const T2 *>(cmp.daughter(1));
20  if (dau2 == nullptr)
21  throw edm::Exception(edm::errors::InvalidReference) << "candidate's second daughter is not of the type required "
22  << "by CompositeCandSelector.\n";
23  return select_(*dau1, *dau2);
24  }
25 
26 private:
28 };
29 
30 // specializations for nDau = 3, 4, ... could go here if needed
31 
32 #endif
CompositeCandSelector(const Selector &select)
Functor that operates on <T>
Definition: Selector.h:22
bool operator()(const reco::Candidate &cmp) const