ATLAS Offline Software
GeoModelSvc.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 #include "GeoModelSvc.h"
6 #include "RDBMaterialManager.h"
7 #include "GeoDbTagSvc.h"
8 
9 #include "GeoModelKernel/GeoBox.h"
10 #include "GeoModelKernel/GeoLogVol.h"
11 #include "GeoModelKernel/GeoPhysVol.h"
12 #include "GeoModelKernel/GeoMaterial.h"
13 #include "GeoModelKernel/GeoVolumeCursor.h"
14 #include "GeoModelKernel/GeoPerfUtils.h"
16 
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/IConversionSvc.h"
19 #include "GaudiKernel/SystemOfUnits.h"
21 #include "SGTools/DataProxy.h"
23 
27 
28 #include <fstream>
29 
30 GeoModelSvc::GeoModelSvc(const std::string& name,ISvcLocator* svc)
32  , m_pSvcLocator(svc)
33 {
34 }
35 
37 // ^ due to IGeoModelTool::registerCallback
38 {
39  // Activate the initialization from SQLite if the overrider has been used
40  if(!m_sqliteDbFullPath.empty()) m_sqliteDb=true;
41 
42  if(!m_sqliteDb && m_supportedGeometry==0) {
43  ATH_MSG_FATAL("The Supported Geometry flag was not set in Job Options! Exiting ...");
44  return StatusCode::FAILURE;
45  }
46 
47  ATH_CHECK( m_detStore.retrieve() );
48 
49  // --- Sebastien
50  // clients (detector tools) are assuming the DetDescrCnvSvc has been
51  // correctly initialized.
52  // We ensure this is indeed correct by manually initialize it so there is
53  // no more service-ordering problem triggered by jobO mix-up
54  ServiceHandle<IConversionSvc> conversionSvc("DetDescrCnvSvc", this->name());
55  ATH_CHECK( conversionSvc.retrieve() );
56  // --- Sebastien
57 
58  // Working around Gaudi Issue https://gitlab.cern.ch/gaudi/Gaudi/issues/82
59  Service* convSvc=dynamic_cast<Service*>(conversionSvc.get());
60  if (convSvc->FSMState() < Gaudi::StateMachine::INITIALIZED) {
61  ATH_MSG_INFO("Explicitly initializing DetDescrCnvSvc");
62  ATH_CHECK( convSvc->sysInitialize() );
63  }
64 
65  ATH_CHECK( m_detectorTools.retrieve() );
66 
67  ToolHandleArray< IGeoModelTool >::iterator itPriv = m_detectorTools.begin(),
68  itPrivEnd = m_detectorTools.end();
69 
70  if(m_useTagInfo) {
71  ATH_CHECK( m_tagInfoMgr.retrieve() );
72  }
73 
74  // build regular geometry
75  ATH_CHECK( geoInit() );
76 
77  if(!m_callBackON) {
78  // _________________ Align functions NOT registered as callbacks _____________
79 
80  // Apply possible alignments to detectors.
81  // Dummy parameters for the callback
82  int par1 = 0;
83  std::list<std::string> par2;
84  for(; itPriv!=itPrivEnd; ++itPriv) {
85  if((*itPriv)->align(par1,par2) != StatusCode::SUCCESS) {
86  ATH_MSG_DEBUG("align() failed for the tool " << (*itPriv)->name());
87  }
88  }
89 
90  // Fill in the contents of TagInfo
91  if(m_useTagInfo) {
92  ATH_CHECK(fillTagInfo());
93  }
94  }
95  else {
96  // Register align() functions for all Tools
97  for (; itPriv!=itPrivEnd; ++itPriv) {
98  IGeoModelTool* theTool = &(**itPriv);
99 
100  if(StatusCode::SUCCESS != theTool->registerCallback()) {
101  ATH_MSG_DEBUG("IGeoModelTool::align() was not registerred on CondDB object for the tool " << theTool->name());
102  }
103  }
104 
105  // Register a callback on TagInfo in order to compare geometry configurations defined in job options
106  // to the one read from the input file
107  if(m_useTagInfo) {
108  m_tagInfoMgr->addListener( this );
109  // Fill in the contents of TagInfo
110  ATH_CHECK(fillTagInfo());
111  }
112  }
113 
114  return StatusCode::SUCCESS;
115 }
116 
118 {
119  m_tagInfoMgr->removeListener(this);
120  return StatusCode::SUCCESS;
121 }
122 
123 // Query the interfaces.
124 // Input: riid, Requested interface ID
125 // ppvInterface, Pointer to requested interface
126 // Return: StatusCode indicating SUCCESS or FAILURE.
127 // N.B. Don't forget to release the interface after use!!!
128 StatusCode GeoModelSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
129 {
130  if(IGeoModelSvc::interfaceID().versionMatch(riid)) {
131  *ppvInterface = (IGeoModelSvc*)this;
132  addRef();
133  return StatusCode::SUCCESS;
134  }
135  else {
136  // Interface is not directly available: try out a base class
137  return AthService::queryInterface(riid, ppvInterface);
138  }
139 }
140 
142 {
143  GeoPhysVol* worldPhys{nullptr};
144  ServiceHandle<IRDBAccessSvc> rdbAccess("RDBAccessSvc",name());
145 
146  // Setup the GeoDbTagSvc
147  ATH_CHECK( m_geoDbTagSvc.retrieve() );
148 
149  GeoDbTagSvc* dbTagSvc = dynamic_cast<GeoDbTagSvc*>(m_geoDbTagSvc.get());
150  if(dbTagSvc==nullptr) {
151  ATH_MSG_FATAL("Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
152  return StatusCode::FAILURE;
153  }
154 
155  // Build geometry from the SQLiteDB file
156  if(m_sqliteDb) {
157  std::string sqliteDbName = "Geometry/" + m_atlasVersion + ".db";
158  std::string sqliteDbPath = m_sqliteDbFullPath.empty()
159  ? PathResolver::find_file (sqliteDbName, "CALIBPATH")
160  : m_sqliteDbFullPath.value();
161  if(sqliteDbPath.empty() && m_sqliteDbFullPath.empty()) {
162  ATH_MSG_FATAL("Failed to find SQLite database file " << sqliteDbName << " for reading in persistent GeoModel tree");
163  return StatusCode::FAILURE;
164  }
165  else {
166  ATH_MSG_INFO("Successfully located SQLite database file " << sqliteDbPath << " for reading in persistent GeoModel tree");
167  }
168  // Read raw geometry description from the file
169  m_sqliteDbManager = std::make_unique<GMDBManager>(sqliteDbPath);
170  if(m_sqliteDbManager->checkIsDBOpen()) {
171  ATH_MSG_INFO("Successfully opened SQLite DB file " << sqliteDbPath << " for reading in persistent GeoModel tree");
172  } else {
173  ATH_MSG_FATAL("Failed to open SQLite database " << sqliteDbPath << " for reading in persistent GeoModel tree");
174  return StatusCode::FAILURE;
175  }
176  m_sqliteReader = std::make_unique<GeoModelIO::ReadGeoModel>(m_sqliteDbManager.get());
177  GeoVPhysVol* vWorldPhys ATLAS_THREAD_SAFE = const_cast<GeoVPhysVol*>(m_sqliteReader->buildGeoModel());
178  worldPhys = dynamic_cast<GeoPhysVol*>(vWorldPhys);
179  if(!worldPhys) {
180  ATH_MSG_FATAL("Having Full Physical Volumes as World Volumes not supported!");
181  return StatusCode::FAILURE;
182  }
183  ATH_MSG_INFO("Successfully read persistent GeoModel description from the file");
184 
185  // Initialize SqliteReadSvc and open the file for reading plain SQLite tables with DetDescr parameters
186  ServiceHandle<IRDBAccessSvc> sqliteReadSvc("SqliteReadSvc",name());
187  ATH_CHECK(sqliteReadSvc.retrieve());
188  if(!sqliteReadSvc->connect(sqliteDbPath)) {
189  ATH_MSG_FATAL("Failed to open SQLite database file " << sqliteDbPath << " for reading geometry parameters");
190  return StatusCode::FAILURE;
191  } else {
192  ATH_MSG_INFO("Successfully opened SQLite DB file: " << sqliteDbPath << " for reading Det Descr parameters");
193  }
194  dbTagSvc->setParamSvcName("SqliteReadSvc");
195  dbTagSvc->setSqliteReader(m_sqliteReader.get());
196  }
197  else {
198  // Build geometry from the GeometryDB
199  ATH_MSG_DEBUG("** Building geometry configuration: ");
200  ATH_MSG_DEBUG("* ATLAS tag: " << m_atlasVersion);
201  ATH_MSG_DEBUG("* InDet tag: " << m_inDetVersionOverride);
202  ATH_MSG_DEBUG("* Pixel tag: " << m_pixelVersionOverride);
203  ATH_MSG_DEBUG("* SCT tag: " << m_sctVersionOverride);
204  ATH_MSG_DEBUG("* TRT tag: " << m_trtVersionOverride);
205  ATH_MSG_DEBUG("* LAr tag: " << m_larVersionOverride);
206  ATH_MSG_DEBUG("* Tile tag: " << m_tileVersionOverride);
207  ATH_MSG_DEBUG("* Muon tag: " << m_muonVersionOverride);
208  ATH_MSG_DEBUG("* Calo tag: " << m_caloVersionOverride);
209  ATH_MSG_DEBUG("* MagField tag: " << m_bFieldVersionOverride);
210  ATH_MSG_DEBUG("* CavernInfra tag: " << m_cavInfraVersionOverride);
211  ATH_MSG_DEBUG("* ForwardDetectors tag: " << m_forDetVersionOverride);
212 
213  // Get RDBAccessSvc and open connection to DB
214  ATH_CHECK( rdbAccess.retrieve() );
215 
216  if(!rdbAccess->connect()) {
217  ATH_MSG_FATAL("Unable to connect to the Geometry DB");
218  return StatusCode::FAILURE;
219  }
220 
221  // Check the existence of ATLAS tag in the database
222  if(rdbAccess->getChildTag("ATLAS",m_atlasVersion,"ATLAS")=="") {
223  ATH_MSG_FATAL(" *** *** Wrong ATLAS layout: " << m_atlasVersion << " *** ***");
224  ATH_MSG_FATAL(" Either ATLAS geometry tag has been misspelled, or the DB Release does not contain the geometry specified.");
225  ATH_MSG_FATAL(" In latter case please update DB Release version");
226  return StatusCode::FAILURE;
227  }
228 
229  dbTagSvc->setParamSvcName("RDBAccessSvc");
230 
231  if(!m_ignoreTagSupport) {
232  RDBTagDetails atlasTagDetails;
233  rdbAccess->getTagDetails(atlasTagDetails, m_atlasVersion);
234  const coral::AttributeSpecification& supportedSpec = atlasTagDetails["SUPPORTED"].specification();
235  if(supportedSpec.type()==typeid(bool)) {
236  if(!atlasTagDetails["SUPPORTED"].data<bool>()) {
237  ATH_MSG_FATAL(" *** *** ATLAS layout " << m_atlasVersion << " is OBSOLETE and can NOT be supported any more! *** ***");
238  return StatusCode::FAILURE;
239  }
240  }
241  else if(supportedSpec.type()==typeid(int)) {
242  if(atlasTagDetails["SUPPORTED"].data<int>()<m_supportedGeometry) {
243  ATH_MSG_FATAL(" *** *** ATLAS layout " << m_atlasVersion
244  << " is OBSOLETE in rel " << m_supportedGeometry
245  << " and can NOT be supported any more! *** ***");
246  return StatusCode::FAILURE;
247  }
248  }
249  }
250 
251  dbTagSvc->setAtlasVersion(m_atlasVersion);
263 
264  if(dbTagSvc->setupTags().isFailure()) {
265  ATH_MSG_FATAL("Failed to setup subsystem tags");
266  return StatusCode::FAILURE;
267  }
268 
269  // Create a material manager
270  StoredMaterialManager *theMaterialManager{nullptr};
271  try{
272  theMaterialManager = new RDBMaterialManager(m_pSvcLocator);
273  }
274  catch(std::runtime_error& e) {
275  ATH_MSG_FATAL(e.what());
276  return StatusCode::FAILURE;
277  }
278  ATH_CHECK( m_detStore->record(theMaterialManager,"MATERIALS") );
279 
280  // Build the world node from which everything else will be suspended
281  const GeoMaterial* air = theMaterialManager->getMaterial("std::Air");
282  const GeoBox* worldBox = new GeoBox(1000*Gaudi::Units::cm,1000*Gaudi::Units::cm, 1000*Gaudi::Units::cm);
283  const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, air);
284  worldPhys=new GeoPhysVol(worldLog);
285  } // End of the GeometryDB-specific part
286 
287  // Create AtlasExperiment and register it within the transient detector store
288  GeoModelExperiment* theExperiment = new GeoModelExperiment(worldPhys);
289  ATH_CHECK( m_detStore->record(theExperiment,"ATLAS") );
290 
291  int mem,cpu;
292  std::unique_ptr<std::ofstream> geoModelStats;
293  if(m_statisticsToFile) {
294  geoModelStats = std::make_unique<std::ofstream>("GeoModelStatistics");
295  *geoModelStats << "Detector Configuration flag = " << m_atlasVersion << std::endl;
296  }
297 
298  // Loop over all tools
300  itPrivEnd = m_detectorTools.end();
301 
302  for(; itPriv!=itPrivEnd; ++itPriv) {
303  IGeoModelTool* theTool = &(**itPriv);
304 
305  mem = GeoPerfUtils::getMem();
306  cpu = GeoPerfUtils::getCpu();
307 
308  ATH_CHECK(theTool->create());
309 
310  if(m_statisticsToFile) {
311  *geoModelStats << theTool->name() << "\t SZ= "
312  << GeoPerfUtils::getMem() - mem << "Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01 << "S" << std::endl;
313  }
314  else {
315  ATH_MSG_INFO(theTool->name() << "\t SZ= "
316  << GeoPerfUtils::getMem() - mem << "Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01 << "S");
317  }
318  }
319 
320  if(m_statisticsToFile) {
321  geoModelStats->close();
322  }
323 
324  if(!m_sqliteDb) {
325  // Close connection to the GeometryDB
326  rdbAccess->shutdown();
327  }
328 
329  return StatusCode::SUCCESS;
330 }
331 
332 
334 {
335  compareTags().ignore();
336 }
337 
338 
340 {
341  bool tagsMatch = true;
342 
343  ATH_MSG_DEBUG("in compareTags()");
344 
345  // Get tags from TagInfoMgr
346  const ITagInfoMgr::NameTagPairVec pairs = m_tagInfoMgr->getInputTags();
347  for( const auto& pair : pairs ) {
348  std::string tagPairName = pair.first;
349  if(tagPairName=="GeoAtlas") {
350  // ** Two possible cases need to be taken into account
351  // **
352  // ** 1. The retrieved ATLAS tag is following naming schema ATLAS-...-XX-YY-ZZ
353  // ** where '...' can be anything, it may also containg one or more '-'.
354  // ** If this is the case, then we need to check whether the job option tag
355  // ** is also following the same schema and they have the same 'ATLAS-...-XX' part
356  // **
357  // ** 2. The retrieved ATLAS tag is not following the schema mentioned above
358  // ** If this is the case, we just need to check the exact match
359  std::vector<std::string> tokensTagInfo, tokensJobOpt;
360 
361  // Parse Tag Info tag
362  std::string::size_type startpos = 0;
363  std::string currStr = pair.second;
364  for(std::string::size_type endpos=currStr.find('-'); endpos!=std::string::npos; endpos=currStr.find('-',startpos)) {
365  tokensTagInfo.push_back(currStr.substr(startpos,endpos-startpos));
366  startpos = endpos+1;
367  }
368  tokensTagInfo.push_back(currStr.substr(startpos));
369 
370  size_t tokensTagInfoSize = tokensTagInfo.size();
371  bool tagInfoFollowsTheScheme = (tokensTagInfoSize>=5
372  && tokensTagInfo[tokensTagInfoSize-1].size()==2
373  && tokensTagInfo[tokensTagInfoSize-2].size()==2
374  && tokensTagInfo[tokensTagInfoSize-3].size()==2);
375 
376  if(tagInfoFollowsTheScheme) {
377  // Parse Job Options tag
378  startpos = 0;
379  currStr = m_atlasVersion;
380  for(std::string::size_type endpos=currStr.find('-'); endpos!=std::string::npos; endpos=currStr.find('-',startpos)) {
381  tokensJobOpt.push_back(currStr.substr(startpos,endpos-startpos));
382  startpos = endpos+1;
383  }
384  tokensJobOpt.push_back(currStr.substr(startpos));
385 
386  size_t tokensJobOptSize = tokensJobOpt.size();
387  bool jobOptFollowsTheScheme = (tokensJobOptSize>=5
388  && tokensJobOpt[tokensJobOptSize-1].size()==2
389  && tokensJobOpt[tokensJobOptSize-2].size()==2
390  && tokensJobOpt[tokensJobOptSize-3].size()==2);
391  if(jobOptFollowsTheScheme) {
392  const std::string& atlasVersion = m_atlasVersion;
393  tagsMatch = (pair.second.substr(0,currStr.size()-6)==atlasVersion.substr(0,atlasVersion.size()-6));
394  }
395  else {
396  tagsMatch = false;
397  }
398  }
399  else {// Check for the exact match
400  tagsMatch = m_atlasVersion == pair.second;
401  }
402  }
403  else if(tagPairName=="GeoInDet")
404  tagsMatch = m_inDetVersionOverride == pair.second;
405  else if(tagPairName=="GeoPixel")
406  tagsMatch = m_pixelVersionOverride == pair.second;
407  else if(tagPairName=="GeoSCT")
408  tagsMatch = m_sctVersionOverride == pair.second;
409  else if(tagPairName=="GeoTRT")
410  tagsMatch = m_trtVersionOverride == pair.second;
411  else if(tagPairName=="GeoLAr")
412  tagsMatch = m_larVersionOverride == pair.second;
413  else if(tagPairName=="GeoTile")
414  tagsMatch = m_tileVersionOverride == pair.second;
415  else if(tagPairName=="GeoMuon")
416  tagsMatch = m_muonVersionOverride == pair.second;
417 
418  if(!tagsMatch) break;
419  }
420 
421  if(!tagsMatch) {
422  msg((m_ignoreTagDifference? MSG::WARNING : MSG::ERROR))
423  << "*** *** Geometry configured through jobOptions does not match TagInfo tags! *** ***" << endmsg;
424  ATH_MSG_INFO("** Job Option configuration: ");
425  ATH_MSG_INFO("* ATLAS tag: " << m_atlasVersion);
426  ATH_MSG_INFO("* InDet tag: " << m_inDetVersionOverride);
427  ATH_MSG_INFO("* Pixel tag: " << m_pixelVersionOverride);
428  ATH_MSG_INFO("* SCT tag: " << m_sctVersionOverride);
429  ATH_MSG_INFO("* TRT tag: " << m_trtVersionOverride);
430  ATH_MSG_INFO("* LAr tag: " << m_larVersionOverride);
431  ATH_MSG_INFO("* Tile tag: " << m_tileVersionOverride);
432  ATH_MSG_INFO("* Muon tag: " << m_muonVersionOverride);
433  ATH_MSG_INFO("* Calo tag: " << m_caloVersionOverride);
434  ATH_MSG_INFO("* MagField tag: " << m_bFieldVersionOverride);
435  ATH_MSG_INFO("* CavernInfra tag: " << m_cavInfraVersionOverride);
436  ATH_MSG_INFO("* ForwardDetectors tag: " << m_forDetVersionOverride);
437  ATH_MSG_INFO("** TAG INFO configuration: ");
438  for (const auto& pair : pairs) {
439  std::string tagPairName = pair.first;
440  if(tagPairName=="GeoAtlas")
441  ATH_MSG_INFO("* ATLAS tag: " << pair.second);
442  else if(tagPairName=="GeoInDet")
443  ATH_MSG_INFO("*InDet tag: " << pair.second);
444  else if(tagPairName=="GeoPixel")
445  ATH_MSG_INFO("*Pixel tag: " << pair.second);
446  else if(tagPairName=="GeoSCT")
447  ATH_MSG_INFO("*SCT tag: " << pair.second);
448  else if(tagPairName=="GeoTRT")
449  ATH_MSG_INFO("*TRT tag: " << pair.second);
450  else if(tagPairName=="GeoLAr")
451  ATH_MSG_INFO("*LAr tag: " << pair.second);
452  else if(tagPairName=="GeoTile")
453  ATH_MSG_INFO("*Tile tag: " << pair.second);
454  else if(tagPairName=="GeoMuon")
455  ATH_MSG_INFO("*Muon tag: " << pair.second);
456  else if(tagPairName=="GeoCalo")
457  ATH_MSG_INFO("*Calo tag: " << pair.second);
458  else if(tagPairName=="GeoMagField")
459  ATH_MSG_INFO("*MagField tag: " << pair.second);
460  else if(tagPairName=="GeoCavernInfra")
461  ATH_MSG_INFO("*CavernInfra tag: " << pair.second);
462  else if(tagPairName=="GeoForwardDetectors")
463  ATH_MSG_INFO("*ForwardDetectors tag: " << pair.second);
464  }
465 
466  if(!m_ignoreTagDifference) {
467  ATH_MSG_INFO("*** *** Please fix geometry tag settings *** ***");
468  return StatusCode::FAILURE;
469  }
470  }
471  else
472  ATH_MSG_DEBUG("Geometry configurations in jobOptions and TagInfo are consistent");
473 
474  return StatusCode::SUCCESS;
475 }
476 
477 /**********************************************************************************
478  ** Private Member Functions
479  **********************************************************************************/
481 {
482  if(m_atlasVersion == "") {
483  ATH_MSG_ERROR("ATLAS version is empty");
484  return StatusCode::FAILURE;
485  }
486 
487  if(m_tagInfoMgr->addTag("GeoAtlas",m_atlasVersion).isFailure()) {
488  ATH_MSG_ERROR("GeoModelSvc Atlas tag: " << m_atlasVersion << " not added to TagInfo ");
489  return StatusCode::FAILURE;
490  }
491 
492  if(m_inDetVersionOverride != "") {
493  if(m_tagInfoMgr->addTag("GeoInDet",m_inDetVersionOverride).isFailure()) {
494  ATH_MSG_ERROR("GeoModelSvc InDet tag: " << m_inDetVersionOverride << " not added to TagInfo ");
495  return StatusCode::FAILURE;
496  }
497  }
498 
499  if(m_pixelVersionOverride != "") {
500  if(m_tagInfoMgr->addTag("GeoPixel",m_pixelVersionOverride).isFailure()) {
501  ATH_MSG_ERROR("GeoModelSvc Pixel tag: " << m_pixelVersionOverride << " not added to TagInfo ");
502  return StatusCode::FAILURE;
503  }
504  }
505 
506  if(m_sctVersionOverride != "") {
507  if(m_tagInfoMgr->addTag("GeoSCT",m_sctVersionOverride).isFailure()) {
508  ATH_MSG_ERROR("GeoModelSvc SCT tag: " << m_sctVersionOverride << " not added to TagInfo ");
509  return StatusCode::FAILURE;
510  }
511  }
512 
513  if(m_trtVersionOverride != "") {
514  if(m_tagInfoMgr->addTag("GeoTRT",m_trtVersionOverride).isFailure()) {
515  ATH_MSG_ERROR("GeoModelSvc TRT tag: " << m_trtVersionOverride << " not added to TagInfo ");
516  return StatusCode::FAILURE;
517  }
518  }
519 
520  if(m_larVersionOverride != "") {
521  if(m_tagInfoMgr->addTag("GeoLAr",m_larVersionOverride).isFailure()) {
522  ATH_MSG_ERROR("GeoModelSvc LAr tag: " << m_larVersionOverride << " not added to TagInfo ");
523  return StatusCode::FAILURE;
524  }
525  }
526 
527  if(m_tileVersionOverride != "") {
528  if(m_tagInfoMgr->addTag("GeoTile",m_tileVersionOverride).isFailure()) {
529  ATH_MSG_ERROR("GeoModelSvc Tile tag: " << m_tileVersionOverride << " not added to TagInfo ");
530  return StatusCode::FAILURE;
531  }
532  }
533 
534  if(m_muonVersionOverride != "") {
535  if(m_tagInfoMgr->addTag("GeoMuon",m_muonVersionOverride).isFailure()) {
536  ATH_MSG_ERROR("GeoModelSvc Muon tag: " << m_muonVersionOverride << " not added to TagInfo ");
537  return StatusCode::FAILURE;
538  }
539  }
540 
541  if(m_caloVersionOverride != "") {
542  if(m_tagInfoMgr->addTag("GeoCalo",m_caloVersionOverride).isFailure()) {
543  ATH_MSG_ERROR("GeoModelSvc Calo tag: " << m_caloVersionOverride << " not added to TagInfo ");
544  return StatusCode::FAILURE;
545  }
546  }
547 
548  if(m_bFieldVersionOverride != "") {
549  if(m_tagInfoMgr->addTag("GeoMagField",m_bFieldVersionOverride).isFailure()) {
550  ATH_MSG_ERROR("GeoModelSvc MagField tag: " << m_bFieldVersionOverride << " not added to TagInfo ");
551  return StatusCode::FAILURE;
552  }
553  }
554 
555  if(m_cavInfraVersionOverride != "") {
556  if(m_tagInfoMgr->addTag("GeoCavernInfra",m_cavInfraVersionOverride).isFailure()) {
557  ATH_MSG_ERROR("GeoModelSvc CavernInfra tag: " << m_cavInfraVersionOverride << " not added to TagInfo ");
558  return StatusCode::FAILURE;
559  }
560  }
561 
562  if(m_forDetVersionOverride != "") {
563  if(m_tagInfoMgr->addTag("GeoForwardDetectors",m_forDetVersionOverride).isFailure()) {
564  ATH_MSG_ERROR("GeoModelSvc ForwardDetectors tag: " << m_forDetVersionOverride << " not added to TagInfo ");
565  return StatusCode::FAILURE;
566  }
567  }
568 
569  return StatusCode::SUCCESS;
570 }
571 
572 const IGeoModelTool* GeoModelSvc::getTool(std::string toolName) const
573 {
574  for (const ToolHandle<IGeoModelTool>& tool : m_detectorTools) {
575  if(tool->name().find(toolName)!=std::string::npos)
576  return tool.get();
577  }
578 
579  return 0;
580 }
581 
583 {
584  ATH_MSG_DEBUG("In clear()");
585 
586  // Call clear() for all tools
587  for (ToolHandle<IGeoModelTool>& tool : m_detectorTools) {
588  if(tool->clear().isFailure()) {
589  ATH_MSG_ERROR("clear() failed for the tool: " << tool->name());
590  return StatusCode::FAILURE;
591  } else {
592  ATH_MSG_DEBUG(tool->name() << " tool released");
593  }
594  }
595 
596  // Delete GeoModelExperiment - cascade delete of the entire GeoModel tree
597  std::vector<std::string> sgkeysExp;
598  m_detStore->keys<GeoModelExperiment>(sgkeysExp);
599  for (const std::string& key : sgkeysExp) {
601  if(proxy) {
602  proxy->reset();
603  ATH_MSG_DEBUG(key << " GeoModel experiment released");
604  }
605  }
606 
607  // Release stored material manager
608  std::vector<std::string> sgkeysMat;
609  m_detStore->keys<StoredMaterialManager>(sgkeysMat);
610  for (const std::string& key : sgkeysMat) {
612  if(proxy) {
613  proxy->reset();
614  ATH_MSG_DEBUG(key << " material manager released");
615  }
616  }
617 
618  return StatusCode::SUCCESS;
619 }
GeoDbTagSvc::setTileVersionOverride
void setTileVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:33
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RDBMaterialManager.h
GeoModelSvc::m_sctVersionOverride
Gaudi::Property< std::string > m_sctVersionOverride
Definition: GeoModelSvc.h:65
GeoModelSvc::m_tileVersionOverride
Gaudi::Property< std::string > m_tileVersionOverride
Definition: GeoModelSvc.h:68
GeoModelSvc::m_muonVersionOverride
Gaudi::Property< std::string > m_muonVersionOverride
Definition: GeoModelSvc.h:69
GeoDbTagSvc
Definition: GeoDbTagSvc.h:15
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
GeoModelSvc::m_trtVersionOverride
Gaudi::Property< std::string > m_trtVersionOverride
Definition: GeoModelSvc.h:66
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GeoModelSvc::m_sqliteDbFullPath
Gaudi::Property< std::string > m_sqliteDbFullPath
Definition: GeoModelSvc.h:85
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
IGeoModelSvc
Definition: IGeoModelSvc.h:17
IGeoModelSvc::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: IGeoModelSvc.h:58
GeoDbTagSvc::setAtlasVersion
void setAtlasVersion(const std::string &tag)
Definition: GeoDbTagSvc.h:27
GeoModelSvc::getTool
virtual const IGeoModelTool * getTool(std::string toolName) const override
Definition: GeoModelSvc.cxx:572
initialize
void initialize()
Definition: run_EoverP.cxx:894
GeoModelSvc::tagInfoUpdated
virtual void tagInfoUpdated() override final
Callback from TagInfoMgr on TagInfo change.
Definition: GeoModelSvc.cxx:333
GeoModelSvc::finalize
virtual StatusCode finalize() override
Definition: GeoModelSvc.cxx:117
GeoModelExperiment
Definition: GeoModelExperiment.h:32
GeoModelSvc::atlasVersion
virtual const std::string & atlasVersion() const override
Definition: GeoModelSvc.h:90
GeoModelSvc::m_supportedGeometry
Gaudi::Property< int > m_supportedGeometry
Definition: GeoModelSvc.h:81
RDBMaterialManager
Definition: RDBMaterialManager.h:28
GeoModelSvc::fillTagInfo
StatusCode fillTagInfo() const
Definition: GeoModelSvc.cxx:480
python.FakeAthena.Service
def Service(name)
Definition: FakeAthena.py:38
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
GeoModelExperiment.h
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
GeoModelSvc::m_atlasVersion
Gaudi::Property< std::string > m_atlasVersion
Definition: GeoModelSvc.h:61
GeoModelSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: GeoModelSvc.cxx:128
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GeoModelSvc::m_sqliteReader
std::unique_ptr< GeoModelIO::ReadGeoModel > m_sqliteReader
Definition: GeoModelSvc.h:87
GeoModelSvc::m_detectorTools
ToolHandleArray< IGeoModelTool > m_detectorTools
Definition: GeoModelSvc.h:53
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
ITagInfoMgr::NameTagPairVec
std::vector< NameTagPair > NameTagPairVec
Definition: ITagInfoMgr.h:63
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
AthService
Definition: AthService.h:32
GeoDbTagSvc.h
GeoDbTagSvc::setMuonVersionOverride
void setMuonVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:34
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
GeoModelSvc::m_caloVersionOverride
Gaudi::Property< std::string > m_caloVersionOverride
Definition: GeoModelSvc.h:70
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
GeoDbTagSvc::setInDetVersionOverride
void setInDetVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:28
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
GeoModelSvc::m_inDetVersionOverride
Gaudi::Property< std::string > m_inDetVersionOverride
Definition: GeoModelSvc.h:63
GeoModelSvc::clear
virtual StatusCode clear() override
Definition: GeoModelSvc.cxx:582
ATLAS_NOT_THREAD_SAFE
StatusCode GeoModelSvc::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: GeoModelSvc.cxx:36
GeoModelSvc::m_forDetVersionOverride
Gaudi::Property< std::string > m_forDetVersionOverride
Definition: GeoModelSvc.h:73
GeoModelSvc::m_pixelVersionOverride
Gaudi::Property< std::string > m_pixelVersionOverride
Definition: GeoModelSvc.h:64
GeoModelSvc::m_larVersionOverride
Gaudi::Property< std::string > m_larVersionOverride
Definition: GeoModelSvc.h:67
GeoModelSvc::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: GeoModelSvc.h:59
GeoModelSvc::m_pSvcLocator
ISvcLocator * m_pSvcLocator
Definition: GeoModelSvc.h:55
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
GeoModelSvc::m_tagInfoMgr
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Definition: GeoModelSvc.h:58
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
GeoDbTagSvc::setLAr_VersionOverride
void setLAr_VersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:32
RDBTagDetails
coral::AttributeList RDBTagDetails
Definition: IRDBAccessSvc.h:29
GeoDbTagSvc::setCavernInfraVersionOverride
void setCavernInfraVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:37
IGeoModelTool::create
virtual StatusCode create()=0
GeoModelSvc::m_cavInfraVersionOverride
Gaudi::Property< std::string > m_cavInfraVersionOverride
Definition: GeoModelSvc.h:72
GeoDbTagSvc::setSCT_VersionOverride
void setSCT_VersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:30
GeoDbTagSvc::setSqliteReader
void setSqliteReader(GeoModelIO::ReadGeoModel *reader)
Definition: GeoDbTagSvc.h:41
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
GeoDbTagSvc::setTRT_VersionOverride
void setTRT_VersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:31
GeoDbTagSvc::setPixelVersionOverride
void setPixelVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:29
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
IGeoModelTool
Definition: IGeoModelTool.h:12
GeoModelSvc::m_statisticsToFile
Gaudi::Property< bool > m_statisticsToFile
Definition: GeoModelSvc.h:79
GeoModelSvc::m_sqliteDb
Gaudi::Property< bool > m_sqliteDb
Definition: GeoModelSvc.h:84
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
GeoModelSvc.h
GeoDbTagSvc::setForwardDetectorsVersionOverride
void setForwardDetectorsVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:38
StoredMaterialManager
This class holds one or more material managers and makes them storeable, under StoreGate.
Definition: StoredMaterialManager.h:28
GeoModelSvc::geoInit
StatusCode geoInit()
Definition: GeoModelSvc.cxx:141
GeoDbTagSvc::setParamSvcName
void setParamSvcName(const std::string &name)
Definition: GeoDbTagSvc.h:40
GeoModelSvc::compareTags
StatusCode compareTags()
Definition: GeoModelSvc.cxx:339
GeoModelSvc::GeoModelSvc
GeoModelSvc(const std::string &name, ISvcLocator *svc)
Definition: GeoModelSvc.cxx:30
GeoModelSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: GeoModelSvc.h:57
GeoModelSvc::m_sqliteDbManager
std::unique_ptr< GMDBManager > m_sqliteDbManager
Definition: GeoModelSvc.h:88
GeoDbTagSvc::setupTags
StatusCode setupTags()
Definition: GeoDbTagSvc.cxx:30
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
GeoModelSvc::m_bFieldVersionOverride
Gaudi::Property< std::string > m_bFieldVersionOverride
Definition: GeoModelSvc.h:71
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
SG::DataProxy
Definition: DataProxy.h:44
GeoModelSvc::m_ignoreTagSupport
Gaudi::Property< bool > m_ignoreTagSupport
Definition: GeoModelSvc.h:82
getCpu
int getCpu()
Definition: SingleTrackValidation.cxx:60
GeoDbTagSvc::setCaloVersionOverride
void setCaloVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:35
GeoDbTagSvc::setMagFieldVersionOverride
void setMagFieldVersionOverride(const std::string &tag)
Definition: GeoDbTagSvc.h:36
ServiceHandle< IConversionSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
DataProxy.h
GeoModelSvc::m_ignoreTagDifference
Gaudi::Property< bool > m_ignoreTagDifference
Definition: GeoModelSvc.h:76