1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/*!
\page DataFormats_Common_containers Package DataFormats/Common: container classes
<center>
<small>
<a href=http://cmsdoc.cern.ch/swdev/viewcvs/viewcvs.cgi/CMSSW/DataFormats/Common/?cvsroot=CMSSW>CVS head for this package</a> -
<a href=http://cmsdoc.cern.ch/swdev/viewcvs/viewcvs.cgi/CMSSW/DataFormats/Common/.admin/developers?rev=HEAD&cvsroot=CMSSW&content-type=text/vnd.viewcvs-markup>Administrative privileges</a>
</small>
</center>
\section desc Description
Commonly used persistent containers.
\subsection interface Public interface
- edm::AssociationMap <b><Tag></b>: one-to-many, one-to-one
or one-to-value association based on edm::Ref. Objects in a EDM collection
are associated to one or many objects in another EDM collection or to
values of a specified type.<br><br>
The template <tt>Tag</tt> should be one of the following:
- edm::OneToValue <b><CKey, Val, index></b> for associations by value
- edm::OneToOne <b><CKey, CVal, index></b> for one-to-one maps by reference
- edm::OneToMany <b><CKey, CVal, index></b> for one-to-many maps by reference
- edm::OneToManyWithQuality <b><CKey, CVal, Q, index></b>
<b>CKey</b> is the collection type of the object to be associated, <b>CVal</b> is the collection of
associated objects, <b>Val</b> is the associated value type and <b>Q</b> is the data type describing
the match quality. References are stored as indices of type <tt>index</tt>, that is by default
<tt>unsigned long</tt>, but could be <tt>unsigned short</tt> for collections with less than 65535
objects or <tt>unsigned char</tt> for collections with less than 255 objects.<br><br>
One example of basic usage is presented below:
\htmlonly
<pre>
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;
</pre>
\endhtmlonly
The attribute <tt>transientMap_</tt> has to be declared transient in the
dictionary. Other used persistent
types have to be declared in the dictionary, depending case by case:
\htmlonly
<pre>
<lcgdict>
<class name="edm::AssociationMap< ... >" >
<field name="transientMap_" transient="true" />
</class >
</lcgdict>
</pre>
\endhtmlonly
- edm::AssociationVector <b><CKey, CVal></b>: container very similar to
<tt>std::vector<CVal></tt>, with in addition an <tt>edm::RefProd<CKey></tt>.
Assuming the two collection of types <tt>CKey</tt> and <tt>CVal</tt> 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 <i>i<sup>th</sup></i> object in
the <tt>CKey</tt> collection, the method <tt>key(i)</tt> is implemented. Below
a user example:
\htmlonly
<pre>
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();
}
</pre>
\endhtmlonly
- edm::DetSet <b><T></b>:
- edm::EDCollection <b><T></b>: Functionally equivalent to <tt>std::vector<T></tt>.
Still present for hystorical reason; will be probably removed in one of the next releases.
- edm::IDVectorMap <b><ID, C, P></b>:
- edm::OwnVector <b><T, P = edm::ClonePolicy<T> ></b>: container
with interface very similar to <tt>std::vector<T></tt>,
capable of storing polymorphic objects that are owned by the
container to avoid memory leak.
edm::OwnVector has functionalities very similar to
<a href="http://www.boost.org/libs/ptr_container/doc/ptr_vector.html"><tt>boost::ptr_vector<T></tt></a>,
providing also EDM persistent capabilities.
<br><br>The first template argument <tt><b>T</b></tt> is the common base class of
polymorphic objects to be stored; the second parameter <tt><b>P</b></TT> specifies
the \ref DataFormats_Common_helpers "policy" required to allocate clones of
the stored object. By default, it
is equal to the type <b>edm::ClonePolicy<T></b> assuming the
type <tt>T</tt> is equipped with a virtual method <tt><b>clone()</b></tt> that returning a cloned
instance of the actual concrete object. Other user-provided policy implementations are possible.
<br><br>
As for <a href="http://www.boost.org/libs/ptr_container/doc/ptr_vector.html"><tt>boost::ptr_vector</tt></a>,
due to the polymorphic nature of contained objects, the STL <tt><b>std::sort</b></tt>
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 <a href="http://www.boost.org/libs/ptr_container/doc/ptr_vector.html"><tt>boost::ptr_vector</tt></a>.
See also this <a href="http://www.boost.org/libs/ptr_container/doc/tutorial.html#algorithms">documentation</a>
from <a href="http://www.boost.org">Boost library</a>.<br><br>
Please, note that for classes that do not provide a "<" operator, the function
<tt>sort()</tt> has to be <b>explicitly removed</b> from the reflex dictionary generation.
So, you should add to your <tt>classes_def.xml</tt> the following lines:
\htmlonly
<pre>
<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>
</pre>
\endhtmlonly
- edm::RangeMap <b><ID, C, P></b>: generic container of objects
organized in a collection of type <tt><b>C</b></tt> and sorted
according to an identified of type <tt><b>ID</b></tt>. 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 \ref DataFormats_Common_helpers "policy" to be used
to produce copies/clones of the objects during insertion and final
sorting phases can be specified as template parameter <tt><b>P</b></tt>.
- edm::SortedCollection <b><T, SORT></b>:
</pre>
\subsection modules Modules
None.
\subsection tests Unit tests and examples
None.
\section status Status and planned development
Completed, stable.
<hr>
Last updated: @DATE@ L. Lista
*/
|