CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CompositeCandSelector.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_CandUtils_CompositeCandSelector_h
2 #define PhysicsTools_CandUtils_CompositeCandSelector_h
5 
6 template<typename Selector, typename T1 = reco::Candidate, typename T2 = T1, unsigned int nDau = 2>
8 public:
9  explicit CompositeCandSelector(const Selector& select) : select_(select) { }
10  bool operator()(const reco::Candidate & cmp) const {
11  if(cmp.numberOfDaughters() != nDau)
13  << "candidate has " << cmp.numberOfDaughters()
14  << ", while CompositeCandSelector "
15  << "requires " << nDau << " daughters.\n";
16  const T1 * dau1 = dynamic_cast<const T1 *>(cmp.daughter(0));
17  if(dau1 == 0)
19  << "candidate's first daughter is not of the type required "
20  << "by CompositeCandSelector.\n";
21  const T2 * dau2 = dynamic_cast<const T2 *>(cmp.daughter(1));
22  if(dau2 == 0)
24  << "candidate's second daughter is not of the type required "
25  << "by CompositeCandSelector.\n";
26  return select_(*dau1, *dau2);
27  }
28 private:
30 };
31 
32 // specializations for nDau = 3, 4, ... could go here if needed
33 
34 #endif
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
CompositeCandSelector(const Selector &select)
virtual size_type numberOfDaughters() const =0
number of daughters
bool operator()(const reco::Candidate &cmp) const
Functor that operates on &lt;T&gt;
Definition: Selector.h:25