Commonly used persistent containers.
Tag
should be one of the following:index
, that is by default unsigned long
, but could be unsigned short
for collections with less than 65535 objects or unsigned char
for collections with less than 255 objects.typedef edm::AssociationMap<edm::OneToMany<CaloJetCollection, TrackCollection> > JetTracksMap; JetTracksMap map; CaloJetRef rj = ...; TrackRef rt = ...; map->insert( rj, rt ); const TrackRefVector & tracks = map[ rj ]; JetTracksMap::const_iterator i = map.find( rj ); assert( i != map.end() ); const CaloJetRef & jet1 = i->key; const TrackRefVector & tracks1 = i->val;The attribute
transientMap_
has to be declared transient in the dictionary. Other used persistent types have to be declared in the dictionary, depending case by case:
<lcgdict> <class name="edm::AssociationMap< ... >" > <field name="transientMap_" transient="true" /> </class > </lcgdict>
std::vector<CVal>
, with in addition an edm::RefProd<CKey>
. Assuming the two collection of types CKey
and CVal
are of the same size and properly ordered, this container implements in a very simple way a one-to-one association. In order to get the reference to the ith object in the CKey
collection, the method key(i)
is implemented. Below a user example:
edm::AssiciationVector<reco::MuonCollection, std::vector<double> > isolations( muonRefProd ); // fill the association ... for( size_t i = 0; i < isolations.size(); ++ i ) { double iso = isolations[ i ]; reco::MuonRef muon = isolations.key( i ); double pt = muon->pt(); }
std::vector<T>
. Still present for hystorical reason; will be probably removed in one of the next releases.std::vector<T>
, boost::ptr_vector<T>
, providing also EDM persistent capabilities. T
is the common base class of polymorphic objects to be stored; the second parameter P
specifies the policy required to allocate clones of the stored object. By default, it is equal to the type edm::ClonePolicy<T> assuming the type T
is equipped with a virtual method clone()
that returning a cloned instance of the actual concrete object. Other user-provided policy implementations are possible. boost::ptr_vector
, due to the polymorphic nature of contained objects, the STL std::sort
function and other mutating algorithms do not work with edm::OwnVector. For this reason, functions to sort the collection are provided as class methods, using the same approach taken by boost::ptr_vector
. See also this documentation from Boost library.sort()
has to be explicitly removed from the reflex dictionary generation. So, you should add to your classes_def.xml
the following lines:
<lcgdict> <selection> <class name="MyBaseClass" /> <class name="edm::OwnVector<MyBaseClass, edm::ClonePolicy<MyBaseClass> >" /> . . . </selection> <exclusion> <class name="edm::OwnVector<MyBaseClass, edm::ClonePolicy<MyBaseClass> >"> <method name="sort" /> </class> </exclusion> </lcgdict>
C
and sorted according to an identified of type ID
. It is possible to iterate over contained object, iterate over identifiers, access only objects with a specified identifier, or whose identifier match a specified criterion. The collection is sorted before being inserted in the Event. The policy to be used to produce copies/clones of the objects during insertion and final sorting phases can be specified as template parameter P
.None.
None.
Completed, stable.
Last updated: @ L. Lista