Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:54

0001 #ifndef DataFormats_Common_ThinnedAssociation_h
0002 #define DataFormats_Common_ThinnedAssociation_h
0003 
0004 /** \class edm::ThinnedAssociation
0005 \author W. David Dagenhart, created 11 June 2014
0006 */
0007 
0008 #include "DataFormats/Provenance/interface/ProductID.h"
0009 
0010 #include <optional>
0011 #include <vector>
0012 
0013 namespace edm {
0014 
0015   class ThinnedAssociation {
0016   public:
0017     ThinnedAssociation();
0018 
0019     ProductID const& parentCollectionID() const { return parentCollectionID_; }
0020     ProductID const& thinnedCollectionID() const { return thinnedCollectionID_; }
0021     std::vector<unsigned int> const& indexesIntoParent() const { return indexesIntoParent_; }
0022 
0023     // If this association contains the parent index, return the
0024     // corresponding index into the thinned collection. Otherwise
0025     // return null std::optional.
0026     std::optional<unsigned int> getThinnedIndex(unsigned int parentIndex) const;
0027 
0028     void setParentCollectionID(ProductID const& v) { parentCollectionID_ = v; }
0029     void setThinnedCollectionID(ProductID const& v) { thinnedCollectionID_ = v; }
0030     void push_back(unsigned int index) { indexesIntoParent_.push_back(index); }
0031 
0032   private:
0033     ProductID parentCollectionID_;
0034     ProductID thinnedCollectionID_;
0035 
0036     // The size of indexesIntoParent_ is the same as
0037     // the size of the thinned collection and each
0038     // element of indexesIntoParent corresponds to the
0039     // element of the thinned collection at the same position.
0040     // The values give the index of the corresponding element
0041     // in the parent collection.
0042     std::vector<unsigned int> indexesIntoParent_;
0043   };
0044 }  // namespace edm
0045 #endif