ATLAS Offline Software
TagInfoMgr.h
Go to the documentation of this file.
1 //Dear emacs, this is -*-c++-*-
2 /*
3  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #ifndef EVENTINFOMGT_TAGINFOMGR_H
7 #define EVENTINFOMGT_TAGINFOMGR_H
8 
17 //<<<<<< INCLUDES >>>>>>
18 
21 #include "GaudiKernel/Service.h"
22 #include "GaudiKernel/ServiceHandle.h"
23 #include "GaudiKernel/ToolHandle.h"
24 #include "AthenaKernel/IOVRange.h"
25 #include "AthenaKernel/IIOVDbSvc.h"
26 #include "GaudiKernel/MsgStream.h"
27 #include "EventInfo/TagInfo.h"
29 
30 #include <map>
31 #include <set>
32 #include <shared_mutex>
33 
34 //<<<<<< PUBLIC TYPES >>>>>>
35 
36 class StoreGateSvc;
38 
39 //<<<<<< CLASS DECLARATIONS >>>>>>
40 
67 class TagInfoMgr : virtual public AthService,
68  virtual public ITagInfoMgr,
69  virtual public IIncidentListener
70 {
71 public:
72 
74  TagInfoMgr(const std::string &name,ISvcLocator *pSvcLocator);
75  ~TagInfoMgr();
76 
78 
79  virtual StatusCode initialize() override;
80  virtual StatusCode start() override;
81  virtual StatusCode finalize() override;
82 
84  virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ) override;
86 
88 
89  virtual StatusCode addTag(const std::string& tagName,
91  const std::string& tagValue) override;
92 
95  virtual StatusCode removeTagFromInput(const std::string& tagName) override;
96 
98  virtual std::string findTag(const std::string & name) const override final;
99 
101  virtual std::string findInputTag(const std::string& name) const override final;
102 
104  virtual NameTagPairVec getInputTags() const override final;
105 
107  virtual std::string dumpTagInfoToStr() const override final;
108 
110  virtual void printTags(MsgStream& log) const override final;
111 
113  virtual void addListener(Listener* listener) override final;
114 
116  virtual void removeListener(Listener* listener) override final;
118 
120 
121  void handle(const Incident& incident) override final;
122 
125 
127  void notifyListeners() const;
129 
130 
132  // Private methods:
134 private:
136  template <class TYPE> class SvcFactory;
137  friend class SvcFactory<TagInfoMgr>;
138 
142  StatusCode getRunNumber (unsigned int& runNumber);
143 
145  // Private data:
147 private:
148 
149 
151 
152  StatusCode fillTagInfo(const CondAttrListCollection* tagInfoCond);
153  StatusCode fillMetaData(const CondAttrListCollection* tagInfoCond);
155 
157  Gaudi::Property<std::map<std::string,std::string> >
158  m_extraTagValuePairs { this, "ExtraTagValuePairs", {}, "key/value pairs to be added", "mapMergeNoReplace<T,T>" };
159 
161  std::map<std::string,std::string> m_extraTagValuePairsViaInterface;
162 
164  std::set<std::string> m_tagsToBeRemoved;
165 
167  ServiceHandle<StoreGateSvc> m_storeGate { this, "StoreGateSvc", "StoreGateSvc" };
168 
170  ServiceHandle<StoreGateSvc> m_detStore { this, "DetectorStore", "DetectorStore" };
171 
173  ServiceHandle<IIOVDbSvc> m_iovDbSvc { this, "IOVDbSvc", "IOVDbSvc" };
174 
176  PublicToolHandle<IIOVDbMetaDataTool> m_metaDataTool { this, "IOVDbMetaDataTool", "IOVDbMetaDataTool" };
177 
179  bool m_isFirstBeginRun { true };
180 
182  EventIDBase::number_type m_conditionsRun { EventIDBase::UNDEFNUM };
183 
185  EventIDBase::number_type m_currentRun { EventIDBase::UNDEFNUM };
186 
189 
192 
194  std::set< Listener* > m_listeners;
195 
197  mutable std::shared_mutex m_mutex ATLAS_THREAD_SAFE;
198 };
199 
200 
201 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>>
202 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
203 
204 #endif // EVENTINFOMGT_TAGINFOMGR_H
TagInfoMgr::addListener
virtual void addListener(Listener *listener) override final
Add a Listener to the notification list for TagInfo changes.
Definition: TagInfoMgr.cxx:709
TagInfoMgr::start
virtual StatusCode start() override
Definition: TagInfoMgr.cxx:96
TagInfoMgr::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
The event store.
Definition: TagInfoMgr.h:167
TagInfoMgr::findTag
virtual std::string findTag(const std::string &name) const override final
Find tag by name, return by value.
Definition: TagInfoMgr.cxx:666
TagInfoMgr::addTag
virtual StatusCode addTag(const std::string &tagName, const std::string &tagValue) override
Method to allow clients add in tags as: tag name, tag value.
Definition: TagInfoMgr.cxx:643
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
TagInfoMgr::~TagInfoMgr
~TagInfoMgr()
Definition: TagInfoMgr.cxx:46
IOVRange.h
Validity Range object. Holds two IOVTime instances (start and stop)
TagInfoMgr::getInputTags
virtual NameTagPairVec getInputTags() const override final
Return a vector with all current input tags.
Definition: TagInfoMgr.cxx:685
TagInfoMgr::removeListener
virtual void removeListener(Listener *listener) override final
Remove a Listener from the notification list for TagInfo changes.
Definition: TagInfoMgr.cxx:716
ITagInfoMgr.h
TagInfoMgr::m_conditionsRun
EventIDBase::number_type m_conditionsRun
conditionsRun from the first BeginRun incident (HLT)
Definition: TagInfoMgr.h:182
TagInfoMgr::fillMetaData
StatusCode fillMetaData(const CondAttrListCollection *tagInfoCond)
Definition: TagInfoMgr.cxx:296
TagInfoMgr::m_extraTagValuePairsViaInterface
std::map< std::string, std::string > m_extraTagValuePairsViaInterface
Extra tags/values pairs added in via interface.
Definition: TagInfoMgr.h:161
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
TagInfoMgr::TagInfoMgr
TagInfoMgr(const TagInfoMgr &)
IIOVDbSvc.h
Abstract interface to IOVDbSvc to access IOVRange and tag information.
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
TagInfoMgr::updateTagInfo
StatusCode updateTagInfo()
Update Tags when input tags (/TagInfo in-file metadata) change.
Definition: TagInfoMgr.cxx:594
TagInfoMgr::finalize
virtual StatusCode finalize() override
Definition: TagInfoMgr.cxx:103
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
TagInfoMgr::m_currentRun
EventIDBase::number_type m_currentRun
current run number from BeginRun incident
Definition: TagInfoMgr.h:185
TagInfoMgr::handle
void handle(const Incident &incident) override final
Definition: TagInfoMgr.cxx:469
TagInfo
This class contains the list of currently valid tags for detector description - GeoModel and IOV/Cond...
Definition: TagInfo.h:41
ITagInfoMgr::Listener
Listener interface class that client who want to be notified about TagInfo update should implement (a...
Definition: ITagInfoMgr.h:69
ITagInfoMgr::NameTagPairVec
std::vector< NameTagPair > NameTagPairVec
Definition: ITagInfoMgr.h:63
TagInfoMgr::printTags
virtual void printTags(MsgStream &log) const override final
Printout method.
Definition: TagInfoMgr.cxx:701
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthService
Definition: AthService.h:32
TagInfoMgr
This is a Athena service which manages detector description tag information. It maintains a TagInfo o...
Definition: TagInfoMgr.h:70
TagInfoMgr::m_tagInfo
TagInfo m_tagInfo
The Tags.
Definition: TagInfoMgr.h:191
TagInfoMgr::m_extraTagValuePairs
Gaudi::Property< std::map< std::string, std::string > > m_extraTagValuePairs
Extra tags/values pairs added in my jobOptions.
Definition: TagInfoMgr.h:158
TagInfoMgr::m_isFirstBeginRun
bool m_isFirstBeginRun
Flag to identify the first BeginRun incident.
Definition: TagInfoMgr.h:179
TagInfoMgr::ATLAS_THREAD_SAFE
std::shared_mutex m_mutex ATLAS_THREAD_SAFE
mutex to protect internal data in MT
Definition: TagInfoMgr.h:197
TagInfoMgr::dumpTagInfoToStr
virtual std::string dumpTagInfoToStr() const override final
Dump the content of the current TagInfo to std::string for debug.
Definition: TagInfoMgr.cxx:693
TagInfoMgr::m_lastIOVRange
IOVRange m_lastIOVRange
IOVRange of last TagInfo added to the file meta data.
Definition: TagInfoMgr.h:188
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
TagInfoMgr::m_listeners
std::set< Listener * > m_listeners
List of listeners notified when the TagInfo changed.
Definition: TagInfoMgr.h:194
TagInfoMgr::SvcFactory
Allow the factory class access to the constructor.
Definition: TagInfoMgr.h:136
TagInfoMgr::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
The detector store.
Definition: TagInfoMgr.h:170
TagInfoMgr::removeTagFromInput
virtual StatusCode removeTagFromInput(const std::string &tagName) override
Method to allow clients to remove a tag which may have come in on the input.
Definition: TagInfoMgr.cxx:656
TagInfo.h
This class contains the list of currently valid tags for detector description - GeoModel and IOV/Cond...
TagInfoMgr::getRunNumber
StatusCode getRunNumber(unsigned int &runNumber)
Definition: TagInfoMgr.cxx:407
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
TagInfoMgr::notifyListeners
void notifyListeners() const
Notify all listeners that the Tags were updated.
Definition: TagInfoMgr.cxx:579
TagInfoMgr::m_metaDataTool
PublicToolHandle< IIOVDbMetaDataTool > m_metaDataTool
Access to iov meta data tool.
Definition: TagInfoMgr.h:176
TagInfoMgr::fillTagInfo
StatusCode fillTagInfo(const CondAttrListCollection *tagInfoCond)
Definition: TagInfoMgr.cxx:111
ITagInfoMgr
This is a Athena service which manages detector description tag information. It maintains a TagInfo o...
Definition: ITagInfoMgr.h:58
TagInfoMgr::m_iovDbSvc
ServiceHandle< IIOVDbSvc > m_iovDbSvc
Access to IOVDbSvc interface - used to register callback.
Definition: TagInfoMgr.h:173
TagInfoMgr::initialize
virtual StatusCode initialize() override
Definition: TagInfoMgr.cxx:65
TagInfoMgr::findInputTag
virtual std::string findInputTag(const std::string &name) const override final
Find tag by its name - for input tags, return by value.
Definition: TagInfoMgr.cxx:677
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AthService.h
TagInfoMgr::m_tagsToBeRemoved
std::set< std::string > m_tagsToBeRemoved
Extra tags to be removed.
Definition: TagInfoMgr.h:164
IIOVDbMetaDataTool.h
This is an interface to a tool used to manage the IOV Meta Data for a given object in the MetaData St...
TagInfoMgr::TagInfoMgr
TagInfoMgr()
TagInfoMgr::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Query the interfaces.
Definition: TagInfoMgr.cxx:52
TagInfoMgr::operator=
TagInfoMgr & operator=(const TagInfoMgr &)
ServiceHandle< StoreGateSvc >