ATLAS Offline Software
JetCollectionCnv_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 // JetCollectionCnv_p1.cxx
8 // Implementation file for class JetCollectionCnv_p1
9 // Author: S.Binet<binet@cern.ch>
11 
12 // DataModel includes
13 #include "AthAllocators/DataPool.h"
14 
15 // JetEvent includes
16 #include "JetEvent/Jet.h"
17 #include "JetEvent/JetCollection.h"
18 
19 
20 // JetEventTPCnv includes
24 
25 #include <sstream>
26 
27 // preallocate converters
28 static const JetCnv_p1 jetCnv;
29 
30 
31 void
33  JetCollection* trans,
34  MsgStream& msg ) const
35 {
36 // msg << MSG::DEBUG << "Loading JetCollection from persistent state..."
37 // << endmsg;
38 
39  // elements are managed by DataPool
40  trans->clear(SG::VIEW_ELEMENTS);
41 
42  DataPool<Jet> pool( 20 );
43  const std::size_t nJets = pers->size();
44  if ( pool.capacity() - pool.allocated() < nJets ) {
45  pool.reserve( pool.allocated() + nJets );
46  }
47 
48  trans->setOrdered (static_cast<JetCollection::OrderedVar>(pers->m_ordered));
49  // the transient version does not have this data member any more,
50  // each jet knows its ROI
51  // trans->m_ROIauthor = //pers->m_roiAuthor;
52 
53  trans->reserve( nJets );
54  for ( JetCollection_p1::const_iterator
55  itr = pers->begin(),
56  itrEnd = pers->end();
57  itr != itrEnd;
58  ++itr ) {
59  Jet * jet = pool.nextElementPtr();
60  jetCnv.persToTrans( &(*itr), jet, msg );
61  trans->push_back( jet );
62  }
63 
64  // now each jet knows its ROI
65  unsigned int RoIWord;
66  std::stringstream strm(pers->m_roiAuthor);
67  strm >> RoIWord;
68  if( strm.good() )
69  {
70  msg << MSG::DEBUG << "Note: This jet collection uses RoIWords!" << endmsg;
71  for( JetCollection::iterator itr = trans->begin(); itr != trans->end(); ++itr )
72  (*itr)->set_RoIword( RoIWord );
73  }
74 // msg << MSG::DEBUG << "Loading JetCollection from persistent state [OK]"
75 // << endmsg;
76  }
77 
78 void
80  JetCollection_p1* pers,
81  MsgStream& msg ) const
82 {
83 // msg << MSG::DEBUG << "Creating persistent state of JetCollection..."
84 // << endmsg;
85 
86  pers->m_ordered = static_cast<short>(trans->ordered());
87  //pers->m_roiAuthor = trans->m_ROIauthor;
88 
89  std::size_t size = trans->size();
90  pers->resize(size);
91 
92  // convert vector entries one by one
93  JetCollection::const_iterator transItr = trans->begin();
94  JetCollection_p1::iterator persItr = pers->begin();
95  while(size) {
96  jetCnv.transToPers( *transItr, &(*persItr), msg );
97  ++persItr; ++transItr; --size;
98  }
99 
100 // msg << MSG::DEBUG << "Creating persistent state of JetCollection [OK]"
101 // << endmsg;
102  }
103 
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
JetCollectionCnv_p1.h
Jet
Basic data class defines behavior for all Jet objects The Jet class is the principal data class for...
Definition: Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
JetCnv_p1.h
JetCollectionCnv_p1::persToTrans
virtual void persToTrans(const JetCollection_p1 *pers, JetCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetCollection from its persistent representation JetC...
Definition: JetCollectionCnv_p1.cxx:32
pool
pool namespace
Definition: libname.h:15
JetCollection::OrderedVar
OrderedVar
Definition: JetCollection.h:35
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JetCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
JetCollection::ordered
JetCollection::OrderedVar ordered() const
Definition: JetCollection.h:68
JetCollection_p1::m_roiAuthor
std::string m_roiAuthor
Definition: JetCollection_p1.h:38
JetCollection::clear
void clear()
Definition: JetCollection.cxx:93
DataPool.h
JetCollection_p1::m_ordered
short m_ordered
Definition: JetCollection_p1.h:39
JetCollection_p1
Definition: JetCollection_p1.h:26
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
JetCollectionCnv_p1::transToPers
virtual void transToPers(const JetCollection *trans, JetCollection_p1 *pers, MsgStream &msg) const override
Method creating the persistent representation JetCollection_p1 from its transient representation JetC...
Definition: JetCollectionCnv_p1.cxx:79
JetCnv_p1
Definition: JetCnv_p1.h:27
JetCollection
Container for Jets
Definition: JetCollection.h:30
DEBUG
#define DEBUG
Definition: page_access.h:11
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
Jet.h
JetCollection::setOrdered
void setOrdered(JetCollection::OrderedVar ordered)
Definition: JetCollection.h:65
JetCollection::iterator
DataVector< Jet >::iterator iterator
Definition: JetCollection.h:34
JetCollection_p1.h
JetCnv_p1::transToPers
virtual void transToPers(const Jet *transObj, Jet_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation Jet_p1 from its transient representation Jet.
Definition: JetCnv_p1.cxx:69
JetCollection::push_back
void push_back(Jet *j)
Definition: JetCollection.cxx:82
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
JetCnv_p1::persToTrans
virtual void persToTrans(const Jet_p1 *persObj, Jet *transObj, MsgStream &msg) const override
Method creating the transient representation of Jet from its persistent representation Jet_p1.
Definition: JetCnv_p1.cxx:34
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.