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 
14 #include <vector>
15 #include <map>
16 #include <iterator>
17 
31 template <typename IndexType, typename DigiType>
33  public:
34  typedef typename std::vector<DigiType>::const_iterator DigiRangeIterator;
35  typedef std::map<IndexType, std::vector<DigiType> > BaseContainer;
36  typedef typename BaseContainer::const_iterator BaseIterator;
37 
38  typedef std::pair<IndexType,
39  std::pair<DigiRangeIterator,
42  typedef void pointer;
43  typedef typename DigiRangeIterator::difference_type difference_type;
44  typedef typename DigiRangeIterator::iterator_category iterator_category;
45 
48  // implicit copy constructor
49  // implicit assignment operator
50  // implicit destructor
51 
53  { return DigiContainerIterator (base_++); }
54 
56  { ++base_; return *this; }
57 
59  { return x.base_ == base_; }
60 
62  { return x.base_ != base_; }
63 
64  value_type operator* (void) const
65  {
66  return std::make_pair(base_->first,
67  std::make_pair(base_->second.begin(),
68  base_->second.end()));
69  }
70 
71  private:
73  };
74 
75 
76 
77 
97 template <typename IndexType,
98  typename DigiType>
99 
101 
102 public:
103 
105 
106  typedef typename std::vector<DigiType>::const_iterator const_iterator;
107  typedef typename std::pair<const_iterator,const_iterator> Range;
108 
109 
111  void insertDigi(const IndexType& index, const DigiType& digi){
112  std::vector<DigiType> &digis = data_[index];
113  digis.push_back(digi);
114  }
115 
117  void put(Range range, const IndexType& index){
118  std::vector<DigiType> &digis = data_[index];
119  digis.reserve (digis.size () + (range.second - range.first));
120  std::copy (range.first, range.second, std::back_inserter (digis));
121 
122  }
123 
125  Range get(const IndexType& index) const{
126  typename container::const_iterator it = data_.find(index);
127  if (it==data_.end()) {
128  // if data_ is empty there is no other way to get an empty range
129  static std::vector<DigiType> empty;
130  return std::make_pair(empty.end(),empty.end());
131  }
132  const std::vector<DigiType>& digis = (*it).second;
133  return std::make_pair(digis.begin(),digis.end());
134  }
135 
137 
139  return data_.begin();}
140 
142  return data_.end();}
143 
144 
145 private:
146 
147  typedef std::map<IndexType,std::vector<DigiType> > container;
149 
150 
151 }; // MuonDigiCollection
152 
153 
154 
155 #endif
156 
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...