Main Page
Namespaces
Classes
Package Documentation
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
);
EDProducer.h
HLT_2018_cff.InputTag
InputTag
Definition:
HLT_2018_cff.py:78913
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:131
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:66
pat::PATTriggerMatchJetEmbedder
PATTriggerMatchEmbedder< Jet > PATTriggerMatchJetEmbedder
Definition:
PATTriggerMatchEmbedder.cc:55
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:59
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:525
pat::PATTriggerMatchEmbedder
Definition:
PATTriggerMatchEmbedder.cc:40
edm::Ref
Definition:
AssociativeIterator.h:57
edm::StreamID
Definition:
StreamID.h:30
Event.h
pat::PATTriggerMatchEmbedder::produce
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition:
PATTriggerMatchEmbedder.cc:76
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:49
RefToBase.h
std
Definition:
JetResolutionObject.h:76
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:32
pat::PATTriggerMatchElectronEmbedder
PATTriggerMatchEmbedder< Electron > PATTriggerMatchElectronEmbedder
Definition:
PATTriggerMatchEmbedder.cc:54
edm::EDGetTokenT
Definition:
EDGetToken.h:33
Frameworkfwd.h
edm::InputTag::encode
std::string encode() const
Definition:
InputTag.cc:159
pat::PATTriggerMatchMuonEmbedder
PATTriggerMatchEmbedder< Muon > PATTriggerMatchMuonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:57
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:126
pat
Definition:
HeavyIon.h:7
ParameterSet.h
edm::LogError
Definition:
MessageLogger.h:183
iEvent
int iEvent
Definition:
GenABIO.cc:224
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
watchdog.const
const
Definition:
watchdog.py:83
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:36
pat::PATTriggerMatchEmbedder::srcToken_
const edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_
Definition:
PATTriggerMatchEmbedder.cc:42
MET.h
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:58
pat::PATTriggerMatchEmbedder::matches_
const std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:43
Tau.h
edm::EventSetup
Definition:
EventSetup.h:57
edm::global::EDProducer
Definition:
EDProducer.h:32
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:70
Electron.h
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder() override
Definition:
PATTriggerMatchEmbedder.cc:48
transform.h
pat::PATTriggerMatchEmbedder::matchesTokens_
const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_
Definition:
PATTriggerMatchEmbedder.cc:44
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
Photon.h
Muon.h
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::InputTag
Definition:
InputTag.h:15
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:86
InputTag.h
Jet.h
edm::ParameterSet
Definition:
ParameterSet.h:36
cand
Definition:
decayParser.h:34
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
pat::PATTriggerMatchEmbedder::src_
const edm::InputTag src_
Definition:
PATTriggerMatchEmbedder.cc:41
edm::Event
Definition:
Event.h:72
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:56
HLT_2018_cff.candidates
candidates
Definition:
HLT_2018_cff.py:53403
sistrip::View
View
Definition:
ConstantsForView.h:26
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Handle.h
Generated for CMSSW Reference Manual by
1.8.11