 |
ATLAS Offline Software
|
This is an interface to a tool used to manage the IOV Meta Data for a given object in the Meta Data Store.
More...
#include <IOVDbMetaDataTool.h>
This is an interface to a tool used to manage the IOV Meta Data for a given object in the Meta Data Store.
Definition at line 39 of file IOVDbMetaDataTool.h.
◆ StoreGateSvc_t
◆ IOVDbMetaDataTool()
| IOVDbMetaDataTool::IOVDbMetaDataTool |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
◆ ~IOVDbMetaDataTool()
| IOVDbMetaDataTool::~IOVDbMetaDataTool |
( |
| ) |
|
|
virtual |
◆ addPayload()
Add an IOV and Payload for a particular folder - replaces payloads if there is an IOV overlap.
Definition at line 363 of file IOVDbMetaDataTool.cxx.
367 std::scoped_lock guard(
m_mutex );
374 ATH_MSG_DEBUG(
"Retrieved IOVMetaDataContainer from MetaDataStore for folder "
378 ATH_MSG_ERROR(
"addPayload: Could not find IOVMetaDataContainer in MetaDataStore for folder "
380 <<
". One must have previously called registerFolder. ");
381 return StatusCode::FAILURE;
397 <<
" (may be duplicate payload).");
406 std::ostringstream
stream;
411 return StatusCode::SUCCESS;
◆ beginInputFile()
Function called when a new input file is opened.
Definition at line 227 of file IOVDbMetaDataTool.cxx.
233 return StatusCode::SUCCESS;
◆ checkOverrideRunNumber()
| void IOVDbMetaDataTool::checkOverrideRunNumber |
( |
| ) |
|
|
private |
check if we should override the run number in the incoming meta data
Definition at line 249 of file IOVDbMetaDataTool.cxx.
269 ATH_MSG_DEBUG(
"checkOverrideRunNumber: check if tag is set in jobOpts");
273 SmartIF<IProperty> appMgr{serviceLocator()->service(
"ApplicationMgr")};
275 ATH_MSG_ERROR(
"checkOverrideRunNumber: Cannot get ApplicationMgr ");
278 StringProperty property(
"EvtSel",
"");
280 if (!
sc.isSuccess()) {
281 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get EvtSel: found " << property.value());
286 SmartIF<IProperty> evtSel{serviceLocator()->service(
eventSelector)};
293 BooleanProperty overrideRunNumber(
"OverrideRunNumberFromInput",
false);
294 sc = evtSel->getProperty(&overrideRunNumber);
295 if (!
sc.isSuccess()) {
297 ATH_MSG_DEBUG(
"resetRunNumber: unable to get OverrideRunNumberFromInput property from EventSelector ");
303 IntegerProperty
runNumber(
"RunNumber", 0);
305 if (!
sc.isSuccess()) {
306 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get RunNumber from EventSelector: found "
312 IntegerProperty oldRunNumber(
"OldRunNumber", 0);
313 sc = evtSel->getProperty(&oldRunNumber);
314 if (!
sc.isSuccess()) {
315 ATH_MSG_ERROR(
"checkOverrideRunNumber: unable to get OldRunNumber from EventSelector: found "
316 << oldRunNumber.value());
◆ endInputFile()
Function called when the currently open input file got completely processed.
Definition at line 236 of file IOVDbMetaDataTool.cxx.
238 return StatusCode::SUCCESS;
◆ finalize()
| StatusCode IOVDbMetaDataTool::finalize |
( |
| ) |
|
|
overridevirtual |
◆ findMetaDataContainer()
◆ getMetaDataContainer()
return meta data container from the meta data store
Definition at line 513 of file IOVDbMetaDataTool.cxx.
525 <<
". Created a new instance");
527 if (!
sc.isSuccess()) {
536 if (!
sc.isSuccess()) {
◆ handle()
| void IOVDbMetaDataTool::handle |
( |
const Incident & |
incident | ) |
|
|
overridevirtual |
Incident service handle listening for BeginInputFile and EndInputFile.
Definition at line 211 of file IOVDbMetaDataTool.cxx.
213 const FileIncident* fileInc =
dynamic_cast<const FileIncident*
>(&inc);
214 if(!fileInc)
throw std::runtime_error(
"Unable to get FileName from FirstInputFile incident");
216 const std::string
fileName = fileInc->fileName();
223 if(!
sc.isSuccess())
throw std::runtime_error(
"Could not process input file meta data");
◆ initialize()
| StatusCode IOVDbMetaDataTool::initialize |
( |
| ) |
|
|
overridevirtual |
Initialize AlgTool.
Definition at line 59 of file IOVDbMetaDataTool.cxx.
66 incSvc->addListener(
this,
"FirstInputFile", 60);
79 std::map<std::string, std::map<std::string, std::string>> folderPayloads;
83 size_t colonPos =
key.find(
':');
84 if (colonPos == std::string::npos) {
85 ATH_MSG_ERROR(
"Invalid payload key format: " <<
key <<
" (expected 'folder:key')");
86 return StatusCode::FAILURE;
90 std::string paramName =
key.substr(colonPos + 1);
94 ATH_MSG_DEBUG(
"Processing " << folderPayloads.size() <<
" folder(s) for direct payload registration");
97 std::map<std::string, std::pair<std::unique_ptr<CondAttrListCollection>, EventIDRange>> payloadsForCondStore;
103 return StatusCode::FAILURE;
106 unsigned int beginRun = std::stoul(
parameters.at(
"beginRun"));
107 unsigned int endRun = std::stoul(
parameters.at(
"endRun"));
110 std::map<std::string, std::string> filteredParams;
112 [](
const auto&
p) { return p.first !=
"beginRun" && p.first !=
"endRun"; });
115 <<
" parameters, IOV [" << beginRun <<
", " << endRun <<
"]");
122 coral::AttributeListSpecification*
spec =
new coral::AttributeListSpecification();
123 for (
const auto& [
key,
value] : filteredParams) {
128 for (
const auto& [
key,
value] : filteredParams) {
132 auto payload = std::make_unique<CondAttrListCollection>(
true);
137 ATH_MSG_DEBUG(
"Created payload with IOV [" << beginRun <<
", " << endRun <<
"]");
140 EventIDRange iovRange(EventIDBase(beginRun, EventIDBase::UNDEFEVT, 0, 0, 0),
141 EventIDBase(endRun, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM));
142 payloadsForCondStore[
folderName] = std::make_pair(std::make_unique<CondAttrListCollection>(*
payload), iovRange);
149 if (!payloadsForCondStore.empty()) {
150 ATH_MSG_INFO(
"Registering " << payloadsForCondStore.size() <<
" payload(s) to ConditionStore");
157 for (
auto& [
folderName, payloadPair] : payloadsForCondStore) {
158 auto& [
payload, iovRange] = payloadPair;
171 return StatusCode::FAILURE;
176 return StatusCode::FAILURE;
185 return StatusCode::FAILURE;
190 auto athAttrList = std::make_unique<AthenaAttributeList>(attrList);
192 ATH_CHECK(
cc->insert(iovRange, std::move(athAttrList), Gaudi::Hive::currentContext()));
198 return(StatusCode::SUCCESS);
◆ lock_shared()
| virtual void IOVDbMetaDataTool::lock_shared |
( |
| ) |
const |
|
inlinefinaloverridevirtual |
◆ metaDataStop()
| StatusCode IOVDbMetaDataTool::metaDataStop |
( |
| ) |
|
|
overridevirtual |
Function called when the tool should write out its metadata.
Definition at line 241 of file IOVDbMetaDataTool.cxx.
243 return StatusCode::SUCCESS;
◆ modifyPayload()
Modify a Payload for a particular folder - replaces one of the internal attributes.
Modify a Payload for a particular folder - replaces one of the internal attributes
Definition at line 417 of file IOVDbMetaDataTool.cxx.
427 bool modifyAttr =
false;
428 std::string attributeName;
431 for (
unsigned int i = 0;
i <
folders.size(); ++
i) {
436 ATH_MSG_DEBUG(
"modifyPayload: remove attribute " << attributeName);
444 return StatusCode::SUCCESS;
447 bool iovSizeIsZero = coll->iov_size() == 0;
448 IOVRange testIOV = coll->minRange();
460 unsigned int nchans = coll->size();
461 bool hasChanNames = (coll->name_size() == nchans);
467 for (
unsigned int iatt = 0; iatt < oldAttrList.size(); ++iatt) {
469 if (attributeName == oldAttrList[iatt].specification().name()) {
470 ATH_MSG_DEBUG(
"modifyPayload: skipping attribute name " << oldAttrList[iatt].specification().
name());
475 newAttrList.extend(oldAttrList[iatt].specification().
name(),
476 oldAttrList[iatt].specification().
type());
477 const coral::Attribute& oldAttr = oldAttrList[iatt];
478 coral::Attribute& newAttr = newAttrList[oldAttrList[iatt].specification().name()];
482 << oldAttrList[iatt].specification().
name() <<
" "
486 if (!iovSizeIsZero) coll1->
add(
chan, coll->iovRange(
chan));
487 if(hasChanNames)coll1->
add(
chan, coll->chanName(
chan));
493 std::ostringstream
stream;
498 return StatusCode::SUCCESS;
◆ overrideIOV()
override IOV with new run number
Definition at line 817 of file IOVDbMetaDataTool.cxx.
829 bool iovSizeIsZero = coll->
iov_size() == 0;
834 if (
start.isRunEvent() &&
stop.isRunEvent()) {
843 return StatusCode::SUCCESS;
848 <<
" iovSizeIsZero: " << (
int)iovSizeIsZero
849 <<
" newRange " << newRange);
862 unsigned int nchans = coll->
size();
875 ATH_MSG_DEBUG(
"overrideIOV: after overriding the IOV of collection");
876 std::ostringstream
stream;
883 return StatusCode::SUCCESS;
◆ processInputFileMetaData()
| StatusCode IOVDbMetaDataTool::processInputFileMetaData |
( |
const std::string & |
fileName | ) |
|
|
overridevirtual |
Explicit call to process IOV meta data from the input meta data store, transferring it to the main meta data store.
Normally, this method is called at the BeginInputFile incident. However, this explicit call allows the transfer to occur during the initialization phase, which occurs before BeginInputFile incident.
Definition at line 546 of file IOVDbMetaDataTool.cxx.
549 std::scoped_lock guard(
m_mutex );
558 if (!
sc.isSuccess()) {
559 ATH_MSG_DEBUG(
"processInputFileMetaData: Could not retrieve IOVMetaDataContainer objects from InputMetaDataStore - cannot process input file meta data");
560 return StatusCode::SUCCESS;
563 ATH_MSG_DEBUG(
"processInputFileMetaData: Retrieved from IOVMetaDataContainer(s) from InputMetaDataStore");
566 unsigned int ncolls = 0;
567 unsigned int ndupColls = 0;
568 for (; cont != contEnd; ++cont) {
570 , cont->folderDescription());
574 std::list<SG::ObjectWithVersion<IOVMetaDataContainer> > allVersions;
576 if (!
sc.isSuccess()) {
584 ATH_MSG_DEBUG(
"processInputFileMetaData: New container: payload size " <<
payload->size() <<
" version key " <<
obj.versionedKey);
589 ATH_MSG_VERBOSE(
"Before merge, payload minRange for folder " << cont->folderName());
590 if (payloadMaster && payloadMaster->
size()) {
594 unsigned int iPayload = 0;
595 for (; itColl != itCollEnd; ++itColl, ++iPayload) {
597 << (*itColl)->size());
611 std::ostringstream
stream;
612 for (; itColl1 != itCollEnd1; ++itColl1) (*itColl1)->dump(
stream);
623 for (; itColl != itCollEnd; ++itColl) {
635 ATH_MSG_ERROR(
"processInputFileMetaData: Could not modify the payload for folder " << contMaster->
folderName());
636 return StatusCode::FAILURE;
640 if (!contMaster->
merge(coll)) {
652 ATH_MSG_DEBUG(
"processInputFileMetaData: Merged together containers for folder " << cont->folderName() <<
" ncoll/ndup "
653 << ncolls <<
" " << ndupColls);
657 if (payloadMaster && payloadMaster->
size()) {
662 if ((*itColl)->minRange().start().isTimestamp()) lastStop =
IOVTime(0);
664 bool hasError =
false;
665 for (; itColl != itCollEnd; ++itColl) {
666 if ((*itColl)->minRange().start() < lastStop) hasError =
true;
667 lastStop = (*itColl)->minRange().stop();
670 ATH_MSG_ERROR(
"processInputFileMetaData: error after merge of file meta data. " );
673 ATH_MSG_ERROR(
"processInputFileMetaData: MinRange for meta data folders ");
674 unsigned int iPayload = 0;
675 itColl = payloadMaster->
begin();
676 for (; itColl != itCollEnd; ++itColl, ++iPayload) {
677 ATH_MSG_ERROR(iPayload <<
" " << (*itColl)->minRange() <<
" " << (*itColl)->size());
685 ATH_MSG_VERBOSE(
"processInputFileMetaData: After merge, payload minRange ");
690 unsigned int iPayload = 0;
691 for (; itColl != itCollEnd; ++itColl, ++iPayload) {
693 << (*itColl)->size());
701 ATH_MSG_DEBUG(
"processInputFileMetaData: Input payload " << cont->folderName());
702 std::ostringstream streamInp;
705 for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamInp);
708 std::ostringstream streamOut;
711 for (; itColl != itCollEnd; ++itColl) (*itColl)->dump(streamOut);
717 ATH_MSG_DEBUG(
"processInputFileMetaData: Total number of attribute collections merged together " << ncolls
718 <<
" Number of duplicate collections " << ndupColls);
725 constexpr
std::array folderNames{
"/Digitization/Parameters",
"/Simulation/Parameters"};
726 for (std::string_view
folderName : folderNames) {
735 bool inPayloads =
false;
751 if (payloadMaster && payloadMaster->
size() > 0) {
777 return StatusCode::FAILURE;
782 return StatusCode::FAILURE;
789 auto itr = coll->
begin();
791 auto athAttrList = std::make_unique<AthenaAttributeList>(attrList);
803 ATH_CHECK(
cc->insert(
range, std::move(athAttrList), Gaudi::Hive::currentContext()));
811 return StatusCode::SUCCESS;
◆ registerFolder() [1/2]
| StatusCode IOVDbMetaDataTool::registerFolder |
( |
const std::string & |
folderName | ) |
const |
|
overridevirtual |
Register folder in the IOV Db MetaData without folder description - uses default folder description for CondAttrListCollection.
Definition at line 330 of file IOVDbMetaDataTool.cxx.
334 std::string
folderDescr =
"<timeStamp>run-event</timeStamp><addrHeader><address_header service_type=\"256\" clid=\"1238547719\" /> </addrHeader><typeName>CondAttrListCollection</typeName>" ;
◆ registerFolder() [2/2]
| StatusCode IOVDbMetaDataTool::registerFolder |
( |
const std::string & |
folderName, |
|
|
const std::string & |
folderDescription |
|
) |
| const |
|
overridevirtual |
Register folder in the IOV Db MetaData - done once at initialize.
Definition at line 342 of file IOVDbMetaDataTool.cxx.
346 std::scoped_lock guard(
m_mutex );
352 return(StatusCode::FAILURE);
358 return StatusCode::SUCCESS;
◆ unlock_shared()
| virtual void IOVDbMetaDataTool::unlock_shared |
( |
| ) |
const |
|
inlinefinaloverridevirtual |
◆ m_attributesToBeRemoved
| StringArrayProperty IOVDbMetaDataTool::m_attributesToBeRemoved {this, "AttributesToBeRemoved", {"RandomSeedOffset"}} |
|
private |
◆ m_condStore
◆ m_filesProcessed
| std::set<std::string> IOVDbMetaDataTool::m_filesProcessed |
|
private |
◆ m_foldersToBeModified
| StringArrayProperty IOVDbMetaDataTool::m_foldersToBeModified {this, "FoldersToBeModified", {"/Simulation/Parameters"}} |
|
private |
◆ m_inputStore
◆ m_maxRunNumber
| unsigned int IOVDbMetaDataTool::m_maxRunNumber |
|
private |
◆ m_metaDataStore
◆ m_minMaxRunNumbers
| UnsignedIntegerArrayProperty IOVDbMetaDataTool::m_minMaxRunNumbers {this, "MinMaxRunNumbers", {}, "Min/max run numbers for overriding meta data IOV"} |
|
private |
◆ m_minRunNumber
| unsigned int IOVDbMetaDataTool::m_minRunNumber |
|
private |
◆ m_modifyFolders
| bool IOVDbMetaDataTool::m_modifyFolders |
|
private |
◆ m_mutex
| std::shared_mutex IOVDbMetaDataTool::m_mutex |
|
mutableprivate |
◆ m_newRunNumber
| unsigned int IOVDbMetaDataTool::m_newRunNumber |
|
private |
◆ m_oldRunNumber
| unsigned int IOVDbMetaDataTool::m_oldRunNumber |
|
private |
◆ m_overrideMinMaxRunNumber
| bool IOVDbMetaDataTool::m_overrideMinMaxRunNumber |
|
private |
◆ m_overrideRunNumber
| bool IOVDbMetaDataTool::m_overrideRunNumber |
|
private |
◆ m_payloads
| Gaudi::Property<std::map<std::string, std::string> > IOVDbMetaDataTool::m_payloads |
|
private |
Initial value:{
this, "Payloads", {}, "Direct payload registration (format: {folder:key: value})"}
Definition at line 142 of file IOVDbMetaDataTool.h.
The documentation for this class was generated from the following files:
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
uint32_t event() const noexcept
static CondContFactory & Instance()
SG::DataObjectSharedPtr< DataObject > Create(Athena::IRCUSvc &rcusvc, const CLID &clid, const std::string &key) const
void addNewStop(const IOVTime &stop)
Add new stop time to minRange - make sure that stop is <= to new stop
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
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
void addNewStart(const IOVTime &start)
Add new start time to minRange - make sure that start is >= to new start.
Simple smart pointer for Gaudi-style refcounted objects.
#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.
Default, invalid implementation of ClassID_traits.
Out copy_if(In first, const In &last, Out res, const Pred &p)
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
This class is a container for the payload of conditions data. It is intended to be used to store cond...
static constexpr uint32_t MAXEVENT
uint32_t run() const noexcept
size_type size() const
number of Chan/AttributeList pairs
payloadVec::const_iterator const_iterator
const_iterator end() const
End of payload vector.
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.