|
|
Go to the documentation of this file. 1 #ifndef DataFormats_Common_DetSetVectorNew_h
2 #define DataFormats_Common_DetSetVectorNew_h
8 #include <boost/iterator/transform_iterator.hpp>
48 namespace dstvdetails {
75 assert(rh.m_filling ==
false);
82 assert(rh.m_filling ==
false);
122 return offset.compare_exchange_strong(expected, -2);
134 bool expected =
false;
135 if (!
m_filling.compare_exchange_strong(expected,
true))
154 template <
typename T>
155 class DetSetVector :
private dstvdetails::DetSetVectorTrans {
171 typedef typename IdContainer::iterator
IdIter;
172 typedef typename std::vector<data_type>::iterator
DataIter;
198 typedef std::pair<const_iterator, const_iterator>
Range;
233 m_v.m_filling =
false;
242 if (
m_v.onDemand() &&
m_v.m_data.size() ==
m_v.m_data.capacity())
247 if (
m_v.onDemand() &&
m_v.m_data.size() +
s >
m_v.m_data.capacity())
262 m_v.m_dataSize =
m_v.m_data.size();
276 m_v.m_data.push_back(
d);
291 friend class ::TestDetSet;
316 m_v.m_filling =
false;
321 bool expected =
false;
322 while (!
m_v.m_filling.compare_exchange_weak(expected,
true)) {
324 nanosleep(
nullptr,
nullptr);
327 if (
m_v.onDemand() &&
full()) {
328 m_v.m_filling =
false;
335 m_v.m_dataSize =
m_v.m_data.size();
337 m_v.m_filling =
false;
366 friend class ::TestDetSet;
384 bool expected =
false;
385 while (!iContainer.
m_filling.compare_exchange_weak(expected,
true, std::memory_order_acq_rel)) {
387 nanosleep(
nullptr,
nullptr);
430 m_ids.reserve(isize);
436 m_ids.shrink_to_fit();
440 void resize(
size_t isize,
size_t dsize) {
475 if ((*p).isValid() && (*p).size > 0 &&
m_data.size() == (*p).offset + (*p).size) {
476 m_data.resize((*p).offset);
486 if (
p !=
m_ids.end() && !(it < *
p))
498 return p !=
m_ids.end() && (*p).isValid();
513 return DetSet(*
this, *
p,
true);
525 std::pair<const_IdIter, const_IdIter>
p = std::equal_range(
m_ids.begin(),
m_ids.end(),
Item(
i));
526 return (
p.first !=
p.second) ?
p.first :
m_ids.end();
540 template <
typename CMP>
543 std::pair<const_IdIter, const_IdIter>
p = std::equal_range(
m_ids.begin(),
m_ids.end(),
i,
cmp);
578 friend class ::TestDetSet;
593 template <
typename T>
601 template <
typename T>
603 const std::vector<det_id_type>& iDets,
608 m_ids.reserve(iDets.size());
610 for (std::vector<det_id_type>::const_iterator itDetId = iDets.begin(), itDetIdEnd = iDets.end();
611 itDetId != itDetIdEnd;
613 assert(sanityCheck < *itDetId &&
"vector of det_id_type was not ordered");
614 sanityCheck = *itDetId;
615 m_ids.push_back(*itDetId);
619 template <
typename T>
626 if (
item.initialize()) {
630 static_cast<Getter*>(m_getter.get())->
fill(
ff);
636 template <
typename T>
641 while (
item.initializing())
642 nanosleep(
nullptr,
nullptr);
643 m_data = &icont.data();
645 m_offset =
item.offset;
651 #include <type_traits>
656 namespace refhelper {
657 template <
typename T>
665 namespace refhelper {
666 template <
typename T>
673 return &(iContainer[iIndex]);
677 template <
typename T>
687 template <
class HandleT>
690 const HandleT& iHandle,
typename HandleT::element_type::value_type::const_iterator itIter) {
691 static_assert(std::is_same<
typename HandleT::element_type,
693 "Handle and DetSetVector do not have compatible types.");
694 auto index = itIter - &iHandle->data().front();
696 iHandle.id(), &(*itIter),
index);
703 template <
typename T>
710 return iElement - &(iContainer->
data().front());
718 template <
typename T>
724 template <
typename T,
typename Selector>
727 unsigned int& iIndex,
731 for (
auto iter = detset.
begin(),
end = detset.
end(); iter !=
end; ++iter, ++iIndex) {
734 if (detset.
begin() != detset.
end()) {
void swap(IdContainer &iic, DataContainer &idc)
void errorIdExists(det_id_type iid)
bool initializing() const
Functor that operates on <T>
void resize(size_t isize, size_t dsize)
DetSetVector< T >::id_type key_type
void push_back(data_type const &d)
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
bool exists(id_type i) const
id_type id(size_t cell) const
DetSetVector< T >::Item const & m_item
FastFiller(DetSetVector< T > &iv, typename DetSetVector< T >::Item &it, bool isaveEmpty=false)
DetSetVector< T >::size_type size_type
DetSet insert(id_type iid, data_type const *idata, size_type isize)
DetSetVector< T >::size_type size_type
std::pair< IdIter, DataIter > IterPair
void reserve(size_t isize, size_t dsize)
void swap(Association< C > &lhs, Association< C > &rhs)
std::vector< Item > IdContainer
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
void update(Item const &item) const
std::vector< data_type >::iterator DataIter
void fillCollectionForThinning(edmNew::DetSet< T > const &detset, Selector &selector, unsigned int &iIndex, edmNew::DetSetVector< T > &output, edm::ThinnedAssociation &association)
DetSetVectorTrans(const DetSetVectorTrans &rh)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
dslv::LazyGetter< T > Getter
static unsigned int indexFor(const value_type *iElement, const edmNew::DetSetVector< T > *iContainer)
const_iterator begin(bool update=false) const
void fillCollectionForThinning(Item const &item, Selector &selector, unsigned int iIndex, Collection &output, ThinnedAssociation &association)
DetSet insert(id_type iid, size_type isize)
DetSetVector< T >::id_type id_type
void throwCapacityExausted()
data_type & operator[](size_type i)
void push_back(data_type const &d)
Item const & item(size_t cell) const
TSFastFiller(DetSetVector< T > &iv, id_type id)
static DetSetVector< T >::Item & dummy()
IterHelp(DetSetVector< T > const &iv, bool iup)
void swap(DetSetVectorTrans &rh)
DetSetVector< T >::data_type value_type
IdContainer const & ids() const
DetSetVector< T > const * m_v
IdContainer::const_iterator const_IdIter
edmNew::DetSet< T > DetSet
Item & operator=(Item &&rh) noexcept
void push_back(data_type &&d)
const_iterator find(id_type i, bool update=false) const
void checkCapacityExausted() const
FindSetForNewDetSetVector< T > value
edm::refhelper::FindForNewDetSetVector< data_type > RefFinder
std::atomic< int > offset
DetSetVector< T >::id_type key_type
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
result_type operator()(first_argument_type iContainer, second_argument_type iIndex)
DetSetVectorTrans & operator=(DetSetVectorTrans &&rh)
std::pair< const_IdIter, const_DataIter > const_IterPair
DetSetVector< T >::data_type value_type
static size_t size(const edmNew::DetSetVector< T > *iContainer)
#define CMS_CLASS_VERSION(_version_)
void throw_range(det_id_type iid)
unsigned int second_argument_type
Item & operator=(Item const &rh) noexcept
size_type dataSize() const
unsigned int second_argument_type
data_type operator()(size_t cell, size_t frame) const
Range equal_range(id_type i, CMP cmp, bool update=false) const
bool operator<(Item const &rh) const
edmNew::DetSetVector< T >::FindForDetSetVector value
void reserve(size_type s)
void checkCapacityExausted(size_type s) const
Item & push_back(id_type iid)
CapacityExaustedException()
DetSetVector< T >::id_type id_type
DetSetVector< T >::Item & m_item
DetSetVectorTrans & operator=(const DetSetVectorTrans &)=delete
std::vector< data_type > DataContainer
std::pair< const_iterator, const_iterator > Range
void swap(DetSetVector &rh)
std::vector< data_type >::const_iterator const_DataIter
DetSetVectorTrans(DetSetVectorTrans &&rh)
std::vector< Trans::Item > m_ids
void push_back(data_type &&d)
std::atomic< bool > m_filling
DetSetVector(int isubdet=0)
IdContainer::iterator IdIter
FastFiller(DetSetVector< T > &iv, id_type id, bool isaveEmpty=false)
void set(Container const &icont, typename Container::Item const &item, bool update=true)
bool uninitialized() const
void pop_back(id_type iid)
DetSetVector< T > const & m_v
data_type & operator[](size_type i)
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
data_type const * data(size_t cell) const
const_IdIter findItem(id_type i) const
Item(Item const &rh) noexcept
typename edmNew::DetSetVector< T >::data_type type
const_iterator end(bool update=false) const
TSFastFiller(DetSetVector< T > const &iv, typename DetSetVector< T >::Item const &it)
std::shared_ptr< void > m_getter
static DetSetVector< T >::Item const & dummy()
DetSet operator[](id_type i) const
void reserve(size_type s)
Item & addItem(id_type iid, size_type isize)
size_type detsetSize(size_t cell) const
dstvdetails::DetSetVectorTrans Trans
bool isValid(id_type i) const
#define CMS_THREAD_GUARD(_var_)
DataContainer const & data() const
Item(id_type i=0, int io=-1, size_type is=0)
result_type & operator()(Item const &item) const
std::atomic< size_type > m_dataSize
DetSetVector & operator=(const DetSetVector &)=delete
Namespace of DDCMS conversion namespace.