CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterTPAssociation.h
Go to the documentation of this file.
1 #ifndef SimTracker_TrackerHitAssociation_ClusterTPAssociation_h
2 #define SimTracker_TrackerHitAssociation_ClusterTPAssociation_h
3 
9 
10 #include <vector>
11 #include <utility>
12 #include <algorithm>
13 
21 public:
24  using value_type = std::pair<key_type, mapped_type>;
25  using map_type = std::vector<value_type>;
26  using const_iterator = typename map_type::const_iterator;
27  using range = std::pair<const_iterator, const_iterator>;
28 
30  explicit ClusterTPAssociation(const edm::HandleBase& mappedHandle): ClusterTPAssociation(mappedHandle.id()) {}
31  explicit ClusterTPAssociation(const edm::ProductID& mappedProductId): mappedProductId_(mappedProductId) {}
32 
33  void emplace_back(const OmniClusterRef& cluster, const TrackingParticleRef& tp) {
35  map_.emplace_back(cluster, tp);
36  }
37  void sort() { std::sort(map_.begin(), map_.end(), compare); }
38  void swap(ClusterTPAssociation& other) {
39  map_.swap(other.map_);
41  }
42 
43  bool empty() const { return map_.empty(); }
44  size_t size() const { return map_.size(); }
45 
46  const_iterator begin() const { return map_.begin(); }
47  const_iterator cbegin() const { return map_.cbegin(); }
48  const_iterator end() const { return map_.end(); }
49  const_iterator cend() const { return map_.end(); }
50 
52  return std::equal_range(map_.begin(), map_.end(), value_type(key, TrackingParticleRef()), compare);
53  }
54 
55  const map_type& map() const { return map_; }
56 
57  void checkMappedProductID(const edm::HandleBase& mappedHandle) const { checkMappedProductID(mappedHandle.id()); }
59  void checkMappedProductID(const edm::ProductID& id) const;
60 
61 private:
62  static bool compare(const value_type& i, const value_type& j) {
63  return i.first.rawIndex() > j.first.rawIndex();
64  }
65 
68 };
69 
70 #endif
int i
Definition: DBlmapReader.cc:9
const_iterator cbegin() const
ProductID id() const
Definition: HandleBase.cc:15
void checkMappedProductID(const TrackingParticleRef &tp) const
const_iterator begin() const
typename map_type::const_iterator const_iterator
void swap(ProductID &other)
Definition: ProductID.cc:17
edm::ProductID mappedProductId_
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
const_iterator end() const
const_iterator cend() const
int j
Definition: DBlmapReader.cc:9
range equal_range(const OmniClusterRef &key) const
static bool compare(const value_type &i, const value_type &j)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
std::vector< value_type > map_type
ClusterTPAssociation(const edm::HandleBase &mappedHandle)
void swap(ClusterTPAssociation &other)
void checkMappedProductID(const edm::HandleBase &mappedHandle) const
std::pair< const_iterator, const_iterator > range
const map_type & map() const
std::pair< key_type, mapped_type > value_type
edm::Ref< TrackingParticleCollection > TrackingParticleRef
void emplace_back(const OmniClusterRef &cluster, const TrackingParticleRef &tp)
ClusterTPAssociation(const edm::ProductID &mappedProductId)