00001
00002
00003
00004
00005
00006 #include "PhysicsTools/PatUtils/interface/TriggerHelper.h"
00007
00008 #include "DataFormats/Common/interface/AssociativeIterator.h"
00009
00010
00011 using namespace pat;
00012 using namespace pat::helper;
00013
00014
00015
00017
00018 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
00019 {
00020 if ( matchResult ) {
00021 edm::AssociativeIterator< reco::CandidateBaseRef, TriggerObjectMatch > it( *matchResult, edm::EdmEventItemGetter< reco::CandidateBaseRef >( event ) ), itEnd( it.end() );
00022 while ( it != itEnd ) {
00023 if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
00024 if ( it->first == candRef ) {
00025 return TriggerObjectRef( it->second );
00026 }
00027 }
00028 ++it;
00029 }
00030 }
00031 return TriggerObjectRef();
00032 }
00033 TriggerObjectRef TriggerMatchHelper::triggerMatchObject( const reco::CandidateBaseRef & candRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
00034 {
00035 return triggerMatchObject( candRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
00036 }
00037
00038 TriggerObjectMatchMap TriggerMatchHelper::triggerMatchObjects( const reco::CandidateBaseRef & candRef, const edm::Event & event, const TriggerEvent & triggerEvent ) const
00039 {
00040 TriggerObjectMatchMap theContainer;
00041 const std::vector< std::string > matchers( triggerEvent.triggerMatchers() );
00042 for ( size_t iMatch = 0; iMatch < matchers.size(); ++iMatch ) {
00043 theContainer[ matchers.at( iMatch ) ] = triggerMatchObject( candRef, matchers.at( iMatch ), event, triggerEvent );
00044 }
00045 return theContainer;
00046 }
00047
00048 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const TriggerObjectMatch * matchResult, const edm::Event & event, const TriggerEvent & triggerEvent ) const
00049 {
00050 reco::CandidateBaseRefVector theCands;
00051 if ( matchResult ) {
00052 edm::AssociativeIterator< reco::CandidateBaseRef, TriggerObjectMatch > it( *matchResult, edm::EdmEventItemGetter< reco::CandidateBaseRef >( event ) ), itEnd( it.end() );
00053 while ( it != itEnd ) {
00054 if ( it->first.isNonnull() && it->second.isNonnull() && it->second.isAvailable() ) {
00055 if ( it->second == objectRef ) {
00056 theCands.push_back( it->first );
00057 }
00058 }
00059 ++it;
00060 }
00061 }
00062 return theCands;
00063 }
00064 reco::CandidateBaseRefVector TriggerMatchHelper::triggerMatchCandidates( const TriggerObjectRef & objectRef, const std::string & labelMatcher, const edm::Event & event, const TriggerEvent & triggerEvent ) const
00065 {
00066 return triggerMatchCandidates( objectRef, triggerEvent.triggerObjectMatchResult( labelMatcher ), event, triggerEvent );
00067 }