src
CommonTools
CandUtils
interface
CompositeCandSelector.h
Go to the documentation of this file.
1
#ifndef CommonTools_CandUtils_CompositeCandSelector_h
2
#define CommonTools_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() <<
", 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
:
27
Selector
select_
;
28
};
29
30
// specializations for nDau = 3, 4, ... could go here if needed
31
32
#endif
CompositeCandSelector::CompositeCandSelector
CompositeCandSelector(const Selector &select)
Definition:
CompositeCandSelector.h:9
CompositeCandSelector
Definition:
CompositeCandSelector.h:7
Exception
Definition:
hltDiff.cc:245
reco::Candidate
Definition:
Candidate.h:27
Candidate.h
EDMException.h
edm::Exception
Definition:
EDMException.h:82
CompositeCandSelector::select_
Selector select_
Definition:
CompositeCandSelector.h:27
Selector
Functor that operates on <T>
Definition:
Selector.h:22
edm::errors::InvalidReference
Definition:
EDMException.h:39
CompositeCandSelector::operator()
bool operator()(const reco::Candidate &cmp) const
Definition:
CompositeCandSelector.h:10
singleTopDQM_cfi.select
select
Definition:
singleTopDQM_cfi.py:50
fileCollector.cmp
cmp
Definition:
fileCollector.py:125
Generated for CMSSW Reference Manual by
1.8.14