Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
14 //<<<<<< INCLUDES >>>>>>
15 
16 #include "EventInfoWriter.h"
17 
18 // Event includes
20 
21 // Constructor with parameters:
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 
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 
123 StatusCode
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 }
EventInfoWriter::m_removeDummyTags
BooleanProperty m_removeDummyTags
For testing only: remove input dummy tags.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:80
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
EventInfoWriter::m_createDummyTags
BooleanProperty m_createDummyTags
For testing only: add in dummy tags.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:77
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ITagInfoMgr.h
EventInfoWriter::m_tagInfoMgr
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Access to the TagInfoMgr.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:87
EventInfoWriter::m_setDummyTags
bool m_setDummyTags
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:92
EventInfoWriter::execute
virtual StatusCode execute() override
Algorithm execute once per event.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:64
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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::fillTagInfo
StatusCode fillTagInfo()
Add in tags to TagInfoMgr.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:124
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EventInfoWriter::finalize
virtual StatusCode finalize() override
Algorithm finalize at end of job.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:115
EventInfoWriter::EventInfoWriter
EventInfoWriter()
Avoid use of default constructor.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
EventInfoWriter.h
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EventInfoWriter::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.cxx:29
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
EventInfoWriter::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
Definition: AtlasTest/DatabaseTest/AthenaPoolTest/src/EventInfoWriter.h:90