ATLAS Offline Software
JetCollectionCnv_p4.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // JetCollectionCnv_p4.cxx
8 // Implementation file for class JetCollectionCnv_p4
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
25 
26 // DataModelAthenaPool includes
28 
29 #include <sstream>
30 
31 // preallocate converters
32 static const JetCnv_p4 jetCnv;
33 static const JetKeyDescriptorCnv_p1 jetkeyCnv;
34 
35 
36 void
38  JetCollection* trans,
39  MsgStream& msg ) const
40 {
41  msg << MSG::DEBUG << "Loading JetCollection from persistent state..."
42  << endmsg;
43 
44  // make sure to first read the JetKeyDescriptor
46  JetKeyStoreCnv.persToTrans( &pers->m_keyStore, &trans->m_keyStore, msg );
47  // link the JetKeyDescriptorInstance to the store:
48  if( trans->m_keyStore.isValid() ){
49  trans->keyDesc()->m_Stores = nullptr;
50  trans->keyDesc()->m_ConstStores = trans->m_keyStore.cptr();
51  // make sure the global instance is pointing to this jetkey store
54  }
55  else if (trans->m_keyStore.isDefault()) {
56  DataLink<JetKeyDescriptor> dl ("JetKeyMap");
57  if (dl.isValid()) {
58  trans->keyDesc()->m_Stores = nullptr;
59  trans->keyDesc()->m_ConstStores = dl.cptr();
60  // make sure the global instance is pointing to this jetkey store
63  }
64  else {
65  trans->keyDesc()->m_Stores =
67  trans->keyDesc()->m_ConstStores =
69  }
70  }
71  else {
74  }
75 
76  msg << MSG::DEBUG << "attached JetKeyDescriptor to its instance" << endmsg;
77 
79 
80  trans->setOrdered (static_cast<JetCollection::OrderedVar>(pers->m_ordered));
81  // the transient version does not have this data member any more,
82  // each jet knows its ROI
83  // trans->m_ROIauthor = //pers->m_roiAuthor;
84 
86 
87  trans->clear();
88  trans->reserve(pers->size());
89 
90  for (const TPObjRef& ref : *pers) {
92  }
93 
94  // now each jet knows its ROI
95  unsigned int RoIWord;
96  std::stringstream strm(pers->m_roiAuthor);
97  strm >> RoIWord;
98  if( strm.good() )
99  {
100  msg << MSG::DEBUG << "Note: This jet collection uses RoIWords!" << endmsg;
101  for( JetCollection::iterator itr = trans->begin(); itr != trans->end(); ++itr )
102  (*itr)->set_RoIword( RoIWord );
103  }
104 
105  msg << MSG::DEBUG << "Loading JetCollection from persistent state [OK]"
106  << endmsg;
107 }
108 
109 void
111  JetCollection_p4* pers,
112  MsgStream& msg ) const
113 {
114 // msg << MSG::DEBUG << "Creating persistent state of JetCollection..."
115 // << endmsg;
116 
117  pers->m_ordered = static_cast<short>(trans->ordered());
118  //pers->m_roiAuthor = trans->m_ROIauthor;
119 
120  pers->clear();
121  pers->reserve(trans->size());
122 
123  for (const Jet* jet : *trans) {
124  pers->push_back(toPersistent((ITPConverterFor<Jet>**)nullptr, jet, msg));
125  }
126 
127  // RS now deal with the JetKeyDescriptor
129  JetKeyStoreCnv.transToPers( &trans->m_keyStore, &pers->m_keyStore, msg );
130 }
131 
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
JetCollection_p4::m_keyStore
DataLink_p1 m_keyStore
Definition: JetCollection_p4.h:43
JetKeyDescriptorInstance::m_Stores
JetKeyDescriptor * m_Stores
Definition: JetKeyDescriptor.h:155
ITPConverterFor
Definition: TPConverter.h:37
TestSUSYToolsAlg.dl
dl
Definition: TestSUSYToolsAlg.py:83
JetCollectionCnv_p4::transToPers
virtual void transToPers(const JetCollection *trans, JetCollection_p4 *pers, MsgStream &msg) const override
Method creating the persistent representation JetCollection_p1 from its transient representation JetC...
Definition: JetCollectionCnv_p4.cxx:110
JetCollection_p4
Definition: JetCollection_p4.h:29
JetCollection::keyDesc
JetKeyDescriptorInstance * keyDesc() const
Definition: JetCollection.cxx:43
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
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
JetCollection_p4.h
JetCnv_p4
Definition: JetCnv_p4.h:29
JetCollection::OrderedVar
OrderedVar
Definition: JetCollection.h:35
TPObjRef
Definition: TPObjRef.h:20
JetCnv_p4.h
JetKeyDescriptorInstance::instance
static JetKeyDescriptorInstance * instance()
Definition: JetKeyDescriptor.h:123
JetCollection::m_keyStore
DataLink< JetKeyDescriptor > m_keyStore
link to the JetKeyDescriptor is mandatory for persistency. Access done through the JetKeyDescriptorIn...
Definition: JetCollection.h:94
JetCollectionCnv_p4.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
DataLinkCnv_p1::transToPers
virtual void transToPers(const DLink_t *trans, PersDLink_t *pers, MsgStream &log) const override
JetCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
JetCollection::ordered
JetCollection::OrderedVar ordered() const
Definition: JetCollection.h:68
DataLinkCnv_p1::persToTrans
virtual void persToTrans(const PersDLink_t *pers, DLink_t *trans, MsgStream &log) const override
JetCollection::clear
void clear()
Definition: JetCollection.cxx:93
JetCollectionCnv_p4::persToTrans
virtual void persToTrans(const JetCollection_p4 *pers, JetCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetCollection from its persistent representation JetC...
Definition: JetCollectionCnv_p4.cxx:37
JetKeyDescriptorCnv_p1.h
DataPool.h
ITPConverterFor::toPersistent
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
Definition: TPConverter.h:119
DataLinkBase::isDefault
bool isDefault() const
Test to see if we're in the default state.
Definition: DataLinkBase.cxx:31
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
JetKeyDescriptorCnv_p1
Definition: JetKeyDescriptorCnv_p1.h:17
ref
const boost::regex ref(r_ef)
JetCollection
Container for Jets
Definition: JetCollection.h:30
DEBUG
#define DEBUG
Definition: page_access.h:11
Jet.h
JetCollection::setOrdered
void setOrdered(JetCollection::OrderedVar ordered)
Definition: JetCollection.h:65
JetCollection::iterator
DataVector< Jet >::iterator iterator
Definition: JetCollection.h:34
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
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DataLinkCnv_p1
Definition: DataLinkCnv_p1.h:23
ITPConverterFor::createTransFromPStore
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
Definition: TPConverter.h:172
JetKeyDescriptorInstance::m_ConstStores
const JetKeyDescriptor * m_ConstStores
Definition: JetKeyDescriptor.h:156
JetCollection_p4::m_ordered
short m_ordered
Definition: JetCollection_p4.h:42