ATLAS Offline Software
IOVDbMetaDataTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
16 #include "IOVDbMetaDataTool.h"
17 
18 #include "GaudiKernel/IIncidentSvc.h"
19 #include "GaudiKernel/FileIncident.h"
20 
21 #include "StoreGate/StoreGateSvc.h"
23 
24 
26  const std::string& name,
27  const IInterface* parent)
29  , m_metaDataStore ("StoreGateSvc/MetaDataStore", name)
30  , m_inputStore ("StoreGateSvc/InputMetaDataStore", name)
31  , m_processedFirstInputFileIncident(false)
32  , m_overrideRunNumber(false)
33  , m_overrideMinMaxRunNumber(false)
34  , m_newRunNumber(0)
35  , m_oldRunNumber(0)
36  , m_minRunNumber(0)
37  , m_maxRunNumber(0)
38  , m_modifyFolders(false)
39 {
40  // Declare additional interface
41  declareInterface<IIOVDbMetaDataTool>(this);
42  declareInterface<IMetaDataTool>(this);
43 
44  // Declare properties
45  declareProperty("MinMaxRunNumbers", m_minMaxRunNumbers);
46 
47  // Folders and attributes to be deleted
48  declareProperty("FoldersToBeModified"
49  , m_foldersToBeModified = std::vector<std::string>(1, "/Simulation/Parameters"));
50  declareProperty("AttributesToBeRemoved"
51  , m_attributesToBeRemoved = std::vector<std::string>(1, "RandomSeedOffset"));
52 
53 }
54 
55 //--------------------------------------------------------------------------
57 {}
58 
59 
60 //--------------------------------------------------------------------------
61 
63 {
64  ATH_MSG_DEBUG("in initialize()");
65 
66  // Set to be listener for FirstInputFile
67  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", this->name());
68  ATH_CHECK(incSvc.retrieve());
69  incSvc->addListener(this, "FirstInputFile", 60); // pri has to be < 100 to be after MetaDataSvc.
70 
71  // locate the meta data stores
72  ATH_CHECK(m_metaDataStore.retrieve());
73  ATH_CHECK(m_inputStore.retrieve());
74 
75  // Check whether folders need to be modified
76  m_modifyFolders = (m_foldersToBeModified.value().size()>0);
77  ATH_MSG_DEBUG("initialize(): " << (m_modifyFolders ? "" : "No ") << "need to modify folders");
78 
79  return(StatusCode::SUCCESS);
80 }
81 
82 //--------------------------------------------------------------------------
83 
86 {
87  return StatusCode::SUCCESS;
88 }
89 
90 //--------------------------------------------------------------------------
91 
92 void IOVDbMetaDataTool::handle(const Incident& inc)
93 {
94  const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
95  if(!fileInc) throw std::runtime_error("Unable to get FileName from FirstInputFile incident");
96 
97  const std::string fileName = fileInc->fileName();
98  ATH_MSG_DEBUG("handle() " << inc.type() << " for " << fileName);
99 
101  // Check if we need to override run number - only needed for simulation
103 
105  if(!sc.isSuccess()) throw std::runtime_error("Could not process input file meta data");
106 }
107 
109 {
111  // We skip the first BeginInputFile incident following the FirstInputFile - both are fired for the first file
113  ATH_MSG_DEBUG("The first BeginInputFile incident is fired along with the FirstInputFile incident so we skip the processing of the Input File MetaData ");
114  return StatusCode::SUCCESS;
115  }
116  else {
117  return processInputFileMetaData(sid);
118  }
119 }
120 
122 {
123  return StatusCode::SUCCESS;
124 }
125 
127 {
128  return StatusCode::SUCCESS;
129 }
130 
131 //--------------------------------------------------------------------------
132 
133 void
135 {
136  ATH_MSG_DEBUG("begin checkOverrideRunNumber");
137 
138  // Check if override run numbers have been set by properties or by
139  // the EventSelector
140 
141  if (m_minMaxRunNumbers.value().size() > 0) {
143  m_minRunNumber = m_minMaxRunNumbers.value()[0];
144  if (m_minMaxRunNumbers.value().size() > 1) m_maxRunNumber = m_minMaxRunNumbers.value()[1];
146 
148 
149  ATH_MSG_INFO("checkOverrideRunNumber: overriding IOV for range - min: " << m_minRunNumber
150  << " max: " << m_maxRunNumber);
151  return;
152  }
153 
154  ATH_MSG_DEBUG("checkOverrideRunNumber: check if tag is set in jobOpts");
155 
156  // Get name of event selector from the application manager to
157  // make sure we get the one for MC signal events
158  SmartIF<IProperty> appMgr{serviceLocator()->service("ApplicationMgr")};
159  if (!appMgr) {
160  ATH_MSG_ERROR("checkOverrideRunNumber: Cannot get ApplicationMgr ");
161  return;
162  }
163  StringProperty property("EvtSel", "");
164  StatusCode sc = appMgr->getProperty(&property);
165  if (!sc.isSuccess()) {
166  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get EvtSel: found " << property.value());
167  return;
168  }
169  // Get EventSelector for ApplicationMgr
170  const std::string eventSelector = property.value();
171  SmartIF<IProperty> evtSel{serviceLocator()->service(eventSelector)};
172  if (!evtSel) {
173  ATH_MSG_ERROR("checkOverrideRunNumber: Cannot get EventSelector " << eventSelector);
174  return;
175  }
176 
177  // Is flag set to override the run number?
178  BooleanProperty overrideRunNumber = IntegerProperty("OverrideRunNumberFromInput", false);
179  sc = evtSel->getProperty(&overrideRunNumber);
180  if (!sc.isSuccess()) {
181  // Not all EventSelectors have this property, so we must be tolerant
182  ATH_MSG_DEBUG("resetRunNumber: unable to get OverrideRunNumberFromInput property from EventSelector ");
183  return;
184  }
185  m_overrideRunNumber = overrideRunNumber.value();
186  if (m_overrideRunNumber) {
187  // New run number
188  IntegerProperty runNumber = IntegerProperty("RunNumber", 0);
189  sc = evtSel->getProperty(&runNumber);
190  if (!sc.isSuccess()) {
191  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get RunNumber from EventSelector: found "
192  << runNumber.value());
193  return;
194  }
195  m_newRunNumber = runNumber.value();
196  // Old run number
197  runNumber = IntegerProperty("OldRunNumber", 0);
198  sc = evtSel->getProperty(&runNumber);
199  if (!sc.isSuccess()) {
200  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get OldRunNumber from EventSelector: found "
201  << runNumber.value());
202  return;
203  }
204  m_oldRunNumber = runNumber.value();
205 
206  ATH_MSG_DEBUG("checkOverrideRunNumber: Changing old to new run number: " << m_oldRunNumber
207  << " " << m_newRunNumber << " obtained from " << eventSelector);
208  }
209  else ATH_MSG_DEBUG("checkOverrideRunNumber: OverrideRunNumberFromInput not set for " << eventSelector);
210 }
211 
212 //--------------------------------------------------------------------------
213 
216 {
217  // Set the default folder description for a CondAttrListCollection
218  // which will be read back via IOVDbSvc
219  std::string folderDescr = "<timeStamp>run-event</timeStamp><addrHeader><address_header service_type=\"256\" clid=\"1238547719\" /> </addrHeader><typeName>CondAttrListCollection</typeName>" ;
220 
221  return registerFolder(folderName, folderDescr);
222 }
223 
224 //--------------------------------------------------------------------------
225 
228  const std::string& folderDescription) const
229 {
230  // lock the tool before getMetaDataContainer() call
231  std::scoped_lock guard( m_mutex );
232 
233  ATH_MSG_DEBUG("begin registerFolder ");
234 
235  if( ! getMetaDataContainer(folderName, folderDescription) ) {
236  ATH_MSG_ERROR("Unable to register folder " << folderName);
237  return(StatusCode::FAILURE);
238  }
239  else {
240  ATH_MSG_DEBUG("IOVMetaDataContainer for folder " << folderName << " has been registered ");
241  }
242 
243  return StatusCode::SUCCESS;
244 }
245 
246 //--------------------------------------------------------------------------
247 
250 {
251  // lock the tool while it is modifying the folder
252  std::scoped_lock guard( m_mutex );
253 
254  ATH_MSG_DEBUG("begin addPayload ");
255 
256  // Check if the folder has already been found
258  if(cont) {
259  ATH_MSG_DEBUG("Retrieved IOVMetaDataContainer from MetaDataStore for folder "
260  << folderName);
261  }
262  else {
263  ATH_MSG_ERROR("addPayload: Could not find IOVMetaDataContainer in MetaDataStore for folder "
264  << folderName
265  << ". One must have previously called registerFolder. ");
266  return StatusCode::FAILURE;
267  }
268 
269  // Override run number if requested
272  }
273 
274  // Add payload to container
275  bool success = cont->merge(payload);
276  if (success) {
277  ATH_MSG_DEBUG("Added new payload for folder " << folderName);
278  }
279  else {
280  ATH_MSG_DEBUG("Could not add new payload for folder "
281  << folderName
282  << " (may be duplicate payload).");
283 
284  // To Do: the function implicitly assumes ownership on the payload pointer
285  delete payload;
286  payload = nullptr;
287  }
288 
289  // Debug printout
290  if(payload && msgLvl(MSG::DEBUG)) {
291  std::ostringstream stream;
292  payload->dump(stream);
293  ATH_MSG_DEBUG(stream.str());
294  }
295 
296  return StatusCode::SUCCESS;
297 }
298 
299 //--------------------------------------------------------------------------
300 
303  CondAttrListCollection*& coll) const
304 {
305  // protected by lock in processInputFileMetaData()
306 
309  ATH_MSG_DEBUG("begin modifyPayload for folder " << folderName);
310 
311  // check if this folder needs to be modified
312  bool modifyAttr = false;
313  std::string attributeName;
314  const std::vector<std::string>& folders = m_foldersToBeModified.value();
315  const std::vector<std::string>& attrs = m_attributesToBeRemoved.value();
316  for (unsigned int i = 0; i < folders.size(); ++i) {
317  if (folderName == folders[i]) {
318  if (attrs.size() > i) {
319  attributeName = attrs[i];
320  modifyAttr = true;
321  ATH_MSG_DEBUG("modifyPayload: remove attribute " << attributeName);
322  break;
323  }
324  }
325  }
326 
327  if (!modifyAttr) {
328  ATH_MSG_DEBUG("modifyPayload: folder " << folderName << " OK ");
329  return StatusCode::SUCCESS;
330  }
331 
332  bool iovSizeIsZero = coll->iov_size() == 0;
333  IOVRange testIOV = coll->minRange();
334  IOVTime start = testIOV.start();
335  IOVTime stop = testIOV.stop();
336  // Set the IOV
338  if (iovSizeIsZero) {
339  // Only add in overall range if channels do not have
340  // IOVs - otherwise this is automatically calculated
341  coll1->addNewStart(start);
342  coll1->addNewStop (stop);
343  }
344  // Add in channels
345  unsigned int nchans = coll->size();
346  bool hasChanNames = (coll->name_size() == nchans);
347  for (unsigned int ichan = 0; ichan < nchans; ++ichan) {
349  // Now filter out the unwanted attribute
351  const CondAttrListCollection::AttributeList& oldAttrList = coll->attributeList(chan);
352  for (unsigned int iatt = 0; iatt < oldAttrList.size(); ++iatt) {
353  // skip the unwanted attribute
354  if (attributeName == oldAttrList[iatt].specification().name()) {
355  ATH_MSG_DEBUG("modifyPayload: skipping attribute name " << oldAttrList[iatt].specification().name());
356  continue;
357  }
358 
359  // copy the rest
360  newAttrList.extend(oldAttrList[iatt].specification().name(),
361  oldAttrList[iatt].specification().type());
362  const coral::Attribute& oldAttr = oldAttrList[iatt];
363  coral::Attribute& newAttr = newAttrList[oldAttrList[iatt].specification().name()];
364  newAttr = oldAttr;
365  // newAttr.setValue(oldAttr.data());
366  ATH_MSG_DEBUG("modifyPayload: copying attr name "
367  << oldAttrList[iatt].specification().name() << " "
368  /*<< newAttr*/);
369  }
370  coll1->add(chan, newAttrList);
371  if (!iovSizeIsZero) coll1->add(chan, coll->iovRange(chan));
372  if(hasChanNames)coll1->add(chan, coll->chanName(chan));
373  ATH_MSG_DEBUG("modifyPayload: copied attribute list for channel " << chan);
374  }
375  delete coll;
376  coll = coll1;
377  if (msgLvl(MSG::DEBUG)) {
378  std::ostringstream stream;
379  coll->dump(stream);
380  ATH_MSG_DEBUG(stream.str());
381  }
382 
383  return StatusCode::SUCCESS;
384 }
385 
386 //--------------------------------------------------------------------------
387 
390 {
391  // lock the tool before this call
392  // Return the folder if it is in the meta data store
393  return m_metaDataStore->tryRetrieve<IOVMetaDataContainer>(folderName);
394 }
395 
396 
399  , const std::string& folderDescription) const
400 {
401  // protected by locks in addPayload() and registerFolder()
402  ATH_MSG_DEBUG("begin getMetaDataContainer ");
403 
404  IOVMetaDataContainer* cont{nullptr};
405  // See if it is in the meta data store
407  // Container not found, add in new one
408  cont = new IOVMetaDataContainer(folderName, folderDescription);
409  ATH_MSG_DEBUG("No IOVMetaDataContainer in MetaDataStore for folder " << folderName
410  << ". Created a new instance");
411  StatusCode sc = m_metaDataStore->record(cont, folderName);
412  if (!sc.isSuccess()) {
413  ATH_MSG_ERROR("Could not record IOVMetaDataContainer in MetaDataStore for folder " << folderName);
414  delete cont;
415  cont = nullptr;
416  }
417  }
418  else {
419  ATH_MSG_DEBUG("IOVMetaDataContainer already in MetaDataStore for folder " << folderName);
420  StatusCode sc = m_metaDataStore->retrieve(cont, folderName);
421  if (!sc.isSuccess()) {
422  ATH_MSG_ERROR("Could not retrieve IOVMetaDataContainer in MetaDataStore for folder " << folderName);
423  cont = nullptr;
424  }
425  }
426  return cont;
427 }
428 
429 //--------------------------------------------------------------------------
430 
432 {
433  // lock the tool while it is processing input metadata
434  std::scoped_lock guard( m_mutex );
435 
436  ATH_MSG_DEBUG("processInputFileMetaData: file name " << fileName);
437 
438  // Retrieve all meta data containers from InputMetaDataStore
441 
442  StatusCode sc = m_inputStore->retrieve(cont, contEnd);
443  if (!sc.isSuccess()) {
444  ATH_MSG_DEBUG("processInputFileMetaData: Could not retrieve IOVMetaDataContainer objects from InputMetaDataStore - cannot process input file meta data");
445  return StatusCode::SUCCESS;
446  }
447 
448  ATH_MSG_DEBUG("processInputFileMetaData: Retrieved from IOVMetaDataContainer(s) from InputMetaDataStore");
449 
450  // For each container, merge its contents into the MetaDataStore
451  unsigned int ncolls = 0;
452  unsigned int ndupColls = 0;
453  for (; cont != contEnd; ++cont) {
454  IOVMetaDataContainer* contMaster = getMetaDataContainer(cont->folderName()
455  , cont->folderDescription());
456 
457  // We assume that the folder is the same for all versions, and
458  // now we loop over versions for the payloads
459  std::list<SG::ObjectWithVersion<IOVMetaDataContainer> > allVersions;
460  sc = m_inputStore->retrieveAllVersions(allVersions, cont.key());
461  if (!sc.isSuccess()) {
462  ATH_MSG_ERROR("Could not retrieve all versions for " << cont.key());
463  return sc;
464  }
465 
466  for (SG::ObjectWithVersion<IOVMetaDataContainer>& obj : allVersions) {
467  const IOVPayloadContainer* payload = obj.dataObject->payloadContainer();
468 
469  ATH_MSG_DEBUG("processInputFileMetaData: New container: payload size " << payload->size() << " version key " << obj.versionedKey);
470 
471  // detailed printout before merge
472  if (msgLvl(MSG::VERBOSE)) {
473  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
474  ATH_MSG_VERBOSE("Before merge, payload minRange for folder " << cont->folderName());
475  if (payloadMaster && payloadMaster->size()) {
476  // Loop over AttrColls and print out minRange
477  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
478  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
479  unsigned int iPayload = 0;
480  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
481  ATH_MSG_VERBOSE(iPayload << " " << (*itColl)->minRange() << " "
482  << (*itColl)->size());
483  }
484  }
485  else {
486  ATH_MSG_VERBOSE(" no payloads yet!");
487  }
488  }
489  }
490 
491  // Detailed printout
492  if (msgLvl(MSG::DEBUG)) {
493  ATH_MSG_DEBUG("processInputFileMetaData: Current payload before merge " << contMaster->folderName());
495  IOVPayloadContainer::const_iterator itCollEnd1 = contMaster->payloadContainer()->end();
496  std::ostringstream stream;
497  for (; itColl1 != itCollEnd1; ++itColl1) (*itColl1)->dump(stream);
498  ATH_MSG_DEBUG(stream.str());
499  }
500 
501  //
502  // Loop over CondAttrListCollections and do merge
503  //
504  for (SG::ObjectWithVersion<IOVMetaDataContainer>& obj : allVersions) {
505  const IOVPayloadContainer* payload = obj.dataObject->payloadContainer();
507  IOVPayloadContainer::const_iterator itCollEnd = payload->end();
508  for (; itColl != itCollEnd; ++itColl) {
509 
510  // Make a copy of the collection and merge it into
511  // master container in meta data store
512  CondAttrListCollection* coll = new CondAttrListCollection(**itColl);
513  // Override run number if requested
515  ATH_CHECK( overrideIOV(coll) );
516  }
517 
518  // first check if we need to modify the incoming payload
519  if (!modifyPayload (contMaster->folderName(), coll).isSuccess()) {
520  ATH_MSG_ERROR("processInputFileMetaData: Could not modify the payload for folder " << contMaster->folderName());
521  return StatusCode::FAILURE;
522  }
523 
524  ATH_MSG_VERBOSE("processInputFileMetaData: merge minRange: " << coll->minRange());
525  if (!contMaster->merge(coll)) {
526  // Did not merge it in - was a duplicate, so we need to delete it
527  delete coll;
528  ++ndupColls;
529  ATH_MSG_VERBOSE(" => not merged ");
530  }
531  else {
532  ++ncolls;
533  ATH_MSG_VERBOSE(" => merged ");
534  }
535 
536  }
537  ATH_MSG_DEBUG("processInputFileMetaData: Merged together containers for folder " << cont->folderName() << " ncoll/ndup "
538  << ncolls << " " << ndupColls);
539 
540  // Check for consistency after merge
541  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
542  if (payloadMaster && payloadMaster->size()) {
543  // Loop over AttrColls and print out minRange
544  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
545  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
546  IOVTime lastStop;
547  if ((*itColl)->minRange().start().isTimestamp()) lastStop = IOVTime(0);
548  else lastStop = IOVTime(0,0);
549  bool hasError = false;
550  for (; itColl != itCollEnd; ++itColl) {
551  if ((*itColl)->minRange().start() < lastStop) hasError = true;
552  lastStop = (*itColl)->minRange().stop();
553  }
554  if (hasError) {
555  ATH_MSG_ERROR("processInputFileMetaData: error after merge of file meta data. " );
556  ATH_MSG_ERROR("processInputFileMetaData: Filename " << fileName);
557  ATH_MSG_ERROR("processInputFileMetaData: folder " << contMaster->folderName());
558  ATH_MSG_ERROR("processInputFileMetaData: MinRange for meta data folders ");
559  unsigned int iPayload = 0;
560  itColl = payloadMaster->begin();
561  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
562  ATH_MSG_ERROR(iPayload << " " << (*itColl)->minRange() << " " << (*itColl)->size());
563  }
564  }
565  }
566 
567  // detailed printout after merge
568  if (msgLvl(MSG::VERBOSE)) {
569  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
570  ATH_MSG_VERBOSE("processInputFileMetaData: After merge, payload minRange ");
571  if (payloadMaster) {
572  // Loop over AttrColls and print out minRange
573  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
574  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
575  unsigned int iPayload = 0;
576  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
577  ATH_MSG_VERBOSE(iPayload << " " << (*itColl)->minRange() << " "
578  << (*itColl)->size());
579  }
580  }
581  else { ATH_MSG_ERROR(" no payloads yet!"); }
582  }
583 
584  // Detailed printout
585  if (msgLvl(MSG::DEBUG)) {
586  ATH_MSG_DEBUG("processInputFileMetaData: Input payload " << cont->folderName());
587  std::ostringstream streamInp;
588  itColl = payload->begin();
589  itCollEnd = payload->end();
590  for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamInp);
591  ATH_MSG_DEBUG(streamInp.str());
592  ATH_MSG_DEBUG("processInputFileMetaData: Output payload " << contMaster->folderName());
593  std::ostringstream streamOut;
594  itColl = contMaster->payloadContainer()->begin();
595  itCollEnd = contMaster->payloadContainer()->end();
596  for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamOut);
597  ATH_MSG_DEBUG(streamOut.str());
598  }
599  }
600  }
601 
602  ATH_MSG_DEBUG("processInputFileMetaData: Total number of attribute collections merged together " << ncolls
603  << " Number of duplicate collections " << ndupColls);
604  return StatusCode::SUCCESS;
605 }
606 
607 //--------------------------------------------------------------------------
608 
611 {
612  ATH_MSG_DEBUG("overrideIOV ");
613 
614  // Override the IOV for run/event IOVs
615 
616  // (ONLY TRUE FOR OVERRIDE COMING IN VIA EVENTSELECTOR:)
617  // NOTE: we require that the old run number falls within the
618  // IOVRange of the incoming collection. We override ALL IOVs for
619  // ALL channels forcing the IOVRange to be (newRunNumber,1) to
620  // (newRunNumber+1,1)
621 
622  bool iovSizeIsZero = coll->iov_size() == 0;
623  IOVRange testIOV = coll->minRange();
624  IOVTime start = testIOV.start();
625  IOVTime stop = testIOV.stop();
626  IOVTime oldRun(m_oldRunNumber, 0);
627  if (start.isRunEvent() && stop.isRunEvent()) { // only for run/event
628  IOVRange newRange;
629  // Two ways of resetting
631  else if (m_overrideRunNumber) newRange = IOVRange(IOVTime(m_newRunNumber, 0), IOVTime(m_newRunNumber + 1, 0));
632 
633  if (m_overrideRunNumber && !testIOV.isInRange(oldRun)) {
634  // old run must be in the range
635  ATH_MSG_ERROR("overrideIOV: old run number does not match. Old run number " << m_oldRunNumber << " IOVRange: " << testIOV);
636  return StatusCode::SUCCESS;
637  }
638 
639  ATH_MSG_DEBUG("overrideIOV: overrideMinMaxRunNumber: " << (int)m_overrideMinMaxRunNumber
640  << " overrideRunNumber " << (int)m_overrideRunNumber
641  << " iovSizeIsZero: " << (int)iovSizeIsZero
642  << " newRange " << newRange);
643 
644  // Now over ride IOVs - two cases: 1) single IOV for full collection, 2) IOVs for individual channels.
645  // Must treat the reset of collection IOV differently
646  if (iovSizeIsZero) {
647  // Only add in overall range if channels do not have
648  // IOVs - otherwise this is automatically calculated
649  coll->resetMinRange(); // must first reset to 'full range' and then reduce the IOVRange accordingly
650  coll->addNewStart(newRange.start());
651  coll->addNewStop (newRange.stop());
652  }
653  else {
654  // Add in channels
655  unsigned int nchans = coll->size();
656  ATH_MSG_DEBUG("overrideIOV: nchans " << nchans);
657  for (unsigned int ichan = 0; ichan < nchans; ++ichan) {
658  // FIXME: O(N^2)!
660  coll->add(chan, newRange);
661  ATH_MSG_DEBUG("overrideIOV: overriding the IOV of collection chan " << chan);
662  }
663  // must reset the collection range AFTER the channels, because the collection range will be
664  // 'narrowed' to that of the channels
665  coll->resetMinRange();
666  }
667  if (msgLvl(MSG::DEBUG)) {
668  ATH_MSG_DEBUG("overrideIOV: after overriding the IOV of collection");
669  std::ostringstream stream;
670  coll->dump(stream);
671  ATH_MSG_DEBUG(stream.str());
672  }
673  }
674  else ATH_MSG_DEBUG("overrideIOV: IOV is not run/event ");
675 
676  return StatusCode::SUCCESS;
677 }
678 
CondAttrListCollection::resetMinRange
void resetMinRange()
Reset minRange according to the IOVs of the contained channels.
Definition: CondAttrListCollection.h:529
CondAttrListCollection::minRange
const IOVRange & minRange() const
Current minimal IOVRange.
Definition: CondAttrListCollection.h:438
IOVDbMetaDataTool.h
This is a tool used to manage the IOV Meta Data for a given object into the Meta Data Store.
IOVMetaDataContainer::payloadContainer
const IOVPayloadContainer * payloadContainer() const
Access to payload container.
Definition: IOVMetaDataContainer.h:141
IOVDbMetaDataTool::m_processedFirstInputFileIncident
bool m_processedFirstInputFileIncident
Definition: IOVDbMetaDataTool.h:120
python.PoolAttributeHelper.attrs
list attrs
Definition: PoolAttributeHelper.py:89
CondAttrListCollection::iov_size
iov_size_type iov_size() const
number of Chan/IOV pairs
Definition: CondAttrListCollection.h:350
IOVMetaDataContainer
This class is a container for conditions data. It is intended to be used to store conditions data fro...
Definition: IOVMetaDataContainer.h:37
IOVRange
Validity Range object. Holds two IOVTimes (start and stop)
Definition: IOVRange.h:30
IOVDbMetaDataTool::handle
virtual void handle(const Incident &incident) override
Incident service handle listening for BeginInputFile and EndInputFile.
Definition: IOVDbMetaDataTool.cxx:92
IOVDbMetaDataTool::getMetaDataContainer
IOVMetaDataContainer * getMetaDataContainer(const std::string &folderName, const std::string &folderDescription) const
return meta data container from the meta data store
Definition: IOVDbMetaDataTool.cxx:398
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
IOVDbMetaDataTool::m_metaDataStore
StoreGateSvc_t m_metaDataStore
Definition: IOVDbMetaDataTool.h:115
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IOVDbMetaDataTool::metaDataStop
virtual StatusCode metaDataStop() override
Function called when the tool should write out its metadata.
Definition: IOVDbMetaDataTool.cxx:126
IOVDbMetaDataTool::m_attributesToBeRemoved
StringArrayProperty m_attributesToBeRemoved
Definition: IOVDbMetaDataTool.h:143
IOVMetaDataContainer::folderName
const std::string & folderName() const
Folder name.
Definition: IOVMetaDataContainer.h:127
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SG::detail::IteratorBase::key
const std::string & key() const
Get the key string with which the current object was stored.
Definition: SGIterator.cxx:155
IOVMetaDataContainer::merge
bool merge(CondAttrListCollection *payload)
Add in new payload.
Definition: IOVMetaDataContainer.cxx:14
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
IOVRange::start
const IOVTime & start() const
Definition: IOVRange.h:38
IOVRange::isInRange
bool isInRange(const IOVTime &t) const
Definition: IOVRange.h:41
IOVDbMetaDataTool::m_minRunNumber
unsigned int m_minRunNumber
Definition: IOVDbMetaDataTool.h:132
IOVDbMetaDataTool::m_modifyFolders
bool m_modifyFolders
Definition: IOVDbMetaDataTool.h:144
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
IOVDbMetaDataTool::finalize
virtual StatusCode finalize() override
Finalize AlgTool.
Definition: IOVDbMetaDataTool.cxx:85
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
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
IOVDbMetaDataTool::addPayload
virtual StatusCode addPayload(const std::string &folderName, CondAttrListCollection *payload) const override
Add an IOV and Payload for a particular folder - replaces payloads if there is an IOV overlap.
Definition: IOVDbMetaDataTool.cxx:248
IOVDbMetaDataTool::overrideIOV
StatusCode overrideIOV(CondAttrListCollection *&coll) const
override IOV with new run number
Definition: IOVDbMetaDataTool.cxx:610
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
IOVPayloadContainer::size
size_type size() const
size of payload vector
Definition: IOVPayloadContainer.h:121
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IOVDbMetaDataTool::m_minMaxRunNumbers
UnsignedIntegerArrayProperty m_minMaxRunNumbers
Definition: IOVDbMetaDataTool.h:139
IOVRange::stop
const IOVTime & stop() const
Definition: IOVRange.h:39
IOVPayloadContainer::begin
const_iterator begin() const
Begin of payload vector.
Definition: IOVPayloadContainer.h:107
IOVTime
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Definition: IOVTime.h:33
CondAttrListCollection::dump
void dump() const
Dump our contents to std::cout.
Definition: CondAttrListCollection.h:557
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
IOVDbMetaDataTool::m_overrideMinMaxRunNumber
bool m_overrideMinMaxRunNumber
Definition: IOVDbMetaDataTool.h:126
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::chanNum
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
Definition: CondAttrListCollection.h:384
CondAttrListCollection::attributeList
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
Definition: CondAttrListCollection.h:401
IOVDbMetaDataTool::modifyPayload
StatusCode modifyPayload(const std::string &folderName, CondAttrListCollection *&payload) const
Modify a Payload for a particular folder - replaces one of the internal attributes.
Definition: IOVDbMetaDataTool.cxx:302
IOVDbMetaDataTool::m_maxRunNumber
unsigned int m_maxRunNumber
Definition: IOVDbMetaDataTool.h:133
IOVDbMetaDataTool::m_foldersToBeModified
StringArrayProperty m_foldersToBeModified
Definition: IOVDbMetaDataTool.h:142
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
IOVPayloadContainer
This class is a container for the payload of conditions data. It is intended to be used to store cond...
Definition: IOVPayloadContainer.h:35
IOVDbMetaDataTool::m_newRunNumber
unsigned int m_newRunNumber
Definition: IOVDbMetaDataTool.h:129
CondAttrListCollection::chanName
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
Definition: CondAttrListCollection.h:426
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
IOVMetaDataContainer.h
This class is a container for conditions data. It is intended to be used to store conditions data fro...
IOVDbMetaDataTool::m_oldRunNumber
unsigned int m_oldRunNumber
Definition: IOVDbMetaDataTool.h:130
CondAttrListCollection::name_size
name_size_type name_size() const
number of Chan/Name pairs
Definition: CondAttrListCollection.h:377
CaloCellTimeCorrFiller.folderName
string folderName
Definition: CaloCellTimeCorrFiller.py:20
defineDB.ichan
int ichan
Definition: JetTagCalibration/share/defineDB.py:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IOVDbMetaDataTool::m_mutex
std::shared_mutex m_mutex
Definition: IOVDbMetaDataTool.h:147
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
IOVDbMetaDataTool::endInputFile
virtual StatusCode endInputFile(const SG::SourceID &) override
Function called when the currently open input file got completely processed.
Definition: IOVDbMetaDataTool.cxx:121
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
IOVDbMetaDataTool::m_inputStore
StoreGateSvc_t m_inputStore
Definition: IOVDbMetaDataTool.h:116
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
IOVDbMetaDataTool::IOVDbMetaDataTool
IOVDbMetaDataTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: IOVDbMetaDataTool.cxx:25
IOVDbMetaDataTool::checkOverrideRunNumber
void checkOverrideRunNumber()
check if we should override the run number in the incoming meta data
Definition: IOVDbMetaDataTool.cxx:134
makeDTCalibBlob_pickPhase.folders
folders
Definition: makeDTCalibBlob_pickPhase.py:346
IOVPayloadContainer::const_iterator
payloadVec::const_iterator const_iterator
Definition: IOVPayloadContainer.h:39
IOVDbMetaDataTool::~IOVDbMetaDataTool
virtual ~IOVDbMetaDataTool()
Definition: IOVDbMetaDataTool.cxx:56
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IOVDbMetaDataTool::registerFolder
virtual StatusCode registerFolder(const std::string &folderName, const std::string &folderDescription) const override
Register folder in the IOV Db MetaData - done once at initialize.
Definition: IOVDbMetaDataTool.cxx:227
SG::SourceID
std::string SourceID
Definition: AthenaKernel/AthenaKernel/SourceID.h:25
DEBUG
#define DEBUG
Definition: page_access.h:11
IOVPayloadContainer::end
const_iterator end() const
End of payload vector.
Definition: IOVPayloadContainer.h:114
LArNewCalib_DelayDump_OFC_Cali.eventSelector
eventSelector
Definition: LArNewCalib_DelayDump_OFC_Cali.py:112
IOVDbMetaDataTool::beginInputFile
virtual StatusCode beginInputFile(const SG::SourceID &) override
Function called when a new input file is opened.
Definition: IOVDbMetaDataTool.cxx:108
IOVDbMetaDataTool::m_overrideRunNumber
bool m_overrideRunNumber
Definition: IOVDbMetaDataTool.h:125
CondAttrListCollection::iovRange
const IOVRange & iovRange(ChanNum chanNum) const
IOVRange list for a given channel number.
Definition: CondAttrListCollection.h:414
IOVDbMetaDataTool::findMetaDataContainer
virtual IOVMetaDataContainer * findMetaDataContainer(const std::string &folderName) const override final
Definition: IOVDbMetaDataTool.cxx:389
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
AthAlgTool
Definition: AthAlgTool.h:26
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition: SGVersionedKey.h:17
python.PyAthena.obj
obj
Definition: PyAthena.py:132
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
StoreGateSvc.h
SG::ConstIterator
Definition: SGIterator.h:163
IOVDbMetaDataTool::initialize
virtual StatusCode initialize() override
Initialize AlgTool.
Definition: IOVDbMetaDataTool.cxx:62
IOVDbMetaDataTool::processInputFileMetaData
virtual StatusCode processInputFileMetaData(const std::string &fileName) override
Explicit call to process IOV meta data from the input meta data store, transferring it to the main me...
Definition: IOVDbMetaDataTool.cxx:431
ServiceHandle< IIncidentSvc >