CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | 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 >:
reco::CaloTauDiscriminator reco::CaloTauDiscriminatorByIsolation 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, helper_vector &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)
 
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 ()
 

Private Types

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

Private Member Functions

 BOOST_STATIC_ASSERT ((boost::is_convertible< SizeType, typename CVal::size_type >::value))
 
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 62 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 68 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 97 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 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 KeyRef::value_type edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::key_type

Definition at line 70 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 67 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 64 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 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 std::vector<value_type> edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::transient_vector_type

Definition at line 72 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 71 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 128 of file AssociationVector.h.

128  :
129  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 132 of file AssociationVector.h.

133  :
134  data_(coll == 0 ? ref->size() : coll->size()), ref_(ref),
135  transientVector_( new transient_vector_type(coll == 0 ? 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 140 of file AssociationVector.h.

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

140  :
141  data_(o.data_), ref_(o.ref_), transientVector_() {
142  auto t = o.transientVector_.load(std::memory_order_acquire);
143  if(t) {
144  transientVector_.store( new transient_vector_type(*t), std::memory_order_release);
145  }
146  }
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 151 of file AssociationVector.h.

151  {
152  delete transientVector_.load(std::memory_order_acquire);
153  }
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

Definition at line 99 of file AssociationVector.h.

Referenced by BTagPerformanceAnalyzerOnData::analyze(), and BTagPerformanceAnalyzerMC::analyze().

99 { return transientVector().begin(); }
transient_vector_type const & transientVector() 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>
edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::BOOST_STATIC_ASSERT ( (boost::is_convertible< SizeType, typename CVal::size_type >::value )
private
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,
helper_vector helpers 
) const

Definition at line 250 of file AssociationVector.h.

References edm::detail::reallyFillView().

Referenced by edm::fillView().

253  {
254  detail::reallyFillView(*this, id, pointers, helpers);
255 // pointers.reserve(this->size());
256 // for(typename CVal::const_iterator i=data_.begin(), e=data_.end(); i!=e; ++i)
257 // pointers.push_back(&(*i));
258 // // helpers is not yet filled in.
259 // //Exception::throwThis(errors::UnimplementedFeature, "AssociationVector<T>::fillView(...)");
260  }
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, helper_vector &helpers)
Definition: FillView.h:49
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 235 of file AssociationVector.h.

References i, and findQualityFiles::size.

235  {
236  if (nullptr == transientVector_.load(std::memory_order_acquire)) {
237  std::unique_ptr<transient_vector_type> newT {new transient_vector_type(size()) };
238  for(size_type i = 0; i != size(); ++i) {
239  (*newT)[ i ] = std::make_pair(KeyRef(ref_, i), data_[ i ]);
240  }
241  transient_vector_type* expected = nullptr;
242  if(transientVector_.compare_exchange_strong(expected, newT.get()) ) {
243  newT.release();
244  }
245  }
246  }
int i
Definition: DBlmapReader.cc:9
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 90 of file AssociationVector.h.

90 { return KeyRef(ref_, i); }
int i
Definition: DBlmapReader.cc:9
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 89 of file AssociationVector.h.

Referenced by reco::tau::RecoTauDiscriminantFromDiscriminator::operator()().

89 { 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

Definition at line 186 of file AssociationVector.h.

References python.connectstrParser::o, and edmStreamStallGrapher::t.

186  {
187  if(this == &o) {
188  return *this;
189  }
190  data_ = o.data_;
191  ref_ = o.ref_;
192  auto t =transientVector_.exchange(nullptr, std::memory_order_acq_rel);
193  delete t;
194  return *this;
195  }
std::atomic< transient_vector_type * > transientVector_
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

Definition at line 158 of file AssociationVector.h.

References n.

158  {
159  return transientVector()[ n ];
160  }
transient_vector_type const & transientVector() const
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

Definition at line 164 of file AssociationVector.h.

References edm::checkForWrongProduct(), and reco::get().

164  {
165  KeyRef keyRef = KeyReferenceHelper::get(k, ref_.id());
166  checkForWrongProduct(keyRef.id(), ref_.id());
167  return data_[ keyRef.key() ];
168  }
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
int k[5][pyjets_maxn]
T get(const Candidate &c)
Definition: component.h:55
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 174 of file AssociationVector.h.

References edm::checkForWrongProduct(), reco::get(), and edmStreamStallGrapher::t.

174  {
175  KeyRef keyRef = KeyReferenceHelper::get(k, ref_.id());
176  auto t = transientVector_.exchange(nullptr,std::memory_order_acq_rel);
177  delete t;
178  checkForWrongProduct(keyRef.id(), ref_.id());
179  return data_[ keyRef.key() ];
180  }
void checkForWrongProduct(ProductID const &keyID, ProductID const &refID)
int k[5][pyjets_maxn]
std::atomic< transient_vector_type * > transientVector_
T get(const Candidate &c)
Definition: component.h:55
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 228 of file AssociationVector.h.

Referenced by edm::swap().

228  {
229  data_.swap(other.data_);
230  other.transientVector_.store(transientVector_.exchange(other.transientVector_.load(std::memory_order_acquire),std::memory_order_acq_rel),std::memory_order_release);
231  ref_.swap(other.ref_);
232  }
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 122 of file AssociationVector.h.

Referenced by edm::AssociationVector< PFTauRefProd, std::vector< int > >::begin(), and edm::AssociationVector< PFTauRefProd, std::vector< int > >::end().

122  {
123  fixup();
124  return *(transientVector_.load(std::memory_order_acquire)); }
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