ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataWrite
src
xAODTestWrite.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 "
xAODTestWrite.h
"
13
#include "
xAODTestWriteHelper.h
"
14
#include "
DataModelTestDataCommon/CVec.h
"
15
#include "
DataModelTestDataCommon/CVecWithData.h
"
16
#include "
DataModelTestDataCommon/C.h
"
17
#include "
DataModelTestDataCommon/CAuxContainer.h
"
18
#include "
DataModelTestDataCommon/CTrigAuxContainer.h
"
19
#include "
DataModelTestDataWrite/GVec.h
"
20
#include "
DataModelTestDataWrite/G.h
"
21
#include "
DataModelTestDataWrite/GAuxContainer.h
"
22
#include "
AthContainersInterfaces/AuxDataOption.h
"
23
#include "AthLinks/ElementLink.h"
24
#include "
AthenaKernel/errorcheck.h
"
25
26
27
namespace
DMTest
{
28
29
33
StatusCode
xAODTestWrite::initialize
()
34
{
35
ATH_CHECK
(
m_cvecKey
.initialize() );
36
ATH_CHECK
(
m_ctrigKey
.initialize() );
37
ATH_CHECK
(
m_gvecKey
.initialize (
SG::AllowEmpty
) );
38
ATH_CHECK
(
m_cvecWDKey
.initialize() );
39
return
StatusCode::SUCCESS;
40
}
41
42
46
StatusCode
xAODTestWrite::execute
(
const
EventContext& ctx)
const
47
{
48
unsigned
int
count
= ctx.eventID().event_number() + 1;
49
50
SG::ReadHandle<DMTest::CVec>
cvec (
m_cvecKey
, ctx);
51
52
auto
trig_coll = std::make_unique<DMTest::CVec>();
53
auto
trig_store = std::make_unique<DMTest::CTrigAuxContainer>();
54
trig_coll->setStore (trig_store.get());
55
56
static
const
C::Accessor<int> anInt2 (
"anInt2"
);
57
static
const
C::Accessor<ElementLink<DMTest::CVec> > cEL (
"cEL"
);
58
59
//static const C::Decorator<SG::PackedElement<unsigned int> > dpInt1 ("dpInt1");
60
//static const C::Decorator<SG::PackedElement<std::vector<float> > > dpvFloat ("dpvFloat");
61
static
const
C::Decorator<unsigned int> dpInt1 (
"dpInt1"
);
62
static
const
C::Decorator<std::vector<float> > dpvFloat (
"dpvFloat"
);
63
64
for
(
int
i=0; i < 8; i++) {
65
trig_coll->push_back (
new
DMTest::C
);
66
C
& c = *trig_coll->back();
67
c.setAnInt (
count
* 500 + i+1);
68
c.setAFloat (
count
* 600 + (
float
)i*0.1);
69
70
anInt2(c) =
count
*700 + i+1;
71
}
72
73
SG::WriteHandle<DMTest::CVec>
ctrig (
m_ctrigKey
, ctx);
74
CHECK
( ctrig.
record
(std::move (trig_coll), std::move (trig_store)) );
75
76
if
(!
m_gvecKey
.empty()) {
77
auto
gcont = std::make_unique<DMTest::GVec>();
78
auto
gstore = std::make_unique<DMTest::GAuxContainer>();
79
gcont->setStore (gstore.get());
80
81
for
(
int
i=0; i < 10; i++) {
82
gcont->push_back (
new
DMTest::G
);
83
G
& g = *gcont->back();
84
g.setAnInt (
count
* 700 + i+1);
85
g.setgFloat (
count
* 700 + 100 + i+0.5);
86
std::vector<double> v;
87
for
(
int
j=0; j<i; j++) {
88
v.push_back (
count
* 700 + 100*j + i+0.5);
89
}
90
g.setgvFloat (v);
91
}
92
93
SG::WriteHandle<DMTest::GVec>
gvec (
m_gvecKey
, ctx);
94
CHECK
( gvec.
record
(std::move (gcont), std::move (gstore)) );
95
}
96
97
CHECK
(
write_cvec_with_data
(
count
, ctx) );
98
99
return
StatusCode::SUCCESS;
100
}
101
102
106
StatusCode
xAODTestWrite::write_cvec_with_data
(
unsigned
int
count
,
107
const
EventContext& ctx)
const
108
{
109
auto
coll = std::make_unique<DMTest::CVecWithData>();
110
auto
store = std::make_unique<DMTest::CAuxContainer>();
111
coll->setStore (store.get());
112
113
coll->meta1 =
count
+ 1000;
114
for
(
int
i=0; i < 10; i++) {
115
coll->push_back (
new
DMTest::C
);
116
C
& c = *coll->back();
117
c.setAnInt (
count
* 200 + i+1);
118
}
119
120
SG::WriteHandle<DMTest::CVecWithData>
cvecWD (
m_cvecWDKey
, ctx);
121
CHECK
( cvecWD.
record
(std::move (coll), std::move (store)) );
122
123
return
StatusCode::SUCCESS;
124
}
125
126
127
}
// namespace DMTest
128
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.
CTrigAuxContainer.h
Class used for testing xAOD data reading/writing.
CVecWithData.h
Test writing a container with metadata.
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.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GAuxContainer.h
Test for xAOD auto schema evolution.
GVec.h
G.h
Test for xAOD auto schema evolution.
DMTest::xAODTestWrite::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWrite.cxx:33
DMTest::xAODTestWrite::m_ctrigKey
SG::WriteHandleKey< DMTest::CVec > m_ctrigKey
Definition
xAODTestWrite.h:58
DMTest::xAODTestWrite::m_gvecKey
SG::WriteHandleKey< DMTest::GVec > m_gvecKey
Definition
xAODTestWrite.h:60
DMTest::xAODTestWrite::m_cvecKey
SG::ReadHandleKey< DMTest::CVec > m_cvecKey
Definition
xAODTestWrite.h:56
DMTest::xAODTestWrite::write_cvec_with_data
StatusCode write_cvec_with_data(unsigned int count, const EventContext &ctx) const
Test writing container with additional data.
Definition
xAODTestWrite.cxx:106
DMTest::xAODTestWrite::m_cvecWDKey
SG::WriteHandleKey< DMTest::CVecWithData > m_cvecWDKey
Definition
xAODTestWrite.h:62
DMTest::xAODTestWrite::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWrite.cxx:46
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.
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
DMTest::G
G_v1 G
Definition
DataModelTestDataRead/DataModelTestDataRead/G.h:26
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAODTestWriteHelper.h
Test recording ViewVector w/o having CLASS_DEF visible in compilation unit.
xAODTestWrite.h
Algorithm to test writing xAOD classes with auxiliary data.
Generated on
for ATLAS Offline Software by
1.17.0