ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestWriteCInfo.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
xAODTestWriteCInfo.h
"
13
#include "
DataModelTestDataCommon/C.h
"
14
#include "
DataModelTestDataCommon/CInfoAuxContainer.h
"
15
#include "AthLinks/ElementLink.h"
16
17
18
namespace
DMTest
{
19
20
26
xAODTestWriteCInfo::xAODTestWriteCInfo
(
const
std::string &name,
27
ISvcLocator *pSvcLocator)
28
:
AthReentrantAlgorithm
(name, pSvcLocator),
29
m_cvecKey
(
"cvec"
),
30
m_cinfoKey
(
"cinfo"
)
31
{
32
declareProperty
(
"Offset"
,
m_offset
= 0);
33
declareProperty
(
"CVecKey"
,
m_cvecKey
);
34
declareProperty
(
"CInfoKey"
,
m_cinfoKey
);
35
}
36
37
41
StatusCode
xAODTestWriteCInfo::initialize
()
42
{
43
ATH_CHECK
(
m_eventInfoKey
.initialize() );
44
ATH_CHECK
(
m_cvecKey
.initialize() );
45
ATH_CHECK
(
m_cinfoKey
.initialize() );
46
return
StatusCode::SUCCESS;
47
}
48
49
53
StatusCode
xAODTestWriteCInfo::execute
(
const
EventContext& ctx)
const
54
{
55
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
56
unsigned
int
count
= eventInfo->eventNumber() + 1;
57
58
SG::ReadHandle<DMTest::CVec>
cvec (
m_cvecKey
, ctx);
59
60
auto
cinfo = std::make_unique<DMTest::C>();
61
auto
info_store = std::make_unique<DMTest::CInfoAuxContainer>();
62
cinfo->setStore (info_store.get());
63
64
static
const
C::Accessor<int> anInt2 (
"anInt2"
);
65
static
const
C::Accessor<ElementLink<DMTest::CVec> > cEL (
"cEL"
);
66
67
cinfo->setAnInt (
count
* 1000 +
m_offset
);
68
cinfo->setAFloat ((
float
)
count
* 0.1 +
m_offset
);
69
anInt2(*cinfo) =
count
* 2000 +
m_offset
;
70
71
if
(!cvec->empty()) {
72
cEL(*cinfo).toIndexedElement (*cvec,
count
% cvec->size(), ctx);
73
}
74
75
SG::WriteHandle<DMTest::C>
cinfoH (
m_cinfoKey
, ctx);
76
std::unique_ptr<const DMTest::C> cinfo_c (std::move (cinfo));
77
std::unique_ptr<const DMTest::CInfoAuxContainer> info_store_c (std::move (info_store));
78
if
(cinfoH.
put
(std::move(cinfo_c), std::move(info_store_c)) ==
nullptr
) {
79
ATH_MSG_ERROR
(
"Can't record CInfo"
);
80
return
StatusCode::FAILURE;
81
}
82
83
return
StatusCode::SUCCESS;
84
}
85
86
90
StatusCode
xAODTestWriteCInfo::finalize
()
91
{
92
return
StatusCode::SUCCESS;
93
}
94
95
96
}
// namespace DMTest
97
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:47
CInfoAuxContainer.h
Class used for testing xAOD data reading/writing.
C.h
Class used for testing xAOD data reading/writing.
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::xAODTestWriteCInfo::m_offset
int m_offset
Definition
xAODTestWriteCInfo.h:65
DMTest::xAODTestWriteCInfo::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWriteCInfo.cxx:53
DMTest::xAODTestWriteCInfo::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWriteCInfo.cxx:41
DMTest::xAODTestWriteCInfo::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
xAODTestWriteCInfo.h:66
DMTest::xAODTestWriteCInfo::xAODTestWriteCInfo
xAODTestWriteCInfo(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
xAODTestWriteCInfo.cxx:26
DMTest::xAODTestWriteCInfo::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWriteCInfo.h:67
DMTest::xAODTestWriteCInfo::m_cinfoKey
SG::WriteHandleKey< DMTest::C > m_cinfoKey
Definition
xAODTestWriteCInfo.h:68
DMTest::xAODTestWriteCInfo::finalize
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
Definition
xAODTestWriteCInfo.cxx:90
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:71
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
xAODTestWriteCInfo.h
Algorithm to test writing xAOD classes with auxiliary data (cinfo).
Generated on
for ATLAS Offline Software by
1.17.0