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