|
ATLAS Offline Software
|
This is a Athena service which manages detector description tag information. It maintains a TagInfo object in the Detector Store with current tag values.
More...
#include <TagInfoMgr.h>
|
class | SvcFactory< TagInfoMgr > |
| forward declaration More...
|
|
Gaudi::Property< std::map< std::string, std::string > > | m_extraTagValuePairs { this, "ExtraTagValuePairs", {}, "key/value pairs to be added", "mapMergeNoReplace<T,T>" } |
| Extra tags/values pairs added in my jobOptions. More...
|
|
std::map< std::string, std::string > | m_extraTagValuePairsViaInterface |
| Extra tags/values pairs added in via interface. More...
|
|
std::set< std::string > | m_tagsToBeRemoved |
| Extra tags to be removed. More...
|
|
ServiceHandle< StoreGateSvc > | m_storeGate { this, "StoreGateSvc", "StoreGateSvc" } |
| The event store. More...
|
|
ServiceHandle< StoreGateSvc > | m_detStore { this, "DetectorStore", "DetectorStore" } |
| The detector store. More...
|
|
ServiceHandle< IIOVDbSvc > | m_iovDbSvc { this, "IOVDbSvc", "IOVDbSvc" } |
| Access to IOVDbSvc interface - used to register callback. More...
|
|
PublicToolHandle< IIOVDbMetaDataTool > | m_metaDataTool { this, "IOVDbMetaDataTool", "IOVDbMetaDataTool" } |
| Access to iov meta data tool. More...
|
|
bool | m_isFirstBeginRun { true } |
| Flag to identify the first BeginRun incident. More...
|
|
EventIDBase::number_type | m_conditionsRun { EventIDBase::UNDEFNUM } |
| conditionsRun from the first BeginRun incident (HLT) More...
|
|
EventIDBase::number_type | m_currentRun { EventIDBase::UNDEFNUM } |
| current run number from BeginRun incident More...
|
|
IOVRange | m_lastIOVRange { IOVRange(IOVTime(), IOVTime()) } |
| IOVRange of last TagInfo added to the file meta data. More...
|
|
TagInfo | m_tagInfo |
| The Tags. More...
|
|
std::set< Listener * > | m_listeners |
| List of listeners notified when the TagInfo changed. More...
|
|
std::shared_mutex m_mutex | ATLAS_THREAD_SAFE |
| mutex to protect internal data in MT More...
|
|
void | handle (const Incident &incident) override final |
|
StatusCode | updateTagInfo () |
| Update Tags when input tags (/TagInfo in-file metadata) change. More...
|
|
void | notifyListeners () const |
| Notify all listeners that the Tags were updated. More...
|
|
| TagInfoMgr () |
|
| TagInfoMgr (const TagInfoMgr &) |
|
TagInfoMgr & | operator= (const TagInfoMgr &) |
|
StatusCode | getRunNumber (unsigned int &runNumber) |
|
StatusCode | fillTagInfo (const CondAttrListCollection *tagInfoCond) |
|
StatusCode | fillMetaData (const CondAttrListCollection *tagInfoCond) |
|
This is a Athena service which manages detector description tag information. It maintains a TagInfo object in the Detector Store with current tag values.
The tags to fill the TagInfo object may come from a variety of sources: i.e. the tags specified by the GeoModelSvc and IOVDbSvc, or the tags stored in the incoming EventInfo object, or the TagInfo object itself may be in the IOV DB. The TagInfoMgr itself only adds in tags from the incoming event. Others are added by external clients.
The interface provides a 'input' method to allow client to add in their own tags:
virtual StatusCode addTag(const std::string& tagName, const std::string& tagValue) = 0;
The full set of tags in TagInfo are copied each event into EventInfo (specifically EventType) to be written out in the event stream. Currently, the tags are NOT written to the IOV DB via the TagInfoMgr.
Definition at line 67 of file TagInfoMgr.h.
◆ TagInfoMgr() [1/3]
TagInfoMgr::TagInfoMgr |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
pSvcLocator |
|
) |
| |
Constructor with parameters:
Definition at line 42 of file TagInfoMgr.cxx.
43 base_class(
name, pSvcLocator)
◆ ~TagInfoMgr()
TagInfoMgr::~TagInfoMgr |
( |
| ) |
|
◆ TagInfoMgr() [2/3]
TagInfoMgr::TagInfoMgr |
( |
| ) |
|
|
private |
◆ TagInfoMgr() [3/3]
◆ addListener()
void TagInfoMgr::addListener |
( |
Listener * |
listener | ) |
|
|
finaloverridevirtual |
Add a Listener to the notification list for TagInfo changes.
Definition at line 689 of file TagInfoMgr.cxx.
691 std::unique_lock guard(m_mutex);
◆ addTag()
StatusCode TagInfoMgr::addTag |
( |
const std::string & |
tagName, |
|
|
const std::string & |
tagValue |
|
) |
| |
|
overridevirtual |
Method to allow clients add in tags as: tag name, tag value.
Definition at line 623 of file TagInfoMgr.cxx.
626 ATH_MSG_DEBUG(
"addTag - adding name/value pairs: " << tagName <<
" " << tagValue);
627 std::unique_lock guard( m_mutex );
629 return StatusCode::SUCCESS;
◆ dumpTagInfoToStr()
std::string TagInfoMgr::dumpTagInfoToStr |
( |
| ) |
const |
|
finaloverridevirtual |
Dump the content of the current TagInfo to std::string for debug.
Definition at line 673 of file TagInfoMgr.cxx.
675 std::shared_lock guard(m_mutex);
◆ fillMetaData()
Register folder in the IOV Db MetaData
Definition at line 281 of file TagInfoMgr.cxx.
315 ATH_MSG_ERROR(
"fillMetaData: Could not get event info neither via retrieve nor from the EventSelectror");
316 return (StatusCode::FAILURE);
324 ATH_MSG_DEBUG(
"fillMetaData: Adding value/tag pairs to file meta data: ");
325 for (
unsigned int i = 0;
i <
pairs.size(); ++
i) {
333 attrListColl->
add(0, attrList);
342 bool isFirstIOVCheck =
false;
343 if (!
start.isValid() || !
stop.isValid()) {
350 isFirstIOVCheck =
true;
354 if (!isFirstIOVCheck)
start = testTime;
375 if (StatusCode::SUCCESS !=
m_metaDataTool->registerFolder(
"/TagInfo")) {
376 ATH_MSG_ERROR(
"fillMetaData: Unable to register folder for TagInfo with meta data tool ");
377 return StatusCode::FAILURE;
381 if (StatusCode::SUCCESS !=
m_metaDataTool->addPayload(
"/TagInfo", attrListColl)) {
382 ATH_MSG_ERROR(
"fillMetaData: Unable to register folder for TagInfo with meta data tool ");
383 return StatusCode::FAILURE;
386 return StatusCode::SUCCESS;
◆ fillTagInfo()
Definition at line 96 of file TagInfoMgr.cxx.
120 ATH_MSG_DEBUG(
"fillTagInfo: - reading Tags from infile IOV metadata");
125 if (itr != tagInfoCond->
end()) {
127 coral::AttributeList::const_iterator itAttrList = attrList.begin();
128 coral::AttributeList::const_iterator itLast = attrList.end();
129 for (; itAttrList != itLast; ++itAttrList) {
136 const std::string&
name = (*itAttrList).specification().name();
137 const std::string&
value = (*itAttrList).data<std::string>();
149 ATH_MSG_DEBUG(
"fillTagInfo: Did NOT add tag - on remove list: name/tag: "
159 ATH_MSG_WARNING(
"fillTagInfo: Unable to add value/tag to TagInfo as input tag "
162 ATH_MSG_DEBUG(
"fillTagInfo: Added value/tag to TagInfo as input tag "
169 return (StatusCode::FAILURE);
191 ATH_MSG_DEBUG(
"fillTagInfo: Could not find EventInfo - skipping the filling of TagInfo from input EventInfo");
195 << evtH->
event_ID()->run_number() <<
","
196 << evtH->
event_ID()->event_number() <<
":"
197 << evtH->
event_ID()->time_stamp() <<
"] " );
205 ATH_MSG_DEBUG(
"fillTagInfo: EventInfo/EventType has no tags");
207 for (
unsigned int i = 0;
i < pairs1.size(); ++
i) {
219 std::string&
name = pairs1[
i].first;
222 ATH_MSG_ERROR(
"fillTagInfo: Unable to add tag to TagInfo: name/tag "
223 << pairs1[
i].
first <<
" : "
225 return (StatusCode::FAILURE);
227 else ATH_MSG_DEBUG(
"fillTagInfo: Added name/tag to TagInfo "
228 << pairs1[
i].
first <<
" : "
231 ATH_MSG_DEBUG(
"fillTagInfo: Did NOT add tag - on remove list: name/tag: "
232 << pairs1[
i].
first <<
" : "
241 ATH_MSG_ERROR(
"fillTagInfo: Unable to add input tag to TagInfo: name/tag "
242 << pairs1[
i].
first <<
" : "
244 return (StatusCode::FAILURE);
247 ATH_MSG_DEBUG(
"fillTagInfo: Added EventInfo tags to TagInfo current/input");
253 ATH_MSG_DEBUG(
"fillTagInfo: print out tags before adding extra tags");
261 valueTagPairs[tv.first]=tv.second;
264 for (
auto& tv : valueTagPairs) {
265 ATH_MSG_DEBUG(
"fillTagInfo: Adding extra value/tag pair: " << tv.first <<
" " << tv.second);
267 ATH_MSG_WARNING(
"fillTagInfo: Extra value/tag not added to TagInfo ");
275 return StatusCode::SUCCESS;
◆ finalize()
StatusCode TagInfoMgr::finalize |
( |
| ) |
|
|
overridevirtual |
◆ findInputTag()
std::string TagInfoMgr::findInputTag |
( |
const std::string & |
name | ) |
const |
|
finaloverridevirtual |
Find tag by its name - for input tags, return by value.
Definition at line 657 of file TagInfoMgr.cxx.
659 std::shared_lock guard(m_mutex);
◆ findTag()
std::string TagInfoMgr::findTag |
( |
const std::string & |
name | ) |
const |
|
finaloverridevirtual |
Find tag by name, return by value.
Definition at line 646 of file TagInfoMgr.cxx.
648 std::shared_lock guard(m_mutex);
◆ getInputTags()
Return a vector with all current input tags.
Definition at line 665 of file TagInfoMgr.cxx.
667 std::shared_lock guard(m_mutex);
◆ getRunNumber()
StatusCode TagInfoMgr::getRunNumber |
( |
unsigned int & |
runNumber | ) |
|
|
private |
Definition at line 392 of file TagInfoMgr.cxx.
399 ATH_MSG_DEBUG(
"getRunNumber: check if tag is set in jobOpts");
402 SmartIF<IProperty> appMgr(serviceLocator()->service(
"ApplicationMgr"));
405 StringProperty property(
"EvtSel",
"");
407 if (!
sc.isSuccess()) {
408 ATH_MSG_ERROR(
"getRunNumber: unable to get EvtSel: found " << property.value());
409 return StatusCode::FAILURE;
413 SmartIF<IProperty> evtSel(serviceLocator()->service(
eventSelector));
416 BooleanProperty overrideRunNumber = BooleanProperty(
"OverrideRunNumber",
false);
417 sc = evtSel->getProperty(&overrideRunNumber);
418 if (!
sc.isSuccess()) {
421 ATH_MSG_WARNING(
"getRunNumber: unable to get OverrideRunNumber property from EventSelector ");
422 return StatusCode::FAILURE;
424 if (overrideRunNumber.value()) {
425 IntegerProperty runNumberProp = IntegerProperty(
"RunNumber", 0);
426 sc = evtSel->getProperty(&runNumberProp);
427 if (!
sc.isSuccess()) {
428 ATH_MSG_ERROR(
"getRunNumber: unable to get RunNumber from EventSelector: found "
429 << runNumberProp.value());
430 return StatusCode::FAILURE;
440 ATH_MSG_ERROR(
"getRunNumber: OverrideRunNumber from EventSelector is false ");
441 return StatusCode::FAILURE;
443 return StatusCode::SUCCESS;
◆ handle()
void TagInfoMgr::handle |
( |
const Incident & |
incident | ) |
|
|
finaloverride |
This method is called at the both the BeginRun and BeginInputFile incidents:
1) For the first begin run, we retrieve the TagInfo and set up IOVDbSvc so that is can use TagInfo to define its hierarchical tags. The member m_currentRun is saved to be used for the IOV in fillMetaData.
2) Then whenever a new file is opened (BeginInputFile), we use the TagInfo object from the detector store to "re-fill" and overwrite the newly merged TagInfo meta data in the output meta data store. We receive BeginInputFile AFTER the IOVDbMetaDataTool has done this automatic merging, so that we can safely overwrite with the desired TagInfo information for this job/run. As well, if there is a second BeginRun during the processing, here we update m_currentRun and overwrite again the TagInfo in the
meta store with the new run which will just extend the IOV of the TagInfo meta data.
Definition at line 449 of file TagInfoMgr.cxx.
475 ATH_MSG_DEBUG(
"handle: received incident of type " << inc.type()
476 <<
" from " << inc.source());
478 const EventIDBase eventID = inc.context().eventID();
480 if (inc.type() == IncidentType::BeginRun) {
490 << eventID.run_number() <<
","
491 << eventID.lumi_block() <<
":"
492 << eventID.time_stamp() <<
"] ");
517 uint64_t nsTime = eventID.time_stamp()*1000000000LL;
518 nsTime += eventID.time_stamp_ns_offset();
521 if (StatusCode::SUCCESS !=
m_iovDbSvc->signalBeginRun(curTime, inc.context()))
524 throw GaudiException(
"Unable to signal begin run to IOVDbSvc",
"TagInfoMgr::handle", StatusCode::FAILURE );
526 ATH_MSG_DEBUG(
"Signaled begin run to IOVDbSvc " << curTime);
530 throw GaudiException(
"updateTagInfo ERROR:",
"TagInfoMgr::handle", StatusCode::FAILURE );
538 if (
m_iovDbSvc->processTagInfo().isFailure() ) {
539 throw GaudiException(
"iovDbSvc::processTagInfo ERROR",
"TagInfoMgr::handle", StatusCode::FAILURE );
541 ATH_MSG_DEBUG(
"handle: TagInfo successfully processed by IOVDbSvc to register callback");
544 else if ((inc.type() == IncidentType::BeginInputFile || inc.type() == IncidentType::BeginRun)
550 throw GaudiException(
"updateTagInfo ERROR:",
"TagInfoMgr::handle", StatusCode::FAILURE );
◆ initialize()
StatusCode TagInfoMgr::initialize |
( |
| ) |
|
|
overridevirtual |
Definition at line 50 of file TagInfoMgr.cxx.
60 ATH_MSG_DEBUG(
" Value/tag pair: " << tv.first <<
" " << tv.second );
70 incSvc->addListener(
this,
"BeginRun", 100);
75 incSvc->addListener(
this,
"BeginInputFile", 50);
77 return StatusCode::SUCCESS;
◆ notifyListeners()
void TagInfoMgr::notifyListeners |
( |
| ) |
const |
Notify all listeners that the Tags were updated.
Definition at line 559 of file TagInfoMgr.cxx.
563 m_mutex.lock_shared();
565 m_mutex.unlock_shared();
567 for(
auto listener : listeners ) {
568 listener->tagInfoUpdated();
◆ operator=()
◆ printTags()
void TagInfoMgr::printTags |
( |
MsgStream & |
log | ) |
const |
|
finaloverridevirtual |
Printout method.
Definition at line 681 of file TagInfoMgr.cxx.
683 std::shared_lock guard(m_mutex);
◆ removeListener()
void TagInfoMgr::removeListener |
( |
Listener * |
listener | ) |
|
|
finaloverridevirtual |
Remove a Listener from the notification list for TagInfo changes.
Definition at line 696 of file TagInfoMgr.cxx.
698 std::unique_lock guard(m_mutex);
◆ removeTagFromInput()
StatusCode TagInfoMgr::removeTagFromInput |
( |
const std::string & |
tagName | ) |
|
|
overridevirtual |
Method to allow clients to remove a tag which may have come in on the input.
Definition at line 636 of file TagInfoMgr.cxx.
639 ATH_MSG_DEBUG(
"removeTagFromInput - adding tag name to be removed: " << tagName);
640 std::unique_lock guard( m_mutex );
642 return StatusCode::SUCCESS;
◆ start()
StatusCode TagInfoMgr::start |
( |
| ) |
|
|
overridevirtual |
◆ updateTagInfo()
StatusCode TagInfoMgr::updateTagInfo |
( |
| ) |
|
Update Tags when input tags (/TagInfo in-file metadata) change.
Definition at line 574 of file TagInfoMgr.cxx.
585 if (
m_detStore->retrieve( attrListColl,
"/TagInfo" ).isFailure() ) {
586 ATH_MSG_ERROR(
"updateTagInfo: No TagInfo meta data in DetectorStore");
587 return StatusCode::FAILURE ;
590 ATH_MSG_DEBUG(
"updateTagInfo: Retrieved TagInfo meta data from detStore. size " << attrListColl->
size());
594 ATH_MSG_DEBUG(
"updateTagInfo: det store does NOT contain AttrListColl for TagInfo");
601 if (attrListColl && attrListColl->
size() == 0) {
602 ATH_MSG_DEBUG(
"updateTagInfo: /TagInfo empty - do nothing");
604 return StatusCode::SUCCESS;
607 std::unique_lock guard(m_mutex);
609 if (attrListColl)
ATH_MSG_DEBUG(
"updateTagInfo: Filled TagInfo from file meta data ");
610 else ATH_MSG_DEBUG(
"updateTagInfo: Filled TagInfo from input event ");
614 ATH_MSG_DEBUG(
"updateTagInfo: Wrote TagInfo to MetaDataStore ");
616 return StatusCode::SUCCESS;
◆ SvcFactory< TagInfoMgr >
◆ ATLAS_THREAD_SAFE
std::shared_mutex m_mutex TagInfoMgr::ATLAS_THREAD_SAFE |
|
mutableprivate |
mutex to protect internal data in MT
Definition at line 193 of file TagInfoMgr.h.
◆ m_conditionsRun
EventIDBase::number_type TagInfoMgr::m_conditionsRun { EventIDBase::UNDEFNUM } |
|
private |
conditionsRun from the first BeginRun incident (HLT)
Definition at line 178 of file TagInfoMgr.h.
◆ m_currentRun
EventIDBase::number_type TagInfoMgr::m_currentRun { EventIDBase::UNDEFNUM } |
|
private |
current run number from BeginRun incident
Definition at line 181 of file TagInfoMgr.h.
◆ m_detStore
◆ m_extraTagValuePairs
Gaudi::Property<std::map<std::string,std::string> > TagInfoMgr::m_extraTagValuePairs { this, "ExtraTagValuePairs", {}, "key/value pairs to be added", "mapMergeNoReplace<T,T>" } |
|
private |
◆ m_extraTagValuePairsViaInterface
std::map<std::string,std::string> TagInfoMgr::m_extraTagValuePairsViaInterface |
|
private |
Extra tags/values pairs added in via interface.
Definition at line 157 of file TagInfoMgr.h.
◆ m_iovDbSvc
◆ m_isFirstBeginRun
bool TagInfoMgr::m_isFirstBeginRun { true } |
|
private |
Flag to identify the first BeginRun incident.
Definition at line 175 of file TagInfoMgr.h.
◆ m_lastIOVRange
◆ m_listeners
std::set< Listener* > TagInfoMgr::m_listeners |
|
private |
◆ m_metaDataTool
◆ m_storeGate
◆ m_tagInfo
◆ m_tagsToBeRemoved
std::set<std::string> TagInfoMgr::m_tagsToBeRemoved |
|
private |
The documentation for this class was generated from the following files:
const IOVRange & minRange() const
Current minimal IOVRange.
virtual StatusCode start() override
const_iterator end() const
ServiceHandle< StoreGateSvc > m_storeGate
The event store.
void get_detdescr_tags(NameTagPairVec &pairs) const
Access DetDescr tags.
Validity Range object. Holds two IOVTimes (start and stop)
StatusCode addTag(const NameTagPair &pair, bool override=false)
addTag for current tags - returns failure if tag name exists and override == false
void findInputTag(const std::string &name, std::string &tag) const
Find tag by its name - for input tags, return in the reference argument.
EventIDBase::number_type conditionsRun() const
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop
StatusCode addInputTag(const NameTagPair &pair, bool override=false)
addInputTag for input tags - returns failure if tag name exists and override == false
const IOVTime & start() const
bool isInRange(const IOVTime &t) const
void getTags(NameTagPairVec &pairs) const
Fill vector with all current tags.
EventIDBase::number_type m_conditionsRun
conditionsRun from the first BeginRun incident (HLT)
void printTags(MsgStream &log) const
Printout method:
StatusCode fillMetaData(const CondAttrListCollection *tagInfoCond)
std::map< std::string, std::string > m_extraTagValuePairsViaInterface
Extra tags/values pairs added in via interface.
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
std::string str() const
String representation.
void addNewStart(const IOVTime &start)
Add new start time to minRange - make sure that start is >= to new start.
This class is a collection of AttributeLists where each one is associated with a channel number....
StatusCode updateTagInfo()
Update Tags when input tags (/TagInfo in-file metadata) change.
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
const IOVTime & stop() const
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
EventIDBase::number_type m_currentRun
current run number from BeginRun incident
std::pair< std::string, std::string > NameTagPair
This class contains the list of currently valid tags for detector description - GeoModel and IOV/Cond...
std::vector< NameTagPair > NameTagPairVec
::StatusCode StatusCode
StatusCode definition for legacy code.
EventID * event_ID()
the unique identification of the event.
TagInfo m_tagInfo
The Tags.
Gaudi::Property< std::map< std::string, std::string > > m_extraTagValuePairs
Extra tags/values pairs added in my jobOptions.
bool m_isFirstBeginRun
Flag to identify the first BeginRun incident.
void setTimestamp(uint64_t timestamp) noexcept
IOVRange m_lastIOVRange
IOVRange of last TagInfo added to the file meta data.
void getInputTags(NameTagPairVec &pairs) const
Fill reference vector with all current input tags.
std::set< Listener * > m_listeners
List of listeners notified when the TagInfo changed.
This class provides general information about an event. Event information is provided by the accessor...
size_type size() const
number of Chan/AttributeList pairs
ServiceHandle< StoreGateSvc > m_detStore
The detector store.
StatusCode getRunNumber(unsigned int &runNumber)
void notifyListeners() const
Notify all listeners that the Tags were updated.
PublicToolHandle< IIOVDbMetaDataTool > m_metaDataTool
Access to iov meta data tool.
StatusCode fillTagInfo(const CondAttrListCollection *tagInfoCond)
#define ATH_MSG_WARNING(x)
ChanAttrListMap::const_iterator const_iterator
ServiceHandle< IIOVDbSvc > m_iovDbSvc
Access to IOVDbSvc interface - used to register callback.
void setRunEvent(uint32_t run, uint32_t event) noexcept
std::set< std::string > m_tagsToBeRemoved
Extra tags to be removed.
void findTag(const std::string &name, std::string &tag) const
Find tag by its name - for current tags, returning in the reference argument.
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc