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