ATLAS Offline Software
Loading...
Searching...
No Matches
JetSamplingCollectionCnv_p2.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// JetSamplingCollectionCnv_p2.cxx
8// Implementation file for class JetSamplingCollectionCnv_p2
9// Created by Belen.Salvachua@cern.ch based on JetSamplingCollectionCnv_p1.cxx from
10// S.Binet<binet@cern.ch>
11// Date: Dec 2008
13
14// DataModel includes
16
17// JetEvent includes
20
21
22// JetEventTPCnv includes
26
27// preallocate converters
29
30
31void
34 MsgStream& msg ) const
35{
36// msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state..."
37// << endmsg;
38
39
40 // elements are managed by DataPool
42
44 const std::size_t nJetSampling = pers->size();
45 if ( pool.capacity() - pool.allocated() < nJetSampling ) {
46 pool.reserve( pool.allocated() + nJetSampling );
47 }
48
49 trans->reserve( nJetSampling );
50 for ( JetSamplingCollection_p2::const_iterator
51 itr = pers->begin(),
52 itrEnd = pers->end();
53 itr != itrEnd;
54 ++itr ) {
55 JetSampling * jetSampling = pool.nextElementPtr();
56 jetSamplingCnv.persToTrans( &(*itr), jetSampling, msg );
57 trans->push_back( jetSampling );
58 }
59// msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state [OK]"
60// << endmsg;
61 }
62
63void
66 MsgStream& msg ) const
67{
68// msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection..."
69// << endmsg;
70
71 std::size_t size = trans->size();
72 pers->resize(size);
73
74 // convert vector entries one by one
76 JetSamplingCollection_p2::iterator persItr = pers->begin();
77 while(size) {
78 jetSamplingCnv.transToPers( *transItr, &(*persItr), msg );
79 ++persItr; ++transItr; --size;
80 }
81
82// msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection [OK]"
83// << endmsg;
84 }
static const JetSamplingCnv_p1 jetSamplingCnv
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
virtual void persToTrans(const JetSamplingCollection_p2 *pers, JetSamplingCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetSamplingCollection from its persistent representat...
virtual void transToPers(const JetSamplingCollection *trans, JetSamplingCollection_p2 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSamplingCollection_p2 from its transient representat...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
pool namespace
Definition libname.h:15
MsgStream & msg
Definition testRead.cxx:32