1 #ifndef DataFormats_Common_DetSetRefVector_h 2 #define DataFormats_Common_DetSetRefVector_h 31 #include "boost/concept_check.hpp" 32 #include "boost/iterator/indirect_iterator.hpp" 62 "DetSetRefVector::operator[] called with index not in collection;\nindex value: ", i);
69 template<
typename T,
typename C >
77 return &(*(iContainer.find(iIndex)));
83 template <
typename T,
typename C=DetSetVector<T> >
87 return iRef.
key() < iId;
90 return iId < iRef.
key();
94 template <
typename T,
typename C=DetSetVector<T> >
99 BOOST_CLASS_REQUIRE(
T,
boost, LessThanComparableConcept);
110 typedef boost::indirect_iterator<typename collection_type::const_iterator>
const_iterator;
123 sets_.reserve(iDets.size());
125 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
126 itDetIdEnd = iDets.end();
127 itDetId != itDetIdEnd;
129 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
130 sanityCheck = *itDetId;
132 sets_.push_back(ref_type(iHandle, *itDetId,
false));
137 sets_.reserve(iDets.size());
139 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
140 itDetIdEnd = iDets.end();
141 itDetId != itDetIdEnd;
143 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
144 sanityCheck = *itDetId;
146 sets_.push_back(ref_type(iHandle, *itDetId,
false));
151 sets_.reserve(iDets.size());
153 for(std::vector<det_id_type>::const_iterator itDetId = iDets.begin(),
154 itDetIdEnd = iDets.end();
155 itDetId != itDetIdEnd;
157 assert(sanityCheck <= *itDetId &&
"vector of det_id_type was not ordered");
158 sanityCheck = *itDetId;
160 sets_.push_back(ref_type(iHandle, *itDetId,
false));
172 size_type
size()
const;
188 const_iterator
begin()
const;
191 const_iterator
end()
const;
201 collection_type sets_;
209 sets_.swap(other.sets_);
212 template <
typename T,
typename C>
221 template <
typename T,
typename C>
226 return sets_.empty();
229 template <
typename T,
typename C>
237 template <
typename T,
typename C>
245 std::pair<typename collection_type::const_iterator,typename collection_type::const_iterator>
p =
247 if (p.first == p.second)
return sets_.end();
254 template <
typename T,
typename C>
261 const_iterator it = this->
find(i);
266 template <
typename T,
typename C>
271 return sets_.begin();
274 template <
typename T,
typename C>
283 template <
typename T,
typename C>
292 namespace refhelper {
293 template<
typename T,
typename C>
301 return &(*(iContainer.
find(iIndex.first)->data.begin()+iIndex.second));
305 template<
typename T,
typename C>
313 template<
class HandleT>
317 typename HandleT::element_type::value_type::const_iterator itIter) {
318 typedef typename HandleT::element_type Vec;
320 typename Vec::const_iterator itFound = iHandle->find(iDetID);
321 index += (itIter- itFound->data.begin());
325 template<
class HandleT>
329 typename HandleT::element_type::value_type::iterator itIter) {
330 typedef typename HandleT::element_type Vec;
331 typename Vec::detset::const_iterator itIter2 = itIter;
DetSetRefVector & operator=(DetSetRefVector const &rhs)
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefToDetSetRefVector(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::const_iterator itIter)
DetSetRefVector(const OrphanHandle< C > &iHandle, const std::vector< det_id_type > &iDets)
key_type key() const
Accessor for product key.
#define CMS_CLASS_VERSION(_version_)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const_iterator find(det_id_type id) const
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
DetSetRefVector(const Handle< C > &iHandle, const std::vector< det_id_type > &iDets)
void swap(Association< C > &lhs, Association< C > &rhs)
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
void _throw_range(det_id_type i)
std::vector< ref_type > collection_type
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
detset const & const_reference
const_iterator begin() const
Return an iterator to the first DetSet.
bool operator()(const ref_type &iRef, det_id_type iId)
bool empty() const
Return true if we contain no DetSets.
T operator[](int i) const
def template(fileName, svg, replaceme="REPLACEME")
const_reference operator[](det_id_type i) const
bool operator()(det_id_type iId, const ref_type &iRef)
std::pair< det_id_type, typename DetSet< T >::collection_type::size_type > second_argument_type
collection_type::size_type size_type
C const & first_argument_type
Ref< C, DetSet< T >, refhelper::FindDetSetForDetSetVector< T, C > > ref_type
size_type size() const
Return the number of contained DetSets.
void swap(DetSetRefVector &other)
edm::det_id_type const second_argument_type
FindForDetSetRefVector< T, C > value
result_type operator()(first_argument_type iContainer, second_argument_type iIndex) const
boost::indirect_iterator< typename collection_type::const_iterator > const_iterator
const_iterator end() const
Return the off-the-end iterator.
DetSetRefVector(const TestHandle< C > &iHandle, const std::vector< det_id_type > &iDets)