ATLAS Offline Software
Loading...
Searching...
No Matches
AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14//<<<<<< INCLUDES >>>>>>
15
16#include "EventInfoWriter.h"
17
18// Event includes
20
21// Constructor with parameters:
22EventInfoWriter::EventInfoWriter(const std::string &name,
23 ISvcLocator *pSvcLocator) :
24 AthAlgorithm(name,pSvcLocator)
25{
26}
27
28// Initialize method:
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:
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, getContext());
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:
116{
117 // Get the messaging service, print where you are
118 ATH_MSG_DEBUG("EventInfoWriter::finalize()");
119
120 return StatusCode::SUCCESS;
121}
122
123StatusCode
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 //
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Test Algorithm for checking TagInfoMgr and the storing of geometry and conditions tags in EventInfo,...
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
BooleanProperty m_createDummyOverrideTags
For testing only: add in dummy tags which may override existing tags.
BooleanProperty m_createDummyTags
For testing only: add in dummy tags.
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Access to the TagInfoMgr.
virtual StatusCode execute() override
Algorithm execute once per event.
EventInfoWriter()
Avoid use of default constructor.
BooleanProperty m_removeDummyTags
For testing only: remove input dummy tags.
virtual StatusCode finalize() override
Algorithm finalize at end of job.
virtual bool isValid() override final
Can the handle be successfully dereferenced?