Go to the documentation of this file.00001
00002
00003
00004
00005 #include "DataFormats/PatCandidates/interface/TriggerObject.h"
00006
00007 #include "FWCore/Utilities/interface/EDMException.h"
00008
00009
00010 using namespace pat;
00011
00012
00013
00014
00015
00016
00017 TriggerObject::TriggerObject() :
00018 reco::LeafCandidate()
00019 {
00020 triggerObjectTypes_.clear();
00021 }
00022
00023
00024
00025 TriggerObject::TriggerObject( const trigger::TriggerObject & trigObj ) :
00026 reco::LeafCandidate( 0, trigObj.particle().p4(), reco::Particle::Point( 0., 0., 0. ), trigObj.id() ),
00027 refToOrig_()
00028 {
00029 triggerObjectTypes_.clear();
00030 }
00031
00032
00033
00034 TriggerObject::TriggerObject( const reco::LeafCandidate & leafCand ) :
00035 reco::LeafCandidate( leafCand ),
00036 refToOrig_()
00037 {
00038 triggerObjectTypes_.clear();
00039 }
00040
00041
00042
00043 TriggerObject::TriggerObject( const reco::CandidateBaseRef & candRef ) :
00044 reco::LeafCandidate( *candRef ),
00045 refToOrig_( candRef )
00046 {
00047 triggerObjectTypes_.clear();
00048 }
00049
00050
00051
00052 TriggerObject::TriggerObject( const reco::Particle::LorentzVector & vec, int id ) :
00053 reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
00054 refToOrig_()
00055 {
00056 triggerObjectTypes_.clear();
00057 }
00058 TriggerObject::TriggerObject( const reco::Particle::PolarLorentzVector & vec, int id ) :
00059 reco::LeafCandidate( 0, vec, reco::Particle::Point( 0., 0., 0. ), id ),
00060 refToOrig_()
00061 {
00062 triggerObjectTypes_.clear();
00063 }
00064
00065
00066
00067
00068
00069
00070 std::vector< int > TriggerObject::triggerObjectTypes() const
00071 {
00072 std::vector< int > triggerObjectTypes;
00073 for ( size_t iTo = 0; iTo < triggerObjectTypes_.size(); ++iTo ) {
00074 triggerObjectTypes.push_back( triggerObjectTypes_.at( iTo ) );
00075 }
00076 return triggerObjectTypes;
00077 }
00078
00079
00080
00081 bool TriggerObject::hasCollection( const std::string & collName ) const
00082 {
00083
00084 if ( collName == collection_ ) return true;
00085
00086 const edm::InputTag collectionTag( collection_ );
00087 const edm::InputTag collTag( collName );
00088
00089 if ( collTag.process().empty() ) {
00090
00091 if ( ( collTag.instance().empty() && collectionTag.instance().empty() ) || collTag.instance() == collectionTag.instance() ) {
00092
00093 return ( collTag.label() == collectionTag.label() );
00094 }
00095 }
00096 return false;
00097 }
00098
00099
00100
00101 bool TriggerObject::hasTriggerObjectType( trigger::TriggerObjectType triggerObjectType ) const
00102 {
00103 for ( size_t iF = 0; iF < triggerObjectTypes_.size(); ++iF ) {
00104 if ( triggerObjectType == triggerObjectTypes_.at( iF ) ) return true;
00105 }
00106 return false;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 const l1extra::L1EmParticleRef TriggerObject::origL1EmRef() const
00119 {
00120 l1extra::L1EmParticleRef l1Ref;
00121 try {
00122 l1Ref = origObjRef().castTo< l1extra::L1EmParticleRef >();
00123 } catch ( edm::Exception X ) {
00124 if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
00125 }
00126 return l1Ref;
00127 }
00128
00129
00130 const l1extra::L1EtMissParticleRef TriggerObject::origL1EtMissRef() const
00131 {
00132 l1extra::L1EtMissParticleRef l1Ref;
00133 try {
00134 l1Ref = origObjRef().castTo< l1extra::L1EtMissParticleRef >();
00135 } catch ( edm::Exception X ) {
00136 if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
00137 }
00138 return l1Ref;
00139 }
00140
00141
00142 const l1extra::L1JetParticleRef TriggerObject::origL1JetRef() const
00143 {
00144 l1extra::L1JetParticleRef l1Ref;
00145 try {
00146 l1Ref = origObjRef().castTo< l1extra::L1JetParticleRef >();
00147 } catch ( edm::Exception X ) {
00148 if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
00149 }
00150 return l1Ref;
00151 }
00152
00153
00154 const l1extra::L1MuonParticleRef TriggerObject::origL1MuonRef() const
00155 {
00156 l1extra::L1MuonParticleRef l1Ref;
00157 try {
00158 l1Ref = origObjRef().castTo< l1extra::L1MuonParticleRef >();
00159 } catch ( edm::Exception X ) {
00160 if ( X.categoryCode() != edm::errors::InvalidReference ) throw X;
00161 }
00162 return l1Ref;
00163 }