ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataRead
src
xAODTestReadCInfo.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
3
*/
4
// $Id$
11
12
13
#include "
xAODTestReadCInfo.h
"
14
#include "
DataModelTestDataCommon/C.h
"
15
#include "
DataModelTestDataCommon/CVec.h
"
16
#include "
DataModelTestDataCommon/CInfoAuxContainer.h
"
17
#include "
AthContainers/AuxTypeRegistry.h
"
18
#include "AthLinks/ElementLink.h"
19
#include "
AthenaKernel/errorcheck.h
"
20
#include <sstream>
21
22
23
namespace
DMTest
{
24
25
31
xAODTestReadCInfo::xAODTestReadCInfo
(
const
std::string &name,
32
ISvcLocator *pSvcLocator)
33
:
AthReentrantAlgorithm
(name, pSvcLocator)
34
{
35
declareProperty
(
"CInfoKey"
,
m_cinfoKey
=
"cinfo"
);
36
declareProperty
(
"WriteKey"
,
m_writeKey
);
37
}
38
39
43
StatusCode
xAODTestReadCInfo::initialize
()
44
{
45
ATH_CHECK
(
m_cinfoKey
.initialize() );
46
if
(!
m_writeKey
.key().empty())
47
ATH_CHECK
(
m_writeKey
.initialize() );
48
return
StatusCode::SUCCESS;
49
}
50
51
55
StatusCode
xAODTestReadCInfo::execute
(
const
EventContext& ctx)
const
56
{
57
static
const
C::Accessor<int> anInt2 (
"anInt2"
);
58
static
const
C::Accessor<int> anInt10 (
"anInt10"
);
59
static
const
C::Accessor<int> dInt1 (
"dInt1"
);
60
static
const
C::Accessor<unsigned int> dpInt1 (
"dpInt1"
);
61
static
const
C::Accessor<std::vector<float> > dpvFloat (
"dpvFloat"
);
62
static
const
C::Accessor<int> dInt100 (
"dInt100"
);
63
static
const
C::Accessor<int> dInt150 (
"dInt150"
);
64
static
const
C::Accessor<int> dInt200 (
"dInt200"
);
65
static
const
C::Accessor<int> dInt250 (
"dInt250"
);
66
static
const
C::Accessor<ElementLink<DMTest::CVec> > cEL (
"cEL"
);
67
68
// Ordering of auxid is not reliable. Sort by name.
69
const
SG::AuxTypeRegistry
&
r
=
SG::AuxTypeRegistry::instance
();
70
std::vector<std::string> names;
71
72
SG::ReadHandle<DMTest::C>
cinfo (
m_cinfoKey
, ctx);
73
74
names.clear();
75
for
(
SG::auxid_t
auxid : cinfo->getAuxIDs())
76
names.push_back (
r
.getName(auxid));
77
std::sort
(names.begin(), names.end());
78
std::ostringstream ost1;
79
ost1 <<
"cinfo aux items: "
;
80
for
(
const
std::string& n : names)
81
ost1 << n <<
" "
;
82
ATH_MSG_INFO
(ost1.str());
83
84
std::ostringstream ost2;
85
ost2 <<
"cinfo "
86
<<
" anInt1 "
<< cinfo->anInt()
87
<<
" aFloat: "
<< cinfo->aFloat()
88
<<
" anInt2: "
<< anInt2(*cinfo)
89
<<
" dInt1: "
<< dInt1(*cinfo)
90
<<
" cEL: "
<< cEL(*cinfo).dataID()
91
<<
"["
<< cEL(*cinfo).index() <<
"]"
;
92
if
(dInt100.isAvailable(*cinfo))
93
ost2 <<
" dInt100: "
<< dInt100(*cinfo);
94
if
(dInt150.isAvailable(*cinfo))
95
ost2 <<
" dInt150: "
<< dInt150(*cinfo);
96
if
(dInt200.isAvailable(*cinfo))
97
ost2 <<
" dInt200: "
<< dInt200(*cinfo);
98
if
(dInt250.isAvailable(*cinfo))
99
ost2 <<
" dInt250: "
<< dInt250(*cinfo);
100
if
(anInt10.isAvailable(*cinfo))
101
ost2 <<
" anInt10: "
<< anInt10(*cinfo);
102
ATH_MSG_INFO
(ost2.str());
103
104
if
(!
m_writeKey
.key().empty()) {
105
auto
cnew = std::make_unique<DMTest::C>();
106
auto
info_store = std::make_unique<DMTest::CInfoAuxContainer>();
107
cnew->setStore (info_store.get());
108
*cnew = *cinfo;
109
110
SG::WriteHandle<DMTest::C>
writevec (
m_writeKey
, ctx);
111
ATH_CHECK
( writevec.
record
(std::move(cnew), std::move(info_store)) );
112
}
113
114
return
StatusCode::SUCCESS;
115
}
116
117
118
}
// namespace DMTest
119
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
CVec.h
Class used for testing xAOD data reading/writing.
C.h
Class used for testing xAOD data reading/writing.
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DMTest::xAODTestReadCInfo::m_writeKey
SG::WriteHandleKey< DMTest::C > m_writeKey
Definition
xAODTestReadCInfo.h:55
DMTest::xAODTestReadCInfo::execute
virtual StatusCode execute(const EventContext &ctx) const
Algorithm event processing.
Definition
xAODTestReadCInfo.cxx:55
DMTest::xAODTestReadCInfo::m_cinfoKey
SG::ReadHandleKey< DMTest::C > m_cinfoKey
Definition
xAODTestReadCInfo.h:54
DMTest::xAODTestReadCInfo::initialize
virtual StatusCode initialize()
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestReadCInfo.cxx:43
DMTest::xAODTestReadCInfo::xAODTestReadCInfo
xAODTestReadCInfo(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
xAODTestReadCInfo.cxx:31
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition
AuxTypeRegistry.h:61
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition
AuxTypeRegistry.cxx:640
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
r
int r
Definition
globals.cxx:22
DMTest
Definition
B.h:23
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
xAODTestReadCInfo.h
Algorithm to test reading xAOD cinfo data.
Generated on
for ATLAS Offline Software by
1.17.0