ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleEventTPCnv
src
CompositeParticleContainerCnv_p1.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// CompositeParticleContainerCnv_p1.cxx
8
// Implementation file for class CompositeParticleContainerCnv_p1
9
// Author: S.Binet<binet@cern.ch>
11
12
#include "
AthAllocators/DataPool.h
"
13
14
// ParticleEvent includes
15
#include "ParticleEvent/CompositeParticle.h"
16
#include "ParticleEvent/CompositeParticleContainer.h"
17
18
19
// ParticleEventTPCnv includes
20
#include "
ParticleEventTPCnv/CompositeParticleCnv_p1.h
"
21
#include "
ParticleEventTPCnv/CompositeParticleContainer_p1.h
"
22
#include "
ParticleEventTPCnv/CompositeParticleContainerCnv_p1.h
"
23
24
// preallocate converters
25
static
const
CompositeParticleCnv_p1
s_cpCnv
;
26
27
28
void
29
CompositeParticleContainerCnv_p1::persToTrans
(
const
CompositeParticleContainer_p1
* pers,
30
CompositeParticleContainer
* trans,
31
MsgStream&
msg
)
const
32
{
33
// msg << MSG::DEBUG << "Loading CompositeParticleContainer from persistent state..."
34
// << endmsg;
35
36
// elements are managed by DataPool
37
trans->
clear
(
SG::VIEW_ELEMENTS
);
38
39
DataPool<CompositeParticle>
pool
( 20 );
40
const
std::size_t nElems = pers->size();
41
if
(
pool
.capacity() -
pool
.allocated() < nElems ) {
42
pool
.reserve(
pool
.allocated() + nElems );
43
}
44
45
trans->
reserve
( nElems );
46
for
( CompositeParticleContainer_p1::const_iterator
47
itr = pers->begin(),
48
itrEnd = pers->end();
49
itr != itrEnd;
50
++itr ) {
51
CompositeParticle
* p =
pool
.nextElementPtr();
52
s_cpCnv
.persToTrans( &(*itr), p,
msg
);
53
trans->
push_back
( p );
54
}
55
// msg << MSG::DEBUG << "Loading CompositeParticleContainer from persistent state [OK]"
56
// << endmsg;
57
return
;
58
}
59
60
void
61
CompositeParticleContainerCnv_p1::transToPers
(
const
CompositeParticleContainer
* trans,
62
CompositeParticleContainer_p1
* pers,
63
MsgStream&
msg
)
const
64
{
65
// msg << MSG::DEBUG
66
// << "Creating persistent state of CompositeParticleContainer..."
67
// << endmsg;
68
69
std::size_t
size
= trans->
size
();
70
pers->resize(
size
);
71
72
// convert vector entries one by one
73
CompositeParticleContainer::const_iterator
transItr = trans->
begin
();
74
CompositeParticleContainer_p1::iterator persItr = pers->begin();
75
while
(
size
) {
76
s_cpCnv
.transToPers( *transItr, &(*persItr),
msg
);
77
++persItr; ++transItr; --
size
;
78
}
79
80
// msg << MSG::DEBUG
81
// << "Creating persistent state of CompositeParticleContainer [OK]"
82
// << endmsg;
83
return
;
84
}
CompositeParticleCnv_p1.h
s_cpCnv
static const CompositeParticleCnv_p1 s_cpCnv
Definition
CompositeParticleContainerCnv_p1.cxx:25
CompositeParticleContainerCnv_p1.h
CompositeParticleContainer_p1.h
DataPool.h
size
size_t size() const
Number of registered mappings.
CompositeParticleCnv_p1
Definition
CompositeParticleCnv_p1.h:28
CompositeParticleContainerCnv_p1::transToPers
virtual void transToPers(const CompositeParticleContainer *trans, CompositeParticleContainer_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation CompositeParticleContainer_p1 from its transient repres...
Definition
CompositeParticleContainerCnv_p1.cxx:61
CompositeParticleContainerCnv_p1::persToTrans
virtual void persToTrans(const CompositeParticleContainer_p1 *pers, CompositeParticleContainer *trans, MsgStream &msg) const override
Method creating the transient representation of CompositeParticleContainer from its persistent repres...
Definition
CompositeParticleContainerCnv_p1.cxx:29
CompositeParticleContainer_p1
Definition
CompositeParticleContainer_p1.h:22
CompositeParticleContainer
Definition
PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticleContainer.h:36
CompositeParticle
class which is made from the composition of other particles.
Definition
PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:52
DataPool
a typed memory pool that saves time spent allocation small object.
Definition
DataPool.h:63
DataVector< CompositeParticle >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::clear
void clear()
Erase all the elements in the collection.
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
pool
Framework include files.
Definition
libname.h:15
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0