ATLAS Offline Software
Loading...
Searching...
No Matches
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"
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
30namespace DMTest {
31
32
37{
38 ATH_CHECK( m_pvecKey.initialize() );
39 return StatusCode::SUCCESS;
40}
41
42
46StatusCode 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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
Hold information about an option setting request.
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Helper class to provide type-safe access to aux data.
std::array< fp_t, 2 > pvec
Class used for testing xAOD data reading/writing with packed containers.
#define CHECK_OPTION(ret)
Class used for testing xAOD data reading/writing with packed containers.
Class used for testing xAOD data reading/writing with packed containers.
SG::WriteHandleKey< DMTest::PVec > m_pvecKey
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
Hold information about an option setting request.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Definition B.h:23
P_v1 P
Definition P.h:23