ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/PatAlgos/plugins/PATTrigProducer.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Oct 20 17:15:14 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: ANA
CVS Tags: start
Changes since 1.1: +0 -0 lines
Log Message:
version CMSSW_2_2_10

File Contents

# Content
1 //
2 // $Id: PATTrigProducer.cc,v 1.2 2008/06/08 12:24:03 vadler Exp $
3 //
4
5
6 #include "PhysicsTools/PatAlgos/plugins/PATTrigProducer.h"
7
8 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
9
10 #include "DataFormats/PatCandidates/interface/TriggerPrimitive.h"
11
12
13 using namespace pat;
14 using namespace trigger;
15 using namespace edm;
16 using namespace std;
17
18
19 PATTrigProducer::PATTrigProducer( const ParameterSet & iConfig ) :
20 // initialize
21 triggerEvent_ (iConfig.getParameter<InputTag>( "triggerEvent" ) ),
22 filterName_ (iConfig.getParameter<InputTag>( "filterName" ) )
23 {
24 produces<TriggerPrimitiveCollection>();
25 }
26
27
28 PATTrigProducer::~PATTrigProducer()
29 {
30 }
31
32
33 void PATTrigProducer::produce( Event& iEvent, const EventSetup& iSetup )
34 {
35 auto_ptr<TriggerPrimitiveCollection> patTrigCandidates( new TriggerPrimitiveCollection );
36 Handle<TriggerEvent> triggerEvent;
37 try { // In this case, we want to act differently compared to the usual behaviour on "ProductNotFound" exception thrown by Event::getByLabel.
38 iEvent.getByLabel( triggerEvent_, triggerEvent );
39 size_type nFilters = triggerEvent->sizeFilters();
40 if ( nFilters == 0 ) {
41 LogDebug( "noTriggerFilters" ) << "PATTrigProducer: The TriggerEvent of this event contains no filter information at all!";
42 } else {
43 size_type iFilter = triggerEvent->filterIndex( filterName_ );
44 if ( iFilter == nFilters ) {
45 LogDebug( "noTriggerFilter" ) << "PATTrigProducer: The TriggerEvent of this event contains no filter information on filter " << filterName_.label() << "!";
46 } else {
47 const Vids & triggerIds = triggerEvent->filterIds( iFilter );
48 const Keys & triggerKeys = triggerEvent->filterKeys( iFilter );
49 const TriggerObjectCollection & triggerObjects = triggerEvent->getObjects();
50 assert( triggerIds.size() == triggerKeys.size() );
51 for ( size_type idx = 0; idx < triggerKeys.size(); ++idx ) {
52 const TriggerObject triggerObject = triggerObjects.at( triggerKeys.at( idx ) );
53 auto_ptr<TriggerPrimitive> ptr( new TriggerPrimitive( triggerObject.particle().p4(), filterName_.label(), triggerIds.at( idx ), triggerObject.id() ) );
54 patTrigCandidates->push_back( ptr );
55 }
56 }
57 }
58 } catch( Exception exc ) {
59 if ( exc.categoryCode() == errors::ProductNotFound ) {
60 LogWarning( "noTriggerEvent" ) << "PATTrigProducer: No TriggerEvent " << triggerEvent_.label() << " found!";
61 } else {
62 throw exc;
63 }
64 }
65 iEvent.put( patTrigCandidates );
66 }
67
68
69 #include "FWCore/Framework/interface/MakerMacros.h"
70 DEFINE_FWK_MODULE(PATTrigProducer);