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;
204 _sets.swap(
other._sets);
205 bool tmp = _alreadySorted;
206 _alreadySorted =
other._alreadySorted;
212 _alreadySorted =
false;
228 std::pair<iterator, iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
232 if (
p.first !=
p.second)
237 #if defined(__GXX_EXPERIMENTAL_CXX0X__) 238 return *(_sets.emplace(
p.first,
id));
240 return *(_sets.insert(
p.first,
detset(
id)));
246 return _sets.empty();
256 _alreadySorted =
false;
257 std::pair<iterator, iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
258 if (
p.first ==
p.second)
274 std::pair<const_iterator, const_iterator>
p = std::equal_range(_sets.begin(), _sets.end(),
id);
275 if (
p.first ==
p.second)
285 _alreadySorted =
false;
289 if (
it == this->
end())
299 if (
it == this->
end())
306 _alreadySorted =
false;
307 return _sets.
begin();
312 return _sets.
begin();
317 _alreadySorted =
false;
329 this->begin(), this->
end(), std::back_inserter(
result), std::bind(&
DetSet<T>::id, std::placeholders::_1));
334 _sets.shrink_to_fit();
337 typename collection_type::iterator
i = _sets.begin();
338 typename collection_type::iterator
e = _sets.end();
340 for (;
i !=
e; ++
i) {
341 i->data.shrink_to_fit();
354 std::vector<void const*>& pointers,
366 std::vector<void const*>& pointers,
387 namespace refhelper {
388 template <
typename T>
396 return &(*(iContainer.
find(iIndex.first)->data.begin() + iIndex.second));
400 template <
typename T>
408 template <
class HandleT>
410 const HandleT& iHandle,
det_id_type iDetID,
typename HandleT::element_type::value_type::const_iterator itIter) {
411 typedef typename HandleT::element_type
Vec;
413 typename Vec::const_iterator itFound = iHandle->find(iDetID);
414 if (itFound == iHandle->end()) {
416 "an edm::Ref to an edm::DetSetVector was given a DetId, ",
418 ", that is not in the DetSetVector");
420 index += (itIter - itFound->data.begin());
421 if (
index >= itFound->data.size()) {
423 "an edm::Ref to a edm::DetSetVector is being made with an interator that is not part of the " 424 "edm::DetSet itself");
427 iHandle, std::make_pair(iDetID,
index));
430 template <
class HandleT>
431 inline Ref<typename HandleT::element_type, typename HandleT::element_type::value_type::value_type>
434 typename HandleT::element_type::value_type::iterator itIter) {
435 typedef typename HandleT::element_type
Vec;
436 typename Vec::detset::const_iterator itIter2 = itIter;
437 return makeRefTo(iHandle, iDetID, itIter2);
void _throw_range(det_id_type i)
detset const & const_reference
iterator find(det_id_type id)
void swap(DetSetVector< T > &a, DetSetVector< T > &b)
void getIds(std::vector< det_id_type > &result) const
bool empty() const
Return true if we contain no DetSets.
#define CMS_CLASS_VERSION(_version_)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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)
void swap(DetSetVector &other)
std::pair< det_id_type, typename DetSet< T >::collection_type::size_type > second_argument_type
static std::string const input
reference find_or_insert(det_id_type id)
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
FindForDetSetVector< T > value
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)
size_type size() const
Return the number of contained DetSets.
def template(fileName, svg, replaceme="REPLACEME")
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
std::vector< detset > collection_type
collection_type::iterator iterator
iterator end()
Return the off-the-end iterator.
DetSetVector()
Create an empty DetSetVector.
edm::BoolCache _alreadySorted
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
void _sort()
Sort the DetSet in order of increasing DetId.
void fillView(DetSetVector< T > const &obj, ProductID const &id, std::vector< void const *> &pointers, FillViewHelperVector &helpers)
BOOST_CLASS_REQUIRE(T, boost, LessThanComparableConcept)
alpaka::Vec< TDim, Idx > Vec
void insert(detset const &s)
Insert the given DetSet.
void fillView(ProductID const &id, std::vector< void const *> &pointers, FillViewHelperVector &helpers) const
reference operator[](det_id_type i)
collection_type::size_type size_type
iterator begin()
Return an iterator to the first DetSet.
collection_type::const_iterator const_iterator
T operator[](int i) const
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const *> &ptrs, FillViewHelperVector &helpers)
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector