CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > Class Template Reference

#include <AssociationVector.h>

Inheritance diagram for edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >:
pat::PATTauDiscriminator reco::JetFlavourInfoMatchingCollection reco::JetFlavourMatchingCollection reco::JetMatchedPartonsCollection reco::JetPiZeroAssociation reco::PFJetChargedHadronAssociation reco::PFTauDiscriminator reco::PFTauDiscriminatorByIsolation

Public Types

typedef KeyRefProd::product_type CKey
 
typedef transient_vector_type::const_iterator const_iterator
 
typedef value_type const & const_reference
 
typedef KeyRef::value_type key_type
 
typedef KeyRefProd refprod_type
 
typedef SizeType size_type
 
typedef std::vector< value_typetransient_vector_type
 
typedef std::pair< KeyRef, typename CVal::value_type > value_type
 

Public Member Functions

 AssociationVector ()
 
 AssociationVector (KeyRefProd const &ref, CKey const *=0)
 
 AssociationVector (AssociationVector const &)
 
const_iterator begin () const
 
void clear ()
 
bool empty () const
 
const_iterator end () const
 
void fillView (ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const
 
KeyRef key (size_type i) const
 
KeyRefProd const & keyProduct () const
 
selfoperator= (self const &)
 
const_reference operator[] (size_type n) const
 
CVal::const_reference operator[] (KeyRef const &k) const
 
CVal::reference operator[] (KeyRef const &k)
 
template<typename K >
CVal::const_reference operator[] (edm::Ptr< K > const &k) const
 
template<typename K >
CVal::const_reference operator[] (edm::RefToBase< K > const &k) const
 
void setValue (size_type i, typename CVal::value_type const &val)
 
size_type size () const
 
void swap (self &other)
 
CVal::value_type const value (size_type i) const
 
 ~AssociationVector ()
 

Static Public Member Functions

static short Class_Version ()
 

Private Types

enum  CacheState { kUnset, kFilling, kSet }
 
typedef AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > self
 

Private Member Functions

void fixup () const
 
transient_vector_type const & transientVector () const
 

Private Attributes

CVal data_
 
KeyRefProd ref_
 
std::atomic< transient_vector_type * > transientVector_
 

Detailed Description

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
class edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >

Definition at line 67 of file AssociationVector.h.

Member Typedef Documentation

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef KeyRefProd::product_type edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::CKey

Definition at line 74 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef transient_vector_type::const_iterator edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::const_iterator

Definition at line 106 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef value_type const& edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::const_reference

Definition at line 79 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef KeyRef::value_type edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::key_type

Definition at line 76 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef KeyRefProd edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::refprod_type

Definition at line 73 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper> edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::self
private

Definition at line 69 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef SizeType edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size_type

Definition at line 75 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef std::vector<value_type> edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transient_vector_type

Definition at line 78 of file AssociationVector.h.

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
typedef std::pair<KeyRef, typename CVal::value_type> edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::value_type

Definition at line 77 of file AssociationVector.h.

Member Enumeration Documentation

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
enum edm::AssociationVector::CacheState
private

Constructor & Destructor Documentation

template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::AssociationVector ( )
inline

Definition at line 133 of file AssociationVector.h.

134  : data_(), ref_(), transientVector_(nullptr) {}
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::AssociationVector ( KeyRefProd const &  ref,
CKey const *  coll = 0 
)
inline

Definition at line 137 of file AssociationVector.h.

139  : data_(coll == nullptr ? ref->size() : coll->size()),
140  ref_(ref),
141  transientVector_(new transient_vector_type(coll == nullptr ? ref->size() : coll->size())) {}
std::vector< value_type > transient_vector_type
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::AssociationVector ( AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &  o)
inline

Definition at line 144 of file AssociationVector.h.

References OrderedSet::t, and edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_.

146  : data_(o.data_), ref_(o.ref_), transientVector_() {
147  auto t = o.transientVector_.load(std::memory_order_acquire);
148  if (t) {
149  transientVector_.store(new transient_vector_type(*t), std::memory_order_release);
150  }
151  }
std::vector< value_type > transient_vector_type
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::~AssociationVector ( )
inline

Definition at line 154 of file AssociationVector.h.

References edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_.

154  {
155  delete transientVector_.load(std::memory_order_acquire);
156  }
std::atomic< transient_vector_type * > transientVector_

Member Function Documentation

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
const_iterator edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::begin ( void  ) const
inline
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
static short edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::Class_Version ( )
inlinestatic
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
void edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::clear ( void  )
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
bool edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::empty ( ) const
inline
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
const_iterator edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::end ( void  ) const
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
void edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::fillView ( ProductID const &  id,
std::vector< void const * > &  pointers,
FillViewHelperVector helpers 
) const

Definition at line 269 of file AssociationVector.h.

References edm::detail::reallyFillView().

Referenced by edm::fillView().

270  {
271  detail::reallyFillView(*this, id, pointers, helpers);
272  // pointers.reserve(this->size());
273  // for(typename CVal::const_iterator i=data_.begin(), e=data_.end(); i!=e; ++i)
274  // pointers.push_back(&(*i));
275  // // helpers is not yet filled in.
276  // //Exception::throwThis(errors::UnimplementedFeature, "AssociationVector<T>::fillView(...)");
277  }
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
Definition: FillView.h:25
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
void edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::fixup ( ) const
inlineprivate

Definition at line 255 of file AssociationVector.h.

References edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_, mps_fire::i, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size(), and edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_.

255  {
256  if (nullptr == transientVector_.load(std::memory_order_acquire)) {
257  std::unique_ptr<transient_vector_type> newT{new transient_vector_type(size())};
258  for (size_type i = 0; i != size(); ++i) {
259  (*newT)[i] = std::make_pair(KeyRef(ref_, i), data_[i]);
260  }
261  transient_vector_type* expected = nullptr;
262  if (transientVector_.compare_exchange_strong(expected, newT.get())) {
263  newT.release();
264  }
265  }
266  }
std::vector< value_type > transient_vector_type
std::atomic< transient_vector_type * > transientVector_
size_type size() const
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
KeyRef edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::key ( size_type  i) const
inline

Definition at line 101 of file AssociationVector.h.

Referenced by TagAndProbeBtagTriggerMonitor::analyze().

101 { return KeyRef(ref_, i); }
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
KeyRefProd const& edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::keyProduct ( ) const
inline

Definition at line 100 of file AssociationVector.h.

Referenced by JetChargeProducer::produce(), and JetSignalVertexCompatibility::produce().

100 { return ref_; }
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > & edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator= ( self const &  o)
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::const_reference edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[] ( size_type  n) const
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
CVal::const_reference edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[] ( KeyRef const &  k) const
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
CVal::reference edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[] ( KeyRef const &  k)
inline

Definition at line 193 of file AssociationVector.h.

References edm::checkForWrongProduct(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_, timingPdfMaker::get, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_, OrderedSet::t, and edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_.

194  {
195  KeyRef keyRef = KeyReferenceHelper::get(k, ref_.id());
196  auto t = transientVector_.exchange(nullptr, std::memory_order_acq_rel);
197  delete t;
198  checkForWrongProduct(keyRef.id(), ref_.id());
199  return data_[keyRef.key()];
200  }
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
template<typename K >
CVal::const_reference edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[] ( edm::Ptr< K > const &  k) const
inline

Definition at line 175 of file AssociationVector.h.

References edm::checkForWrongProduct(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_, edm::Ptr< T >::id(), edm::Ptr< T >::key(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_, and relativeConstraints::value.

175  {
177  "edm::Ptr's key type is not a base class of AssociationVector's item type");
178  checkForWrongProduct(k.id(), ref_.id());
179  return data_[k.key()];
180  }
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
key_type key() const
Definition: Ptr.h:163
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
template<typename K >
CVal::const_reference edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[] ( edm::RefToBase< K > const &  k) const

Definition at line 184 of file AssociationVector.h.

References edm::checkForWrongProduct(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_, edm::RefToBase< T >::id(), edm::RefToBase< T >::key(), edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_, and relativeConstraints::value.

185  {
187  "edm::RefToBase's key type is not a base class of AssociationVector's item type");
188  checkForWrongProduct(k.id(), ref_.id());
189  return data_[k.key()];
190  }
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
ProductID id() const
Definition: RefToBase.h:214
size_t key() const
Definition: RefToBase.h:219
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
void edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::setValue ( size_type  i,
typename CVal::value_type const &  val 
)
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size_type edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::size ( void  ) const
inline
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
void edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::swap ( self other)
inline

Definition at line 246 of file AssociationVector.h.

References edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_, trackingPlots::other, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_, and edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_.

Referenced by edm::swap().

246  {
247  data_.swap(other.data_);
248  other.transientVector_.store(
249  transientVector_.exchange(other.transientVector_.load(std::memory_order_acquire), std::memory_order_acq_rel),
250  std::memory_order_release);
251  ref_.swap(other.ref_);
252  }
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd , typename CVal , typename KeyRef , typename SizeType , typename KeyReferenceHelper >
AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transient_vector_type const & edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector ( ) const
inlineprivate

Definition at line 127 of file AssociationVector.h.

Referenced by edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::operator[]().

127  {
128  fixup();
129  return *(transientVector_.load(std::memory_order_acquire));
130  }
std::atomic< transient_vector_type * > transientVector_
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
CVal::value_type const edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::value ( size_type  i) const
inline

Member Data Documentation

template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
CVal edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::data_
private
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
KeyRefProd edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::ref_
private
template<typename KeyRefProd, typename CVal, typename KeyRef = typename helper::RefFromRefProdTrait<KeyRefProd>::ref_type, typename SizeType = unsigned int, typename KeyReferenceHelper = typename helper::AssociationKeyReferenceTrait<KeyRef>::type>
std::atomic<transient_vector_type*> edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transientVector_
mutableprivate