ATLAS Offline Software
TagInfoMgr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 //<<<<<< INCLUDES >>>>>>
14 
15 #include "TagInfoMgr.h"
16 
17 // Event includes
18 #include "EventInfo/EventID.h"
19 #include "EventInfo/EventInfo.h"
20 #include "EventInfo/EventType.h"
21 
23 
24 // IOVDbSvc
25 #include "AthenaKernel/IIOVDbSvc.h"
26 
27 // TES include
28 #include "StoreGate/StoreGateSvc.h"
29 #include "AthenaKernel/IIOVSvc.h"
30 #include "AthenaKernel/IOVTime.h"
31 #include "AthenaKernel/IOVRange.h"
35 
36 // Gaudi includes
37 #include "GaudiKernel/IIncidentSvc.h"
38 #include "GaudiKernel/GaudiException.h"
39 
40 
41 // Constructor with parameters:
42 TagInfoMgr::TagInfoMgr(const std::string &name, ISvcLocator *pSvcLocator) :
43  AthService(name, pSvcLocator)
44 {}
45 
47 {}
48 
49 
52 TagInfoMgr::queryInterface( const InterfaceID& riid, void** ppvInterface )
53 {
54  if ( ITagInfoMgr::interfaceID().versionMatch(riid) ) {
55  *ppvInterface = (ITagInfoMgr*)this;
56  }
57  else {
58  // Interface is not directly available: try out a base class
59  return(::AthService::queryInterface(riid, ppvInterface));
60  }
61  return StatusCode::SUCCESS;
62 }
63 
64 // Initialize method:
66 {
68 
69  // Get the messaging service, print where you are
70  ATH_MSG_DEBUG( "initialize()");
71 
72  if (msgLvl(MSG::DEBUG)) {
73  ATH_MSG_DEBUG( "ExtraTagValuePairs " );
74  for (auto& tv : m_extraTagValuePairs) {
75  ATH_MSG_DEBUG( " Value/tag pair: " << tv.first << " " << tv.second );
76  }
77  }
78 
79  // To copy TagInfo to EventInfo, we set listener to the
80  // IncidentSvc for BeginRun and BeginInputFile
81  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
82 
83  // Add BeginRun to trigger tag extraction and writing to output
84  // file meta data
85  incSvc->addListener( this, "BeginRun", 100);
86 
87  // Add BeginInputFile to trigger refilling meta data store after a new input file - priority has
88  // to be < 50 to be run after IOVDbMetaDataTool (triggered by MetaDataSvc), which is merging
89  // the input meta data from the new file into the output file metadata.
90  incSvc->addListener(this, "BeginInputFile", 50); //
91 
92  return StatusCode::SUCCESS;
93 }
94 
95 // Start method:
97 {
98  ATH_MSG_DEBUG( "start()");
99  return StatusCode::SUCCESS;
100 }
101 
102 // Finalize method:
104 {
105  ATH_MSG_DEBUG( "finalize()");
106  return StatusCode::SUCCESS;
107 }
108 
109 
110 StatusCode
112 {
113 
114  // Fill tag info
115  //
116  // We first fill normal tag and input tags with tags coming from
117  // either the EventInfo object or the tag info object coming
118  // from COOL
119  //
120  // Then we fill in tags with list of extra tags which are the
121  // current tags for this job. These normally will "over ride"
122  // the tags coming from either COOL/EventInfo. And, of course,
123  // they are not saved as input tags.
124  //
125 
126  // Get the messaging service, print where you are
127  ATH_MSG_DEBUG( "fillTagInfo: ");
128  // clear existing tags
129  m_tagInfo = TagInfo();
130 
131  // Add tags to TagInfo
132 
133  if (tagInfoCond) {
134  // Coming from COOL
135  ATH_MSG_DEBUG( "fillTagInfo: - reading Tags from infile IOV metadata");
136 
137  // tagInfoCond->dump();
138 
139  CondAttrListCollection::const_iterator itr = tagInfoCond->begin();
140  if (itr != tagInfoCond->end()) {
141  const coral::AttributeList& attrList = (*itr).second;
142  coral::AttributeList::const_iterator itAttrList = attrList.begin();
143  coral::AttributeList::const_iterator itLast = attrList.end();
144  for (; itAttrList != itLast; ++itAttrList) {
145  // Add current tags:
146  // -----------------
147  // Assumption is that tags from file meta data should
148  // be the "first ones in" and there should not be any
149  // clash with existing tags. Return WARNING if this
150  // happens
151  const std::string& name = (*itAttrList).specification().name();
152  const std::string& value = (*itAttrList).data<std::string>();
153  // First make sure that this tag name is not on the
154  // list of those to be removed
155  if (m_tagsToBeRemoved.find(name) == m_tagsToBeRemoved.end()) {
156  if (m_tagInfo.addTag(EventType::NameTagPair(name, value)).isFailure()) {
157  ATH_MSG_WARNING( "fillTagInfo: Unable to add value/tag to TagInfo "
158  << name << " " << value);
159  }
160  ATH_MSG_DEBUG( "fillTagInfo: Added name/tag to TagInfo "
161  << name << " " << value);
162  }
163  else
164  ATH_MSG_DEBUG( "fillTagInfo: Did NOT add tag - on remove list: name/tag: "
165  << name << " " << value);
166 
167  // Duplicate as input tags:
168  // ------------------------
169  // Assumption is that tags from file meta data should
170  // be the "first ones in" and there should not be any
171  // clash with existing tags. Return WARNING if this
172  // happens
174  ATH_MSG_WARNING( "fillTagInfo: Unable to add value/tag to TagInfo as input tag "
175  << name << " " << value);
176  }
177  ATH_MSG_DEBUG( "fillTagInfo: Added value/tag to TagInfo as input tag "
178  << name << " " << value);
179  }
180  }
181  else {
182  // error!
183  ATH_MSG_DEBUG( "fillTagInfo: Could not get attribute list");
184  return (StatusCode::FAILURE);
185  }
186  }
187  else {
188  // **********************************************************
189  // Get tags from EventInfo/EventType
190  // **********************************************************
191  // ***** NOTE: THIS PART IS FOR BACKWARDS COMPATIBILITY *****
192  // ***** TAGS ARE NOW WRITTEN TO FILE META DATA *****
193  // ***** THIS CAN BE REMOVED WHEN NO FILES ARE *****
194  // ***** READ WITH TAGS IN EVENT INFO *****
195  // ***** RDS 04/2009 *****
196  // **********************************************************
197  //MN: 2021-2022 and still not clear what to do with this part
198 
199  ATH_MSG_DEBUG( "fillTagInfo: Reading Tags from EventInfo");
200  const EventInfo* evtH = m_storeGate->tryConstRetrieve<EventInfo>();
201  if( !evtH ) {
202  // For simulation, we may be in the initialzation phase
203  // and we cannot get EventInfo. We simply skip this step,
204  // assuming that most times the information is coming in
205  // via conditions/file meta data.
206  ATH_MSG_DEBUG( "fillTagInfo: Could not find EventInfo - skipping the filling of TagInfo from input EventInfo");
207  }
208  else {
209  ATH_MSG_DEBUG( "fillTagInfo: Event ID: ["
210  << evtH->event_ID()->run_number() << ","
211  << evtH->event_ID()->event_number() << ":"
212  << evtH->event_ID()->time_stamp() << "] " );
214  evtH->event_type()->get_detdescr_tags(pairs1);
215 
216  if(pairs1.size()) {
217  ATH_MSG_DEBUG( "fillTagInfo: Pairs from EventType:");
218  }
219  else {
220  ATH_MSG_DEBUG( "fillTagInfo: EventInfo/EventType has no tags");
221  }
222  for (unsigned int i = 0; i < pairs1.size(); ++i) {
223  ATH_MSG_DEBUG( "fillTagInfo: " << pairs1[i].first << " : "
224  << pairs1[i].second
225  );
226  // Add current tags:
227  // -----------------
228  // Assumption is that EventInfo tags should be the
229  // "first ones in" and there should not be any clash
230  // with existing tags. Return ERROR if this happens
231 
232  // First make sure that this tag name is not on the
233  // list of those to be removed
234  std::string& name = pairs1[i].first;
235  if (m_tagsToBeRemoved.find(name) == m_tagsToBeRemoved.end()) {
236  if (m_tagInfo.addTag(pairs1[i]).isFailure()) {
237  ATH_MSG_ERROR( "fillTagInfo: Unable to add tag to TagInfo: name/tag "
238  << pairs1[i].first << " : "
239  << pairs1[i].second);
240  return (StatusCode::FAILURE);
241  }
242  else ATH_MSG_DEBUG( "fillTagInfo: Added name/tag to TagInfo "
243  << pairs1[i].first << " : "
244  << pairs1[i].second );
245  } else
246  ATH_MSG_DEBUG( "fillTagInfo: Did NOT add tag - on remove list: name/tag: "
247  << pairs1[i].first << " : "
248  << pairs1[i].second );
249 
250  // Duplicate as input tags:
251  // ------------------------
252  // Assumption is that EventInfo tags should be the
253  // "first ones in" and there should not be any clash
254  // with existing tags. Return ERROR if this happens
255  if (m_tagInfo.addInputTag(pairs1[i]).isFailure()) {
256  ATH_MSG_ERROR( "fillTagInfo: Unable to add input tag to TagInfo: name/tag "
257  << pairs1[i].first << " : "
258  << pairs1[i].second);
259  return (StatusCode::FAILURE);
260  }
261  }
262  ATH_MSG_DEBUG( "fillTagInfo: Added EventInfo tags to TagInfo current/input");
263 
264  }
265  }
266 
267  // Dump out contents of TagInfo
268  ATH_MSG_DEBUG( "fillTagInfo: print out tags before adding extra tags");
270 
271 
272  // Add in any extra tag value pairs if specified
273  std::map<std::string,std::string> valueTagPairs(m_extraTagValuePairs);
274  // Add in pairs from interface
275  for (auto & tv : m_extraTagValuePairsViaInterface) {
276  valueTagPairs[tv.first]=tv.second;
277  }
278 
279  for (auto& tv : valueTagPairs) {
280  ATH_MSG_DEBUG( "fillTagInfo: Adding extra value/tag pair: " << tv.first << " " << tv.second);
281  if (m_tagInfo.addTag(EventType::NameTagPair(tv.first,tv.second), true).isFailure()) {
282  ATH_MSG_WARNING( "fillTagInfo: Extra value/tag not added to TagInfo ");
283  }
284  }
285 
286  // Dump out contents of TagInfo
287  ATH_MSG_DEBUG( "fillTagInfo: print out tags");
289 
290  return StatusCode::SUCCESS;
291 
292 }
293 
294 
297 {
298  // fillMetaData is called at the beginning of the job and for each
299  // new file being read in.
300  //
301  // Fill IOV object in metadata store with information from tag
302  // info.
303  //
304  // For the IOV we use the IOV from the input conditions. For the first input
305  // file, we use the incoming IOV if the current run falls within the IOV
306  // range. If not we set the IOV to runNumber to runNumber + 1. For
307  // subsequent input files, if the runNumber falls within the previous IOV
308  // range, then we set the new IOV to [runNumber, lastStop), otherwise the
309  // IOV is set to [runNumber, runNumber+1). This latter is used for the
310  // zerobias overlaying.
311  //
312 
313  ATH_MSG_DEBUG( "entering fillMetaData");
314 
315  // Get run number for IOV
316  EventIDBase::number_type runNumber = EventIDBase::UNDEFNUM;
317 
318  if( m_currentRun != EventIDBase::UNDEFNUM ) {
320  }
321  else if( m_conditionsRun != EventIDBase::UNDEFNUM ) {
322  // Not completely sure of the use-case for the setting of the conditions run number, but
323  // this will be used if the current run number has not been set. RDS 2020/08
325  ATH_MSG_INFO( "fillMetaData: Using conditions run number: " << m_conditionsRun << " rather then current run number: " << m_currentRun);
326  } else {
327  // For simulation, we may be in the initialization phase and
328  // must get the run number from the event selector
329  if (StatusCode::SUCCESS != getRunNumber (runNumber)) {
330  ATH_MSG_ERROR( "fillMetaData: Could not get event info neither via retrieve nor from the EventSelectror");
331  return (StatusCode::FAILURE);
332  }
333  }
334 
335  // Copy tags to AttributeList
336  coral::AttributeList attrList;
339  ATH_MSG_DEBUG( "fillMetaData: Adding value/tag pairs to file meta data: ");
340  for (unsigned int i = 0; i < pairs.size(); ++i) {
341  attrList.extend(pairs[i].first, "string");
342  attrList[pairs[i].first].setValue(pairs[i].second);
343  ATH_MSG_DEBUG( pairs[i].first << " " << pairs[i].second);
344  }
345 
346  // Fill collection
347  CondAttrListCollection* attrListColl = new CondAttrListCollection(true);
348  attrListColl->add(0, attrList);
349  // Set IOV:
350 
351  if (tagInfoCond) {
352  // set to the IOV of the incoming conditions
353  // if run num is in previous IOV, set new IOV to be [runNum, lastStop)
354  IOVTime testTime(runNumber, 0);
357  bool isFirstIOVCheck = false;
358  if (!start.isValid() || !stop.isValid()) {
359  // Start of job, set lastIOVRange to the incoming IOV
360  IOVRange minRange = tagInfoCond->minRange();
361  start = minRange.start();
362  stop = minRange.stop();
363  ATH_MSG_DEBUG( "IOV minRange from IOVMetaData: " << tagInfoCond->minRange());
365  isFirstIOVCheck = true;
366  }
367  if (m_lastIOVRange.isInRange(testTime)) {
368  // set start to runNumber after the
369  if (!isFirstIOVCheck) start = testTime;
370  ATH_MSG_DEBUG( "fillMetaData: run number is in previous IOVRange: " << runNumber << " " << m_lastIOVRange);
371  }
372  else {
373  // Out of range
374  start = testTime;
375  stop = IOVTime(runNumber + 1, 0);
376  ATH_MSG_DEBUG( "fillMetaData: run number is outside of previous IOVRange: " << runNumber << " " << m_lastIOVRange << ". Reset range to run number.");
377  }
378  attrListColl->addNewStart(start);
379  attrListColl->addNewStop (stop);
381  ATH_MSG_DEBUG( "fillMetaData: start, stop: " << start << " " << stop);
382  }
383  else {
384  // set to the IOV of this run to run+1
385  attrListColl->addNewStart(IOVTime(runNumber, 0));
386  attrListColl->addNewStop(IOVTime(runNumber + 1, 0));
387  }
388 
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;
393  }
394 
395  // Add payload
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;
399  }
400 
401  return StatusCode::SUCCESS;
402 
403 }
404 
405 
406 StatusCode
408 {
409  // check if EventSelector is being used to override run numbers if
410  // so, we return the runNumber from the properties of the
411  // EventSelector
412 
413  // Get run number parameter from the EventSelector
414  ATH_MSG_DEBUG( "getRunNumber: check if tag is set in jobOpts");
415  // Get name of event selector from the application manager to
416  // make sure we get the one for MC signal events
417  IProperty* propertyServer(0);
418  StatusCode sc = serviceLocator()->service("ApplicationMgr", propertyServer);
419  if (sc != StatusCode::SUCCESS ) {
420  ATH_MSG_ERROR( "getRunNumber: Cannot get ApplicationMgr ");
421  return StatusCode::FAILURE;
422  }
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;
428  }
429  // Get EventSelector for ApplicationMgr
430  std::string eventSelector = property.value();
431  sc = serviceLocator()->service(eventSelector, propertyServer);
432  if (sc != StatusCode::SUCCESS ) {
433  ATH_MSG_ERROR( "getRunNumber: Cannot get EventSelector " << eventSelector);
434  return StatusCode::FAILURE;
435  }
436  BooleanProperty overrideRunNumber = BooleanProperty("OverrideRunNumber", false);
437  sc = propertyServer->getProperty(&overrideRunNumber);
438  if (!sc.isSuccess()) {
439  // Not all EventSelectors have this property, but we should
440  // not get here if the ES is not one for simulation => return failure
441  ATH_MSG_WARNING( "getRunNumber: unable to get OverrideRunNumber property from EventSelector ");
442  return StatusCode::FAILURE;
443  }
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;
451  }
452  else {
453  runNumber = runNumberProp.value();
454  ATH_MSG_DEBUG( "getRunNumber: Run number: "
455  << runNumber << " obtained from "
456  << eventSelector);
457  }
458  }
459  else {
460  ATH_MSG_ERROR( "getRunNumber: OverrideRunNumber from EventSelector is false ");
461  return StatusCode::FAILURE;
462  }
463  return StatusCode::SUCCESS;
464 }
465 
466 
467 
468 void
469 TagInfoMgr::handle(const Incident& inc) {
470 
494  // Get the messaging service, print where you are
495  ATH_MSG_DEBUG( "handle: received incident of type " << inc.type()
496  << " from " << inc.source());
497 
498  const EventIDBase eventID = inc.context().eventID();
499 
500  if (inc.type() == IncidentType::BeginRun) {
501  // For begin run, reset the current run number
502 
503  // get conditionsRun from the Context - can be used if no EventID in the SG (for HLT)
505 
506  // Set current run number to be used for fillMetaData
507  m_currentRun = eventID.run_number();
508 
509  ATH_MSG_DEBUG( "handle: BeginRun incident - Event ID: ["
510  << eventID.run_number() << ","
511  << eventID.lumi_block() << ":"
512  << eventID.time_stamp() << "] ");
513  if( m_conditionsRun != EventIDBase::UNDEFNUM ) {
514  ATH_MSG_DEBUG( "handle: conditionsRun = " << m_conditionsRun);
515  }
516  if( m_currentRun != EventIDBase::UNDEFNUM ) {
517  ATH_MSG_DEBUG( "handle: currentRun = " << m_currentRun);
518  }
519  }
520 
521  // At first BeginRun we retrieve TagInfo and trigger IOVDbSvc to use it
522  if (inc.type() == IncidentType::BeginRun && m_isFirstBeginRun) {
523 
524  // No longer first BeginRun
525  m_isFirstBeginRun = false;
526 
527  // For the moment, we must set IOVDbSvc into the BeginRun
528  // state to be able to access TagInfo from the file meta data
529 
530  // create IOV time from current event coming in with BeginRun incident
531  EventIDBase::number_type run = eventID.run_number();
532  EventIDBase::number_type lb = eventID.lumi_block();
533  IOVTime curTime;
534  curTime.setRunEvent(run, lb);
535 
536  // save both seconds and ns offset for timestamp
537  uint64_t nsTime = eventID.time_stamp()*1000000000LL;
538  nsTime += eventID.time_stamp_ns_offset();
539  curTime.setTimestamp(nsTime);
540 
541  if (StatusCode::SUCCESS != m_iovDbSvc->signalBeginRun(curTime, inc.context()))
542  {
543  ATH_MSG_ERROR( "Unable to signal begin run to IOVDbSvc");
544  throw GaudiException( "Unable to signal begin run to IOVDbSvc", "TagInfoMgr::handle", StatusCode::FAILURE );
545  }
546  ATH_MSG_DEBUG( "Signaled begin run to IOVDbSvc " << curTime);
547 
548  // For BeginRun, update TagInfo
549  if( updateTagInfo().isFailure() ) {
550  throw GaudiException( "updateTagInfo ERROR:", "TagInfoMgr::handle", StatusCode::FAILURE );
551  }
552 
553  // May have pre-existing TagInfo with incorrect IOV
554  // range. Try dropping and retrieving again.
555  // bool sc = m_iovDbSvc->dropObject("/TagInfo"); //MN: No idea what that was supposed to do
556 
557  // Process TagInfo by IOVDbSvc
558  if (m_iovDbSvc->processTagInfo().isFailure() ) {
559  throw GaudiException( "iovDbSvc::processTagInfo ERROR", "TagInfoMgr::handle", StatusCode::FAILURE );
560  }
561  ATH_MSG_DEBUG( "handle: TagInfo successfully processed by IOVDbSvc to register callback");
562  notifyListeners();
563  }
564  else if ((inc.type() == IncidentType::BeginInputFile || inc.type() == IncidentType::BeginRun)
565  && !m_isFirstBeginRun)
566  {
567  // For a new file incident or a subsequent begin run incident, we must "refill" the meta
568  // data store with the current value of the TagInfo folder in the detector store.
569  if( updateTagInfo().isFailure() ) {
570  throw GaudiException( "updateTagInfo ERROR:", "TagInfoMgr::handle", StatusCode::FAILURE );
571  }
572  notifyListeners();
573  }
574 }
575 
576 
577 //______________________________________________________________________________
578 void
580 {
581  ATH_MSG_DEBUG( "notifyListeners (" << m_listeners.size() <<" registered)");
582 
583  m_mutex.lock_shared();
584  const auto listeners = m_listeners;
585  m_mutex.unlock_shared();
586 
587  for( auto listener : listeners ) {
588  listener->tagInfoUpdated();
589  }
590 }
591 
592 //______________________________________________________________________________
593 StatusCode
595 
596  // Fill the TagInfo object
597  // The tag info may come from either the input file meta data or
598  // the currently available EventInfo object
599  ATH_MSG_DEBUG( "updateTagInfo: getting /TagInfo");
600 
601  // Check whether TagInfo is coming from file meta data or the
602  // input event
603  const CondAttrListCollection* attrListColl = 0;
604  if (m_detStore->contains<CondAttrListCollection>("/TagInfo")) {
605  if (m_detStore->retrieve( attrListColl, "/TagInfo" ).isFailure() ) {
606  ATH_MSG_ERROR( "updateTagInfo: No TagInfo meta data in DetectorStore");
607  return StatusCode::FAILURE ;
608  }
609  else {
610  ATH_MSG_DEBUG( "updateTagInfo: Retrieved TagInfo meta data from detStore. size " << attrListColl->size());
611  }
612  }
613  else {
614  ATH_MSG_DEBUG( "updateTagInfo: det store does NOT contain AttrListColl for TagInfo");
615  }
616 
617  // Fill TagInfo from (file meta data) conditions if they exist. If
618  // they are empty, we restore from the saved TagInfo
619  // information. Otherwise we fill from from event info (OLD and
620  // most likely not used anymore. RDS 08/2012).
621  if (attrListColl && attrListColl->size() == 0) {
622  ATH_MSG_DEBUG( "updateTagInfo: /TagInfo empty - do nothing");
624  return StatusCode::SUCCESS;
625  }
626 
627  std::unique_lock guard(m_mutex);
628  ATH_CHECK( fillTagInfo(attrListColl) );
629  if (attrListColl) ATH_MSG_DEBUG( "updateTagInfo: Filled TagInfo from file meta data ");
630  else ATH_MSG_DEBUG( "updateTagInfo: Filled TagInfo from input event ");
631 
632  // Copy TagInfo to meta data store for writing to file meta data
633  ATH_CHECK( fillMetaData(attrListColl) );
634  ATH_MSG_DEBUG( "updateTagInfo: Wrote TagInfo to MetaDataStore ");
635 
636  return StatusCode::SUCCESS;
637 }
638 
639 
640 //______________________________________________________________________________
643 TagInfoMgr::addTag(const std::string& tagName, const std::string& tagValue)
644 {
645  // Add name/value to input vector
646  ATH_MSG_DEBUG("addTag - adding name/value pairs: " << tagName << " " << tagValue);
647  std::unique_lock guard( m_mutex );
648  m_extraTagValuePairsViaInterface[tagName]=tagValue;
649  return StatusCode::SUCCESS;
650 }
651 
652 //______________________________________________________________________________
656 TagInfoMgr::removeTagFromInput(const std::string& tagName)
657 {
658  // Add name/value to input vector
659  ATH_MSG_DEBUG( "removeTagFromInput - adding tag name to be removed: " << tagName);
660  std::unique_lock guard( m_mutex );
661  m_tagsToBeRemoved.insert(tagName);
662  return StatusCode::SUCCESS;
663 }
664 
665 //______________________________________________________________________________
666 std::string TagInfoMgr::findTag(const std::string & name) const
667 {
668  std::shared_lock guard(m_mutex);
669  const auto iter = m_extraTagValuePairsViaInterface.find(name);
670  if( iter != m_extraTagValuePairsViaInterface.end() ) {
671  return iter->second;
672  }
673  return m_tagInfo.findTag(name);
674 }
675 
676 //______________________________________________________________________________
677 std::string TagInfoMgr::findInputTag(const std::string & name) const
678 {
679  std::shared_lock guard(m_mutex);
680  return m_tagInfo.findInputTag(name);
681 }
682 
683 //______________________________________________________________________________
686 {
687  std::shared_lock guard(m_mutex);
688  return m_tagInfo.getInputTags();
689 }
690 
691 //______________________________________________________________________________
692 std::string
694 {
695  std::shared_lock guard(m_mutex);
696  return m_tagInfo.str();
697 }
698 
699 //______________________________________________________________________________
700 void
701 TagInfoMgr::printTags(MsgStream& log) const
702 {
703  std::shared_lock guard(m_mutex);
705 }
706 
707 
708 //______________________________________________________________________________
710 {
711  std::unique_lock guard(m_mutex);
712  m_listeners.insert( listener );
713 }
714 
715 //______________________________________________________________________________
717 {
718  std::unique_lock guard(m_mutex);
719  m_listeners.erase( listener );
720 }
721 
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
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
EventIDFromStore.h
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
EventType::get_detdescr_tags
void get_detdescr_tags(NameTagPairVec &pairs) const
Access DetDescr tags.
Definition: EventType.cxx:113
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
TagInfoMgr::~TagInfoMgr
~TagInfoMgr()
Definition: TagInfoMgr.cxx:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TagInfo::addTag
StatusCode addTag(const NameTagPair &pair, bool override=false)
addTag for current tags - returns failure if tag name exists and override == false
Definition: TagInfo.cxx:175
IOVRange.h
Validity Range object. Holds two IOVTime instances (start and stop)
CondAttrListCollAddress.h
This file contains the class definition for the CondAttrListCollAddress class.
TagInfo::findInputTag
void findInputTag(const std::string &name, std::string &tag) const
Find tag by its name - for input tags, return in the reference argument.
Definition: TagInfo.cxx:106
CondAttrListCollection::minRange
IOVRange minRange() const
Current minimal IOVRange.
Definition: CondAttrListCollection.h:438
TagInfoMgr::getInputTags
virtual NameTagPairVec getInputTags() const override final
Return a vector with all current input tags.
Definition: TagInfoMgr.cxx:685
Atlas::ExtendedEventContext::conditionsRun
EventIDBase::number_type conditionsRun() const
Definition: ExtendedEventContext.h:38
CondAttrListCollection::addNewStop
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop
Definition: CondAttrListCollection.h:518
TagInfoMgr::removeListener
virtual void removeListener(Listener *listener) override final
Remove a Listener from the notification list for TagInfo changes.
Definition: TagInfoMgr.cxx:716
ExtendedEventContext.h
TagInfo::addInputTag
StatusCode addInputTag(const NameTagPair &pair, bool override=false)
addInputTag for input tags - returns failure if tag name exists and override == false
Definition: TagInfo.cxx:181
initialize
void initialize()
Definition: run_EoverP.cxx:894
IOVRange::start
const IOVTime & start() const
Definition: IOVRange.h:38
IOVRange::isInRange
bool isInRange(const IOVTime &t) const
Definition: IOVRange.h:41
TagInfo::getTags
void getTags(NameTagPairVec &pairs) const
Fill vector with all current tags.
Definition: TagInfo.cxx:117
TagInfoMgr::m_conditionsRun
EventIDBase::number_type m_conditionsRun
conditionsRun from the first BeginRun incident (HLT)
Definition: TagInfoMgr.h:182
TagInfo::printTags
void printTags(MsgStream &log) const
Printout method:
Definition: TagInfo.cxx:192
TagInfoMgr::fillMetaData
StatusCode fillMetaData(const CondAttrListCollection *tagInfoCond)
Definition: TagInfoMgr.cxx:296
AthCommonMsg< Service >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TagInfoMgr::m_extraTagValuePairsViaInterface
std::map< std::string, std::string > m_extraTagValuePairsViaInterface
Extra tags/values pairs added in via interface.
Definition: TagInfoMgr.h:161
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
athena.value
value
Definition: athena.py:122
TagInfo::str
std::string str() const
String representation.
Definition: TagInfo.cxx:207
CondAttrListCollection::addNewStart
void addNewStart(const IOVTime &start)
Add new start time to minRange - make sure that start is >= to new start.
Definition: CondAttrListCollection.h:508
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IOVTime.h
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
TagInfoMgr::finalize
virtual StatusCode finalize() override
Definition: TagInfoMgr.cxx:103
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
IOVRange::stop
const IOVTime & stop() const
Definition: IOVRange.h:39
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
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
EventType::NameTagPair
std::pair< std::string, std::string > NameTagPair
Definition: EventType.h:100
TagInfo
This class contains the list of currently valid tags for detector description - GeoModel and IOV/Cond...
Definition: TagInfo.h:41
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
ITagInfoMgr::Listener
Listener interface class that client who want to be notified about TagInfo update should implement (a...
Definition: ITagInfoMgr.h:69
lumiFormat.i
int i
Definition: lumiFormat.py:92
EventType::NameTagPairVec
std::vector< NameTagPair > NameTagPairVec
Definition: EventType.h:101
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthService
Definition: AthService.h:32
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:210
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
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
run
Definition: run.py:1
TagInfoMgr::m_isFirstBeginRun
bool m_isFirstBeginRun
Flag to identify the first BeginRun incident.
Definition: TagInfoMgr.h:179
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
IOVTime::setTimestamp
void setTimestamp(uint64_t timestamp) noexcept
Definition: IOVTime.cxx:72
TagInfoMgr::m_lastIOVRange
IOVRange m_lastIOVRange
IOVRange of last TagInfo added to the file meta data.
Definition: TagInfoMgr.h:188
TagInfo::getInputTags
void getInputTags(NameTagPairVec &pairs) const
Fill reference vector with all current input tags.
Definition: TagInfo.cxx:127
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
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
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
ITagInfoMgr::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: ITagInfoMgr.h:113
IIOVSvc.h
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
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
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
DeMoScan.first
bool first
Definition: DeMoScan.py:534
DEBUG
#define DEBUG
Definition: page_access.h:11
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
IOVTime::setRunEvent
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition: IOVTime.cxx:96
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LArNewCalib_DelayDump_OFC_Cali.eventSelector
eventSelector
Definition: LArNewCalib_DelayDump_OFC_Cali.py:112
TagInfoMgr::m_tagsToBeRemoved
std::set< std::string > m_tagsToBeRemoved
Extra tags to be removed.
Definition: TagInfoMgr.h:164
TagInfo::findTag
void findTag(const std::string &name, std::string &tag) const
Find tag by its name - for current tags, returning in the reference argument.
Definition: TagInfo.cxx:95
TagInfoMgr::TagInfoMgr
TagInfoMgr()
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
TagInfoMgr::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Query the interfaces.
Definition: TagInfoMgr.cxx:52
StoreGateSvc.h
EventInfo::event_type
EventType * event_type()
the type of the event, e.g. simulation, testbeam, etc
Definition: EventInfo/EventInfo/EventInfo.h:220
TagInfoMgr.h
This is a Athena service which manages detector description tag information. It maintains a private T...
ServiceHandle< IIncidentSvc >