CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
43  typedef void pointer;
44  typedef typename DigiRangeIterator::difference_type difference_type;
45  typedef typename DigiRangeIterator::iterator_category iterator_category;
46 
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:
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_);}
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 
154  return data_.begin();}
155 
157  return data_.end();}
158 
159 
160 private:
161 
162  typedef std::map<IndexType,std::vector<DigiType> > container;
164 
165 
166 }; // MuonDigiCollection
167 
168 template <typename IndexType,
169  typename DigiType>
170 inline
173 
174 #endif
175 
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
int i
Definition: DBlmapReader.cc:9
DigiContainerIterator< IndexType, DigiType > DigiRangeIterator
std::vector< DigiType >::const_iterator DigiRangeIterator
void swap(MuonDigiCollection &rh)
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
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&lt;IndexType...