ATLAS Offline Software
JetSamplingCollectionCnv_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 // JetSamplingCollectionCnv_p1.cxx
8 // Implementation file for class JetSamplingCollectionCnv_p1
9 // Author: S.Binet<binet@cern.ch>
11 
12 // DataModel includes
13 #include "AthAllocators/DataPool.h"
14 
15 // JetEvent includes
16 #include "JetEvent/JetSampling.h"
18 
19 
20 // JetEventTPCnv includes
24 
25 // preallocate converters
26 static const JetSamplingCnv_p1 jetSamplingCnv;
27 
28 
29 void
31  JetSamplingCollection* trans,
32  MsgStream& msg ) const
33 {
34 // msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state..."
35 // << endmsg;
36 
37 
38  // elements are managed by DataPool
39  trans->clear(SG::VIEW_ELEMENTS);
40 
42  const std::size_t nJetSampling = pers->size();
43  if ( pool.capacity() - pool.allocated() < nJetSampling ) {
44  pool.reserve( pool.allocated() + nJetSampling );
45  }
46 
47  trans->reserve( nJetSampling );
48  for ( JetSamplingCollection_p1::const_iterator
49  itr = pers->begin(),
50  itrEnd = pers->end();
51  itr != itrEnd;
52  ++itr ) {
53  JetSampling * jetSampling = pool.nextElementPtr();
54  jetSamplingCnv.persToTrans( &(*itr), jetSampling, msg );
55  trans->push_back( jetSampling );
56  }
57 // msg << MSG::DEBUG << "Loading JetSamplingCollection from persistent state [OK]"
58 // << endmsg;
59  }
60 
61 void
64  MsgStream& msg ) const
65 {
66 // msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection..."
67 // << endmsg;
68 
69  std::size_t size = trans->size();
70  pers->resize(size);
71 
72  // convert vector entries one by one
73  JetSamplingCollection::const_iterator transItr = trans->begin();
74  JetSamplingCollection_p1::iterator persItr = pers->begin();
75  while(size) {
76  jetSamplingCnv.transToPers( *transItr, &(*persItr), msg );
77  ++persItr; ++transItr; --size;
78  }
79 
80 // msg << MSG::DEBUG << "Creating persistent state of JetSamplingCollection [OK]"
81 // << endmsg;
82  }
83 
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
JetSamplingCnv_p1.h
JetSamplingCollectionCnv_p1::transToPers
virtual void transToPers(const JetSamplingCollection *trans, JetSamplingCollection_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSamplingCollection_p1 from its transient representat...
Definition: JetSamplingCollectionCnv_p1.cxx:62
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
JetSampling.h
JetSamplingCollection_p1
Definition: JetSamplingCollection_p1.h:25
pool
pool namespace
Definition: libname.h:15
JetSamplingCnv_p1::persToTrans
virtual void persToTrans(const JetSampling_p1 *pers, JetSampling *trans, MsgStream &msg) const override
Method creating the transient representation of JetSampling from its persistent representation JetSam...
Definition: JetSamplingCnv_p1.cxx:34
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
JetSampling
Definition: JetSampling.h:44
JetSamplingCnv_p1::transToPers
virtual void transToPers(const JetSampling *trans, JetSampling_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation JetSampling_p1 from its transient representation JetSam...
Definition: JetSamplingCnv_p1.cxx:171
DataVector::clear
void clear()
Erase all the elements in the collection.
DataPool.h
JetSamplingCollectionCnv_p1::persToTrans
virtual void persToTrans(const JetSamplingCollection_p1 *pers, JetSamplingCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetSamplingCollection from its persistent representat...
Definition: JetSamplingCollectionCnv_p1.cxx:30
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
JetSamplingCnv_p1
Definition: JetSamplingCnv_p1.h:31
JetSamplingCollection.h
JetSamplingCollectionCnv_p1.h
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
JetSamplingCollection
Definition: JetSamplingCollection.h:20
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.
JetSamplingCollection_p1.h