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;
338 this->begin(), this->
end(), std::back_inserter(
result), std::bind(&
DetSet<T>::id, std::placeholders::_1));
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();
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);
void _throw_range(det_id_type i)
detset const & const_reference
iterator find(det_id_type id)
DetSetVector & operator=(DetSetVector const &other)
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