ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
ParticleEventTPCnv
src
ParticleShallowCloneContainerCnv_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
// ParticleShallowCloneContainerCnv_p1.cxx
8
// Implementation file for class ParticleShallowCloneContainerCnv_p1
9
// Author: Karsten Koeneke - February 2013
11
12
#include "
AthAllocators/DataPool.h
"
13
14
// ParticleEvent includes
15
#include "
ParticleEvent/ParticleShallowClone.h
"
16
#include "
ParticleEvent/ParticleShallowCloneContainer.h
"
17
18
19
// ParticleEventTPCnv includes
20
#include "
ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h
"
21
#include "
ParticleEventTPCnv/ParticleShallowCloneContainer_p1.h
"
22
#include "
ParticleEventTPCnv/ParticleShallowCloneContainerCnv_p1.h
"
23
24
// preallocate converters
25
static
const
ParticleShallowCloneCnv_p1
s_cpCnv
;
26
27
28
void
29
ParticleShallowCloneContainerCnv_p1::persToTrans
(
const
ParticleShallowCloneContainer_p1
* pers,
30
ParticleShallowCloneContainer
* trans,
31
MsgStream&
msg
)
const
32
{
33
// msg << MSG::DEBUG << "Loading ParticleShallowCloneContainer from persistent state..."
34
// << endmsg;
35
36
// elements are managed by DataPool
37
trans->
clear
(
SG::VIEW_ELEMENTS
);
38
39
DataPool<Analysis::ParticleShallowClone>
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
( ParticleShallowCloneContainer_p1::const_iterator
47
itr = pers->begin(),
48
itrEnd = pers->end();
49
itr != itrEnd;
50
++itr )
51
{
52
Analysis::ParticleShallowClone
* p =
pool
.nextElementPtr();
53
s_cpCnv
.persToTrans( &(*itr), p,
msg
);
54
trans->
push_back
( p );
55
}
56
// msg << MSG::DEBUG << "Loading ParticleShallowCloneContainer from persistent state [OK]"
57
// << endmsg;
58
return
;
59
}
60
61
void
62
ParticleShallowCloneContainerCnv_p1::transToPers
(
const
ParticleShallowCloneContainer
* trans,
63
ParticleShallowCloneContainer_p1
* pers,
64
MsgStream&
msg
)
const
65
{
66
// msg << MSG::DEBUG
67
// << "Creating persistent state of ParticleShallowCloneContainer..."
68
// << endmsg;
69
70
std::size_t
size
= trans->
size
();
71
pers->resize(
size
);
72
73
// convert vector entries one by one
74
ParticleShallowCloneContainer::const_iterator
transItr = trans->
begin
();
75
ParticleShallowCloneContainer_p1::iterator persItr = pers->begin();
76
while
(
size
)
77
{
78
s_cpCnv
.transToPers( *transItr, &(*persItr),
msg
);
79
++persItr; ++transItr; --
size
;
80
}
81
82
// msg << MSG::DEBUG
83
// << "Creating persistent state of ParticleShallowCloneContainer [OK]"
84
// << endmsg;
85
return
;
86
}
s_cpCnv
static const CompositeParticleCnv_p1 s_cpCnv
Definition
CompositeParticleContainerCnv_p1.cxx:25
DataPool.h
ParticleShallowCloneCnv_p1.h
ParticleShallowCloneContainerCnv_p1.h
ParticleShallowCloneContainer.h
ParticleShallowCloneContainer_p1.h
ParticleShallowClone.h
size
size_t size() const
Number of registered mappings.
Analysis::ParticleShallowClone
Definition
ParticleShallowClone.h:51
DataPool
a typed memory pool that saves time spent allocation small object.
Definition
DataPool.h:63
DataVector< Analysis::ParticleShallowClone >::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.
ParticleShallowCloneCnv_p1
Definition
ParticleShallowCloneCnv_p1.h:30
ParticleShallowCloneContainerCnv_p1::transToPers
virtual void transToPers(const ParticleShallowCloneContainer *trans, ParticleShallowCloneContainer_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation ParticleShallowCloneContainer_p1 from its transient rep...
Definition
ParticleShallowCloneContainerCnv_p1.cxx:62
ParticleShallowCloneContainerCnv_p1::persToTrans
virtual void persToTrans(const ParticleShallowCloneContainer_p1 *pers, ParticleShallowCloneContainer *trans, MsgStream &msg) const override
Method creating the transient representation of ParticleShallowCloneContainer from its persistent rep...
Definition
ParticleShallowCloneContainerCnv_p1.cxx:29
ParticleShallowCloneContainer_p1
Definition
ParticleShallowCloneContainer_p1.h:22
ParticleShallowCloneContainer
Definition
ParticleShallowCloneContainer.h:35
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