![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
19 #include "EventInfo/EventInfo.h"
37 #include "GaudiKernel/IIncidentSvc.h"
38 #include "GaudiKernel/GaudiException.h"
59 return(::AthService::queryInterface(riid, ppvInterface));
61 return StatusCode::SUCCESS;
75 ATH_MSG_DEBUG(
" Value/tag pair: " << tv.first <<
" " << tv.second );
85 incSvc->addListener(
this,
"BeginRun", 100);
90 incSvc->addListener(
this,
"BeginInputFile", 50);
92 return StatusCode::SUCCESS;
99 return StatusCode::SUCCESS;
106 return StatusCode::SUCCESS;
135 ATH_MSG_DEBUG(
"fillTagInfo: - reading Tags from infile IOV metadata");
140 if (itr != tagInfoCond->
end()) {
142 coral::AttributeList::const_iterator itAttrList = attrList.begin();
143 coral::AttributeList::const_iterator itLast = attrList.end();
144 for (; itAttrList != itLast; ++itAttrList) {
151 const std::string&
name = (*itAttrList).specification().name();
152 const std::string&
value = (*itAttrList).data<std::string>();
164 ATH_MSG_DEBUG(
"fillTagInfo: Did NOT add tag - on remove list: name/tag: "
174 ATH_MSG_WARNING(
"fillTagInfo: Unable to add value/tag to TagInfo as input tag "
177 ATH_MSG_DEBUG(
"fillTagInfo: Added value/tag to TagInfo as input tag "
184 return (StatusCode::FAILURE);
206 ATH_MSG_DEBUG(
"fillTagInfo: Could not find EventInfo - skipping the filling of TagInfo from input EventInfo");
210 << evtH->
event_ID()->run_number() <<
","
211 << evtH->
event_ID()->event_number() <<
":"
212 << evtH->
event_ID()->time_stamp() <<
"] " );
220 ATH_MSG_DEBUG(
"fillTagInfo: EventInfo/EventType has no tags");
222 for (
unsigned int i = 0;
i < pairs1.size(); ++
i) {
234 std::string&
name = pairs1[
i].first;
237 ATH_MSG_ERROR(
"fillTagInfo: Unable to add tag to TagInfo: name/tag "
238 << pairs1[
i].
first <<
" : "
240 return (StatusCode::FAILURE);
242 else ATH_MSG_DEBUG(
"fillTagInfo: Added name/tag to TagInfo "
243 << pairs1[
i].
first <<
" : "
246 ATH_MSG_DEBUG(
"fillTagInfo: Did NOT add tag - on remove list: name/tag: "
247 << pairs1[
i].
first <<
" : "
256 ATH_MSG_ERROR(
"fillTagInfo: Unable to add input tag to TagInfo: name/tag "
257 << pairs1[
i].
first <<
" : "
259 return (StatusCode::FAILURE);
262 ATH_MSG_DEBUG(
"fillTagInfo: Added EventInfo tags to TagInfo current/input");
268 ATH_MSG_DEBUG(
"fillTagInfo: print out tags before adding extra tags");
276 valueTagPairs[tv.first]=tv.second;
279 for (
auto& tv : valueTagPairs) {
280 ATH_MSG_DEBUG(
"fillTagInfo: Adding extra value/tag pair: " << tv.first <<
" " << tv.second);
282 ATH_MSG_WARNING(
"fillTagInfo: Extra value/tag not added to TagInfo ");
290 return StatusCode::SUCCESS;
330 ATH_MSG_ERROR(
"fillMetaData: Could not get event info neither via retrieve nor from the EventSelectror");
331 return (StatusCode::FAILURE);
339 ATH_MSG_DEBUG(
"fillMetaData: Adding value/tag pairs to file meta data: ");
340 for (
unsigned int i = 0;
i <
pairs.size(); ++
i) {
348 attrListColl->
add(0, attrList);
357 bool isFirstIOVCheck =
false;
358 if (!
start.isValid() || !
stop.isValid()) {
365 isFirstIOVCheck =
true;
369 if (!isFirstIOVCheck)
start = testTime;
390 if (StatusCode::SUCCESS !=
m_metaDataTool->registerFolder(
"/TagInfo")) {
391 ATH_MSG_ERROR(
"fillMetaData: Unable to register folder for TagInfo with meta data tool ");
392 return StatusCode::FAILURE;
396 if (StatusCode::SUCCESS !=
m_metaDataTool->addPayload(
"/TagInfo", attrListColl)) {
397 ATH_MSG_ERROR(
"fillMetaData: Unable to register folder for TagInfo with meta data tool ");
398 return StatusCode::FAILURE;
401 return StatusCode::SUCCESS;
414 ATH_MSG_DEBUG(
"getRunNumber: check if tag is set in jobOpts");
417 IProperty* propertyServer(0);
418 StatusCode sc = serviceLocator()->service(
"ApplicationMgr", propertyServer);
419 if (
sc != StatusCode::SUCCESS ) {
421 return StatusCode::FAILURE;
423 StringProperty property(
"EvtSel",
"");
424 sc = propertyServer->getProperty(&property);
425 if (!
sc.isSuccess()) {
426 ATH_MSG_ERROR(
"getRunNumber: unable to get EvtSel: found " << property.value());
427 return StatusCode::FAILURE;
432 if (
sc != StatusCode::SUCCESS ) {
434 return StatusCode::FAILURE;
436 BooleanProperty overrideRunNumber = BooleanProperty(
"OverrideRunNumber",
false);
437 sc = propertyServer->getProperty(&overrideRunNumber);
438 if (!
sc.isSuccess()) {
441 ATH_MSG_WARNING(
"getRunNumber: unable to get OverrideRunNumber property from EventSelector ");
442 return StatusCode::FAILURE;
444 if (overrideRunNumber.value()) {
445 IntegerProperty runNumberProp = IntegerProperty(
"RunNumber", 0);
446 sc = propertyServer->getProperty(&runNumberProp);
447 if (!
sc.isSuccess()) {
448 ATH_MSG_ERROR(
"getRunNumber: unable to get RunNumber from EventSelector: found "
449 << runNumberProp.value());
450 return StatusCode::FAILURE;
460 ATH_MSG_ERROR(
"getRunNumber: OverrideRunNumber from EventSelector is false ");
461 return StatusCode::FAILURE;
463 return StatusCode::SUCCESS;
495 ATH_MSG_DEBUG(
"handle: received incident of type " << inc.type()
496 <<
" from " << inc.source());
498 const EventIDBase eventID = inc.context().eventID();
500 if (inc.type() == IncidentType::BeginRun) {
510 << eventID.run_number() <<
","
511 << eventID.lumi_block() <<
":"
512 << eventID.time_stamp() <<
"] ");
537 uint64_t nsTime = eventID.time_stamp()*1000000000LL;
538 nsTime += eventID.time_stamp_ns_offset();
541 if (StatusCode::SUCCESS !=
m_iovDbSvc->signalBeginRun(curTime, inc.context()))
544 throw GaudiException(
"Unable to signal begin run to IOVDbSvc",
"TagInfoMgr::handle", StatusCode::FAILURE );
546 ATH_MSG_DEBUG(
"Signaled begin run to IOVDbSvc " << curTime);
550 throw GaudiException(
"updateTagInfo ERROR:",
"TagInfoMgr::handle", StatusCode::FAILURE );
558 if (
m_iovDbSvc->processTagInfo().isFailure() ) {
559 throw GaudiException(
"iovDbSvc::processTagInfo ERROR",
"TagInfoMgr::handle", StatusCode::FAILURE );
561 ATH_MSG_DEBUG(
"handle: TagInfo successfully processed by IOVDbSvc to register callback");
564 else if ((inc.type() == IncidentType::BeginInputFile || inc.type() == IncidentType::BeginRun)
570 throw GaudiException(
"updateTagInfo ERROR:",
"TagInfoMgr::handle", StatusCode::FAILURE );
583 m_mutex.lock_shared();
585 m_mutex.unlock_shared();
587 for(
auto listener : listeners ) {
588 listener->tagInfoUpdated();
605 if (
m_detStore->retrieve( attrListColl,
"/TagInfo" ).isFailure() ) {
606 ATH_MSG_ERROR(
"updateTagInfo: No TagInfo meta data in DetectorStore");
607 return StatusCode::FAILURE ;
610 ATH_MSG_DEBUG(
"updateTagInfo: Retrieved TagInfo meta data from detStore. size " << attrListColl->
size());
614 ATH_MSG_DEBUG(
"updateTagInfo: det store does NOT contain AttrListColl for TagInfo");
621 if (attrListColl && attrListColl->
size() == 0) {
622 ATH_MSG_DEBUG(
"updateTagInfo: /TagInfo empty - do nothing");
624 return StatusCode::SUCCESS;
627 std::unique_lock guard(m_mutex);
629 if (attrListColl)
ATH_MSG_DEBUG(
"updateTagInfo: Filled TagInfo from file meta data ");
630 else ATH_MSG_DEBUG(
"updateTagInfo: Filled TagInfo from input event ");
634 ATH_MSG_DEBUG(
"updateTagInfo: Wrote TagInfo to MetaDataStore ");
636 return StatusCode::SUCCESS;
646 ATH_MSG_DEBUG(
"addTag - adding name/value pairs: " << tagName <<
" " << tagValue);
647 std::unique_lock guard( m_mutex );
649 return StatusCode::SUCCESS;
659 ATH_MSG_DEBUG(
"removeTagFromInput - adding tag name to be removed: " << tagName);
660 std::unique_lock guard( m_mutex );
662 return StatusCode::SUCCESS;
668 std::shared_lock guard(m_mutex);
679 std::shared_lock guard(m_mutex);
687 std::shared_lock guard(m_mutex);
695 std::shared_lock guard(m_mutex);
703 std::shared_lock guard(m_mutex);
711 std::unique_lock guard(m_mutex);
718 std::unique_lock guard(m_mutex);
virtual void addListener(Listener *listener) override final
Add a Listener to the notification list for TagInfo changes.
virtual StatusCode start() override
const_iterator end() const
ServiceHandle< StoreGateSvc > m_storeGate
The event store.
virtual std::string findTag(const std::string &name) const override final
Find tag by name, return by value.
virtual StatusCode addTag(const std::string &tagName, const std::string &tagValue) override
Method to allow clients add in tags as: tag name, tag value.
void get_detdescr_tags(NameTagPairVec &pairs) const
Access DetDescr tags.
Validity Range object. Holds two IOVTimes (start and stop)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
StatusCode addTag(const NameTagPair &pair, bool override=false)
addTag for current tags - returns failure if tag name exists and override == false
Validity Range object. Holds two IOVTime instances (start and stop)
This file contains the class definition for the CondAttrListCollAddress class.
void findInputTag(const std::string &name, std::string &tag) const
Find tag by its name - for input tags, return in the reference argument.
IOVRange minRange() const
Current minimal IOVRange.
virtual NameTagPairVec getInputTags() const override final
Return a vector with all current input tags.
EventIDBase::number_type conditionsRun() const
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop
virtual void removeListener(Listener *listener) override final
Remove a Listener from the notification list for TagInfo changes.
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)
bool msgLvl(const MSG::Level lvl) const
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 provides general information about an event. It extends EventInfo with a list of sub-evts ...
Abstract interface to IOVDbSvc to access IOVRange and tag information.
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.
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
virtual StatusCode finalize() override
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.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
EventIDBase::number_type m_currentRun
current run number from BeginRun incident
void handle(const Incident &incident) override final
std::pair< std::string, std::string > NameTagPair
This class contains the list of currently valid tags for detector description - GeoModel and IOV/Cond...
Listener interface class that client who want to be notified about TagInfo update should implement (a...
std::vector< NameTagPair > NameTagPairVec
std::vector< NameTagPair > NameTagPairVec
virtual void printTags(MsgStream &log) const override final
Printout method.
::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.
virtual std::string dumpTagInfoToStr() const override final
Dump the content of the current TagInfo to std::string for debug.
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.
virtual StatusCode removeTagFromInput(const std::string &tagName) override
Method to allow clients to remove a tag which may have come in on the input.
static const InterfaceID & interfaceID()
Retrieve interface ID.
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)
This is a Athena service which manages detector description tag information. It maintains a TagInfo o...
#define ATH_MSG_WARNING(x)
ChanAttrListMap::const_iterator const_iterator
ServiceHandle< IIOVDbSvc > m_iovDbSvc
Access to IOVDbSvc interface - used to register callback.
virtual StatusCode initialize() override
virtual std::string findInputTag(const std::string &name) const override final
Find tag by its name - for input tags, return by value.
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.
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Query the interfaces.
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
This is a Athena service which manages detector description tag information. It maintains a private T...