ATLAS Offline Software
Loading...
Searching...
No Matches
xAODTestDecor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13
14#include "xAODTestDecor.h"
19
20
21namespace DMTest {
22
23
29xAODTestDecor::xAODTestDecor (const std::string &name,
30 ISvcLocator *pSvcLocator)
31 : AthReentrantAlgorithm (name, pSvcLocator)
32{
33 declareProperty ("ReadPrefix", m_readPrefix);
34 declareProperty ("DecorName", m_decorName = "dInt1");
35 declareProperty ("Offset", m_offset = 0);
36
37 declareProperty ("CVecDecorKey", m_cvecDecorKey);
38 declareProperty ("CInfoDecorKey", m_cinfoDecorKey);
39 declareProperty ("ObjDecorKey", m_objDecorKey);
40 declareProperty ("CTrigDecorKey", m_ctrigDecorKey);
41
42 declareProperty ("DoCVec", m_doCVec = true);
43 declareProperty ("DoCInfo", m_doCInfo = true);
44 declareProperty ("DoCTrig", m_doCTrig = true);
45}
46
47
52{
55 m_objDecorKey = m_readPrefix + "cinfo." + m_decorName + "Base";
57
58 ATH_CHECK( m_eventInfoKey.initialize() );
59 ATH_CHECK( m_cvecDecorKey.initialize (m_doCVec) );
60 ATH_CHECK( m_cinfoDecorKey.initialize (m_doCInfo) );
61 ATH_CHECK( m_objDecorKey.initialize (m_doCInfo) );
62 ATH_CHECK( m_ctrigDecorKey.initialize (m_doCTrig) );
63 return StatusCode::SUCCESS;
64}
65
66
70StatusCode xAODTestDecor::execute (const EventContext& ctx) const
71{
73 unsigned int count = eventInfo->eventNumber() + 1;
74
75 if (m_doCInfo) {
77 if (!cinfoDecor.isPresent()) {
78 ATH_MSG_ERROR( "cinfoDecor.isPresent check fails" );
79 return StatusCode::FAILURE;
80 }
81 cinfoDecor(0) = cinfoDecor->anInt() + (m_offset ? 400 + m_offset : count * 2000);
82
84 objDecor(0) = cinfoDecor->anInt() + (m_offset ? 400 + m_offset : count * 2000) + 1;
85 }
86
87 if (m_doCVec) {
89 if (!cvecDecor.isPresent()) {
90 ATH_MSG_ERROR( "cvecDecor.isPresent check fails" );
91 return StatusCode::FAILURE;
92 }
93 for (const C* celt : *cvecDecor) {
94 cvecDecor(*celt) = celt->anInt() + (m_offset ? m_offset : count*300);
95 }
96 }
97
98 if (m_doCTrig) {
100 if (!ctrigDecor.isPresent()) {
101 ATH_MSG_ERROR( "ctrigDecor.isPresent check fails" );
102 return StatusCode::FAILURE;
103 }
104 for (const C* celt : *ctrigDecor) {
105 ctrigDecor(*celt) = celt->anInt() + (m_offset ? 600 + m_offset : -count*20);
106 }
107 }
108
109 return StatusCode::SUCCESS;
110}
111
112
117{
118 return StatusCode::SUCCESS;
119}
120
121
122} // namespace DMTest
123
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Class used for testing xAOD data reading/writing.
Class used for testing xAOD data reading/writing.
Helpers for checking error return status codes and reporting errors.
Handle class for adding a decoration to an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode finalize() override
Algorithm finalization; called at the end of the job.
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm event processing.
SG::WriteDecorHandleKey< CVec > m_ctrigDecorKey
std::string m_decorName
Parameter: Name of the decoration.
SG::WriteDecorHandleKey< C > m_cinfoDecorKey
SG::WriteDecorHandleKey< CVec > m_cvecDecorKey
virtual StatusCode initialize() override
Algorithm initialization; called at the beginning of the job.
std::string m_readPrefix
Parameter: Prefix for names read from SG.
xAODTestDecor(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
int m_offset
Parameter: Offset to be applied to decoration.
SG::WriteDecorHandleKey< SG::AuxElement > m_objDecorKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Handles for writing decorations.
Handle class for adding a decoration to an object.
bool isPresent() const
Is the referenced container present in SG?
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
C_v1 C
Definition C.h:26
Algorithm to test adding decorations to xAOD types.