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)
31  : base_class(name,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 
124 {
125  GeoPhysVol* worldPhys{nullptr};
126  ServiceHandle<IRDBAccessSvc> rdbAccess("RDBAccessSvc",name());
127 
128  // Setup the GeoDbTagSvc
129  ATH_CHECK( m_geoDbTagSvc.retrieve() );
130 
131  GeoDbTagSvc* dbTagSvc = dynamic_cast<GeoDbTagSvc*>(m_geoDbTagSvc.get());
132  if(dbTagSvc==nullptr) {
133  ATH_MSG_FATAL("Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
134  return StatusCode::FAILURE;
135  }
136 
137  // Build geometry from the SQLiteDB file
138  if(m_sqliteDb) {
139  std::string sqliteDbName = "Geometry/" + m_atlasVersion + ".db";
140  std::string sqliteDbPath = m_sqliteDbFullPath.empty()
141  ? PathResolver::find_file (sqliteDbName, "CALIBPATH")
142  : m_sqliteDbFullPath.value();
143  if(sqliteDbPath.empty() && m_sqliteDbFullPath.empty()) {
144  ATH_MSG_FATAL("Failed to find SQLite database file " << sqliteDbName << " for reading in persistent GeoModel tree");
145  return StatusCode::FAILURE;
146  }
147  else {
148  ATH_MSG_INFO("Successfully located SQLite database file " << sqliteDbPath << " for reading in persistent GeoModel tree");
149  }
150  // Read raw geometry description from the file
151  m_sqliteDbManager = std::make_unique<GMDBManager>(sqliteDbPath);
152  if(m_sqliteDbManager->checkIsDBOpen()) {
153  ATH_MSG_INFO("Successfully opened SQLite DB file " << sqliteDbPath << " for reading in persistent GeoModel tree");
154  } else {
155  ATH_MSG_FATAL("Failed to open SQLite database " << sqliteDbPath << " for reading in persistent GeoModel tree");
156  return StatusCode::FAILURE;
157  }
158  m_sqliteReader = std::make_unique<GeoModelIO::ReadGeoModel>(m_sqliteDbManager.get());
159  GeoVPhysVol* vWorldPhys ATLAS_THREAD_SAFE = const_cast<GeoVPhysVol*>(m_sqliteReader->buildGeoModel());
160  worldPhys = dynamic_cast<GeoPhysVol*>(vWorldPhys);
161  if(!worldPhys) {
162  ATH_MSG_FATAL("Having Full Physical Volumes as World Volumes not supported!");
163  return StatusCode::FAILURE;
164  }
165  ATH_MSG_INFO("Successfully read persistent GeoModel description from the file");
166 
167  // Initialize SqliteReadSvc and open the file for reading plain SQLite tables with DetDescr parameters
168  ServiceHandle<IRDBAccessSvc> sqliteReadSvc("SqliteReadSvc",name());
169  ATH_CHECK(sqliteReadSvc.retrieve());
170  if(!sqliteReadSvc->connect(sqliteDbPath)) {
171  ATH_MSG_FATAL("Failed to open SQLite database file " << sqliteDbPath << " for reading geometry parameters");
172  return StatusCode::FAILURE;
173  } else {
174  ATH_MSG_INFO("Successfully opened SQLite DB file: " << sqliteDbPath << " for reading Det Descr parameters");
175  }
176  dbTagSvc->setParamSvcName("SqliteReadSvc");
177  dbTagSvc->setSqliteReader(m_sqliteReader.get());
178  if(dbTagSvc->setupConfig().isFailure()) {
179  ATH_MSG_FATAL("Failed to setup Geoconfig");
180  return StatusCode::FAILURE;
181  }
182  }
183  else {
184  // Build geometry from the GeometryDB
185  ATH_MSG_DEBUG("** Building geometry configuration: ");
186  ATH_MSG_DEBUG("* ATLAS tag: " << m_atlasVersion);
187  ATH_MSG_DEBUG("* InDet tag: " << m_inDetVersionOverride);
188  ATH_MSG_DEBUG("* Pixel tag: " << m_pixelVersionOverride);
189  ATH_MSG_DEBUG("* SCT tag: " << m_sctVersionOverride);
190  ATH_MSG_DEBUG("* TRT tag: " << m_trtVersionOverride);
191  ATH_MSG_DEBUG("* LAr tag: " << m_larVersionOverride);
192  ATH_MSG_DEBUG("* Tile tag: " << m_tileVersionOverride);
193  ATH_MSG_DEBUG("* Muon tag: " << m_muonVersionOverride);
194  ATH_MSG_DEBUG("* Calo tag: " << m_caloVersionOverride);
195  ATH_MSG_DEBUG("* MagField tag: " << m_bFieldVersionOverride);
196  ATH_MSG_DEBUG("* CavernInfra tag: " << m_cavInfraVersionOverride);
197  ATH_MSG_DEBUG("* ForwardDetectors tag: " << m_forDetVersionOverride);
198 
199  // Get RDBAccessSvc and open connection to DB
200  ATH_CHECK( rdbAccess.retrieve() );
201 
202  if(!rdbAccess->connect()) {
203  ATH_MSG_FATAL("Unable to connect to the Geometry DB");
204  return StatusCode::FAILURE;
205  }
206 
207  // Check the existence of ATLAS tag in the database
208  if(rdbAccess->getChildTag("ATLAS",m_atlasVersion,"ATLAS")=="") {
209  ATH_MSG_FATAL(" *** *** Wrong ATLAS layout: " << m_atlasVersion << " *** ***");
210  ATH_MSG_FATAL(" Either ATLAS geometry tag has been misspelled, or the DB Release does not contain the geometry specified.");
211  ATH_MSG_FATAL(" In latter case please update DB Release version");
212  return StatusCode::FAILURE;
213  }
214 
215  dbTagSvc->setParamSvcName("RDBAccessSvc");
216 
217  if(!m_ignoreTagSupport) {
218  RDBTagDetails atlasTagDetails;
219  rdbAccess->getTagDetails(atlasTagDetails, m_atlasVersion);
220  const coral::AttributeSpecification& supportedSpec = atlasTagDetails["SUPPORTED"].specification();
221  if(supportedSpec.type()==typeid(bool)) {
222  if(!atlasTagDetails["SUPPORTED"].data<bool>()) {
223  ATH_MSG_FATAL(" *** *** ATLAS layout " << m_atlasVersion << " is OBSOLETE and can NOT be supported any more! *** ***");
224  return StatusCode::FAILURE;
225  }
226  }
227  else if(supportedSpec.type()==typeid(int)) {
228  if(atlasTagDetails["SUPPORTED"].data<int>()<m_supportedGeometry) {
229  ATH_MSG_FATAL(" *** *** ATLAS layout " << m_atlasVersion
230  << " is OBSOLETE in rel " << m_supportedGeometry
231  << " and can NOT be supported any more! *** ***");
232  return StatusCode::FAILURE;
233  }
234  }
235  }
236 
237  dbTagSvc->setAtlasVersion(m_atlasVersion);
249 
250  if(dbTagSvc->setupTags().isFailure()) {
251  ATH_MSG_FATAL("Failed to setup subsystem tags");
252  return StatusCode::FAILURE;
253  }
254  if(dbTagSvc->setupConfig().isFailure()) {
255  ATH_MSG_FATAL("Failed to setup Geoconfig");
256  return StatusCode::FAILURE;
257  }
258 
259  // Create a material manager
260  StoredMaterialManager *theMaterialManager{nullptr};
261  try{
262  theMaterialManager = new RDBMaterialManager(m_pSvcLocator);
263  }
264  catch(std::runtime_error& e) {
265  ATH_MSG_FATAL(e.what());
266  return StatusCode::FAILURE;
267  }
268  ATH_CHECK( m_detStore->record(theMaterialManager,"MATERIALS") );
269 
270  // Build the world node from which everything else will be suspended
271  const GeoMaterial* air = theMaterialManager->getMaterial("std::Air");
272  const GeoBox* worldBox = new GeoBox(1000*Gaudi::Units::cm,1000*Gaudi::Units::cm, 1000*Gaudi::Units::cm);
273  const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, air);
274  worldPhys=new GeoPhysVol(worldLog);
275  } // End of the GeometryDB-specific part
276 
277  // Create AtlasExperiment and register it within the transient detector store
278  GeoModelExperiment* theExperiment = new GeoModelExperiment(worldPhys);
279  ATH_CHECK( m_detStore->record(theExperiment,"ATLAS") );
280 
281  int mem,cpu;
282  std::unique_ptr<std::ofstream> geoModelStats;
283  if(m_statisticsToFile) {
284  geoModelStats = std::make_unique<std::ofstream>("GeoModelStatistics");
285  *geoModelStats << "Detector Configuration flag = " << m_atlasVersion << std::endl;
286  }
287 
288  // Loop over all tools
290  itPrivEnd = m_detectorTools.end();
291 
292  for(; itPriv!=itPrivEnd; ++itPriv) {
293  IGeoModelTool* theTool = &(**itPriv);
294 
295  mem = GeoPerfUtils::getMem();
296  cpu = GeoPerfUtils::getCpu();
297 
298  ATH_CHECK(theTool->create());
299 
300  if(m_statisticsToFile) {
301  *geoModelStats << theTool->name() << "\t SZ= "
302  << GeoPerfUtils::getMem() - mem << "Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01 << "S" << std::endl;
303  }
304  else {
305  ATH_MSG_INFO(theTool->name() << "\t SZ= "
306  << GeoPerfUtils::getMem() - mem << "Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01 << "S");
307  }
308  }
309 
310  if(m_statisticsToFile) {
311  geoModelStats->close();
312  }
313 
314  if(!m_sqliteDb) {
315  // Close connection to the GeometryDB
316  rdbAccess->shutdown();
317  }
318 
319  return StatusCode::SUCCESS;
320 }
321 
322 
324 {
325  compareTags().ignore();
326 }
327 
328 
330 {
331  bool tagsMatch = true;
332 
333  ATH_MSG_DEBUG("in compareTags()");
334 
335  // Get tags from TagInfoMgr
336  const ITagInfoMgr::NameTagPairVec pairs = m_tagInfoMgr->getInputTags();
337  for( const auto& pair : pairs ) {
338  std::string tagPairName = pair.first;
339  if(tagPairName=="GeoAtlas") {
340  // ** Two possible cases need to be taken into account
341  // **
342  // ** 1. The retrieved ATLAS tag is following naming schema ATLAS-...-XX-YY-ZZ
343  // ** where '...' can be anything, it may also containg one or more '-'.
344  // ** If this is the case, then we need to check whether the job option tag
345  // ** is also following the same schema and they have the same 'ATLAS-...-XX' part
346  // **
347  // ** 2. The retrieved ATLAS tag is not following the schema mentioned above
348  // ** If this is the case, we just need to check the exact match
349  std::vector<std::string> tokensTagInfo, tokensJobOpt;
350 
351  // Parse Tag Info tag
352  std::string::size_type startpos = 0;
353  std::string currStr = pair.second;
354  for(std::string::size_type endpos=currStr.find('-'); endpos!=std::string::npos; endpos=currStr.find('-',startpos)) {
355  tokensTagInfo.push_back(currStr.substr(startpos,endpos-startpos));
356  startpos = endpos+1;
357  }
358  tokensTagInfo.push_back(currStr.substr(startpos));
359 
360  size_t tokensTagInfoSize = tokensTagInfo.size();
361  bool tagInfoFollowsTheScheme = (tokensTagInfoSize>=5
362  && tokensTagInfo[tokensTagInfoSize-1].size()==2
363  && tokensTagInfo[tokensTagInfoSize-2].size()==2
364  && tokensTagInfo[tokensTagInfoSize-3].size()==2);
365 
366  if(tagInfoFollowsTheScheme) {
367  // Parse Job Options tag
368  startpos = 0;
369  currStr = m_atlasVersion;
370  for(std::string::size_type endpos=currStr.find('-'); endpos!=std::string::npos; endpos=currStr.find('-',startpos)) {
371  tokensJobOpt.push_back(currStr.substr(startpos,endpos-startpos));
372  startpos = endpos+1;
373  }
374  tokensJobOpt.push_back(currStr.substr(startpos));
375 
376  size_t tokensJobOptSize = tokensJobOpt.size();
377  bool jobOptFollowsTheScheme = (tokensJobOptSize>=5
378  && tokensJobOpt[tokensJobOptSize-1].size()==2
379  && tokensJobOpt[tokensJobOptSize-2].size()==2
380  && tokensJobOpt[tokensJobOptSize-3].size()==2);
381  if(jobOptFollowsTheScheme) {
382  const std::string& atlasVersion = m_atlasVersion;
383  tagsMatch = (pair.second.substr(0,currStr.size()-6)==atlasVersion.substr(0,atlasVersion.size()-6));
384  }
385  else {
386  tagsMatch = false;
387  }
388  }
389  else {// Check for the exact match
390  tagsMatch = m_atlasVersion == pair.second;
391  }
392  }
393  else if(tagPairName=="GeoInDet")
394  tagsMatch = m_inDetVersionOverride == pair.second;
395  else if(tagPairName=="GeoPixel")
396  tagsMatch = m_pixelVersionOverride == pair.second;
397  else if(tagPairName=="GeoSCT")
398  tagsMatch = m_sctVersionOverride == pair.second;
399  else if(tagPairName=="GeoTRT")
400  tagsMatch = m_trtVersionOverride == pair.second;
401  else if(tagPairName=="GeoLAr")
402  tagsMatch = m_larVersionOverride == pair.second;
403  else if(tagPairName=="GeoTile")
404  tagsMatch = m_tileVersionOverride == pair.second;
405  else if(tagPairName=="GeoMuon")
406  tagsMatch = m_muonVersionOverride == pair.second;
407 
408  if(!tagsMatch) break;
409  }
410 
411  if(!tagsMatch) {
412  msg((m_ignoreTagDifference? MSG::WARNING : MSG::ERROR))
413  << "*** *** Geometry configured through jobOptions does not match TagInfo tags! *** ***" << endmsg;
414  ATH_MSG_INFO("** Job Option configuration: ");
415  ATH_MSG_INFO("* ATLAS tag: " << m_atlasVersion);
416  ATH_MSG_INFO("* InDet tag: " << m_inDetVersionOverride);
417  ATH_MSG_INFO("* Pixel tag: " << m_pixelVersionOverride);
418  ATH_MSG_INFO("* SCT tag: " << m_sctVersionOverride);
419  ATH_MSG_INFO("* TRT tag: " << m_trtVersionOverride);
420  ATH_MSG_INFO("* LAr tag: " << m_larVersionOverride);
421  ATH_MSG_INFO("* Tile tag: " << m_tileVersionOverride);
422  ATH_MSG_INFO("* Muon tag: " << m_muonVersionOverride);
423  ATH_MSG_INFO("* Calo tag: " << m_caloVersionOverride);
424  ATH_MSG_INFO("* MagField tag: " << m_bFieldVersionOverride);
425  ATH_MSG_INFO("* CavernInfra tag: " << m_cavInfraVersionOverride);
426  ATH_MSG_INFO("* ForwardDetectors tag: " << m_forDetVersionOverride);
427  ATH_MSG_INFO("** TAG INFO configuration: ");
428  for (const auto& pair : pairs) {
429  std::string tagPairName = pair.first;
430  if(tagPairName=="GeoAtlas")
431  ATH_MSG_INFO("* ATLAS tag: " << pair.second);
432  else if(tagPairName=="GeoInDet")
433  ATH_MSG_INFO("*InDet tag: " << pair.second);
434  else if(tagPairName=="GeoPixel")
435  ATH_MSG_INFO("*Pixel tag: " << pair.second);
436  else if(tagPairName=="GeoSCT")
437  ATH_MSG_INFO("*SCT tag: " << pair.second);
438  else if(tagPairName=="GeoTRT")
439  ATH_MSG_INFO("*TRT tag: " << pair.second);
440  else if(tagPairName=="GeoLAr")
441  ATH_MSG_INFO("*LAr tag: " << pair.second);
442  else if(tagPairName=="GeoTile")
443  ATH_MSG_INFO("*Tile tag: " << pair.second);
444  else if(tagPairName=="GeoMuon")
445  ATH_MSG_INFO("*Muon tag: " << pair.second);
446  else if(tagPairName=="GeoCalo")
447  ATH_MSG_INFO("*Calo tag: " << pair.second);
448  else if(tagPairName=="GeoMagField")
449  ATH_MSG_INFO("*MagField tag: " << pair.second);
450  else if(tagPairName=="GeoCavernInfra")
451  ATH_MSG_INFO("*CavernInfra tag: " << pair.second);
452  else if(tagPairName=="GeoForwardDetectors")
453  ATH_MSG_INFO("*ForwardDetectors tag: " << pair.second);
454  }
455 
456  if(!m_ignoreTagDifference) {
457  ATH_MSG_INFO("*** *** Please fix geometry tag settings *** ***");
458  return StatusCode::FAILURE;
459  }
460  }
461  else
462  ATH_MSG_DEBUG("Geometry configurations in jobOptions and TagInfo are consistent");
463 
464  return StatusCode::SUCCESS;
465 }
466 
467 /**********************************************************************************
468  ** Private Member Functions
469  **********************************************************************************/
471 {
472  if(m_atlasVersion == "") {
473  ATH_MSG_ERROR("ATLAS version is empty");
474  return StatusCode::FAILURE;
475  }
476 
477  if(m_tagInfoMgr->addTag("GeoAtlas",m_atlasVersion).isFailure()) {
478  ATH_MSG_ERROR("GeoModelSvc Atlas tag: " << m_atlasVersion << " not added to TagInfo ");
479  return StatusCode::FAILURE;
480  }
481 
482  if(m_inDetVersionOverride != "") {
483  if(m_tagInfoMgr->addTag("GeoInDet",m_inDetVersionOverride).isFailure()) {
484  ATH_MSG_ERROR("GeoModelSvc InDet tag: " << m_inDetVersionOverride << " not added to TagInfo ");
485  return StatusCode::FAILURE;
486  }
487  }
488 
489  if(m_pixelVersionOverride != "") {
490  if(m_tagInfoMgr->addTag("GeoPixel",m_pixelVersionOverride).isFailure()) {
491  ATH_MSG_ERROR("GeoModelSvc Pixel tag: " << m_pixelVersionOverride << " not added to TagInfo ");
492  return StatusCode::FAILURE;
493  }
494  }
495 
496  if(m_sctVersionOverride != "") {
497  if(m_tagInfoMgr->addTag("GeoSCT",m_sctVersionOverride).isFailure()) {
498  ATH_MSG_ERROR("GeoModelSvc SCT tag: " << m_sctVersionOverride << " not added to TagInfo ");
499  return StatusCode::FAILURE;
500  }
501  }
502 
503  if(m_trtVersionOverride != "") {
504  if(m_tagInfoMgr->addTag("GeoTRT",m_trtVersionOverride).isFailure()) {
505  ATH_MSG_ERROR("GeoModelSvc TRT tag: " << m_trtVersionOverride << " not added to TagInfo ");
506  return StatusCode::FAILURE;
507  }
508  }
509 
510  if(m_larVersionOverride != "") {
511  if(m_tagInfoMgr->addTag("GeoLAr",m_larVersionOverride).isFailure()) {
512  ATH_MSG_ERROR("GeoModelSvc LAr tag: " << m_larVersionOverride << " not added to TagInfo ");
513  return StatusCode::FAILURE;
514  }
515  }
516 
517  if(m_tileVersionOverride != "") {
518  if(m_tagInfoMgr->addTag("GeoTile",m_tileVersionOverride).isFailure()) {
519  ATH_MSG_ERROR("GeoModelSvc Tile tag: " << m_tileVersionOverride << " not added to TagInfo ");
520  return StatusCode::FAILURE;
521  }
522  }
523 
524  if(m_muonVersionOverride != "") {
525  if(m_tagInfoMgr->addTag("GeoMuon",m_muonVersionOverride).isFailure()) {
526  ATH_MSG_ERROR("GeoModelSvc Muon tag: " << m_muonVersionOverride << " not added to TagInfo ");
527  return StatusCode::FAILURE;
528  }
529  }
530 
531  if(m_caloVersionOverride != "") {
532  if(m_tagInfoMgr->addTag("GeoCalo",m_caloVersionOverride).isFailure()) {
533  ATH_MSG_ERROR("GeoModelSvc Calo tag: " << m_caloVersionOverride << " not added to TagInfo ");
534  return StatusCode::FAILURE;
535  }
536  }
537 
538  if(m_bFieldVersionOverride != "") {
539  if(m_tagInfoMgr->addTag("GeoMagField",m_bFieldVersionOverride).isFailure()) {
540  ATH_MSG_ERROR("GeoModelSvc MagField tag: " << m_bFieldVersionOverride << " not added to TagInfo ");
541  return StatusCode::FAILURE;
542  }
543  }
544 
545  if(m_cavInfraVersionOverride != "") {
546  if(m_tagInfoMgr->addTag("GeoCavernInfra",m_cavInfraVersionOverride).isFailure()) {
547  ATH_MSG_ERROR("GeoModelSvc CavernInfra tag: " << m_cavInfraVersionOverride << " not added to TagInfo ");
548  return StatusCode::FAILURE;
549  }
550  }
551 
552  if(m_forDetVersionOverride != "") {
553  if(m_tagInfoMgr->addTag("GeoForwardDetectors",m_forDetVersionOverride).isFailure()) {
554  ATH_MSG_ERROR("GeoModelSvc ForwardDetectors tag: " << m_forDetVersionOverride << " not added to TagInfo ");
555  return StatusCode::FAILURE;
556  }
557  }
558 
559  return StatusCode::SUCCESS;
560 }
561 
562 const IGeoModelTool* GeoModelSvc::getTool(std::string toolName) const
563 {
564  for (const ToolHandle<IGeoModelTool>& tool : m_detectorTools) {
565  if(tool->name().find(toolName)!=std::string::npos)
566  return tool.get();
567  }
568 
569  return 0;
570 }
571 
573 {
574  ATH_MSG_DEBUG("In clear()");
575 
576  // Call clear() for all tools
577  for (ToolHandle<IGeoModelTool>& tool : m_detectorTools) {
578  if(tool->clear().isFailure()) {
579  ATH_MSG_ERROR("clear() failed for the tool: " << tool->name());
580  return StatusCode::FAILURE;
581  } else {
582  ATH_MSG_DEBUG(tool->name() << " tool released");
583  }
584  }
585 
586  // Delete GeoModelExperiment - cascade delete of the entire GeoModel tree
587  std::vector<std::string> sgkeysExp;
588  m_detStore->keys<GeoModelExperiment>(sgkeysExp);
589  for (const std::string& key : sgkeysExp) {
591  if(proxy) {
592  proxy->reset();
593  ATH_MSG_DEBUG(key << " GeoModel experiment released");
594  }
595  }
596 
597  // Release stored material manager
598  std::vector<std::string> sgkeysMat;
599  m_detStore->keys<StoredMaterialManager>(sgkeysMat);
600  for (const std::string& key : sgkeysMat) {
602  if(proxy) {
603  proxy->reset();
604  ATH_MSG_DEBUG(key << " material manager released");
605  }
606  }
607 
608  return StatusCode::SUCCESS;
609 }
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:59
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
GeoModelSvc::m_tileVersionOverride
Gaudi::Property< std::string > m_tileVersionOverride
Definition: GeoModelSvc.h:62
GeoModelSvc::m_muonVersionOverride
Gaudi::Property< std::string > m_muonVersionOverride
Definition: GeoModelSvc.h:63
GeoDbTagSvc
Definition: GeoDbTagSvc.h:16
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:60
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GeoModelSvc::m_sqliteDbFullPath
Gaudi::Property< std::string > m_sqliteDbFullPath
Definition: GeoModelSvc.h:81
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
GeoDbTagSvc::setupConfig
StatusCode setupConfig()
Definition: GeoDbTagSvc.cxx:93
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:562
initialize
void initialize()
Definition: run_EoverP.cxx:894
GeoModelSvc::tagInfoUpdated
virtual void tagInfoUpdated() override final
Callback from TagInfoMgr on TagInfo change.
Definition: GeoModelSvc.cxx:323
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:87
GeoModelSvc::m_supportedGeometry
Gaudi::Property< int > m_supportedGeometry
Definition: GeoModelSvc.h:75
RDBMaterialManager
Definition: RDBMaterialManager.h:28
GeoModelSvc::fillTagInfo
StatusCode fillTagInfo() const
Definition: GeoModelSvc.cxx:470
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:55
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:84
GeoModelSvc::m_detectorTools
ToolHandleArray< IGeoModelTool > m_detectorTools
Definition: GeoModelSvc.h:47
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:66
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
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:64
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:57
GeoModelSvc::clear
virtual StatusCode clear() override
Definition: GeoModelSvc.cxx:572
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:67
GeoModelSvc::m_pixelVersionOverride
Gaudi::Property< std::string > m_pixelVersionOverride
Definition: GeoModelSvc.h:58
GeoModelSvc::m_larVersionOverride
Gaudi::Property< std::string > m_larVersionOverride
Definition: GeoModelSvc.h:61
GeoModelSvc::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: GeoModelSvc.h:53
GeoModelSvc::m_pSvcLocator
ISvcLocator * m_pSvcLocator
Definition: GeoModelSvc.h:49
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
GeoModelSvc::m_tagInfoMgr
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Definition: GeoModelSvc.h:52
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:66
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
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:73
GeoModelSvc::m_sqliteDb
Gaudi::Property< bool > m_sqliteDb
Definition: GeoModelSvc.h:80
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:123
GeoDbTagSvc::setParamSvcName
void setParamSvcName(const std::string &name)
Definition: GeoDbTagSvc.h:40
GeoModelSvc::compareTags
StatusCode compareTags()
Definition: GeoModelSvc.cxx:329
GeoModelSvc::GeoModelSvc
GeoModelSvc(const std::string &name, ISvcLocator *svc)
Definition: GeoModelSvc.cxx:30
GeoModelSvc::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: GeoModelSvc.h:51
GeoModelSvc::m_sqliteDbManager
std::unique_ptr< GMDBManager > m_sqliteDbManager
Definition: GeoModelSvc.h:85
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:65
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
SG::DataProxy
Definition: DataProxy.h:45
GeoModelSvc::m_ignoreTagSupport
Gaudi::Property< bool > m_ignoreTagSupport
Definition: GeoModelSvc.h:76
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
getCpu
int getCpu()
Definition: SingleTrackValidation.cxx:53
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:70