10#include "GaudiKernel/ConcurrencyFlags.h"
11#include "GaudiKernel/IConversionSvc.h"
12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/SystemOfUnits.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"
38 "The Supported Geometry flag was not set in Job Options! Exiting ...");
39 return StatusCode::FAILURE;
54 Service *convSvc =
dynamic_cast<Service *
>(conversionSvc.get());
57 return StatusCode::FAILURE;
59 if (convSvc->FSMState() < Gaudi::StateMachine::INITIALIZED) {
84 return StatusCode::SUCCESS;
89 return StatusCode::SUCCESS;
93 PVLink worldPhys{
nullptr};
100 if (dbTagSvc ==
nullptr) {
101 ATH_MSG_FATAL(
"Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
102 return StatusCode::FAILURE;
108 std::string sqliteDbPath =
115 <<
" for reading in persistent GeoModel tree");
116 return StatusCode::FAILURE;
118 ATH_MSG_INFO(
"Successfully located SQLite database file "
119 << sqliteDbPath <<
" for reading in persistent GeoModel tree");
125 <<
" for reading in persistent GeoModel tree");
126 return StatusCode::FAILURE;
128 GeoThreading::ThreadPool::getPool(
m_nTheads);
130 "Successfully opened SQLite DB file "
131 << sqliteDbPath <<
" for reading in persistent GeoModel tree using "
132 << GeoThreading::ThreadPool::getPool().nThreads() <<
" threads.");
136 worldPhys = const_pointer_cast(vWorldPhys);
139 "Having Full Physical Volumes as World Volumes not supported!");
140 return StatusCode::FAILURE;
143 "Successfully read persistent GeoModel description from the file");
149 if (!sqliteReadSvc->connect(sqliteDbPath)) {
151 << sqliteDbPath <<
" for reading geometry parameters");
152 return StatusCode::FAILURE;
155 << sqliteDbPath <<
" for reading Det Descr parameters");
161 return StatusCode::FAILURE;
182 if (!rdbAccess->connect()) {
184 return StatusCode::FAILURE;
188 if (rdbAccess->getChildTag(
"ATLAS",
m_atlasVersion,
"ATLAS") ==
"") {
192 " Either ATLAS geometry tag has been misspelled, or the DB Release "
193 "does not contain the geometry specified.");
194 ATH_MSG_FATAL(
" In latter case please update DB Release version");
195 return StatusCode::FAILURE;
203 const coral::AttributeSpecification &supportedSpec =
204 atlasTagDetails[
"SUPPORTED"].specification();
205 if (supportedSpec.type() ==
typeid(
bool)) {
206 if (!atlasTagDetails[
"SUPPORTED"].
data<bool>()) {
208 " *** *** ATLAS layout "
210 <<
" is OBSOLETE and can NOT be supported any more! *** ***");
211 return StatusCode::FAILURE;
213 }
else if (supportedSpec.type() ==
typeid(
int)) {
218 <<
" and can NOT be supported any more! *** ***");
219 return StatusCode::FAILURE;
239 return StatusCode::FAILURE;
243 return StatusCode::FAILURE;
247 std::unique_ptr<StoredMaterialManager> theMaterialManager{};
249 theMaterialManager = std::make_unique<RDBMaterialManager>(
m_pSvcLocator);
250 }
catch (std::runtime_error &e) {
252 return StatusCode::FAILURE;
256 worldPhys = createGeoWorld();
261 std::make_unique<GeoModelExperiment>(std::move(worldPhys));
267 geoModelStats <<
"Detector Configuration flag = " <<
m_atlasVersion
273 mem = GeoPerfUtils::getMem();
274 cpu = GeoPerfUtils::getCpu();
279 geoModelStats << theTool->name()
280 <<
"\t SZ= " << GeoPerfUtils::getMem() - mem
281 <<
"Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01
285 <<
"\t SZ= " << GeoPerfUtils::getMem() - mem
286 <<
"Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01
293 rdbAccess->shutdown();
296 return StatusCode::SUCCESS;
304 bool tagsMatch =
true;
310 for (
const auto &
pair : pairs) {
311 std::string tagPairName =
pair.first;
312 if (tagPairName ==
"GeoAtlas") {
326 std::vector<std::string> tokensTagInfo, tokensJobOpt;
329 std::string::size_type startpos = 0;
330 std::string currStr =
pair.second;
331 for (std::string::size_type endpos = currStr.find(
'-');
332 endpos != std::string::npos; endpos = currStr.find(
'-', startpos)) {
333 tokensTagInfo.push_back(currStr.substr(startpos, endpos - startpos));
334 startpos = endpos + 1;
336 tokensTagInfo.push_back(currStr.substr(startpos));
338 size_t tokensTagInfoSize = tokensTagInfo.size();
339 bool tagInfoFollowsTheScheme =
340 (tokensTagInfoSize >= 5 &&
341 tokensTagInfo[tokensTagInfoSize - 1].size() == 2 &&
342 tokensTagInfo[tokensTagInfoSize - 2].size() == 2 &&
343 tokensTagInfo[tokensTagInfoSize - 3].size() == 2);
345 if (tagInfoFollowsTheScheme) {
349 for (std::string::size_type endpos = currStr.find(
'-');
350 endpos != std::string::npos;
351 endpos = currStr.find(
'-', startpos)) {
352 tokensJobOpt.push_back(currStr.substr(startpos, endpos - startpos));
353 startpos = endpos + 1;
355 tokensJobOpt.push_back(currStr.substr(startpos));
357 size_t tokensJobOptSize = tokensJobOpt.size();
358 bool jobOptFollowsTheScheme =
359 (tokensJobOptSize >= 5 &&
360 tokensJobOpt[tokensJobOptSize - 1].size() == 2 &&
361 tokensJobOpt[tokensJobOptSize - 2].size() == 2 &&
362 tokensJobOpt[tokensJobOptSize - 3].size() == 2);
363 if (jobOptFollowsTheScheme) {
365 tagsMatch = (
pair.second.substr(0, currStr.size() - 6) ==
373 }
else if (tagPairName ==
"GeoInDet")
375 else if (tagPairName ==
"GeoPixel")
377 else if (tagPairName ==
"GeoSCT")
379 else if (tagPairName ==
"GeoTRT")
381 else if (tagPairName ==
"GeoLAr")
383 else if (tagPairName ==
"GeoTile")
385 else if (tagPairName ==
"GeoMuon")
394 <<
"*** *** Geometry configured through jobOptions does not match "
395 "TagInfo tags! *** ***"
411 for (
const auto &
pair : pairs) {
412 const std::string &tagPairName =
pair.first;
413 if (tagPairName ==
"GeoAtlas") {
415 }
else if (tagPairName ==
"GeoInDet") {
417 }
else if (tagPairName ==
"GeoPixel") {
419 }
else if (tagPairName ==
"GeoSCT") {
421 }
else if (tagPairName ==
"GeoTRT") {
423 }
else if (tagPairName ==
"GeoLAr") {
425 }
else if (tagPairName ==
"GeoTile") {
427 }
else if (tagPairName ==
"GeoMuon") {
429 }
else if (tagPairName ==
"GeoCalo") {
431 }
else if (tagPairName ==
"GeoMagField") {
433 }
else if (tagPairName ==
"GeoCavernInfra") {
435 }
else if (tagPairName ==
"GeoForwardDetectors") {
441 ATH_MSG_INFO(
"*** *** Please fix geometry tag settings *** ***");
442 return StatusCode::FAILURE;
446 "Geometry configurations in jobOptions and TagInfo are consistent");
448 return StatusCode::SUCCESS;
457 return StatusCode::FAILURE;
462 <<
" not added to TagInfo ");
463 return StatusCode::FAILURE;
469 <<
" not added to TagInfo ");
470 return StatusCode::FAILURE;
477 <<
" not added to TagInfo ");
478 return StatusCode::FAILURE;
485 <<
" not added to TagInfo ");
486 return StatusCode::FAILURE;
493 <<
" not added to TagInfo ");
494 return StatusCode::FAILURE;
501 <<
" not added to TagInfo ");
502 return StatusCode::FAILURE;
509 <<
" not added to TagInfo ");
510 return StatusCode::FAILURE;
517 <<
" not added to TagInfo ");
518 return StatusCode::FAILURE;
525 <<
" not added to TagInfo ");
526 return StatusCode::FAILURE;
534 <<
" not added to TagInfo ");
535 return StatusCode::FAILURE;
544 return StatusCode::FAILURE;
553 return StatusCode::FAILURE;
557 return StatusCode::SUCCESS;
562 if (tool->name().find(toolName) != std::string::npos)
574 if (tool->clear().isFailure()) {
575 ATH_MSG_ERROR(
"clear() failed for the tool: " << tool->name());
576 return StatusCode::FAILURE;
583 std::vector<std::string> sgkeysExp;
585 for (
const std::string &key : sgkeysExp) {
595 std::vector<std::string> sgkeysMat;
597 for (
const std::string &key : sgkeysMat) {
608 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
char data[hepevt_bytes_allocation_ATLAS]
Definition of the abstract IRDBAccessSvc interface.
coral::AttributeList RDBTagDetails
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Gaudi::Property< bool > m_ignoreTagSupport
virtual void tagInfoUpdated() override final
Callback from TagInfoMgr on TagInfo change.
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_muonVersionOverride
Gaudi::Property< std::string > m_atlasVersion
virtual const IGeoModelTool * getTool(std::string toolName) const override
Gaudi::Property< unsigned > m_nTheads
Gaudi::Property< int > m_supportedGeometry
std::unique_ptr< GeoModelIO::ReadGeoModel > m_sqliteReader
Gaudi::Property< std::string > m_larVersionOverride
Gaudi::Property< std::string > m_bFieldVersionOverride
ServiceHandle< StoreGateSvc > m_detStore
Gaudi::Property< std::string > m_sqliteDbFullPath
Gaudi::Property< std::string > m_tileVersionOverride
Gaudi::Property< std::string > m_trtVersionOverride
StatusCode fillTagInfo() const
virtual const std::string & atlasVersion() const override
Gaudi::Property< bool > m_ignoreTagDifference
Gaudi::Property< bool > m_sqliteDb
virtual StatusCode finalize() override
Gaudi::Property< std::string > m_forDetVersionOverride
ISvcLocator * m_pSvcLocator
Gaudi::Property< bool > m_checkTagInfo
Gaudi::Property< std::string > m_inDetVersionOverride
GeoModelSvc(const std::string &name, ISvcLocator *svc)
Gaudi::Property< std::string > m_caloVersionOverride
Gaudi::Property< std::string > m_pixelVersionOverride
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
std::shared_ptr< GMDBManager > m_sqliteDbManager
ToolHandleArray< IGeoModelTool > m_detectorTools
Gaudi::Property< std::string > m_sctVersionOverride
Gaudi::Property< std::string > m_cavInfraVersionOverride
Gaudi::Property< bool > m_statisticsToFile
virtual StatusCode clear() override
Gaudi::Property< bool > m_useTagInfo
std::vector< NameTagPair > NameTagPairVec
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.