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 <string_view>
20 #include <vector>
21 #include <cassert>
22 
23 namespace trigger {
24 
27  public:
30  public:
43  };
44 
46  private:
50  std::vector<std::string> collectionTags_;
56  std::vector<TriggerFilterObject> triggerFilters_;
57 
59  public:
67  triggerFilters_() {
68  collectionTags_.reserve(nc);
69  collectionKeys_.reserve(nc);
70  triggerObjects_.reserve(no);
71  triggerFilters_.reserve(nf);
72  }
73 
76  triggerObjects_.insert(triggerObjects_.end(), triggerObjects.begin(), triggerObjects.end());
77  }
78 
79  void addCollections(const std::vector<edm::InputTag>& collectionTags, const Keys& collectionKeys) {
80  assert(collectionTags.size() == collectionKeys.size());
81  const trigger::size_type n(collectionTags.size());
82  for (trigger::size_type i = 0; i != n; ++i) {
83  collectionTags_.push_back(collectionTags[i].encode());
84  }
85  collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
86  }
87 
88  void addCollections(const std::vector<std::string>& collectionTags, const Keys& collectionKeys) {
89  assert(collectionTags.size() == collectionKeys.size());
90  collectionTags_.insert(collectionTags_.end(), collectionTags.begin(), collectionTags.end());
91  collectionKeys_.insert(collectionKeys_.end(), collectionKeys.begin(), collectionKeys.end());
92  }
93 
96  }
97 
99  const std::string& usedProcessName() const { return usedProcessName_; }
100  const std::vector<std::string>& collectionTags() const { return collectionTags_; }
101  const Keys& collectionKeys() const { return collectionKeys_; }
103 
105  return edm::InputTag(collectionTags_.at(index));
106  }
110  return edm::InputTag(triggerFilters_.at(index).filterTag_);
111  }
113  std::string_view filterLabel(trigger::size_type index) const {
114  std::string_view tag = triggerFilters_.at(index).filterTag_;
115  auto const idx = tag.find(':');
116  return (idx == tag.npos ? tag : tag.substr(0, idx));
117  }
118  const Vids& filterIds(trigger::size_type index) const { return triggerFilters_.at(index).filterIds_; }
119  const Keys& filterKeys(trigger::size_type index) const { return triggerFilters_.at(index).filterKeys_; }
120 
123  const std::string encodedCollectionTag(collectionTag.encode());
124  const trigger::size_type n(collectionTags_.size());
125  for (trigger::size_type i = 0; i != n; ++i) {
126  if (encodedCollectionTag == collectionTags_[i]) {
127  return i;
128  }
129  }
130  return n;
131  }
134  const std::string encodedFilterTag(filterTag.encode());
135  const trigger::size_type n(triggerFilters_.size());
136  for (trigger::size_type i = 0; i != n; ++i) {
137  if (encodedFilterTag == triggerFilters_[i].filterTag_) {
138  return i;
139  }
140  }
141  return n;
142  }
143 
146  trigger::size_type sizeObjects() const { return triggerObjects_.size(); }
147  trigger::size_type sizeFilters() const { return triggerFilters_.size(); }
148  };
149 
150 } // namespace trigger
151 
152 #endif
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:119
const std::vector< std::string > & collectionTags() const
Definition: TriggerEvent.h:100
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:26
trigger::size_type collectionKey(trigger::size_type index) const
Definition: TriggerEvent.h:108
std::string encode() const
Definition: InputTag.cc:159
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:147
TriggerFilterObject(const edm::InputTag &filterTag)
Definition: TriggerEvent.h:39
std::vector< std::string > collectionTags_
Input tags of packed up collections.
Definition: TriggerEvent.h:50
const std::string & collectionTagEncoded(trigger::size_type index) const
Definition: TriggerEvent.h:107
const edm::InputTag collectionTag(trigger::size_type index) const
Definition: TriggerEvent.h:104
void addCollections(const std::vector< edm::InputTag > &collectionTags, const Keys &collectionKeys)
Definition: TriggerEvent.h:79
assert(be >=bs)
void addCollections(const std::vector< std::string > &collectionTags, const Keys &collectionKeys)
Definition: TriggerEvent.h:88
uint16_t size_type
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:109
TriggerObjectCollection triggerObjects_
collection of all unique physics objects (linearised vector)
Definition: TriggerEvent.h:54
trigger::size_type sizeCollections() const
other
Definition: TriggerEvent.h:145
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:102
trigger::size_type sizeObjects() const
Definition: TriggerEvent.h:146
void addFilter(const edm::InputTag &filterTag, const Vids &filterIds, const Keys &filterKeys)
Definition: TriggerEvent.h:94
TriggerFilterObject(const edm::InputTag &filterTag, const Vids &filterIds, const Keys &filterKeys)
Definition: TriggerEvent.h:41
std::string filterTag_
encoded InputTag of filter product
Definition: TriggerEvent.h:32
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:52
std::string usedProcessName_
data members
Definition: TriggerEvent.h:48
const Vids & filterIds(trigger::size_type index) const
Definition: TriggerEvent.h:118
std::vector< TriggerFilterObject > triggerFilters_
collection of all TriggerFilterObjects
Definition: TriggerEvent.h:56
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:133
std::vector< size_type > Keys
Vids filterIds_
physics object type as per filter
Definition: TriggerEvent.h:34
def encode(args, files)
Keys filterKeys_
indices pointing into collection of unique TriggerObjects
Definition: TriggerEvent.h:36
const std::string & filterTagEncoded(trigger::size_type index) const
Definition: TriggerEvent.h:112
trigger::size_type collectionIndex(const edm::InputTag &collectionTag) const
find index of collection from collection tag
Definition: TriggerEvent.h:122
const std::string & usedProcessName() const
getters
Definition: TriggerEvent.h:99
void addObjects(const TriggerObjectCollection &triggerObjects)
setters
Definition: TriggerEvent.h:75
std::string_view filterLabel(trigger::size_type index) const
Definition: TriggerEvent.h:113
Helper class: recording trigger objects firing a single filter.
Definition: TriggerEvent.h:29
const Keys & collectionKeys() const
Definition: TriggerEvent.h:101
TriggerEvent(const std::string &usedProcessName, trigger::size_type nc, trigger::size_type no, trigger::size_type nf)
Definition: TriggerEvent.h:62
std::vector< int > Vids