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
19
#include <vector>
20
21
#include "
FWCore/Utilities/interface/transform.h
"
22
23
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
24
#include "
FWCore/Framework/interface/global/EDProducer.h
"
25
#include "
FWCore/Framework/interface/Event.h
"
26
#include "
FWCore/ParameterSet/interface/ParameterSet.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
39
namespace
pat
{
40
41
template
<
class
PATObjectType >
42
class
PATTriggerMatchEmbedder
:
public
edm::global::EDProducer
<> {
43
44
const
edm::InputTag
src_
;
45
const
edm::EDGetTokenT< edm::View< PATObjectType >
>
srcToken_
;
46
const
std::vector< edm::InputTag >
matches_
;
47
const
std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > >
matchesTokens_
;
48
49
public
:
50
51
explicit
PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig );
52
~PATTriggerMatchEmbedder
()
override
{};
53
54
private
:
55
56
void
produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const override
;
57
58
};
59
60
typedef
PATTriggerMatchEmbedder< Electron >
PATTriggerMatchElectronEmbedder
;
61
typedef
PATTriggerMatchEmbedder< Jet >
PATTriggerMatchJetEmbedder
;
62
typedef
PATTriggerMatchEmbedder< MET >
PATTriggerMatchMETEmbedder
;
63
typedef
PATTriggerMatchEmbedder< Muon >
PATTriggerMatchMuonEmbedder
;
64
typedef
PATTriggerMatchEmbedder< Photon >
PATTriggerMatchPhotonEmbedder
;
65
typedef
PATTriggerMatchEmbedder< Tau >
PATTriggerMatchTauEmbedder
;
66
67
}
68
69
70
using namespace
pat
;
71
72
73
template
<
class
PATObjectType >
74
PATTriggerMatchEmbedder< PATObjectType >::PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig ) :
75
src_
( iConfig.getParameter<
edm
::InputTag >(
"src"
) ),
76
srcToken_
(
consumes
<
edm
::
View
< PATObjectType > >(
src_
) ),
77
matches_
( iConfig.getParameter<
std
::vector<
edm
::InputTag > >(
"matches"
) ),
78
matchesTokens_
(
edm
::
vector_transform
(
matches_
, [this](
edm
::InputTag const &
tag
) {
return
consumes< TriggerObjectStandAloneMatch >(
tag
); } ) )
79
{
80
produces< std::vector< PATObjectType > >();
81
}
82
83
template
<
class
PATObjectType >
84
void
PATTriggerMatchEmbedder< PATObjectType >::produce
(
edm::StreamID
,
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
const
85
{
86
auto
output
= std::make_unique<std::vector<PATObjectType>>();
87
88
edm::Handle< edm::View< PATObjectType >
>
candidates
;
89
iEvent.
getByToken
(
srcToken_
, candidates );
90
if
( ! candidates.isValid() ) {
91
edm::LogError
(
"missingInputSource"
) <<
"Input source with InputTag "
<<
src_
.
encode
() <<
" not in event."
;
92
return
;
93
}
94
95
for
(
typename
edm::View< PATObjectType >::const_iterator
iCand = candidates->begin(); iCand != candidates->end(); ++iCand ) {
96
const
unsigned
index
( iCand - candidates->begin() );
97
PATObjectType
cand
( candidates->at(
index
) );
98
std::set< TriggerObjectStandAloneRef > cachedRefs;
99
for
(
size_t
iMatch = 0; iMatch <
matchesTokens_
.size(); ++iMatch ) {
100
edm::Handle< TriggerObjectStandAloneMatch >
match
;
101
iEvent.
getByToken
(
matchesTokens_
.at( iMatch ),
match
);
102
if
( ! match.
isValid
() ) {
103
edm::LogError
(
"missingInputMatch"
) <<
"Input match with InputTag "
<<
matches_
.at( iMatch ).encode() <<
" not in event."
;
104
continue
;
105
}
106
const
TriggerObjectStandAloneRef
trigRef( ( *match )[ candidates->refAt(
index
) ] );
107
if
( trigRef.isNonnull() && trigRef.isAvailable() ) {
108
if
( cachedRefs.insert( trigRef ).second ) {
// protection from multiple entries of the same trigger objects
109
cand
.addTriggerObjectMatch( *trigRef );
110
}
111
}
112
}
113
output
->push_back(
cand
);
114
}
115
116
iEvent.
put
(
std::move
(
output
) );
117
}
118
119
120
#include "
FWCore/Framework/interface/MakerMacros.h
"
121
122
DEFINE_FWK_MODULE
(
PATTriggerMatchElectronEmbedder
);
123
DEFINE_FWK_MODULE
(
PATTriggerMatchJetEmbedder
);
124
DEFINE_FWK_MODULE
(
PATTriggerMatchMETEmbedder
);
125
DEFINE_FWK_MODULE
(
PATTriggerMatchMuonEmbedder
);
126
DEFINE_FWK_MODULE
(
PATTriggerMatchPhotonEmbedder
);
127
DEFINE_FWK_MODULE
(
PATTriggerMatchTauEmbedder
);
EDProducer.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:136
pat::PATTriggerMatchEmbedder::matches_
const std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:46
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:74
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:519
pat::PATTriggerMatchEmbedder
Definition:
PATTriggerMatchEmbedder.cc:42
edm::Ref< TriggerObjectStandAloneCollection >
pat::PATTriggerMatchElectronEmbedder
PATTriggerMatchEmbedder< Electron > PATTriggerMatchElectronEmbedder
Definition:
PATTriggerMatchEmbedder.cc:60
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
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:84
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:47
RefToBase.h
std
Definition:
JetResolutionObject.h:76
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:32
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:64
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::EDGetTokenT
Definition:
EDGetToken.h:32
Frameworkfwd.h
edm::InputTag::encode
std::string encode() const
Definition:
InputTag.cc:166
pat::PATTriggerMatchEmbedder::matchesTokens_
const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_
Definition:
PATTriggerMatchEmbedder.cc:47
objects.IsoTrackAnalyzer.candidates
candidates
Definition:
IsoTrackAnalyzer.py:319
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
EDConsumerBase.h:105
pat
Definition:
HeavyIon.h:7
ParameterSet.h
edm::LogError
Definition:
MessageLogger.h:166
iEvent
int iEvent
Definition:
GenABIO.cc:230
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:33
MET.h
Tau.h
edm::EventSetup
Definition:
EventSetup.h:48
edm::global::EDProducer
Definition:
EDProducer.h:32
pat::PATTriggerMatchMuonEmbedder
PATTriggerMatchEmbedder< Muon > PATTriggerMatchMuonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:63
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:74
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:65
Electron.h
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder() override
Definition:
PATTriggerMatchEmbedder.cc:52
transform.h
Photon.h
pat::PATTriggerMatchEmbedder::srcToken_
const edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_
Definition:
PATTriggerMatchEmbedder.cc:45
Muon.h
edm
HLT enums.
Definition:
AlignableModifier.h:17
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
pat::PATTriggerMatchJetEmbedder
PATTriggerMatchEmbedder< Jet > PATTriggerMatchJetEmbedder
Definition:
PATTriggerMatchEmbedder.cc:61
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:44
edm::Event
Definition:
Event.h:69
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:62
sistrip::View
View
Definition:
ConstantsForView.h:26
eostools.move
def move(src, dest)
Definition:
eostools.py:510
Handle.h
Generated for CMSSW Reference Manual by
1.8.11