ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
AtlasTest
DatabaseTest
AthenaPoolTest
src
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
13
14
//<<<<<< INCLUDES >>>>>>
15
16
#include "
EventInfoWriter.h
"
17
18
// Event includes
19
#include "
EventInfoMgt/ITagInfoMgr.h
"
20
21
// Constructor with parameters:
22
EventInfoWriter::EventInfoWriter
(
const
std::string &name,
23
ISvcLocator *pSvcLocator) :
24
AthAlgorithm
(name,pSvcLocator)
25
{
26
}
27
28
// Initialize method:
29
StatusCode
EventInfoWriter::initialize
()
30
{
31
// Get the messaging service, print where you are
32
ATH_MSG_DEBUG
(
"EventInfoWriter::initialize()"
);
33
34
ATH_MSG_DEBUG
(
"CreateDummyTags "
<<
m_createDummyTags
);
35
ATH_MSG_DEBUG
(
"RemoveDummyTags "
<<
m_removeDummyTags
);
36
ATH_MSG_DEBUG
(
"CreateDummyOverrideTags "
<<
m_createDummyOverrideTags
);
37
38
// get TagInfoMgr service
39
ATH_CHECK
(
m_tagInfoMgr
.retrieve());
40
41
// Insert a dummy tag into the TagInfoMgr
42
if
(
m_tagInfoMgr
->addTag(
"EventInfoWriterTag"
,
"EIW-00-00-01"
).isFailure()) {
43
ATH_MSG_FATAL
(
"Unable to add tag to TagInfoMgr !"
);
44
return
StatusCode::FAILURE;
45
}
46
else
{
47
ATH_MSG_DEBUG
(
"Added tag to TagInfoMgr"
);
48
}
49
50
if
(
fillTagInfo
().isFailure()) {
51
ATH_MSG_FATAL
(
"Unable to to call fillTagInfo !"
);
52
return
StatusCode::FAILURE;
53
}
54
else
{
55
ATH_MSG_DEBUG
(
"Called fillTagInfo"
);
56
}
57
58
ATH_CHECK
(
m_eventInfoKey
.initialize());
59
60
return
StatusCode::SUCCESS;
61
}
62
63
// Execute method:
64
StatusCode
EventInfoWriter::execute
(
const
EventContext& ctx)
65
{
66
// Get the messaging service, print where you are
67
ATH_MSG_DEBUG
(
"EventInfoWriter::execute()"
);
68
69
SG::ReadHandle<xAOD::EventInfo>
eventInfo (
m_eventInfoKey
, ctx);
70
if
(!eventInfo.
isValid
()) {
71
ATH_MSG_ERROR
(
" Could not get event info"
);
72
return
StatusCode::FAILURE;
73
}
74
else
{
75
ATH_MSG_DEBUG
(
"Event ID: ["
76
<< eventInfo->runNumber() <<
","
77
<< eventInfo->eventNumber() <<
":"
78
<< eventInfo->timeStamp() <<
"] "
79
);
80
}
81
82
// Set new dummy tags only at the first event of run 2
83
if
(!
m_setDummyTags
&& eventInfo->runNumber() == 2 &&
m_createDummyOverrideTags
) {
84
m_setDummyTags
=
true
;
85
ATH_MSG_DEBUG
(
"Create dummy tags, A2-D2"
);
86
// New/different tags
87
if
(
m_tagInfoMgr
->addTag(
"TagA1"
,
"A2"
).isFailure()) {
88
ATH_MSG_WARNING
(
"TagA1 NOT added"
);
89
}
90
if
(
m_tagInfoMgr
->addTag(
"TagB1"
,
"B2"
).isFailure()) {
91
ATH_MSG_WARNING
(
"TagB1 NOT added"
);
92
}
93
if
(
m_tagInfoMgr
->addTag(
"TagC1"
,
"C2"
).isFailure()) {
94
ATH_MSG_WARNING
(
"TagC1 NOT added"
);
95
}
96
if
(
m_tagInfoMgr
->addTag(
"TagD1"
,
"D2"
).isFailure()) {
97
ATH_MSG_WARNING
(
"TagD1 NOT added"
);
98
}
99
}
100
101
// Dump out Tags
102
ATH_MSG_DEBUG
(
"Tags from TagInfoMgr:"
);
103
MsgStream log(msgSvc(), name());
104
m_tagInfoMgr
->printTags(log);
105
106
// Print out current Release version
107
std::string releaseVersion =
m_tagInfoMgr
->findTag(
"AtlasRelease"
);
108
ATH_MSG_DEBUG
(
"Found Release version from TagInfoMgr: "
<< releaseVersion);
109
110
return
StatusCode::SUCCESS;
111
}
112
113
114
// Finalize method:
115
StatusCode
EventInfoWriter::finalize
()
116
{
117
// Get the messaging service, print where you are
118
ATH_MSG_DEBUG
(
"EventInfoWriter::finalize()"
);
119
120
return
StatusCode::SUCCESS;
121
}
122
123
StatusCode
124
EventInfoWriter::fillTagInfo
()
125
{
126
127
// Get the messaging service, print where you are
128
ATH_MSG_DEBUG
(
"EventInfoWriter::fillTagInfo()"
);
129
130
//
131
// For tests, add in dummy tags
132
//
133
if
(
m_createDummyTags
) {
134
ATH_MSG_DEBUG
(
"Create dummy tags, A1-D1"
);
135
// New/different tags
136
if
(
m_tagInfoMgr
->addTag(
"TagA1"
,
"A1"
).isFailure()) {
137
ATH_MSG_WARNING
(
"TagA1 NOT added"
);
138
}
139
if
(
m_tagInfoMgr
->addTag(
"TagB1"
,
"B1"
).isFailure()) {
140
ATH_MSG_WARNING
(
"TagB1 NOT added"
);
141
}
142
if
(
m_tagInfoMgr
->addTag(
"TagC1"
,
"C1"
).isFailure()) {
143
ATH_MSG_WARNING
(
"TagC1 NOT added"
);
144
}
145
if
(
m_tagInfoMgr
->addTag(
"TagD1"
,
"D1"
).isFailure()) {
146
ATH_MSG_WARNING
(
"TagD1 NOT added"
);
147
}
148
}
149
150
// Remove incoming dummy tag
151
if
(
m_removeDummyTags
) {
152
ATH_MSG_DEBUG
(
"Create dummy tags, A1-D1"
);
153
if
(
m_tagInfoMgr
->removeTagFromInput(
"TagC1"
).isFailure()) {
154
ATH_MSG_WARNING
(
"TagC1 NOT removed"
);
155
}
156
}
157
158
return
StatusCode::SUCCESS;
159
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
EventInfoWriter.h
Test Algorithm for checking TagInfoMgr and the storing of geometry and conditions tags in EventInfo,...
ITagInfoMgr.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
EventInfoWriter::m_setDummyTags
bool m_setDummyTags
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:92
EventInfoWriter::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:29
EventInfoWriter::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:90
EventInfoWriter::m_createDummyOverrideTags
BooleanProperty m_createDummyOverrideTags
For testing only: add in dummy tags which may override existing tags.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:84
EventInfoWriter::m_createDummyTags
BooleanProperty m_createDummyTags
For testing only: add in dummy tags.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:77
EventInfoWriter::fillTagInfo
StatusCode fillTagInfo()
Add in tags to TagInfoMgr.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:124
EventInfoWriter::m_tagInfoMgr
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Access to the TagInfoMgr.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:87
EventInfoWriter::EventInfoWriter
EventInfoWriter()
Avoid use of default constructor.
EventInfoWriter::m_removeDummyTags
BooleanProperty m_removeDummyTags
For testing only: remove input dummy tags.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:80
EventInfoWriter::finalize
virtual StatusCode finalize() override
Algorithm finalize at end of job.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:115
EventInfoWriter::execute
virtual StatusCode execute(const EventContext &ctx) override
Algorithm execute once per event.
Definition
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:64
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Generated on
for ATLAS Offline Software by
1.17.0