|
|
Go to the documentation of this file. 1 #ifndef DataFormats_Common_DetSetVector_h
2 #define DataFormats_Common_DetSetVector_h
42 #include <type_traits>
43 #include "boost/concept_check.hpp"
86 class DetSetVector :
public std::conditional_t<std::is_base_of<edm::DoNotSortUponInsertion, T>::value,
87 edm::DoNotSortUponInsertion,
101 typedef typename collection_type::iterator
iterator;
206 _sets.swap(
other._sets);
207 bool tmp = _alreadySorted;
208 _alreadySorted =
other._alreadySorted;
213 inline DetSetVector<T>& DetSetVector<T>::operator=(DetSetVector<T>
const&
other) {
221 _alreadySorted =
false;
237 std::pair<iterator, iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
241 if (
p.first !=
p.second)
246 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
247 return *(_sets.emplace(
p.first,
id));
249 return *(_sets.insert(
p.first,
detset(
id)));
255 return _sets.empty();
265 _alreadySorted =
false;
266 std::pair<iterator, iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
267 if (
p.first ==
p.second)
283 std::pair<const_iterator, const_iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
284 if (
p.first ==
p.second)
294 _alreadySorted =
false;
298 if (it == this->
end())
308 if (it == this->
end())
315 _alreadySorted =
false;
316 return _sets.begin();
321 return _sets.begin();
326 _alreadySorted =
false;
343 _sets.shrink_to_fit();
346 typename collection_type::iterator
i = _sets.begin();
347 typename collection_type::iterator
e = _sets.end();
349 for (;
i !=
e; ++
i) {
350 i->data.shrink_to_fit();
352 std::sort(
i->data.begin(),
i->data.end());
358 std::sort(_sets.begin(), _sets.end());
363 std::vector<void const*>& pointers,
375 std::vector<void const*>& pointers,
396 namespace refhelper {
397 template <
typename T>
405 return &(*(iContainer.
find(iIndex.first)->data.begin() + iIndex.second));
409 template <
typename T>
417 template <
class HandleT>
419 const HandleT& iHandle,
det_id_type iDetID,
typename HandleT::element_type::value_type::const_iterator itIter) {
420 typedef typename HandleT::element_type Vec;
422 typename Vec::const_iterator itFound = iHandle->find(iDetID);
423 if (itFound == iHandle->end()) {
425 "an edm::Ref to an edm::DetSetVector was given a DetId, ",
427 ", that is not in the DetSetVector");
429 index += (itIter - itFound->data.begin());
430 if (
index >= itFound->data.size()) {
432 "an edm::Ref to a edm::DetSetVector is being made with an interator that is not part of the "
433 "edm::DetSet itself");
436 iHandle, std::make_pair(iDetID,
index));
439 template <
class HandleT>
440 inline Ref<typename HandleT::element_type, typename HandleT::element_type::value_type::value_type>
443 typename HandleT::element_type::value_type::iterator itIter) {
444 typedef typename HandleT::element_type Vec;
445 typename Vec::detset::const_iterator itIter2 = itIter;
446 return makeRefTo(iHandle, iDetID, itIter2);
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
detset const & const_reference
void _sort()
Sort the DetSet in order of increasing DetId.
static const std::string input
edm::BoolCache _alreadySorted
BOOST_CLASS_REQUIRE(T, boost, LessThanComparableConcept)
void fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const
iterator end()
Return the off-the-end iterator.
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
FindForDetSetVector< T > value
void _throw_range(det_id_type i)
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::const_iterator itIter)
iterator begin()
Return an iterator to the first DetSet.
void swap(DetSetVector< T > &a, DetSetVector< T > &b)
DetSetVector & operator=(DetSetVector const &other)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void swap(DetSetVector &other)
bool empty() const
Return true if we contain no DetSets.
void insert(detset const &s)
Insert the given DetSet.
collection_type::iterator iterator
#define CMS_CLASS_VERSION(_version_)
size_type size() const
Return the number of contained DetSets.
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
reference operator[](det_id_type i)
void fillView(DetSetVector< T > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
collection_type::const_iterator const_iterator
iterator find(det_id_type id)
def template(fileName, svg, replaceme="REPLACEME")
std::vector< detset > collection_type
collection_type::size_type size_type
std::pair< det_id_type, typename DetSet< T >::collection_type::size_type > second_argument_type
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
DetSetVector()
Create an empty DetSetVector.
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
void getIds(std::vector< det_id_type > &result) const
reference find_or_insert(det_id_type id)
Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefToDetSetVector(const HandleT &iHandle, det_id_type iDetID, typename HandleT::element_type::value_type::iterator itIter)
T operator[](int i) const