ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataWrite
src
xAODTestWriteCInfoTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// $Id$
12
13
14
#include "
xAODTestWriteCInfoTool.h
"
15
#include "
DataModelTestDataCommon/C.h
"
16
#include "
DataModelTestDataCommon/CInfoAuxContainer.h
"
17
#include "AthLinks/ElementLink.h"
18
19
20
namespace
DMTest
{
21
22
29
xAODTestWriteCInfoTool::xAODTestWriteCInfoTool
(
const
std::string&
type
,
30
const
std::string& name,
31
const
IInterface* parent)
32
33
: base_class (
type
, name, parent),
34
m_cvecKey
(
"cvec"
),
35
m_cinfoKey
(
"cinfo"
)
36
{
37
declareProperty (
"CVecKey"
,
m_cvecKey
);
38
declareProperty (
"CInfoKey"
,
m_cinfoKey
);
39
}
40
41
45
StatusCode
xAODTestWriteCInfoTool::initialize
()
46
{
47
ATH_CHECK
(
m_cvecKey
.initialize() );
48
ATH_CHECK
(
m_cinfoKey
.initialize() );
49
return
StatusCode::SUCCESS;
50
}
51
52
56
StatusCode
xAODTestWriteCInfoTool::doit
(
const
EventContext& ctx)
const
57
{
58
unsigned
int
count
= ctx.eventID().event_number() + 1;
59
60
SG::ReadHandle<DMTest::CVec>
cvec (
m_cvecKey
, ctx);
61
62
auto
cinfo = std::make_unique<DMTest::C>();
63
auto
info_store = std::make_unique<DMTest::CInfoAuxContainer>();
64
cinfo->setStore (info_store.get());
65
66
static
const
C::Accessor<int> anInt2 (
"anInt2"
);
67
static
const
C::Accessor<ElementLink<DMTest::CVec> > cEL (
"cEL"
);
68
69
cinfo->setAnInt (
count
* 1000);
70
cinfo->setAFloat ((
float
)
count
* 0.1);
71
anInt2(*cinfo) =
count
* 2000;
72
73
if
(!cvec->empty()) {
74
cEL(*cinfo).toIndexedElement (*cvec,
count
% cvec->size());
75
}
76
77
SG::WriteHandle<DMTest::C>
cinfoH (
m_cinfoKey
, ctx);
78
std::unique_ptr<const DMTest::C> cinfo_c (std::move (cinfo));
79
std::unique_ptr<const DMTest::CInfoAuxContainer> info_store_c (std::move (info_store));
80
if
(cinfoH.
put
(std::move(cinfo_c), std::move(info_store_c)) ==
nullptr
) {
81
ATH_MSG_ERROR
(
"Can't record CInfo"
);
82
return
StatusCode::FAILURE;
83
}
84
85
return
StatusCode::SUCCESS;
86
}
87
88
89
}
// namespace DMTest
90
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
C.h
Class used for testing xAOD data reading/writing.
DMTest::xAODTestWriteCInfoTool::initialize
virtual StatusCode initialize() override
Tool initialization; called at the beginning of the job.
Definition
xAODTestWriteCInfoTool.cxx:45
DMTest::xAODTestWriteCInfoTool::m_cinfoKey
SG::WriteHandleKey< DMTest::C > m_cinfoKey
Definition
xAODTestWriteCInfoTool.h:63
DMTest::xAODTestWriteCInfoTool::xAODTestWriteCInfoTool
xAODTestWriteCInfoTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition
xAODTestWriteCInfoTool.cxx:29
DMTest::xAODTestWriteCInfoTool::doit
virtual StatusCode doit(const EventContext &ctx) const override
Tool event processing.
Definition
xAODTestWriteCInfoTool.cxx:56
DMTest::xAODTestWriteCInfoTool::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWriteCInfoTool.h:62
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
DMTest
Definition
B.h:23
type
xAODTestWriteCInfoTool.h
Tool to test writing xAOD classes with auxiliary data (cinfo).
Generated on
for ATLAS Offline Software by
1.17.0