Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:41

0001 #ifndef HLTReco_TriggerFilterObjectWithRefs_h
0002 #define HLTReco_TriggerFilterObjectWithRefs_h
0003 
0004 /** \class trigger::TriggerFilterObjectWithRefs
0005  *
0006  *  If HLT cuts of intermediate or final HLT filters are satisfied,
0007  *  instances of this class hold the combination of reconstructed
0008  *  physics objects (e/gamma/mu/jet/MMet...) satisfying the cuts.
0009  *
0010  *  This implementation is not completely space-efficient as some
0011  *  physics object containers may stay empty. However, the big
0012  *  advantage is that the solution is generic, i.e., works for all
0013  *  possible HLT filters. Hence we accept the reasonably small
0014  *  overhead of empty containers.
0015  *
0016  *
0017  *  \author Martin Grunewald
0018  *
0019  */
0020 
0021 #include "DataFormats/HLTReco/interface/TriggerRefsCollections.h"
0022 #include "FWCore/Utilities/interface/InputTag.h"
0023 
0024 #include <string>
0025 #include <vector>
0026 #include <algorithm>
0027 
0028 namespace trigger {
0029 
0030   /// Transient book-keeping EDProduct filled by HLTFilter module to
0031   /// record physics objects firing the filter (never persistet in
0032   /// production; same functionality but different implementation
0033   /// compared to the old HLT data model's HLTFilterObjectWithRefs
0034   /// class)
0035   class TriggerFilterObjectWithRefs : public TriggerRefsCollections {
0036     /// data members
0037   private:
0038     int path_;
0039     int module_;
0040     std::vector<std::string> collectionTags_;
0041 
0042     /// methods
0043   public:
0044     /// constructors
0045     TriggerFilterObjectWithRefs() : TriggerRefsCollections(), path_(-9), module_(-9), collectionTags_() {}
0046 
0047     TriggerFilterObjectWithRefs(int path, int module)
0048         : TriggerRefsCollections(), path_(path), module_(module), collectionTags_() {}
0049 
0050     /// accessors
0051     int path() const { return path_; }
0052     int module() const { return module_; }
0053 
0054     /// collectionTags
0055     void addCollectionTag(const edm::InputTag& collectionTag) { collectionTags_.push_back(collectionTag.encode()); }
0056 
0057     void getCollectionTags(std::vector<edm::InputTag>& collectionTags) const {
0058       const trigger::size_type n(collectionTags_.size());
0059       collectionTags.resize(n);
0060       for (trigger::size_type i = 0; i != n; ++i) {
0061         collectionTags[i] = edm::InputTag(collectionTags_[i]);
0062       }
0063     }
0064 
0065     /// low-level technical accessor
0066     const std::vector<std::string>& getCollectionTagsAsStrings() const { return collectionTags_; }
0067 
0068     /// utility
0069     void swap(TriggerFilterObjectWithRefs& other) {
0070       TriggerRefsCollections::swap(other);  // swap base instance
0071       std::swap(path_, other.path_);
0072       std::swap(module_, other.module_);
0073       std::swap(collectionTags_, other.collectionTags_);  // use specialized version for STL containers
0074     }
0075   };
0076 
0077   // picked up via argument dependent lookup, e-g- by boost::swap()
0078   inline void swap(TriggerFilterObjectWithRefs& first, TriggerFilterObjectWithRefs& second) { first.swap(second); }
0079 
0080 }  // namespace trigger
0081 
0082 #endif