ATLAS Offline Software
JetSamplingCollectionCnv_p2.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 // 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
15 #include "AthAllocators/DataPool.h"
16 
17 // JetEvent includes
18 #include "JetEvent/JetSampling.h"
20 
21 
22 // JetEventTPCnv includes
26 
27 // preallocate converters
28 static const JetSamplingCnv_p2 jetSamplingCnv;
29 
30 
31 void
33  JetSamplingCollection* trans,
34  MsgStream& msg ) const
35 {
36 // msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state..."
37 // << endmsg;
38 
39 
40  // elements are managed by DataPool
41  trans->clear(SG::VIEW_ELEMENTS);
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 
63 void
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
75  JetSamplingCollection::const_iterator transItr = trans->begin();
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  }
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
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
JetSamplingCnv_p2::transToPers
virtual void transToPers(const JetSampling *trans, JetSampling_p2 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSampling_p2 from its transient representation JetSam...
Definition: JetSamplingCnv_p2.cxx:133
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
JetSamplingCnv_p2.h
JetSampling.h
pool
pool namespace
Definition: libname.h:15
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
JetSampling
Definition: JetSampling.h:44
JetSamplingCollectionCnv_p2.h
JetSamplingCnv_p2
Definition: JetSamplingCnv_p2.h:33
JetSamplingCollectionCnv_p2::transToPers
virtual void transToPers(const JetSamplingCollection *trans, JetSamplingCollection_p2 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSamplingCollection_p2 from its transient representat...
Definition: JetSamplingCollectionCnv_p2.cxx:64
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.
JetSamplingCnv_p2::persToTrans
virtual void persToTrans(const JetSampling_p2 *pers, JetSampling *trans, MsgStream &msg) const override
Method creating the transient representation of JetSampling from its persistent representation JetSam...
Definition: JetSamplingCnv_p2.cxx:33
JetSamplingCollection.h
JetSamplingCollectionCnv_p2::persToTrans
virtual void persToTrans(const JetSamplingCollection_p2 *pers, JetSamplingCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetSamplingCollection from its persistent representat...
Definition: JetSamplingCollectionCnv_p2.cxx:32
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:63
JetSamplingCollection_p2.h
JetSamplingCollection
Definition: JetSamplingCollection.h:20
JetSamplingCollection_p2
Definition: JetSamplingCollection_p2.h:26
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.