ATLAS Offline Software
ParticleShallowCloneContainerCnv_p1.cxx
Go to the documentation of this file.
1 
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
17 
18 
19 // ParticleEventTPCnv includes
23 
24 // preallocate converters
25 static const ParticleShallowCloneCnv_p1 s_cpCnv;
26 
27 
28 void
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 
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
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
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 }
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ParticleShallowCloneContainer
Definition: ParticleShallowCloneContainer.h:35
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ParticleShallowCloneContainer_p1.h
ParticleShallowCloneCnv_p1::persToTrans
virtual void persToTrans(const ParticleShallowClone_p1 *persObj, Analysis::ParticleShallowClone *transObj, MsgStream &msg) const override
Method creating the transient representation of ParticleShallowClone from its persistent representati...
Definition: ParticleShallowCloneCnv_p1.cxx:38
pool
pool namespace
Definition: libname.h:15
ParticleShallowCloneCnv_p1::transToPers
virtual void transToPers(const Analysis::ParticleShallowClone *transObj, ParticleShallowClone_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation ParticleShallowClone_p1 from its transient representati...
Definition: ParticleShallowCloneCnv_p1.cxx:69
ParticleShallowCloneContainer.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
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
ParticleShallowCloneContainerCnv_p1.h
ParticleShallowCloneCnv_p1.h
Analysis::ParticleShallowClone
Definition: ParticleShallowClone.h:51
DataVector::clear
void clear()
Erase all the elements in the collection.
DataPool.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ParticleShallowCloneContainer_p1
Definition: ParticleShallowCloneContainer_p1.h:22
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
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
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ParticleShallowClone.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ParticleShallowCloneCnv_p1
Definition: ParticleShallowCloneCnv_p1.h:30