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 const std::string & collectionTagEncoded(trigger::size_type index) const {return collectionTags_.at(index);}
00104 trigger::size_type collectionKey(trigger::size_type index) const {return collectionKeys_.at(index);}
00105 const edm::InputTag filterTag(trigger::size_type index) const {return edm::InputTag(triggerFilters_.at(index).filterTag_);}
00106 const std::string & filterTagEncoded(trigger::size_type index) const {return triggerFilters_.at(index).filterTag_;}
00107 std::string filterLabel(trigger::size_type index) const {
00108 const std::string & tag = triggerFilters_.at(index).filterTag_;
00109 std::string::size_type idx = tag.find(':');
00110 return (idx == std::string::npos ? tag : tag.substr(0,idx));
00111 }
00112 const Vids& filterIds(trigger::size_type index) const {return triggerFilters_.at(index).filterIds_;}
00113 const Keys& filterKeys(trigger::size_type index) const {return triggerFilters_.at(index).filterKeys_;}
00114
00116 trigger::size_type collectionIndex(const edm::InputTag& collectionTag) const {
00117 const std::string encodedCollectionTag(collectionTag.encode());
00118 const trigger::size_type n(collectionTags_.size());
00119 for (trigger::size_type i=0; i!=n; ++i) {
00120 if (encodedCollectionTag==collectionTags_[i]) {return i;}
00121 }
00122 return n;
00123 }
00125 trigger::size_type filterIndex(const edm::InputTag& filterTag) const {
00126 const std::string encodedFilterTag(filterTag.encode());
00127 const trigger::size_type n(triggerFilters_.size());
00128 for (trigger::size_type i=0; i!=n; ++i) {
00129 if (encodedFilterTag==triggerFilters_[i].filterTag_) {return i;}
00130 }
00131 return n;
00132 }
00133
00135 trigger::size_type sizeCollections() const {return collectionTags_.size();}
00136 trigger::size_type sizeObjects() const {return triggerObjects_.size();}
00137 trigger::size_type sizeFilters() const {return triggerFilters_.size();}
00138
00139 };
00140
00141 }
00142
00143 #endif