CMS 3D CMS Logo

TriggerEvent.h
Go to the documentation of this file.
1 #ifndef HLTReco_TriggerEvent_h
2 #define HLTReco_TriggerEvent_h
3 
18 #include <string>
19 #include <vector>
20 #include <cassert>
21 
22 namespace trigger {
23 
26  public:
29  public:
42  };
43 
45  private:
49  std::vector<std::string> collectionTags_;
55  std::vector<TriggerFilterObject> triggerFilters_;
56 
58  public:
66  triggerFilters_() {
67  collectionTags_.reserve(nc);
68  collectionKeys_.reserve(nc);
69  triggerObjects_.reserve(no);
70  triggerFilters_.reserve(nf);
71  }
72 
75  triggerObjects_.insert(triggerObjects_.end(), triggerObjects.begin(), triggerObjects.end());
76  }
77 
78  void addCollections(const std::vector<edm::InputTag>& collectionTags, const Keys& collectionKeys) {
79  assert(collectionTags.size() == collectionKeys.size());
80  const trigger::size_type n(collectionTags.size());
81  for (trigger::size_type i = 0; i != n; ++i) {
82  collectionTags_.push_back(collectionTags[i].encode());
83  }
84  collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
85  }
86 
87  void addCollections(const std::vector<std::string>& collectionTags, const Keys& collectionKeys) {
88  assert(collectionTags.size() == collectionKeys.size());
89  collectionTags_.insert(collectionTags_.end(), collectionTags.begin(), collectionTags.end());
90  collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
91  }
92 
95  }
96 
98  const std::string& usedProcessName() const { return usedProcessName_; }
99  const std::vector<std::string>& collectionTags() const { return collectionTags_; }
100  const Keys& collectionKeys() const { return collectionKeys_; }
102 
104  return edm::InputTag(collectionTags_.at(index));
105  }
109  return edm::InputTag(triggerFilters_.at(index).filterTag_);
110  }
113  const std::string& tag = triggerFilters_.at(index).filterTag_;
114  std::string::size_type idx = tag.find(':');
115  return (idx == std::string::npos ? tag : tag.substr(0, idx));
116  }
117  const Vids& filterIds(trigger::size_type index) const { return triggerFilters_.at(index).filterIds_; }
118  const Keys& filterKeys(trigger::size_type index) const { return triggerFilters_.at(index).filterKeys_; }
119 
122  const std::string encodedCollectionTag(collectionTag.encode());
123  const trigger::size_type n(collectionTags_.size());
124  for (trigger::size_type i = 0; i != n; ++i) {
125  if (encodedCollectionTag == collectionTags_[i]) {
126  return i;
127  }
128  }
129  return n;
130  }
133  const std::string encodedFilterTag(filterTag.encode());
134  const trigger::size_type n(triggerFilters_.size());
135  for (trigger::size_type i = 0; i != n; ++i) {
136  if (encodedFilterTag == triggerFilters_[i].filterTag_) {
137  return i;
138  }
139  }
140  return n;
141  }
142 
145  trigger::size_type sizeObjects() const { return triggerObjects_.size(); }
146  trigger::size_type sizeFilters() const { return triggerFilters_.size(); }
147  };
148 
149 } // namespace trigger
150 
151 #endif
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
const std::vector< std::string > & collectionTags() const
Definition: TriggerEvent.h:99
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::size_type collectionKey(trigger::size_type index) const
Definition: TriggerEvent.h:107
std::string encode() const
Definition: InputTag.cc:159
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
TriggerFilterObject(const edm::InputTag &filterTag)
Definition: TriggerEvent.h:38
std::vector< std::string > collectionTags_
Input tags of packed up collections.
Definition: TriggerEvent.h:49
const std::string & collectionTagEncoded(trigger::size_type index) const
Definition: TriggerEvent.h:106
const edm::InputTag collectionTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
void addCollections(const std::vector< edm::InputTag > &collectionTags, const Keys &collectionKeys)
Definition: TriggerEvent.h:78
assert(be >=bs)
void addCollections(const std::vector< std::string > &collectionTags, const Keys &collectionKeys)
Definition: TriggerEvent.h:87
uint16_t size_type
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:108
TriggerObjectCollection triggerObjects_
collection of all unique physics objects (linearised vector)
Definition: TriggerEvent.h:53
std::string filterLabel(trigger::size_type index) const
Definition: TriggerEvent.h:112
trigger::size_type sizeCollections() const
other
Definition: TriggerEvent.h:144
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
trigger::size_type sizeObjects() const
Definition: TriggerEvent.h:145
void addFilter(const edm::InputTag &filterTag, const Vids &filterIds, const Keys &filterKeys)
Definition: TriggerEvent.h:93
TriggerFilterObject(const edm::InputTag &filterTag, const Vids &filterIds, const Keys &filterKeys)
Definition: TriggerEvent.h:40
std::string filterTag_
encoded InputTag of filter product
Definition: TriggerEvent.h:31
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
Keys collectionKeys_
1-past-end indices into linearised vector
Definition: TriggerEvent.h:51
std::string usedProcessName_
data members
Definition: TriggerEvent.h:47
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:117
std::vector< TriggerFilterObject > triggerFilters_
collection of all TriggerFilterObjects
Definition: TriggerEvent.h:55
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
std::vector< size_type > Keys
Vids filterIds_
physics object type as per filter
Definition: TriggerEvent.h:33
def encode(args, files)
Keys filterKeys_
indices pointing into collection of unique TriggerObjects
Definition: TriggerEvent.h:35
const std::string & filterTagEncoded(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type collectionIndex(const edm::InputTag &collectionTag) const
find index of collection from collection tag
Definition: TriggerEvent.h:121
const std::string & usedProcessName() const
getters
Definition: TriggerEvent.h:98
void addObjects(const TriggerObjectCollection &triggerObjects)
setters
Definition: TriggerEvent.h:74
Helper class: recording trigger objects firing a single filter.
Definition: TriggerEvent.h:28
const Keys & collectionKeys() const
Definition: TriggerEvent.h:100
TriggerEvent(const std::string &usedProcessName, trigger::size_type nc, trigger::size_type no, trigger::size_type nf)
Definition: TriggerEvent.h:61
std::vector< int > Vids