PhysicsTools
PatAlgos
plugins
PATTriggerMatchEmbedder.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: PatAlgos
4
// Class: pat::PATTriggerMatchEmbedder
5
//
15
//
16
//
17
18
#include <vector>
19
20
#include "
FWCore/Utilities/interface/transform.h
"
21
22
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
23
#include "
FWCore/Framework/interface/global/EDProducer.h
"
24
#include "
FWCore/Framework/interface/Event.h
"
25
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
26
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
27
#include "
FWCore/Utilities/interface/InputTag.h
"
28
#include "
DataFormats/Common/interface/Handle.h
"
29
#include "
DataFormats/Common/interface/RefToBase.h
"
30
31
#include "
DataFormats/PatCandidates/interface/Electron.h
"
32
#include "
DataFormats/PatCandidates/interface/Jet.h
"
33
#include "
DataFormats/PatCandidates/interface/MET.h
"
34
#include "
DataFormats/PatCandidates/interface/Muon.h
"
35
#include "
DataFormats/PatCandidates/interface/Photon.h
"
36
#include "
DataFormats/PatCandidates/interface/Tau.h
"
37
38
namespace
pat
{
39
40
template
<
class
PATObjectType>
41
class
PATTriggerMatchEmbedder
:
public
edm::global::EDProducer
<> {
42
const
edm::InputTag
src_
;
43
const
edm::EDGetTokenT<edm::View<PATObjectType>
>
srcToken_
;
44
const
std::vector<edm::InputTag>
matches_
;
45
const
std::vector<edm::EDGetTokenT<TriggerObjectStandAloneMatch>>
matchesTokens_
;
46
47
public
:
48
explicit
PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig);
49
~PATTriggerMatchEmbedder
()
override
{};
50
51
private
:
52
void
produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const override
;
53
};
54
55
typedef
PATTriggerMatchEmbedder<Electron>
PATTriggerMatchElectronEmbedder
;
56
typedef
PATTriggerMatchEmbedder<Jet>
PATTriggerMatchJetEmbedder
;
57
typedef
PATTriggerMatchEmbedder<MET>
PATTriggerMatchMETEmbedder
;
58
typedef
PATTriggerMatchEmbedder<Muon>
PATTriggerMatchMuonEmbedder
;
59
typedef
PATTriggerMatchEmbedder<Photon>
PATTriggerMatchPhotonEmbedder
;
60
typedef
PATTriggerMatchEmbedder<Tau>
PATTriggerMatchTauEmbedder
;
61
62
}
// namespace pat
63
64
using namespace
pat
;
65
66
template
<
class
PATObjectType>
67
PATTriggerMatchEmbedder<PATObjectType>::PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig)
68
: src_(iConfig.getParameter<
edm
::
InputTag
>(
"src"
)),
69
srcToken_(consumes<
edm
::
View
<PATObjectType>>(src_)),
70
matches_(iConfig.getParameter<
std
::
vector
<
edm
::
InputTag
>>(
"matches"
)),
71
matchesTokens_(
edm
::
vector_transform
(
72
matches_, [this](
edm
::
InputTag
const
&
tag
) {
return
consumes<TriggerObjectStandAloneMatch>(
tag
); })) {
73
produces<std::vector<PATObjectType>>();
74
}
75
76
template
<
class
PATObjectType>
77
void
PATTriggerMatchEmbedder<PATObjectType>::produce
(
edm::StreamID
,
78
edm::Event
&
iEvent
,
79
const
edm::EventSetup
& iSetup)
const
{
80
auto
output
= std::make_unique<std::vector<PATObjectType>>();
81
82
edm::Handle<edm::View<PATObjectType>
>
candidates
;
83
iEvent
.getByToken(srcToken_,
candidates
);
84
if
(!
candidates
.isValid()) {
85
edm::LogError
(
"missingInputSource"
) <<
"Input source with InputTag "
<< src_.encode() <<
" not in event."
;
86
return
;
87
}
88
89
for
(
typename
edm::View<PATObjectType>::const_iterator
iCand =
candidates
->begin(); iCand !=
candidates
->end();
90
++iCand) {
91
const
unsigned
index
(iCand -
candidates
->begin());
92
PATObjectType
cand
(
candidates
->at(
index
));
93
std::set<TriggerObjectStandAloneRef> cachedRefs;
94
for
(
size_t
iMatch = 0; iMatch < matchesTokens_.size(); ++iMatch) {
95
edm::Handle<TriggerObjectStandAloneMatch>
match
;
96
iEvent
.getByToken(matchesTokens_.at(iMatch),
match
);
97
if
(!
match
.isValid()) {
98
edm::LogError
(
"missingInputMatch"
)
99
<<
"Input match with InputTag "
<< matches_.at(iMatch).encode() <<
" not in event."
;
100
continue
;
101
}
102
const
TriggerObjectStandAloneRef
trigRef((*
match
)[
candidates
->refAt(
index
)]);
103
if
(trigRef.isNonnull() && trigRef.isAvailable()) {
104
if
(cachedRefs.insert(trigRef).second) {
// protection from multiple entries of the same trigger objects
105
cand
.addTriggerObjectMatch(*trigRef);
106
}
107
}
108
}
109
output
->push_back(
cand
);
110
}
111
112
iEvent
.put(
std::move
(
output
));
113
}
114
115
#include "
FWCore/Framework/interface/MakerMacros.h
"
116
117
DEFINE_FWK_MODULE
(
PATTriggerMatchElectronEmbedder
);
118
DEFINE_FWK_MODULE
(
PATTriggerMatchJetEmbedder
);
119
DEFINE_FWK_MODULE
(
PATTriggerMatchMETEmbedder
);
120
DEFINE_FWK_MODULE
(
PATTriggerMatchMuonEmbedder
);
121
DEFINE_FWK_MODULE
(
PATTriggerMatchPhotonEmbedder
);
122
DEFINE_FWK_MODULE
(
PATTriggerMatchTauEmbedder
);
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:67
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder() override
Definition:
PATTriggerMatchEmbedder.cc:49
edm::StreamID
Definition:
StreamID.h:30
Handle.h
MessageLogger.h
sistrip::View
View
Definition:
ConstantsForView.h:26
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
Muon.h
Photon.h
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89301
pat::PATTriggerMatchEmbedder::matchesTokens_
const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_
Definition:
PATTriggerMatchEmbedder.cc:45
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:59
watchdog.const
const
Definition:
watchdog.py:83
edm::Handle
Definition:
AssociativeIterator.h:50
Tau.h
edm::Ref
Definition:
AssociativeIterator.h:58
MakerMacros.h
pat::PATTriggerMatchEmbedder::src_
const edm::InputTag src_
Definition:
PATTriggerMatchEmbedder.cc:42
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
pat::PATTriggerMatchEmbedder::matches_
const std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:44
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:57
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:60
RefToBase.h
edm::global::EDProducer
Definition:
EDProducer.h:32
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition:
transform.h:11
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
makeGlobalPositionRcd_cfg.tag
tag
Definition:
makeGlobalPositionRcd_cfg.py:6
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
cand
Definition:
decayParser.h:32
pat::PATTriggerMatchJetEmbedder
PATTriggerMatchEmbedder< Jet > PATTriggerMatchJetEmbedder
Definition:
PATTriggerMatchEmbedder.cc:56
iEvent
int iEvent
Definition:
GenABIO.cc:224
trackerHitRTTI::vector
Definition:
trackerHitRTTI.h:21
edm::EventSetup
Definition:
EventSetup.h:58
pat
Definition:
HeavyIon.h:7
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:123
MET.h
Jet.h
pat::PATTriggerMatchEmbedder::produce
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition:
PATTriggerMatchEmbedder.cc:77
InputTag.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
Frameworkfwd.h
pat::PATTriggerMatchElectronEmbedder
PATTriggerMatchEmbedder< Electron > PATTriggerMatchElectronEmbedder
Definition:
PATTriggerMatchEmbedder.cc:55
transform.h
HLT_FULL_cff.candidates
candidates
Definition:
HLT_FULL_cff.py:55017
pat::PATTriggerMatchMuonEmbedder
PATTriggerMatchEmbedder< Muon > PATTriggerMatchMuonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:58
Electron.h
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:86
ParameterSet.h
EDProducer.h
edm::Event
Definition:
Event.h:73
pat::PATTriggerMatchEmbedder::srcToken_
const edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_
Definition:
PATTriggerMatchEmbedder.cc:43
edm::InputTag
Definition:
InputTag.h:15
pat::PATTriggerMatchEmbedder
Definition:
PATTriggerMatchEmbedder.cc:41
Generated for CMSSW Reference Manual by
1.8.16