ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetEventTPCnv
src
JetCollectionCnv_p2.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// JetCollectionCnv_p2.cxx
8
// Implementation file for class JetCollectionCnv_p2
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
21
#include "
JetEventTPCnv/JetCnv_p2.h
"
22
#include "
JetEventTPCnv/JetCollection_p2.h
"
23
#include "
JetEventTPCnv/JetCollectionCnv_p2.h
"
24
#include "
JetEventTPCnv/JetKeyDescriptorCnv_p1.h
"
25
26
// DataModelAthenaPool includes
27
#include "
DataModelAthenaPool/DataLinkCnv_p1.h
"
28
29
#include <sstream>
30
31
// preallocate converters
32
static
const
JetCnv_p2
jetCnv
;
33
static
const
JetKeyDescriptorCnv_p1
jetkeyCnv
;
34
35
void
36
JetCollectionCnv_p2::persToTrans
(
const
JetCollection_p2
* pers,
37
JetCollection
*
trans
,
38
MsgStream&
msg
)
const
39
{
40
msg
<< MSG::DEBUG <<
"Loading JetCollection from persistent state..."
41
<<
endmsg
;
42
43
// make sure to first read the JetKeyDescriptor
44
DataLinkCnv_p1<DataLink<JetKeyDescriptor>
> JetKeyStoreCnv;
45
JetKeyStoreCnv.
persToTrans
( &pers->
m_keyStore
, &
trans
->m_keyStore,
msg
);
46
47
// If the link is null, reset it to a default key.
48
if
(
trans
->m_keyStore.isDefault())
49
trans
->m_keyStore.toDefaultObject();
50
// link the JetKeyDescriptorInstance to the store:
51
if
(
trans
->m_keyStore.isValid() ){
52
trans
->keyDesc()->m_Stores =
nullptr
;
53
trans
->keyDesc()->m_ConstStores =
trans
->m_keyStore.cptr();
54
// make sure the global instance is pointing to this jetkey store
55
JetKeyDescriptorInstance::instance
()->
m_Stores
=
nullptr
;
56
JetKeyDescriptorInstance::instance
()->
m_ConstStores
=
trans
->keyDesc()->m_ConstStores;
57
}
58
else
if
(
trans
->m_keyStore.isDefault()) {
59
DataLink<JetKeyDescriptor>
dl (
"JetKeyMap"
);
60
if
(dl.isValid()) {
61
trans
->keyDesc()->m_Stores =
nullptr
;
62
trans
->keyDesc()->m_ConstStores = dl.cptr();
63
// make sure the global instance is pointing to this jetkey store
64
JetKeyDescriptorInstance::instance
()->
m_Stores
=
nullptr
;
65
JetKeyDescriptorInstance::instance
()->
m_ConstStores
=
trans
->keyDesc()->m_ConstStores;
66
}
67
else
{
68
trans
->keyDesc()->m_Stores =
69
JetKeyDescriptorInstance::instance
()->
m_Stores
;
70
trans
->keyDesc()->m_ConstStores =
71
JetKeyDescriptorInstance::instance
()->
m_ConstStores
;
72
}
73
}
74
else
{
75
trans
->keyDesc()->m_Stores =
JetKeyDescriptorInstance::instance
()->
m_Stores
;
76
trans
->keyDesc()->m_ConstStores =
JetKeyDescriptorInstance::instance
()->
m_ConstStores
;
77
}
78
79
//(trans->m_keyStore)->printOut(msg);
80
msg
<< MSG::DEBUG <<
"Rolf : "
<< &(*
trans
->m_keyStore) <<
endmsg
;
81
// attach the map to the instance
82
(
trans
->m_keyStore)->access();
83
msg
<< MSG::DEBUG <<
"attached JetKeyDescriptor to its instance"
<<
endmsg
;
84
85
// elements are managed by DataPool
86
trans
->clear(
SG::VIEW_ELEMENTS
);
87
88
DataPool<Jet>
pool
( 20 );
89
const
std::size_t nJets = pers->size();
90
if
(
pool
.capacity() -
pool
.allocated() < nJets ) {
91
pool
.reserve(
pool
.allocated() + nJets );
92
}
93
94
trans
->setOrdered (
static_cast<
JetCollection::OrderedVar
>
(pers->
m_ordered
));
95
// the transient version does not have this data member any more,
96
// each jet knows its ROI
97
//trans->m_ROIauthor = //pers->m_roiAuthor;
98
99
trans
->reserve( nJets );
100
for
( JetCollection_p2::const_iterator
101
itr = pers->begin(),
102
itrEnd = pers->end();
103
itr != itrEnd;
104
++itr ) {
105
Jet
*
jet
=
pool
.nextElementPtr();
106
jetCnv
.persToTrans( &(*itr),
jet
,
msg
);
107
trans
->push_back(
jet
);
108
109
}
110
111
// now each jet knows its ROI
112
unsigned
int
RoIWord;
113
std::stringstream strm(pers->
m_roiAuthor
);
114
strm >> RoIWord;
115
if
( strm.good() )
116
{
117
msg
<< MSG::DEBUG <<
"Note: This jet collection uses RoIWords!"
<<
endmsg
;
118
for
(
JetCollection::iterator
itr =
trans
->begin(); itr !=
trans
->end(); ++itr )
119
(*itr)->set_RoIword( RoIWord );
120
}
121
122
msg
<< MSG::DEBUG <<
"Loading JetCollection from persistent state [OK]"
123
<<
endmsg
;
124
}
125
126
void
127
JetCollectionCnv_p2::transToPers
(
const
JetCollection
*
trans
,
128
JetCollection_p2
* pers,
129
MsgStream&
msg
)
const
130
{
131
// msg << MSG::DEBUG << "Creating persistent state of JetCollection..."
132
// << endmsg;
133
134
pers->
m_ordered
=
static_cast<
short
>
(
trans
->ordered());
135
//pers->m_roiAuthor = trans->m_ROIauthor;
136
137
std::size_t
size
=
trans
->size();
138
pers->resize(
size
);
139
140
// convert vector entries one by one
141
JetCollection::const_iterator
transItr =
trans
->begin();
142
JetCollection_p2::iterator persItr = pers->begin();
143
while
(
size
) {
144
jetCnv
.transToPers( *transItr, &(*persItr),
msg
);
145
++persItr; ++transItr; --
size
;
146
}
147
148
// RS now deal with the JetKeyDescriptor
149
DataLinkCnv_p1<DataLink<JetKeyDescriptor>
> JetKeyStoreCnv;
150
JetKeyStoreCnv.
transToPers
( &
trans
->m_keyStore, &pers->
m_keyStore
,
msg
);
151
}
152
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
DataLinkCnv_p1.h
This file contains the class definition for the DataLinkCnv_p1 class and DataLinkVectorCnv_p1 class.
DataPool.h
JetCnv_p2.h
jetCnv
static const JetCnv_p1 jetCnv
Definition
JetCollectionCnv_p1.cxx:28
jetkeyCnv
static const JetKeyDescriptorCnv_p1 jetkeyCnv
Definition
JetCollectionCnv_p2.cxx:33
JetCollectionCnv_p2.h
JetCollection.h
JetCollection_p2.h
JetKeyDescriptorCnv_p1.h
Jet.h
size
size_t size() const
Number of registered mappings.
DataLinkCnv_p1
Definition
DataLinkCnv_p1.h:23
DataLinkCnv_p1::persToTrans
virtual void persToTrans(const PersDLink_t *pers, DLink_t *trans, MsgStream &log) const override
DataLinkCnv_p1::transToPers
virtual void transToPers(const DLink_t *trans, PersDLink_t *pers, MsgStream &log) const override
DataLink
Object reference supporting deferred reading from StoreGate.
Definition
AthLinks/DataLink.h:96
DataPool
a typed memory pool that saves time spent allocation small object.
Definition
DataPool.h:63
DataVector< Jet >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:861
JetCnv_p2
Definition
JetCnv_p2.h:27
JetCollectionCnv_p2::transToPers
virtual void transToPers(const JetCollection *trans, JetCollection_p2 *pers, MsgStream &msg) const override
Method creating the persistent representation JetCollection_p1 from its transient representation JetC...
Definition
JetCollectionCnv_p2.cxx:127
JetCollectionCnv_p2::persToTrans
virtual void persToTrans(const JetCollection_p2 *pers, JetCollection *trans, MsgStream &msg) const override
Method creating the transient representation of JetCollection from its persistent representation JetC...
Definition
JetCollectionCnv_p2.cxx:36
JetCollection_p2
Definition
JetCollection_p2.h:29
JetCollection_p2::m_ordered
short m_ordered
Definition
JetCollection_p2.h:42
JetCollection_p2::m_roiAuthor
std::string m_roiAuthor
Definition
JetCollection_p2.h:41
JetCollection_p2::m_keyStore
DataLink_p1 m_keyStore
Definition
JetCollection_p2.h:43
JetCollection
Definition
JetCollection.h:30
JetCollection::OrderedVar
OrderedVar
Definition
JetCollection.h:35
JetCollection::iterator
DataVector< Jet >::iterator iterator
Definition
JetCollection.h:34
JetKeyDescriptorCnv_p1
Definition
JetKeyDescriptorCnv_p1.h:17
JetKeyDescriptorInstance::m_ConstStores
const JetKeyDescriptor * m_ConstStores
Definition
JetKeyDescriptor.h:156
JetKeyDescriptorInstance::m_Stores
JetKeyDescriptor * m_Stores
Definition
JetKeyDescriptor.h:155
JetKeyDescriptorInstance::instance
static JetKeyDescriptorInstance * instance()
Definition
JetKeyDescriptor.h:123
Jet
Definition
Reconstruction/Jet/JetEvent/JetEvent/Jet.h:47
trans
TH1F * trans(TH1F *h, bool t=false)
Definition
comparitor.cxx:199
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
pool
Framework include files.
Definition
libname.h:15
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0