Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
DataFormats
Candidate
interface
component.h
Go to the documentation of this file.
1
#ifndef Candidate_component_h
2
#define Candidate_component_h
3
11
#include "
FWCore/Utilities/interface/Exception.h
"
12
13
namespace
reco
{
14
15
class
Candidate
;
16
17
struct
DefaultComponentTag
{ };
18
19
namespace
componenthelper {
20
21
struct
SingleComponentTag
{ };
22
23
struct
MultipleComponentsTag
{ };
24
25
template
<
typename
C,
typename
T, T (C::*F)() const>
26
struct
SingleComponent
{
27
static
T
get
(
const
Candidate
&
c
) {
28
const
C
* dc =
dynamic_cast<
const
C
*
>
( &
c
);
29
if
( dc == 0 )
return
T
();
30
return
(dc->*
F
)();
31
}
32
};
33
34
template
<
typename
C,
typename
T, T (C::*F)(
size_t
) const ,
size_t
(C::*S)() const>
35
struct
MultipleComponents
{
36
static
size_t
numberOf
(
const
Candidate
&
c
) {
37
const
C
* dc =
dynamic_cast<
const
C
*
>
( &
c
);
38
if
( dc == 0 )
return
0;
39
return
(dc->*
S
)();
40
}
41
static
T
get
(
const
Candidate
&
c
,
size_t
i
) {
42
const
C
* dc =
dynamic_cast<
const
C
*
>
( &
c
);
43
if
( dc == 0 )
return
T
();
44
if
(
i
< (dc->*
S
)() )
return
(dc->*
F
)(
i
);
45
else
throw
cms::Exception
(
"Error"
) <<
"index "
<<
i
<<
" out ot range"
;
46
}
47
};
48
49
}
50
51
template
<
typename
T,
typename
M,
typename
Tag = DefaultComponentTag>
52
struct
component
{ };
53
54
template
<
typename
T>
55
inline
T
get
(
const
Candidate
&
c
) {
56
return
component<T, componenthelper::SingleComponentTag>::type::get
(
c
);
57
}
58
59
template
<
typename
T,
typename
Tag>
60
inline
T
get
(
const
Candidate
&
c
) {
61
return
component<T, componenthelper::SingleComponentTag, Tag>::type::get
(
c
);
62
}
63
64
template
<
typename
T>
65
inline
T
get
(
const
Candidate
&
c
,
size_t
i
) {
66
return
component<T, componenthelper::MultipleComponentsTag>::type::get
(
c
,
i
);
67
}
68
69
template
<
typename
T,
typename
Tag>
70
inline
T
get
(
const
Candidate
&
c
,
size_t
i
) {
71
return
component<T, componenthelper::MultipleComponentsTag, Tag>::type::get
(
c
,
i
);
72
}
73
74
template
<
typename
T>
75
inline
size_t
numberOf
(
const
Candidate
&
c
) {
76
return
component<T, componenthelper::MultipleComponentsTag>::type::numberOf
( c );
77
}
78
79
template
<
typename
T,
typename
Tag>
80
inline
size_t
numberOf
(
const
Candidate
&
c
) {
81
return
component<T, componenthelper::MultipleComponentsTag, Tag>::type::numberOf
( c );
82
}
83
84
}
85
86
#define GET_CANDIDATE_COMPONENT( CAND, TYPE, FUN, TAG ) \
87
template<> \
88
struct component<TYPE, componenthelper::SingleComponentTag, TAG> { \
89
typedef componenthelper::SingleComponent<CAND, TYPE, & CAND::FUN> type; \
90
}
91
92
#define GET_DEFAULT_CANDIDATE_COMPONENT( CAND, TYPE, FUN ) \
93
template<> \
94
struct component<TYPE, componenthelper::SingleComponentTag, DefaultComponentTag> { \
95
typedef componenthelper::SingleComponent<CAND, TYPE, & CAND::FUN> type; \
96
}
97
98
#define GET_CANDIDATE_MULTIPLECOMPONENTS( CAND, TYPE, FUN, SIZE, TAG ) \
99
template<> \
100
struct component<TYPE, componenthelper::MultipleComponentsTag, TAG> { \
101
typedef componenthelper::MultipleComponents<CAND, TYPE, & CAND::FUN, & CAND::SIZE> type; \
102
}
103
104
#define GET_DEFAULT_CANDIDATE_MULTIPLECOMPONENTS( CAND, TYPE, FUN, SIZE ) \
105
template<> \
106
struct component<TYPE, componenthelper::MultipleComponentsTag, DefaultComponentTag> { \
107
typedef componenthelper::MultipleComponents<CAND, TYPE, & CAND::FUN, & CAND::SIZE> type; \
108
}
109
110
#endif
i
int i
Definition:
DBlmapReader.cc:9
reco::Candidate
Definition:
Candidate.h:32
funct::C
C
Definition:
Factorize.h:141
dt_dqm_sourceclient_common_cff.reco
tuple reco
Definition:
dt_dqm_sourceclient_common_cff.py:107
reco::numberOf
size_t numberOf(const Candidate &c)
Definition:
component.h:75
reco::component
Definition:
component.h:52
reco::componenthelper::MultipleComponents::numberOf
static size_t numberOf(const Candidate &c)
Definition:
component.h:36
reco::componenthelper::MultipleComponents
Definition:
component.h:35
configurableAnalysis::Candidate
char Candidate[]
Definition:
modules.cc:22
reco::componenthelper::SingleComponentTag
Definition:
component.h:21
Exception.h
edm::hlt::Exception
error
Definition:
HLTenums.h:21
reco::DefaultComponentTag
Definition:
component.h:17
trackerHits.c
tuple c
Definition:
trackerHits.py:26
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition:
Particle.cc:99
reco::componenthelper::MultipleComponentsTag
Definition:
component.h:23
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition:
blowfish.cc:281
T
long double T
Definition:
Basic3DVectorLD.h:57
reco::componenthelper::SingleComponent
Definition:
component.h:26
reco::get
T get(const Candidate &c)
Definition:
component.h:55
Generated for CMSSW Reference Manual by
1.8.5