ATLAS Offline Software
IOVDbMetaDataTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  IProperty* propertyServer(0);
159  StatusCode sc = serviceLocator()->service("ApplicationMgr", propertyServer);
160  if (sc != StatusCode::SUCCESS ) {
161  ATH_MSG_ERROR("checkOverrideRunNumber: Cannot get ApplicationMgr ");
162  return;
163  }
164  StringProperty property("EvtSel", "");
165  sc = propertyServer->getProperty(&property);
166  if (!sc.isSuccess()) {
167  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get EvtSel: found " << property.value());
168  return;
169  }
170  // Get EventSelector for ApplicationMgr
171  std::string eventSelector = property.value();
172  sc = serviceLocator()->service(eventSelector, propertyServer);
173  if (sc != StatusCode::SUCCESS ) {
174  ATH_MSG_ERROR("checkOverrideRunNumber: Cannot get EventSelector " << eventSelector);
175  return;
176  }
177 
178  // Is flag set to override the run number?
179  BooleanProperty overrideRunNumber = IntegerProperty("OverrideRunNumberFromInput", false);
180  sc = propertyServer->getProperty(&overrideRunNumber);
181  if (!sc.isSuccess()) {
182  // Not all EventSelectors have this property, so we must be tolerant
183  ATH_MSG_DEBUG("resetRunNumber: unable to get OverrideRunNumberFromInput property from EventSelector ");
184  return;
185  }
186  m_overrideRunNumber = overrideRunNumber.value();
187  if (m_overrideRunNumber) {
188  // New run number
189  IntegerProperty runNumber = IntegerProperty("RunNumber", 0);
190  sc = propertyServer->getProperty(&runNumber);
191  if (!sc.isSuccess()) {
192  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get RunNumber from EventSelector: found "
193  << runNumber.value());
194  return;
195  }
196  m_newRunNumber = runNumber.value();
197  // Old run number
198  runNumber = IntegerProperty("OldRunNumber", 0);
199  sc = propertyServer->getProperty(&runNumber);
200  if (!sc.isSuccess()) {
201  ATH_MSG_ERROR("checkOverrideRunNumber: unable to get OldRunNumber from EventSelector: found "
202  << runNumber.value());
203  return;
204  }
205  m_oldRunNumber = runNumber.value();
206 
207  ATH_MSG_DEBUG("checkOverrideRunNumber: Changing old to new run number: " << m_oldRunNumber
208  << " " << m_newRunNumber << " obtained from " << eventSelector);
209  }
210  else ATH_MSG_DEBUG("checkOverrideRunNumber: OverrideRunNumberFromInput not set for " << eventSelector);
211 }
212 
213 //--------------------------------------------------------------------------
214 
217 {
218  // Set the default folder description for a CondAttrListCollection
219  // which will be read back via IOVDbSvc
220  std::string folderDescr = "<timeStamp>run-event</timeStamp><addrHeader><address_header service_type=\"256\" clid=\"1238547719\" /> </addrHeader><typeName>CondAttrListCollection</typeName>" ;
221 
222  return registerFolder(folderName, folderDescr);
223 }
224 
225 //--------------------------------------------------------------------------
226 
229  const std::string& folderDescription) const
230 {
231  // lock the tool before getMetaDataContainer() call
232  std::scoped_lock guard( m_mutex );
233 
234  ATH_MSG_DEBUG("begin registerFolder ");
235 
236  if( ! getMetaDataContainer(folderName, folderDescription) ) {
237  ATH_MSG_ERROR("Unable to register folder " << folderName);
238  return(StatusCode::FAILURE);
239  }
240  else {
241  ATH_MSG_DEBUG("IOVMetaDataContainer for folder " << folderName << " has been registered ");
242  }
243 
244  return StatusCode::SUCCESS;
245 }
246 
247 //--------------------------------------------------------------------------
248 
251 {
252  // lock the tool while it is modifying the folder
253  std::scoped_lock guard( m_mutex );
254 
255  ATH_MSG_DEBUG("begin addPayload ");
256 
257  // Check if the folder has already been found
259  if(cont) {
260  ATH_MSG_DEBUG("Retrieved IOVMetaDataContainer from MetaDataStore for folder "
261  << folderName);
262  }
263  else {
264  ATH_MSG_ERROR("addPayload: Could not find IOVMetaDataContainer in MetaDataStore for folder "
265  << folderName
266  << ". One must have previously called registerFolder. ");
267  return StatusCode::FAILURE;
268  }
269 
270  // Override run number if requested
273  }
274 
275  // Add payload to container
276  bool success = cont->merge(payload);
277  if (success) {
278  ATH_MSG_DEBUG("Added new payload for folder " << folderName);
279  }
280  else {
281  ATH_MSG_DEBUG("Could not add new payload for folder "
282  << folderName
283  << " (may be duplicate payload).");
284 
285  // To Do: the function implicitly assumes ownership on the payload pointer
286  delete payload;
287  payload = nullptr;
288  }
289 
290  // Debug printout
291  if(payload && msgLvl(MSG::DEBUG)) {
292  std::ostringstream stream;
293  payload->dump(stream);
294  ATH_MSG_DEBUG(stream.str());
295  }
296 
297  return StatusCode::SUCCESS;
298 }
299 
300 //--------------------------------------------------------------------------
301 
304  CondAttrListCollection*& coll) const
305 {
306  // protected by lock in processInputFileMetaData()
307 
310  ATH_MSG_DEBUG("begin modifyPayload for folder " << folderName);
311 
312  // check if this folder needs to be modified
313  bool modifyAttr = false;
314  std::string attributeName;
315  const std::vector<std::string>& folders = m_foldersToBeModified.value();
316  const std::vector<std::string>& attrs = m_attributesToBeRemoved.value();
317  for (unsigned int i = 0; i < folders.size(); ++i) {
318  if (folderName == folders[i]) {
319  if (attrs.size() > i) {
320  attributeName = attrs[i];
321  modifyAttr = true;
322  ATH_MSG_DEBUG("modifyPayload: remove attribute " << attributeName);
323  break;
324  }
325  }
326  }
327 
328  if (!modifyAttr) {
329  ATH_MSG_DEBUG("modifyPayload: folder " << folderName << " OK ");
330  return StatusCode::SUCCESS;
331  }
332 
333  bool iovSizeIsZero = coll->iov_size() == 0;
334  IOVRange testIOV = coll->minRange();
335  IOVTime start = testIOV.start();
336  IOVTime stop = testIOV.stop();
337  // Set the IOV
339  if (iovSizeIsZero) {
340  // Only add in overall range if channels do not have
341  // IOVs - otherwise this is automatically calculated
342  coll1->addNewStart(start);
343  coll1->addNewStop (stop);
344  }
345  // Add in channels
346  unsigned int nchans = coll->size();
347  bool hasChanNames = (coll->name_size() == nchans);
348  for (unsigned int ichan = 0; ichan < nchans; ++ichan) {
350  // Now filter out the unwanted attribute
352  const CondAttrListCollection::AttributeList& oldAttrList = coll->attributeList(chan);
353  for (unsigned int iatt = 0; iatt < oldAttrList.size(); ++iatt) {
354  // skip the unwanted attribute
355  if (attributeName == oldAttrList[iatt].specification().name()) {
356  ATH_MSG_DEBUG("modifyPayload: skipping attribute name " << oldAttrList[iatt].specification().name());
357  continue;
358  }
359 
360  // copy the rest
361  newAttrList.extend(oldAttrList[iatt].specification().name(),
362  oldAttrList[iatt].specification().type());
363  const coral::Attribute& oldAttr = oldAttrList[iatt];
364  coral::Attribute& newAttr = newAttrList[oldAttrList[iatt].specification().name()];
365  newAttr = oldAttr;
366  // newAttr.setValue(oldAttr.data());
367  ATH_MSG_DEBUG("modifyPayload: copying attr name "
368  << oldAttrList[iatt].specification().name() << " "
369  /*<< newAttr*/);
370  }
371  coll1->add(chan, newAttrList);
372  if (!iovSizeIsZero) coll1->add(chan, coll->iovRange(chan));
373  if(hasChanNames)coll1->add(chan, coll->chanName(chan));
374  ATH_MSG_DEBUG("modifyPayload: copied attribute list for channel " << chan);
375  }
376  delete coll;
377  coll = coll1;
378  if (msgLvl(MSG::DEBUG)) {
379  std::ostringstream stream;
380  coll->dump(stream);
381  ATH_MSG_DEBUG(stream.str());
382  }
383 
384  return StatusCode::SUCCESS;
385 }
386 
387 //--------------------------------------------------------------------------
388 
391 {
392  // lock the tool before this call
393  // Return the folder if it is in the meta data store
394  return m_metaDataStore->tryRetrieve<IOVMetaDataContainer>(folderName);
395 }
396 
397 
400  , const std::string& folderDescription) const
401 {
402  // protected by locks in addPayload() and registerFolder()
403  ATH_MSG_DEBUG("begin getMetaDataContainer ");
404 
405  IOVMetaDataContainer* cont{nullptr};
406  // See if it is in the meta data store
408  // Container not found, add in new one
409  cont = new IOVMetaDataContainer(folderName, folderDescription);
410  ATH_MSG_DEBUG("No IOVMetaDataContainer in MetaDataStore for folder " << folderName
411  << ". Created a new instance");
412  StatusCode sc = m_metaDataStore->record(cont, folderName);
413  if (!sc.isSuccess()) {
414  ATH_MSG_ERROR("Could not record IOVMetaDataContainer in MetaDataStore for folder " << folderName);
415  delete cont;
416  cont = nullptr;
417  }
418  }
419  else {
420  ATH_MSG_DEBUG("IOVMetaDataContainer already in MetaDataStore for folder " << folderName);
421  StatusCode sc = m_metaDataStore->retrieve(cont, folderName);
422  if (!sc.isSuccess()) {
423  ATH_MSG_ERROR("Could not retrieve IOVMetaDataContainer in MetaDataStore for folder " << folderName);
424  cont = nullptr;
425  }
426  }
427  return cont;
428 }
429 
430 //--------------------------------------------------------------------------
431 
433 {
434  // lock the tool while it is processing input metadata
435  std::scoped_lock guard( m_mutex );
436 
437  ATH_MSG_DEBUG("processInputFileMetaData: file name " << fileName);
438 
439  // Retrieve all meta data containers from InputMetaDataStore
442 
443  StatusCode sc = m_inputStore->retrieve(cont, contEnd);
444  if (!sc.isSuccess()) {
445  ATH_MSG_DEBUG("processInputFileMetaData: Could not retrieve IOVMetaDataContainer objects from InputMetaDataStore - cannot process input file meta data");
446  return StatusCode::SUCCESS;
447  }
448 
449  ATH_MSG_DEBUG("processInputFileMetaData: Retrieved from IOVMetaDataContainer(s) from InputMetaDataStore");
450 
451  // For each container, merge its contents into the MetaDataStore
452  unsigned int ncolls = 0;
453  unsigned int ndupColls = 0;
454  for (; cont != contEnd; ++cont) {
455  IOVMetaDataContainer* contMaster = getMetaDataContainer(cont->folderName()
456  , cont->folderDescription());
457 
458  // We assume that the folder is the same for all versions, and
459  // now we loop over versions for the payloads
460  std::list<SG::ObjectWithVersion<IOVMetaDataContainer> > allVersions;
461  sc = m_inputStore->retrieveAllVersions(allVersions, cont.key());
462  if (!sc.isSuccess()) {
463  ATH_MSG_ERROR("Could not retrieve all versions for " << cont.key());
464  return sc;
465  }
466 
467  for (SG::ObjectWithVersion<IOVMetaDataContainer>& obj : allVersions) {
468  const IOVPayloadContainer* payload = obj.dataObject->payloadContainer();
469 
470  ATH_MSG_DEBUG("processInputFileMetaData: New container: payload size " << payload->size() << " version key " << obj.versionedKey);
471 
472  // detailed printout before merge
473  if (msgLvl(MSG::VERBOSE)) {
474  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
475  ATH_MSG_VERBOSE("Before merge, payload minRange for folder " << cont->folderName());
476  if (payloadMaster && payloadMaster->size()) {
477  // Loop over AttrColls and print out minRange
478  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
479  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
480  unsigned int iPayload = 0;
481  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
482  ATH_MSG_VERBOSE(iPayload << " " << (*itColl)->minRange() << " "
483  << (*itColl)->size());
484  }
485  }
486  else {
487  ATH_MSG_VERBOSE(" no payloads yet!");
488  }
489  }
490  }
491 
492  // Detailed printout
493  if (msgLvl(MSG::DEBUG)) {
494  ATH_MSG_DEBUG("processInputFileMetaData: Current payload before merge " << contMaster->folderName());
496  IOVPayloadContainer::const_iterator itCollEnd1 = contMaster->payloadContainer()->end();
497  std::ostringstream stream;
498  for (; itColl1 != itCollEnd1; ++itColl1) (*itColl1)->dump(stream);
499  ATH_MSG_DEBUG(stream.str());
500  }
501 
502  //
503  // Loop over CondAttrListCollections and do merge
504  //
505  for (SG::ObjectWithVersion<IOVMetaDataContainer>& obj : allVersions) {
506  const IOVPayloadContainer* payload = obj.dataObject->payloadContainer();
508  IOVPayloadContainer::const_iterator itCollEnd = payload->end();
509  for (; itColl != itCollEnd; ++itColl) {
510 
511  // Make a copy of the collection and merge it into
512  // master container in meta data store
513  CondAttrListCollection* coll = new CondAttrListCollection(**itColl);
514  // Override run number if requested
516  ATH_CHECK( overrideIOV(coll) );
517  }
518 
519  // first check if we need to modify the incoming payload
520  if (!modifyPayload (contMaster->folderName(), coll).isSuccess()) {
521  ATH_MSG_ERROR("processInputFileMetaData: Could not modify the payload for folder " << contMaster->folderName());
522  return StatusCode::FAILURE;
523  }
524 
525  ATH_MSG_VERBOSE("processInputFileMetaData: merge minRange: " << coll->minRange());
526  if (!contMaster->merge(coll)) {
527  // Did not merge it in - was a duplicate, so we need to delete it
528  delete coll;
529  ++ndupColls;
530  ATH_MSG_VERBOSE(" => not merged ");
531  }
532  else {
533  ++ncolls;
534  ATH_MSG_VERBOSE(" => merged ");
535  }
536 
537  }
538  ATH_MSG_DEBUG("processInputFileMetaData: Merged together containers for folder " << cont->folderName() << " ncoll/ndup "
539  << ncolls << " " << ndupColls);
540 
541  // Check for consistency after merge
542  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
543  if (payloadMaster && payloadMaster->size()) {
544  // Loop over AttrColls and print out minRange
545  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
546  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
547  IOVTime lastStop;
548  if ((*itColl)->minRange().start().isTimestamp()) lastStop = IOVTime(0);
549  else lastStop = IOVTime(0,0);
550  bool hasError = false;
551  for (; itColl != itCollEnd; ++itColl) {
552  if ((*itColl)->minRange().start() < lastStop) hasError = true;
553  lastStop = (*itColl)->minRange().stop();
554  }
555  if (hasError) {
556  ATH_MSG_ERROR("processInputFileMetaData: error after merge of file meta data. " );
557  ATH_MSG_ERROR("processInputFileMetaData: Filename " << fileName);
558  ATH_MSG_ERROR("processInputFileMetaData: folder " << contMaster->folderName());
559  ATH_MSG_ERROR("processInputFileMetaData: MinRange for meta data folders ");
560  unsigned int iPayload = 0;
561  itColl = payloadMaster->begin();
562  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
563  ATH_MSG_ERROR(iPayload << " " << (*itColl)->minRange() << " " << (*itColl)->size());
564  }
565  }
566  }
567 
568  // detailed printout after merge
569  if (msgLvl(MSG::VERBOSE)) {
570  const IOVPayloadContainer* payloadMaster = contMaster->payloadContainer();
571  ATH_MSG_VERBOSE("processInputFileMetaData: After merge, payload minRange ");
572  if (payloadMaster) {
573  // Loop over AttrColls and print out minRange
574  IOVPayloadContainer::const_iterator itColl = payloadMaster->begin();
575  IOVPayloadContainer::const_iterator itCollEnd = payloadMaster->end();
576  unsigned int iPayload = 0;
577  for (; itColl != itCollEnd; ++itColl, ++iPayload) {
578  ATH_MSG_VERBOSE(iPayload << " " << (*itColl)->minRange() << " "
579  << (*itColl)->size());
580  }
581  }
582  else { ATH_MSG_ERROR(" no payloads yet!"); }
583  }
584 
585  // Detailed printout
586  if (msgLvl(MSG::DEBUG)) {
587  ATH_MSG_DEBUG("processInputFileMetaData: Input payload " << cont->folderName());
588  std::ostringstream streamInp;
589  itColl = payload->begin();
590  itCollEnd = payload->end();
591  for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamInp);
592  ATH_MSG_DEBUG(streamInp.str());
593  ATH_MSG_DEBUG("processInputFileMetaData: Output payload " << contMaster->folderName());
594  std::ostringstream streamOut;
595  itColl = contMaster->payloadContainer()->begin();
596  itCollEnd = contMaster->payloadContainer()->end();
597  for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamOut);
598  ATH_MSG_DEBUG(streamOut.str());
599  }
600  }
601  }
602 
603  ATH_MSG_DEBUG("processInputFileMetaData: Total number of attribute collections merged together " << ncolls
604  << " Number of duplicate collections " << ndupColls);
605  return StatusCode::SUCCESS;
606 }
607 
608 //--------------------------------------------------------------------------
609 
612 {
613  ATH_MSG_DEBUG("overrideIOV ");
614 
615  // Override the IOV for run/event IOVs
616 
617  // (ONLY TRUE FOR OVERRIDE COMING IN VIA EVENTSELECTOR:)
618  // NOTE: we require that the old run number falls within the
619  // IOVRange of the incoming collection. We override ALL IOVs for
620  // ALL channels forcing the IOVRange to be (newRunNumber,1) to
621  // (newRunNumber+1,1)
622 
623  bool iovSizeIsZero = coll->iov_size() == 0;
624  IOVRange testIOV = coll->minRange();
625  IOVTime start = testIOV.start();
626  IOVTime stop = testIOV.stop();
627  IOVTime oldRun(m_oldRunNumber, 0);
628  if (start.isRunEvent() && stop.isRunEvent()) { // only for run/event
629  IOVRange newRange;
630  // Two ways of resetting
632  else if (m_overrideRunNumber) newRange = IOVRange(IOVTime(m_newRunNumber, 0), IOVTime(m_newRunNumber + 1, 0));
633 
634  if (m_overrideRunNumber && !testIOV.isInRange(oldRun)) {
635  // old run must be in the range
636  ATH_MSG_ERROR("overrideIOV: old run number does not match. Old run number " << m_oldRunNumber << " IOVRange: " << testIOV);
637  return StatusCode::SUCCESS;
638  }
639 
640  ATH_MSG_DEBUG("overrideIOV: overrideMinMaxRunNumber: " << (int)m_overrideMinMaxRunNumber
641  << " overrideRunNumber " << (int)m_overrideRunNumber
642  << " iovSizeIsZero: " << (int)iovSizeIsZero
643  << " newRange " << newRange);
644 
645  // Now over ride IOVs - two cases: 1) single IOV for full collection, 2) IOVs for individual channels.
646  // Must treat the reset of collection IOV differently
647  if (iovSizeIsZero) {
648  // Only add in overall range if channels do not have
649  // IOVs - otherwise this is automatically calculated
650  coll->resetMinRange(); // must first reset to 'full range' and then reduce the IOVRange accordingly
651  coll->addNewStart(newRange.start());
652  coll->addNewStop (newRange.stop());
653  }
654  else {
655  // Add in channels
656  unsigned int nchans = coll->size();
657  ATH_MSG_DEBUG("overrideIOV: nchans " << nchans);
658  for (unsigned int ichan = 0; ichan < nchans; ++ichan) {
659  // FIXME: O(N^2)!
661  coll->add(chan, newRange);
662  ATH_MSG_DEBUG("overrideIOV: overriding the IOV of collection chan " << chan);
663  }
664  // must reset the collection range AFTER the channels, because the collection range will be
665  // 'narrowed' to that of the channels
666  coll->resetMinRange();
667  }
668  if (msgLvl(MSG::DEBUG)) {
669  ATH_MSG_DEBUG("overrideIOV: after overriding the IOV of collection");
670  std::ostringstream stream;
671  coll->dump(stream);
672  ATH_MSG_DEBUG(stream.str());
673  }
674  }
675  else ATH_MSG_DEBUG("overrideIOV: IOV is not run/event ");
676 
677  return StatusCode::SUCCESS;
678 }
679 
CondAttrListCollection::resetMinRange
void resetMinRange()
Reset minRange according to the IOVs of the contained channels.
Definition: CondAttrListCollection.h:529
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:399
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::minRange
IOVRange minRange() const
Current minimal IOVRange.
Definition: CondAttrListCollection.h:438
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:249
IOVDbMetaDataTool::overrideIOV
StatusCode overrideIOV(CondAttrListCollection *&coll) const
override IOV with new run number
Definition: IOVDbMetaDataTool.cxx:611
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
defineDB.folders
list folders
Definition: JetTagCalibration/share/defineDB.py:26
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:92
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:303
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:192
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
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:228
SG::SourceID
std::string SourceID
Definition: AthenaKernel/AthenaKernel/SourceID.h:23
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:390
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:135
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:432
ServiceHandle< IIncidentSvc >