#include <PhysicsTools/PatAlgos/plugins/PATTrigProducer.h>
Public Member Functions | |
PATTrigProducer (const edm::ParameterSet &iConfig) | |
~PATTrigProducer () | |
Private Member Functions | |
virtual void | produce (edm::Event &iEvent, const edm::EventSetup &iSetup) |
Private Attributes | |
edm::InputTag | filterName_ |
edm::InputTag | triggerEvent_ |
A CandidateCollection of trigger objects from a given filter is produced from trigger information available in AOD.
Definition at line 36 of file PATTrigProducer.h.
PATTrigProducer::PATTrigProducer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 19 of file PATTrigProducer.cc.
00019 : 00020 // initialize 00021 triggerEvent_ (iConfig.getParameter<InputTag>( "triggerEvent" ) ), 00022 filterName_ (iConfig.getParameter<InputTag>( "filterName" ) ) 00023 { 00024 produces<TriggerPrimitiveCollection>(); 00025 }
PATTrigProducer::~PATTrigProducer | ( | ) |
void PATTrigProducer::produce | ( | edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 33 of file PATTrigProducer.cc.
References filterName_, edm::Event::getByLabel(), edm::InputTag::label(), LogDebug, reco::Particle::p4(), edm::errors::ProductNotFound, ptr, edm::Event::put(), and triggerEvent_.
00034 { 00035 auto_ptr<TriggerPrimitiveCollection> patTrigCandidates( new TriggerPrimitiveCollection ); 00036 Handle<TriggerEvent> triggerEvent; 00037 try { // In this case, we want to act differently compared to the usual behaviour on "ProductNotFound" exception thrown by Event::getByLabel. 00038 iEvent.getByLabel( triggerEvent_, triggerEvent ); 00039 size_type nFilters = triggerEvent->sizeFilters(); 00040 if ( nFilters == 0 ) { 00041 LogDebug( "noTriggerFilters" ) << "PATTrigProducer: The TriggerEvent of this event contains no filter information at all!"; 00042 } else { 00043 size_type iFilter = triggerEvent->filterIndex( filterName_ ); 00044 if ( iFilter == nFilters ) { 00045 LogDebug( "noTriggerFilter" ) << "PATTrigProducer: The TriggerEvent of this event contains no filter information on filter " << filterName_.label() << "!"; 00046 } else { 00047 const Vids & triggerIds = triggerEvent->filterIds( iFilter ); 00048 const Keys & triggerKeys = triggerEvent->filterKeys( iFilter ); 00049 const TriggerObjectCollection & triggerObjects = triggerEvent->getObjects(); 00050 assert( triggerIds.size() == triggerKeys.size() ); 00051 for ( size_type idx = 0; idx < triggerKeys.size(); ++idx ) { 00052 const TriggerObject triggerObject = triggerObjects.at( triggerKeys.at( idx ) ); 00053 auto_ptr<TriggerPrimitive> ptr( new TriggerPrimitive( triggerObject.particle().p4(), filterName_.label(), triggerIds.at( idx ), triggerObject.id() ) ); 00054 patTrigCandidates->push_back( ptr ); 00055 } 00056 } 00057 } 00058 } catch( Exception exc ) { 00059 if ( exc.categoryCode() == errors::ProductNotFound ) { 00060 LogWarning( "noTriggerEvent" ) << "PATTrigProducer: No TriggerEvent " << triggerEvent_.label() << " found!"; 00061 } else { 00062 throw exc; 00063 } 00064 } 00065 iEvent.put( patTrigCandidates ); 00066 }