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