CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends

edm::AssociationMap< Tag > Class Template Reference

#include <AssociationMap.h>

List of all members.

Classes

struct  const_iterator
 const iterator More...
struct  Find
 find helper More...

Public Types

typedef Tag::data_type data_type
 insert data type
typedef Tag::index_type index_type
 index type
typedef std::map< index_type,
value_type
internal_transient_map_type
 transient map type
typedef Tag::key_type key_type
 insert key type
typedef Tag::map_type map_type
 map type
typedef Tag::ref_type ref_type
 reference set type
typedef value_type::value_type result_type
 result type
typedef AssociationMap< Tag > self
 self type
typedef map_type::size_type size_type
 size type
typedef helpers::KeyVal
< key_type, internal_val_type
value_type
 value type

Public Member Functions

 AssociationMap ()
 default constructor
 AssociationMap (const ref_type &ref)
 default constructor
const_iterator begin () const
 first iterator over the map (read only)
void clear ()
 clear map
bool empty () const
 return true if empty
const_iterator end () const
 last iterator over the map (read only)
size_type erase (const key_type &k)
 erase the element whose key is k
const_iterator find (const key_type &k) const
 find element with specified reference key
void insert (const key_type &k, const data_type &v)
 insert an association
void insert (const value_type &kv)
Tag::transient_key_vector keys ()
Tag::transient_map_type map ()
size_type numberOfAssociations (const key_type &k) const
 number of associations to a key
const result_typeoperator[] (const key_type &k) const
 find element with specified reference key
void post_insert ()
 post insert action
const ref_typerefProd () const
 return ref-prod structure
size_type size () const
 map size
Tag::transient_val_vector values ()

Private Types

typedef Tag::val_type internal_val_type
 insert key type

Private Member Functions

const_iterator find (size_type i) const
 find element with index i
const value_typeoperator[] (size_type i) const
 return value_typeelement with key i

Private Attributes

map_type map_
 index map
ref_type ref_
 reference set
internal_transient_map_type transientMap_
 transient reference map

Friends

struct const_iterator
struct Find
class OneToMany
class OneToManyWithQuality
class OneToOne
class OneToValue
struct refhelper::FindTrait< self, value_type >

Detailed Description

template<typename Tag>
class edm::AssociationMap< Tag >

one-to-many or one-to-one associative map using EDM references

Author:
Luca Lista, INFN
Id:
AssociationMap.h,v 1.40 2010/09/01 19:48:30 chrjones Exp

Definition at line 20 of file AssociationMap.h.


Member Typedef Documentation

template<typename Tag>
typedef Tag::data_type edm::AssociationMap< Tag >::data_type

insert data type

Definition at line 31 of file AssociationMap.h.

template<typename Tag>
typedef Tag::index_type edm::AssociationMap< Tag >::index_type

index type

Definition at line 27 of file AssociationMap.h.

template<typename Tag>
typedef std::map<index_type, value_type> edm::AssociationMap< Tag >::internal_transient_map_type

transient map type

Definition at line 43 of file AssociationMap.h.

template<typename Tag>
typedef Tag::val_type edm::AssociationMap< Tag >::internal_val_type [private]

insert key type

Definition at line 22 of file AssociationMap.h.

template<typename Tag>
typedef Tag::key_type edm::AssociationMap< Tag >::key_type

insert key type

Definition at line 29 of file AssociationMap.h.

template<typename Tag>
typedef Tag::map_type edm::AssociationMap< Tag >::map_type

map type

Definition at line 35 of file AssociationMap.h.

template<typename Tag>
typedef Tag::ref_type edm::AssociationMap< Tag >::ref_type

reference set type

Definition at line 33 of file AssociationMap.h.

template<typename Tag>
typedef value_type::value_type edm::AssociationMap< Tag >::result_type

result type

Definition at line 41 of file AssociationMap.h.

template<typename Tag>
typedef AssociationMap<Tag> edm::AssociationMap< Tag >::self

self type

Definition at line 25 of file AssociationMap.h.

template<typename Tag>
typedef map_type::size_type edm::AssociationMap< Tag >::size_type

size type

Definition at line 37 of file AssociationMap.h.

template<typename Tag>
typedef helpers::KeyVal<key_type, internal_val_type> edm::AssociationMap< Tag >::value_type

value type

Definition at line 39 of file AssociationMap.h.


Constructor & Destructor Documentation

template<typename Tag>
edm::AssociationMap< Tag >::AssociationMap ( ) [inline]

default constructor

Definition at line 72 of file AssociationMap.h.

{ }
template<typename Tag>
edm::AssociationMap< Tag >::AssociationMap ( const ref_type ref) [inline, explicit]

default constructor

Definition at line 75 of file AssociationMap.h.

: ref_(ref) { }

Member Function Documentation

template<typename Tag>
const_iterator edm::AssociationMap< Tag >::begin ( void  ) const [inline]
template<typename Tag>
void edm::AssociationMap< Tag >::clear ( void  ) [inline]

clear map

Definition at line 77 of file AssociationMap.h.

{ map_.clear(); transientMap_.clear(); }
template<typename Tag>
bool edm::AssociationMap< Tag >::empty ( ) const [inline]

return true if empty

Definition at line 81 of file AssociationMap.h.

{ return map_.empty(); }
template<typename Tag>
const_iterator edm::AssociationMap< Tag >::end ( void  ) const [inline]
template<typename Tag>
size_type edm::AssociationMap< Tag >::erase ( const key_type k) [inline]

erase the element whose key is k

Definition at line 99 of file AssociationMap.h.

                                       {
      index_type i = k.key();
      transientMap_.erase(i);
      return map_.erase(i);
    }
template<typename Tag>
const_iterator edm::AssociationMap< Tag >::find ( const key_type k) const [inline]
template<typename Tag>
const_iterator edm::AssociationMap< Tag >::find ( size_type  i) const [inline, private]

find element with index i

Definition at line 157 of file AssociationMap.h.

                                           {
      typename map_type::const_iterator f = map_.find(i);
      if (f == map_.end()) return end();
      return const_iterator(this, f);
    }
template<typename Tag>
void edm::AssociationMap< Tag >::insert ( const key_type k,
const data_type v 
) [inline]
template<typename Tag>
void edm::AssociationMap< Tag >::insert ( const value_type kv) [inline]

Definition at line 86 of file AssociationMap.h.

                                       {
      Tag::insert(ref_, map_, kv.key, kv.val);
    }
template<typename Tag>
Tag::transient_key_vector edm::AssociationMap< Tag >::keys ( ) [inline]

fill and return a transient key vector required for ROOT interactive usage

Definition at line 126 of file AssociationMap.h.

                                            { 
      return Tag::transientKeyVector( ref_, map_ ); 
    }
template<typename Tag>
Tag::transient_map_type edm::AssociationMap< Tag >::map ( ) [inline]

fill and return a transient map required for ROOT interactive usage

Definition at line 121 of file AssociationMap.h.

                                         { 
      return Tag::transientMap( ref_, map_ ); 
    }
template<typename Tag>
size_type edm::AssociationMap< Tag >::numberOfAssociations ( const key_type k) const [inline]

number of associations to a key

Definition at line 110 of file AssociationMap.h.

Referenced by VertexAssociatorByTracks::associateRecoToSim(), and VertexAssociatorByTracks::associateSimToReco().

                                                             {
      if (ref_.key.id() != k.id()) return 0;
      typename map_type::const_iterator f = map_.find(k.key());
      if (f == map_.end()) return 0;
      return Tag::size(f->second);
    }
template<typename Tag>
const value_type& edm::AssociationMap< Tag >::operator[] ( size_type  i) const [inline, private]

return value_typeelement with key i

Definition at line 163 of file AssociationMap.h.

                                                     {
      typename internal_transient_map_type::const_iterator tf = transientMap_.find(i);
      if (tf == transientMap_.end()) {
        typename map_type::const_iterator f = map_.find(i);
        if (f == map_.end())
          Exception::throwThis(edm::errors::InvalidReference, "can't find reference in AssociationMap at position ", i);
        value_type v(key_type(ref_.key, i), Tag::val(ref_, f->second));
        std::pair<typename internal_transient_map_type::const_iterator, bool> ins =
          transientMap_.insert(std::make_pair(i, v));
        return ins.first->second;
      } else {
        return tf->second;
      }
    }
template<typename Tag>
const result_type& edm::AssociationMap< Tag >::operator[] ( const key_type k) const [inline]

find element with specified reference key

Definition at line 105 of file AssociationMap.h.

Referenced by edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::operator[]().

                                                             {
      helpers::checkRef(ref_.key, k);
      return operator[](k.key()).val;
    }
template<typename Tag>
void edm::AssociationMap< Tag >::post_insert ( ) [inline]
template<typename Tag>
const ref_type& edm::AssociationMap< Tag >::refProd ( ) const [inline]

return ref-prod structure

Definition at line 117 of file AssociationMap.h.

{ return ref_; }
template<typename Tag>
size_type edm::AssociationMap< Tag >::size ( void  ) const [inline]
template<typename Tag>
Tag::transient_val_vector edm::AssociationMap< Tag >::values ( ) [inline]

fill and return a transient key vector required for ROOT interactive usage

Definition at line 131 of file AssociationMap.h.

                                              { 
      return Tag::transientValVector( ref_, map_ ); 
    }

Friends And Related Function Documentation

template<typename Tag>
friend struct const_iterator [friend]
template<typename Tag>
friend struct Find [friend]

Definition at line 178 of file AssociationMap.h.

template<typename Tag>
friend class OneToMany [friend]

Definition at line 182 of file AssociationMap.h.

template<typename Tag>
friend class OneToManyWithQuality [friend]

Definition at line 183 of file AssociationMap.h.

template<typename Tag>
friend class OneToOne [friend]

Definition at line 181 of file AssociationMap.h.

template<typename Tag>
friend class OneToValue [friend]

Definition at line 180 of file AssociationMap.h.

template<typename Tag>
friend struct refhelper::FindTrait< self, value_type > [friend]

Definition at line 179 of file AssociationMap.h.


Member Data Documentation

template<typename Tag>
map_type edm::AssociationMap< Tag >::map_ [private]

index map

Definition at line 153 of file AssociationMap.h.

Referenced by edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::begin(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::clear(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::empty(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::end(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::erase(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::find(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::insert(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::keys(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::map(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::numberOfAssociations(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::operator[](), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::post_insert(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::size(), and edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::values().

template<typename Tag>
ref_type edm::AssociationMap< Tag >::ref_ [private]
template<typename Tag>
internal_transient_map_type edm::AssociationMap< Tag >::transientMap_ [mutable, private]