00001 #ifndef PhysicsTools_PatAlgos_PATTriggerMatchSelector_h
00002 #define PhysicsTools_PatAlgos_PATTriggerMatchSelector_h
00003
00004
00005
00006
00007
00008
00009
00019
00020
00021
00022
00023
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029
00030 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00031
00032 #include <iostream>
00033
00034
00035
00036 namespace pat {
00037
00038 template< typename T1, typename T2 >
00039 class PATTriggerMatchSelector {
00040
00041 bool andOr_;
00042 std::vector< unsigned > filterIds_;
00043 std::vector< std::string > filterIdsEnum_;
00044 std::vector< std::string > filterLabels_;
00045 std::vector< std::string > pathNames_;
00046 std::vector< std::string > collectionTags_;
00047
00048 public:
00049
00050 PATTriggerMatchSelector( const edm::ParameterSet & iConfig ) :
00051 andOr_( iConfig.getParameter< bool >( "andOr" ) ),
00052 filterIds_( iConfig.getParameter< std::vector< unsigned > >( "filterIds" ) ),
00053 filterIdsEnum_( iConfig.getParameter< std::vector< std::string > >( "filterIdsEnum" ) ),
00054 filterLabels_( iConfig.getParameter< std::vector< std::string > >( "filterLabels" ) ),
00055 pathNames_( iConfig.getParameter< std::vector< std::string > >( "pathNames" ) ),
00056 collectionTags_( iConfig.getParameter< std::vector< std::string > >( "collectionTags" ) )
00057 {
00058 }
00059
00060 bool operator()( const T1 & patObj, const T2 & trigObj ) const {
00061 std::map< std::string, trigger::TriggerObjectType > filterIdsEnumMap;
00062 filterIdsEnumMap.insert( std::make_pair( "TriggerL1Mu" , trigger::TriggerL1Mu ) );
00063 filterIdsEnumMap.insert( std::make_pair( "TriggerL1NoIsoEG" , trigger::TriggerL1NoIsoEG ) );
00064 filterIdsEnumMap.insert( std::make_pair( "TriggerL1IsoEG" , trigger::TriggerL1IsoEG ) );
00065 filterIdsEnumMap.insert( std::make_pair( "TriggerL1CenJet" , trigger::TriggerL1CenJet ) );
00066 filterIdsEnumMap.insert( std::make_pair( "TriggerL1ForJet" , trigger::TriggerL1ForJet ) );
00067 filterIdsEnumMap.insert( std::make_pair( "TriggerL1TauJet" , trigger::TriggerL1TauJet ) );
00068 filterIdsEnumMap.insert( std::make_pair( "TriggerL1ETM" , trigger::TriggerL1ETM ) );
00069 filterIdsEnumMap.insert( std::make_pair( "TriggerL1ETT" , trigger::TriggerL1ETT ) );
00070 filterIdsEnumMap.insert( std::make_pair( "TriggerL1HTT" , trigger::TriggerL1HTT ) );
00071 filterIdsEnumMap.insert( std::make_pair( "TriggerL1JetCounts", trigger::TriggerL1JetCounts ) );
00072 filterIdsEnumMap.insert( std::make_pair( "TriggerPhoton" , trigger::TriggerPhoton ) );
00073 filterIdsEnumMap.insert( std::make_pair( "TriggerElectron" , trigger::TriggerElectron ) );
00074 filterIdsEnumMap.insert( std::make_pair( "TriggerMuon" , trigger::TriggerMuon ) );
00075 filterIdsEnumMap.insert( std::make_pair( "TriggerTau" , trigger::TriggerTau ) );
00076 filterIdsEnumMap.insert( std::make_pair( "TriggerJet" , trigger::TriggerJet ) );
00077 filterIdsEnumMap.insert( std::make_pair( "TriggerBJet" , trigger::TriggerBJet ) );
00078 filterIdsEnumMap.insert( std::make_pair( "TriggerMET" , trigger::TriggerMET ) );
00079 filterIdsEnumMap.insert( std::make_pair( "TriggerHT" , trigger::TriggerHT ) );
00080 filterIdsEnumMap.insert( std::make_pair( "TriggerTrack" , trigger::TriggerTrack ) );
00081 filterIdsEnumMap.insert( std::make_pair( "TriggerCluster" , trigger::TriggerCluster ) );
00082 filterIdsEnumMap.insert( std::make_pair( "TriggerMETSig" , trigger::TriggerMETSig ) );
00083 filterIdsEnumMap.insert( std::make_pair( "TriggerELongit" , trigger::TriggerELongit ) );
00084 if ( andOr_ ) {
00085 for ( size_t i = 0; i < filterIds_.size(); ++i ) {
00086 if ( filterIds_.at( i ) == 0 || trigObj.hasFilterId( filterIds_.at( i ) ) ) return true;
00087 }
00088 for ( size_t j = 0; j < filterLabels_.size(); ++j ) {
00089 if ( filterLabels_.at( j ) == "*" || filterLabels_.at( j ) == "@" || trigObj.hasFilterLabel( filterLabels_.at( j ) ) ) return true;
00090 }
00091 for ( size_t k = 0; k < pathNames_.size(); ++k ) {
00092 if ( pathNames_.at( k ) == "*" || pathNames_.at( k ) == "@" || trigObj.hasPathName( pathNames_.at( k ) ) ) return true;
00093 }
00094 for ( size_t l = 0; l < collectionTags_.size(); ++l ) {
00095 if ( collectionTags_.at( l ) == "*" || collectionTags_.at( l ) == "@" || collectionTags_.at( l ) == trigObj.collection() ) return true;
00096 }
00097 for ( size_t m = 0; m < filterIdsEnum_.size(); ++m ) {
00098 if ( filterIdsEnum_.at( m ) == "*" || filterIdsEnum_.at( m ) == "@" ) return true;
00099 std::map< std::string, trigger::TriggerObjectType >::const_iterator iter( filterIdsEnumMap.find( filterIdsEnum_.at( m ) ) );
00100 if ( iter != filterIdsEnumMap.end() && trigObj.hasFilterId( iter->second ) ) return true;
00101 }
00102 return false;
00103 } else {
00104 for ( size_t i = 0; i < filterIds_.size(); ++i ) {
00105 if ( filterIds_.at( i ) == 0 || trigObj.hasFilterId( filterIds_.at( i ) ) ) {
00106 for ( size_t j = 0; j < filterLabels_.size(); ++j ) {
00107 if ( filterLabels_.at( j ) == "*" || filterLabels_.at( j ) == "@" || trigObj.hasFilterLabel( filterLabels_.at( j ) ) ) {
00108 for ( size_t k = 0; k < pathNames_.size(); ++k ) {
00109 if ( pathNames_.at( k ) == "*" || pathNames_.at( k ) == "@" || trigObj.hasPathName( pathNames_.at( k ) ) ) {
00110 for ( size_t l = 0; l < collectionTags_.size(); ++l ) {
00111 if ( collectionTags_.at( l ) == "*" || collectionTags_.at( l ) == "@" || collectionTags_.at( l ) == trigObj.collection() ) {
00112 for ( size_t m = 0; m < filterIdsEnum_.size(); ++m ) {
00113 if ( filterIdsEnum_.at( m ) == "*" || filterIdsEnum_.at( m ) == "@" ) return true;
00114 std::map< std::string, trigger::TriggerObjectType >::const_iterator iter( filterIdsEnumMap.find( filterIdsEnum_.at( m ) ) );
00115 if ( iter != filterIdsEnumMap.end() && trigObj.hasFilterId( iter->second ) ) return true;
00116 }
00117 }
00118 }
00119 }
00120 }
00121 }
00122 }
00123 }
00124 }
00125 return false;
00126 }
00127 return false;
00128 }
00129
00130 };
00131
00132 }
00133
00134
00135 #endif