ATLAS Offline Software
EventInfoWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  m_createDummyTags(false),
26  m_removeDummyTags(false),
27  m_createDummyOverrideTags(false),
28  m_tagInfoMgr(nullptr)
29 {
30  declareProperty("CreateDummyTags", m_createDummyTags);
31  declareProperty("RemoveDummyTags", m_removeDummyTags);
32  declareProperty("CreateDummyOverrideTags", m_createDummyOverrideTags);
33 }
34 
35 // Initialize method:
37 {
38  // Get the messaging service, print where you are
39  ATH_MSG_DEBUG("EventInfoWriter::initialize()");
40 
41  ATH_MSG_DEBUG("CreateDummyTags " << m_createDummyTags);
42  ATH_MSG_DEBUG("RemoveDummyTags " << m_removeDummyTags);
43  ATH_MSG_DEBUG("CreateDummyOverrideTags " << m_createDummyOverrideTags);
44 
45 
46  // get TagInfoMgr service
47  if (service("TagInfoMgr", m_tagInfoMgr).isFailure()) {
48  ATH_MSG_FATAL("TagInfoMgr service not found !");
49  return StatusCode::FAILURE;
50  }
51 
52  // Insert a dummy tag into the TagInfoMgr
53  if (m_tagInfoMgr->addTag("EventInfoWriterTag", "EIW-00-00-01").isFailure()) {
54  ATH_MSG_FATAL("Unable to add tag to TagInfoMgr !");
55  return StatusCode::FAILURE;
56  }
57  else {
58  ATH_MSG_DEBUG("Added tag to TagInfoMgr");
59  }
60 
61  if (fillTagInfo().isFailure()) {
62  ATH_MSG_FATAL("Unable to to call fillTagInfo !");
63  return StatusCode::FAILURE;
64  }
65  else {
66  ATH_MSG_DEBUG("Called fillTagInfo");
67  }
68 
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 // Execute method:
76 {
77  // Get the messaging service, print where you are
78  ATH_MSG_DEBUG("EventInfoWriter::execute()");
79 
80  SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey, getContext());
81  if(!eventInfo.isValid()) {
82  ATH_MSG_ERROR(" Could not get event info");
83  return StatusCode::FAILURE;
84  }
85  else {
86  ATH_MSG_DEBUG("Event ID: ["
87  << eventInfo->runNumber() << ","
88  << eventInfo->eventNumber() << ":"
89  << eventInfo->timeStamp() << "] "
90  );
91  }
92 
93  // Set new dummy tags only at the first event of run 2
94  if (!m_setDummyTags && eventInfo->runNumber() == 2 && m_createDummyOverrideTags) {
95  m_setDummyTags = true;
96  ATH_MSG_DEBUG("Create dummy tags, A2-D2");
97  // New/different tags
98  if (m_tagInfoMgr->addTag("TagA1", "A2").isFailure()) {
99  ATH_MSG_WARNING("TagA1 NOT added");
100  }
101  if (m_tagInfoMgr->addTag("TagB1", "B2").isFailure()) {
102  ATH_MSG_WARNING("TagB1 NOT added");
103  }
104  if (m_tagInfoMgr->addTag("TagC1", "C2").isFailure()) {
105  ATH_MSG_WARNING("TagC1 NOT added");
106  }
107  if (m_tagInfoMgr->addTag("TagD1", "D2").isFailure()) {
108  ATH_MSG_WARNING("TagD1 NOT added");
109  }
110  }
111 
112  // Dump out Tags
113  ATH_MSG_DEBUG("Tags from TagInfoMgr:");
114  MsgStream log(msgSvc(), name());
116 
117  // Print out current Release version
118  std::string releaseVersion = m_tagInfoMgr->findTag("AtlasRelease");
119  ATH_MSG_DEBUG("Found Release version from TagInfoMgr: " << releaseVersion);
120 
121  return StatusCode::SUCCESS;
122 }
123 
124 
125 // Finalize method:
127 {
128  // Get the messaging service, print where you are
129  ATH_MSG_DEBUG("EventInfoWriter::finalize()");
130 
131  return StatusCode::SUCCESS;
132 }
133 
134 StatusCode
136 {
137 
138  // Get the messaging service, print where you are
139  ATH_MSG_DEBUG("EventInfoWriter::fillTagInfo()");
140 
141  //
142  // For tests, add in dummy tags
143  //
144  if(m_createDummyTags) {
145  ATH_MSG_DEBUG("Create dummy tags, A1-D1");
146  // New/different tags
147  if (m_tagInfoMgr->addTag("TagA1", "A1").isFailure()) {
148  ATH_MSG_WARNING("TagA1 NOT added");
149  }
150  if (m_tagInfoMgr->addTag("TagB1", "B1").isFailure()) {
151  ATH_MSG_WARNING("TagB1 NOT added");
152  }
153  if (m_tagInfoMgr->addTag("TagC1", "C1").isFailure()) {
154  ATH_MSG_WARNING("TagC1 NOT added");
155  }
156  if (m_tagInfoMgr->addTag("TagD1", "D1").isFailure()) {
157  ATH_MSG_WARNING("TagD1 NOT added");
158  }
159  }
160 
161  // Remove incoming dummy tag
162  if (m_removeDummyTags) {
163  ATH_MSG_DEBUG("Create dummy tags, A1-D1");
164  if (m_tagInfoMgr->removeTagFromInput("TagC1").isFailure()) {
165  ATH_MSG_WARNING("TagC1 NOT removed");
166  }
167  }
168 
169  return StatusCode::SUCCESS;
170 }
EventInfoWriter::m_removeDummyTags
BooleanProperty m_removeDummyTags
For testing only: remove input dummy tags.
Definition: EventInfoWriter.h:80
ITagInfoMgr::findTag
virtual std::string findTag(const std::string &name) const =0
Find tag by its name, return by value - empty string if not found.
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: EventInfoWriter.h:77
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ITagInfoMgr.h
ITagInfoMgr::removeTagFromInput
virtual StatusCode removeTagFromInput(const std::string &tagName)=0
Method to allow clients to remove a tag which may have come in on the input.
ITagInfoMgr::addTag
virtual StatusCode addTag(const std::string &tagName, const std::string &tagValue)=0
Method to allow clients to add in tags as: tag name, tag value.
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
EventInfoWriter::m_setDummyTags
bool m_setDummyTags
Definition: EventInfoWriter.h:92
EventInfoWriter::execute
virtual StatusCode execute() override
Algorithm execute once per event.
Definition: EventInfoWriter.cxx:75
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: EventInfoWriter.h:84
EventInfoWriter::fillTagInfo
StatusCode fillTagInfo()
Add in tags to TagInfoMgr.
Definition: EventInfoWriter.cxx:135
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: EventInfoWriter.cxx:126
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
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfoWriter::m_tagInfoMgr
ITagInfoMgr * m_tagInfoMgr
Access to the TagInfoMgr.
Definition: EventInfoWriter.h:87
ITagInfoMgr::printTags
virtual void printTags(MsgStream &log) const =0
Printout method.
EventInfoWriter::initialize
virtual StatusCode initialize() override
Algorithm initialize at begin of job.
Definition: EventInfoWriter.cxx:36
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::EventInfo_v1::timeStamp
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
EventInfoWriter::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG key for Event Info.
Definition: EventInfoWriter.h:90
EventInfoWriter.h
Test Algorithm for checking TagInfoMgr and the storing of geometry and conditions tags in EventInfo,...