ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaRoot
AthenaRootComps
src
xAODCnv.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// xAODCnv.cxx
8
// Implementation file for class xAODCnv
9
// Author: Johannes Elmsheuser, Will Buttinger
11
12
// AthenaRootComps includes
13
#include "
xAODCnv.h
"
14
#include "
xAODBranchAddress.h
"
15
#include "
RootDataBucketBranch.h
"
16
17
// STL includes
18
#include <sstream>
19
#include <typeinfo>
20
#include <stdexcept>
21
22
// framework
23
#include "GaudiKernel/DataObject.h"
24
//#include "GaudiKernel/GenericAddress.h"
25
#include "GaudiKernel/ServiceHandle.h"
26
#include "GaudiKernel/System.h"
27
#include "
AthenaKernel/IDictLoaderSvc.h
"
28
#include "
AthenaKernel/DataBucketBase.h
"
29
#include "
StorageSvc/DbType.h
"
30
31
// ROOT
32
#include "TBranch.h"
33
#include "
RootUtils/TBranchElementClang.h
"
34
#include "TLeaf.h"
35
#include "TTree.h"
36
37
namespace
{
38
std::string name_from_clid (
const
CLID
clid)
39
{
40
std::ostringstream o;
41
o <<
"AthenaRootxAODCnv_"
<< clid;
42
return
o.str();
43
}
44
}
45
46
namespace
Athena
{
47
49
// Public methods:
51
52
// Constructors
54
xAODCnv::xAODCnv
(
const
CLID
& clid,
55
ISvcLocator* pSvcLocator ) :
56
::
Converter
(
pool
::ROOT_StorageType.
type
(), clid, pSvcLocator ),
57
::
AthMessaging
( msgSvc(), name_from_clid(clid) ),
58
m_type
()
59
{
60
//
61
// Property declaration
62
//
63
//declareProperty( "Property", m_nProperty );
64
65
}
66
67
xAODCnv::xAODCnv
( ISvcLocator* pSvcLocator ) :
68
::
Converter
(
pool
::ROOT_StorageType.
type
(), CLID_NULL, pSvcLocator ),
69
::
AthMessaging
( msgSvc(), name_from_clid(CLID_NULL) ),
70
m_type
()
71
{
72
//
73
// Property declaration
74
//
75
//declareProperty( "Property", m_nProperty );
76
ATH_MSG_DEBUG
(
"Constructor xAODCnv..."
);
77
78
}
79
80
// Destructor
82
xAODCnv::~xAODCnv
()
83
{
84
ATH_MSG_DEBUG
(
"Calling destructor"
);
85
}
86
87
// Athena Service's Hooks
89
StatusCode
xAODCnv::initialize
()
90
{
91
// configure our MsgStream
92
//msg().setLevel( MSG::INFO );
93
94
ATH_MSG_DEBUG
(
"Initializing xAODCnv..."
);
95
96
ATH_MSG_DEBUG
(
"Initializing base class..."
);
97
if
( ::Converter::initialize().isFailure() ) {
98
ATH_MSG_ERROR
(
"Could not intialize base class !!"
);
99
return
StatusCode::FAILURE;
100
}
else
{
101
ATH_MSG_VERBOSE
(
"Base class initialized"
);
102
}
103
104
// retrieve the dict-loader-svc
105
typedef
ServiceHandle<IDictLoaderSvc>
IDictLoaderSvc_t;
106
IDictLoaderSvc_t dictSvc(
"AthDictLoaderSvc"
,
107
"Athena::xAODCnv"
);
108
// name_from_clid(objType()));
109
if
( !dictSvc.retrieve().isSuccess() ) {
110
ATH_MSG_ERROR
(
"could not retrieve ["
<< dictSvc.typeAndName() <<
"] !"
);
111
return
StatusCode::FAILURE;
112
}
113
114
RootType
ty = dictSvc->load_type(this->objType());
115
ATH_MSG_VERBOSE
(
"loaded dictionary for clid ["
116
<< this->objType() <<
"]: name=["
117
<< ty.
Name
() <<
"]"
);
118
m_type
= std::move(ty);
119
120
ATH_MSG_DEBUG
(
"converter correctly initialized - clid=["
<< objType() <<
"]"
);
121
return
StatusCode::SUCCESS;
122
}
123
125
// Const methods:
127
128
long
129
xAODCnv::repSvcType
()
const
130
{
131
ATH_MSG_DEBUG
(
"Calling xAODCnv::repSvcType"
);
132
return
pool::ROOT_StorageType
.type();
133
}
134
136
// Non-const methods:
138
142
StatusCode
143
xAODCnv::createObj
(IOpaqueAddress* pAddr, DataObject*& pObj)
144
{
145
ATH_MSG_DEBUG
(
"::createObj("
<< pAddr <<
", "
<< pObj <<
")"
);
146
Athena::xAODBranchAddress
*rba =
dynamic_cast<
Athena::xAODBranchAddress
*
>
(pAddr);
147
if
(!rba) {
148
ATH_MSG_DEBUG
(*pAddr->par() <<
" is NOT a GenericAddress!"
);
149
return
StatusCode::FAILURE;
150
}
151
ATH_MSG_DEBUG
(
"loading branch: ["
<< rba->par()[0]
152
<<
"/"
<< rba->par()[1] <<
"]..."
);
153
//rba->setBranchAddress(m_type);
154
ATH_MSG_DEBUG
(
"xAODCnv::createObj 1"
);
155
// FIXME JE
156
rba->
setTEventAddress
();
157
ATH_MSG_DEBUG
(
"loading branch: ["
<< rba->par()[0]
158
<<
"/"
<< rba->par()[1] <<
"]... [done]"
);
159
ATH_MSG_DEBUG
(
"xAODCnv::createObj 2"
);
160
Athena::DataBucketBranch
*dbb =
new
DataBucketBranch
(rba->clID(),
m_type
, rba->
m_ptr
);
161
dbb->
allowMismatchCLID
=
true
;
//FIXME WB : hack to allow requests from other clid types
162
ATH_MSG_DEBUG
(
"xAODCnv::createObj 3"
);
163
pObj = dbb;
164
ATH_MSG_DEBUG
(
"xAODCnv::createObj 4"
);
165
return
StatusCode::SUCCESS;
166
}
167
171
StatusCode
172
xAODCnv::createRep
(DataObject* pObj, IOpaqueAddress*& pAddr)
173
{
174
ATH_MSG_DEBUG
(
"Calling xAODCnv::createRep"
);
175
176
ATH_MSG_INFO
(
"::createRep("
<< pObj <<
", "
<< pAddr <<
")"
);
177
if
(0==pObj) {
178
ATH_MSG_ERROR
(
"::createRep: received null ptr to dobj"
);
179
return
StatusCode::FAILURE;
180
}
181
msg
(MSG::INFO) <<
" -> clid: ["
<< pObj->clID() <<
"]"
<<
endmsg
182
<<
" -> name: ["
<< pObj->name() <<
"]"
<<
endmsg
;
183
184
/*
185
Athena::DataBucketBranch *dbb = 0;
186
dbb = dynamic_cast<Athena::DataBucketBranch*>(pObj);
187
if (!dbb) {
188
ATH_MSG_INFO("dataobject at [" << pObj->name() << "] is not"
189
<< " a DataBucketBranch ! [clid=" << pObj->clID() << "]");
190
return StatusCode::FAILURE;
191
}
192
*/
193
194
// FIXME:
195
// Athena::RootBranchAddress* addr = new Athena::RootBranchAddress
196
// (pool::ROOT_StorageType.type(),
197
// dbb->clID(),
198
// m_tupleName.value(),
199
// br_name,
200
// (unsigned long)(value_ptr),
201
// (unsigned long)(m_nbrEvts-1));
202
#if 1
203
GenericAddress* addr =
new
GenericAddress(
pool::ROOT_StorageType
.
type
(),
204
pObj->clID(),
205
pObj->name());
206
#else
207
Athena::xAODBranchAddress
* addr =
new
Athena::xAODBranchAddress
208
(
pool::ROOT_StorageType
.
type
(),
id
,
209
"foo"
,
//m_tupleName.value(),
210
dbb->name(),
211
(
unsigned
long
)(value_ptr),
212
(
unsigned
long
)(m_nbrEvts-1));
213
#endif
214
pAddr = addr;
215
return
StatusCode::SUCCESS;
216
}
217
218
long
219
xAODCnv::storageType
()
220
{
221
std::cout <<
"Calling xAODCnv::storageType"
<< std::endl;
222
223
return
pool::ROOT_StorageType
.type();
224
225
}
226
228
// Const methods:
230
232
// Non-const methods:
234
236
// Protected methods:
238
239
}
//> end namespace Athena
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DataBucketBase.h
DbType.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IDictLoaderSvc.h
RootDataBucketBranch.h
RootType
TTypeAdapter RootType
Definition
RootType.h:211
TBranchElementClang.h
Include TBranchElement.h, suppressing clang warnings.
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition
AthMessaging.h:167
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
Athena::DataBucketBranch
Definition
RootDataBucketBranch.h:26
Athena::DataBucketBranch::allowMismatchCLID
bool allowMismatchCLID
Definition
RootDataBucketBranch.h:83
Athena::xAODBranchAddress
A simple class to do the retrieve from TEvent.
Definition
xAODBranchAddress.h:31
Athena::xAODBranchAddress::m_ptr
void * m_ptr
Definition
xAODBranchAddress.h:65
Athena::xAODBranchAddress::setTEventAddress
void setTEventAddress()
Definition
xAODBranchAddress.cxx:93
Athena::xAODCnv::~xAODCnv
virtual ~xAODCnv()
Destructor:
Definition
xAODCnv.cxx:82
Athena::xAODCnv::storageType
static long storageType()
Definition
xAODCnv.cxx:219
Athena::xAODCnv::xAODCnv
xAODCnv(const CLID &clid, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition
xAODCnv.cxx:54
Athena::xAODCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create a transient object from a persistent representation.
Definition
xAODCnv.cxx:143
Athena::xAODCnv::initialize
virtual StatusCode initialize()
Gaudi Service Implementation.
Definition
xAODCnv.cxx:89
Athena::xAODCnv::repSvcType
long repSvcType() const
Definition
xAODCnv.cxx:129
Athena::xAODCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create a persistent representation for a transient object.
Definition
xAODCnv.cxx:172
Athena::xAODCnv::m_type
RootType m_type
the type we can convert
Definition
xAODCnv.h:89
Converter::Converter
Converter()
Definition
Converter.h:29
ServiceHandle
Definition
ClusterMakerTool.h:36
TScopeAdapter::Name
std::string Name(unsigned int mod=Reflex::SCOPED) const
Definition
RootType.cxx:612
Athena
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
Definition
AthDsoUtils.h:10
pool
Framework include files.
Definition
libname.h:15
pool::ROOT_StorageType
static const DbType ROOT_StorageType
Definition
DbType.h:85
type
xAODBranchAddress.h
xAODCnv.h
Generated on
for ATLAS Offline Software by
1.17.0