CMS 3D CMS Logo

MuonDigiCollection.h
Go to the documentation of this file.
1 #ifndef DataFormats_MuonDigiCollection_h
2 #define DataFormats_MuonDigiCollection_h
3 
12 #include <vector>
13 #include <map>
14 #include <iterator>
15 
29 template <typename IndexType, typename DigiType>
31 public:
32  typedef typename std::vector<DigiType>::const_iterator DigiRangeIterator;
33  typedef std::map<IndexType, std::vector<DigiType> > BaseContainer;
34  typedef typename BaseContainer::const_iterator BaseIterator;
35 
36  typedef std::pair<IndexType, std::pair<DigiRangeIterator, DigiRangeIterator> > value_type;
38  typedef void pointer;
39  typedef typename DigiRangeIterator::difference_type difference_type;
40  typedef typename DigiRangeIterator::iterator_category iterator_category;
41 
44  // implicit copy constructor
45  // implicit assignment operator
46  // implicit destructor
47 
49 
51  ++base_;
52  return *this;
53  }
54 
55  bool operator==(const DigiContainerIterator& x) const { return x.base_ == base_; }
56 
57  bool operator!=(const DigiContainerIterator& x) const { return x.base_ != base_; }
58 
59  value_type operator*(void)const {
60  return std::make_pair(base_->first, std::make_pair(base_->second.begin(), base_->second.end()));
61  }
62 
63 private:
65 };
66 
86 template <typename IndexType, typename DigiType>
88 public:
90 
91  // void swap(MuonDigiCollection<IndexType,DigiType> & rh) { std::swap(data_,rh.data_);}
93 
94  typedef typename std::vector<DigiType>::const_iterator const_iterator;
95  typedef typename std::pair<const_iterator, const_iterator> Range;
96 
98  void insertDigi(const IndexType& index, const DigiType& digi) {
99  std::vector<DigiType>& digis = data_[index];
100  digis.push_back(digi);
101  }
102 
104  void put(Range range, const IndexType& index) {
105  std::vector<DigiType>& digis = data_[index];
106  digis.reserve(digis.size() + (range.second - range.first));
107  std::copy(range.first, range.second, std::back_inserter(digis));
108  }
109 
110 #ifndef CMS_NOCXX11
111  template <typename IRange>
113  void move(IRange range, const IndexType& index) {
114  std::vector<DigiType>& digis = data_[index];
115  digis.reserve(digis.size() + (range.second - range.first));
116  digis.insert(digis.end(), std::make_move_iterator(range.first), std::make_move_iterator(range.second));
117  }
118 #endif
119 
121  Range get(const IndexType& index) const {
122  typename container::const_iterator it = data_.find(index);
123  if (it == data_.end()) {
124  // if data_ is empty there is no other way to get an empty range
125  static const std::vector<DigiType> empty;
126  return std::make_pair(empty.end(), empty.end());
127  }
128  const std::vector<DigiType>& digis = (*it).second;
129  return std::make_pair(digis.begin(), digis.end());
130  }
131 
133 
134  DigiRangeIterator begin() const { return data_.begin(); }
135 
136  DigiRangeIterator end() const { return data_.end(); }
137 
138 private:
139  typedef std::map<IndexType, std::vector<DigiType> > container;
141 
142 }; // MuonDigiCollection
143 
144 template <typename IndexType, typename DigiType>
146  rh.swap(lh);
147 }
148 
149 #endif
MuonDigiCollection::move
void move(IRange range, const IndexType &index)
insert a range of digis for a given DetUnit
Definition: MuonDigiCollection.h:113
DigiContainerIterator::value_type
std::pair< IndexType, std::pair< DigiRangeIterator, DigiRangeIterator > > value_type
Definition: MuonDigiCollection.h:36
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:428
DigiContainerIterator::operator==
bool operator==(const DigiContainerIterator &x) const
Definition: MuonDigiCollection.h:55
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
MuonDigiCollection::data_
container data_
Definition: MuonDigiCollection.h:140
DigiContainerIterator::BaseIterator
BaseContainer::const_iterator BaseIterator
Definition: MuonDigiCollection.h:34
MuonDigiCollection
A container for a generic type of digis indexed by some index, implemented with a map<IndexType,...
Definition: MuonDigiCollection.h:87
DigiContainerIterator::iterator_category
DigiRangeIterator::iterator_category iterator_category
Definition: MuonDigiCollection.h:40
mathSSE::lh
bool int lh
Definition: SIMDVec.h:20
DigiContainerIterator::base_
BaseIterator base_
Definition: MuonDigiCollection.h:64
DigiContainerIterator::DigiContainerIterator
DigiContainerIterator(void)
Definition: MuonDigiCollection.h:42
DDAxes::x
DigiContainerIterator::difference_type
DigiRangeIterator::difference_type difference_type
Definition: MuonDigiCollection.h:39
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
DigiContainerIterator::reference
value_type reference
Definition: MuonDigiCollection.h:37
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
DigiContainerIterator::DigiContainerIterator
DigiContainerIterator(BaseIterator i)
Definition: MuonDigiCollection.h:43
DigiContainerIterator::operator++
DigiContainerIterator & operator++(void)
Definition: MuonDigiCollection.h:50
MuonDigiCollection::end
DigiRangeIterator end() const
Definition: MuonDigiCollection.h:136
DigiContainerIterator::pointer
void pointer
Definition: MuonDigiCollection.h:38
MuonDigiCollection::begin
DigiRangeIterator begin() const
Definition: MuonDigiCollection.h:134
MuonDigiCollection::put
void put(Range range, const IndexType &index)
insert a range of digis for a given DetUnit
Definition: MuonDigiCollection.h:104
DigiContainerIterator::operator++
DigiContainerIterator operator++(int)
Definition: MuonDigiCollection.h:48
MuonDigiCollection::MuonDigiCollection
MuonDigiCollection()
Definition: MuonDigiCollection.h:89
DigiContainerIterator::DigiRangeIterator
std::vector< DigiType >::const_iterator DigiRangeIterator
Definition: MuonDigiCollection.h:32
sistriplas_dqm_sourceclient-live_cfg.DigiType
DigiType
Definition: sistriplas_dqm_sourceclient-live_cfg.py:51
DigiContainerIterator::BaseContainer
std::map< IndexType, std::vector< DigiType > > BaseContainer
Definition: MuonDigiCollection.h:33
DigiContainerIterator::operator*
value_type operator*(void) const
Definition: MuonDigiCollection.h:59
MuonDigiCollection::swap
void swap(MuonDigiCollection &rh)
Definition: MuonDigiCollection.h:92
MuonDigiCollection::get
Range get(const IndexType &index) const
return the digis for a given DetUnit
Definition: MuonDigiCollection.h:121
MuonDigiCollection::DigiRangeIterator
DigiContainerIterator< IndexType, DigiType > DigiRangeIterator
Definition: MuonDigiCollection.h:132
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
swap
void swap(MuonDigiCollection< IndexType, DigiType > &rh, MuonDigiCollection< IndexType, DigiType > &lh)
Definition: MuonDigiCollection.h:145
MuonDigiCollection::insertDigi
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
Definition: MuonDigiCollection.h:98
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
DigiContainerIterator
Definition: MuonDigiCollection.h:30
MuonDigiCollection::container
std::map< IndexType, std::vector< DigiType > > container
Definition: MuonDigiCollection.h:139
DigiContainerIterator::operator!=
bool operator!=(const DigiContainerIterator &x) const
Definition: MuonDigiCollection.h:57