Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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
() {};
53
54
private
:
55
56
virtual
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
std::auto_ptr< std::vector< PATObjectType > >
output
(
new
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
( 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
pat::PATTriggerMatchEmbedder::matches_
const std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:46
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:74
objects.IsoTrackAnalyzer.candidates
string candidates
Definition:
IsoTrackAnalyzer.py:296
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:457
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
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:47
RefToBase.h
pat::PATTriggerMatchEmbedder::produce
virtual void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition:
PATTriggerMatchEmbedder.cc:84
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:64
Handle.h
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
HLT_25ns14e33_v1_cff.InputTag
tuple InputTag
Definition:
HLT_25ns14e33_v1_cff.py:45333
edm::EDGetTokenT
Definition:
EDGetToken.h:32
Frameworkfwd.h
pat::PATTriggerMatchEmbedder::matchesTokens_
const std::vector< edm::EDGetTokenT< TriggerObjectStandAloneMatch > > matchesTokens_
Definition:
PATTriggerMatchEmbedder.cc:47
cmsHarvester.index
string index
Definition:
cmsHarvester.py:4378
ParameterSet.h
edm::LogError
Definition:
MessageLogger.h:164
iEvent
int iEvent
Definition:
GenABIO.cc:230
GlobalPosition_Frontier_DevDB_cff.tag
tuple tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:115
MET.h
Tau.h
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder()
Definition:
PATTriggerMatchEmbedder.cc:52
edm::EventSetup
Definition:
EventSetup.h:44
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:75
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:65
Electron.h
transform.h
convertSQLitetoXML_cfg.output
tuple output
Definition:
convertSQLitetoXML_cfg.py:32
Photon.h
pat::PATTriggerMatchEmbedder::srcToken_
const edm::EDGetTokenT< edm::View< PATObjectType > > srcToken_
Definition:
PATTriggerMatchEmbedder.cc:45
compareJSON.const
string const
Definition:
compareJSON.py:14
Muon.h
edm::InputTag
Definition:
InputTag.h:18
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:85
InputTag.h
Jet.h
pat::PATTriggerMatchJetEmbedder
PATTriggerMatchEmbedder< Jet > PATTriggerMatchJetEmbedder
Definition:
PATTriggerMatchEmbedder.cc:61
edm::ParameterSet
Definition:
ParameterSet.h:36
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:61
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:62
sistrip::View
View
Definition:
ConstantsForView.h:26
Generated for CMSSW Reference Manual by
1.8.5