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/Utilities/interface/InputTag.h
"
27
#include "
DataFormats/Common/interface/Handle.h
"
28
#include "
DataFormats/Common/interface/RefToBase.h
"
29
30
#include "
DataFormats/PatCandidates/interface/Electron.h
"
31
#include "
DataFormats/PatCandidates/interface/Jet.h
"
32
#include "
DataFormats/PatCandidates/interface/MET.h
"
33
#include "
DataFormats/PatCandidates/interface/Muon.h
"
34
#include "
DataFormats/PatCandidates/interface/Photon.h
"
35
#include "
DataFormats/PatCandidates/interface/Tau.h
"
36
37
namespace
pat
{
38
39
template
<
class
PATObjectType>
40
class
PATTriggerMatchEmbedder
:
public
edm::global::EDProducer
<> {
41
const
edm::InputTag
src_
;
42
const
edm::EDGetTokenT<edm::View<PATObjectType>
>
srcToken_
;
43
const
std::vector<edm::InputTag>
matches_
;
44
const
std::vector<edm::EDGetTokenT<TriggerObjectStandAloneMatch>>
matchesTokens_
;
45
46
public
:
47
explicit
PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig);
48
~PATTriggerMatchEmbedder
()
override
{};
49
50
private
:
51
void
produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const override
;
52
};
53
54
typedef
PATTriggerMatchEmbedder<Electron>
PATTriggerMatchElectronEmbedder
;
55
typedef
PATTriggerMatchEmbedder<Jet>
PATTriggerMatchJetEmbedder
;
56
typedef
PATTriggerMatchEmbedder<MET>
PATTriggerMatchMETEmbedder
;
57
typedef
PATTriggerMatchEmbedder<Muon>
PATTriggerMatchMuonEmbedder
;
58
typedef
PATTriggerMatchEmbedder<Photon>
PATTriggerMatchPhotonEmbedder
;
59
typedef
PATTriggerMatchEmbedder<Tau>
PATTriggerMatchTauEmbedder
;
60
61
}
// namespace pat
62
63
using namespace
pat
;
64
65
template
<
class
PATObjectType>
66
PATTriggerMatchEmbedder<PATObjectType>::PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig)
67
: src_(iConfig.getParameter<
edm
::
InputTag
>(
"src"
)),
68
srcToken_(consumes<
edm
::
View
<PATObjectType>>(src_)),
69
matches_(iConfig.getParameter<
std
::
vector
<
edm
::
InputTag
>>(
"matches"
)),
70
matchesTokens_(
edm
::
vector_transform
(
71
matches_, [this](
edm
::
InputTag
const
&
tag
) {
return
consumes<TriggerObjectStandAloneMatch>(
tag
); })) {
72
produces<std::vector<PATObjectType>>();
73
}
74
75
template
<
class
PATObjectType>
76
void
PATTriggerMatchEmbedder<PATObjectType>::produce
(
edm::StreamID
,
77
edm::Event
&
iEvent
,
78
const
edm::EventSetup
& iSetup)
const
{
79
auto
output
= std::make_unique<std::vector<PATObjectType>>();
80
81
edm::Handle<edm::View<PATObjectType>
>
candidates
;
82
iEvent
.getByToken(srcToken_,
candidates
);
83
if
(!
candidates
.isValid()) {
84
edm::LogError
(
"missingInputSource"
) <<
"Input source with InputTag "
<< src_.encode() <<
" not in event."
;
85
return
;
86
}
87
88
for
(
typename
edm::View<PATObjectType>::const_iterator
iCand =
candidates
->begin(); iCand !=
candidates
->end();
89
++iCand) {
90
const
unsigned
index
(iCand -
candidates
->begin());
91
PATObjectType
cand
(
candidates
->at(
index
));
92
std::set<TriggerObjectStandAloneRef> cachedRefs;
93
for
(
size_t
iMatch = 0; iMatch < matchesTokens_.size(); ++iMatch) {
94
edm::Handle<TriggerObjectStandAloneMatch>
match
;
95
iEvent
.getByToken(matchesTokens_.at(iMatch),
match
);
96
if
(!
match
.isValid()) {
97
edm::LogError
(
"missingInputMatch"
)
98
<<
"Input match with InputTag "
<< matches_.at(iMatch).encode() <<
" not in event."
;
99
continue
;
100
}
101
const
TriggerObjectStandAloneRef
trigRef((*
match
)[
candidates
->refAt(
index
)]);
102
if
(trigRef.isNonnull() && trigRef.isAvailable()) {
103
if
(cachedRefs.insert(trigRef).second) {
// protection from multiple entries of the same trigger objects
104
cand
.addTriggerObjectMatch(*trigRef);
105
}
106
}
107
}
108
output
->push_back(
cand
);
109
}
110
111
iEvent
.put(
std::move
(
output
));
112
}
113
114
#include "
FWCore/Framework/interface/MakerMacros.h
"
115
116
DEFINE_FWK_MODULE
(
PATTriggerMatchElectronEmbedder
);
117
DEFINE_FWK_MODULE
(
PATTriggerMatchJetEmbedder
);
118
DEFINE_FWK_MODULE
(
PATTriggerMatchMETEmbedder
);
119
DEFINE_FWK_MODULE
(
PATTriggerMatchMuonEmbedder
);
120
DEFINE_FWK_MODULE
(
PATTriggerMatchPhotonEmbedder
);
121
DEFINE_FWK_MODULE
(
PATTriggerMatchTauEmbedder
);
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:66
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder() override
Definition:
PATTriggerMatchEmbedder.cc:48
edm::StreamID
Definition:
StreamID.h:30
Handle.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:89353
pat::PATTriggerMatchEmbedder::matchesTokens_
const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_
Definition:
PATTriggerMatchEmbedder.cc:44
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:58
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:41
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
pat::PATTriggerMatchEmbedder::matches_
const std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:43
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:56
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:59
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
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:55
iEvent
int iEvent
Definition:
GenABIO.cc:224
trackerHitRTTI::vector
Definition:
trackerHitRTTI.h:21
edm::EventSetup
Definition:
EventSetup.h:57
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:76
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:54
transform.h
HLT_FULL_cff.candidates
candidates
Definition:
HLT_FULL_cff.py:55051
pat::PATTriggerMatchMuonEmbedder
PATTriggerMatchEmbedder< Muon > PATTriggerMatchMuonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:57
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:42
edm::InputTag
Definition:
InputTag.h:15
pat::PATTriggerMatchEmbedder
Definition:
PATTriggerMatchEmbedder.cc:40
Generated for CMSSW Reference Manual by
1.8.16