36 ATH_CHECK(DetDescrConverter::initialize());
44 return StatusCode::SUCCESS;
48 return StatusCode::SUCCESS;
75 "in createObj: creating a IdDictManager object in the detector store");
79 return StatusCode::FAILURE;
83 std::string mgrKey = *(ddAddr->par());
103 return StatusCode::SUCCESS;
126 m_parser = std::make_unique<IdDictParser>();
157 "Dictonary file name from job options or using defaults.");
213 size_t ndict = mgr.get_dictionaries().size();
216 return StatusCode::FAILURE;
225 "NOTE: ** parseXMLDescription called, but parsing was deemed "
228 ATH_MSG_DEBUG(
"parseXMLDescription: Finished parsing and setting options ");
229 return StatusCode::SUCCESS;
236 const IRDBRecord *neighborTable = (*recordset)[0];
274 ATH_MSG_INFO(
"Using dictionary tag: " << (tag.empty() ?
"<no tag>" : tag));
277 std::string version =
278 (
"" != dictionary->version()) ? dictionary->version() :
"default";
279 msg(MSG::INFO) <<
"Dictionary " << dictionary->name();
280 if (dictionary->name().size() < 20) {
281 std::string space(20 - dictionary->name().size(),
' ');
282 msg(MSG::INFO) << space;
284 msg(MSG::INFO) <<
" version " << version;
285 if (version.size() < 20) {
286 std::string space(20 - version.size(),
' ');
287 msg(MSG::INFO) << space;
289 if (dictionary->dict_tag().size()) {
290 msg(MSG::INFO) <<
" DetDescr tag " << dictionary->dict_tag();
291 if (dictionary->dict_tag().size() < 20) {
292 std::string space(25 - dictionary->dict_tag().size(),
' ');
293 msg(MSG::INFO) << space;
296 msg(MSG::INFO) <<
" DetDescr tag (using default)";
328 return StatusCode::SUCCESS;
335 bool skipDbDictAccess =
m_geoDbTagSvc->getParamSvcName().empty();
336 std::string paramSvcName = skipDbDictAccess ?
"RDBAccessSvc" :
m_geoDbTagSvc->getParamSvcName();
341 if(skipDbDictAccess) {
342 ATH_MSG_WARNING(
"Unable to determine RDBAccessSvc backend. Using default dictionaries");
346 return StatusCode::SUCCESS;
350 std::string &fileName,
351 std::string &dictTag) {
352 if (idDictSet->
size()) {
353 const IRDBRecord *idDictTable = (*idDictSet)[0];
354 const std::string dictName = idDictTable->
getString(
"DICT_NAME");
355 fileName = idDictTable->
getString(
"DICT_FILENAME");
356 dictTag = idDictSet->
tagName();
363 << dictName <<
", file: " << fileName
365 <<
", dictionary tag: " << dictTag);
368 ATH_MSG_WARNING(
" no record set found for dictionary"<<idDictSet->
nodeName()<<
" - using default dictionary ");
374 auto getEmbeddedDict = [
this](
const std::string& dictName,
375 std::string &fileName,
376 std::string &dictTag) ->
bool
382 std::string dictString = dictRecord->
getString(
"CONTENTS");
384 std::string dictFileName = dictName+
"-fromSQLite.xml";
385 std::ofstream dictFile;
386 dictFile.open(dictFileName);
387 dictFile << dictString;
390 fileName = std::move(dictFileName);
393 ATH_MSG_DEBUG(dictName <<
" read from the SQLite database as a BLOB");
399 bool useGeomDB = (
m_geoDbTagSvc->getSqliteReader() ==
nullptr);
401 std::string detTag{
""}, detNode{
""}, dictName{
""};
405 bool embeddedDict{
false};
413 << detectorKey.
node());
414 detTag = detectorKey.
tag();
415 detNode = detectorKey.
node();
416 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"DICTXDD", detTag, detNode);
419 if (idDictSet->
size()) {
420 const IRDBRecord *recordInDet = (*idDictSet)[0];
421 std::string InDetString = recordInDet->
getString(
"XMLCLOB");
424 std::ofstream blobFile;
425 blobFile.open(
"InDetIdDict.xml");
426 blobFile << InDetString << std::endl;
429 ATH_MSG_WARNING(
" no record set found for InDetIdentifier - using default dictionary ");
439 detTag = detectorKey.
tag();
440 detNode = detectorKey.
node();
442 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"InDetIdentifier", detTag, detNode);
454 ATH_MSG_DEBUG(
"From Version Tag: " << detectorKey.
tag() <<
" at Node: " << detectorKey.
node() );
455 detTag = detectorKey.
tag();
456 detNode = detectorKey.
node();
458 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"LArIdentifier", detTag, detNode);
469 ATH_MSG_DEBUG(
"From Version Tag: " << detectorKey.
tag() <<
" at Node: " << detectorKey.
node() );
470 detTag = detectorKey.
tag();
471 detNode = detectorKey.
node();
473 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"TileIdentifier", detTag, detNode);
484 ATH_MSG_DEBUG(
"From Version Tag: " << detectorKey.
tag()<<
" at Node: " << detectorKey.
node() );
485 detTag = detectorKey.
tag();
486 detNode = detectorKey.
node();
488 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"CaloIdentifier", detTag, detNode);
494 if (caloNeighborTable->
size() == 0 && useGeomDB) {
495 caloNeighborTable =
m_rdbAccessSvc->getRecordsetPtr(
"CaloNeighborTable",
"CaloNeighborTable-00");
498 if (caloNeighborTable->
size()) {
509 ATH_MSG_DEBUG(
"From Version Tag: " << detectorKey.
tag()<<
" at Node: " << detectorKey.
node() );
510 detTag = detectorKey.
tag();
511 detNode = detectorKey.
node();
513 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"MuonIdentifier", detTag, detNode);
524 ATH_MSG_DEBUG(
"From Version Tag: " << detectorKey.
tag() <<
" at Node: " << detectorKey.
node() );
525 detTag = detectorKey.
tag();
526 detNode = detectorKey.
node();
528 idDictSet =
m_rdbAccessSvc->getRecordsetPtr(
"ForDetIdentifier", detTag, detNode);
531 if (idDictSet->
size() == 0 && useGeomDB) {
533 "ForDetIdentifier-00");
534 ATH_MSG_DEBUG(
" explicitly requesting ForDetIdentifier-00 tag for pre-forward "
541 return StatusCode::SUCCESS;
549 ifile.open(
"InDetIdDict.xml");
583 m_parser->register_external_entity(
"MuonSpectrometer",
589 m_parser->register_external_entity(
"ForwardDetectors",
594 return StatusCode::SUCCESS;
602 auto setDictPaths = [
this, &mgr](
const std::string &dict_name,
603 const std::string &file_name,
604 const std::string &dict_tag) {
605 if (file_name.empty()) {
607 return StatusCode::SUCCESS;
612 return StatusCode::FAILURE;
614 dict->set_file_name(file_name);
615 dict->set_dict_tag(dict_tag);
616 ATH_MSG_DEBUG(
"For " << dict_name <<
" idDict, setting file/tag: "
617 << file_name <<
" " << dict_tag);
618 return StatusCode::SUCCESS;
628 auto addMetaData = [&mgr,
this](
const std::string &key,
629 const std::string &value) {
633 mgr.add_metadata(key, value);
644 return StatusCode::SUCCESS;
647template <
class dType>
654 return StatusCode::FAILURE;
656 const Gaudi::Details::PropertyBase &prop =
658 const Gaudi::Property<dType> *propPtr{
659 dynamic_cast<const Gaudi::Property<dType> *
>(&prop)};
661 ATH_MSG_ERROR(
"Property " << propertyName <<
" is not of type"
662 <<
typeid(dType).name() <<
" but of "
663 <<
typeid(prop).name());
664 return StatusCode::FAILURE;
666 pipeTo = propPtr->value();
668 return StatusCode::SUCCESS;
673template <
class dType>
675 const std::string &propertyName, dType &pipeTo) {
679 pipeTo = std::move(cache);
680 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::vector< Identifier > ID
const long DetDescr_StorageType
uint32_t CLID
The Class ID type.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
Converter for the DetDescrCnvSvc which parses the identifier xml dictionaries and creates an IdDictMa...
convert to and from a SG storable
MsgStream & msg() const
The standard message stream.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
DetDescrConverter(const CLID &myCLID, ISvcLocator *svcloc, const char *name=nullptr)
IRDBRecord is one record in the IRDBRecordset object.
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
virtual bool isFieldNull(const std::string &fieldName) const =0
Check if the field value is NULL.
virtual std::string tagName() const =0
virtual std::string nodeName() const =0
virtual unsigned int size() const =0
std::string m_muonIdDictTag
Tag of RDB record for Muon ids.
std::string m_tileIdDictTag
Tag of RDB record for Tile ids.
std::string m_fcal2dNeighborsName
std::string m_atlasIdDictTag
Tag of RDB record for Atlas top-level ids.
std::string m_atlasIDFileName
File to be read for top-level subsystem ids values.
std::string m_tileNeighborsName
std::string m_forwardIdDictTag
Tag of RDB record for forwards det ids.
std::string m_caloIDFileName
File to be read for Calo ids.
void collectCaloNeighbors(IRDBRecordset_ptr recordset)
A helper function for collecting calo neighbor file names from the database.
StatusCode getFileNamesFromTags()
Get file names from properties.
bool m_doParsing
Flag to which determines whether the xml files are parsed or not.
IdDictDetDescrCnv(ISvcLocator *svcloc)
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
void printDicts(const IdDictManager *dictMgr)
Print out the contained dictionaries and version.
static const CLID & classID()
StatusCode registerInfoWithDicts()
Register the requested files and tag with the created id dicts.
bool m_idDictFromRDB
Flag to get dict parameters from Relational DetDescr DB.
virtual StatusCode initialize() override
StatusCode getFileNamesFromProperties()
Get file names from properties.
std::string m_muonIDFileName
File to be read for Muon ids.
std::string m_inDetIDFileName
File to be read for InDet ids.
std::string m_forwardIDFileName
File to be read for Forward det ids.
std::string m_fullAtlasNeighborsName
Files for Calo Neighbors.
virtual long int repSvcType() const override
std::string m_fcal3dNeighborsNextName
virtual StatusCode finalize() override
std::string m_larIdDictTag
Tag of RDB record for LAr ids.
std::string m_tileIDFileName
File to be read for Tile ids.
std::unique_ptr< IdDictParser > m_parser
The xml parser for the dictionary descriptions.
bool m_doNeighbours
Flag to generate neighbor information - for calos.
std::string m_idDictName
Name of top-level xml dict file.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
std::string m_caloIdDictTag
Tag of RDB record for Calo ids.
StatusCode registerFilesWithParser()
Register the requested files with the xml parser.
SmartIF< IProperty > m_detDescrProxy
Propxy to the DetDescrCnvSvc.
StatusCode loadPropertyWithParse(const std::string &propertyName, dType &pipeTo)
Same as loadProperty but additionally m_doParsing is set to true if the input value does not match th...
bool m_doChecks
Flag to tell helpers to do Checks.
StatusCode loadProperty(const std::string &propertyName, dType &pipeTo)
Loads the property from the DetDecrCnvSvc and pipes its value Returns failure if either the service,...
std::string m_inDetIDTag
Internal InDet id tag.
std::string m_larIDFileName
File to be read for LAr ids.
StatusCode parseXMLDescription()
Create and (re)initialize the IdDictManager - only create the first time.
static long int storageType()
Storage type and class ID (used by CnvFactory)
std::string m_fcal3dNeighborsPrevName
IdDictManager is the interface to identifier dictionaries.
const IdDictMgr * manager(void) const
const std::string & tag() const
Version tag.
dictionary_vec get_dictionaries() const
Access to all dictionaries.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.