ATLAS Offline Software
xAODTestWritePVec.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
3  */
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 
30 namespace DMTest {
31 
32 
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 
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 
SGTest::store
TestStore store
Definition: TestStore.cxx:23
DMTest::P_v1
Class used for testing xAOD data reading/writing with packed containers.
Definition: P_v1.h:29
PVec.h
Class used for testing xAOD data reading/writing with packed containers.
CHECK_OPTION
#define CHECK_OPTION(ret)
Definition: xAODTestWritePVec.cxx:21
PAuxContainer.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.
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AuxDataOption.h
Hold information about an option setting request.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
xAODTestWritePVec.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DMTest::xAODTestWritePVec::execute
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
Definition: xAODTestWritePVec.cxx:46
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
pvec
std::array< fp_t, 2 > pvec
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
Decorator.h
Helper class to provide type-safe access to aux data.
DMTest::xAODTestWritePVec::m_pvecKey
SG::WriteHandleKey< DMTest::PVec > m_pvecKey
Definition: xAODTestWritePVec.h:49
DMTest
Definition: B.h:23