|
ATLAS Offline Software
|
Go to the documentation of this file.
18 #include "GaudiKernel/IIncidentSvc.h"
19 #include "GaudiKernel/FileIncident.h"
26 const std::string&
name,
29 , m_metaDataStore (
"StoreGateSvc/MetaDataStore",
name)
30 , m_inputStore (
"StoreGateSvc/InputMetaDataStore",
name)
31 , m_processedFirstInputFileIncident(false)
32 , m_overrideRunNumber(false)
33 , m_overrideMinMaxRunNumber(false)
38 , m_modifyFolders(false)
41 declareInterface<IIOVDbMetaDataTool>(
this);
42 declareInterface<IMetaDataTool>(
this);
69 incSvc->addListener(
this,
"FirstInputFile", 60);
79 return(StatusCode::SUCCESS);
87 return StatusCode::SUCCESS;
94 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
95 if(!fileInc)
throw std::runtime_error(
"Unable to get FileName from FirstInputFile incident");
97 const std::string
fileName = fileInc->fileName();
105 if(!
sc.isSuccess())
throw std::runtime_error(
"Could not process input file meta data");
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;
123 return StatusCode::SUCCESS;
128 return StatusCode::SUCCESS;
154 ATH_MSG_DEBUG(
"checkOverrideRunNumber: check if tag is set in jobOpts");
158 SmartIF<IProperty> appMgr{serviceLocator()->service(
"ApplicationMgr")};
160 ATH_MSG_ERROR(
"checkOverrideRunNumber: Cannot get ApplicationMgr ");
163 StringProperty property(
"EvtSel",
"");
165 if (!
sc.isSuccess()) {
166 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get EvtSel: found " << property.value());
171 SmartIF<IProperty> evtSel{serviceLocator()->service(
eventSelector)};
178 BooleanProperty overrideRunNumber = IntegerProperty(
"OverrideRunNumberFromInput",
false);
179 sc = evtSel->getProperty(&overrideRunNumber);
180 if (!
sc.isSuccess()) {
182 ATH_MSG_DEBUG(
"resetRunNumber: unable to get OverrideRunNumberFromInput property from EventSelector ");
188 IntegerProperty
runNumber = IntegerProperty(
"RunNumber", 0);
190 if (!
sc.isSuccess()) {
191 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get RunNumber from EventSelector: found "
197 runNumber = IntegerProperty(
"OldRunNumber", 0);
199 if (!
sc.isSuccess()) {
200 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get OldRunNumber from EventSelector: found "
219 std::string folderDescr =
"<timeStamp>run-event</timeStamp><addrHeader><address_header service_type=\"256\" clid=\"1238547719\" /> </addrHeader><typeName>CondAttrListCollection</typeName>" ;
228 const std::string& folderDescription)
const
231 std::scoped_lock guard(
m_mutex );
237 return(StatusCode::FAILURE);
243 return StatusCode::SUCCESS;
252 std::scoped_lock guard(
m_mutex );
259 ATH_MSG_DEBUG(
"Retrieved IOVMetaDataContainer from MetaDataStore for folder "
263 ATH_MSG_ERROR(
"addPayload: Could not find IOVMetaDataContainer in MetaDataStore for folder "
265 <<
". One must have previously called registerFolder. ");
266 return StatusCode::FAILURE;
282 <<
" (may be duplicate payload).");
291 std::ostringstream
stream;
296 return StatusCode::SUCCESS;
312 bool modifyAttr =
false;
313 std::string attributeName;
316 for (
unsigned int i = 0;
i <
folders.size(); ++
i) {
321 ATH_MSG_DEBUG(
"modifyPayload: remove attribute " << attributeName);
329 return StatusCode::SUCCESS;
332 bool iovSizeIsZero = coll->
iov_size() == 0;
345 unsigned int nchans = coll->
size();
346 bool hasChanNames = (coll->
name_size() == nchans);
352 for (
unsigned int iatt = 0; iatt < oldAttrList.size(); ++iatt) {
354 if (attributeName == oldAttrList[iatt].specification().name()) {
355 ATH_MSG_DEBUG(
"modifyPayload: skipping attribute name " << oldAttrList[iatt].specification().
name());
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()];
367 << oldAttrList[iatt].specification().
name() <<
" "
378 std::ostringstream
stream;
383 return StatusCode::SUCCESS;
399 ,
const std::string& folderDescription)
const
410 <<
". Created a new instance");
412 if (!
sc.isSuccess()) {
421 if (!
sc.isSuccess()) {
434 std::scoped_lock guard(
m_mutex );
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;
448 ATH_MSG_DEBUG(
"processInputFileMetaData: Retrieved from IOVMetaDataContainer(s) from InputMetaDataStore");
451 unsigned int ncolls = 0;
452 unsigned int ndupColls = 0;
453 for (; cont != contEnd; ++cont) {
455 , cont->folderDescription());
459 std::list<SG::ObjectWithVersion<IOVMetaDataContainer> > allVersions;
461 if (!
sc.isSuccess()) {
469 ATH_MSG_DEBUG(
"processInputFileMetaData: New container: payload size " <<
payload->size() <<
" version key " <<
obj.versionedKey);
474 ATH_MSG_VERBOSE(
"Before merge, payload minRange for folder " << cont->folderName());
475 if (payloadMaster && payloadMaster->
size()) {
479 unsigned int iPayload = 0;
480 for (; itColl != itCollEnd; ++itColl, ++iPayload) {
482 << (*itColl)->size());
496 std::ostringstream
stream;
497 for (; itColl1 != itCollEnd1; ++itColl1) (*itColl1)->dump(
stream);
508 for (; itColl != itCollEnd; ++itColl) {
520 ATH_MSG_ERROR(
"processInputFileMetaData: Could not modify the payload for folder " << contMaster->
folderName());
521 return StatusCode::FAILURE;
525 if (!contMaster->
merge(coll)) {
537 ATH_MSG_DEBUG(
"processInputFileMetaData: Merged together containers for folder " << cont->folderName() <<
" ncoll/ndup "
538 << ncolls <<
" " << ndupColls);
542 if (payloadMaster && payloadMaster->
size()) {
547 if ((*itColl)->minRange().start().isTimestamp()) lastStop =
IOVTime(0);
549 bool hasError =
false;
550 for (; itColl != itCollEnd; ++itColl) {
551 if ((*itColl)->minRange().start() < lastStop) hasError =
true;
552 lastStop = (*itColl)->minRange().stop();
555 ATH_MSG_ERROR(
"processInputFileMetaData: error after merge of file meta data. " );
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());
570 ATH_MSG_VERBOSE(
"processInputFileMetaData: After merge, payload minRange ");
575 unsigned int iPayload = 0;
576 for (; itColl != itCollEnd; ++itColl, ++iPayload) {
578 << (*itColl)->size());
586 ATH_MSG_DEBUG(
"processInputFileMetaData: Input payload " << cont->folderName());
587 std::ostringstream streamInp;
590 for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamInp);
593 std::ostringstream streamOut;
596 for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamOut);
602 ATH_MSG_DEBUG(
"processInputFileMetaData: Total number of attribute collections merged together " << ncolls
603 <<
" Number of duplicate collections " << ndupColls);
604 return StatusCode::SUCCESS;
622 bool iovSizeIsZero = coll->
iov_size() == 0;
627 if (
start.isRunEvent() &&
stop.isRunEvent()) {
636 return StatusCode::SUCCESS;
641 <<
" iovSizeIsZero: " << (
int)iovSizeIsZero
642 <<
" newRange " << newRange);
655 unsigned int nchans = coll->
size();
668 ATH_MSG_DEBUG(
"overrideIOV: after overriding the IOV of collection");
669 std::ostringstream
stream;
676 return StatusCode::SUCCESS;
void resetMinRange()
Reset minRange according to the IOVs of the contained channels.
const IOVRange & minRange() const
Current minimal IOVRange.
iov_size_type iov_size() const
number of Chan/IOV pairs
Validity Range object. Holds two IOVTimes (start and stop)
static constexpr uint32_t MAXRUN
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
const std::string & key() const
Get the key string with which the current object was stored.
const IOVTime & start() const
bool isInRange(const IOVTime &t) const
bool msgLvl(const MSG::Level lvl) const
void addNewStart(const IOVTime &start)
Add new start time to minRange - make sure that start is >= to new start.
#define ATH_MSG_VERBOSE(x)
This class is a collection of AttributeLists where each one is associated with a channel number....
size_type size() const
size of payload vector
const IOVTime & stop() const
const_iterator begin() const
Begin of payload vector.
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
void dump() const
Dump our contents to std::cout.
::StatusCode StatusCode
StatusCode definition for legacy code.
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
This class is a container for the payload of conditions data. It is intended to be used to store cond...
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
static constexpr uint32_t MAXEVENT
name_size_type name_size() const
number of Chan/Name pairs
size_type size() const
number of Chan/AttributeList pairs
payloadVec::const_iterator const_iterator
const_iterator end() const
End of payload vector.
const IOVRange & iovRange(ChanNum chanNum) const
IOVRange list for a given channel number.
coral::AttributeList AttributeList
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.