ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
DataModelTest
DataModelTestDataCommon
src
xAODTestWritePVec.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 "
xAODTestWritePVec.h
"
13
#include "
DataModelTestDataCommon/PVec.h
"
14
#include "
DataModelTestDataCommon/P.h
"
15
#include "
DataModelTestDataCommon/PAuxContainer.h
"
16
#include "
AthContainersInterfaces/AuxDataOption.h
"
17
#include "
AthContainers/Decorator.h
"
18
#include "
AthenaKernel/errorcheck.h
"
19
20
21
#define CHECK_OPTION(ret) \
22
do { \
23
if (!ret) { \
24
ATH_MSG_ERROR("setOption failed"); \
25
return StatusCode::FAILURE; \
26
} \
27
} while(0)
28
29
30
namespace
DMTest
{
31
32
36
StatusCode
xAODTestWritePVec::initialize
()
37
{
38
ATH_CHECK
(
m_pvecKey
.initialize() );
39
return
StatusCode::SUCCESS;
40
}
41
42
46
StatusCode
xAODTestWritePVec::execute
(
const
EventContext& ctx)
const
47
{
48
unsigned
int
count
= ctx.eventID().event_number() + 1;
49
50
auto
coll = std::make_unique<DMTest::PVec>();
51
auto
store = std::make_unique<DMTest::PAuxContainer>();
52
coll->setStore (store.get());
53
54
const
static
SG::Decorator<unsigned int>
dpInt1 (
"dpInt1"
);
55
const
static
SG::Decorator<std::vector<float>
> dpvFloat (
"dpvFloat"
);
56
57
int
nent = 10;
58
if
(
count
== 5) nent = 0;
59
for
(
int
i=0; i < nent; i++) {
60
coll->push_back (
new
DMTest::P
);
61
P
& p = *coll->back();
62
p.setPInt (
count
* 500 + i+1);
63
p.setPFloat (i + (
float
)
count
* 0.01);
64
65
std::vector<int> pvi;
66
for
(
int
j=0; j<i; j++)
67
pvi.push_back (j + i*10 +
count
*100 - 500);
68
p.setPVInt (pvi);
69
70
std::vector<float> pvf;
71
for
(
int
j=0; j<i; j++)
72
pvf.push_back ((
float
)j*0.1 + (
float
)i*0.01 + (
float
)
count
*0.001 - 0.5);
73
p.setPVFloat (std::move (pvf));
74
75
dpInt1(p) =
count
*50 + i+1;
76
//cEL(c).toIndexedElement (*coll, 9-i);
77
78
pvf.clear();
79
for
(
int
j=0; j<i; j++)
80
pvf.push_back ((
float
)i*0.1 + (
float
)
count
*0.01 + (
float
)j*0.001);
81
dpvFloat(p) = std::move(pvf);
82
}
83
84
SG::WriteHandle<DMTest::PVec>
pvec
(
m_pvecKey
, ctx);
85
CHECK
(
pvec
.record (std::move(coll), std::move(store)) );
86
87
CHECK_OPTION
(
pvec
->setOption (
"dpInt1"
,
SG::AuxDataOption
(
"nbits"
, 13)) );
88
CHECK_OPTION
(
pvec
->setOption (
"dpvFloat"
,
SG::AuxDataOption
(
"nbits"
, 13)) );
89
CHECK_OPTION
(
pvec
->setOption (
"dpvFloat"
,
SG::AuxDataOption
(
"signed"
, 0)));
90
CHECK_OPTION
(
pvec
->setOption (
"dpvFloat"
,
SG::AuxDataOption
(
"nmantissa"
, 13)) );
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
AuxDataOption.h
Hold information about an option setting request.
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
Decorator.h
Helper class to provide type-safe access to aux data.
pvec
std::array< fp_t, 2 > pvec
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
PAuxContainer.h
Class used for testing xAOD data reading/writing with packed containers.
CHECK_OPTION
#define CHECK_OPTION(ret)
Definition
PAuxContainer_v1.cxx:17
PVec.h
Class used for testing xAOD data reading/writing with packed containers.
P.h
Class used for testing xAOD data reading/writing with packed containers.
DMTest::xAODTestWritePVec::m_pvecKey
SG::WriteHandleKey< DMTest::PVec > m_pvecKey
Definition
xAODTestWritePVec.h:49
DMTest::xAODTestWritePVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition
xAODTestWritePVec.cxx:46
DMTest::xAODTestWritePVec::initialize
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Definition
xAODTestWritePVec.cxx:36
SG::AuxDataOption
Hold information about an option setting request.
Definition
AuxDataOption.h:37
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
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::P
P_v1 P
Definition
P.h:23
SG::Decorator
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition
AuxElement.h:576
xAODTestWritePVec.h
Generated on
for ATLAS Offline Software by
1.17.0