CMS 3D CMS Logo

MuonDigiCollection.h
Go to the documentation of this file.
1 #ifndef DataFormats_MuonDigiCollection_h
2 #define DataFormats_MuonDigiCollection_h
3 
13 #include <vector>
14 #include <map>
15 #include <iterator>
17 
18 
32 template <typename IndexType, typename DigiType>
34  public:
35  typedef typename std::vector<DigiType>::const_iterator DigiRangeIterator;
36  typedef std::map<IndexType, std::vector<DigiType> > BaseContainer;
37  typedef typename BaseContainer::const_iterator BaseIterator;
38 
39  typedef std::pair<IndexType,
40  std::pair<DigiRangeIterator,
41  DigiRangeIterator> > value_type;
42  typedef value_type reference;
43  typedef void pointer;
44  typedef typename DigiRangeIterator::difference_type difference_type;
45  typedef typename DigiRangeIterator::iterator_category iterator_category;
46 
48  DigiContainerIterator (BaseIterator i) : base_ (i) {}
49  // implicit copy constructor
50  // implicit assignment operator
51  // implicit destructor
52 
54  { return DigiContainerIterator (base_++); }
55 
57  { ++base_; return *this; }
58 
60  { return x.base_ == base_; }
61 
63  { return x.base_ != base_; }
64 
65  value_type operator* (void) const
66  {
67  return std::make_pair(base_->first,
68  std::make_pair(base_->second.begin(),
69  base_->second.end()));
70  }
71 
72 
73  private:
74  BaseIterator base_;
75  };
76 
77 
78 
79 
99 template <typename IndexType,
100  typename DigiType>
102 
103 public:
104 
106 
107 // void swap(MuonDigiCollection<IndexType,DigiType> & rh) { std::swap(data_,rh.data_);}
108  void swap(MuonDigiCollection & rh) { std::swap(data_,rh.data_);}
109 
110  typedef typename std::vector<DigiType>::const_iterator const_iterator;
111  typedef typename std::pair<const_iterator,const_iterator> Range;
112 
113 
115  void insertDigi(const IndexType& index, const DigiType& digi){
116  std::vector<DigiType> &digis = data_[index];
117  digis.push_back(digi);
118  }
119 
121  void put(Range range, const IndexType& index){
122  std::vector<DigiType> &digis = data_[index];
123  digis.reserve (digis.size () + (range.second - range.first));
124  std::copy (range.first, range.second, std::back_inserter (digis));
125 
126  }
127 
128 #ifndef CMS_NOCXX11
129  template<typename IRange>
131  void move(IRange range, const IndexType& index){
132  std::vector<DigiType> &digis = data_[index];
133  digis.reserve (digis.size () + (range.second - range.first));
134  digis.insert(digis.end(),std::make_move_iterator(range.first), std::make_move_iterator(range.second));
135  }
136 #endif
137 
138 
140  Range get(const IndexType& index) const{
141  typename container::const_iterator it = data_.find(index);
142  if (it==data_.end()) {
143  // if data_ is empty there is no other way to get an empty range
144  static const std::vector<DigiType> empty;
145  return std::make_pair(empty.end(),empty.end());
146  }
147  const std::vector<DigiType>& digis = (*it).second;
148  return std::make_pair(digis.begin(),digis.end());
149  }
150 
152 
153  DigiRangeIterator begin() const {
154  return data_.begin();}
155 
156  DigiRangeIterator end() const {
157  return data_.end();}
158 
159 
160 private:
161 
162  typedef std::map<IndexType,std::vector<DigiType> > container;
163  container data_;
164 
165 
166 }; // MuonDigiCollection
167 
168 template <typename IndexType,
169  typename DigiType>
170 inline
173 
174 #endif
175 
DigiContainerIterator< IndexType, DigiType > DigiRangeIterator
std::vector< DigiType >::const_iterator DigiRangeIterator
def copy(args, dbName)
void swap(MuonDigiCollection &rh)
void swap(MuonDigiCollection< IndexType, DigiType > &rh, MuonDigiCollection< IndexType, DigiType > &lh)
std::map< IndexType, std::vector< DigiType > > BaseContainer
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
bool int lh
Definition: SIMDVec.h:21
value_type operator*(void) const
DigiRangeIterator::iterator_category iterator_category
DigiRangeIterator::difference_type difference_type
std::map< IndexType, std::vector< DigiType > > container
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool operator==(const DigiContainerIterator &x)
std::pair< IndexType, std::pair< DigiRangeIterator, DigiRangeIterator > > value_type
std::vector< DigiType >::const_iterator const_iterator
std::pair< const_iterator, const_iterator > Range
DigiContainerIterator(BaseIterator i)
bool operator!=(const DigiContainerIterator &x)
DigiRangeIterator end() const
BaseContainer::const_iterator BaseIterator
def move(src, dest)
Definition: eostools.py:510
void put(Range range, const IndexType &index)
insert a range of digis for a given DetUnit
DigiContainerIterator & operator++(void)
DigiRangeIterator begin() const
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...