Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
PhysicsTools
CandUtils
interface
CompositeCandSelector.h
Go to the documentation of this file.
1
#ifndef PhysicsTools_CandUtils_CompositeCandSelector_h
2
#define PhysicsTools_CandUtils_CompositeCandSelector_h
3
#include "
DataFormats/Candidate/interface/Candidate.h
"
4
#include "
FWCore/Utilities/interface/EDMException.h
"
5
6
template
<
typename
Selector,
typename
T1 = reco::Cand
id
ate,
typename
T2 = T1,
unsigned
int
nDau = 2>
7
class
CompositeCandSelector
{
8
public
:
9
explicit
CompositeCandSelector
(
const
Selector
&
select
) :
select_
(select) { }
10
bool
operator()
(
const
reco::Candidate
& cmp)
const
{
11
if
(cmp.
numberOfDaughters
() != nDau)
12
throw
edm::Exception
(
edm::errors::InvalidReference
)
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)
18
throw
edm::Exception
(
edm::errors::InvalidReference
)
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)
23
throw
edm::Exception
(
edm::errors::InvalidReference
)
24
<<
"candidate's second daughter is not of the type required "
25
<<
"by CompositeCandSelector.\n"
;
26
return
select_
(*dau1, *dau2);
27
}
28
private
:
29
Selector
select_
;
30
};
31
32
// specializations for nDau = 3, 4, ... could go here if needed
33
34
#endif
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
CompositeCandSelector::CompositeCandSelector
CompositeCandSelector(const Selector &select)
Definition:
CompositeCandSelector.h:9
CompositeCandSelector
Definition:
CompositeCandSelector.h:7
reco::Candidate
Definition:
Candidate.h:29
Candidate.h
reco::Candidate::numberOfDaughters
virtual size_type numberOfDaughters() const =0
number of daughters
EDMException.h
edm::Exception
Definition:
EDMException.h:74
CompositeCandSelector::select_
Selector select_
Definition:
CompositeCandSelector.h:29
CompositeCandSelector::operator()
bool operator()(const reco::Candidate &cmp) const
Definition:
CompositeCandSelector.h:10
Selector
Functor that operates on <T>
Definition:
Selector.h:25
edm::errors::InvalidReference
Definition:
EDMException.h:43
edm::hlt::Exception
error
Definition:
HLTenums.h:24
benchmark_cfg.select
tuple select
Definition:
benchmark_cfg.py:25
Generated for CMSSW Reference Manual by
1.8.5