PhysicsTools
HepMCCandAlgos
plugins
MCMatchCandRefSelector.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/interface/MakerMacros.h
"
2
#include "
FWCore/Framework/interface/Event.h
"
3
#include "
FWCore/Framework/interface/ConsumesCollector.h
"
4
#include "
FWCore/Utilities/interface/InputTag.h
"
5
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
6
#include "
DataFormats/Common/interface/Handle.h
"
7
#include "
DataFormats/HepMCCandidate/interface/GenParticle.h
"
8
#include "
CommonTools/UtilAlgos/interface/EventSetupInitTrait.h
"
9
#include "
CommonTools/UtilAlgos/interface/SingleObjectRefSelector.h
"
10
#include "
CommonTools/UtilAlgos/interface/ParameterAdapter.h
"
11
12
using namespace
edm
;
13
using namespace
reco
;
14
using namespace
std
;
15
16
namespace
reco
{
17
namespace
modules
{
18
19
class
MCMatchCandRefSelector
{
20
public
:
21
explicit
MCMatchCandRefSelector
(
const
EDGetTokenT<GenParticleMatch>
&
srcToken
) : srcToken_(
srcToken
) {}
22
void
newEvent(
const
Event
& evt,
const
EventSetup
&);
23
bool
operator()(
const
CandidateBaseRef
&)
const
;
24
25
private
:
26
EDGetTokenT<GenParticleMatch>
srcToken_
;
27
const
GenParticleMatch
* match_ =
nullptr
;
28
};
29
30
void
MCMatchCandRefSelector::newEvent(
const
Event
& evt,
const
EventSetup
&) {
31
Handle<GenParticleMatch>
match
;
32
evt.
getByToken
(srcToken_,
match
);
33
match_ =
match
.product();
34
}
35
36
bool
MCMatchCandRefSelector::operator()(
const
CandidateBaseRef
&
c
)
const
{
37
GenParticleRef
m
= (*match_)[
c
];
38
return
m
.isNonnull();
39
}
40
41
template
<>
42
struct
ParameterAdapter
<
MCMatchCandRefSelector
> {
43
static
MCMatchCandRefSelector
make
(
const
ParameterSet
&
cfg
,
edm::ConsumesCollector
& iC) {
44
return
MCMatchCandRefSelector
(iC.
consumes
<
GenParticleMatch
>(
cfg
.getParameter<
InputTag
>(
"match"
)));
45
}
46
};
47
48
}
// namespace modules
49
}
// namespace reco
50
51
EVENTSETUP_STD_INIT
(
MCMatchCandRefSelector
);
52
53
typedef
SingleObjectRefSelector<Candidate, reco::modules::MCMatchCandRefSelector>
MCMatchCandRefSelector
;
54
55
DEFINE_FWK_MODULE
(
MCMatchCandRefSelector
);
MCMatchCandRefSelector
SingleObjectRefSelector< Candidate, reco::modules::MCMatchCandRefSelector > MCMatchCandRefSelector
Definition:
MCMatchCandRefSelector.cc:51
EVENTSETUP_STD_INIT
#define EVENTSETUP_STD_INIT(SELECTOR)
Definition:
EventSetupInitTrait.h:103
Handle.h
modules
Definition:
ZHLTMatchFilter.cc:17
edm::EDGetTokenT< GenParticleMatch >
edm
HLT enums.
Definition:
AlignableModifier.h:19
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
EventSetupInitTrait.h
edm::Handle
Definition:
AssociativeIterator.h:50
edm::Ref< GenParticleCollection >
GenParticle.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
reco::modules::MCMatchCandRefSelector
Definition:
MCMatchCandRefSelector.cc:19
L1Validator_cfi.srcToken
srcToken
Definition:
L1Validator_cfi.py:8
SingleObjectRefSelector
Definition:
SingleObjectRefSelector.h:22
visualization-live-secondInstance_cfg.m
m
Definition:
visualization-live-secondInstance_cfg.py:72
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
ConsumesCollector.h:55
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:531
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
edm::Association
Definition:
Association.h:18
edm::EventSetup
Definition:
EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition:
HltBtagPostValidation_cff.py:31
InputTag.h
looper.cfg
cfg
Definition:
looper.py:297
std
Definition:
JetResolutionObject.h:76
edm::match
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
Definition:
BranchDescription.cc:351
SingleObjectRefSelector.h
reco::modules::ParameterAdapter< MCMatchCandRefSelector >::make
static MCMatchCandRefSelector make(const ParameterSet &cfg, edm::ConsumesCollector &iC)
Definition:
MCMatchCandRefSelector.cc:43
reco::modules::MCMatchCandRefSelector::srcToken_
EDGetTokenT< GenParticleMatch > srcToken_
Definition:
MCMatchCandRefSelector.cc:26
reco::modules::MCMatchCandRefSelector::MCMatchCandRefSelector
MCMatchCandRefSelector(const EDGetTokenT< GenParticleMatch > &srcToken)
Definition:
MCMatchCandRefSelector.cc:21
edm::RefToBase< Candidate >
ParameterAdapter.h
ConsumesCollector.h
ParameterSet.h
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
reco::modules::ParameterAdapter
Definition:
ParameterAdapter.h:12
Generated for CMSSW Reference Manual by
1.8.16