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  const IdDictMgr::dictionary_map &dm = mgr.get_dictionary_map();
214  if (dm.empty()) {
215  ATH_MSG_ERROR("No dictionaries found!");
216  return StatusCode::FAILURE;
217  }
218  ATH_MSG_DEBUG("Found " << dm.size() << " 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 
277  dictMgr->manager()->get_dictionary_map();
278  IdDictMgr::dictionary_map::const_iterator it;
279 
280  int n = 0;
281 
282  for (it = dm.begin(); it != dm.end(); ++it, ++n) {
283  const IdDictDictionary &dictionary = *((*it).second);
284  std::string version =
285  ("" != dictionary.version()) ? dictionary.version() : "default";
286  msg(MSG::INFO) << "Dictionary " << dictionary.name();
287  if (dictionary.name().size() < 20) {
288  std::string space(20 - dictionary.name().size(), ' ');
289  msg(MSG::INFO) << space;
290  }
291  msg(MSG::INFO) << " version " << version;
292  if (version.size() < 20) {
293  std::string space(20 - version.size(), ' ');
294  msg(MSG::INFO) << space;
295  }
296  if (dictionary.dict_tag().size()) {
297  msg(MSG::INFO) << " DetDescr tag " << dictionary.dict_tag();
298  if (dictionary.dict_tag().size() < 20) {
299  std::string space(25 - dictionary.dict_tag().size(), ' ');
300  msg(MSG::INFO) << space;
301  }
302  } else {
303  msg(MSG::INFO) << " DetDescr tag (using default)";
304  }
305  ATH_MSG_INFO(" file " << dictionary.file_name());
306  }
307 }
308 
309 //--------------------------------------------------------------------
311  // Check whether non-default names have been specified for the
312  // IdDict files of the subsystems
313 
314  // Atlas IDs
315  ATH_CHECK(loadProperty("AtlasIDFileName", m_atlasIDFileName));
316  // InDet Ids
317  ATH_CHECK(loadProperty("InDetIDFileName", m_inDetIDFileName));
318  // LAr ids
319  ATH_CHECK(loadProperty("LArIDFileName", m_larIDFileName));
320  // Tile ids
321  ATH_CHECK(loadProperty("TileIDFileName", m_tileIDFileName));
322  // Calo ids
323  ATH_CHECK(loadProperty("CaloIDFileName", m_caloIDFileName));
324  // Calo neighbor files
325  ATH_CHECK(loadProperty("FullAtlasNeighborsFileName", m_fullAtlasNeighborsName));
326  ATH_CHECK(loadProperty("FCAL2DNeighborsFileName", m_fcal2dNeighborsName));
327  ATH_CHECK(loadProperty("FCAL3DNeighborsNextFileName", m_fcal3dNeighborsNextName));
328  ATH_CHECK(loadProperty("FCAL3DNeighborsPrevFileName", m_fcal3dNeighborsPrevName));
329 
330  ATH_CHECK(loadProperty("TileNeighborsFileName", m_tileNeighborsName));
331  // Muon ids
332  ATH_CHECK(loadProperty("MuonIDFileName", m_muonIDFileName));
333  // ForwardDetectors ids
334  ATH_CHECK(loadProperty("ForwardIDFileName", m_forwardIDFileName));
335  return StatusCode::SUCCESS;
336 }
337 
338 //--------------------------------------------------------------------
340  // Fetch file names and tags from the RDB
341  ATH_CHECK(m_geoDbTagSvc.retrieve());
342  bool skipDbDictAccess = m_geoDbTagSvc->getParamSvcName().empty();
343  std::string paramSvcName = skipDbDictAccess ? "RDBAccessSvc" : m_geoDbTagSvc->getParamSvcName();
344  ATH_MSG_DEBUG("Accessed " << paramSvcName);
345  m_rdbAccessSvc.setName(paramSvcName);
346  ATH_CHECK(m_rdbAccessSvc.retrieve());
347 
348  if(skipDbDictAccess) {
349  ATH_MSG_WARNING("Unable to determine RDBAccessSvc backend. Using default dictionaries");
350  // Get Calo Neighbor tables from Oracle and return
351  IRDBRecordset_ptr caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", "CaloNeighborTable-00");
352  collectCaloNeighbors(std::move(caloNeighborTable));
353  return StatusCode::SUCCESS;
354  }
355 
356  auto assignTagAndName = [this](const IRDBRecordset_ptr &idDictSet,
357  std::string &fileName,
358  std::string &dictTag) {
359  if (idDictSet->size()) {
360  const IRDBRecord *idDictTable = (*idDictSet)[0];
361  const std::string dictName = idDictTable->getString("DICT_NAME");
362  fileName = idDictTable->getString("DICT_FILENAME");
363  dictTag = idDictSet->tagName();
364  // NOTE: the internal tag for IdDict is global, but is
365  // only used for InDet and thus is defined by InDet
366  if (!idDictTable->isFieldNull("DICT_TAG")) {
367  m_inDetIDTag = idDictTable->getString("DICT_TAG");
368  }
369  ATH_MSG_DEBUG(" using dictionary: "
370  << dictName << ", file: " << fileName
371  << ", with internal tag: " << m_inDetIDTag
372  << ", dictionary tag: " << dictTag);
373 
374  } else {
375  ATH_MSG_WARNING(" no record set found for dictionary"<<idDictSet->nodeName()<< " - using default dictionary ");
376  }
377  };
378 
379  // Function for reading ID dictionary as a BLOB from SQLite
380  // and writing it on the disk in the run directory
381  auto getEmbeddedDict = [this](const std::string& dictName,
382  std::string &fileName,
383  std::string &dictTag) -> bool
384  {
385  ATH_MSG_DEBUG("Try to access "<<dictName);
386  IRDBRecordset_ptr rec = m_rdbAccessSvc->getRecordsetPtr(dictName,"","");
387  if(rec->size()>0) {
388  const IRDBRecord *dictRecord = (*rec)[0];
389  std::string dictString = dictRecord->getString("CONTENTS");
390  // write to the temporary file
391  std::string dictFileName = dictName+"-fromSQLite.xml";
392  std::ofstream dictFile;
393  dictFile.open(dictFileName);
394  dictFile << dictString;
395  dictFile.close();
396 
397  fileName = std::move(dictFileName);
398  dictTag.clear(); // This may change in the future if we also write dict tags into SQLite
399 
400  ATH_MSG_DEBUG(dictName << " read from the SQLite database as a BLOB");
401  return true;
402  }
403  return false;
404  };
405 
406  bool useGeomDB = (m_geoDbTagSvc->getSqliteReader() == nullptr);
407 
408  std::string detTag{""}, detNode{""}, dictName{""};
409  DecodeVersionKey detectorKey("ATLAS");
410  IRDBRecordset_ptr idDictSet{};
411 
412  bool embeddedDict{false};
413 
414  // Get InDet
415  if (m_useGeomDB_InDet) {
416  // Get Innner Detector xml and write to the temporary file
417  // InDetIdDict.xml
418  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "InnerDetector");
419  ATH_MSG_DEBUG("From Version Tag: " << detectorKey.tag() << " at Node: "
420  << detectorKey.node());
421  detTag = detectorKey.tag();
422  detNode = detectorKey.node();
423  idDictSet = m_rdbAccessSvc->getRecordsetPtr("DICTXDD", detTag, detNode);
424 
425  // Size == 0 if not found
426  if (idDictSet->size()) {
427  const IRDBRecord *recordInDet = (*idDictSet)[0];
428  std::string InDetString = recordInDet->getString("XMLCLOB");
429 
430  // write to the temporary file
431  std::ofstream blobFile;
432  blobFile.open("InDetIdDict.xml");
433  blobFile << InDetString << std::endl;
434  blobFile.close();
435  } else {
436  ATH_MSG_WARNING(" no record set found for InDetIdentifier - using default dictionary ");
437  }
438  } else {
439  // Attempt to read the embedded disctionary from SQLite
440  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictInnerDetector",m_inDetIDFileName,m_inDetIdDictTag);
441  if(!embeddedDict) {
442  // Fall back on getting file names from the database
443  if (useGeomDB) {
444  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "InnerDetector");
445  ATH_MSG_DEBUG("From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node());
446  detTag = detectorKey.tag();
447  detNode = detectorKey.node();
448  }
449  idDictSet = m_rdbAccessSvc->getRecordsetPtr("InDetIdentifier", detTag, detNode);
450  assignTagAndName(idDictSet, m_inDetIDFileName, m_inDetIdDictTag);
451  }
452  }
453 
454  // Get LAr
455  // Attempt to read the embedded disctionary from SQLite
456  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictLArCalorimeter",m_larIDFileName,m_larIdDictTag);
457  if(!embeddedDict) {
458  // Fall back on getting file names from the database
459  if (useGeomDB) {
460  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "LAr");
461  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
462  detTag = detectorKey.tag();
463  detNode = detectorKey.node();
464  }
465  idDictSet = m_rdbAccessSvc->getRecordsetPtr("LArIdentifier", detTag, detNode);
466  assignTagAndName(idDictSet, m_larIDFileName, m_larIdDictTag);
467  }
468 
469  // Get Tile
470  // Attempt to read the embedded disctionary from SQLite
471  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictTileCalorimeter",m_tileIDFileName,m_tileIdDictTag);
472  if(!embeddedDict) {
473  // Fall back on getting file names from the database
474  if (useGeomDB) {
475  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "TileCal");
476  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
477  detTag = detectorKey.tag();
478  detNode = detectorKey.node();
479  }
480  idDictSet = m_rdbAccessSvc->getRecordsetPtr("TileIdentifier", detTag, detNode);
481  assignTagAndName(idDictSet, m_tileIDFileName, m_tileIdDictTag);
482  }
483 
484  // Get Calo
485  // Attempt to read the embedded disctionary from SQLite
486  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictCalorimeter",m_caloIDFileName,m_caloIdDictTag);
487  if(!embeddedDict) {
488  // Fall back on getting file names from the database
489  if (useGeomDB) {
490  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "Calorimeter");
491  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag()<< " at Node: " << detectorKey.node() );
492  detTag = detectorKey.tag();
493  detNode = detectorKey.node();
494  }
495  idDictSet = m_rdbAccessSvc->getRecordsetPtr("CaloIdentifier", detTag, detNode);
496  assignTagAndName(idDictSet, m_caloIDFileName, m_caloIdDictTag);
497  }
498  // Calo neighbor files:
499  IRDBRecordset_ptr caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", detTag, detNode);
500 
501  if (caloNeighborTable->size() == 0 && useGeomDB) {
502  caloNeighborTable = m_rdbAccessSvc->getRecordsetPtr("CaloNeighborTable", "CaloNeighborTable-00");
503  }
504  // Size == 0 if not found
505  if (caloNeighborTable->size()) {
506  collectCaloNeighbors(std::move(caloNeighborTable));
507  }
508 
509  // Get Muon
510  // Attempt to read the embedded disctionary from SQLite
511  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictMuonSpectrometer", m_muonIDFileName, m_muonIdDictTag);
512  if(!embeddedDict) {
513  // Fall back on getting file names from the database
514  if (useGeomDB) {
515  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "MuonSpectrometer");
516  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag()<< " at Node: " << detectorKey.node() );
517  detTag = detectorKey.tag();
518  detNode = detectorKey.node();
519  }
520  idDictSet = m_rdbAccessSvc->getRecordsetPtr("MuonIdentifier", detTag, detNode);
521  assignTagAndName(idDictSet, m_muonIDFileName, m_muonIdDictTag);
522  }
523 
524  // Get Forward
525  // Attempt to read the embedded disctionary from SQLite
526  embeddedDict = !useGeomDB && getEmbeddedDict("IdDictForwardDetectors",m_forwardIDFileName,m_forwardIdDictTag);
527  if(!embeddedDict) {
528  // Fall back on getting file names from the database
529  if (useGeomDB) {
530  detectorKey = DecodeVersionKey(m_geoDbTagSvc.get(), "ForwardDetectors");
531  ATH_MSG_DEBUG( "From Version Tag: " << detectorKey.tag() << " at Node: " << detectorKey.node() );
532  detTag = detectorKey.tag();
533  detNode = detectorKey.node();
534  }
535  idDictSet = m_rdbAccessSvc->getRecordsetPtr("ForDetIdentifier", detTag, detNode);
536 
537  // For older datasets use ForDetIdentifier-00 as fallback
538  if (idDictSet->size() == 0 && useGeomDB) {
539  idDictSet = m_rdbAccessSvc->getRecordsetPtr("ForDetIdentifier",
540  "ForDetIdentifier-00");
541  ATH_MSG_DEBUG(" explicitly requesting ForDetIdentifier-00 tag for pre-forward "
542  "detector data ");
543  }
544  // Size == 0 if not found
545  assignTagAndName(idDictSet, m_forwardIDFileName, m_forwardIdDictTag);
546  }
547  ATH_MSG_DEBUG("End access to RDB for id dictionary info ");
548  return StatusCode::SUCCESS;
549 }
550 
551 //--------------------------------------------------------------------
553  // If InDetIdDict.xml exists set InDetFileName set to it's name
554  if (m_useGeomDB_InDet) {
555  std::ifstream ifile;
556  ifile.open("InDetIdDict.xml");
557  if (ifile)
558  m_inDetIDFileName = "InDetIdDict.xml";
559  else
560  ATH_MSG_WARNING(" no temp. file InDetIdDict.xml found - using file "
561  << m_inDetIDFileName);
562  }
563 
564  if (!m_atlasIDFileName.empty()) {
565  m_parser->register_external_entity("ATLAS", m_atlasIDFileName);
566  ATH_MSG_INFO("Reading ATLAS IdDict file "
567  << m_atlasIDFileName);
568  }
569  if (!m_inDetIDFileName.empty()) {
570  m_parser->register_external_entity("InnerDetector", m_inDetIDFileName);
571  ATH_MSG_INFO("Reading InnerDetector IdDict file "
572  << m_inDetIDFileName);
573  }
574  if (!m_larIDFileName.empty()) {
575  m_parser->register_external_entity("LArCalorimeter", m_larIDFileName);
576  ATH_MSG_INFO("Reading LArCalorimeter IdDict file "
577  << m_larIDFileName);
578  }
579  if (!m_tileIDFileName.empty()) {
580  m_parser->register_external_entity("TileCalorimeter", m_tileIDFileName);
581  ATH_MSG_INFO("Reading TileCalorimeter IdDict file "
582  << m_tileIDFileName);
583  }
584  if (!m_caloIDFileName.empty()) {
585  m_parser->register_external_entity("Calorimeter", m_caloIDFileName);
586  ATH_MSG_INFO("Reading Calorimeter IdDict file "
587  << m_caloIDFileName);
588  }
589  if (!m_muonIDFileName.empty()) {
590  m_parser->register_external_entity("MuonSpectrometer",
592  ATH_MSG_INFO("Reading MuonSpectrometer IdDict file "
593  << m_muonIDFileName);
594  }
595  if (!m_forwardIDFileName.empty()) {
596  m_parser->register_external_entity("ForwardDetectors",
598  ATH_MSG_INFO("Reading ForwardDetectors IdDict file "
600  }
601  return StatusCode::SUCCESS;
602 }
603 
604 //--------------------------------------------------------------------
606  // Save the file name and tag in each of the dictionaries
607  IdDictMgr &mgr = m_parser->m_idd;
608 
609  auto setDictPaths = [this, &mgr](const std::string &dict_name,
610  const std::string &file_name,
611  const std::string &dict_tag) {
612  if (file_name.empty()) {
613  ATH_MSG_DEBUG("No idDict will be loaded for " << dict_name);
614  return StatusCode::SUCCESS;
615  }
616  IdDictDictionary *dict = mgr.find_dictionary(dict_name);
617  if (!dict) {
618  ATH_MSG_ERROR("unable to find idDict for " << dict_name);
619  return StatusCode::FAILURE;
620  }
621  dict->set_file_name(file_name);
622  dict->set_dict_tag(dict_tag);
623  ATH_MSG_DEBUG("For " << dict_name << " idDict, setting file/tag: "
624  << file_name << " " << dict_tag);
625  return StatusCode::SUCCESS;
626  };
627  ATH_CHECK(setDictPaths("ATLAS", m_atlasIDFileName, m_atlasIdDictTag));
628  ATH_CHECK(setDictPaths("InnerDetector", m_inDetIDFileName, m_inDetIdDictTag));
629  ATH_CHECK(setDictPaths("LArCalorimeter", m_larIDFileName, m_larIdDictTag));
630  ATH_CHECK(setDictPaths("TileCalorimeter", m_tileIDFileName, m_tileIdDictTag));
631  ATH_CHECK(setDictPaths("Calorimeter", m_caloIDFileName, m_caloIdDictTag));
632  ATH_CHECK(setDictPaths("MuonSpectrometer", m_muonIDFileName, m_muonIdDictTag));
633  ATH_CHECK(setDictPaths("ForwardDetectors", m_forwardIDFileName, m_forwardIdDictTag));
634 
635  auto addMetaData = [&mgr, this](const std::string &key,
636  const std::string &value) {
637  if (value.empty()) {
638  ATH_MSG_DEBUG("No value given for key " << key);
639  } else {
640  mgr.add_metadata(key, value);
641  ATH_MSG_DEBUG("Added to dict mgr meta data: <" << key << ","
642  << value << ">");
643  }
644  };
645  addMetaData("FULLATLASNEIGHBORS", m_fullAtlasNeighborsName);
646  addMetaData("FCAL2DNEIGHBORS", m_fcal2dNeighborsName);
647  addMetaData("FCAL3DNEIGHBORSNEXT", m_fcal3dNeighborsNextName);
648  addMetaData("FCAL3DNEIGHBORSPREV", m_fcal3dNeighborsPrevName);
649  addMetaData("TILENEIGHBORS", m_tileNeighborsName);
650 
651  return StatusCode::SUCCESS;
652 }
653 
654 template <class dType>
655 StatusCode IdDictDetDescrCnv::loadProperty(const std::string &propertyName,
656  dType &pipeTo) {
657 
658  if (!m_detDescrProxy->hasProperty(propertyName)) {
659  ATH_MSG_FATAL("DetDescrSvc does not have the property "
660  << propertyName);
661  return StatusCode::FAILURE;
662  }
663  const Gaudi::Details::PropertyBase &prop =
664  m_detDescrProxy->getProperty(propertyName);
665  const Gaudi::Property<dType> *propPtr{
666  dynamic_cast<const Gaudi::Property<dType> *>(&prop)};
667  if (!propPtr) {
668  ATH_MSG_ERROR("Property " << propertyName << " is not of type"
669  << typeid(dType).name() << " but of "
670  << typeid(prop).name());
671  return StatusCode::FAILURE;
672  }
673  pipeTo = propPtr->value();
674  ATH_MSG_DEBUG("Flag " << propertyName << " is: " << pipeTo);
675  return StatusCode::SUCCESS;
676 }
677 
680 template <class dType>
682  const std::string &propertyName, dType &pipeTo) {
683  dType cache{};
684  ATH_CHECK(loadProperty(propertyName, cache));
685  m_doParsing |= cache != pipeTo;
686  pipeTo = std::move(cache);
687  return StatusCode::SUCCESS;
688 }
IdDictDetDescrCnv::m_tileIdDictTag
std::string m_tileIdDictTag
Tag of RDB record for Tile ids.
Definition: IdDictDetDescrCnv.h:155
IdDictMgr::dictionary_map
std::map< std::string, IdDictDictionary * > dictionary_map
Definition: IdDictMgr.h:16
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:655
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:605
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:339
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
skel.it
it
Definition: skel.GENtoEVGEN.py:407
IdDictMgr::get_dictionary_map
const dictionary_map & get_dictionary_map() const
Access to all dictionaries.
Definition: IdDictMgr.cxx:110
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:388
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
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
IdDictDetDescrCnv::m_inDetIdDictTag
std::string m_inDetIdDictTag
Tag of RDB record for InDet ids.
Definition: IdDictDetDescrCnv.h:149
IdDictMgr
Definition: IdDictMgr.h:14
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
beamspotman.n
n
Definition: beamspotman.py:727
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:381
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:552
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
ReadCellNoiseFromCool.dm
dm
Definition: ReadCellNoiseFromCool.py:235
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
IdDictDetDescrCnv::m_rdbAccessSvc
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc
Definition: IdDictDetDescrCnv.h:59
DecodeVersionKey.h
IdDictDictionary
Definition: IdDictDictionary.h:30
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:681
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:310
IdDictMgr::tag
const std::string & tag() const
Version tag.
Definition: IdDictMgr.cxx:56
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