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