ATLAS Offline Software
CompositeParticleContainerCnv_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 // 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
23 
24 // preallocate converters
25 static const CompositeParticleCnv_p1 s_cpCnv;
26 
27 
28 void
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 
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
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
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 }
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
CompositeParticleCnv_p1.h
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CompositeParticleContainer_p1
Definition: CompositeParticleContainer_p1.h:22
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
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
pool
pool namespace
Definition: libname.h:15
CompositeParticle
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:52
CompositeParticleContainerCnv_p1.h
CompositeParticleContainer
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticleContainer.h:36
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
CompositeParticleCnv_p1::transToPers
virtual void transToPers(const CompositeParticle *transObj, CompositeParticle_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation CompositeParticle_p1 from its transient representation ...
Definition: CompositeParticleCnv_p1.cxx:59
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CompositeParticleContainer_p1.h
DataVector::clear
void clear()
Erase all the elements in the collection.
DataPool.h
CompositeParticleCnv_p1::persToTrans
virtual void persToTrans(const CompositeParticle_p1 *persObj, CompositeParticle *transObj, MsgStream &msg) const override
Method creating the transient representation of CompositeParticle from its persistent representation ...
Definition: CompositeParticleCnv_p1.cxx:38
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
CompositeParticleCnv_p1
Definition: CompositeParticleCnv_p1.h:28
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.