ATLAS Offline Software
IdDictDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  IdDictDetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 #include "IdDictDetDescrCnv.h"
11 
21 
22 // To write text file
23 #include <fstream>
24 #include <iostream>
25 
26 //--------------------------------------------------------------------
27 
29  return (storageType());
30 }
31 
32 //--------------------------------------------------------------------
33 
35  // First call parent init
37  ATH_MSG_INFO("in initialize");
38  // Must set indet tag to EMPTY
39  m_inDetIDTag = "EMPTY";
40 
41  m_detDescrProxy = serviceLocator()->service("DetDescrCnvSvc");
42  ATH_CHECK(m_detDescrProxy.isValid());
43 
44  return StatusCode::SUCCESS;
45 }
47  ATH_MSG_INFO("in finalize");
48  return StatusCode::SUCCESS;
49 }
50 //--------------------------------------------------------------------
51 
53  DataObject *&pObj) {
54  //
55  // Here we create an IdDictManager and provide it with an
56  // IdDictMgr which has been filled by an IdDictParser. This mgr
57  // is used by each IdHelper to initialize itself.
58  //
59  // Lifetime management:
60  //
61  // IdDictDetDescrCnv holds onto ONE IdDictParser, which in
62  // turn holds the same IdDictMgr.
63  //
64  // Multiple initializations are possible. parseXMLDescription
65  // will look for a new set of xml files, clear any
66  // pre-existing IdDictMgr help by the parser and then parse
67  // the new xml files, filling the IdDictMgr.
68  //
69  // Since the parser "refills" the same IdDictMgr, one has the
70  // option to delete and recreate the IdDictManager, or just
71  // keep the same one which will be refreshed with the new
72  // description.
73  //
75  "in createObj: creating a IdDictManager object in the detector store");
76  DetDescrAddress *ddAddr = dynamic_cast<DetDescrAddress *>(pAddr);
77  if (!ddAddr) {
78  ATH_MSG_ERROR("Could not cast to DetDescrAddress.");
79  return StatusCode::FAILURE;
80  }
81 
82  // Get the StoreGate key of this container.
83  std::string mgrKey = *(ddAddr->par());
84  if (mgrKey.empty())
85  ATH_MSG_DEBUG("No Manager key ");
86  else
87  ATH_MSG_DEBUG("Manager key is " << mgrKey);
88 
90 
91  // Create the manager - only once
92  IdDictManager *dictMgr = new IdDictManager(m_parser->m_idd);
93 
94  ATH_MSG_DEBUG("Created IdDictManager ");
95 
96  // Print out the dictionary names
97  printDicts(dictMgr);
98 
99  // Pass a pointer to the container to the Persistency service
100  // by reference.
101  pObj = SG::asStorable(dictMgr);
102 
103  return StatusCode::SUCCESS;
104 }
105 
106 //--------------------------------------------------------------------
107 
109  ATH_MSG_DEBUG("in parseXMLDescription()");
110 
111  // Parse the xml files to obtain the iddict dictionaries
112  //
113  // Parsing of the xml files may not be needed. So we check. The
114  // conditions to reparse are:
115  //
116  // - first pass, i.e. creating a new IdDictParser
117  // - a change in an input xml file
118  // - a change in one of the "options" such as doIdChecks,
119  // doInitNeighbors, etc.
120  //
121 
122  m_doParsing = false; // Preset to no parsing
123 
124  if (!m_parser) {
125  // Create parser
126  m_parser = std::make_unique<IdDictParser>();
127  m_doParsing = true;
128  }
129 
130  // We access the properties on each pass
131 
132  // Set flag for doing checks of ids
134 
135  // Set flag for initializing neighbours
136  ATH_CHECK(loadPropertyWithParse("DoInitNeighbours", m_doNeighbours));
137 
138  // Name of IdDict file
140  ATH_MSG_INFO("IdDictName: " << m_idDictName);
141 
142  // Get the file names: two options - either from jobOpt
143  // properties of the DetDescrCnvSvc or from RDB tags
144 
145  // Determine if Dict filename comes from DD database or
146  // if properties from JobOptions should be used.
147  ATH_CHECK(loadProperty("IdDictFromRDB", m_idDictFromRDB));
148 
149  // Determine if the dictionary content comes from DD database or
150  // if properties from JobOptions should be used.
151  ATH_CHECK(loadProperty("useGeomDB_InDet", m_useGeomDB_InDet));
152 
153  if (m_idDictFromRDB)
154  ATH_MSG_DEBUG("Dictonary file name from DD database");
155  else
157  "Dictonary file name from job options or using defaults.");
158 
159  // Get the file name to parse:
160  //
161  // 1) From Relational DB
162  // 2) Via jobOptions
163  // 3) default name in the xml files
164  //
165  // Currently the logic is 1) or 2) and 3) covers the case where
166  // no file name is found.
167  //
168  if (m_idDictFromRDB) {
169  // Get file names from RDB
171  ATH_MSG_DEBUG("Looked for ID file name from RDB ");
172  } else {
173  // Get file names from properties
175  ATH_MSG_DEBUG("Looked for ID file name from properties ");
176  }
177 
178  // Only parse if necessary
179  if (m_doParsing) {
180  // Register the requested files with the xml parser
182  ATH_MSG_DEBUG("Registered file names ");
183 
184  // Check whether a tag is needed for dictionary initialization
185 
186  // NOTE: the internal tag for IdDict is global, but is only
187  // used for InDet and thus is defined by InDet
188  std::string tag{};
189  if (m_inDetIDTag == "EMPTY")
190  ATH_CHECK(loadProperty("IdDictGlobalTag", tag));
191  else
192  tag = m_inDetIDTag;
193 
194  // Parse the dictionaries
195  m_parser->parse(m_idDictName, tag);
196  if (tag.empty())
197  tag = "default";
198  ATH_MSG_DEBUG("Read dict: " << m_idDictName << " with tag " << tag);
199 
200  // Set flag to check ids
201  IdDictMgr &mgr = m_parser->m_idd;
202 
203  mgr.set_do_checks(m_doChecks);
204  ATH_MSG_DEBUG("Set IdDictManager doChecks flag to"
205  << (m_doChecks ? "true" : "false"));
206 
207  // Set flag to initialize neighbours
208  mgr.set_do_neighbours(m_doNeighbours);
209  ATH_MSG_DEBUG("Set IdDictManager doNeighbours flag to "
210  << (m_doNeighbours ? "true" : "false"));
211 
212  // Do some checks
213  size_t ndict = mgr.get_dictionaries().size();
214  if (ndict == 0) {
215  ATH_MSG_ERROR("No dictionaries found!");
216  return StatusCode::FAILURE;
217  }
218  ATH_MSG_DEBUG("Found " << ndict << " dictionaries.");
219 
220  // Register the requested files and tags with the id dicts
222  ATH_MSG_DEBUG("Registered info with id dicts ");
223  } else {
225  "NOTE: ** parseXMLDescription called, but parsing was deemed "
226  "unnecessary ** ");
227  }
228  ATH_MSG_DEBUG("parseXMLDescription: Finished parsing and setting options ");
229  return StatusCode::SUCCESS;
230 }
231 
232 //--------------------------------------------------------------------
233 
235 {
236  const IRDBRecord *neighborTable = (*recordset)[0];
237  m_fullAtlasNeighborsName = neighborTable->getString("FULLATLASNEIGHBORS");
238  m_fcal2dNeighborsName = neighborTable->getString("FCAL2DNEIGHBORS");
239  m_fcal3dNeighborsNextName = neighborTable->getString("FCAL3DNEIGHBORSNEXT");
240  m_fcal3dNeighborsPrevName = neighborTable->getString("FCAL3DNEIGHBORSPREV");
241  m_tileNeighborsName = neighborTable->getString("TILENEIGHBORS");
242  ATH_MSG_DEBUG(" using neighbor files: ");
243  ATH_MSG_DEBUG(" FullAtlasNeighborsFileName: " << m_fullAtlasNeighborsName);
244  ATH_MSG_DEBUG(" FCAL2DNeighborsFileName: " << m_fcal2dNeighborsName);
245  ATH_MSG_DEBUG(" FCAL3DNeighborsNextFileName: " << m_fcal3dNeighborsNextName);
246  ATH_MSG_DEBUG(" FCAL3DNeighborsPrevFileName: " << m_fcal3dNeighborsPrevName);
247  ATH_MSG_DEBUG(" TileNeighborsFileName: " << m_tileNeighborsName);
248  return;
249 }
250 
251 //--------------------------------------------------------------------
252 
254  return DetDescr_StorageType;
255 }
256 
257 //--------------------------------------------------------------------
260 }
261 
262 //--------------------------------------------------------------------
264  : DetDescrConverter(ClassID_traits<IdDictManager>::ID(), svcloc, "IdDictDetDescrCnv")
265 {}
266 //--------------------------------------------------------------------
268 
269  ATH_MSG_INFO("Found id dicts:");
270  if (!dictMgr)
271  return;
272 
273  std::string tag = dictMgr->manager()->tag();
274  ATH_MSG_INFO("Using dictionary tag: " << (tag.empty() ? "<no tag>" : tag));
275 
276  for (const IdDictDictionary* dictionary : dictMgr->manager()->get_dictionaries()) {
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;
283  }
284  msg(MSG::INFO) << " version " << version;
285  if (version.size() < 20) {
286  std::string space(20 - version.size(), ' ');
287  msg(MSG::INFO) << space;
288  }
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;
294  }
295  } else {
296  msg(MSG::INFO) << " DetDescr tag (using default)";
297  }
298  ATH_MSG_INFO(" file " << dictionary->file_name());
299  }
300 }
301 
302 //--------------------------------------------------------------------
304  // Check whether non-default names have been specified for the
305  // IdDict files of the subsystems
306 
307  // Atlas IDs
308  ATH_CHECK(loadProperty("AtlasIDFileName", m_atlasIDFileName));
309  // InDet Ids
310  ATH_CHECK(loadProperty("InDetIDFileName", m_inDetIDFileName));
311  // LAr ids
312  ATH_CHECK(loadProperty("LArIDFileName", m_larIDFileName));
313  // Tile ids
314  ATH_CHECK(loadProperty("TileIDFileName", m_tileIDFileName));
315  // Calo ids
316  ATH_CHECK(loadProperty("CaloIDFileName", m_caloIDFileName));
317  // Calo neighbor files
318  ATH_CHECK(loadProperty("FullAtlasNeighborsFileName", m_fullAtlasNeighborsName));
319  ATH_CHECK(loadProperty("FCAL2DNeighborsFileName", m_fcal2dNeighborsName));
320  ATH_CHECK(loadProperty("FCAL3DNeighborsNextFileName", m_fcal3dNeighborsNextName));
321  ATH_CHECK(loadProperty("FCAL3DNeighborsPrevFileName", m_fcal3dNeighborsPrevName));
322 
323  ATH_CHECK(loadProperty("TileNeighborsFileName", m_tileNeighborsName));
324  // Muon ids
325  ATH_CHECK(loadProperty("MuonIDFileName", m_muonIDFileName));
326  // ForwardDetectors ids
327  ATH_CHECK(loadProperty("ForwardIDFileName", m_forwardIDFileName));
328  return StatusCode::SUCCESS;
329 }
330 
331 //--------------------------------------------------------------------
333  // Fetch file names and tags from the RDB
334  ATH_CHECK(m_geoDbTagSvc.retrieve());
335  bool skipDbDictAccess = m_geoDbTagSvc->getParamSvcName().empty();
336  std::string paramSvcName = skipDbDictAccess ? "RDBAccessSvc" : m_geoDbTagSvc->getParamSvcName();
337  ATH_MSG_DEBUG("Accessed " << paramSvcName);
338  m_rdbAccessSvc.setName(paramSvcName);
339  ATH_CHECK(m_rdbAccessSvc.retrieve());
340 
341  if(skipDbDictAccess) {
342  ATH_MSG_WARNING("Unable to determine RDBAccessSvc backend. Using default dictionaries");
343  // Get Calo Neighbor tables from Oracle and return
344  IRDBRecordset_ptr caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", "CaloNeighborTable-00");
345  collectCaloNeighbors(std::move(caloNeighborTable));
346  return StatusCode::SUCCESS;
347  }
348 
349  auto assignTagAndName = [this](const IRDBRecordset_ptr &idDictSet,
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();
357  // NOTE: the internal tag for IdDict is global, but is
358  // only used for InDet and thus is defined by InDet
359  if (!idDictTable->isFieldNull("DICT_TAG")) {
360  m_inDetIDTag = idDictTable->getString("DICT_TAG");
361  }
362  ATH_MSG_DEBUG(" using dictionary: "
363  << dictName << ", file: " << fileName
364  << ", with internal tag: " << m_inDetIDTag
365  << ", dictionary tag: " << dictTag);
366 
367  } else {
368  ATH_MSG_WARNING(" no record set found for dictionary"<<idDictSet->nodeName()<< " - using default dictionary ");
369  }
370  };
371 
372  // Function for reading ID dictionary as a BLOB from SQLite
373  // and writing it on the disk in the run directory
374  auto getEmbeddedDict = [this](const std::string& dictName,
375  std::string &fileName,
376  std::string &dictTag) -> bool
377  {
378  ATH_MSG_DEBUG("Try to access "<<dictName);
379  IRDBRecordset_ptr rec = m_rdbAccessSvc->getRecordsetPtr(dictName,"","");
380  if(rec->size()>0) {
381  const IRDBRecord *dictRecord = (*rec)[0];
382  std::string dictString = dictRecord->getString("CONTENTS");
383  // write to the temporary file
384  std::string dictFileName = dictName+"-fromSQLite.xml";
385  std::ofstream dictFile;
386  dictFile.open(dictFileName);
387  dictFile << dictString;
388  dictFile.close();
389 
390  fileName = std::move(dictFileName);
391  dictTag.clear(); // This may change in the future if we also write dict tags into SQLite
392 
393  ATH_MSG_DEBUG(dictName << " read from the SQLite database as a BLOB");
394  return true;
395  }
396  return false;
397  };
398 
399  bool useGeomDB = (m_geoDbTagSvc->getSqliteReader() == nullptr);
400 
401  std::string detTag{""}, detNode{""}, dictName{""};
402  DecodeVersionKey detectorKey("ATLAS");
403  IRDBRecordset_ptr idDictSet{};
404 
405  bool embeddedDict{false};
406 
407  // Get InDet
408  if (m_useGeomDB_InDet) {
409  // Get Innner Detector xml and write to the temporary file
410  // InDetIdDict.xml
411  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "InnerDetector");
412  ATH_MSG_DEBUG("From Version Tag: " << detectorKey.tag() << " at Node: "
413  << detectorKey.node());
414  detTag = detectorKey.tag();
415  detNode = detectorKey.node();
416  idDictSet = m_rdbAccessSvc->getRecordsetPtr("DICTXDD", detTag, detNode);
417 
418  // Size == 0 if not found
419  if (idDictSet->size()) {
420  const IRDBRecord *recordInDet = (*idDictSet)[0];
421  std::string InDetString = recordInDet->getString("XMLCLOB");
422 
423  // write to the temporary file
424  std::ofstream blobFile;
425  blobFile.open("InDetIdDict.xml");
426  blobFile << InDetString << std::endl;
427  blobFile.close();
428  } else {
429  ATH_MSG_WARNING(" no record set found for InDetIdentifier - using default dictionary ");
430  }
431  } else {
432  // Attempt to read the embedded disctionary from SQLite
433  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictInnerDetector",m_inDetIDFileName,m_inDetIdDictTag);
434  if(!embeddedDict) {
435  // Fall back on getting file names from the database
436  if (useGeomDB) {
437  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "InnerDetector");
438  ATH_MSG_DEBUG("From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node());
439  detTag = detectorKey.tag();
440  detNode = detectorKey.node();
441  }
442  idDictSet = m_rdbAccessSvc->getRecordsetPtr("InDetIdentifier", detTag, detNode);
443  assignTagAndName(idDictSet, m_inDetIDFileName, m_inDetIdDictTag);
444  }
445  }
446 
447  // Get LAr
448  // Attempt to read the embedded disctionary from SQLite
449  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictLArCalorimeter",m_larIDFileName,m_larIdDictTag);
450  if(!embeddedDict) {
451  // Fall back on getting file names from the database
452  if (useGeomDB) {
453  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "LAr");
454  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
455  detTag = detectorKey.tag();
456  detNode = detectorKey.node();
457  }
458  idDictSet = m_rdbAccessSvc->getRecordsetPtr("LArIdentifier", detTag, detNode);
459  assignTagAndName(idDictSet, m_larIDFileName, m_larIdDictTag);
460  }
461 
462  // Get Tile
463  // Attempt to read the embedded disctionary from SQLite
464  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictTileCalorimeter",m_tileIDFileName,m_tileIdDictTag);
465  if(!embeddedDict) {
466  // Fall back on getting file names from the database
467  if (useGeomDB) {
468  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "TileCal");
469  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
470  detTag = detectorKey.tag();
471  detNode = detectorKey.node();
472  }
473  idDictSet = m_rdbAccessSvc->getRecordsetPtr("TileIdentifier", detTag, detNode);
474  assignTagAndName(idDictSet, m_tileIDFileName, m_tileIdDictTag);
475  }
476 
477  // Get Calo
478  // Attempt to read the embedded disctionary from SQLite
479  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictCalorimeter",m_caloIDFileName,m_caloIdDictTag);
480  if(!embeddedDict) {
481  // Fall back on getting file names from the database
482  if (useGeomDB) {
483  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "Calorimeter");
484  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag()<< " at Node: " << detectorKey.node() );
485  detTag = detectorKey.tag();
486  detNode = detectorKey.node();
487  }
488  idDictSet = m_rdbAccessSvc->getRecordsetPtr("CaloIdentifier", detTag, detNode);
489  assignTagAndName(idDictSet, m_caloIDFileName, m_caloIdDictTag);
490  }
491  // Calo neighbor files:
492  IRDBRecordset_ptr caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", detTag, detNode);
493 
494  if (caloNeighborTable->size() == 0 && useGeomDB) {
495  caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", "CaloNeighborTable-00");
496  }
497  // Size == 0 if not found
498  if (caloNeighborTable->size()) {
499  collectCaloNeighbors(std::move(caloNeighborTable));
500  }
501 
502  // Get Muon
503  // Attempt to read the embedded disctionary from SQLite
504  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictMuonSpectrometer", m_muonIDFileName, m_muonIdDictTag);
505  if(!embeddedDict) {
506  // Fall back on getting file names from the database
507  if (useGeomDB) {
508  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "MuonSpectrometer");
509  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag()<< " at Node: " << detectorKey.node() );
510  detTag = detectorKey.tag();
511  detNode = detectorKey.node();
512  }
513  idDictSet = m_rdbAccessSvc->getRecordsetPtr("MuonIdentifier", detTag, detNode);
514  assignTagAndName(idDictSet, m_muonIDFileName, m_muonIdDictTag);
515  }
516 
517  // Get Forward
518  // Attempt to read the embedded disctionary from SQLite
519  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictForwardDetectors",m_forwardIDFileName,m_forwardIdDictTag);
520  if(!embeddedDict) {
521  // Fall back on getting file names from the database
522  if (useGeomDB) {
523  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "ForwardDetectors");
524  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
525  detTag = detectorKey.tag();
526  detNode = detectorKey.node();
527  }
528  idDictSet = m_rdbAccessSvc->getRecordsetPtr("ForDetIdentifier", detTag, detNode);
529 
530  // For older datasets use ForDetIdentifier-00 as fallback
531  if (idDictSet->size() == 0 && useGeomDB) {
532  idDictSet = m_rdbAccessSvc->getRecordsetPtr("ForDetIdentifier",
533  "ForDetIdentifier-00");
534  ATH_MSG_DEBUG(" explicitly requesting ForDetIdentifier-00 tag for pre-forward "
535  "detector data ");
536  }
537  // Size == 0 if not found
538  assignTagAndName(idDictSet, m_forwardIDFileName, m_forwardIdDictTag);
539  }
540  ATH_MSG_DEBUG("End access to RDB for id dictionary info ");
541  return StatusCode::SUCCESS;
542 }
543 
544 //--------------------------------------------------------------------
546  // If InDetIdDict.xml exists set InDetFileName set to it's name
547  if (m_useGeomDB_InDet) {
548  std::ifstream ifile;
549  ifile.open("InDetIdDict.xml");
550  if (ifile)
551  m_inDetIDFileName = "InDetIdDict.xml";
552  else
553  ATH_MSG_WARNING(" no temp. file InDetIdDict.xml found - using file "
554  << m_inDetIDFileName);
555  }
556 
557  if (!m_atlasIDFileName.empty()) {
558  m_parser->register_external_entity("ATLAS", m_atlasIDFileName);
559  ATH_MSG_INFO("Reading ATLAS IdDict file "
560  << m_atlasIDFileName);
561  }
562  if (!m_inDetIDFileName.empty()) {
563  m_parser->register_external_entity("InnerDetector", m_inDetIDFileName);
564  ATH_MSG_INFO("Reading InnerDetector IdDict file "
565  << m_inDetIDFileName);
566  }
567  if (!m_larIDFileName.empty()) {
568  m_parser->register_external_entity("LArCalorimeter", m_larIDFileName);
569  ATH_MSG_INFO("Reading LArCalorimeter IdDict file "
570  << m_larIDFileName);
571  }
572  if (!m_tileIDFileName.empty()) {
573  m_parser->register_external_entity("TileCalorimeter", m_tileIDFileName);
574  ATH_MSG_INFO("Reading TileCalorimeter IdDict file "
575  << m_tileIDFileName);
576  }
577  if (!m_caloIDFileName.empty()) {
578  m_parser->register_external_entity("Calorimeter", m_caloIDFileName);
579  ATH_MSG_INFO("Reading Calorimeter IdDict file "
580  << m_caloIDFileName);
581  }
582  if (!m_muonIDFileName.empty()) {
583  m_parser->register_external_entity("MuonSpectrometer",
585  ATH_MSG_INFO("Reading MuonSpectrometer IdDict file "
586  << m_muonIDFileName);
587  }
588  if (!m_forwardIDFileName.empty()) {
589  m_parser->register_external_entity("ForwardDetectors",
591  ATH_MSG_INFO("Reading ForwardDetectors IdDict file "
593  }
594  return StatusCode::SUCCESS;
595 }
596 
597 //--------------------------------------------------------------------
599  // Save the file name and tag in each of the dictionaries
600  IdDictMgr &mgr = m_parser->m_idd;
601 
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()) {
606  ATH_MSG_DEBUG("No idDict will be loaded for " << dict_name);
607  return StatusCode::SUCCESS;
608  }
609  IdDictDictionary *dict = mgr.find_dictionary(dict_name);
610  if (!dict) {
611  ATH_MSG_ERROR("unable to find idDict for " << dict_name);
612  return StatusCode::FAILURE;
613  }
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;
619  };
620  ATH_CHECK(setDictPaths("ATLAS", m_atlasIDFileName, m_atlasIdDictTag));
621  ATH_CHECK(setDictPaths("InnerDetector", m_inDetIDFileName, m_inDetIdDictTag));
622  ATH_CHECK(setDictPaths("LArCalorimeter", m_larIDFileName, m_larIdDictTag));
623  ATH_CHECK(setDictPaths("TileCalorimeter", m_tileIDFileName, m_tileIdDictTag));
624  ATH_CHECK(setDictPaths("Calorimeter", m_caloIDFileName, m_caloIdDictTag));
625  ATH_CHECK(setDictPaths("MuonSpectrometer", m_muonIDFileName, m_muonIdDictTag));
626  ATH_CHECK(setDictPaths("ForwardDetectors", m_forwardIDFileName, m_forwardIdDictTag));
627 
628  auto addMetaData = [&mgr, this](const std::string &key,
629  const std::string &value) {
630  if (value.empty()) {
631  ATH_MSG_DEBUG("No value given for key " << key);
632  } else {
633  mgr.add_metadata(key, value);
634  ATH_MSG_DEBUG("Added to dict mgr meta data: <" << key << ","
635  << value << ">");
636  }
637  };
638  addMetaData("FULLATLASNEIGHBORS", m_fullAtlasNeighborsName);
639  addMetaData("FCAL2DNEIGHBORS", m_fcal2dNeighborsName);
640  addMetaData("FCAL3DNEIGHBORSNEXT", m_fcal3dNeighborsNextName);
641  addMetaData("FCAL3DNEIGHBORSPREV", m_fcal3dNeighborsPrevName);
642  addMetaData("TILENEIGHBORS", m_tileNeighborsName);
643 
644  return StatusCode::SUCCESS;
645 }
646 
647 template <class dType>
648 StatusCode IdDictDetDescrCnv::loadProperty(const std::string &propertyName,
649  dType &pipeTo) {
650 
651  if (!m_detDescrProxy->hasProperty(propertyName)) {
652  ATH_MSG_FATAL("DetDescrSvc does not have the property "
653  << propertyName);
654  return StatusCode::FAILURE;
655  }
656  const Gaudi::Details::PropertyBase &prop =
657  m_detDescrProxy->getProperty(propertyName);
658  const Gaudi::Property<dType> *propPtr{
659  dynamic_cast<const Gaudi::Property<dType> *>(&prop)};
660  if (!propPtr) {
661  ATH_MSG_ERROR("Property " << propertyName << " is not of type"
662  << typeid(dType).name() << " but of "
663  << typeid(prop).name());
664  return StatusCode::FAILURE;
665  }
666  pipeTo = propPtr->value();
667  ATH_MSG_DEBUG("Flag " << propertyName << " is: " << pipeTo);
668  return StatusCode::SUCCESS;
669 }
670 
673 template <class dType>
675  const std::string &propertyName, dType &pipeTo) {
676  dType cache{};
677  ATH_CHECK(loadProperty(propertyName, cache));
678  m_doParsing |= cache != pipeTo;
679  pipeTo = std::move(cache);
680  return StatusCode::SUCCESS;
681 }
IdDictDetDescrCnv::m_tileIdDictTag
std::string m_tileIdDictTag
Tag of RDB record for Tile ids.
Definition: IdDictDetDescrCnv.h:155
IdDictDetDescrCnv::m_idDictName
std::string m_idDictName
Name of top-level xml dict file.
Definition: IdDictDetDescrCnv.h:108
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
IdDictDetDescrCnv::loadProperty
StatusCode loadProperty(const std::string &propertyName, dType &pipeTo)
Loads the property from the DetDecrCnvSvc and pipes its value Returns failure if either the service,...
Definition: IdDictDetDescrCnv.cxx:648
IdDictDetDescrCnv::m_atlasIDFileName
std::string m_atlasIDFileName
File to be read for top-level subsystem ids values.
Definition: IdDictDetDescrCnv.h:118
IdDictDetDescrCnv::m_fcal3dNeighborsPrevName
std::string m_fcal3dNeighborsPrevName
Definition: IdDictDetDescrCnv.h:136
AthCheckMacros.h
IdDictDetDescrCnv::registerInfoWithDicts
StatusCode registerInfoWithDicts()
Register the requested files and tag with the created id dicts.
Definition: IdDictDetDescrCnv.cxx:598
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
IdDictDetDescrCnv::m_inDetIDTag
std::string m_inDetIDTag
Internal InDet id tag.
Definition: IdDictDetDescrCnv.h:167
IdDictDetDescrCnv::m_atlasIdDictTag
std::string m_atlasIdDictTag
Tag of RDB record for Atlas top-level ids.
Definition: IdDictDetDescrCnv.h:146
IdDictDetDescrCnv::getFileNamesFromTags
StatusCode getFileNamesFromTags()
Get file names from properties.
Definition: IdDictDetDescrCnv.cxx:332
StorableConversions.h
convert to and from a SG storable
IdDictDetDescrCnv::m_doNeighbours
bool m_doNeighbours
Flag to generate neighbor information - for calos.
Definition: IdDictDetDescrCnv.h:105
IdDictDetDescrCnv::m_muonIDFileName
std::string m_muonIDFileName
File to be read for Muon ids.
Definition: IdDictDetDescrCnv.h:140
IdDictDictionary.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
IRDBRecord::getString
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
IdDictDetDescrCnv::m_fullAtlasNeighborsName
std::string m_fullAtlasNeighborsName
Files for Calo Neighbors.
Definition: IdDictDetDescrCnv.h:133
DetDescrAddress.h
IdDictDetDescrCnv::m_detDescrProxy
SmartIF< IProperty > m_detDescrProxy
Propxy to the DetDescrCnvSvc.
Definition: IdDictDetDescrCnv.h:62
IdDictDetDescrCnv::m_fcal2dNeighborsName
std::string m_fcal2dNeighborsName
Definition: IdDictDetDescrCnv.h:134
athena.value
value
Definition: athena.py:124
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:97
IdDictDictionary::set_dict_tag
void set_dict_tag(const std::string &tag)
Set the dictionary tag.
Definition: IdDictDictionary.h:392
IdDictDetDescrCnv::finalize
virtual StatusCode finalize() override
Definition: IdDictDetDescrCnv.cxx:46
IdDictManager.h
IdDictDetDescrCnv::m_forwardIDFileName
std::string m_forwardIDFileName
File to be read for Forward det ids.
Definition: IdDictDetDescrCnv.h:143
IdDictDetDescrCnv::m_tileIDFileName
std::string m_tileIDFileName
File to be read for Tile ids.
Definition: IdDictDetDescrCnv.h:127
IdDictDetDescrCnv::parseXMLDescription
StatusCode parseXMLDescription()
Create and (re)initialize the IdDictManager - only create the first time.
Definition: IdDictDetDescrCnv.cxx:108
IdDictDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Definition: IdDictDetDescrCnv.cxx:52
IdDictDetDescrCnv::m_larIDFileName
std::string m_larIDFileName
File to be read for LAr ids.
Definition: IdDictDetDescrCnv.h:124
IdDictDetDescrCnv::m_tileNeighborsName
std::string m_tileNeighborsName
Definition: IdDictDetDescrCnv.h:137
IdDictDetDescrCnv.h
Converter for the DetDescrCnvSvc which parses the identifier xml dictionaries and creates an IdDictMa...
IdDictDetDescrCnv::collectCaloNeighbors
void collectCaloNeighbors(IRDBRecordset_ptr recordset)
A helper function for collecting calo neighbor file names from the database.
Definition: IdDictDetDescrCnv.cxx:234
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:31
IdDictMgr::get_dictionaries
dictionary_vec get_dictionaries() const
Access to all dictionaries.
Definition: IdDictMgr.cxx:106
IdDictDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: IdDictDetDescrCnv.h:149
IdDictMgr
Definition: IdDictMgr.h:16
IdDictDetDescrCnv::IdDictDetDescrCnv
IdDictDetDescrCnv(ISvcLocator *svcloc)
Definition: IdDictDetDescrCnv.cxx:263
DetDescrConverter
Definition: DetDescrConverter.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DetDescrAddress
Definition: DetDescrAddress.h:32
IdDictDetDescrCnv::m_larIdDictTag
std::string m_larIdDictTag
Tag of RDB record for LAr ids.
Definition: IdDictDetDescrCnv.h:152
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
IdDictDetDescrCnv::m_doChecks
bool m_doChecks
Flag to tell helpers to do Checks.
Definition: IdDictDetDescrCnv.h:102
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
IdDictDictionary::set_file_name
void set_file_name(const std::string &name)
Set file name.
Definition: IdDictDictionary.h:385
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:91
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdDictDetDescrCnv::initialize
virtual StatusCode initialize() override
Definition: IdDictDetDescrCnv.cxx:34
IdDictDetDescrCnv::registerFilesWithParser
StatusCode registerFilesWithParser()
Register the requested files with the xml parser.
Definition: IdDictDetDescrCnv.cxx:545
IdDictDetDescrCnv::m_inDetIDFileName
std::string m_inDetIDFileName
File to be read for InDet ids.
Definition: IdDictDetDescrCnv.h:121
IdDictDetDescrCnv::m_useGeomDB_InDet
bool m_useGeomDB_InDet
Definition: IdDictDetDescrCnv.h:170
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IdDictDetDescrCnv::m_fcal3dNeighborsNextName
std::string m_fcal3dNeighborsNextName
Definition: IdDictDetDescrCnv.h:135
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
IdDictDetDescrCnv::m_muonIdDictTag
std::string m_muonIdDictTag
Tag of RDB record for Muon ids.
Definition: IdDictDetDescrCnv.h:161
IdDictDetDescrCnv::repSvcType
virtual long int repSvcType() const override
Definition: IdDictDetDescrCnv.cxx:28
IdDictDetDescrCnv::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: IdDictDetDescrCnv.h:58
master.dictionary
dictionary
Definition: master.py:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:26
IdDictDetDescrCnv::m_caloIdDictTag
std::string m_caloIdDictTag
Tag of RDB record for Calo ids.
Definition: IdDictDetDescrCnv.h:158
IdDictDetDescrCnv::classID
static const CLID & classID()
Definition: IdDictDetDescrCnv.cxx:258
ReadBchFromCrest.mgr
mgr
Definition: ReadBchFromCrest.py:181
IdDictDetDescrCnv::m_rdbAccessSvc
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc
Definition: IdDictDetDescrCnv.h:59
DecodeVersionKey.h
IdDictDictionary
Definition: IdDictDictionary.h:31
get_generator_info.version
version
Definition: get_generator_info.py:33
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
DetDescrConverter.h
IdDictDetDescrCnv::m_forwardIdDictTag
std::string m_forwardIdDictTag
Tag of RDB record for forwards det ids.
Definition: IdDictDetDescrCnv.h:164
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
IRDBRecord::isFieldNull
virtual bool isFieldNull(const std::string &fieldName) const =0
Check if the field value is NULL.
IdDictDetDescrCnv::m_caloIDFileName
std::string m_caloIDFileName
File to be read for Calo ids.
Definition: IdDictDetDescrCnv.h:130
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:30
IdDictDetDescrCnv::loadPropertyWithParse
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...
Definition: IdDictDetDescrCnv.cxx:674
IdDictDetDescrCnv::m_parser
std::unique_ptr< IdDictParser > m_parser
The xml parser for the dictionary descriptions.
Definition: IdDictDetDescrCnv.h:99
IdDictDetDescrCnv::printDicts
void printDicts(const IdDictManager *dictMgr)
Print out the contained dictionaries and version.
Definition: IdDictDetDescrCnv.cxx:267
ClassID_traits::ID
static CLID ID()
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
LArCellNtuple.ifile
string ifile
Definition: LArCellNtuple.py:133
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
IdDictDetDescrCnv::getFileNamesFromProperties
StatusCode getFileNamesFromProperties()
Get file names from properties.
Definition: IdDictDetDescrCnv.cxx:303
IdDictMgr::tag
const std::string & tag() const
Version tag.
Definition: IdDictMgr.cxx:54
IdDictDetDescrCnv::m_idDictFromRDB
bool m_idDictFromRDB
Flag to get dict parameters from Relational DetDescr DB.
Definition: IdDictDetDescrCnv.h:111
IdDictDetDescrCnv::m_doParsing
bool m_doParsing
Flag to which determines whether the xml files are parsed or not.
Definition: IdDictDetDescrCnv.h:115
IdDictDetDescrCnv::storageType
static long int storageType()
Storage type and class ID (used by CnvFactory)
Definition: IdDictDetDescrCnv.cxx:253
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37