CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/HLTReco/interface/TriggerEvent.h

Go to the documentation of this file.
00001 #ifndef HLTReco_TriggerEvent_h
00002 #define HLTReco_TriggerEvent_h
00003 
00016 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00017 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00018 #include "FWCore/Utilities/interface/InputTag.h"
00019 #include "DataFormats/Common/interface/traits.h"
00020 #include <string>
00021 #include <vector>
00022 
00023 namespace trigger
00024 {
00025 
00027   class TriggerEvent : public edm::DoNotRecordParents {
00028 
00029   public:
00030 
00032     class TriggerFilterObject {
00033     public:
00035       std::string filterTag_;
00037       Vids filterIds_;
00039       Keys filterKeys_;
00041       TriggerFilterObject(): filterTag_(), filterIds_(), filterKeys_() {
00042         filterTag_=edm::InputTag().encode();
00043       }
00044       TriggerFilterObject(const edm::InputTag& filterTag): filterTag_(filterTag.encode()), filterIds_(), filterKeys_() { }
00045       TriggerFilterObject(const edm::InputTag& filterTag, const Vids& filterIds, const Keys& filterKeys): filterTag_(filterTag.encode()), filterIds_(filterIds), filterKeys_(filterKeys) { }
00046     };
00047 
00049   private:
00051     std::string usedProcessName_;
00053     std::vector<std::string> collectionTags_;
00055     Keys collectionKeys_;
00057     TriggerObjectCollection triggerObjects_;
00059     std::vector<TriggerFilterObject> triggerFilters_;
00060 
00062   public:
00064     TriggerEvent(): usedProcessName_(), collectionTags_(), collectionKeys_(), triggerObjects_(), triggerFilters_() { }
00065     TriggerEvent(const std::string& usedProcessName, trigger::size_type nc, trigger::size_type no, trigger::size_type nf):
00066       usedProcessName_(usedProcessName), 
00067       collectionTags_(),
00068       collectionKeys_(),
00069       triggerObjects_(), 
00070       triggerFilters_() 
00071     {
00072       collectionTags_.reserve(nc); collectionKeys_.reserve(nc);
00073       triggerObjects_.reserve(no); triggerFilters_.reserve(nf); 
00074     }
00075 
00077     void addObjects(const TriggerObjectCollection& triggerObjects) {triggerObjects_.insert(triggerObjects_.end(), triggerObjects.begin(), triggerObjects.end());}
00078 
00079     void addCollections(const std::vector<edm::InputTag>& collectionTags, const Keys& collectionKeys) {
00080       assert(collectionTags.size()==collectionKeys.size());
00081       const trigger::size_type n(collectionTags.size());
00082       for (trigger::size_type i=0; i!=n; ++i) {
00083         collectionTags_.push_back(collectionTags[i].encode());
00084       }
00085       collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
00086     }
00087 
00088     void addCollections(const std::vector<std::string>& collectionTags, const Keys& collectionKeys) {
00089       assert(collectionTags.size()==collectionKeys.size());
00090       collectionTags_.insert(collectionTags_.end(), collectionTags.begin(), collectionTags.end());
00091       collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
00092     }
00093 
00094     void addFilter(const edm::InputTag& filterTag, const Vids& filterIds, const Keys& filterKeys) {triggerFilters_.push_back(TriggerFilterObject(filterTag, filterIds, filterKeys));}
00095 
00097     const std::string& usedProcessName() const {return usedProcessName_;}
00098     const std::vector<std::string>& collectionTags() const {return collectionTags_;}
00099     const Keys& collectionKeys() const {return collectionKeys_;}
00100     const TriggerObjectCollection& getObjects() const {return triggerObjects_;}
00101 
00102     const edm::InputTag collectionTag(trigger::size_type index) const {return edm::InputTag(collectionTags_.at(index));}
00103     trigger::size_type collectionKey(trigger::size_type index) const {return collectionKeys_.at(index);}
00104     const edm::InputTag filterTag(trigger::size_type index) const {return edm::InputTag(triggerFilters_.at(index).filterTag_);}
00105     const Vids& filterIds(trigger::size_type index) const {return triggerFilters_.at(index).filterIds_;}
00106     const Keys& filterKeys(trigger::size_type index) const {return triggerFilters_.at(index).filterKeys_;}
00107 
00109     trigger::size_type collectionIndex(const edm::InputTag& collectionTag) const {
00110       const std::string encodedCollectionTag(collectionTag.encode());
00111       const trigger::size_type n(collectionTags_.size());
00112       for (trigger::size_type i=0; i!=n; ++i) {
00113         if (encodedCollectionTag==collectionTags_[i]) {return i;}
00114       }
00115       return n;
00116     }
00118     trigger::size_type filterIndex(const edm::InputTag& filterTag) const {
00119       const std::string encodedFilterTag(filterTag.encode());
00120       const trigger::size_type n(triggerFilters_.size());
00121       for (trigger::size_type i=0; i!=n; ++i) {
00122         if (encodedFilterTag==triggerFilters_[i].filterTag_) {return i;}
00123       }
00124       return n;
00125     }
00126 
00128     trigger::size_type sizeCollections() const {return collectionTags_.size();}
00129     trigger::size_type sizeObjects() const {return triggerObjects_.size();}
00130     trigger::size_type sizeFilters() const {return triggerFilters_.size();}
00131 
00132   };
00133 
00134 }
00135 
00136 #endif