Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
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
// $Id: PATTriggerMatchEmbedder.cc,v 1.7 2013/02/27 23:26:56 wmtan Exp $
17
//
18
19
20
#include <vector>
21
22
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
23
#include "
FWCore/Framework/interface/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
38
namespace
pat {
39
40
template
<
class
PATObjectType >
41
class
PATTriggerMatchEmbedder
:
public
edm::EDProducer
{
42
43
edm::InputTag
src_
;
44
std::vector< edm::InputTag >
matches_
;
45
46
public
:
47
48
explicit
PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig );
49
~PATTriggerMatchEmbedder
() {};
50
51
private
:
52
53
virtual
void
produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
override
;
54
55
};
56
57
typedef
PATTriggerMatchEmbedder< Electron >
PATTriggerMatchElectronEmbedder
;
58
typedef
PATTriggerMatchEmbedder< Jet >
PATTriggerMatchJetEmbedder
;
59
typedef
PATTriggerMatchEmbedder< MET >
PATTriggerMatchMETEmbedder
;
60
typedef
PATTriggerMatchEmbedder< Muon >
PATTriggerMatchMuonEmbedder
;
61
typedef
PATTriggerMatchEmbedder< Photon >
PATTriggerMatchPhotonEmbedder
;
62
typedef
PATTriggerMatchEmbedder< Tau >
PATTriggerMatchTauEmbedder
;
63
64
}
65
66
67
using namespace
pat;
68
69
70
template
<
class
PATObjectType >
71
PATTriggerMatchEmbedder< PATObjectType >::PATTriggerMatchEmbedder
(
const
edm::ParameterSet
& iConfig ) :
72
src_( iConfig.getParameter< edm::InputTag >(
"src"
) ),
73
matches_( iConfig.getParameter< std::vector< edm::InputTag > >(
"matches"
) )
74
{
75
produces< std::vector< PATObjectType > >();
76
}
77
78
template
<
class
PATObjectType >
79
void
PATTriggerMatchEmbedder< PATObjectType >::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
80
{
81
std::auto_ptr< std::vector< PATObjectType > >
output
(
new
std::vector< PATObjectType >() );
82
83
edm::Handle< edm::View< PATObjectType >
> candidates;
84
iEvent.
getByLabel
( src_, candidates );
85
if
( ! candidates.
isValid
() ) {
86
edm::LogError
(
"missingInputSource"
) <<
"Input source with InputTag "
<< src_.encode() <<
" not in event."
;
87
return
;
88
}
89
90
for
(
typename
edm::View< PATObjectType >::const_iterator
iCand = candidates->begin(); iCand != candidates->end(); ++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 < matches_.size(); ++iMatch ) {
95
edm::Handle< TriggerObjectStandAloneMatch >
match
;
96
iEvent.
getByLabel
( matches_.at( iMatch ),
match
);
97
if
( ! match.
isValid
() ) {
98
edm::LogError
(
"missingInputMatch"
) <<
"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
( output );
112
}
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
);
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition:
View.h:81
pat::PATTriggerMatchEmbedder::PATTriggerMatchEmbedder
PATTriggerMatchEmbedder(const edm::ParameterSet &iConfig)
Definition:
PATTriggerMatchEmbedder.cc:71
pat::PATTriggerMatchEmbedder
Definition:
PATTriggerMatchEmbedder.cc:41
pat::PATTriggerMatchElectronEmbedder
PATTriggerMatchEmbedder< Electron > PATTriggerMatchElectronEmbedder
Definition:
PATTriggerMatchEmbedder.cc:57
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
pat::PATTriggerMatchEmbedder::matches_
std::vector< edm::InputTag > matches_
Definition:
PATTriggerMatchEmbedder.cc:44
Event.h
pat::PATTriggerMatchEmbedder::src_
edm::InputTag src_
Definition:
PATTriggerMatchEmbedder.cc:43
getHLTprescales.index
tuple index
Definition:
getHLTprescales.py:79
MakerMacros.h
RefToBase.h
pat::PATTriggerMatchPhotonEmbedder
PATTriggerMatchEmbedder< Photon > PATTriggerMatchPhotonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:61
Handle.h
edm::Handle
Definition:
AssociativeIterator.h:48
Frameworkfwd.h
edm::EDProducer
Definition:
EDProducer.h:22
ParameterSet.h
edm::LogError
Definition:
MessageLogger.h:164
iEvent
int iEvent
Definition:
GenABIO.cc:243
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:94
MET.h
pat::PATTriggerMatchEmbedder::~PATTriggerMatchEmbedder
~PATTriggerMatchEmbedder()
Definition:
PATTriggerMatchEmbedder.cc:49
edm::EventSetup
Definition:
EventSetup.h:44
pat::PATTriggerMatchMuonEmbedder
PATTriggerMatchEmbedder< Muon > PATTriggerMatchMuonEmbedder
Definition:
PATTriggerMatchEmbedder.cc:60
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:76
pat::PATTriggerMatchTauEmbedder
PATTriggerMatchEmbedder< Tau > PATTriggerMatchTauEmbedder
Definition:
PATTriggerMatchEmbedder.cc:62
Electron.h
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:361
EDProducer.h
convertSQLitetoXML_cfg.output
tuple output
Definition:
convertSQLitetoXML_cfg.py:32
Photon.h
Muon.h
edm::InputTag
Definition:
InputTag.h:17
InputTag.h
Jet.h
pat::PATTriggerMatchEmbedder::produce
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition:
PATTriggerMatchEmbedder.cc:79
pat::PATTriggerMatchJetEmbedder
PATTriggerMatchEmbedder< Jet > PATTriggerMatchJetEmbedder
Definition:
PATTriggerMatchEmbedder.cc:58
edm::ParameterSet
Definition:
ParameterSet.h:35
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:6
Tau.h
edm::Event
Definition:
Event.h:56
pat::PATTriggerMatchMETEmbedder
PATTriggerMatchEmbedder< MET > PATTriggerMatchMETEmbedder
Definition:
PATTriggerMatchEmbedder.cc:59
edm::Ref
Definition:
AssociativeIterator.h:52
Generated for CMSSW Reference Manual by
1.8.5