1 |
dgele |
1.1 |
// -*- C++ -*-
|
2 |
|
|
//
|
3 |
|
|
// Package: PatAlgos
|
4 |
|
|
// Class: pat::PATTriggerMatchEmbedder
|
5 |
|
|
//
|
6 |
|
|
/**
|
7 |
|
|
\class pat::PATTriggerMatchEmbedder PATTriggerMatchEmbedder.cc "PhysicsTools/PatAlgos/plugins/PATTriggerMatchEmbedder.cc"
|
8 |
|
|
\brief
|
9 |
|
|
|
10 |
|
|
.
|
11 |
|
|
|
12 |
|
|
\author Volker Adler
|
13 |
|
|
\version $Id: PATTriggerMatchEmbedder.cc,v 1.1.2.2 2009/04/20 12:33:27 vadler Exp $
|
14 |
|
|
*/
|
15 |
|
|
//
|
16 |
|
|
// $Id: PATTriggerMatchEmbedder.cc,v 1.1.2.2 2009/04/20 12:33:27 vadler 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, class RecoObjectType >
|
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 );
|
54 |
|
|
|
55 |
|
|
};
|
56 |
|
|
|
57 |
|
|
typedef PATTriggerMatchEmbedder< Electron, ElectronType > PATTriggerMatchElectronEmbedder;
|
58 |
|
|
typedef PATTriggerMatchEmbedder< Jet , JetType > PATTriggerMatchJetEmbedder;
|
59 |
|
|
typedef PATTriggerMatchEmbedder< MET , METType > PATTriggerMatchMETEmbedder;
|
60 |
|
|
typedef PATTriggerMatchEmbedder< Muon , MuonType > PATTriggerMatchMuonEmbedder;
|
61 |
|
|
typedef PATTriggerMatchEmbedder< Photon , PhotonType > PATTriggerMatchPhotonEmbedder;
|
62 |
|
|
typedef PATTriggerMatchEmbedder< Tau , TauType > PATTriggerMatchTauEmbedder;
|
63 |
|
|
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
using namespace pat;
|
68 |
|
|
|
69 |
|
|
template< class PATObjectType, class RecoObjectType >
|
70 |
|
|
PATTriggerMatchEmbedder< PATObjectType, RecoObjectType >::PATTriggerMatchEmbedder( const edm::ParameterSet & iConfig ) :
|
71 |
|
|
src_( iConfig.getParameter< edm::InputTag >( "src" ) ),
|
72 |
|
|
matches_( iConfig.getParameter< std::vector< edm::InputTag > >( "matches" ) )
|
73 |
|
|
{
|
74 |
|
|
produces< std::vector< PATObjectType > >();
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
template< class PATObjectType, class RecoObjectType >
|
78 |
|
|
void PATTriggerMatchEmbedder< PATObjectType, RecoObjectType >::produce( edm::Event & iEvent, const edm::EventSetup & iSetup )
|
79 |
|
|
{
|
80 |
|
|
std::auto_ptr< std::vector< PATObjectType > > output( new std::vector< PATObjectType >() );
|
81 |
|
|
|
82 |
|
|
edm::Handle< edm::View< PATObjectType > > candidates;
|
83 |
|
|
iEvent.getByLabel( src_, candidates );
|
84 |
|
|
if ( ! candidates.isValid() ) {
|
85 |
|
|
edm::LogError( "missingInputSource" ) << "Input source with InputTag " << src_.encode() << " not in event.";
|
86 |
|
|
return;
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
for ( typename edm::View< PATObjectType >::const_iterator iCand = candidates->begin(); iCand != candidates->end(); ++iCand ) {
|
90 |
|
|
const unsigned index( iCand - candidates->begin() );
|
91 |
|
|
const edm::RefToBase< RecoObjectType > candRef( candidates->refAt( index ) );
|
92 |
|
|
PATObjectType cand( candRef );
|
93 |
|
|
for ( size_t iMatch = 0; iMatch < matches_.size(); ++iMatch ) {
|
94 |
|
|
edm::Handle< TriggerObjectStandAloneMatch > match;
|
95 |
|
|
iEvent.getByLabel( matches_.at( iMatch ), match );
|
96 |
|
|
if ( ! match.isValid() ) {
|
97 |
|
|
edm::LogError( "missingInputMatch" ) << "Input match with InputTag " << matches_.at( iMatch ).encode() << " not in event.";
|
98 |
|
|
continue;
|
99 |
|
|
}
|
100 |
|
|
const TriggerObjectStandAloneRef trigRef( ( *match )[ candRef ] );
|
101 |
|
|
if ( trigRef.isNonnull() && trigRef.isAvailable() ) {
|
102 |
|
|
cand.addTriggerObjectMatch( *trigRef );
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
output->push_back( cand );
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
iEvent.put( output );
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
113 |
|
|
|
114 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchElectronEmbedder );
|
115 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchJetEmbedder );
|
116 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchMETEmbedder );
|
117 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchMuonEmbedder );
|
118 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchPhotonEmbedder );
|
119 |
|
|
DEFINE_FWK_MODULE( PATTriggerMatchTauEmbedder );
|