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>
16 
30 template <typename IndexType, typename DigiType>
32  public:
33  typedef typename std::vector<DigiType>::const_iterator DigiRangeIterator;
34  typedef std::map<IndexType, std::vector<DigiType> > BaseContainer;
35  typedef typename BaseContainer::const_iterator BaseIterator;
36 
37  typedef std::pair<IndexType,
38  std::pair<DigiRangeIterator,
41  typedef void pointer;
42  typedef typename DigiRangeIterator::difference_type difference_type;
43  typedef typename DigiRangeIterator::iterator_category iterator_category;
44 
47  // implicit copy constructor
48  // implicit assignment operator
49  // implicit destructor
50 
52  { return DigiContainerIterator (base_++); }
53 
55  { ++base_; return *this; }
56 
58  { return x.base_ == base_; }
59 
61  { return x.base_ != base_; }
62 
63  value_type operator* (void) const
64  {
65  return std::make_pair(base_->first,
66  std::make_pair(base_->second.begin(),
67  base_->second.end()));
68  }
69 
70  private:
72  };
73 
74 
75 
76 
96 template <typename IndexType,
97  typename DigiType>
98 
100 
101 public:
102 
104 
105  typedef typename std::vector<DigiType>::const_iterator const_iterator;
106  typedef typename std::pair<const_iterator,const_iterator> Range;
107 
108 
110  void insertDigi(const IndexType& index, const DigiType& digi){
111  std::vector<DigiType> &digis = data_[index];
112  digis.push_back(digi);
113  }
114 
116  void put(Range range, const IndexType& index){
117  std::vector<DigiType> &digis = data_[index];
118  digis.reserve (digis.size () + (range.second - range.first));
119  std::copy (range.first, range.second, std::back_inserter (digis));
120 
121  }
122 
124  Range get(const IndexType& index) const{
125  typename container::const_iterator it = data_.find(index);
126  if (it==data_.end()) {
127  // if data_ is empty there is no other way to get an empty range
128  static const std::vector<DigiType> empty;
129  return std::make_pair(empty.end(),empty.end());
130  }
131  const std::vector<DigiType>& digis = (*it).second;
132  return std::make_pair(digis.begin(),digis.end());
133  }
134 
136 
138  return data_.begin();}
139 
141  return data_.end();}
142 
143 
144 private:
145 
146  typedef std::map<IndexType,std::vector<DigiType> > container;
148 
149 
150 }; // MuonDigiCollection
151 
152 
153 
154 #endif
155 
int i
Definition: DBlmapReader.cc:9
DigiContainerIterator< IndexType, DigiType > DigiRangeIterator
std::vector< DigiType >::const_iterator DigiRangeIterator
std::map< IndexType, std::vector< DigiType > > BaseContainer
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
value_type operator*(void) const
DigiRangeIterator::iterator_category iterator_category
DigiRangeIterator::difference_type difference_type
std::map< IndexType, std::vector< DigiType > > container
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)
Definition: DDAxes.h:10
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...