ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestWriteCVec.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
xAODTestWriteCVec.h
"
13
#include "
DataModelTestDataCommon/CVec.h
"
14
#include "
DataModelTestDataCommon/C.h
"
15
#include "
DataModelTestDataCommon/CAuxContainer.h
"
16
#include "
AthContainersInterfaces/AuxDataOption.h
"
17
#include "
AthContainers/Accessor.h
"
18
#include "
AthContainers/Decorator.h
"
19
#include "
StoreGate/WriteDecorHandle.h
"
20
#include "AthLinks/ElementLink.h"
21
22
23
namespace
DMTest
{
24
25
31
xAODTestWriteCVec::xAODTestWriteCVec
(
const
std::string &name,
32
ISvcLocator *pSvcLocator)
33
:
AthReentrantAlgorithm
(name, pSvcLocator)
34
{
35
}
36
37
41
StatusCode
xAODTestWriteCVec::initialize
()
42
{
43
ATH_CHECK
(
m_cvecKey
.initialize() );
44
45
if
(
m_cvecDecorKey
.key().empty())
46
m_cvecDecorKey
=
m_cvecKey
.key() +
".dtest"
;
47
ATH_CHECK
(
m_cvecDecorKey
.initialize() );
48
49
return
StatusCode::SUCCESS;
50
}
51
52
56
StatusCode
xAODTestWriteCVec::execute
(
const
EventContext& ctx)
const
57
{
58
unsigned
int
count
= ctx.eventID().event_number() + 1;
59
60
auto
coll = std::make_unique<DMTest::CVec>();
61
auto
store = std::make_unique<DMTest::CAuxContainer>();
62
coll->setStore (store.get());
63
64
const
static
SG::Accessor<int>
anInt2 (
"anInt2"
);
65
const
static
SG::Decorator<int>
dVar1 (
"dVar1"
);
66
const
static
SG::Decorator<int>
dVar2 (
"dVar2"
);
67
const
static
SG::Accessor<ElementLink<DMTest::CVec>
> cEL (
"cEL"
);
68
69
int
nent = 10;
70
if
(
count
== 5) nent = 0;
71
for
(
int
i=0; i < nent; i++) {
72
coll->push_back (
new
DMTest::C
);
73
C
& c = *coll->back();
74
c.setAnInt (
count
* 100 + i+1);
75
c.setAFloat (
count
* 200 + (
float
)i*0.1);
76
77
anInt2(c) =
count
*300 + i+1;
78
dVar1(c) =
count
*450 + i+1;
79
dVar2(c) =
count
*750 + i+1;
80
cEL(c).toIndexedElement (*coll, 9-i);
81
}
82
83
SG::WriteHandle<DMTest::CVec>
cvec (
m_cvecKey
, ctx);
84
CHECK
( cvec.
record
(std::move(coll), std::move(store)) );
85
86
SG::WriteDecorHandle<DMTest::CVec, int>
dtest (
m_cvecDecorKey
, ctx);
87
for
(
int
i=0; i < nent; i++) {
88
dtest (*(*dtest)[i]) = i+123;
89
}
90
91
return
StatusCode::SUCCESS;
92
}
93
94
95
}
// namespace DMTest
96
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
AuxDataOption.h
Hold information about an option setting request.
CAuxContainer.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.
Accessor.h
Helper class to provide type-safe access to aux data.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
Decorator.h
Helper class to provide type-safe access to aux data.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DMTest::xAODTestWriteCVec::m_cvecDecorKey
SG::WriteDecorHandleKey< DMTest::CVec > m_cvecDecorKey
Definition
xAODTestWriteCVec.h:58
DMTest::xAODTestWriteCVec::m_cvecKey
SG::WriteHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWriteCVec.h:56
DMTest::xAODTestWriteCVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWriteCVec.cxx:56
DMTest::xAODTestWriteCVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWriteCVec.cxx:41
DMTest::xAODTestWriteCVec::xAODTestWriteCVec
xAODTestWriteCVec(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
xAODTestWriteCVec.cxx:31
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition
Control/AthContainers/AthContainers/Accessor.h:68
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
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.
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
DMTest::C
C_v1 C
Definition
C.h:26
SG::Decorator
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition
AuxElement.h:576
xAODTestWriteCVec.h
Algorithm to test writing xAOD classes with auxiliary data (cvec).
Generated on
for ATLAS Offline Software by
1.17.0