CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/DataFormats/PatCandidates/interface/TriggerObject.h

Go to the documentation of this file.
00001 #ifndef DataFormats_PatCandidates_TriggerObject_h
00002 #define DataFormats_PatCandidates_TriggerObject_h
00003 
00004 
00005 // -*- C++ -*-
00006 //
00007 // Package:    PatCandidates
00008 // Class:      pat::TriggerObject
00009 //
00010 // $Id: TriggerObject.h,v 1.13 2010/12/20 20:05:52 vadler Exp $
00011 //
00025 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00026 
00027 #include <map>
00028 #include <string>
00029 #include <vector>
00030 #include <algorithm>
00031 
00032 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00033 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
00034 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00035 #include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
00036 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00037 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00038 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00039 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
00040 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00041 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00042 #include "DataFormats/Common/interface/RefVectorIterator.h"
00043 #include "DataFormats/Common/interface/Association.h"
00044 #include "FWCore/Utilities/interface/InputTag.h"
00045 
00046 
00047 namespace pat {
00048 
00049   class TriggerObject : public reco::LeafCandidate {
00050 
00052 
00054       std::string collection_;
00058       std::vector< trigger::TriggerObjectType > triggerObjectTypes_;
00062       reco::CandidateBaseRef refToOrig_;
00063 
00064     public:
00065 
00067 
00069       TriggerObject();
00071       TriggerObject( const trigger::TriggerObject & trigObj );
00073       TriggerObject( const reco::LeafCandidate    & leafCand );
00075       TriggerObject( const reco::CandidateBaseRef & candRef );
00077       TriggerObject( const reco::Particle::LorentzVector      & vec, int id = 0 );
00078       TriggerObject( const reco::Particle::PolarLorentzVector & vec, int id = 0 );
00079 
00081       virtual ~TriggerObject() {};
00082 
00084 
00086       void setCollection( const std::string & collName )   { collection_ = collName; };
00087       void setCollection( const edm::InputTag & collName ) { collection_ = collName.encode(); };
00089       void addTriggerObjectType( trigger::TriggerObjectType triggerObjectType ) { if ( ! hasTriggerObjectType( triggerObjectType ) ) triggerObjectTypes_.push_back( triggerObjectType ); };
00090       void addTriggerObjectType( int                        triggerObjectType ) { addTriggerObjectType( trigger::TriggerObjectType( triggerObjectType ) ); };
00091       void addFilterId( trigger::TriggerObjectType triggerObjectType ) { addTriggerObjectType( triggerObjectType ); };                               // for backward compatibility
00092       void addFilterId( int                        triggerObjectType ) { addTriggerObjectType( trigger::TriggerObjectType( triggerObjectType ) ); }; // for backward compatibility
00094       std::string collection() const { return collection_; };
00096 //       std::vector< trigger::TriggerObjectType > triggerObjectTypes() const { return triggerObjectTypes_; };
00097 //       std::vector< trigger::TriggerObjectType > filterIds()          const { return triggerObjectTypes(); }; // for backward compatibility
00098       std::vector< int > triggerObjectTypes() const;                                  // for backward compatibility
00099       std::vector< int > filterIds()          const { return triggerObjectTypes(); }; // for double backward compatibility
00101       virtual bool hasCollection( const std::string   & collName ) const;
00102       virtual bool hasCollection( const edm::InputTag & collName ) const { return hasCollection( collName.encode() ); };
00104       bool hasTriggerObjectType( trigger::TriggerObjectType triggerObjectType ) const;
00105       bool hasTriggerObjectType( int                        triggerObjectType ) const { return hasTriggerObjectType( trigger::TriggerObjectType( triggerObjectType ) ); };
00106       bool hasFilterId( trigger::TriggerObjectType triggerObjectType ) const { return hasTriggerObjectType( triggerObjectType ); };                               // for backward compatibility
00107       bool hasFilterId( int                        triggerObjectType ) const { return hasTriggerObjectType( trigger::TriggerObjectType( triggerObjectType ) ); }; // for backward compatibility
00108 
00110 
00112       const reco::CandidateBaseRef & origObjRef()  const { return refToOrig_; };
00113       const reco::Candidate        * origObjCand() const { return refToOrig_.get(); };
00116       const l1extra::L1EmParticleRef origL1EmRef() const;
00117       const L1GctEmCand * origL1GctEmCand() const { return origL1EmRef().isNonnull() ? origL1EmRef()->gctEmCand() : 0; };
00119       const l1extra::L1EtMissParticleRef origL1EtMissRef() const;
00120       const L1GctEtMiss  * origL1GctEtMiss()  const { return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtMiss()  : 0; };
00121       const L1GctEtTotal * origL1GctEtTotal() const { return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtTotal() : 0; };
00122       const L1GctHtMiss  * origL1GctHtMiss()  const { return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctHtMiss()  : 0; };
00123       const L1GctEtHad   * origL1GctEtHad()   const { return origL1EtMissRef().isNonnull() ? origL1EtMissRef()->gctEtHad()   : 0; };
00125       const l1extra::L1JetParticleRef origL1JetRef() const;
00126       const L1GctJetCand * origL1GctJetCand() const { return origL1JetRef().isNonnull() ? origL1JetRef()->gctJetCand() : 0; };
00128       const l1extra::L1MuonParticleRef origL1MuonRef() const;
00129       const L1MuGMTExtendedCand * origL1GmtMuonCand() const { return origL1MuonRef().isNonnull() ? &( origL1MuonRef()->gmtMuonCand() ) : 0; };
00130 
00134 
00136       virtual bool coll( const std::string & collName ) const { return hasCollection( collName ); };
00138       bool type( trigger::TriggerObjectType triggerObjectType ) const { return hasTriggerObjectType( triggerObjectType ); };
00139       bool type( int                        triggerObjectType ) const { return hasTriggerObjectType( trigger::TriggerObjectType ( triggerObjectType ) ); };
00140       bool id( trigger::TriggerObjectType triggerObjectType ) const { return hasTriggerObjectType( triggerObjectType ); };                                // for backward compatibility
00141       bool id( int                        triggerObjectType ) const { return hasTriggerObjectType( trigger::TriggerObjectType ( triggerObjectType ) ); }; // for backward compatibility
00142 
00143   };
00144 
00145 
00147   typedef std::vector< TriggerObject >                       TriggerObjectCollection;
00149   typedef edm::Ref< TriggerObjectCollection >                TriggerObjectRef;
00151   typedef std::map< std::string, TriggerObjectRef >          TriggerObjectMatchMap;
00153   typedef edm::RefProd< TriggerObjectCollection >            TriggerObjectRefProd;
00155   typedef edm::RefVector< TriggerObjectCollection >          TriggerObjectRefVector;
00157   typedef edm::RefVectorIterator< TriggerObjectCollection >  TriggerObjectRefVectorIterator;
00159   typedef edm::Association< TriggerObjectCollection >        TriggerObjectMatch;
00161   typedef edm::RefProd< TriggerObjectMatch >                 TriggerObjectMatchRefProd;
00163   typedef std::map< std::string, TriggerObjectMatchRefProd > TriggerObjectMatchContainer;
00164 
00165 }
00166 
00167 
00168 #endif